From 30845969318cba073626216dedef724da95d7b94 Mon Sep 17 00:00:00 2001 From: Jakob Nixdorf Date: Tue, 4 Feb 2020 07:59:16 +0100 Subject: [PATCH] Unify the "last" and "most used" dialogs --- CHANGELOG.md | 1 + .../andotp/Activities/MainActivity.java | 36 +++++-------------- .../flocke/andotp/Utilities/Settings.java | 11 ++---- app/src/main/res/values/settings.xml | 1 - app/src/main/res/values/strings_main.xml | 12 +++---- 5 files changed, 15 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10d80580..539133a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ * New feature: Move the app to the background after copying a token (Issue #373, PR #392 by @Ullas-Aithal) * New feature: Re-lock the app after a certain time of inactivity (Issue #28, PR #390 by @LizardWithHat) * New feature: Re-lock when being send to the background (Issue #216) + * New feature: Sort tokens by "most used" (Issue #443, PR #467 by @Ullas-Aithal) * Improvement: Hide the token list on screen off (Issue #264, PR #390 by @LizardWithHat) * Improvement: Scale the font of the default thumbnail with its size * Improvement: Do not use auto-completion for the account secret (PR #430 by @duchampdev) 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 f09938a4..e9aed5c1 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 @@ -610,8 +610,8 @@ public class MainActivity extends BaseActivity adapter.setSortMode(SortMode.LAST_USED); touchHelperCallback.setDragEnabled(false); } - if (! settings.getLastUsedDialogShown()) - showLastUsedDialog(); + if (! settings.getUsedTokensDialogShown()) + showUsedTokensDialog(); } else if (id == R.id.menu_sort_most_used) { item.setChecked(true); sortMenu.setIcon(R.drawable.ic_sort_inverted_time_white); @@ -620,8 +620,8 @@ public class MainActivity extends BaseActivity adapter.setSortMode(SortMode.MOST_USED); touchHelperCallback.setDragEnabled(false); } - if (! settings.getMostUsedDialogShown()) - showMostUsedDialog(); + if (! settings.getUsedTokensDialogShown()) + showUsedTokensDialog(); } else if (tagsToggle.onOptionsItemSelected(item)) { return true; } @@ -629,31 +629,11 @@ public class MainActivity extends BaseActivity return super.onOptionsItemSelected(item); } - private void showLastUsedDialog() { + private void showUsedTokensDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(R.string.dialog_title_manual_entry) - .setTitle(R.string.dialog_title_last_used) - .setMessage(R.string.dialog_msg_last_used) - .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - settings.setLastUsedDialogShown(true); - } - }) - .create() - .show(); - } - private void showMostUsedDialog() { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(R.string.dialog_title_manual_entry) - .setTitle(R.string.dialog_title_most_used) - .setMessage(R.string.dialog_msg_most_used) - .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - settings.setMostUsedDialogShown(true); - } - }) + builder.setTitle(R.string.dialog_title_used_tokens) + .setMessage(R.string.dialog_msg_used_tokens) + .setPositiveButton(android.R.string.ok, (DialogInterface dialogInterface, int i) -> settings.setUsedTokensDialogShown(true)) .create() .show(); } diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Settings.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Settings.java index 3c92afc8..46a6d9cf 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Settings.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Settings.java @@ -523,20 +523,13 @@ public class Settings { return getBoolean(R.string.settings_key_enable_screenshot, false); } - public boolean getLastUsedDialogShown() { + public boolean getUsedTokensDialogShown() { return getBoolean(R.string.settings_key_last_used_dialog_shown, false); } - public void setLastUsedDialogShown(boolean value) { + public void setUsedTokensDialogShown(boolean value) { setBoolean(R.string.settings_key_last_used_dialog_shown, value); } - public boolean getMostUsedDialogShown() { - return getBoolean(R.string.settings_key_most_used_dialog_shown, false); - } - - public void setMostUsedDialogShown(boolean value) { - setBoolean(R.string.settings_key_most_used_dialog_shown, value); - } public boolean getNewBackupFormatDialogShown() { return getBoolean(R.string.settings_key_new_backup_format_dialog_shown, false); diff --git a/app/src/main/res/values/settings.xml b/app/src/main/res/values/settings.xml index 6d79767a..773706b4 100644 --- a/app/src/main/res/values/settings.xml +++ b/app/src/main/res/values/settings.xml @@ -60,7 +60,6 @@ pref_clear_keystore pref_last_used_dialog_shown - pref_most_used_dialog_shown 30 diff --git a/app/src/main/res/values/strings_main.xml b/app/src/main/res/values/strings_main.xml index a6ab39f2..79df64a8 100644 --- a/app/src/main/res/values/strings_main.xml +++ b/app/src/main/res/values/strings_main.xml @@ -77,8 +77,7 @@ Remove Rename Counter - Last used - Most used + Used tokens KeyStore error Enter password @@ -89,12 +88,9 @@ Please enter your device credentials to start andOTP. Are you sure you want do remove the account \"%1$s\"? - 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. - - In order for andOTP to recognize which token was used the most - you have to have \"tap to reveal\" enabled or use the copy button.\n\nThis message will not + In order for andOTP to recognize which tokens get used you + have to have either \"tap to reveal\" enabled or use the copy button. This applies to the + sorting of the tokens by \"most used\" as well as by \"last used\".\n\nThis message will not be shown again. Failed to load the encryption key from the KeyStore.