New work on PIN and lock pattern UI

This commit is contained in:
Dominik Schürmann 2014-12-29 23:16:54 +01:00
parent 320f825878
commit 610c4780f1
21 changed files with 127 additions and 62 deletions

View File

@ -659,6 +659,12 @@
<activity
android:name=".ui.PassphraseDialogActivity"
android:theme="@android:style/Theme.NoDisplay" />
<activity
android:name="com.haibison.android.lockpattern.LockPatternActivity"
android:label="@string/title_unlock"
android:configChanges="orientation|screenSize|keyboard|keyboardHidden"
android:screenOrientation="user"
android:theme="@style/Alp.42447968.Theme.Dialog.Light" />
<!--
NOTE: singleTop is set to get NFC foreground dispatch to work.
Then, all NFC intents will be broadcasted to onNewIntent() of this activity!

View File

@ -83,7 +83,8 @@ public class CanonicalizedSecretKey extends CanonicalizedPublicKey {
}
public enum SecretKeyType {
UNAVAILABLE(0), GNU_DUMMY(1), PASSPHRASE(2), PASSPHRASE_EMPTY(3), DIVERT_TO_CARD(4);
UNAVAILABLE(0), GNU_DUMMY(1), PASSPHRASE(2), PASSPHRASE_EMPTY(3), DIVERT_TO_CARD(4), PIN(5),
PATTERN(6);
final int mNum;
@ -101,6 +102,10 @@ public class CanonicalizedSecretKey extends CanonicalizedPublicKey {
return PASSPHRASE_EMPTY;
case 4:
return DIVERT_TO_CARD;
case 5:
return PIN;
case 6:
return PATTERN;
// if this case happens, it's probably a check from a database value
default:
return UNAVAILABLE;

View File

@ -41,6 +41,8 @@ import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.haibison.android.lockpattern.LockPatternActivity;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
@ -68,6 +70,8 @@ public class PassphraseDialogActivity extends FragmentActivity {
// special extra for OpenPgpService
public static final String EXTRA_DATA = "data";
private static final int REQUEST_CODE_ENTER_PATTERN = 2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -90,6 +94,40 @@ public class PassphraseDialogActivity extends FragmentActivity {
show(this, keyId, serviceIntent);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case REQUEST_CODE_ENTER_PATTERN: {
/*
* NOTE that there are 4 possible result codes!!!
*/
switch (resultCode) {
case RESULT_OK:
// The user passed
break;
case RESULT_CANCELED:
// The user cancelled the task
break;
case LockPatternActivity.RESULT_FAILED:
// The user failed to enter the pattern
break;
case LockPatternActivity.RESULT_FORGOT_PATTERN:
// The user forgot the pattern and invoked your recovery Activity.
break;
}
/*
* In any case, there's always a key EXTRA_RETRY_COUNT, which holds
* the number of tries that the user did.
*/
int retryCount = data.getIntExtra(
LockPatternActivity.EXTRA_RETRY_COUNT, 0);
break;
}
}
}
/**
* Shows passphrase dialog to cache a new passphrase the user enters for using it later for
* encryption. Based on mSecretKeyId it asks for a passphrase to open a private key or it asks
@ -138,7 +176,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(theme);
alert.setTitle(R.string.title_authentication);
alert.setTitle(R.string.title_unlock);
String userId;
CanonicalizedSecretKey.SecretKeyType keyType = CanonicalizedSecretKey.SecretKeyType.PASSPHRASE;
@ -171,7 +209,10 @@ public class PassphraseDialogActivity extends FragmentActivity {
message = getString(R.string.passphrase_for, userId);
break;
case DIVERT_TO_CARD:
message = getString(R.string.yubikey_pin, userId);
message = getString(R.string.yubikey_pin_for, userId);
break;
case PIN:
message = getString(R.string.pin_for, userId);
break;
default:
message = "This should not happen!";
@ -209,6 +250,15 @@ public class PassphraseDialogActivity extends FragmentActivity {
}
});
if (keyType == CanonicalizedSecretKey.SecretKeyType.PATTERN) {
// start pattern dialog and show progress circle here...
Intent patternActivity = new Intent(getActivity(), LockPatternActivity.class);
patternActivity.putExtra(LockPatternActivity.EXTRA_PATTERN, "123");
startActivityForResult(patternActivity, REQUEST_CODE_ENTER_PATTERN);
mInput.setVisibility(View.GONE);
mProgress.setVisibility(View.VISIBLE);
} else {
// Hack to open keyboard.
// This is the only method that I found to work across all Android versions
// http://turbomanage.wordpress.com/2012/05/02/show-soft-keyboard-automatically-when-edittext-receives-focus/
@ -237,11 +287,14 @@ public class PassphraseDialogActivity extends FragmentActivity {
if (keyType == CanonicalizedSecretKey.SecretKeyType.DIVERT_TO_CARD && Preferences.getPreferences(activity).useNumKeypadForYubikeyPin()) {
mPassphraseEditText.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_VARIATION_PASSWORD);
} else if (keyType == CanonicalizedSecretKey.SecretKeyType.PIN) {
mPassphraseEditText.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_VARIATION_PASSWORD);
} else {
mPassphraseEditText.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
}
mPassphraseEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
AlertDialog dialog = alert.create();
dialog.setButton(DialogInterface.BUTTON_POSITIVE,

View File

@ -9,7 +9,7 @@
<string name="title_encrypt_text">Zašifrovat text</string>
<string name="title_encrypt_files">Zašifrovat soubory</string>
<string name="title_decrypt">Rozšifrovat</string>
<string name="title_authentication">Heslo</string>
<string name="title_unlock">Heslo</string>
<string name="title_add_subkey">Přidat podklíč</string>
<string name="title_edit_key">Editovat klíč</string>
<string name="title_preferences">Možnosti</string>
@ -183,7 +183,7 @@
<string name="passphrase_must_not_be_empty">Prosím zadejte heslo.</string>
<string name="passphrase_for_symmetric_encryption">Symetrická šifra.</string>
<string name="passphrase_for">Zadejte heslo pro \'%s\'</string>
<string name="yubikey_pin">Zadejte PIN pro přístup k Yubikey pro \'%s\'</string>
<string name="yubikey_pin_for">Zadejte PIN pro přístup k Yubikey pro \'%s\'</string>
<string name="file_delete_confirmation">Chcete opravdu smazat\n%s?</string>
<string name="file_delete_successful">Úspěšně smazáno.</string>
<string name="no_file_selected">Nejprve vyberte soubor.</string>

View File

@ -9,7 +9,7 @@
<string name="title_encrypt_text">Text Verschlüsseln</string>
<string name="title_encrypt_files">Dateien verschlüsseln</string>
<string name="title_decrypt">Entschlüsseln</string>
<string name="title_authentication">Passwort</string>
<string name="title_unlock">Passwort</string>
<string name="title_add_subkey">Unterschlüssel hinzufügen</string>
<string name="title_edit_key">Schlüssel bearbeiten</string>
<string name="title_preferences">Einstellungen</string>
@ -189,7 +189,7 @@
<string name="passphrase_must_not_be_empty">Bitte ein Passwort eingeben.</string>
<string name="passphrase_for_symmetric_encryption">Symmetrische Verschlüsselung.</string>
<string name="passphrase_for">Passwort für \'%s\' eingeben</string>
<string name="yubikey_pin">PIN für Zugriff auf Yubikey für \'%s\' eingeben</string>
<string name="yubikey_pin_for">PIN für Zugriff auf Yubikey für \'%s\' eingeben</string>
<string name="file_delete_confirmation">%s wirklich löschen?</string>
<string name="file_delete_successful">Erfolgreich gelöscht.</string>
<string name="no_file_selected">Zuerst eine Datei auswählen.</string>

View File

@ -9,7 +9,7 @@
<string name="title_encrypt_text">Cifrar texto</string>
<string name="title_encrypt_files">Cifrar ficheros</string>
<string name="title_decrypt">Descifrar</string>
<string name="title_authentication">Frase de contraseña</string>
<string name="title_unlock">Frase de contraseña</string>
<string name="title_add_subkey">Añadir subclave</string>
<string name="title_edit_key"> Editar clave</string>
<string name="title_preferences"> Preferencias</string>
@ -189,7 +189,7 @@
<string name="passphrase_must_not_be_empty">Por favor, introduce una frase de contraseña.</string>
<string name="passphrase_for_symmetric_encryption">Cifrado simétrico.</string>
<string name="passphrase_for">Introducir la frase de contraseña para \'%s\'</string>
<string name="yubikey_pin">Introduzca el PIN de acceso a Yubikey para \'%s\'</string>
<string name="yubikey_pin_for">Introduzca el PIN de acceso a Yubikey para \'%s\'</string>
<string name="file_delete_confirmation">¿Está seguro de que quiere eliminar\n%s?</string>
<string name="file_delete_successful">Borrado satisfactoriamente.</string>
<string name="no_file_selected">Selecciona un archivo antes.</string>

View File

@ -4,7 +4,7 @@
http://developer.android.com/guide/topics/resources/string-resource.html (scroll down to "Escaping apostrophes and quotes").-->
<!--title-->
<string name="title_decrypt">Dekrüpteeri</string>
<string name="title_authentication">Salasõne</string>
<string name="title_unlock">Salasõne</string>
<string name="title_edit_key">Muuda võtit</string>
<string name="title_preferences">Seaded</string>
<string name="title_key_server_preference">Võtmeserveri seaded</string>

View File

@ -9,7 +9,7 @@
<string name="title_encrypt_text">Chiffrer un texte</string>
<string name="title_encrypt_files">Chiffrer des fichiers</string>
<string name="title_decrypt">Déchiffrer</string>
<string name="title_authentication">Phrase de passe</string>
<string name="title_unlock">Phrase de passe</string>
<string name="title_add_subkey">Ajouter une sous-clef</string>
<string name="title_edit_key">Modifier une clef</string>
<string name="title_preferences">Préférences</string>
@ -189,7 +189,7 @@
<string name="passphrase_must_not_be_empty">Veuillez saisir une phrase de passe</string>
<string name="passphrase_for_symmetric_encryption">Chriffrement symétrique.</string>
<string name="passphrase_for">Saisir une phrase de passe pour « %s »</string>
<string name="yubikey_pin">Saisir le NIP pour accéder à la Yubikey pour « %s »</string>
<string name="yubikey_pin_for">Saisir le NIP pour accéder à la Yubikey pour « %s »</string>
<string name="file_delete_confirmation">Êtes-vous certain de vouloir supprimer\n%s?</string>
<string name="file_delete_successful">Supprimé avec succès.</string>
<string name="no_file_selected">Choisir d\'abord un fichier.</string>

View File

@ -9,7 +9,7 @@
<string name="title_encrypt_text">Testo Cifrato</string>
<string name="title_encrypt_files">File Cifrati</string>
<string name="title_decrypt">Decodifica</string>
<string name="title_authentication">Frase di accesso</string>
<string name="title_unlock">Frase di accesso</string>
<string name="title_add_subkey">Aggiungi Sottochiave</string>
<string name="title_edit_key">Modifica Chiave</string>
<string name="title_preferences">Preferenze</string>
@ -183,7 +183,7 @@
<string name="passphrase_must_not_be_empty">Si prega di inserire una frase di accesso.</string>
<string name="passphrase_for_symmetric_encryption">Codifica Simmetrica.</string>
<string name="passphrase_for">Inserisci la frase di accesso per \'%s\'</string>
<string name="yubikey_pin">Inserisci il PIN per accedere a Yubikey con \'%s\'</string>
<string name="yubikey_pin_for">Inserisci il PIN per accedere a Yubikey con \'%s\'</string>
<string name="file_delete_confirmation">Sei sicuro di voler eliminare\n%s?</string>
<string name="file_delete_successful">Eliminato correttamente.</string>
<string name="no_file_selected">Seleziona un file prima.</string>

View File

@ -9,7 +9,7 @@
<string name="title_encrypt_text">テキスト暗号化</string>
<string name="title_encrypt_files">ファイル暗号化</string>
<string name="title_decrypt">復号化</string>
<string name="title_authentication">パスフレーズ</string>
<string name="title_unlock">パスフレーズ</string>
<string name="title_add_subkey">副鍵の追加</string>
<string name="title_edit_key">鍵の編集</string>
<string name="title_preferences">設定</string>
@ -187,7 +187,7 @@
<string name="passphrase_must_not_be_empty">パスフレーズを入れてください。</string>
<string name="passphrase_for_symmetric_encryption">対称暗号。</string>
<string name="passphrase_for">\'%s\' にパスフレーズを入れてください。</string>
<string name="yubikey_pin">\'%s\' の Yubikey にアクセスするためのPINを入力してください</string>
<string name="yubikey_pin_for">\'%s\' の Yubikey にアクセスするためのPINを入力してください</string>
<string name="file_delete_confirmation">%s
を削除してもかまいませんか?</string>
<string name="file_delete_successful">削除に成功しました。</string>

View File

@ -4,7 +4,7 @@
http://developer.android.com/guide/topics/resources/string-resource.html (scroll down to "Escaping apostrophes and quotes").-->
<!--title-->
<string name="title_decrypt">Ontsleutelen</string>
<string name="title_authentication">Wachtwoord</string>
<string name="title_unlock">Wachtwoord</string>
<string name="title_edit_key">Sleutel bewerken</string>
<string name="title_preferences">Instellingen</string>
<string name="title_key_server_preference">Sleutelserver Voorkeur</string>

View File

@ -9,7 +9,7 @@
<string name="title_encrypt_text">Szyfruj tekst</string>
<string name="title_encrypt_files">Szyfruj pliki</string>
<string name="title_decrypt">Odszyfruj</string>
<string name="title_authentication">Hasło</string>
<string name="title_unlock">Hasło</string>
<string name="title_add_subkey">Dodaj pod-klucz</string>
<string name="title_edit_key">Edytuj klucz</string>
<string name="title_preferences">Właściwości</string>
@ -186,7 +186,7 @@
<string name="passphrase_must_not_be_empty">Podaj hasło.</string>
<string name="passphrase_for_symmetric_encryption">Szyfrowanie symetryczne.</string>
<string name="passphrase_for">Podaj hasło dla \'%s\'</string>
<string name="yubikey_pin">Wpisz PIN, aby otworzyć Yubikey dla \'%s\'</string>
<string name="yubikey_pin_for">Wpisz PIN, aby otworzyć Yubikey dla \'%s\'</string>
<string name="file_delete_confirmation">Czy jesteś pewny, że chcesz usunąć\n%s?</string>
<string name="file_delete_successful">Usunięto pomyślnie.</string>
<string name="no_file_selected">Najpierw wskaż plik.</string>

View File

@ -6,7 +6,7 @@
<string name="title_select_recipients">Выберите ключи</string>
<string name="title_select_secret_key">Выберите Ваш ключ</string>
<string name="title_decrypt">Расшифровать</string>
<string name="title_authentication">Пароль</string>
<string name="title_unlock">Пароль</string>
<string name="title_add_subkey">Добавить доп. ключ</string>
<string name="title_edit_key">Изменить ключ</string>
<string name="title_preferences">Настройки</string>

View File

@ -9,7 +9,7 @@
<string name="title_encrypt_text">Šifriraj besedilo</string>
<string name="title_encrypt_files">Šifriraj datoteko</string>
<string name="title_decrypt">Dešifriraj</string>
<string name="title_authentication">Geslo</string>
<string name="title_unlock">Geslo</string>
<string name="title_add_subkey">Dodaj podključ</string>
<string name="title_edit_key">Uredi ključ</string>
<string name="title_preferences">Nastavitve</string>

View File

@ -9,7 +9,7 @@
<string name="title_encrypt_text">Шифруј текст</string>
<string name="title_encrypt_files">Шифруј фајлове</string>
<string name="title_decrypt">Дешифруј</string>
<string name="title_authentication">Лозинка</string>
<string name="title_unlock">Лозинка</string>
<string name="title_add_subkey">Додај поткључ</string>
<string name="title_edit_key">Уреди кључ</string>
<string name="title_preferences">Поставке</string>
@ -191,7 +191,7 @@
<string name="passphrase_must_not_be_empty">Унесите лозинку.</string>
<string name="passphrase_for_symmetric_encryption">Симетрично шифровање.</string>
<string name="passphrase_for">Унесите лозинку за „%s“</string>
<string name="yubikey_pin">Унесите ПИН за приступ Јубикључу за „%s“</string>
<string name="yubikey_pin_for">Унесите ПИН за приступ Јубикључу за „%s“</string>
<string name="file_delete_confirmation">Желите ли заиста да обришете\n%s?</string>
<string name="file_delete_successful">Брисање је успело.</string>
<string name="no_file_selected">Најпре изаберите фајл.</string>

View File

@ -9,7 +9,7 @@
<string name="title_encrypt_text">Kryptera text</string>
<string name="title_encrypt_files">Kryptera filer</string>
<string name="title_decrypt">Dekryptera</string>
<string name="title_authentication">Lösenordsfras</string>
<string name="title_unlock">Lösenordsfras</string>
<string name="title_add_subkey">Lägg till undernyckel</string>
<string name="title_edit_key">Redigera nyckel</string>
<string name="title_preferences">Inställningar</string>
@ -180,7 +180,7 @@
<string name="passphrase_must_not_be_empty">Ange en lösenordsfras.</string>
<string name="passphrase_for_symmetric_encryption">Symmetrisk kryptering.</string>
<string name="passphrase_for">Ange lösenordsfras för \'%s\'</string>
<string name="yubikey_pin">Ange PIN för att få åtkomst till Yubikey för \'%s\'</string>
<string name="yubikey_pin_for">Ange PIN för att få åtkomst till Yubikey för \'%s\'</string>
<string name="file_delete_confirmation">Vill du verkligen radera\n%s?</string>
<string name="file_delete_successful">Raderades.</string>
<string name="no_file_selected">Välj en nyckel först.</string>

View File

@ -9,7 +9,7 @@
<string name="title_encrypt_text">Metni Şifrele</string>
<string name="title_encrypt_files">Dosyaları Şifrele</string>
<string name="title_decrypt">Çözümle</string>
<string name="title_authentication">Parola</string>
<string name="title_unlock">Parola</string>
<string name="title_add_subkey">Alt anahtar ekle</string>
<string name="title_edit_key">Anahtarı düzenle</string>
<string name="title_preferences">Seçenekler</string>

View File

@ -6,7 +6,7 @@
<string name="title_select_recipients">Вибрати ключі</string>
<string name="title_select_secret_key">Виберіть ваш ключ</string>
<string name="title_decrypt">Розшифрувати</string>
<string name="title_authentication">Парольна фраза</string>
<string name="title_unlock">Парольна фраза</string>
<string name="title_add_subkey">Додати підключ</string>
<string name="title_edit_key">Редагувати ключ</string>
<string name="title_preferences">Налаштування</string>

View File

@ -9,7 +9,7 @@
<string name="title_encrypt_text">加密文字</string>
<string name="title_encrypt_files">加密檔案</string>
<string name="title_decrypt">解密</string>
<string name="title_authentication">口令</string>
<string name="title_unlock">口令</string>
<string name="title_add_subkey">新增子金鑰</string>
<string name="title_edit_key">編輯金鑰</string>
<string name="title_preferences">偏好設定</string>

View File

@ -7,7 +7,7 @@
<string name="title_encrypt_text">加密文本</string>
<string name="title_encrypt_files">加密文件</string>
<string name="title_decrypt">解密</string>
<string name="title_authentication">密码</string>
<string name="title_unlock">密码</string>
<string name="title_edit_key">编辑密钥</string>
<string name="title_preferences">参数</string>
<string name="title_api_registered_apps">已注册应用</string>

View File

@ -14,7 +14,7 @@
<string name="title_encrypt_text">"Encrypt Text"</string>
<string name="title_encrypt_files">"Encrypt Files"</string>
<string name="title_decrypt">"Decrypt"</string>
<string name="title_authentication">"Passphrase"</string>
<string name="title_unlock">"Unlock Key"</string>
<string name="title_add_subkey">"Add subkey"</string>
<string name="title_edit_key">"Edit Key"</string>
<string name="title_preferences">"Preferences"</string>
@ -205,7 +205,8 @@
<string name="passphrase_must_not_be_empty">"Please enter a passphrase."</string>
<string name="passphrase_for_symmetric_encryption">"Symmetric encryption."</string>
<string name="passphrase_for">"Enter passphrase for '%s'"</string>
<string name="yubikey_pin">"Enter PIN to access YubiKey for '%s'"</string>
<string name="pin_for">"Enter PIN for '%s'"</string>
<string name="yubikey_pin_for">"Enter PIN to access YubiKey for '%s'"</string>
<string name="nfc_text">"Hold YubiKey against the back of your device."</string>
<string name="file_delete_confirmation">"Are you sure you want to delete\n%s?"</string>
<string name="file_delete_successful">"Successfully deleted."</string>