diff options
author | Andy Stadler <stadler@google.com> | 2011-01-31 19:21:37 -0800 |
---|---|---|
committer | Andy Stadler <stadler@google.com> | 2011-01-31 19:21:37 -0800 |
commit | 13d62049f7c96c47356f23eaee7f0997612fdf9f (patch) | |
tree | 4c5b1d4b8245a95544097b99895a89d5d287be3d /src/com/android/settings/CryptKeeper.java | |
parent | ba681faf73906dcc9c372008855667437b034cc4 (diff) | |
download | packages_apps_Settings-13d62049f7c96c47356f23eaee7f0997612fdf9f.tar.gz packages_apps_Settings-13d62049f7c96c47356f23eaee7f0997612fdf9f.tar.bz2 packages_apps_Settings-13d62049f7c96c47356f23eaee7f0997612fdf9f.zip |
More CryptKeeper UI work.
* Implemented failure case.
* More pixel perfect
* Remove the animation
* Display the encroid on the blank screen
* Remove the back button.
* Fix portrait mode screens
Bug: 3384231
Bug: 3394103
Bug: 3388721
Bug: 3381450
Bug: 3406278
Bug: 3351832
Change-Id: Ib763c8b577198deb45255acc767bc6d5409efc0c
Diffstat (limited to 'src/com/android/settings/CryptKeeper.java')
-rw-r--r-- | src/com/android/settings/CryptKeeper.java | 66 |
1 files changed, 49 insertions, 17 deletions
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java index 6f847f3d5..cbad3f033 100644 --- a/src/com/android/settings/CryptKeeper.java +++ b/src/com/android/settings/CryptKeeper.java @@ -35,16 +35,16 @@ import android.os.ServiceManager; import android.os.SystemProperties; import android.os.storage.IMountService; import android.text.TextUtils; -import android.text.format.DateFormat; import android.util.Log; import android.view.KeyEvent; +import android.view.View; +import android.view.View.OnClickListener; import android.view.inputmethod.EditorInfo; +import android.widget.Button; import android.widget.EditText; import android.widget.ProgressBar; import android.widget.TextView; -import java.util.Date; - public class CryptKeeper extends Activity implements TextView.OnEditorActionListener { private static final String TAG = "CryptKeeper"; @@ -59,6 +59,11 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList // This activity is used to fade the screen to black after the password is entered. public static class Blank extends Activity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.crypt_keeper_blank); + } } private Handler mHandler = new Handler() { @@ -105,9 +110,12 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList // Disable the status bar StatusBarManager sbm = (StatusBarManager) getSystemService(Context.STATUS_BAR_SERVICE); - sbm.disable(StatusBarManager.DISABLE_EXPAND | StatusBarManager.DISABLE_NOTIFICATION_ICONS + sbm.disable(StatusBarManager.DISABLE_EXPAND + | StatusBarManager.DISABLE_NOTIFICATION_ICONS | StatusBarManager.DISABLE_NOTIFICATION_ALERTS - | StatusBarManager.DISABLE_SYSTEM_INFO | StatusBarManager.DISABLE_NAVIGATION); + | StatusBarManager.DISABLE_SYSTEM_INFO + | StatusBarManager.DISABLE_NAVIGATION + | StatusBarManager.DISABLE_BACK); } @Override @@ -139,9 +147,38 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList updateProgress(); } + private void showFactoryReset() { + // Hide the encryption-bot to make room for the "factory reset" button + findViewById(R.id.encroid).setVisibility(View.GONE); + + // Show the reset button, failure text, and a divider + Button button = (Button) findViewById(R.id.factory_reset); + button.setVisibility(View.VISIBLE); + button.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + // Factory reset the device. + sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR")); + } + }); + + TextView tv = (TextView) findViewById(R.id.title); + tv.setText(R.string.crypt_keeper_failed_title); + + tv = (TextView) findViewById(R.id.status); + tv.setText(R.string.crypt_keeper_failed_summary); + + View view = findViewById(R.id.bottom_divider); + view.setVisibility(View.VISIBLE); + } + private void updateProgress() { String state = SystemProperties.get("vold.encrypt_progress"); + if ("error_partially_encrypted".equals(state)) { + showFactoryReset(); + return; + } + int progress = 0; try { progress = Integer.parseInt(state); @@ -160,16 +197,18 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList private void cooldown() { TextView tv = (TextView) findViewById(R.id.status); + if (mCooldown <= 0) { // Re-enable the password entry EditText passwordEntry = (EditText) findViewById(R.id.passwordEntry); passwordEntry.setEnabled(true); - tv.setText(R.string.try_again); - + tv.setVisibility(View.GONE); } else { - CharSequence tempalte = getText(R.string.crypt_keeper_cooldown); - tv.setText(TextUtils.expandTemplate(tempalte, Integer.toString(mCooldown))); + CharSequence template = getText(R.string.crypt_keeper_cooldown); + tv.setText(TextUtils.expandTemplate(template, Integer.toString(mCooldown))); + + tv.setVisibility(View.VISIBLE); mCooldown--; mHandler.removeMessages(COOLDOWN); @@ -186,14 +225,6 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList PasswordEntryKeyboardHelper keyboardHelper = new PasswordEntryKeyboardHelper(this, keyboardView, passwordEntry, false); keyboardHelper.setKeyboardMode(PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA); - - - passwordEntry.setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.ic_lock_idle_lock, - 0, 0, 0); - - String dateFormatString = getString(com.android.internal.R.string.full_wday_month_day_no_year); - TextView date = (TextView) findViewById(R.id.date); - date.setText(DateFormat.format(dateFormatString, new Date())); } private IMountService getMountService() { @@ -240,6 +271,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList } else { TextView tv = (TextView) findViewById(R.id.status); tv.setText(R.string.try_again); + tv.setVisibility(View.VISIBLE); } } catch (Exception e) { Log.e(TAG, "Error while decrypting...", e); |