diff options
Diffstat (limited to 'OpenKeychain')
12 files changed, 61 insertions, 7 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java index a32c14ca0..04a932658 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java @@ -83,6 +83,7 @@ public final class Constants { public static final String SEARCH_KEYSERVER = "search_keyserver_pref"; public static final String SEARCH_KEYBASE = "search_keybase_pref"; public static final String USE_DEFAULT_YUBIKEY_PIN = "useDefaultYubikeyPin"; + public static final String USE_NUMKEYPAD_FOR_YUBIKEY_PIN="useNumKeypadForYubikeyPin"; } public static final class Defaults { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java index b9761fbf3..deff648ba 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java @@ -27,6 +27,8 @@ import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; +import android.text.InputType; +import android.text.method.PasswordTransformationMethod; import android.view.ContextThemeWrapper; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -52,6 +54,7 @@ import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.service.PassphraseCacheService; import org.sufficientlysecure.keychain.ui.dialog.CustomAlertDialogBuilder; import org.sufficientlysecure.keychain.util.Log; +import org.sufficientlysecure.keychain.util.Preferences; /** * We can not directly create a dialog on the application context. @@ -138,6 +141,7 @@ public class PassphraseDialogActivity extends FragmentActivity { alert.setTitle(R.string.title_authentication); String userId; + CanonicalizedSecretKey.SecretKeyType keyType = CanonicalizedSecretKey.SecretKeyType.PASSPHRASE; if (mSubKeyId == Constants.key.symmetric || mSubKeyId == Constants.key.none) { alert.setMessage(R.string.passphrase_for_symmetric_encryption); @@ -161,7 +165,7 @@ public class PassphraseDialogActivity extends FragmentActivity { long masterKeyId = new ProviderHelper(activity).getMasterKeyId(mSubKeyId); CachedPublicKeyRing keyRing = new ProviderHelper(activity).getCachedPublicKeyRing(masterKeyId); // get the type of key (from the database) - CanonicalizedSecretKey.SecretKeyType keyType = keyRing.getSecretKeyType(mSubKeyId); + keyType = keyRing.getSecretKeyType(mSubKeyId); switch (keyType) { case PASSPHRASE: message = getString(R.string.passphrase_for, userId); @@ -231,6 +235,14 @@ public class PassphraseDialogActivity extends FragmentActivity { mPassphraseEditText.setImeActionLabel(getString(android.R.string.ok), EditorInfo.IME_ACTION_DONE); mPassphraseEditText.setOnEditorActionListener(this); + if (keyType == CanonicalizedSecretKey.SecretKeyType.DIVERT_TO_CARD && Preferences.getPreferences(activity).useNumKeypadForYubikeyPin()) { + 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, activity.getString(android.R.string.ok), (DialogInterface.OnClickListener) null); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java index 9d3175d15..51fac4779 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java @@ -127,6 +127,9 @@ public class PreferencesActivity extends PreferenceActivity { initializeUseDefaultYubikeyPin( (CheckBoxPreference) findPreference(Constants.Pref.USE_DEFAULT_YUBIKEY_PIN)); + initializeUseNumKeypadForYubikeyPin( + (CheckBoxPreference) findPreference(Constants.Pref.USE_NUMKEYPAD_FOR_YUBIKEY_PIN)); + } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { // Load the legacy preferences headers addPreferencesFromResource(R.xml.preference_headers_legacy); @@ -278,6 +281,9 @@ public class PreferencesActivity extends PreferenceActivity { initializeUseDefaultYubikeyPin( (CheckBoxPreference) findPreference(Constants.Pref.USE_DEFAULT_YUBIKEY_PIN)); + + initializeUseNumKeypadForYubikeyPin( + (CheckBoxPreference) findPreference(Constants.Pref.USE_NUMKEYPAD_FOR_YUBIKEY_PIN)); } } @@ -463,4 +469,14 @@ public class PreferencesActivity extends PreferenceActivity { }); } + private static void initializeUseNumKeypadForYubikeyPin(final CheckBoxPreference mUseNumKeypadForYubikeyPin) { + mUseNumKeypadForYubikeyPin.setChecked(sPreferences.useNumKeypadForYubikeyPin()); + mUseNumKeypadForYubikeyPin.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + public boolean onPreferenceChange(Preference preference, Object newValue) { + mUseNumKeypadForYubikeyPin.setChecked((Boolean) newValue); + sPreferences.setUseNumKeypadForYubikeyPin((Boolean) newValue); + return false; + } + }); + } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java index 8560bccc0..40ee8e0e9 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java @@ -31,6 +31,8 @@ import android.os.Messenger; import android.os.RemoteException; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; +import android.text.InputType; +import android.text.method.PasswordTransformationMethod; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; @@ -54,6 +56,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.service.PassphraseCacheService; import org.sufficientlysecure.keychain.util.Log; +import org.sufficientlysecure.keychain.util.Preferences; public class PassphraseDialogFragment extends DialogFragment implements OnEditorActionListener { private static final String ARG_MESSENGER = "messenger"; @@ -132,6 +135,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor alert.setTitle(R.string.title_authentication); String userId; + CanonicalizedSecretKey.SecretKeyType keyType = CanonicalizedSecretKey.SecretKeyType.PASSPHRASE; if (mSubKeyId == Constants.key.symmetric || mSubKeyId == Constants.key.none) { alert.setMessage(R.string.passphrase_for_symmetric_encryption); @@ -155,7 +159,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor long masterKeyId = new ProviderHelper(getActivity()).getMasterKeyId(mSubKeyId); CachedPublicKeyRing keyRing = new ProviderHelper(getActivity()).getCachedPublicKeyRing(masterKeyId); // get the type of key (from the database) - CanonicalizedSecretKey.SecretKeyType keyType = keyRing.getSecretKeyType(mSubKeyId); + keyType = keyRing.getSecretKeyType(mSubKeyId); switch (keyType) { case PASSPHRASE: message = getString(R.string.passphrase_for, userId); @@ -226,6 +230,13 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor mPassphraseEditText.setImeActionLabel(getString(android.R.string.ok), EditorInfo.IME_ACTION_DONE); mPassphraseEditText.setOnEditorActionListener(this); + if (keyType == CanonicalizedSecretKey.SecretKeyType.DIVERT_TO_CARD && Preferences.getPreferences(activity).useNumKeypadForYubikeyPin()) { + 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, activity.getString(android.R.string.ok), (DialogInterface.OnClickListener) null); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java index bdb7c65fc..52e083fd4 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java @@ -191,6 +191,16 @@ public class Preferences { editor.commit(); } + public boolean useNumKeypadForYubikeyPin() { + return mSharedPreferences.getBoolean(Pref.USE_NUMKEYPAD_FOR_YUBIKEY_PIN, false); + } + + public void setUseNumKeypadForYubikeyPin(boolean useNumKeypadForYubikeyPin) { + SharedPreferences.Editor editor = mSharedPreferences.edit(); + editor.putBoolean(Pref.USE_NUMKEYPAD_FOR_YUBIKEY_PIN, useNumKeypadForYubikeyPin); + editor.commit(); + } + public void setFirstTime(boolean value) { SharedPreferences.Editor editor = mSharedPreferences.edit(); editor.putBoolean(Constants.Pref.FIRST_TIME, value); diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_action_qr_code.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_action_qr_code.png Binary files differindex 1c65e5af8..ceb3b1645 100644 --- a/OpenKeychain/src/main/res/drawable-hdpi/ic_action_qr_code.png +++ b/OpenKeychain/src/main/res/drawable-hdpi/ic_action_qr_code.png diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_action_qr_code.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_action_qr_code.png Binary files differindex 570212461..21594e62f 100644 --- a/OpenKeychain/src/main/res/drawable-mdpi/ic_action_qr_code.png +++ b/OpenKeychain/src/main/res/drawable-mdpi/ic_action_qr_code.png diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_qr_code.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_qr_code.png Binary files differindex ce8965396..93bdac866 100644 --- a/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_qr_code.png +++ b/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_qr_code.png diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_qr_code.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_qr_code.png Binary files differindex c56b128e4..7ede90609 100644 --- a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_qr_code.png +++ b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_qr_code.png diff --git a/OpenKeychain/src/main/res/layout/passphrase_dialog.xml b/OpenKeychain/src/main/res/layout/passphrase_dialog.xml index f003e6994..2ca5199fd 100644 --- a/OpenKeychain/src/main/res/layout/passphrase_dialog.xml +++ b/OpenKeychain/src/main/res/layout/passphrase_dialog.xml @@ -19,7 +19,6 @@ android:layout_marginTop="8dp" android:layout_marginBottom="8dp" android:imeOptions="actionDone" - android:inputType="textPassword" android:hint="@string/label_passphrase" android:ems="10" android:layout_gravity="center_horizontal" /> diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 0b0f0b4fd..d94f9e800 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -49,7 +49,7 @@ <string name="section_advanced">"Advanced"</string> <string name="section_certify">"Certify"</string> <string name="section_actions">"Actions"</string> - <string name="section_share_key">"Public key"</string> + <string name="section_share_key">"Key"</string> <string name="section_certification_key">"Your Key used for certification"</string> <string name="section_upload_key">"Synchronize Key"</string> <string name="section_key_server">"Keyserver"</string> @@ -112,6 +112,7 @@ <string name="label_write_version_header">"Let others know that you're using OpenKeychain"</string> <string name="label_write_version_header_summary">"Writes 'OpenKeychain v2.7' to OpenPGP signatures, ciphertext, and exported keys"</string> <string name="label_use_default_yubikey_pin">"Use default Yubikey PIN"</string> + <string name="label_use_num_keypad_for_yubikey_pin">Use number keypad for Yubikey PIN</string> <string name="label_label_use_default_yubikey_pin_summary">"Uses default PIN (123456) to access Yubikeys over NFC"</string> <string name="label_asymmetric_from">"Signed by:"</string> <string name="label_to">"Encrypt to:"</string> @@ -836,8 +837,8 @@ <string name="msg_con_error_io_secret">"IO error writing secret keys to cache!"</string> <string name="msg_con_error_public">"Error reimporting public keys!"</string> <string name="msg_con_error_secret">"Error reimporting secret keys!"</string> - <string name="msg_con_recover">"Recovering consolidation"</string> - <string name="msg_con_recover_unknown">"Recovering from unknown state"</string> + <string name="msg_con_recover">"Resuming consolidation process"</string> + <string name="msg_con_recover_unknown">"Resuming consolidation process from unknown state"</string> <plurals name="msg_con_reimport_public"> <item quantity="one">"Reimporting one public key"</item> <item quantity="other">"Reimporting %d public keys"</item> diff --git a/OpenKeychain/src/main/res/xml/adv_preferences.xml b/OpenKeychain/src/main/res/xml/adv_preferences.xml index 92e0f2ffc..fcca59abe 100644 --- a/OpenKeychain/src/main/res/xml/adv_preferences.xml +++ b/OpenKeychain/src/main/res/xml/adv_preferences.xml @@ -44,5 +44,9 @@ android:defaultValue="true" android:title="@string/label_use_default_yubikey_pin" android:summary="@string/label_label_use_default_yubikey_pin_summary" /> - + <CheckBoxPreference + android:key="useNumKeypadForYubikeyPin" + android:persistent="false" + android:defaultValue="false" + android:title="@string/label_use_num_keypad_for_yubikey_pin" /> </PreferenceScreen> |