Allow sliding back on all activities.

This commit is contained in:
Hermes Junior 2020-06-17 16:11:18 +02:00 committed by OHermesJunior
parent 0df0482d45
commit be9f0c1fd1
33 changed files with 291 additions and 104 deletions

View File

@ -38,22 +38,22 @@
android:name=".Activity.ReportActivity" android:name=".Activity.ReportActivity"
android:label="@string/report_activity_label" android:label="@string/report_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.Slidable" />
<activity <activity
android:name=".Activity.SelectedSubredditsActivity" android:name=".Activity.SelectedSubredditsActivity"
android:label="@string/selected_subeddits_activity_label" android:label="@string/selected_subeddits_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.Slidable" />
<activity <activity
android:name=".Activity.EditMultiRedditActivity" android:name=".Activity.EditMultiRedditActivity"
android:label="@string/edit_multi_reddit_activity_label" android:label="@string/edit_multi_reddit_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.Slidable" />
<activity <activity
android:name=".Activity.ThemePreviewActivity" android:name=".Activity.ThemePreviewActivity"
android:label="@string/theme_preview_activity_label" android:label="@string/theme_preview_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBarWithTranslucentWindow" /> android:theme="@style/AppTheme.SlidableWithTranslucentWindow" />
<activity <activity
android:name=".Activity.CustomThemeListingActivity" android:name=".Activity.CustomThemeListingActivity"
android:label="@string/custom_theme_listing_activity_label" android:label="@string/custom_theme_listing_activity_label"
@ -68,27 +68,27 @@
android:name=".Activity.SubredditMultiselectionActivity" android:name=".Activity.SubredditMultiselectionActivity"
android:label="@string/subreddit_multiselection_activity_label" android:label="@string/subreddit_multiselection_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.Slidable" />
<activity <activity
android:name=".Activity.CreateMultiRedditActivity" android:name=".Activity.CreateMultiRedditActivity"
android:label="@string/create_multi_reddit_activity_label" android:label="@string/create_multi_reddit_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" android:theme="@style/AppTheme.Slidable"
android:windowSoftInputMode="adjustResize" /> android:windowSoftInputMode="adjustResize" />
<activity <activity
android:name=".Activity.ViewMultiRedditDetailActivity" android:name=".Activity.ViewMultiRedditDetailActivity"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.Slidable" />
<activity <activity
android:name=".Activity.MultiRedditListingActivity" android:name=".Activity.MultiRedditListingActivity"
android:label="@string/multi_reddit_listing_activity_label" android:label="@string/multi_reddit_listing_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.Slidable" />
<activity <activity
android:name=".Activity.AccountSavedThingActivity" android:name=".Activity.AccountSavedThingActivity"
android:label="@string/account_saved_thing_activity_label" android:label="@string/account_saved_thing_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.Slidable" />
<activity android:name=".Activity.ShareDataResolverActivity"> <activity android:name=".Activity.ShareDataResolverActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.SEND" /> <action android:name="android.intent.action.SEND" />
@ -121,32 +121,32 @@
android:name=".Activity.ViewMessageActivity" android:name=".Activity.ViewMessageActivity"
android:label="@string/view_message_activity_label" android:label="@string/view_message_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.Slidable" />
<activity <activity
android:name=".Activity.AccountPostsActivity" android:name=".Activity.AccountPostsActivity"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.Slidable" />
<activity <activity
android:name=".Activity.EditCommentActivity" android:name=".Activity.EditCommentActivity"
android:label="@string/edit_comment_activity_label" android:label="@string/edit_comment_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" android:theme="@style/AppTheme.Slidable"
android:windowSoftInputMode="adjustResize" /> android:windowSoftInputMode="adjustResize" />
<activity <activity
android:name=".Activity.EditPostActivity" android:name=".Activity.EditPostActivity"
android:label="@string/edit_post_activity_label" android:label="@string/edit_post_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" android:theme="@style/AppTheme.Slidable"
android:windowSoftInputMode="adjustResize" /> android:windowSoftInputMode="adjustResize" />
<activity <activity
android:name=".Activity.FilteredThingActivity" android:name=".Activity.FilteredThingActivity"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.Slidable" />
<activity <activity
android:name=".Activity.SearchSubredditsResultActivity" android:name=".Activity.SearchSubredditsResultActivity"
android:label="@string/search_subreddits_activity_label" android:label="@string/search_subreddits_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.Slidable" />
<activity android:name=".Activity.LinkResolverActivity"> <activity android:name=".Activity.LinkResolverActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
@ -220,57 +220,57 @@
android:name=".Activity.SearchActivity" android:name=".Activity.SearchActivity"
android:label="@string/search_activity_label" android:label="@string/search_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.Slidable" />
<activity <activity
android:name=".Activity.RulesActivity" android:name=".Activity.RulesActivity"
android:label="@string/rules_activity_label" android:label="@string/rules_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.Slidable" />
<activity <activity
android:name=".Activity.PostVideoActivity" android:name=".Activity.PostVideoActivity"
android:label="@string/post_video_activity_label" android:label="@string/post_video_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" android:theme="@style/AppTheme.Slidable"
android:windowSoftInputMode="adjustResize" /> android:windowSoftInputMode="adjustResize" />
<activity <activity
android:name=".Activity.PostImageActivity" android:name=".Activity.PostImageActivity"
android:label="@string/post_image_activity_label" android:label="@string/post_image_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" android:theme="@style/AppTheme.Slidable"
android:windowSoftInputMode="adjustResize" /> android:windowSoftInputMode="adjustResize" />
<activity <activity
android:name=".Activity.PostLinkActivity" android:name=".Activity.PostLinkActivity"
android:label="@string/post_link_activity_label" android:label="@string/post_link_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" android:theme="@style/AppTheme.Slidable"
android:windowSoftInputMode="adjustResize" /> android:windowSoftInputMode="adjustResize" />
<activity <activity
android:name=".Activity.SubscribedThingListingActivity" android:name=".Activity.SubscribedThingListingActivity"
android:label="@string/subscriptions" android:label="@string/subscriptions"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.Slidable" />
<activity <activity
android:name=".Activity.SubredditSelectionActivity" android:name=".Activity.SubredditSelectionActivity"
android:label="@string/subreddit_selection_activity_label" android:label="@string/subreddit_selection_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.Slidable" />
<activity <activity
android:name=".Activity.PostTextActivity" android:name=".Activity.PostTextActivity"
android:label="@string/post_text_activity_label" android:label="@string/post_text_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" android:theme="@style/AppTheme.Slidable"
android:windowSoftInputMode="adjustResize" /> android:windowSoftInputMode="adjustResize" />
<activity <activity
android:name=".Activity.CommentActivity" android:name=".Activity.CommentActivity"
android:label="@string/comment_activity_label" android:label="@string/comment_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" android:theme="@style/AppTheme.Slidable"
android:windowSoftInputMode="adjustResize" /> android:windowSoftInputMode="adjustResize" />
<activity <activity
android:name=".Activity.SearchResultActivity" android:name=".Activity.SearchResultActivity"
android:label="@string/search_activity_label" android:label="@string/search_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.Slidable" />
<activity <activity
android:name=".Activity.MainActivity" android:name=".Activity.MainActivity"
android:label="@string/application_name" android:label="@string/application_name"
@ -285,7 +285,7 @@
android:name=".Activity.LoginActivity" android:name=".Activity.LoginActivity"
android:label="@string/login_activity_label" android:label="@string/login_activity_label"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.Slidable" />
<activity <activity
android:name=".Activity.ViewImageOrGifActivity" android:name=".Activity.ViewImageOrGifActivity"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
@ -298,15 +298,15 @@
<activity <activity
android:name=".Activity.ViewPostDetailActivity" android:name=".Activity.ViewPostDetailActivity"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBarWithTransparentBackground" /> android:theme="@style/AppTheme.Slidable" />
<activity <activity
android:name=".Activity.ViewSubredditDetailActivity" android:name=".Activity.ViewSubredditDetailActivity"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBarWithTranslucentWindow" /> android:theme="@style/AppTheme.SlidableWithTranslucentWindow" />
<activity <activity
android:name=".Activity.ViewUserDetailActivity" android:name=".Activity.ViewUserDetailActivity"
android:parentActivityName=".Activity.MainActivity" android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBarWithTranslucentWindow" /> android:theme="@style/AppTheme.SlidableWithTranslucentWindow" />
<provider <provider
android:name="androidx.core.content.FileProvider" android:name="androidx.core.content.FileProvider"

View File

@ -16,6 +16,7 @@ import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -94,6 +95,10 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
applyCustomTheme(); 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 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow(); Window window = getWindow();

View File

@ -21,6 +21,7 @@ import androidx.viewpager.widget.ViewPager;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.tabs.TabLayout; import com.google.android.material.tabs.TabLayout;
import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -42,6 +43,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.Post.PostDataSource;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class AccountSavedThingActivity extends BaseActivity implements ActivityToolbarInterface { public class AccountSavedThingActivity extends BaseActivity implements ActivityToolbarInterface {
@ -95,6 +97,10 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
applyCustomTheme(); 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 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow(); Window window = getWindow();

View File

@ -27,6 +27,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.r0adkll.slidr.Slidr;
import org.commonmark.ext.gfm.tables.TableBlock; import org.commonmark.ext.gfm.tables.TableBlock;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
@ -56,6 +57,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SendComment; import ml.docilealligator.infinityforreddit.SendComment;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.Utils.Utils; import ml.docilealligator.infinityforreddit.Utils.Utils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
@ -122,6 +124,10 @@ public class CommentActivity extends BaseActivity {
applyCustomTheme(); 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()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout); addOnOffsetChangedListener(appBarLayout);
} }

View File

@ -20,6 +20,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.r0adkll.slidr.Slidr;
import java.util.ArrayList; import java.util.ArrayList;
@ -35,6 +36,7 @@ import ml.docilealligator.infinityforreddit.MultiReddit.CreateMultiReddit;
import ml.docilealligator.infinityforreddit.MultiReddit.MultiRedditJSONModel; import ml.docilealligator.infinityforreddit.MultiReddit.MultiRedditJSONModel;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class CreateMultiRedditActivity extends BaseActivity { public class CreateMultiRedditActivity extends BaseActivity {
@ -91,6 +93,10 @@ public class CreateMultiRedditActivity extends BaseActivity {
applyCustomTheme(); 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()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout); addOnOffsetChangedListener(appBarLayout);
} }

View File

@ -38,12 +38,12 @@ import ml.docilealligator.infinityforreddit.AsyncTask.ChangeThemeNameAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.DeleteThemeAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.DeleteThemeAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCustomThemeAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.GetCustomThemeAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.InsertCustomThemeAsyncTask; 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.CustomTheme;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeViewModel; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeViewModel;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent; 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.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
@ -260,7 +260,7 @@ public class CustomThemeListingActivity extends BaseActivity implements
!clipboard.getPrimaryClipDescription().hasMimeType(MIMETYPE_TEXT_PLAIN)) { !clipboard.getPrimaryClipDescription().hasMimeType(MIMETYPE_TEXT_PLAIN)) {
// since the clipboard has data but it is not plain text // since the clipboard has data but it is not plain text
Snackbar.make(coordinatorLayout, R.string.no_data_in_clipboard, Snackbar.LENGTH_SHORT).show(); 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); ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0);
String json = item.getText().toString(); String json = item.getText().toString();
try { try {

View File

@ -18,6 +18,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -36,6 +37,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.API.RedditAPI; import ml.docilealligator.infinityforreddit.API.RedditAPI;
import ml.docilealligator.infinityforreddit.Utils.APIUtils; import ml.docilealligator.infinityforreddit.Utils.APIUtils;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.Utils.Utils; import ml.docilealligator.infinityforreddit.Utils.Utils;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
@ -87,6 +89,10 @@ public class EditCommentActivity extends BaseActivity {
applyCustomTheme(); 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()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout); addOnOffsetChangedListener(appBarLayout);
} }

View File

@ -22,6 +22,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.r0adkll.slidr.Slidr;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
@ -37,6 +38,7 @@ import ml.docilealligator.infinityforreddit.MultiReddit.MultiReddit;
import ml.docilealligator.infinityforreddit.MultiReddit.MultiRedditJSONModel; import ml.docilealligator.infinityforreddit.MultiReddit.MultiRedditJSONModel;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class EditMultiRedditActivity extends BaseActivity { public class EditMultiRedditActivity extends BaseActivity {
@ -100,6 +102,10 @@ public class EditMultiRedditActivity extends BaseActivity {
applyCustomTheme(); 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()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout); addOnOffsetChangedListener(appBarLayout);
} }

View File

@ -20,6 +20,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -38,6 +39,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.API.RedditAPI; import ml.docilealligator.infinityforreddit.API.RedditAPI;
import ml.docilealligator.infinityforreddit.Utils.APIUtils; import ml.docilealligator.infinityforreddit.Utils.APIUtils;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@ -89,6 +91,10 @@ public class EditPostActivity extends BaseActivity {
applyCustomTheme(); 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()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout); addOnOffsetChangedListener(appBarLayout);
} }

View File

@ -16,6 +16,7 @@ import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -109,6 +110,10 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
applyCustomTheme(); 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 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow(); Window window = getWindow();

View File

@ -18,6 +18,7 @@ import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.r0adkll.slidr.Slidr;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -39,6 +40,7 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.API.RedditAPI; import ml.docilealligator.infinityforreddit.API.RedditAPI;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Utils.APIUtils; import ml.docilealligator.infinityforreddit.Utils.APIUtils;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@ -85,6 +87,10 @@ public class LoginActivity extends BaseActivity {
applyCustomTheme(); applyCustomTheme();
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
Slidr.attach(this);
}
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);

View File

@ -583,11 +583,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
viewPager.setOffscreenPageLimit(3); viewPager.setOffscreenPageLimit(3);
tabLayout.setupWithViewPager(viewPager); tabLayout.setupWithViewPager(viewPager);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override @Override
public void onPageSelected(int position) { public void onPageSelected(int position) {
if (mAccessToken != null) { if (mAccessToken != null) {
@ -605,10 +601,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
} }
sectionsPagerAdapter.displaySortTypeInToolbar(); sectionsPagerAdapter.displaySortTypeInToolbar();
} }
@Override
public void onPageScrollStateChanged(int state) {
}
}); });
loadSubscriptions(); loadSubscriptions();

View File

@ -26,6 +26,7 @@ import com.bumptech.glide.RequestManager;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.r0adkll.slidr.Slidr;
import java.util.ArrayList; import java.util.ArrayList;
@ -46,6 +47,7 @@ import ml.docilealligator.infinityforreddit.MultiReddit.MultiReddit;
import ml.docilealligator.infinityforreddit.MultiReddit.MultiRedditViewModel; import ml.docilealligator.infinityforreddit.MultiReddit.MultiRedditViewModel;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class MultiRedditListingActivity extends BaseActivity { public class MultiRedditListingActivity extends BaseActivity {
@ -102,6 +104,10 @@ public class MultiRedditListingActivity extends BaseActivity {
applyCustomTheme(); 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 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow(); Window window = getWindow();

View File

@ -32,6 +32,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.libRG.CustomTextView; import com.libRG.CustomTextView;
import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -56,6 +57,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Service.SubmitPostService; import ml.docilealligator.infinityforreddit.Service.SubmitPostService;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
@ -175,6 +177,10 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
applyCustomTheme(); 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()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout); addOnOffsetChangedListener(appBarLayout);
} }

View File

@ -25,6 +25,7 @@ import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.libRG.CustomTextView; import com.libRG.CustomTextView;
import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -47,6 +48,7 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Service.SubmitPostService; import ml.docilealligator.infinityforreddit.Service.SubmitPostService;
import ml.docilealligator.infinityforreddit.Utils.APIUtils; import ml.docilealligator.infinityforreddit.Utils.APIUtils;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
@ -150,6 +152,10 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
applyCustomTheme(); 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()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout); addOnOffsetChangedListener(appBarLayout);
} }

View File

@ -25,6 +25,7 @@ import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.libRG.CustomTextView; import com.libRG.CustomTextView;
import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -47,6 +48,7 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Service.SubmitPostService; import ml.docilealligator.infinityforreddit.Service.SubmitPostService;
import ml.docilealligator.infinityforreddit.Utils.APIUtils; import ml.docilealligator.infinityforreddit.Utils.APIUtils;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
@ -150,6 +152,10 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
applyCustomTheme(); 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()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout); addOnOffsetChangedListener(appBarLayout);
} }

View File

@ -37,6 +37,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.libRG.CustomTextView; import com.libRG.CustomTextView;
import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -58,6 +59,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Service.SubmitPostService; import ml.docilealligator.infinityforreddit.Service.SubmitPostService;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
@ -183,6 +185,10 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
applyCustomTheme(); 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()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout); addOnOffsetChangedListener(appBarLayout);
} }

View File

@ -15,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.r0adkll.slidr.Slidr;
import java.util.ArrayList; import java.util.ArrayList;
@ -33,6 +34,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.ReportReason; import ml.docilealligator.infinityforreddit.ReportReason;
import ml.docilealligator.infinityforreddit.ReportThing; import ml.docilealligator.infinityforreddit.ReportThing;
import ml.docilealligator.infinityforreddit.Rule; import ml.docilealligator.infinityforreddit.Rule;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class ReportActivity extends BaseActivity { public class ReportActivity extends BaseActivity {
@ -86,6 +88,10 @@ public class ReportActivity extends BaseActivity {
applyCustomTheme(); 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()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout); addOnOffsetChangedListener(appBarLayout);
} }

View File

@ -18,6 +18,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -36,6 +37,7 @@ import ml.docilealligator.infinityforreddit.FetchRules;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Rule; import ml.docilealligator.infinityforreddit.Rule;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class RulesActivity extends BaseActivity { public class RulesActivity extends BaseActivity {
@ -79,6 +81,10 @@ public class RulesActivity extends BaseActivity {
applyCustomTheme(); 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 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow(); Window window = getWindow();

View File

@ -20,6 +20,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.ferfalk.simplesearchview.SimpleSearchView; import com.ferfalk.simplesearchview.SimpleSearchView;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; 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.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
public class SearchActivity extends BaseActivity { public class SearchActivity extends BaseActivity {
@ -86,6 +88,10 @@ public class SearchActivity extends BaseActivity {
applyCustomTheme(); applyCustomTheme();
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
Slidr.attach(this);
}
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
boolean searchOnlySubreddits = getIntent().getBooleanExtra(EXTRA_SEARCH_ONLY_SUBREDDITS, false); boolean searchOnlySubreddits = getIntent().getBooleanExtra(EXTRA_SEARCH_ONLY_SUBREDDITS, false);

View File

@ -21,6 +21,8 @@ import androidx.viewpager.widget.ViewPager;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.tabs.TabLayout; 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.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -93,6 +95,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
private SortTimeBottomSheetFragment sortTimeBottomSheetFragment; private SortTimeBottomSheetFragment sortTimeBottomSheetFragment;
private SearchUserAndSubredditSortTypeBottomSheetFragment searchUserAndSubredditSortTypeBottomSheetFragment; private SearchUserAndSubredditSortTypeBottomSheetFragment searchUserAndSubredditSortTypeBottomSheetFragment;
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment; private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
private SlidrInterface mSlidrInterface;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -108,6 +111,10 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
applyCustomTheme(); 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) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow(); Window window = getWindow();
@ -201,18 +208,15 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(sectionsPagerAdapter); viewPager.setAdapter(sectionsPagerAdapter);
viewPager.setOffscreenPageLimit(2); viewPager.setOffscreenPageLimit(2);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override @Override
public void onPageSelected(int position) { public void onPageSelected(int position) {
sectionsPagerAdapter.displaySortTypeInToolbar(); sectionsPagerAdapter.displaySortTypeInToolbar();
if (position == 0) {
unlockSwipeRightToGoBack();
} else {
lockSwipeRightToGoBack();
} }
@Override
public void onPageScrollStateChanged(int state) {
} }
}); });
tabLayout.setupWithViewPager(viewPager); 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();
}
}
} }

View File

@ -15,6 +15,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -32,6 +33,7 @@ import ml.docilealligator.infinityforreddit.Fragment.SubredditListingFragment;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
public class SearchSubredditsResultActivity extends BaseActivity implements ActivityToolbarInterface { public class SearchSubredditsResultActivity extends BaseActivity implements ActivityToolbarInterface {
@ -76,6 +78,10 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti
applyCustomTheme(); 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 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow(); Window window = getWindow();

View File

@ -16,6 +16,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.r0adkll.slidr.Slidr;
import java.util.ArrayList; import java.util.ArrayList;
@ -29,6 +30,7 @@ import ml.docilealligator.infinityforreddit.Adapter.SelectedSubredditsRecyclerVi
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
public class SelectedSubredditsActivity extends BaseActivity implements ActivityToolbarInterface { public class SelectedSubredditsActivity extends BaseActivity implements ActivityToolbarInterface {
@ -63,8 +65,13 @@ public class SelectedSubredditsActivity extends BaseActivity implements Activity
setContentView(R.layout.activity_selected_subreddits); setContentView(R.layout.activity_selected_subreddits);
ButterKnife.bind(this); ButterKnife.bind(this);
applyCustomTheme(); applyCustomTheme();
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
Slidr.attach(this);
}
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setToolbarGoToTop(toolbar); setToolbarGoToTop(toolbar);

View File

@ -26,6 +26,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager; import com.bumptech.glide.RequestManager;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.r0adkll.slidr.Slidr;
import java.util.ArrayList; import java.util.ArrayList;
@ -42,6 +43,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditViewModel; import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditViewModel;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class SubredditMultiselectionActivity extends BaseActivity implements ActivityToolbarInterface { public class SubredditMultiselectionActivity extends BaseActivity implements ActivityToolbarInterface {
@ -86,6 +88,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
private LinearLayoutManager mLinearLayoutManager; private LinearLayoutManager mLinearLayoutManager;
private SubredditMultiselectionRecyclerViewAdapter mAdapter; private SubredditMultiselectionRecyclerViewAdapter mAdapter;
private RequestManager mGlide; private RequestManager mGlide;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
@ -96,6 +99,10 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
applyCustomTheme(); 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 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow(); Window window = getWindow();

View File

@ -17,6 +17,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -41,6 +42,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData;
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class SubredditSelectionActivity extends BaseActivity implements ActivityToolbarInterface { public class SubredditSelectionActivity extends BaseActivity implements ActivityToolbarInterface {
@ -95,6 +97,10 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
applyCustomTheme(); 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 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow(); Window window = getWindow();

View File

@ -20,6 +20,7 @@ import androidx.viewpager.widget.ViewPager;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.tabs.TabLayout; import com.google.android.material.tabs.TabLayout;
import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -53,6 +54,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData;
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class SubscribedThingListingActivity extends BaseActivity implements ActivityToolbarInterface { public class SubscribedThingListingActivity extends BaseActivity implements ActivityToolbarInterface {
@ -106,6 +108,10 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
applyCustomTheme(); 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 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow(); Window window = getWindow();

View File

@ -32,6 +32,7 @@ import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.chip.Chip; import com.google.android.material.chip.Chip;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.tabs.TabLayout; import com.google.android.material.tabs.TabLayout;
import com.r0adkll.slidr.Slidr;
import java.util.ArrayList; import java.util.ArrayList;
@ -41,15 +42,15 @@ import javax.inject.Named;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener; import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.Font.ContentFontStyle;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomTheme; import ml.docilealligator.infinityforreddit.CustomTheme.CustomTheme;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeSettingsItem; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeSettingsItem;
import ml.docilealligator.infinityforreddit.Font.ContentFontStyle;
import ml.docilealligator.infinityforreddit.Font.FontStyle; import ml.docilealligator.infinityforreddit.Font.FontStyle;
import ml.docilealligator.infinityforreddit.Font.TitleFontStyle;
import ml.docilealligator.infinityforreddit.Fragment.ThemePreviewCommentsFragment; import ml.docilealligator.infinityforreddit.Fragment.ThemePreviewCommentsFragment;
import ml.docilealligator.infinityforreddit.Fragment.ThemePreviewPostsFragment; import ml.docilealligator.infinityforreddit.Fragment.ThemePreviewPostsFragment;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Font.TitleFontStyle;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY;
@ -133,7 +134,7 @@ public class ThemePreviewActivity extends AppCompatActivity {
break; break;
case 1: case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES); 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); getTheme().applyStyle(R.style.Theme_Normal_AmoledDark, true);
} else { } else {
getTheme().applyStyle(R.style.Theme_Normal_NormalDark, true); getTheme().applyStyle(R.style.Theme_Normal_NormalDark, true);
@ -145,10 +146,10 @@ public class ThemePreviewActivity extends AppCompatActivity {
} else { } else {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY); 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); getTheme().applyStyle(R.style.Theme_Normal, true);
} else { } 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); getTheme().applyStyle(R.style.Theme_Normal_AmoledDark, true);
} else { } else {
getTheme().applyStyle(R.style.Theme_Normal_NormalDark, true); getTheme().applyStyle(R.style.Theme_Normal_NormalDark, true);
@ -215,8 +216,13 @@ public class ThemePreviewActivity extends AppCompatActivity {
setContentView(R.layout.activity_theme_preview); setContentView(R.layout.activity_theme_preview);
ButterKnife.bind(this); ButterKnife.bind(this);
applyCustomTheme(); 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 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (immersiveInterface) { if (immersiveInterface) {
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); 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; params.topMargin = statusBarHeight;
toolbar.setLayoutParams(params); toolbar.setLayoutParams(params);
TypedValue tv = new TypedValue(); TypedValue tv = new TypedValue();
if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
{ ((ViewGroup.MarginLayoutParams) linearLayout.getLayoutParams()).setMargins(0,
((ViewGroup.MarginLayoutParams)linearLayout.getLayoutParams()).setMargins(0, TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()) + statusBarHeight, 0, 0);
TypedValue.complexToDimensionPixelSize(tv.data,getResources().getDisplayMetrics()) + statusBarHeight, 0, 0);
} }
} }
} }

View File

@ -259,21 +259,11 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa
private void setupViewPager() { private void setupViewPager() {
setToolbarTitle(0); setToolbarTitle(0);
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override @Override
public void onPageSelected(int position) { public void onPageSelected(int position) {
setToolbarTitle(position); setToolbarTitle(position);
} }
@Override
public void onPageScrollStateChanged(int state) {
}
}); });
viewPager.setAdapter(sectionsPagerAdapter); viewPager.setAdapter(sectionsPagerAdapter);
} }

View File

@ -26,6 +26,7 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager; import com.bumptech.glide.RequestManager;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -47,6 +48,7 @@ import ml.docilealligator.infinityforreddit.MessageViewModel;
import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class ViewMessageActivity extends BaseActivity implements ActivityToolbarInterface { public class ViewMessageActivity extends BaseActivity implements ActivityToolbarInterface {
@ -107,6 +109,10 @@ public class ViewMessageActivity extends BaseActivity implements ActivityToolbar
applyCustomTheme(); applyCustomTheme();
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
Slidr.attach(this);
}
mGlide = Glide.with(this); mGlide = Glide.with(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {

View File

@ -18,6 +18,7 @@ import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
@ -28,12 +29,12 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface; import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; 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.PostLayoutBottomSheetFragment;
import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTimeBottomSheetFragment; import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTimeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTypeBottomSheetFragment; 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.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.MultiReddit.DeleteMultiReddit; import ml.docilealligator.infinityforreddit.MultiReddit.DeleteMultiReddit;
@ -108,6 +109,10 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
applyCustomTheme(); 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 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow(); Window window = getWindow();
@ -301,8 +306,8 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
public void sortTypeSelected(SortType sortType) { public void sortTypeSelected(SortType sortType) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiPath, mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiPath,
sortType.getType().name()).apply(); sortType.getType().name()).apply();
if(sortType.getTime() != null) { if (sortType.getTime() != null) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE+ multiPath, mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiPath,
sortType.getTime().name()).apply(); sortType.getTime().name()).apply();
} }

View File

@ -37,6 +37,8 @@ import com.google.android.material.chip.Chip;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.tabs.TabLayout; 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.EventBus;
import org.greenrobot.eventbus.Subscribe; 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.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubredditDataAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubredditDataAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask; 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.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.GoBackToMainPageEvent; import ml.docilealligator.infinityforreddit.Event.GoBackToMainPageEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FetchSubredditData; import ml.docilealligator.infinityforreddit.FetchSubredditData;
import ml.docilealligator.infinityforreddit.Fragment.PostFragment; 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.Fragment.SidebarFragment;
import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTimeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTypeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.Post.PostDataSource;
@ -196,6 +198,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private int collapsedTabIndicatorColor; private int collapsedTabIndicatorColor;
private int unsubscribedColor; private int unsubscribedColor;
private int subscribedColor; private int subscribedColor;
private SlidrInterface mSlidrInterface;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -212,6 +215,10 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
applyCustomTheme(); 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) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow(); Window window = getWindow();
if (isImmersiveInterface()) { if (isImmersiveInterface()) {
@ -624,6 +631,16 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}).execute(); }).execute();
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); 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.setAdapter(sectionsPagerAdapter);
viewPager.setOffscreenPageLimit(2); viewPager.setOffscreenPageLimit(2);
tabLayout.setupWithViewPager(viewPager); tabLayout.setupWithViewPager(viewPager);
@ -634,12 +651,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
viewPager.setCurrentItem(1, false); viewPager.setCurrentItem(1, false);
} }
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override @Override
public void onPageSelected(int position) { public void onPageSelected(int position) {
if (mAccessToken != null) { if (mAccessToken != null) {
@ -658,11 +670,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
sectionsPagerAdapter.displaySortTypeInToolbar(); sectionsPagerAdapter.displaySortTypeInToolbar();
} }
@Override
public void onPageScrollStateChanged(int state) {
}
}); });
} }
@ -982,7 +989,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
public void changeSortType(SortType sortType) { public void changeSortType(SortType sortType) {
if (postFragment != null) { if (postFragment != null) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + subredditName, sortType.getType().name()).apply(); 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(); 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();
}
}
} }

View File

@ -36,6 +36,8 @@ import com.google.android.material.chip.Chip;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.tabs.TabLayout; 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.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -171,6 +173,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
private boolean showToast = false; private boolean showToast = false;
private String mMessageFullname; private String mMessageFullname;
private String mNewAccountName; private String mNewAccountName;
private SlidrInterface mSlidrInterface;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -187,6 +190,10 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
applyCustomTheme(); 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); username = getIntent().getStringExtra(EXTRA_USER_NAME_KEY);
if (savedInstanceState == null) { if (savedInstanceState == null) {
@ -496,12 +503,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
viewPager.setOffscreenPageLimit(2); viewPager.setOffscreenPageLimit(2);
tabLayout.setupWithViewPager(viewPager); tabLayout.setupWithViewPager(viewPager);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override @Override
public void onPageSelected(int position) { public void onPageSelected(int position) {
if (isInLazyMode) { if (isInLazyMode) {
@ -511,12 +513,12 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
sectionsPagerAdapter.pauseLazyMode(); sectionsPagerAdapter.pauseLazyMode();
} }
} }
sectionsPagerAdapter.displaySortTypeInToolbar(); if (position == 0) {
unlockSwipeRightToGoBack();
} else {
lockSwipeRightToGoBack();
} }
sectionsPagerAdapter.displaySortTypeInToolbar();
@Override
public void onPageScrollStateChanged(int state) {
} }
}); });
@ -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();
}
}
} }

View File

@ -27,11 +27,19 @@
<item name="android:windowTranslucentStatus">true</item> <item name="android:windowTranslucentStatus">true</item>
</style> </style>
<style name="AppTheme.NoActionBarWithTransparentBackground" parent="AppTheme.NoActionBar"> <style name="AppTheme.Slidable" parent="AppTheme.NoActionBar">
<item name="android:windowIsTranslucent">true</item> <item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowBackground">@android:color/transparent</item>
</style> </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"> <style name="AppTheme.Draggable" parent="AppTheme">
<item name="android:colorBackgroundCacheHint">@null</item> <item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowContentOverlay">@null</item> <item name="android:windowContentOverlay">@null</item>