From 0c0fb0f2c73367a206daf6071b88d4dc77892483 Mon Sep 17 00:00:00 2001 From: Jakob Nixdorf Date: Thu, 11 Jan 2018 13:14:40 +0100 Subject: [PATCH] Update first run dialog --- .../andotp/Activities/MainActivity.java | 33 ++++++---- .../res/layout/dialog_database_encryption.xml | 60 +++++++++++++++++++ .../res/layout/dialog_security_backup.xml | 39 ------------ app/src/main/res/values/strings_main.xml | 36 ++++++----- 4 files changed, 103 insertions(+), 65 deletions(-) create mode 100644 app/src/main/res/layout/dialog_database_encryption.xml delete mode 100644 app/src/main/res/layout/dialog_security_backup.xml diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java b/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java index 81dfe5a1..353b8693 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java @@ -106,15 +106,32 @@ public class MainActivity extends BaseActivity private void showFirstTimeWarning() { ViewGroup container = findViewById(R.id.main_content); - View msgView = getLayoutInflater().inflate(R.layout.dialog_security_backup, container, false); + View msgView = getLayoutInflater().inflate(R.layout.dialog_database_encryption, container, false); AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(R.string.dialog_title_security_backup) + builder.setTitle(R.string.dialog_title_encryption) .setView(msgView) - .setPositiveButton(R.string.button_warned, new DialogInterface.OnClickListener() { + .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { settings.setFirstTimeWarningShown(true); + updateEncryption(null); + } + }) + .setNegativeButton(R.string.button_settings, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + settings.setFirstTimeWarningShown(true); + + Intent settingsIntent = new Intent(getBaseContext(), SettingsActivity.class); + startActivityForResult(settingsIntent, Constants.INTENT_MAIN_SETTINGS); + } + }) + .setOnCancelListener(new DialogInterface.OnCancelListener() { + @Override + public void onCancel(DialogInterface dialogInterface) { + settings.setFirstTimeWarningShown(true); + updateEncryption(null); } }) .create() @@ -316,15 +333,9 @@ public class MainActivity extends BaseActivity authenticate(R.string.auth_msg_authenticate); } } else { - if (encryptionType == EncryptionType.KEYSTORE) { + if (settings.getFirstTimeWarningShown()) { if (adapter.getEncryptionKey() == null) { - adapter.setEncryptionKey(KeyStoreHelper.loadEncryptionKeyFromKeyStore(this, false)); - } - - populateAdapter(); - } else if (encryptionType == EncryptionType.PASSWORD) { - if (adapter.getEncryptionKey() == null) { - authenticate(R.string.auth_msg_authenticate); + updateEncryption(null); } else { populateAdapter(); } diff --git a/app/src/main/res/layout/dialog_database_encryption.xml b/app/src/main/res/layout/dialog_database_encryption.xml new file mode 100644 index 00000000..69d322e7 --- /dev/null +++ b/app/src/main/res/layout/dialog_database_encryption.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_security_backup.xml b/app/src/main/res/layout/dialog_security_backup.xml deleted file mode 100644 index 62afe8a0..00000000 --- a/app/src/main/res/layout/dialog_security_backup.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/strings_main.xml b/app/src/main/res/values/strings_main.xml index 3f04ce5c..ea8b3ca2 100644 --- a/app/src/main/res/values/strings_main.xml +++ b/app/src/main/res/values/strings_main.xml @@ -7,7 +7,7 @@ Scan QR-Code Save New tag - You have been warned! + Settings All tags No tags @@ -63,26 +63,32 @@ Enter details Remove Rename - Security and Backups Last used KeyStore error + Database encryption Please enter your device credentials to start andOTP. Are you sure you want do remove the account \"%1$s\"? - To keep your account information secure this app - only stores it encrypted. Part of the encryption key used for this is stored in the Android - KeyStore system. The advantage of this approach is that the key is kept separate from the - apps data and can be backed by hardware cryptography (if your device supports this). - - As a drawback this makes backups of the apps - data a little bit more difficult. If you use 3rd party apps (like Titanium Backup) you only - backup the data files, not the encryption key and as a result such backups become useless. - - Please only use the internal backup functions - provided by the app to backup your accounts! Anything else WILL lead to data loss. - - This message will not be shown again. + 1. Android KeyStore + 2. Password / PIN + + To ensure the security of your accounts this app + only stores them in encrypted data files using one of the following two methods: + The KeyStore is a system component of Android for + securely storing cryptographic keys. The advantage of this approach is that the keys are + stored separated from the data files and can be backed by hardware cryptography (if the + hardware supports it). However as the keys are not stored with the apps data this method + prevents external backup solutions (like Titanium) from working. If you choose this method + you will have to rely on the internal backup functions provided by andOTP. + This method will encrypt your data with a key + generated from a password or PIN. The main advantage here is that this will work with + external backup solutions (like Titanium). However you will have to enter your credentials + every time you start andOTP. + By default the Android KeyStore will be used, however + this is known to cause problems on certain custom ROMs (and a few stock ones as well). You + can change the encryption in the Settings by clicking on the button below. + In order for andOTP to recognize which token was used last you have to have \"tap to reveal\" enabled or use the copy button.\n\nThis message will not be shown again.