Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3173)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/Preferences.java

Issue 2386753002: Only allow one instance of Preferences to show at a time (Closed)
Patch Set: Only allow one instance of Preferences to show at a time in Android N+ multi-window Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/Preferences.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/Preferences.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/Preferences.java
index 06ecba30fc44d10df6ec878eab752ea0e76e3eb4..6cd85f0dfb04e04c65d4031f0469df921db7bdd4 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/Preferences.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/Preferences.java
@@ -157,13 +157,14 @@ public class Preferences extends AppCompatActivity implements
// Prevent the user from interacting with multiple instances of Preferences at the same time
// (e.g. in multi-instance mode on a Samsung device), which would cause many fun bugs.
- if (sResumedInstance != null && !mIsNewlyCreated) {
+ if (sResumedInstance != null && sResumedInstance != this && !mIsNewlyCreated) {
// This activity was unpaused or recreated while another instance of Preferences was
// already showing. The existing instance takes precedence.
finish();
} else {
// This activity was newly created and takes precedence over sResumedInstance.
- if (sResumedInstance != null) sResumedInstance.finish();
+ if (sResumedInstance != null && sResumedInstance != this) sResumedInstance.finish();
+
sResumedInstance = this;
mIsNewlyCreated = false;
}
@@ -172,10 +173,15 @@ public class Preferences extends AppCompatActivity implements
@Override
protected void onPause() {
super.onPause();
- if (sResumedInstance == this) sResumedInstance = null;
ChromeApplication.flushPersistentData();
}
+ @Override
+ protected void onStop() {
+ super.onStop();
+ if (sResumedInstance == this) sResumedInstance = null;
+ }
+
/**
* Returns the fragment showing as this activity's main content, typically a PreferenceFragment.
* This does not include DialogFragments or other Fragments shown on top of the main content.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698