From 34c3f57b19147b4bf48c380ecf77e941f5bc834f Mon Sep 17 00:00:00 2001 From: MrLetsplay Date: Fri, 26 Jan 2024 21:06:47 +0100 Subject: [PATCH] Update project, Tap to copy if code is visible, Update version --- app/build.gradle | 8 +++---- .../code_guard/otplist/OTPListAdapter.java | 24 ++++++++++++------- app/src/main/res/values-de/strings.xml | 2 ++ app/src/main/res/values-fr/strings.xml | 2 ++ app/src/main/res/values-pl/strings.xml | 2 ++ app/src/main/res/values-uk/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 4 +++- build.gradle | 4 ++-- 8 files changed, 33 insertions(+), 15 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d555b5a..624d1f2 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 7 - versionName "1.0.0_beta2" + versionCode 8 + versionName "1.0.0_beta3" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -71,8 +71,8 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.11.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'androidx.lifecycle:lifecycle-livedata:2.6.2' - implementation 'androidx.lifecycle:lifecycle-viewmodel:2.6.2' + implementation 'androidx.lifecycle:lifecycle-livedata:2.7.0' + implementation 'androidx.lifecycle:lifecycle-viewmodel:2.7.0' implementation 'androidx.navigation:navigation-fragment:2.7.6' implementation 'androidx.navigation:navigation-ui:2.7.6' testImplementation 'junit:junit:4.13.2' 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 03b6ad9..0166895 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 @@ -1,5 +1,7 @@ package com.cringe_studios.code_guard.otplist; +import android.content.ClipData; +import android.content.ClipboardManager; import android.content.Context; import android.os.Handler; import android.os.Looper; @@ -73,7 +75,7 @@ public class OTPListAdapter extends RecyclerView.Adapter { try { holder.refresh(); } catch (OTPException e) { - DialogUtil.showErrorDialog(context, context.getString(R.string.otp_add_error, e.getMessage() != null ? e.getMessage() : e.toString())); + DialogUtil.showErrorDialog(context, context.getString(R.string.otp_add_error), e); } holder.getBinding().otpCodeIcon.setVisibility(SettingsUtil.isShowImages(context) ? View.VISIBLE : View.GONE); @@ -103,18 +105,24 @@ public class OTPListAdapter extends RecyclerView.Adapter { holder.getBinding().getRoot().setOnClickListener(view -> { if(!editing) { - if(!SettingsUtil.isHideCodes(context)) return; - - if(!holder.isCodeShown()) { - showCode(holder); - }else { - holder.setCodeShown(false); + if(!SettingsUtil.isHideCodes(context) || holder.isCodeShown()) { + try { + ClipboardManager manager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); + ClipData clip = ClipData.newPlainText(null, holder.getOTPData().getPin()); + manager.setPrimaryClip(clip); + Toast.makeText(context, R.string.otp_copied, Toast.LENGTH_SHORT).show(); + } catch (OTPException e) { + DialogUtil.showErrorDialog(context, context.getString(R.string.otp_copy_error), e); + } + return; } + showCode(holder); + try { holder.refresh(); } catch (OTPException e) { - DialogUtil.showErrorDialog(context, context.getString(R.string.otp_add_error, e.getMessage() != null ? e.getMessage() : e.toString())); + DialogUtil.showErrorDialog(context, context.getString(R.string.otp_add_error), e); } }else { holder.setSelected(!holder.isSelected()); diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 374a448..f84bcb9 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -174,4 +174,6 @@ Supergeheime Einstellungen Ich mag Hamburger 🍔 Extra-Cringe-Symbol verwenden + Kopieren des OTP-Codes fehlgeschlagen + OTP-Code in die Zwischenablage kopiert \ 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 0c98e07..f8ed495 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -160,4 +160,6 @@ Paramètres super secrets J\'aime les hamburgers 🍔 Utiliser l\'icône de l\'humour supplémentaire + Échec de la copie de l\'OTP dans le presse-papiers + OTP copié dans le presse-papiers \ 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 ab3bd85..8cd0307 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -160,4 +160,6 @@ Super tajne ustawienia Lubię hamburgery 🍔 Użyj dodatkowej ikony cringe + Nie udało się skopiować OTP do schowka + OTP skopiowany do schowka \ 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 92f347d..109251f 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -160,4 +160,6 @@ Суперсекретні налаштування Я люблю гамбургери 🍔 Використовуйте додаткову піктограму обтиснення + Не вдалося скопіювати OTP до буфера обміну + OTP скопійовано в буфер обміну \ 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 8dbbb59..6c67410 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -42,7 +42,8 @@ Secret Name Period - Failed to update OTP: %s + Failed to update OTP + Failed to copy OTP to clipboard Issuer (optional) Missing name OTP Migration @@ -191,4 +192,5 @@ Super Secret Settings I like hamburgers 🍔 Use extra cringe icon + OTP copied to clipboard \ No newline at end of file diff --git a/build.gradle b/build.gradle index f26916f..67edaeb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id 'com.android.application' version '8.2.0' apply false - id 'com.android.library' version '8.2.0' apply false + id 'com.android.application' version '8.2.2' apply false + id 'com.android.library' version '8.2.2' apply false id 'com.google.protobuf' version '0.9.3' apply false } \ No newline at end of file