Add option to show next code, Bump version to 1.1 (11)

This commit is contained in:
MrLetsplay 2024-09-07 21:39:36 +02:00
parent 2ed7dc3968
commit 4a8dfc6694
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
13 changed files with 59 additions and 18 deletions

View File

@ -11,8 +11,8 @@ android {
applicationId "com.cringe_studios.code_guard" applicationId "com.cringe_studios.code_guard"
minSdk 21 minSdk 21
targetSdk 34 targetSdk 34
versionCode 10 versionCode 11
versionName "1.0.1" versionName "1.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
@ -71,18 +71,18 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.7.0' implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.google.android.material:material:1.12.0' implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.lifecycle:lifecycle-livedata:2.8.3' implementation 'androidx.lifecycle:lifecycle-livedata:2.8.5'
implementation 'androidx.lifecycle:lifecycle-viewmodel:2.8.3' implementation 'androidx.lifecycle:lifecycle-viewmodel:2.8.5'
implementation 'androidx.navigation:navigation-fragment:2.7.7' implementation 'androidx.navigation:navigation-fragment:2.8.0'
implementation 'androidx.navigation:navigation-ui:2.7.7' implementation 'androidx.navigation:navigation-ui:2.8.0'
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.2.1' androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
implementation "androidx.biometric:biometric:1.1.0" implementation "androidx.biometric:biometric:1.1.0"
implementation 'com.cringe_studios:CringeAuthenticatorLibrary:1.6' implementation 'com.cringe_studios:CringeAuthenticatorLibrary:1.7'
implementation 'com.google.mlkit:barcode-scanning:17.2.0' implementation 'com.google.mlkit:barcode-scanning:17.3.0'
implementation 'com.google.code.gson:gson:2.10.1' 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" def camerax_version = "1.3.4"
implementation "androidx.camera:camera-core:${camerax_version}" implementation "androidx.camera:camera-core:${camerax_version}"

View File

@ -262,6 +262,9 @@ public class SettingsFragment extends NamedFragment {
binding.settingsGroupSize.setValue(SettingsUtil.getDigitGroupSize(requireContext())); binding.settingsGroupSize.setValue(SettingsUtil.getDigitGroupSize(requireContext()));
binding.settingsGroupSize.addOnChangeListener((view, value, fromUser) -> SettingsUtil.setDigitGroupSize(requireContext(), (int) value)); 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 -> { binding.settingsCreateBackup.setOnClickListener(view -> {
new StyledDialogBuilder(requireContext()) new StyledDialogBuilder(requireContext())
.setTitle(R.string.create_backup) .setTitle(R.string.create_backup)

View File

@ -1,7 +1,5 @@
package com.cringe_studios.code_guard.model; 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.OTP;
import com.cringe_studios.cringe_authenticator_library.OTPAlgorithm; import com.cringe_studios.cringe_authenticator_library.OTPAlgorithm;
import com.cringe_studios.cringe_authenticator_library.OTPException; import com.cringe_studios.cringe_authenticator_library.OTPException;
@ -104,6 +102,10 @@ public class OTPData implements Serializable {
return getOTP().getPin(); return getOTP().getPin();
} }
public String getNextPin() throws OTPException {
return getOTP().getNextPin();
}
public void incrementCounter() { public void incrementCounter() {
getOTP().incrementCounter(); getOTP().incrementCounter();
this.counter = getOTP().getCounter(); this.counter = getOTP().getCounter();

View File

@ -80,6 +80,7 @@ public class OTPListAdapter extends RecyclerView.Adapter<OTPListItem> {
} }
holder.getBinding().otpCodeIcon.setVisibility(SettingsUtil.isShowImages(context) ? View.VISIBLE : View.GONE); 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().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); holder.getBinding().progress.setVisibility(data.getType() == OTPType.TOTP ? View.VISIBLE : View.GONE);

View File

@ -53,6 +53,7 @@ public class OTPListItem extends RecyclerView.ViewHolder {
public void refresh() throws OTPException { public void refresh() throws OTPException {
binding.otpCode.setText(formatCode(otpData.getPin())); binding.otpCode.setText(formatCode(otpData.getPin()));
binding.nextOtpCode.setText(formatCode(otpData.getNextPin()));
if(otpData.getType() == OTPType.TOTP) { if(otpData.getType() == OTPType.TOTP) {
long timeDiff = otpData.getNextDueTime() - System.currentTimeMillis() / 1000; long timeDiff = otpData.getNextDueTime() - System.currentTimeMillis() / 1000;

View File

@ -268,6 +268,14 @@ public class SettingsUtil {
return ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE).getBoolean("searchEverywhere", true); 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) { public static void setHiddenStyle(Context ctx, HiddenStyle style) {
ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE).edit().putString("hiddenStyle", style.name()).apply(); ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE).edit().putString("hiddenStyle", style.name()).apply();
} }

View File

@ -193,6 +193,12 @@
android:valueTo="6" android:valueTo="6"
android:stepSize="1" /> android:stepSize="1" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/settings_show_next_code"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/settings_show_next_code" />
</LinearLayout> </LinearLayout>
<View <View

View File

@ -52,21 +52,36 @@
android:layout_width="30dp" android:layout_width="30dp"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
<TextView <LinearLayout
android:id="@+id/otpCode"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/otpCode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="monospace" android:fontFamily="monospace"
android:gravity="top|center" android:gravity="top|center"
android:textSize="24sp" android:textSize="24sp"
tools:text="000000" /> tools:text="000000" />
<TextView
android:id="@+id/nextOtpCode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
tools:text="111111" />
</LinearLayout>
<ImageView <ImageView
android:id="@+id/progress" android:id="@+id/progress"
android:layout_width="30dp" android:layout_width="30dp"
android:layout_height="30dp" android:layout_height="30dp"
app:srcCompat="@drawable/progress_circle" /> app:srcCompat="@drawable/progress_circle"
tools:visibility="gone" />
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/refresh" android:id="@+id/refresh"

View File

@ -176,4 +176,5 @@
<string name="style_stars">Sterne</string> <string name="style_stars">Sterne</string>
<string name="style_dots">Punkte</string> <string name="style_dots">Punkte</string>
<string name="settings_group_size">Gruppengröße für Ziffern</string> <string name="settings_group_size">Gruppengröße für Ziffern</string>
<string name="settings_show_next_code">Nächsten Code anzeigen</string>
</resources> </resources>

View File

@ -176,4 +176,5 @@
<string name="style_dots">Points</string> <string name="style_dots">Points</string>
<string name="settings_group_size">Taille du groupe de chiffres</string> <string name="settings_group_size">Taille du groupe de chiffres</string>
<string name="backup_create_new_password">Créer avec un nouveau mot de passe</string> <string name="backup_create_new_password">Créer avec un nouveau mot de passe</string>
<string name="settings_show_next_code">Afficher le code suivant</string>
</resources> </resources>

View File

@ -176,4 +176,5 @@
<string name="style_dots">Kropki</string> <string name="style_dots">Kropki</string>
<string name="settings_group_size">Wielkość grupy cyfr</string> <string name="settings_group_size">Wielkość grupy cyfr</string>
<string name="backup_create_new_password">Utwórz z nowym hasłem</string> <string name="backup_create_new_password">Utwórz z nowym hasłem</string>
<string name="settings_show_next_code">Pokaż następny kod</string>
</resources> </resources>

View File

@ -176,4 +176,5 @@
<string name="style_dots">Крапки</string> <string name="style_dots">Крапки</string>
<string name="settings_group_size">Розмір групи цифр</string> <string name="settings_group_size">Розмір групи цифр</string>
<string name="backup_create_new_password">Створити з новим паролем</string> <string name="backup_create_new_password">Створити з новим паролем</string>
<string name="settings_show_next_code">Показати наступний код</string>
</resources> </resources>

View File

@ -197,4 +197,5 @@
<string name="style_stars">Stars</string> <string name="style_stars">Stars</string>
<string name="style_dots">Dots</string> <string name="style_dots">Dots</string>
<string name="settings_group_size">Digit group size</string> <string name="settings_group_size">Digit group size</string>
<string name="settings_show_next_code">Show next code</string>
</resources> </resources>