From 8e43ef421bbe59b86e2e87686916fdcb60b421ca Mon Sep 17 00:00:00 2001 From: Thore Goebel Date: Thu, 21 Apr 2022 00:54:42 +0000 Subject: [PATCH] Capture back press in Settings and About The Settings and About fragments are arguably one logical layer below the PairingFragment (which feels like the "main screen"). Capture the back press and return to the PairingFragment. Fixes https://bugs.kde.org/show_bug.cgi?id=442716. Notes: - In a DeviceFragment back-pressing continues to close the app, as before. Judging from the fact that the app persists the last selected device to the shared prefs, I assume this is a intentional. - I also thought about storing from where the Settings/About were opened (e.g. from a specific DeviceFragment) and returning there. However this would be a much larger change with arguable user benefit. After all, from the PairingFragment it's just a single click to your device. --- src/org/kde/kdeconnect/UserInterface/MainActivity.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/org/kde/kdeconnect/UserInterface/MainActivity.java b/src/org/kde/kdeconnect/UserInterface/MainActivity.java index 079dd760..38b82334 100644 --- a/src/org/kde/kdeconnect/UserInterface/MainActivity.java +++ b/src/org/kde/kdeconnect/UserInterface/MainActivity.java @@ -249,6 +249,10 @@ public class MainActivity extends AppCompatActivity implements SharedPreferences public void onBackPressed() { if (mDrawerLayout.isDrawerOpen(mNavigationView)) { mDrawerLayout.closeDrawer(mNavigationView); + } else if (mCurrentMenuEntry == MENU_ENTRY_SETTINGS || mCurrentMenuEntry == MENU_ENTRY_ABOUT) { + mCurrentMenuEntry = MENU_ENTRY_ADD_DEVICE; + mNavigationView.setCheckedItem(MENU_ENTRY_ADD_DEVICE); + setContentFragment(new PairingFragment()); } else { super.onBackPressed(); }