summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/com/android/dialer/settings/DialerSettingsActivity.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/com/android/dialer/settings/DialerSettingsActivity.java b/src/com/android/dialer/settings/DialerSettingsActivity.java
index 2b7277224..fee0fa88e 100644
--- a/src/com/android/dialer/settings/DialerSettingsActivity.java
+++ b/src/com/android/dialer/settings/DialerSettingsActivity.java
@@ -35,6 +35,8 @@ import java.util.List;
public class DialerSettingsActivity extends AppCompatPreferenceActivity {
protected SharedPreferences mPreferences;
+ private boolean mIsVisible;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -42,6 +44,31 @@ public class DialerSettingsActivity extends AppCompatPreferenceActivity {
}
@Override
+ protected void onStart() {
+ super.onStart();
+ mIsVisible = true;
+ }
+
+ @Override
+ protected void onStop() {
+ mIsVisible = false;
+ super.onStop();
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle out) {
+ mIsVisible = false;
+ super.onSaveInstanceState(out);
+ }
+
+ /**
+ * Returns true when the Activity is currently visible (between onStart and onStop).
+ */
+ /* package */ boolean isVisible() {
+ return mIsVisible;
+ }
+
+ @Override
public void onBuildHeaders(List<Header> target) {
Header displayOptionsHeader = new Header();
displayOptionsHeader.titleRes = R.string.display_options_title;
@@ -131,6 +158,14 @@ public class DialerSettingsActivity extends AppCompatPreferenceActivity {
}
@Override
+ public void onBackPressed() {
+ if (!isVisible()) {
+ return;
+ }
+ super.onBackPressed();
+ }
+
+ @Override
protected boolean isValidFragment(String fragmentName) {
return true;
}