From 4a8dfc669480cb88045a9f9af3f9b6d1ae437cea Mon Sep 17 00:00:00 2001 From: MrLetsplay Date: Sat, 7 Sep 2024 21:39:36 +0200 Subject: [PATCH] Add option to show next code, Bump version to 1.1 (11) --- app/build.gradle | 18 ++++++------ .../code_guard/fragment/SettingsFragment.java | 3 ++ .../code_guard/model/OTPData.java | 6 ++-- .../code_guard/otplist/OTPListAdapter.java | 1 + .../code_guard/otplist/OTPListItem.java | 1 + .../code_guard/util/SettingsUtil.java | 8 +++++ app/src/main/res/layout/fragment_settings.xml | 6 ++++ app/src/main/res/layout/otp_code.xml | 29 ++++++++++++++----- app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values-pl/strings.xml | 1 + app/src/main/res/values-uk/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 13 files changed, 59 insertions(+), 18 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index da53454..cbdd092 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,8 +11,8 @@ android { applicationId "com.cringe_studios.code_guard" minSdk 21 targetSdk 34 - versionCode 10 - versionName "1.0.1" + versionCode 11 + versionName "1.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -71,18 +71,18 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.7.0' implementation 'com.google.android.material:material:1.12.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'androidx.lifecycle:lifecycle-livedata:2.8.3' - implementation 'androidx.lifecycle:lifecycle-viewmodel:2.8.3' - implementation 'androidx.navigation:navigation-fragment:2.7.7' - implementation 'androidx.navigation:navigation-ui:2.7.7' + implementation 'androidx.lifecycle:lifecycle-livedata:2.8.5' + implementation 'androidx.lifecycle:lifecycle-viewmodel:2.8.5' + implementation 'androidx.navigation:navigation-fragment:2.8.0' + implementation 'androidx.navigation:navigation-ui:2.8.0' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.2.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' implementation "androidx.biometric:biometric:1.1.0" - implementation 'com.cringe_studios:CringeAuthenticatorLibrary:1.6' - implementation 'com.google.mlkit:barcode-scanning:17.2.0' + implementation 'com.cringe_studios:CringeAuthenticatorLibrary:1.7' + implementation 'com.google.mlkit:barcode-scanning:17.3.0' implementation 'com.google.code.gson:gson:2.10.1' - implementation 'androidx.activity:activity:1.9.0' + implementation 'androidx.activity:activity:1.9.2' def camerax_version = "1.3.4" implementation "androidx.camera:camera-core:${camerax_version}" diff --git a/app/src/main/java/com/cringe_studios/code_guard/fragment/SettingsFragment.java b/app/src/main/java/com/cringe_studios/code_guard/fragment/SettingsFragment.java index eff997b..77e4679 100644 --- a/app/src/main/java/com/cringe_studios/code_guard/fragment/SettingsFragment.java +++ b/app/src/main/java/com/cringe_studios/code_guard/fragment/SettingsFragment.java @@ -262,6 +262,9 @@ public class SettingsFragment extends NamedFragment { binding.settingsGroupSize.setValue(SettingsUtil.getDigitGroupSize(requireContext())); binding.settingsGroupSize.addOnChangeListener((view, value, fromUser) -> SettingsUtil.setDigitGroupSize(requireContext(), (int) value)); + binding.settingsShowNextCode.setChecked(SettingsUtil.isShowNextCode(requireContext())); + binding.settingsShowNextCode.setOnCheckedChangeListener((view, checked) -> SettingsUtil.setShowNextCode(requireContext(), checked)); + binding.settingsCreateBackup.setOnClickListener(view -> { new StyledDialogBuilder(requireContext()) .setTitle(R.string.create_backup) diff --git a/app/src/main/java/com/cringe_studios/code_guard/model/OTPData.java b/app/src/main/java/com/cringe_studios/code_guard/model/OTPData.java index a42cd31..ea75bda 100644 --- a/app/src/main/java/com/cringe_studios/code_guard/model/OTPData.java +++ b/app/src/main/java/com/cringe_studios/code_guard/model/OTPData.java @@ -1,7 +1,5 @@ package com.cringe_studios.code_guard.model; -import android.util.Log; - import com.cringe_studios.cringe_authenticator_library.OTP; import com.cringe_studios.cringe_authenticator_library.OTPAlgorithm; import com.cringe_studios.cringe_authenticator_library.OTPException; @@ -104,6 +102,10 @@ public class OTPData implements Serializable { return getOTP().getPin(); } + public String getNextPin() throws OTPException { + return getOTP().getNextPin(); + } + public void incrementCounter() { getOTP().incrementCounter(); this.counter = getOTP().getCounter(); diff --git a/app/src/main/java/com/cringe_studios/code_guard/otplist/OTPListAdapter.java b/app/src/main/java/com/cringe_studios/code_guard/otplist/OTPListAdapter.java index 13570f0..4c5c4e3 100644 --- a/app/src/main/java/com/cringe_studios/code_guard/otplist/OTPListAdapter.java +++ b/app/src/main/java/com/cringe_studios/code_guard/otplist/OTPListAdapter.java @@ -80,6 +80,7 @@ public class OTPListAdapter extends RecyclerView.Adapter { } holder.getBinding().otpCodeIcon.setVisibility(SettingsUtil.isShowImages(context) ? View.VISIBLE : View.GONE); + holder.getBinding().nextOtpCode.setVisibility(SettingsUtil.isShowNextCode(context) ? View.VISIBLE : View.GONE); holder.getBinding().label.setText(String.format("%s%s", data.getIssuer() == null || data.getIssuer().isEmpty() ? "" : data.getIssuer() + ": ", data.getName())); holder.getBinding().progress.setVisibility(data.getType() == OTPType.TOTP ? View.VISIBLE : View.GONE); diff --git a/app/src/main/java/com/cringe_studios/code_guard/otplist/OTPListItem.java b/app/src/main/java/com/cringe_studios/code_guard/otplist/OTPListItem.java index 6ada179..8656bdd 100644 --- a/app/src/main/java/com/cringe_studios/code_guard/otplist/OTPListItem.java +++ b/app/src/main/java/com/cringe_studios/code_guard/otplist/OTPListItem.java @@ -53,6 +53,7 @@ public class OTPListItem extends RecyclerView.ViewHolder { public void refresh() throws OTPException { binding.otpCode.setText(formatCode(otpData.getPin())); + binding.nextOtpCode.setText(formatCode(otpData.getNextPin())); if(otpData.getType() == OTPType.TOTP) { long timeDiff = otpData.getNextDueTime() - System.currentTimeMillis() / 1000; diff --git a/app/src/main/java/com/cringe_studios/code_guard/util/SettingsUtil.java b/app/src/main/java/com/cringe_studios/code_guard/util/SettingsUtil.java index 2a3a679..3f7f0db 100644 --- a/app/src/main/java/com/cringe_studios/code_guard/util/SettingsUtil.java +++ b/app/src/main/java/com/cringe_studios/code_guard/util/SettingsUtil.java @@ -268,6 +268,14 @@ public class SettingsUtil { return ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE).getBoolean("searchEverywhere", true); } + public static void setShowNextCode(Context ctx, boolean enable) { + ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE).edit().putBoolean("showNextCode", enable).apply(); + } + + public static boolean isShowNextCode(Context ctx) { + return ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE).getBoolean("showNextCode", false); + } + public static void setHiddenStyle(Context ctx, HiddenStyle style) { ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE).edit().putString("hiddenStyle", style.name()).apply(); } diff --git a/app/src/main/res/layout/fragment_settings.xml b/app/src/main/res/layout/fragment_settings.xml index e764359..6d8c120 100644 --- a/app/src/main/res/layout/fragment_settings.xml +++ b/app/src/main/res/layout/fragment_settings.xml @@ -193,6 +193,12 @@ android:valueTo="6" android:stepSize="1" /> + + - + android:gravity="center" + android:orientation="vertical"> + + + + + + app:srcCompat="@drawable/progress_circle" + tools:visibility="gone" /> Sterne Punkte Gruppengröße für Ziffern + Nächsten Code anzeigen \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index cf16c1c..e6180d6 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -176,4 +176,5 @@ Points Taille du groupe de chiffres Créer avec un nouveau mot de passe + Afficher le code suivant \ No newline at end of file diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 0bf96af..b91ed5d 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -176,4 +176,5 @@ Kropki Wielkość grupy cyfr Utwórz z nowym hasłem + Pokaż następny kod \ No newline at end of file diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 340da1e..0dc0862 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -176,4 +176,5 @@ Крапки Розмір групи цифр Створити з новим паролем + Показати наступний код \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 63cab4b..6d746a6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -197,4 +197,5 @@ Stars Dots Digit group size + Show next code \ No newline at end of file