From 885c0a68bb4a91d461914c43c2e42a565394aa59 Mon Sep 17 00:00:00 2001 From: Shuhrat Dehkanov Date: Sat, 4 Feb 2012 02:10:51 +0900 Subject: Remove PKCS12_PASSWORD_DIALOG and NAME_CREDENTIAL_DIALOG in order to correctly recreate it on onCreateDialog If an empty password or name is supplied for certificate password or certificate name dialogs, respectively, showDialog is called without removing them. As a result onCreateDialog is not called leaving the dialog without visible UI to the user. Steps to reproduce: 1. Put password protected certificate to the SD card. 2. Navigate to Settings > Security and initiate certificate installation. 3. Provide an empty password and press OK. 3.1. Provide an empty name for NAME_CREDENTIAL_DIALOG related issue. Change-Id: I83ffd680313eb9c69214113d3091a70910a80ae2 Signed-off-by: Shuhrat Dehkanov --- src/com/android/certinstaller/CertInstaller.java | 14 ++++++++++++-- src/com/android/certinstaller/ViewHelper.java | 9 +++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/com/android/certinstaller/CertInstaller.java b/src/com/android/certinstaller/CertInstaller.java index d37cd72..0809ad3 100644 --- a/src/com/android/certinstaller/CertInstaller.java +++ b/src/com/android/certinstaller/CertInstaller.java @@ -317,6 +317,10 @@ public class CertInstaller extends Activity { private Dialog createPkcs12PasswordDialog() { View view = View.inflate(this, R.layout.password_dialog, null); mView.setView(view); + if (mView.getHasEmptyError()) { + mView.showError(R.string.password_empty_error); + mView.setHasEmptyError(false); + } String title = mCredentials.getName(); title = TextUtils.isEmpty(title) @@ -329,7 +333,8 @@ public class CertInstaller extends Activity { public void onClick(DialogInterface dialog, int id) { String password = mView.getText(R.id.credential_password); if (TextUtils.isEmpty(password)) { - mView.showError(R.string.password_empty_error); + mView.setHasEmptyError(true); + removeDialog(PKCS12_PASSWORD_DIALOG); showDialog(PKCS12_PASSWORD_DIALOG); } else { mNextAction = new Pkcs12ExtractAction(password); @@ -354,6 +359,10 @@ public class CertInstaller extends Activity { private Dialog createNameCredentialDialog() { ViewGroup view = (ViewGroup) View.inflate(this, R.layout.name_credential_dialog, null); mView.setView(view); + if (mView.getHasEmptyError()) { + mView.showError(R.string.name_empty_error); + mView.setHasEmptyError(false); + } mView.setText(R.id.credential_info, mCredentials.getDescription(this).toString()); final EditText nameInput = (EditText) view.findViewById(R.id.credential_name); nameInput.setText(getDefaultName()); @@ -365,7 +374,8 @@ public class CertInstaller extends Activity { public void onClick(DialogInterface dialog, int id) { String name = mView.getText(R.id.credential_name); if (TextUtils.isEmpty(name)) { - mView.showError(R.string.name_empty_error); + mView.setHasEmptyError(true); + removeDialog(NAME_CREDENTIAL_DIALOG); showDialog(NAME_CREDENTIAL_DIALOG); } else { removeDialog(NAME_CREDENTIAL_DIALOG); diff --git a/src/com/android/certinstaller/ViewHelper.java b/src/com/android/certinstaller/ViewHelper.java index 81ff628..6561667 100644 --- a/src/com/android/certinstaller/ViewHelper.java +++ b/src/com/android/certinstaller/ViewHelper.java @@ -24,6 +24,7 @@ import android.widget.TextView; */ class ViewHelper { private View mView; + private boolean mHasEmptyError; void setView(View view) { mView = view; @@ -49,4 +50,12 @@ class ViewHelper { TextView v = (TextView) mView.findViewById(viewId); if (v != null) v.setText(textId); } + + void setHasEmptyError(boolean hasEmptyError) { + mHasEmptyError = hasEmptyError; + } + + boolean getHasEmptyError() { + return mHasEmptyError; + } } -- cgit v1.2.3