From c727f035909a4479f122ffd32de4fa36cd716bee Mon Sep 17 00:00:00 2001 From: JosJuice Date: Wed, 5 Aug 2020 13:21:07 +0200 Subject: [PATCH 1/2] Android: Properly restore state of SettingsActivityPresenter Fixes https://bugs.dolphin-emu.org/issues/10815 --- .../settings/ui/SettingsActivityPresenter.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java index a66391d8bb..679d6b007a 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java @@ -42,16 +42,11 @@ public final class SettingsActivityPresenter public void onCreate(Bundle savedInstanceState, MenuTag menuTag, String gameId, Context context) { - if (savedInstanceState == null) - { - this.menuTag = menuTag; - this.gameId = gameId; - this.context = context; - } - else - { - mShouldSave = savedInstanceState.getBoolean(KEY_SHOULD_SAVE); - } + this.menuTag = menuTag; + this.gameId = gameId; + this.context = context; + + mShouldSave = savedInstanceState != null && savedInstanceState.getBoolean(KEY_SHOULD_SAVE); } public void onStart() From 05e49b13ef5f28c0fe8705030bdd2fa975d02aff Mon Sep 17 00:00:00 2001 From: JosJuice Date: Wed, 5 Aug 2020 13:50:36 +0200 Subject: [PATCH 2/2] Android: Fix SettingsActivity back stack behavior after stop+start Fixes the behavior where the settings activity would go back to the top-level menu after switching to a different app and back. --- .../settings/ui/SettingsActivity.java | 16 +++------------ .../ui/SettingsActivityPresenter.java | 20 ------------------- .../settings/ui/SettingsActivityView.java | 5 ----- 3 files changed, 3 insertions(+), 38 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java index 33626d32dc..2abed0cd25 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java @@ -108,16 +108,13 @@ public final class SettingsActivity extends AppCompatActivity implements Setting mPresenter.onStop(isFinishing()); } - @Override - public void onBackPressed() - { - mPresenter.onBackPressed(); - } - @Override public void showSettingsFragment(MenuTag menuTag, Bundle extras, boolean addToStack, String gameID) { + if (!addToStack && getFragment() != null) + return; + FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); if (addToStack) @@ -132,7 +129,6 @@ public final class SettingsActivity extends AppCompatActivity implements Setting } transaction.addToBackStack(null); - mPresenter.addToStack(); } transaction.replace(R.id.frame_content, SettingsFragment.newInstance(menuTag, gameID, extras), FRAGMENT_TAG); @@ -279,12 +275,6 @@ public final class SettingsActivity extends AppCompatActivity implements Setting Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); } - @Override - public void popBackStack() - { - getSupportFragmentManager().popBackStackImmediate(); - } - @Override public void onSettingChanged(String key) { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java index 679d6b007a..d3ee3584c7 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java @@ -23,8 +23,6 @@ public final class SettingsActivityPresenter private Settings mSettings = new Settings(); - private int mStackCount; - private boolean mShouldSave; private DirectoryStateReceiver directoryStateReceiver; @@ -147,24 +145,6 @@ public final class SettingsActivityPresenter } } - public void addToStack() - { - mStackCount++; - } - - public void onBackPressed() - { - if (mStackCount > 0) - { - mView.popBackStack(); - mStackCount--; - } - else - { - mView.finish(); - } - } - public boolean handleOptionsItem(int itemId) { switch (itemId) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityView.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityView.java index 3ad0c6b9cd..b56b8808d6 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityView.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityView.java @@ -56,11 +56,6 @@ public interface SettingsActivityView */ void showToastMessage(String message); - /** - * Show the previous fragment. - */ - void popBackStack(); - /** * End the activity. */