aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorHermes Junior <ohermesjunior@gmail.com>2020-06-17 14:11:18 +0000
committerOHermesJunior <ohermesjunior@gmail.com>2020-06-17 14:11:18 +0000
commitbe9f0c1fd184460c39ba40153a6a449899a8718a (patch)
treeef8527229fbf6e28b790cc324f576f2a1248275f /app/src/main
parent0df0482d458d91d3e1dba3b493285299f91fcc32 (diff)
downloadinfinity-for-reddit-be9f0c1fd184460c39ba40153a6a449899a8718a.tar
infinity-for-reddit-be9f0c1fd184460c39ba40153a6a449899a8718a.tar.gz
infinity-for-reddit-be9f0c1fd184460c39ba40153a6a449899a8718a.tar.bz2
infinity-for-reddit-be9f0c1fd184460c39ba40153a6a449899a8718a.tar.lz
infinity-for-reddit-be9f0c1fd184460c39ba40153a6a449899a8718a.tar.xz
infinity-for-reddit-be9f0c1fd184460c39ba40153a6a449899a8718a.tar.zst
infinity-for-reddit-be9f0c1fd184460c39ba40153a6a449899a8718a.zip
Allow sliding back on all activities.
Diffstat (limited to '')
-rw-r--r--app/src/main/AndroidManifest.xml60
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditMultiRedditActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ReportActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java34
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SelectedSubredditsActivity.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ThemePreviewActivity.java23
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java15
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java51
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java36
-rw-r--r--app/src/main/res/values/styles.xml10
33 files changed, 291 insertions, 104 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index e3d8fa78..5b4d7d0a 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -38,22 +38,22 @@
android:name=".Activity.ReportActivity"
android:label="@string/report_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar" />
+ android:theme="@style/AppTheme.Slidable" />
<activity
android:name=".Activity.SelectedSubredditsActivity"
android:label="@string/selected_subeddits_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar" />
+ android:theme="@style/AppTheme.Slidable" />
<activity
android:name=".Activity.EditMultiRedditActivity"
android:label="@string/edit_multi_reddit_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar" />
+ android:theme="@style/AppTheme.Slidable" />
<activity
android:name=".Activity.ThemePreviewActivity"
android:label="@string/theme_preview_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBarWithTranslucentWindow" />
+ android:theme="@style/AppTheme.SlidableWithTranslucentWindow" />
<activity
android:name=".Activity.CustomThemeListingActivity"
android:label="@string/custom_theme_listing_activity_label"
@@ -68,27 +68,27 @@
android:name=".Activity.SubredditMultiselectionActivity"
android:label="@string/subreddit_multiselection_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar" />
+ android:theme="@style/AppTheme.Slidable" />
<activity
android:name=".Activity.CreateMultiRedditActivity"
android:label="@string/create_multi_reddit_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar"
+ android:theme="@style/AppTheme.Slidable"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".Activity.ViewMultiRedditDetailActivity"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar" />
+ android:theme="@style/AppTheme.Slidable" />
<activity
android:name=".Activity.MultiRedditListingActivity"
android:label="@string/multi_reddit_listing_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar" />
+ android:theme="@style/AppTheme.Slidable" />
<activity
android:name=".Activity.AccountSavedThingActivity"
android:label="@string/account_saved_thing_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar" />
+ android:theme="@style/AppTheme.Slidable" />
<activity android:name=".Activity.ShareDataResolverActivity">
<intent-filter>
<action android:name="android.intent.action.SEND" />
@@ -121,32 +121,32 @@
android:name=".Activity.ViewMessageActivity"
android:label="@string/view_message_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar" />
+ android:theme="@style/AppTheme.Slidable" />
<activity
android:name=".Activity.AccountPostsActivity"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar" />
+ android:theme="@style/AppTheme.Slidable" />
<activity
android:name=".Activity.EditCommentActivity"
android:label="@string/edit_comment_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar"
+ android:theme="@style/AppTheme.Slidable"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".Activity.EditPostActivity"
android:label="@string/edit_post_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar"
+ android:theme="@style/AppTheme.Slidable"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".Activity.FilteredThingActivity"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar" />
+ android:theme="@style/AppTheme.Slidable" />
<activity
android:name=".Activity.SearchSubredditsResultActivity"
android:label="@string/search_subreddits_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar" />
+ android:theme="@style/AppTheme.Slidable" />
<activity android:name=".Activity.LinkResolverActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
@@ -220,57 +220,57 @@
android:name=".Activity.SearchActivity"
android:label="@string/search_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar" />
+ android:theme="@style/AppTheme.Slidable" />
<activity
android:name=".Activity.RulesActivity"
android:label="@string/rules_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar" />
+ android:theme="@style/AppTheme.Slidable" />
<activity
android:name=".Activity.PostVideoActivity"
android:label="@string/post_video_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar"
+ android:theme="@style/AppTheme.Slidable"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".Activity.PostImageActivity"
android:label="@string/post_image_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar"
+ android:theme="@style/AppTheme.Slidable"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".Activity.PostLinkActivity"
android:label="@string/post_link_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar"
+ android:theme="@style/AppTheme.Slidable"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".Activity.SubscribedThingListingActivity"
android:label="@string/subscriptions"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar" />
+ android:theme="@style/AppTheme.Slidable" />
<activity
android:name=".Activity.SubredditSelectionActivity"
android:label="@string/subreddit_selection_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar" />
+ android:theme="@style/AppTheme.Slidable" />
<activity
android:name=".Activity.PostTextActivity"
android:label="@string/post_text_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar"
+ android:theme="@style/AppTheme.Slidable"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".Activity.CommentActivity"
android:label="@string/comment_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar"
+ android:theme="@style/AppTheme.Slidable"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".Activity.SearchResultActivity"
android:label="@string/search_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar" />
+ android:theme="@style/AppTheme.Slidable" />
<activity
android:name=".Activity.MainActivity"
android:label="@string/application_name"
@@ -285,7 +285,7 @@
android:name=".Activity.LoginActivity"
android:label="@string/login_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar" />
+ android:theme="@style/AppTheme.Slidable" />
<activity
android:name=".Activity.ViewImageOrGifActivity"
android:parentActivityName=".Activity.MainActivity"
@@ -298,15 +298,15 @@
<activity
android:name=".Activity.ViewPostDetailActivity"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBarWithTransparentBackground" />
+ android:theme="@style/AppTheme.Slidable" />
<activity
android:name=".Activity.ViewSubredditDetailActivity"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBarWithTranslucentWindow" />
+ android:theme="@style/AppTheme.SlidableWithTranslucentWindow" />
<activity
android:name=".Activity.ViewUserDetailActivity"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBarWithTranslucentWindow" />
+ android:theme="@style/AppTheme.SlidableWithTranslucentWindow" />
<provider
android:name="androidx.core.content.FileProvider"
@@ -324,4 +324,4 @@
android:exported="false" />
</application>
-</manifest> \ No newline at end of file
+</manifest>
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java
index 1e6ef259..97cc5967 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java
@@ -16,6 +16,7 @@ import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
+import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -94,6 +95,10 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java
index d3c3caf9..52a3d489 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java
@@ -21,6 +21,7 @@ import androidx.viewpager.widget.ViewPager;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.tabs.TabLayout;
+import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -42,6 +43,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
public class AccountSavedThingActivity extends BaseActivity implements ActivityToolbarInterface {
@@ -95,6 +97,10 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java
index d9c07e88..95804f88 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java
@@ -27,6 +27,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
+import com.r0adkll.slidr.Slidr;
import org.commonmark.ext.gfm.tables.TableBlock;
import org.greenrobot.eventbus.EventBus;
@@ -56,6 +57,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SendComment;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.Utils.Utils;
import retrofit2.Retrofit;
@@ -122,6 +124,10 @@ public class CommentActivity extends BaseActivity {
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java
index b564a3a3..86669de9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java
@@ -20,6 +20,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.snackbar.Snackbar;
+import com.r0adkll.slidr.Slidr;
import java.util.ArrayList;
@@ -35,6 +36,7 @@ import ml.docilealligator.infinityforreddit.MultiReddit.CreateMultiReddit;
import ml.docilealligator.infinityforreddit.MultiReddit.MultiRedditJSONModel;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
public class CreateMultiRedditActivity extends BaseActivity {
@@ -91,6 +93,10 @@ public class CreateMultiRedditActivity extends BaseActivity {
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java
index 42ee73c0..4e937cf6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java
@@ -38,12 +38,12 @@ import ml.docilealligator.infinityforreddit.AsyncTask.ChangeThemeNameAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.DeleteThemeAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCustomThemeAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.InsertCustomThemeAsyncTask;
+import ml.docilealligator.infinityforreddit.BottomSheetFragment.CreateThemeBottomSheetFragment;
+import ml.docilealligator.infinityforreddit.BottomSheetFragment.CustomThemeOptionsBottomSheetFragment;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomTheme;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeViewModel;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
-import ml.docilealligator.infinityforreddit.BottomSheetFragment.CreateThemeBottomSheetFragment;
-import ml.docilealligator.infinityforreddit.BottomSheetFragment.CustomThemeOptionsBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
@@ -260,7 +260,7 @@ public class CustomThemeListingActivity extends BaseActivity implements
!clipboard.getPrimaryClipDescription().hasMimeType(MIMETYPE_TEXT_PLAIN)) {
// since the clipboard has data but it is not plain text
Snackbar.make(coordinatorLayout, R.string.no_data_in_clipboard, Snackbar.LENGTH_SHORT).show();
- } else if (clipboard.getPrimaryClip() != null){
+ } else if (clipboard.getPrimaryClip() != null) {
ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0);
String json = item.getText().toString();
try {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java
index 307f5e13..1d807d13 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java
@@ -18,6 +18,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
+import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -36,6 +37,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.API.RedditAPI;
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.Utils.Utils;
import retrofit2.Call;
import retrofit2.Callback;
@@ -87,6 +89,10 @@ public class EditCommentActivity extends BaseActivity {
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditMultiRedditActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditMultiRedditActivity.java
index de8c71a9..1eb815b6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditMultiRedditActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditMultiRedditActivity.java
@@ -22,6 +22,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.snackbar.Snackbar;
+import com.r0adkll.slidr.Slidr;
import javax.inject.Inject;
import javax.inject.Named;
@@ -37,6 +38,7 @@ import ml.docilealligator.infinityforreddit.MultiReddit.MultiReddit;
import ml.docilealligator.infinityforreddit.MultiReddit.MultiRedditJSONModel;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
public class EditMultiRedditActivity extends BaseActivity {
@@ -100,6 +102,10 @@ public class EditMultiRedditActivity extends BaseActivity {
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java
index aaf5d2f5..d886f91f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java
@@ -20,6 +20,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
+import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -38,6 +39,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.API.RedditAPI;
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@@ -89,6 +91,10 @@ public class EditPostActivity extends BaseActivity {
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java
index c850f2d3..1ed02b61 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java
@@ -16,6 +16,7 @@ import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
+import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -109,6 +110,10 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java
index f67893fd..0fa06f4f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java
@@ -18,6 +18,7 @@ import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.AppBarLayout;
+import com.r0adkll.slidr.Slidr;
import org.json.JSONException;
import org.json.JSONObject;
@@ -39,6 +40,7 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.API.RedditAPI;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@@ -85,6 +87,10 @@ public class LoginActivity extends BaseActivity {
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
index ad7458f7..69b52cfb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
@@ -583,11 +583,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
viewPager.setOffscreenPageLimit(3);
tabLayout.setupWithViewPager(viewPager);
- viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
- }
-
+ viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
if (mAccessToken != null) {
@@ -605,10 +601,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
sectionsPagerAdapter.displaySortTypeInToolbar();
}
-
- @Override
- public void onPageScrollStateChanged(int state) {
- }
});
loadSubscriptions();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java
index 2db98f2c..e636572d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java
@@ -26,6 +26,7 @@ import com.bumptech.glide.RequestManager;
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 java.util.ArrayList;
@@ -46,6 +47,7 @@ import ml.docilealligator.infinityforreddit.MultiReddit.MultiReddit;
import ml.docilealligator.infinityforreddit.MultiReddit.MultiRedditViewModel;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
public class MultiRedditListingActivity extends BaseActivity {
@@ -102,6 +104,10 @@ public class MultiRedditListingActivity extends BaseActivity {
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java
index 0bfbc20e..07952f79 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java
@@ -32,6 +32,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import com.libRG.CustomTextView;
+import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -56,6 +57,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Service.SubmitPostService;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
@@ -175,6 +177,10 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java
index 5edb7c8f..effbd8fb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java
@@ -25,6 +25,7 @@ import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
import com.libRG.CustomTextView;
+import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -47,6 +48,7 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Service.SubmitPostService;
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
@@ -150,6 +152,10 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java
index 29b0256f..a713b24f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java
@@ -25,6 +25,7 @@ import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
import com.libRG.CustomTextView;
+import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -47,6 +48,7 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Service.SubmitPostService;
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
@@ -150,6 +152,10 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java
index 386032a7..68068775 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java
@@ -37,6 +37,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import com.libRG.CustomTextView;
+import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -58,6 +59,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Service.SubmitPostService;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
@@ -183,6 +185,10 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ReportActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ReportActivity.java
index 4e3a0738..b816b505 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ReportActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ReportActivity.java
@@ -15,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.snackbar.Snackbar;
+import com.r0adkll.slidr.Slidr;
import java.util.ArrayList;
@@ -33,6 +34,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.ReportReason;
import ml.docilealligator.infinityforreddit.ReportThing;
import ml.docilealligator.infinityforreddit.Rule;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
public class ReportActivity extends BaseActivity {
@@ -86,6 +88,10 @@ public class ReportActivity extends BaseActivity {
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java
index 2c5cb05c..f90dedf3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java
@@ -18,6 +18,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
+import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -36,6 +37,7 @@ import ml.docilealligator.infinityforreddit.FetchRules;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Rule;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
public class RulesActivity extends BaseActivity {
@@ -79,6 +81,10 @@ public class RulesActivity extends BaseActivity {
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchActivity.java
index 0160401a..8b603451 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchActivity.java
@@ -20,6 +20,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.ferfalk.simplesearchview.SimpleSearchView;
import com.google.android.material.appbar.AppBarLayout;
+import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -33,6 +34,7 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
public class SearchActivity extends BaseActivity {
@@ -86,6 +88,10 @@ public class SearchActivity extends BaseActivity {
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
setSupportActionBar(toolbar);
boolean searchOnlySubreddits = getIntent().getBooleanExtra(EXTRA_SEARCH_ONLY_SUBREDDITS, false);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java
index 764c065c..5ea80f8f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java
@@ -21,6 +21,8 @@ import androidx.viewpager.widget.ViewPager;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.tabs.TabLayout;
+import com.r0adkll.slidr.Slidr;
+import com.r0adkll.slidr.model.SlidrInterface;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -93,6 +95,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
private SortTimeBottomSheetFragment sortTimeBottomSheetFragment;
private SearchUserAndSubredditSortTypeBottomSheetFragment searchUserAndSubredditSortTypeBottomSheetFragment;
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
+ private SlidrInterface mSlidrInterface;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -108,6 +111,10 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ mSlidrInterface = Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
@@ -201,18 +208,15 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(sectionsPagerAdapter);
viewPager.setOffscreenPageLimit(2);
- viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
- }
-
+ viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
sectionsPagerAdapter.displaySortTypeInToolbar();
- }
-
- @Override
- public void onPageScrollStateChanged(int state) {
+ if (position == 0) {
+ unlockSwipeRightToGoBack();
+ } else {
+ lockSwipeRightToGoBack();
+ }
}
});
tabLayout.setupWithViewPager(viewPager);
@@ -497,4 +501,16 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
}
}
}
+
+ private void lockSwipeRightToGoBack() {
+ if (mSlidrInterface != null) {
+ mSlidrInterface.lock();
+ }
+ }
+
+ private void unlockSwipeRightToGoBack() {
+ if (mSlidrInterface != null) {
+ mSlidrInterface.unlock();
+ }
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java
index 092cd5d8..b7b2730d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java
@@ -15,6 +15,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.AppBarLayout;
+import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -32,6 +33,7 @@ import ml.docilealligator.infinityforreddit.Fragment.SubredditListingFragment;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
public class SearchSubredditsResultActivity extends BaseActivity implements ActivityToolbarInterface {
@@ -76,6 +78,10 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SelectedSubredditsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SelectedSubredditsActivity.java
index 96bbabdb..3d17ecbf 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SelectedSubredditsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SelectedSubredditsActivity.java
@@ -16,6 +16,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import com.r0adkll.slidr.Slidr;
import java.util.ArrayList;
@@ -29,6 +30,7 @@ import ml.docilealligator.infinityforreddit.Adapter.SelectedSubredditsRecyclerVi
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
public class SelectedSubredditsActivity extends BaseActivity implements ActivityToolbarInterface {
@@ -63,8 +65,13 @@ public class SelectedSubredditsActivity extends BaseActivity implements Activity
setContentView(R.layout.activity_selected_subreddits);
ButterKnife.bind(this);
+
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setToolbarGoToTop(toolbar);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java
index d464ecec..88825dc5 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java
@@ -26,6 +26,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.google.android.material.appbar.AppBarLayout;
+import com.r0adkll.slidr.Slidr;
import java.util.ArrayList;
@@ -42,6 +43,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditViewModel;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
public class SubredditMultiselectionActivity extends BaseActivity implements ActivityToolbarInterface {
@@ -86,6 +88,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
private LinearLayoutManager mLinearLayoutManager;
private SubredditMultiselectionRecyclerViewAdapter mAdapter;
private RequestManager mGlide;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
((Infinity) getApplication()).getAppComponent().inject(this);
@@ -96,6 +99,10 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java
index f48cb952..b6aa045d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java
@@ -17,6 +17,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.AppBarLayout;
+import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -41,6 +42,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData;
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
public class SubredditSelectionActivity extends BaseActivity implements ActivityToolbarInterface {
@@ -95,6 +97,10 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java
index e6f3d8b7..4546ac10 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java
@@ -20,6 +20,7 @@ import androidx.viewpager.widget.ViewPager;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.tabs.TabLayout;
+import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -53,6 +54,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData;
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
public class SubscribedThingListingActivity extends BaseActivity implements ActivityToolbarInterface {
@@ -106,6 +108,10 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ThemePreviewActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ThemePreviewActivity.java
index 015f0a37..ed20127b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ThemePreviewActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ThemePreviewActivity.java
@@ -32,6 +32,7 @@ import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.chip.Chip;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.tabs.TabLayout;
+import com.r0adkll.slidr.Slidr;
import java.util.ArrayList;
@@ -41,15 +42,15 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
-import ml.docilealligator.infinityforreddit.Font.ContentFontStyle;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomTheme;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeSettingsItem;
+import ml.docilealligator.infinityforreddit.Font.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Font.FontStyle;
+import ml.docilealligator.infinityforreddit.Font.TitleFontStyle;
import ml.docilealligator.infinityforreddit.Fragment.ThemePreviewCommentsFragment;
import ml.docilealligator.infinityforreddit.Fragment.ThemePreviewPostsFragment;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
-import ml.docilealligator.infinityforreddit.Font.TitleFontStyle;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY;
@@ -133,7 +134,7 @@ public class ThemePreviewActivity extends AppCompatActivity {
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
- if(mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) {
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) {
getTheme().applyStyle(R.style.Theme_Normal_AmoledDark, true);
} else {
getTheme().applyStyle(R.style.Theme_Normal_NormalDark, true);
@@ -145,10 +146,10 @@ public class ThemePreviewActivity extends AppCompatActivity {
} else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
- if((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_NO) {
+ if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_NO) {
getTheme().applyStyle(R.style.Theme_Normal, true);
} else {
- if(mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) {
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) {
getTheme().applyStyle(R.style.Theme_Normal_AmoledDark, true);
} else {
getTheme().applyStyle(R.style.Theme_Normal_NormalDark, true);
@@ -215,8 +216,13 @@ public class ThemePreviewActivity extends AppCompatActivity {
setContentView(R.layout.activity_theme_preview);
ButterKnife.bind(this);
+
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (immersiveInterface) {
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
@@ -354,10 +360,9 @@ public class ThemePreviewActivity extends AppCompatActivity {
params.topMargin = statusBarHeight;
toolbar.setLayoutParams(params);
TypedValue tv = new TypedValue();
- if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
- {
- ((ViewGroup.MarginLayoutParams)linearLayout.getLayoutParams()).setMargins(0,
- TypedValue.complexToDimensionPixelSize(tv.data,getResources().getDisplayMetrics()) + statusBarHeight, 0, 0);
+ if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
+ ((ViewGroup.MarginLayoutParams) linearLayout.getLayoutParams()).setMargins(0,
+ TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()) + statusBarHeight, 0, 0);
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java
index 4fa00e41..742b961f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java
@@ -259,21 +259,11 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa
private void setupViewPager() {
setToolbarTitle(0);
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
- viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
-
- }
-
+ viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
setToolbarTitle(position);
}
-
- @Override
- public void onPageScrollStateChanged(int state) {
-
- }
});
viewPager.setAdapter(sectionsPagerAdapter);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java
index a71cf47b..5e7446bc 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java
@@ -26,6 +26,7 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
+import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -47,6 +48,7 @@ import ml.docilealligator.infinityforreddit.MessageViewModel;
import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
public class ViewMessageActivity extends BaseActivity implements ActivityToolbarInterface {
@@ -107,6 +109,10 @@ public class ViewMessageActivity extends BaseActivity implements ActivityToolbar
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
mGlide = Glide.with(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java
index a87a200a..1317e133 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java
@@ -18,6 +18,7 @@ import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
+import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus;
@@ -28,12 +29,12 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
-import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
-import ml.docilealligator.infinityforreddit.Event.RefreshMultiRedditsEvent;
-import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment;
import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTimeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTypeBottomSheetFragment;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.Event.RefreshMultiRedditsEvent;
+import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.MultiReddit.DeleteMultiReddit;
@@ -108,6 +109,10 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
@@ -301,8 +306,8 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
public void sortTypeSelected(SortType sortType) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiPath,
sortType.getType().name()).apply();
- if(sortType.getTime() != null) {
- mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE+ multiPath,
+ if (sortType.getTime() != null) {
+ mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiPath,
sortType.getTime().name()).apply();
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
index 1accdeec..6f122bee 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
@@ -37,6 +37,8 @@ import com.google.android.material.chip.Chip;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.tabs.TabLayout;
+import com.r0adkll.slidr.Slidr;
+import com.r0adkll.slidr.model.SlidrInterface;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -56,17 +58,17 @@ import ml.docilealligator.infinityforreddit.AsyncTask.CheckIsSubscribedToSubredd
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubredditDataAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
+import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment;
+import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostTypeBottomSheetFragment;
+import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTimeBottomSheetFragment;
+import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTypeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.GoBackToMainPageEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FetchSubredditData;
import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
-import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment;
-import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostTypeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Fragment.SidebarFragment;
-import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTimeBottomSheetFragment;
-import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTypeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
@@ -196,6 +198,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private int collapsedTabIndicatorColor;
private int unsubscribedColor;
private int subscribedColor;
+ private SlidrInterface mSlidrInterface;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -212,6 +215,10 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ mSlidrInterface = Slidr.attach(this);
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
if (isImmersiveInterface()) {
@@ -624,6 +631,16 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}).execute();
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
+ viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
+ @Override
+ public void onPageSelected(int position) {
+ if (position == 0) {
+ unlockSwipeRightToGoBack();
+ } else {
+ lockSwipeRightToGoBack();
+ }
+ }
+ });
viewPager.setAdapter(sectionsPagerAdapter);
viewPager.setOffscreenPageLimit(2);
tabLayout.setupWithViewPager(viewPager);
@@ -634,12 +651,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
viewPager.setCurrentItem(1, false);
}
- viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
-
- }
-
+ viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
if (mAccessToken != null) {
@@ -658,11 +670,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
sectionsPagerAdapter.displaySortTypeInToolbar();
}
-
- @Override
- public void onPageScrollStateChanged(int state) {
-
- }
});
}
@@ -982,7 +989,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
public void changeSortType(SortType sortType) {
if (postFragment != null) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + subredditName, sortType.getType().name()).apply();
- if(sortType.getTime() != null) {
+ if (sortType.getTime() != null) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + subredditName, sortType.getTime().name()).apply();
}
@@ -1025,4 +1032,16 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}
}
}
+
+ private void lockSwipeRightToGoBack() {
+ if (mSlidrInterface != null) {
+ mSlidrInterface.lock();
+ }
+ }
+
+ private void unlockSwipeRightToGoBack() {
+ if (mSlidrInterface != null) {
+ mSlidrInterface.unlock();
+ }
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java
index fd120df2..c3d4c345 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java
@@ -36,6 +36,8 @@ import com.google.android.material.chip.Chip;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.tabs.TabLayout;
+import com.r0adkll.slidr.Slidr;
+import com.r0adkll.slidr.model.SlidrInterface;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -171,6 +173,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
private boolean showToast = false;
private String mMessageFullname;
private String mNewAccountName;
+ private SlidrInterface mSlidrInterface;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -187,6 +190,10 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
applyCustomTheme();
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
+ mSlidrInterface = Slidr.attach(this);
+ }
+
username = getIntent().getStringExtra(EXTRA_USER_NAME_KEY);
if (savedInstanceState == null) {
@@ -496,12 +503,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
viewPager.setOffscreenPageLimit(2);
tabLayout.setupWithViewPager(viewPager);
- viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
-
- }
-
+ viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
if (isInLazyMode) {
@@ -511,13 +513,13 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
sectionsPagerAdapter.pauseLazyMode();
}
}
+ if (position == 0) {
+ unlockSwipeRightToGoBack();
+ } else {
+ lockSwipeRightToGoBack();
+ }
sectionsPagerAdapter.displaySortTypeInToolbar();
}
-
- @Override
- public void onPageScrollStateChanged(int state) {
-
- }
});
if (mAccessToken != null && mMessageFullname != null) {
@@ -926,4 +928,16 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
}
}
}
+
+ private void lockSwipeRightToGoBack() {
+ if (mSlidrInterface != null) {
+ mSlidrInterface.lock();
+ }
+ }
+
+ private void unlockSwipeRightToGoBack() {
+ if (mSlidrInterface != null) {
+ mSlidrInterface.unlock();
+ }
+ }
}
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 43df2318..de788275 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -27,11 +27,19 @@
<item name="android:windowTranslucentStatus">true</item>
</style>
- <style name="AppTheme.NoActionBarWithTransparentBackground" parent="AppTheme.NoActionBar">
+ <style name="AppTheme.Slidable" parent="AppTheme.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
+ <style name="AppTheme.SlidableWithTranslucentWindow" parent="AppTheme.Slidable">
+ <item name="android:windowTranslucentStatus">true</item>
+ </style>
+
+ <style name="AppTheme.SlidableWithTransparentStatusBar" parent="AppTheme.Slidable">
+ <item name="android:statusBarColor">@android:color/transparent</item>
+ </style>
+
<style name="AppTheme.Draggable" parent="AppTheme">
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowContentOverlay">@null</item>