mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-29 19:14:44 +01:00
New option: Main Page Back Button Action. It replaces Confirm to Exit.
This commit is contained in:
parent
f5a333e2ac
commit
723f1c0713
@ -98,7 +98,6 @@ import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTimeBottomS
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTypeBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeConfirmToExitEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeDisableSwipingBetweenTabsEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeLockBottomAppBarEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent;
|
||||
@ -231,7 +230,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
private String mMessageFullname;
|
||||
private String mNewAccountName;
|
||||
private boolean showBottomAppBar;
|
||||
private boolean mConfirmToExit;
|
||||
private int mBackButtonAction;
|
||||
private boolean mLockBottomAppBar;
|
||||
private boolean mDisableSwipingBetweenTabs;
|
||||
private boolean mShowFavoriteMultiReddits;
|
||||
@ -312,7 +311,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
toggle.syncState();
|
||||
|
||||
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, true);
|
||||
mConfirmToExit = mSharedPreferences.getBoolean(SharedPreferencesUtils.CONFIRM_TO_EXIT, false);
|
||||
mBackButtonAction = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.MAIN_PAGE_BACK_BUTTON_ACTION, "0"));
|
||||
mLockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
|
||||
mDisableSwipingBetweenTabs = mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false);
|
||||
|
||||
@ -1119,13 +1118,15 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
} else {
|
||||
if (mConfirmToExit) {
|
||||
if (mBackButtonAction == SharedPreferencesUtils.MAIN_PAGE_BACK_BUTTON_ACTION_CONFIRM_EXIT) {
|
||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||
.setTitle(R.string.exit_app)
|
||||
.setPositiveButton(R.string.yes, (dialogInterface, i)
|
||||
-> finish())
|
||||
.setNegativeButton(R.string.no, null)
|
||||
.show();
|
||||
} else if (mBackButtonAction == SharedPreferencesUtils.MAIN_PAGE_BACK_BUTTON_ACTION_OPEN_NAVIGATION_DRAWER) {
|
||||
drawer.openDrawer(GravityCompat.START);
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
@ -1245,11 +1246,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
ActivityCompat.recreate(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onChangeConfirmToExitEvent(ChangeConfirmToExitEvent changeConfirmToExitEvent) {
|
||||
mConfirmToExit = changeConfirmToExitEvent.confirmToExit;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onChangeLockBottomAppBar(ChangeLockBottomAppBarEvent changeLockBottomAppBarEvent) {
|
||||
mLockBottomAppBar = changeLockBottomAppBarEvent.lockBottomAppBar;
|
||||
|
@ -39,12 +39,12 @@ public class MiscellaneousPreferenceFragment extends PreferenceFragmentCompat {
|
||||
|
||||
((Infinity) activity.getApplication()).getAppComponent().inject(this);
|
||||
|
||||
SwitchPreference confirmToExitSwitch = findPreference(SharedPreferencesUtils.CONFIRM_TO_EXIT);
|
||||
ListPreference mainPageBackButtonActionListPreference = findPreference(SharedPreferencesUtils.MAIN_PAGE_BACK_BUTTON_ACTION);
|
||||
SwitchPreference savePostFeedScrolledPositionSwitch = findPreference(SharedPreferencesUtils.SAVE_FRONT_PAGE_SCROLLED_POSITION);
|
||||
ListPreference languageListPreference = findPreference(SharedPreferencesUtils.LANGUAGE);
|
||||
|
||||
if (confirmToExitSwitch != null) {
|
||||
confirmToExitSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
if (mainPageBackButtonActionListPreference != null) {
|
||||
mainPageBackButtonActionListPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
EventBus.getDefault().post(new RecreateActivityEvent());
|
||||
return true;
|
||||
});
|
||||
|
@ -105,7 +105,9 @@ public class SharedPreferencesUtils {
|
||||
public static final String SWAP_TAP_AND_LONG_COMMENTS = "swap_tap_and_long_in_comments";
|
||||
public static final String SWIPE_UP_TO_HIDE_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON = "swipe_up_to_hide_jump_to_next_top_level_comments_button";
|
||||
public static final String SHOW_TOP_LEVEL_COMMENTS_FIRST = "show_top_level_comments_first";
|
||||
public static final String CONFIRM_TO_EXIT = "confirm_to_exit";
|
||||
public static final String MAIN_PAGE_BACK_BUTTON_ACTION = "main_page_back_button_action";
|
||||
public static final int MAIN_PAGE_BACK_BUTTON_ACTION_CONFIRM_EXIT = 1;
|
||||
public static final int MAIN_PAGE_BACK_BUTTON_ACTION_OPEN_NAVIGATION_DRAWER = 2;
|
||||
public static final String LOCK_BOTTOM_APP_BAR = "lock_bottom_app_bar";
|
||||
public static final String COMMENT_TOOLBAR_HIDDEN = "comment_toolbar_hidden";
|
||||
public static final String COMMENT_TOOLBAR_HIDE_ON_CLICK = "comment_toolbar_hide_on_click";
|
||||
@ -358,4 +360,5 @@ public class SharedPreferencesUtils {
|
||||
public static final String NSFW_KEY_LEGACY = "nsfw";
|
||||
public static final String BLUR_NSFW_KEY_LEGACY = "blur_nsfw";
|
||||
public static final String BLUR_SPOILER_KEY_LEGACY = "blur_spoiler";
|
||||
public static final String CONFIRM_TO_EXIT_LEGACY = "confirm_to_exit";
|
||||
}
|
||||
|
@ -508,4 +508,16 @@
|
||||
<item>86400000</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="main_page_back_button_action">
|
||||
<item>@string/default_in_array</item>
|
||||
<item>@string/settings_confirm_to_exit</item>
|
||||
<item>@string/settings_open_navigation_drawer</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="main_page_back_button_action_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
@ -190,7 +190,7 @@
|
||||
<string name="send_message_failed">Could not send this message</string>
|
||||
|
||||
<string name="select_a_subreddit">Please select a subreddit first</string>
|
||||
<string name="title_required">The post need a good title</string>
|
||||
<string name="title_required">The post needs a good title</string>
|
||||
<string name="link_required">Hey where is the link?</string>
|
||||
<string name="select_an_image">Please select an image first</string>
|
||||
<string name="posting">Posting</string>
|
||||
@ -391,7 +391,9 @@
|
||||
<string name="settings_automatically_try_redgifs_title">Automatically Try Accessing Redgifs if Videos on Gfycat are Removed.</string>
|
||||
<string name="settings_video_player_ignore_nav_bar_title">Ignore Navigation Bar in Video Player</string>
|
||||
<string name="settings_video_player_ignore_nav_bar_summary">Prevent the Video Controller Having Extra Margin</string>
|
||||
<string name="settings_main_page_back_button_action">Main Page Back Button Action</string>
|
||||
<string name="settings_confirm_to_exit">Confirm to Exit</string>
|
||||
<string name="settings_open_navigation_drawer">Open Navigation Drawer</string>
|
||||
<string name="settings_category_comment_title">Comment</string>
|
||||
<string name="settings_show_top_level_comments_first_title">Show Top-level Comments First</string>
|
||||
<string name="settings_show_comment_divider_title">Show Comment Divider</string>
|
||||
|
@ -13,11 +13,14 @@
|
||||
app:key="open_link_in_app"
|
||||
app:title="@string/settings_open_link_in_app_title" />
|
||||
|
||||
<SwitchPreference
|
||||
app:defaultValue="false"
|
||||
app:key="confirm_to_exit"
|
||||
<ListPreference
|
||||
app:defaultValue="0"
|
||||
app:entries="@array/main_page_back_button_action"
|
||||
app:entryValues="@array/main_page_back_button_action_values"
|
||||
app:key="main_page_back_button_action"
|
||||
app:icon="@drawable/ic_exit_24dp"
|
||||
app:title="@string/settings_confirm_to_exit" />
|
||||
app:title="@string/settings_main_page_back_button_action"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<SwitchPreference
|
||||
app:defaultValue="true"
|
||||
|
Loading…
x
Reference in New Issue
Block a user