diff options
author | Vikram Aggarwal <viki@google.com> | 2012-11-15 12:53:25 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-11-15 12:53:25 -0800 |
commit | f15f9d67652dacc7f8d2764245f79b25d2c6c67b (patch) | |
tree | 4ad72f8e757ddd82e6ce88f4f998f7bfa6959930 | |
parent | 940f6f0c46d2558bc30d1fe788150ae6d295779b (diff) | |
parent | bf459dafdc5d97d8f2103c1d2a9cb65f5096e4f8 (diff) | |
download | packages_apps_settings-f15f9d67652dacc7f8d2764245f79b25d2c6c67b.zip packages_apps_settings-f15f9d67652dacc7f8d2764245f79b25d2c6c67b.tar.gz packages_apps_settings-f15f9d67652dacc7f8d2764245f79b25d2c6c67b.tar.bz2 |
Merge "Remove back button entirely when disabled" into jb-mr1.1-dev
-rw-r--r-- | src/com/android/settings/CryptKeeper.java | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java index f07d6fa..94c793d 100644 --- a/src/com/android/settings/CryptKeeper.java +++ b/src/com/android/settings/CryptKeeper.java @@ -55,6 +55,7 @@ import android.widget.EditText; import android.widget.ProgressBar; import android.widget.TextView; +import com.android.internal.statusbar.StatusBarIcon; import com.android.internal.telephony.ITelephony; import com.android.internal.telephony.Phone; import com.android.internal.telephony.PhoneConstants; @@ -229,6 +230,16 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList }; private AudioManager mAudioManager; + /** The status bar where back/home/recent buttons are shown. */ + private StatusBarManager mStatusBar; + + /** All the widgets to disable in the status bar */ + final private static int sWidgetsToDisable = StatusBarManager.DISABLE_EXPAND + | StatusBarManager.DISABLE_NOTIFICATION_ICONS + | StatusBarManager.DISABLE_NOTIFICATION_ALERTS + | StatusBarManager.DISABLE_SYSTEM_INFO + | StatusBarManager.DISABLE_HOME + | StatusBarManager.DISABLE_RECENT; /** @return whether or not this Activity was started for debugging the UI only. */ private boolean isDebugView() { @@ -269,6 +280,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList */ @Override public void onBackPressed() { + // In the rare case that something pressed back even though we were disabled. if (mIgnoreBack) return; super.onBackPressed(); @@ -299,13 +311,8 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList // Disable the status bar, but do NOT disable back because the user needs a way to go // from keyboard settings and back to the password screen. - StatusBarManager sbm = (StatusBarManager) getSystemService(Context.STATUS_BAR_SERVICE); - sbm.disable(StatusBarManager.DISABLE_EXPAND - | StatusBarManager.DISABLE_NOTIFICATION_ICONS - | StatusBarManager.DISABLE_NOTIFICATION_ALERTS - | StatusBarManager.DISABLE_SYSTEM_INFO - | StatusBarManager.DISABLE_HOME - | StatusBarManager.DISABLE_RECENT); + mStatusBar = (StatusBarManager) getSystemService(Context.STATUS_BAR_SERVICE); + mStatusBar.disable(sWidgetsToDisable); setAirplaneModeIfNecessary(); mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); @@ -403,7 +410,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ((ProgressBar) findViewById(R.id.progress_bar)).setIndeterminate(true); // Ignore all back presses from now, both hard and soft keys. - mIgnoreBack = true; + setBackFunctionality(false); // Start the first run of progress manually. This method sets up messages to occur at // repeated intervals. updateProgress(); @@ -469,7 +476,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList if (mCooldown <= 0) { // Re-enable the password entry and back presses. mPasswordEntry.setEnabled(true); - mIgnoreBack = false; + setBackFunctionality(true); status.setText(R.string.enter_password); } else { CharSequence template = getText(R.string.crypt_keeper_cooldown); @@ -481,6 +488,19 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList } } + /** + * Sets the back status: enabled or disabled according to the parameter. + * @param isEnabled true if back is enabled, false otherwise. + */ + private final void setBackFunctionality(boolean isEnabled) { + mIgnoreBack = !isEnabled; + if (isEnabled) { + mStatusBar.disable(sWidgetsToDisable); + } else { + mStatusBar.disable(sWidgetsToDisable | StatusBarManager.DISABLE_BACK); + } + } + private void passwordEntryInit() { mPasswordEntry = (EditText) findViewById(R.id.passwordEntry); mPasswordEntry.setOnEditorActionListener(this); @@ -610,7 +630,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList // Disable the password entry and back keypress while checking the password. These // we either be re-enabled if the password was wrong or after the cooldown period. mPasswordEntry.setEnabled(false); - mIgnoreBack = true; + setBackFunctionality(false); Log.d(TAG, "Attempting to send command to decrypt"); new DecryptTask().execute(password); |