Re-add setting to open drawer when pressing back (#6355)

This commit is contained in:
ByteHamster 2023-02-28 20:42:46 +01:00 committed by GitHub
parent ebcb5e2a7c
commit 5e75c968ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 1 deletions

View File

@ -493,7 +493,11 @@ public class MainActivity extends CastEnabledActivity {
String toPage = UserPreferences.getDefaultPage();
if (NavDrawerFragment.getLastNavFragment(this).equals(toPage)
|| UserPreferences.DEFAULT_PAGE_REMEMBER.equals(toPage)) {
super.onBackPressed();
if (UserPreferences.backButtonOpensDrawer() && drawerLayout != null) {
drawerLayout.openDrawer(navDrawer);
} else {
super.onBackPressed();
}
} else {
loadFragment(toPage, null);
}

View File

@ -133,5 +133,10 @@ public class PreferenceUpgrader {
"" + UserPreferences.EPISODE_CACHE_SIZE_UNLIMITED).apply();
}
}
if (oldVersion < 3000007) {
if (prefs.getString("prefBackButtonBehavior", "").equals("drawer")) {
prefs.edit().putBoolean(UserPreferences.PREF_BACK_OPENS_DRAWER, true).apply();
}
}
}
}

View File

@ -88,6 +88,11 @@
android:title="@string/pref_default_page"
android:summary="@string/pref_default_page_sum"
android:defaultValue="HomeFragment"/>
<SwitchPreferenceCompat
android:key="prefBackButtonOpensDrawer"
android:title="@string/pref_back_button_opens_drawer"
android:summary="@string/pref_back_button_opens_drawer_summary"
android:defaultValue="false"/>
<Preference
android:key="prefSwipe"
android:summary="@string/swipeactions_summary"

View File

@ -63,6 +63,7 @@ public class UserPreferences {
public static final String PREF_DEFAULT_PAGE = "prefDefaultPage";
public static final String PREF_FILTER_FEED = "prefSubscriptionsFilter";
public static final String PREF_SUBSCRIPTION_TITLE = "prefSubscriptionTitle";
public static final String PREF_BACK_OPENS_DRAWER = "prefBackButtonOpensDrawer";
public static final String PREF_QUEUE_KEEP_SORTED = "prefQueueKeepSorted";
public static final String PREF_QUEUE_KEEP_SORTED_ORDER = "prefQueueKeepSortedOrder";
@ -869,6 +870,10 @@ public class UserPreferences {
prefs.edit().putString(PREF_DEFAULT_PAGE, defaultPage).apply();
}
public static boolean backButtonOpensDrawer() {
return prefs.getBoolean(PREF_BACK_OPENS_DRAWER, false);
}
public static boolean timeRespectsSpeed() {
return prefs.getBoolean(PREF_TIME_RESPECTS_SPEED, false);
}

View File

@ -514,6 +514,8 @@
<string name="behavior">Behavior</string>
<string name="pref_default_page">Default Page</string>
<string name="pref_default_page_sum">Screen that is opened when starting AntennaPod.</string>
<string name="pref_back_button_opens_drawer">Back button opens drawer</string>
<string name="pref_back_button_opens_drawer_summary">Pressing the back button on the default page opens the navigation drawer</string>
<string name="remember_last_page">Remember last page</string>
<string name="pref_delete_removes_from_queue_title">Delete removes from Queue</string>
<string name="pref_delete_removes_from_queue_sum">Automatically remove an episode from the queue when it is deleted.</string>