mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-06 18:57:26 +01:00
Merge new features from 4.2.3 to 4.2.5.
This commit is contained in:
commit
ff7281aa89
@ -6,8 +6,8 @@ android {
|
||||
applicationId "ml.docilealligator.infinityforreddit"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 30
|
||||
versionCode 57
|
||||
versionName "4.2.2"
|
||||
versionCode 60
|
||||
versionName "4.2.5"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
@ -32,6 +32,12 @@ android {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
bundle {
|
||||
language {
|
||||
enableSplit = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package ml.docilealligator.infinityforreddit;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@ -13,6 +15,7 @@ import java.util.Map;
|
||||
import ml.docilealligator.infinityforreddit.account.Account;
|
||||
import ml.docilealligator.infinityforreddit.apis.RedditAPI;
|
||||
import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
import okhttp3.Authenticator;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.Request;
|
||||
@ -24,10 +27,12 @@ import retrofit2.Retrofit;
|
||||
class AccessTokenAuthenticator implements Authenticator {
|
||||
private Retrofit mRetrofit;
|
||||
private RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||
private SharedPreferences mCurrentAccountSharedPreferences;
|
||||
|
||||
AccessTokenAuthenticator(Retrofit retrofit, RedditDataRoomDatabase accountRoomDatabase) {
|
||||
AccessTokenAuthenticator(Retrofit retrofit, RedditDataRoomDatabase accountRoomDatabase, SharedPreferences currentAccountSharedPreferences) {
|
||||
mRetrofit = retrofit;
|
||||
mRedditDataRoomDatabase = accountRoomDatabase;
|
||||
mCurrentAccountSharedPreferences = currentAccountSharedPreferences;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -77,6 +82,9 @@ class AccessTokenAuthenticator implements Authenticator {
|
||||
} else {
|
||||
mRedditDataRoomDatabase.accountDao().updateAccessTokenAndRefreshToken(account.getAccountName(), newAccessToken, newRefreshToken);
|
||||
}
|
||||
if (mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "").equals(account.getAccountName())) {
|
||||
mCurrentAccountSharedPreferences.edit().putString(SharedPreferencesUtils.ACCESS_TOKEN, newAccessToken).apply();
|
||||
}
|
||||
|
||||
return newAccessToken;
|
||||
}
|
||||
|
@ -144,9 +144,10 @@ class AppModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
OkHttpClient provideOkHttpClient(@Named("no_oauth") Retrofit retrofit, RedditDataRoomDatabase accountRoomDatabase) {
|
||||
OkHttpClient provideOkHttpClient(@Named("no_oauth") Retrofit retrofit, RedditDataRoomDatabase accountRoomDatabase,
|
||||
@Named("current_account") SharedPreferences currentAccountSharedPreferences) {
|
||||
OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient.Builder();
|
||||
okHttpClientBuilder.authenticator(new AccessTokenAuthenticator(retrofit, accountRoomDatabase))
|
||||
okHttpClientBuilder.authenticator(new AccessTokenAuthenticator(retrofit, accountRoomDatabase, currentAccountSharedPreferences))
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.writeTimeout(30, TimeUnit.SECONDS)
|
||||
|
@ -56,6 +56,9 @@ public class PullNotificationWorker extends Worker {
|
||||
@Named("default")
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
@Named("current_account")
|
||||
SharedPreferences mCurrentAccountSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
private Context context;
|
||||
|
||||
@ -255,6 +258,9 @@ public class PullNotificationWorker extends Worker {
|
||||
} else {
|
||||
mRedditDataRoomDatabase.accountDao().updateAccessTokenAndRefreshToken(account.getAccountName(), newAccessToken, newRefreshToken);
|
||||
}
|
||||
if (mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "").equals(account.getAccountName())) {
|
||||
mCurrentAccountSharedPreferences.edit().putString(SharedPreferencesUtils.ACCESS_TOKEN, newAccessToken).apply();
|
||||
}
|
||||
return newAccessToken;
|
||||
}
|
||||
return "";
|
||||
|
@ -11,6 +11,7 @@ import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.InflateException;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
@ -20,8 +21,11 @@ import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import org.json.JSONException;
|
||||
@ -53,6 +57,8 @@ import retrofit2.Retrofit;
|
||||
|
||||
public class LoginActivity extends BaseActivity {
|
||||
|
||||
private static final String ENABLE_DOM_STATE = "EDS";
|
||||
|
||||
@BindView(R.id.coordinator_layout_login_activity)
|
||||
CoordinatorLayout coordinatorLayout;
|
||||
@BindView(R.id.appbar_layout_login_activity)
|
||||
@ -63,6 +69,8 @@ public class LoginActivity extends BaseActivity {
|
||||
TextView twoFAInfoTextView;
|
||||
@BindView(R.id.webview_login_activity)
|
||||
WebView webView;
|
||||
@BindView(R.id.fab_login_activity)
|
||||
FloatingActionButton fab;
|
||||
@Inject
|
||||
@Named("no_oauth")
|
||||
Retrofit mRetrofit;
|
||||
@ -82,6 +90,7 @@ public class LoginActivity extends BaseActivity {
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private String authCode;
|
||||
private boolean enableDom = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -112,7 +121,28 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
enableDom = savedInstanceState.getBoolean(ENABLE_DOM_STATE);
|
||||
}
|
||||
|
||||
fab.setOnClickListener(view -> {
|
||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||
.setTitle(R.string.have_trouble_login_title)
|
||||
.setMessage(R.string.have_trouble_login_message)
|
||||
.setPositiveButton(R.string.yes, (dialogInterface, i) -> {
|
||||
enableDom = !enableDom;
|
||||
ActivityCompat.recreate(this);
|
||||
})
|
||||
.setNegativeButton(R.string.no, null)
|
||||
.show();
|
||||
});
|
||||
|
||||
if (enableDom) {
|
||||
twoFAInfoTextView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
webView.getSettings().setDomStorageEnabled(enableDom);
|
||||
|
||||
Uri baseUri = Uri.parse(APIUtils.OAUTH_URL);
|
||||
Uri.Builder uriBuilder = baseUri.buildUpon();
|
||||
@ -231,6 +261,12 @@ public class LoginActivity extends BaseActivity {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(ENABLE_DOM_STATE, enableDom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SharedPreferences getDefaultSharedPreferences() {
|
||||
return mSharedPreferences;
|
||||
@ -248,6 +284,7 @@ public class LoginActivity extends BaseActivity {
|
||||
twoFAInfoTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||
Drawable infoDrawable = Utils.getTintedDrawable(this, R.drawable.ic_info_preference_24dp, mCustomThemeWrapper.getPrimaryIconColor());
|
||||
twoFAInfoTextView.setCompoundDrawablesWithIntrinsicBounds(infoDrawable, null, null, null);
|
||||
applyFABTheme(fab);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -520,7 +520,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchSubredditDataFail() {
|
||||
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||
makeSnackbar(R.string.cannot_fetch_subreddit_info, true);
|
||||
mFetchSubredditInfoSuccess = false;
|
||||
}
|
||||
|
@ -346,4 +346,7 @@ public interface RedditAPI {
|
||||
Call<String> addSubredditToMultiReddit(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params,
|
||||
@Path(value = "multipath", encoded = true) String multipath, @Path("subredditName") String subredditName);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("/api/quarantine_optin?raw_json=1")
|
||||
Call<String> optInQuarantinedSubreddit(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class LoadSubredditIcon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchSubredditDataFail() {
|
||||
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||
loadSubredditIconAsyncTaskListener.loadIconSuccess(null);
|
||||
}
|
||||
}));
|
||||
|
@ -9,6 +9,7 @@ import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -247,12 +248,13 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
|
||||
bindView(resources);
|
||||
new Handler().postDelayed(() -> bindView(resources), 0);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
private void bindView(Resources resources) {
|
||||
if (mActivity != null && !mActivity.isFinishing() && !mActivity.isDestroyed()) {
|
||||
mLinearLayoutManager = new LinearLayoutManager(mActivity);
|
||||
mCommentRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||
|
||||
@ -328,6 +330,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
||||
|
||||
mSwipeRefreshLayout.setOnRefreshListener(() -> mCommentViewModel.refresh());
|
||||
}
|
||||
}
|
||||
|
||||
public void changeSortType(SortType sortType) {
|
||||
mCommentViewModel.changeSortType(sortType);
|
||||
|
@ -199,7 +199,7 @@ public class SidebarFragment extends Fragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchSubredditDataFail() {
|
||||
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
Toast.makeText(activity, R.string.cannot_fetch_sidebar, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
@ -1200,7 +1200,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchSubredditDataFail() {
|
||||
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||
mRespectSubredditRecommendedSortType = false;
|
||||
ViewPostDetailFragment.this.sortType = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT, SortType.Type.BEST.value.toUpperCase());
|
||||
if (ViewPostDetailFragment.this.sortType != null) {
|
||||
|
@ -403,7 +403,7 @@ public class ParsePost {
|
||||
if (gfycatId.contains("-")) {
|
||||
gfycatId = gfycatId.substring(0, gfycatId.indexOf('-'));
|
||||
}
|
||||
post.setGfycatId(gfycatId);
|
||||
post.setGfycatId(gfycatId.toLowerCase());
|
||||
} else if (authority != null && authority.contains("redgifs.com")) {
|
||||
String gfycatId = url.substring(url.lastIndexOf("/") + 1);
|
||||
if (gfycatId.contains("-")) {
|
||||
@ -411,7 +411,7 @@ public class ParsePost {
|
||||
}
|
||||
post.setIsRedgifs(true);
|
||||
post.setVideoUrl(url);
|
||||
post.setGfycatId(gfycatId);
|
||||
post.setGfycatId(gfycatId.toLowerCase());
|
||||
}
|
||||
} catch (IllegalArgumentException ignore) { }
|
||||
} else if (post.getPostType() == Post.LINK_TYPE || post.getPostType() == Post.NO_PREVIEW_LINK_TYPE) {
|
||||
@ -449,16 +449,21 @@ public class ParsePost {
|
||||
} else if (post.getPostType() == Post.LINK_TYPE) {
|
||||
Uri uri = Uri.parse(url);
|
||||
String authority = uri.getAuthority();
|
||||
|
||||
// Gyfcat ids must be lowercase to resolve to a video through the api, we are not
|
||||
// guaranteed to get an id that is all lowercase.
|
||||
String gfycatId = url.substring(url.lastIndexOf("/") + 1).toLowerCase();
|
||||
|
||||
if (authority != null && (authority.contains("gfycat.com"))) {
|
||||
post.setPostType(Post.VIDEO_TYPE);
|
||||
post.setIsGfycat(true);
|
||||
post.setVideoUrl(url);
|
||||
post.setGfycatId(url.substring(url.lastIndexOf("/") + 1));
|
||||
post.setGfycatId(gfycatId);
|
||||
} else if (authority != null && authority.contains("redgifs.com")) {
|
||||
post.setPostType(Post.VIDEO_TYPE);
|
||||
post.setIsRedgifs(true);
|
||||
post.setVideoUrl(url);
|
||||
post.setGfycatId(url.substring(url.lastIndexOf("/") + 1));
|
||||
post.setGfycatId(gfycatId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ public class PostFilter implements Parcelable {
|
||||
if (postFilter.postTitleExcludesStrings != null && !postFilter.postTitleExcludesStrings.equals("")) {
|
||||
String[] titles = postFilter.postTitleExcludesStrings.split(",", 0);
|
||||
for (String t : titles) {
|
||||
if (!t.equals("") && post.getTitle().toLowerCase().contains(t.toLowerCase())) {
|
||||
if (!t.trim().equals("") && post.getTitle().toLowerCase().contains(t.toLowerCase().trim())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -178,7 +178,7 @@ public class PostFilter implements Parcelable {
|
||||
if (postFilter.excludeSubreddits != null && !postFilter.excludeSubreddits.equals("")) {
|
||||
String[] subreddits = postFilter.excludeSubreddits.split(",", 0);
|
||||
for (String s : subreddits) {
|
||||
if (!s.equals("") && post.getSubredditName().equalsIgnoreCase(s)) {
|
||||
if (!s.trim().equals("") && post.getSubredditName().equalsIgnoreCase(s.trim())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -186,7 +186,7 @@ public class PostFilter implements Parcelable {
|
||||
if (postFilter.excludeUsers != null && !postFilter.excludeUsers.equals("")) {
|
||||
String[] users = postFilter.excludeUsers.split(",", 0);
|
||||
for (String u : users) {
|
||||
if (!u.equals("") && post.getAuthor().equalsIgnoreCase(u)) {
|
||||
if (!u.trim().equals("") && post.getAuthor().equalsIgnoreCase(u.trim())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -194,7 +194,7 @@ public class PostFilter implements Parcelable {
|
||||
if (postFilter.excludeFlairs != null && !postFilter.excludeFlairs.equals("")) {
|
||||
String[] flairs = postFilter.excludeFlairs.split(",", 0);
|
||||
for (String f : flairs) {
|
||||
if (!f.equals("") && post.getFlair().equalsIgnoreCase(f)) {
|
||||
if (!f.trim().equals("") && post.getFlair().equalsIgnoreCase(f.trim())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -202,7 +202,7 @@ public class PostFilter implements Parcelable {
|
||||
if (postFilter.containFlairs != null && !postFilter.containFlairs.equals("")) {
|
||||
String[] flairs = postFilter.containFlairs.split(",", 0);
|
||||
for (String f : flairs) {
|
||||
if (!f.equals("") && post.getFlair().equalsIgnoreCase(f)) {
|
||||
if (!f.trim().equals("") && post.getFlair().equalsIgnoreCase(f.trim())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -212,10 +212,10 @@ public class PostFilter implements Parcelable {
|
||||
}
|
||||
|
||||
public static PostFilter mergePostFilter(List<PostFilter> postFilterList) {
|
||||
PostFilter postFilter = new PostFilter();
|
||||
if (postFilterList.size() == 1) {
|
||||
return postFilterList.get(0);
|
||||
}
|
||||
PostFilter postFilter = new PostFilter();
|
||||
StringBuilder stringBuilder;
|
||||
postFilter.name = "Merged";
|
||||
for (PostFilter p : postFilterList) {
|
||||
@ -229,30 +229,39 @@ public class PostFilter implements Parcelable {
|
||||
postFilter.onlyNSFW = p.onlyNSFW ? p.onlyNSFW : postFilter.onlyNSFW;
|
||||
postFilter.onlySpoiler = p.onlySpoiler ? p.onlySpoiler : postFilter.onlySpoiler;
|
||||
|
||||
postFilter.postTitleExcludesRegex = p.postTitleExcludesRegex.equals("") ? postFilter.postTitleExcludesRegex : p.postTitleExcludesRegex;
|
||||
stringBuilder = new StringBuilder(postFilter.postTitleExcludesStrings);
|
||||
if (p.postTitleExcludesRegex != null && !p.postTitleExcludesRegex.equals("")) {
|
||||
postFilter.postTitleExcludesRegex = p.postTitleExcludesRegex;
|
||||
}
|
||||
|
||||
if (p.postTitleExcludesStrings != null && !p.postTitleExcludesStrings.equals("")) {
|
||||
stringBuilder = new StringBuilder(postFilter.postTitleExcludesStrings == null ? "" : postFilter.postTitleExcludesStrings);
|
||||
stringBuilder.append(",").append(p.postTitleExcludesStrings);
|
||||
postFilter.postTitleExcludesStrings = stringBuilder.toString();
|
||||
}
|
||||
|
||||
postFilter.excludeSubreddits = p.excludeSubreddits.equals("") ? postFilter.excludeSubreddits : p.postTitleExcludesRegex;
|
||||
stringBuilder = new StringBuilder(postFilter.excludeSubreddits);
|
||||
if (p.excludeSubreddits != null && !p.excludeSubreddits.equals("")) {
|
||||
stringBuilder = new StringBuilder(postFilter.excludeSubreddits == null ? "" : postFilter.excludeSubreddits);
|
||||
stringBuilder.append(",").append(p.excludeSubreddits);
|
||||
postFilter.excludeSubreddits = stringBuilder.toString();
|
||||
}
|
||||
|
||||
postFilter.excludeUsers = p.excludeUsers.equals("") ? postFilter.excludeUsers : p.postTitleExcludesRegex;
|
||||
stringBuilder = new StringBuilder(postFilter.excludeUsers);
|
||||
if (p.excludeUsers != null && !p.excludeUsers.equals("")) {
|
||||
stringBuilder = new StringBuilder(postFilter.excludeUsers == null ? "" : postFilter.excludeUsers);
|
||||
stringBuilder.append(",").append(p.excludeUsers);
|
||||
postFilter.excludeUsers = stringBuilder.toString();
|
||||
}
|
||||
|
||||
postFilter.containFlairs = p.containFlairs.equals("") ? postFilter.containFlairs : p.postTitleExcludesRegex;
|
||||
stringBuilder = new StringBuilder(postFilter.containFlairs);
|
||||
if (p.containFlairs != null && !p.containFlairs.equals("")) {
|
||||
stringBuilder = new StringBuilder(postFilter.containFlairs == null ? "" : postFilter.containFlairs);
|
||||
stringBuilder.append(",").append(p.containFlairs);
|
||||
postFilter.containFlairs = stringBuilder.toString();
|
||||
}
|
||||
|
||||
postFilter.excludeFlairs = p.excludeFlairs.equals("") ? postFilter.excludeFlairs : p.postTitleExcludesRegex;
|
||||
stringBuilder = new StringBuilder(postFilter.excludeFlairs);
|
||||
if (p.excludeFlairs != null && !p.excludeFlairs.equals("")) {
|
||||
stringBuilder = new StringBuilder(postFilter.excludeFlairs == null ? "" : postFilter.excludeFlairs);
|
||||
stringBuilder.append(",").append(p.excludeFlairs);
|
||||
postFilter.excludeFlairs = stringBuilder.toString();
|
||||
}
|
||||
|
||||
postFilter.containTextType = p.containTextType || postFilter.containTextType;
|
||||
postFilter.containLinkType = p.containLinkType || postFilter.containLinkType;
|
||||
|
@ -25,6 +25,7 @@ import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.Process;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
@ -207,17 +208,18 @@ public class DownloadRedditVideoService extends Service {
|
||||
updateNotification(R.string.downloading_reddit_video_audio_track, 0,
|
||||
randomNotificationIdOffset, null);
|
||||
|
||||
Response<ResponseBody> audioResponse = downloadFile.downloadFile(audioUrl).execute();
|
||||
if (audioResponse.isSuccessful() && audioResponse.body() != null) {
|
||||
String videoFilePath = externalCacheDirectoryPath + fileNameWithoutExtension + "-cache.mp4";
|
||||
String audioFilePath = externalCacheDirectoryPath + fileNameWithoutExtension + "-cache.mp3";
|
||||
String outputFilePath = externalCacheDirectoryPath + fileNameWithoutExtension + ".mp4";
|
||||
|
||||
String savedVideoFilePath = writeResponseBodyToDisk(videoResponse.body(), videoFilePath);
|
||||
if (savedVideoFilePath == null) {
|
||||
downloadFinished(null, ERROR_VIDEO_FILE_CANNOT_SAVE, randomNotificationIdOffset);
|
||||
return;
|
||||
}
|
||||
|
||||
Response<ResponseBody> audioResponse = downloadFile.downloadFile(audioUrl).execute();
|
||||
if (audioResponse.isSuccessful() && audioResponse.body() != null) {
|
||||
String audioFilePath = externalCacheDirectoryPath + fileNameWithoutExtension + "-cache.mp3";
|
||||
String outputFilePath = externalCacheDirectoryPath + fileNameWithoutExtension + ".mp4";
|
||||
|
||||
String savedAudioFilePath = writeResponseBodyToDisk(audioResponse.body(), audioFilePath);
|
||||
if (savedAudioFilePath == null) {
|
||||
downloadFinished(null, ERROR_AUDIO_FILE_CANNOT_SAVE, randomNotificationIdOffset);
|
||||
@ -246,8 +248,6 @@ public class DownloadRedditVideoService extends Service {
|
||||
downloadFinished(null, ERROR_MUXED_VIDEO_FILE_CANNOT_SAVE, randomNotificationIdOffset);
|
||||
}
|
||||
} else {
|
||||
String videoFilePath = externalCacheDirectoryPath + fileNameWithoutExtension + "-cache.mp4";
|
||||
|
||||
updateNotification(R.string.downloading_reddit_video_save_file_to_public_dir, -1,
|
||||
randomNotificationIdOffset, null);
|
||||
try {
|
||||
|
@ -31,17 +31,17 @@ public class FetchSubredditData {
|
||||
|
||||
@Override
|
||||
public void onParseSubredditDataFail() {
|
||||
fetchSubredditDataListener.onFetchSubredditDataFail();
|
||||
fetchSubredditDataListener.onFetchSubredditDataFail(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fetchSubredditDataListener.onFetchSubredditDataFail();
|
||||
fetchSubredditDataListener.onFetchSubredditDataFail(response.code() == 403);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
fetchSubredditDataListener.onFetchSubredditDataFail();
|
||||
fetchSubredditDataListener.onFetchSubredditDataFail(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -84,7 +84,7 @@ public class FetchSubredditData {
|
||||
public interface FetchSubredditDataListener {
|
||||
void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers);
|
||||
|
||||
void onFetchSubredditDataFail();
|
||||
void onFetchSubredditDataFail(boolean isQuarantined);
|
||||
}
|
||||
|
||||
interface FetchSubredditListingDataListener {
|
||||
|
@ -56,7 +56,7 @@ public class SubredditSubscription {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchSubredditDataFail() {
|
||||
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||
|
||||
}
|
||||
});
|
||||
|
9
app/src/main/res/drawable/ic_help_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_help_24dp.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M11,18h2v-2h-2v2zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM12,6c-2.21,0 -4,1.79 -4,4h2c0,-1.1 0.9,-2 2,-2s2,0.9 2,2c0,2 -3,1.75 -3,5h2c0,-2.25 3,-2.5 3,-5 0,-2.21 -1.79,-4 -4,-4z"
|
||||
android:fillColor="#ffffff"/>
|
||||
</vector>
|
@ -47,4 +47,12 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fab_login_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:src="@drawable/ic_help_24dp" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
@ -1017,4 +1017,7 @@
|
||||
|
||||
<string name="choose_a_user">Choose a user</string>
|
||||
|
||||
<string name="have_trouble_login_title">Having Trouble Login</string>
|
||||
<string name="have_trouble_login_message">Do you want to try another way to login?</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user