From 98237ef76c8d0354df042d1772be458c4e93c34e Mon Sep 17 00:00:00 2001 From: Filippo De Bortoli Date: Tue, 24 Mar 2020 10:42:45 +0000 Subject: [PATCH 01/18] Translated using Weblate (Italian) Currently translated at 79.5% (339 of 426 strings) Translation: KeePass DX/Strings Translate-URL: https://hosted.weblate.org/projects/keepass-dx/strings/it/ --- app/src/main/res/values-it/strings.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index d59e46726..d9fb53855 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -27,7 +27,7 @@ Aggiungi gruppo Algoritmo di cifratura Scadenza app - Inattività prima del blocco dell\'app + Tempo di inattività prima del blocco dell\'app App Impostazioni app Parentesi @@ -82,7 +82,7 @@ conferma password password generata Nome gruppo - file chiave + File chiave lunghezza Password password @@ -140,7 +140,7 @@ Maiuscole Attenzione Evita password con caratteri al di fuori del formato di codifica del testo nel file di database (i caratteri non riconosciuti vengono convertiti nella stessa lettera). - Monta la scheda SD per creare o caricare un database. + Monta la scheda di memoria per poter creare o caricare un database. Versione %1$s La scansione di impronte è supportata ma non impostata. Scansione impronte @@ -392,21 +392,21 @@ Cifre Algoritmo Password usa e getta - Segreto della password usa e getta non valido - " Impostare almeno una credenziale." + Segreto per password usa e getta (OTP) non valido. + Impostare almeno una credenziale. Non puoi copiare un gruppo qui. - La chiave segreta deve essere nel formato Base32 + La chiave segreta deve essere nel formato Base32. Il contatore deve essere tra %1$d e %2$d. Il periodo deve essere tra %1$d e %2$d secondi. Il token deve contenere tra %1$d e %2$d cifre. %1$s con le stesse credenziali univoche %2$s è già esistente. - Sto creando il database... + Sto creando il database… Impostazioni di sicurezza Il databse contiene identificativi univoci univerali duplicati. Non è possibile salvare il database. Salva il database Svuota il cestino - Esecuzione del comando... + Esecuzione del comando… Sei sicuro di voler eliminare definitivamente i nodi selezionati\? Allegati \ No newline at end of file From 155030fdca778648ce308f9580e4ff3172105a11 Mon Sep 17 00:00:00 2001 From: anonymous Date: Tue, 24 Mar 2020 10:46:20 +0000 Subject: [PATCH 02/18] Translated using Weblate (Italian) Currently translated at 79.5% (339 of 426 strings) Translation: KeePass DX/Strings Translate-URL: https://hosted.weblate.org/projects/keepass-dx/strings/it/ --- app/src/main/res/values-it/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index d9fb53855..35307ff3e 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -238,7 +238,7 @@ Percorso file Visualizza il percorso file completo Usa il cestino - Sposta gruppi ed elementi nel cestino prima di eliminare + Sposta i gruppi e le voci nel gruppo \"Cestino\" prima di eliminarlo Carattere campi Cambia il carattere usato nei campi per una migliore visibilità Fiducia appunti @@ -348,7 +348,7 @@ Suono alla pressione Modalità selezione Non terminare l\'app… - Premere Indietro sulla schermata principale per bloccare + Premere \'\'Indietro\'\' per bloccare Bloccare il database quando l\'utente preme il pulsante Indietro nella schermata principale Pulisci alla chiusura Chiudere il database alla chiusura della notifica From 61769c4f205c39af147a71fb4f2149c065142159 Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Wed, 25 Mar 2020 21:07:36 +0100 Subject: [PATCH 03/18] Fix Nextcloud File Upload conflict #497 --- app/src/main/java/com/kunzisoft/keepass/utils/UriUtil.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/kunzisoft/keepass/utils/UriUtil.kt b/app/src/main/java/com/kunzisoft/keepass/utils/UriUtil.kt index 4872055d1..7428747c4 100644 --- a/app/src/main/java/com/kunzisoft/keepass/utils/UriUtil.kt +++ b/app/src/main/java/com/kunzisoft/keepass/utils/UriUtil.kt @@ -42,7 +42,7 @@ object UriUtil { return false return try { //https://developer.android.com/reference/android/content/res/AssetFileDescriptor - contentResolver.openInputStream(fileUri)?.close() + contentResolver.openAssetFileDescriptor(fileUri, "r")?.close() true } catch (e: Exception) { Log.e(UriUtil.javaClass.name, "Unable to access uri $fileUri : ${e.message}") From d0e35b109e22799c3128bc130c76af34f66e7ebb Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Wed, 25 Mar 2020 22:48:15 +0100 Subject: [PATCH 04/18] Revert : Fix Nextcloud File Upload conflict #497 --- app/src/main/java/com/kunzisoft/keepass/utils/UriUtil.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/kunzisoft/keepass/utils/UriUtil.kt b/app/src/main/java/com/kunzisoft/keepass/utils/UriUtil.kt index 7428747c4..4872055d1 100644 --- a/app/src/main/java/com/kunzisoft/keepass/utils/UriUtil.kt +++ b/app/src/main/java/com/kunzisoft/keepass/utils/UriUtil.kt @@ -42,7 +42,7 @@ object UriUtil { return false return try { //https://developer.android.com/reference/android/content/res/AssetFileDescriptor - contentResolver.openAssetFileDescriptor(fileUri, "r")?.close() + contentResolver.openInputStream(fileUri)?.close() true } catch (e: Exception) { Log.e(UriUtil.javaClass.name, "Unable to access uri $fileUri : ${e.message}") From 206bc661dc8ede51b9c1b86f2e04e1da71733de3 Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 25 Mar 2020 22:42:03 +0000 Subject: [PATCH 05/18] Translated using Weblate (German) Currently translated at 96.2% (410 of 426 strings) Translation: KeePass DX/Strings Translate-URL: https://hosted.weblate.org/projects/keepass-dx/strings/de/ --- app/src/main/res/values-de/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 95fe8c3c4..859f6ec64 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -288,7 +288,7 @@ Diese Funktion ist <strong>in Entwicklung</strong> und erfordert <strong>Ihren Beitrag</strong>, um bald verfügbar zu sein. Durch den Kauf der <strong>Pro-Version</strong>, Durch Ihr <strong>Mitwirken</strong>, - du bestärkst die Entwickler:innen, <strong>neue Funktionen</strong> einzuführen und gemäß deinen<strong> Anmerkungen <strong>Fehler auszumerzen</strong>.<strong>neue Funktionen</strong> einzuführen und gemäß Ihren Anmerkungen <strong>Fehler auszumerzen</strong>. + Sie ermutigen die Entwickler:innen, <strong>neue Funktionen</strong> einzuführen und gemäß Ihren<strong> Anmerkungen <strong>Fehler zu beheben</strong>. Vielen Dank für Ihre Unterstützung. Wir bemühen uns, diese Funktion bald zu veröffentlichen. Vergessen Sie nicht, Ihre App aktuell zu halten indem sie neue Versionen installieren. @@ -449,7 +449,7 @@ Aktion der Go-Taste, die automatisch nach dem Drücken einer Feldtaste ausgeführt wird %1$s herunterladen Initialisieren… - Fortschritt: %1$d% + Fortschritt: %1$d% Fertigstellung… Vollständig! Tippen Sie, um die Datei zu öffnen. Abgelaufene Einträge ausblenden From 0f258fc5f80027c1b4bf78f0756753dbca5b030a Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Thu, 26 Mar 2020 12:47:32 +0100 Subject: [PATCH 06/18] Upgrade autofill algorithm --- .../kunzisoft/keepass/autofill/StructureParser.kt | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/kunzisoft/keepass/autofill/StructureParser.kt b/app/src/main/java/com/kunzisoft/keepass/autofill/StructureParser.kt index 6c01b0d87..2c9c9165b 100644 --- a/app/src/main/java/com/kunzisoft/keepass/autofill/StructureParser.kt +++ b/app/src/main/java/com/kunzisoft/keepass/autofill/StructureParser.kt @@ -34,7 +34,6 @@ import java.util.* internal class StructureParser(private val structure: AssistStructure) { private var result: Result? = null private var usernameCandidate: AutofillId? = null - private var lockHint: Boolean = false fun parse(): Result? { result = Result() @@ -98,15 +97,10 @@ internal class StructureParser(private val structure: AssistStructure) { Log.d(TAG, "Autofill password hint") return true } - it.toLowerCase(Locale.ENGLISH) == "off" -> { - Log.d(TAG, "Autofill OFF hint") - lockHint = true - return false - } + it.toLowerCase(Locale.ENGLISH) == "off" || it.toLowerCase(Locale.ENGLISH) == "on" -> { - Log.d(TAG, "Autofill ON hint") - if (parseNodeByHtmlAttributes(node)) - return true + Log.d(TAG, "Autofill web hint") + return parseNodeByHtmlAttributes(node) } else -> Log.d(TAG, "Autofill unsupported hint $it") } @@ -115,8 +109,6 @@ internal class StructureParser(private val structure: AssistStructure) { } private fun parseNodeByHtmlAttributes(node: AssistStructure.ViewNode): Boolean { - if (lockHint) - return false val autofillId = node.autofillId val nodHtml = node.htmlInfo when (nodHtml?.tag?.toLowerCase(Locale.ENGLISH)) { @@ -136,6 +128,7 @@ internal class StructureParser(private val structure: AssistStructure) { "password" -> { result?.passwordId = autofillId Log.d(TAG, "Autofill password type: ${node.htmlInfo?.tag} ${node.htmlInfo?.attributes}") + return true } } } From 5b65575c7a49cd9d039dca3f4260eb6ba49586fc Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Thu, 26 Mar 2020 12:57:24 +0100 Subject: [PATCH 07/18] Add comment to ignore autocomplete off --- .../main/java/com/kunzisoft/keepass/autofill/StructureParser.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/com/kunzisoft/keepass/autofill/StructureParser.kt b/app/src/main/java/com/kunzisoft/keepass/autofill/StructureParser.kt index 2c9c9165b..c22fe810a 100644 --- a/app/src/main/java/com/kunzisoft/keepass/autofill/StructureParser.kt +++ b/app/src/main/java/com/kunzisoft/keepass/autofill/StructureParser.kt @@ -97,6 +97,8 @@ internal class StructureParser(private val structure: AssistStructure) { Log.d(TAG, "Autofill password hint") return true } + // Ignore autocomplete="off" + // https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion it.toLowerCase(Locale.ENGLISH) == "off" || it.toLowerCase(Locale.ENGLISH) == "on" -> { Log.d(TAG, "Autofill web hint") From 6c1c3ff87fee48a1c1506ff08068744faac29a6c Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Thu, 26 Mar 2020 13:38:20 +0100 Subject: [PATCH 08/18] New method to wait 1.5 seconds after screen turns off --- .../keepass/utils/BroadcastAction.kt | 43 +++++++++++++------ app/src/main/res/values/donottranslate.xml | 2 +- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/kunzisoft/keepass/utils/BroadcastAction.kt b/app/src/main/java/com/kunzisoft/keepass/utils/BroadcastAction.kt index 7e889f86d..31b7709d5 100644 --- a/app/src/main/java/com/kunzisoft/keepass/utils/BroadcastAction.kt +++ b/app/src/main/java/com/kunzisoft/keepass/utils/BroadcastAction.kt @@ -19,12 +19,15 @@ */ package com.kunzisoft.keepass.utils +import android.app.AlarmManager import android.app.NotificationManager +import android.app.PendingIntent import android.content.BroadcastReceiver import android.content.Context +import android.content.Context.ALARM_SERVICE import android.content.Intent import android.content.IntentFilter -import android.os.Handler +import android.os.Build import android.util.Log import com.kunzisoft.keepass.R import com.kunzisoft.keepass.database.element.Database @@ -42,26 +45,34 @@ const val REMOVE_ENTRY_MAGIKEYBOARD_ACTION = "com.kunzisoft.keepass.REMOVE_ENTRY class LockReceiver(var lockAction: () -> Unit) : BroadcastReceiver() { - private val screenOffHandler = Handler() - private var screenOffRunnable: Runnable? = null + var mLockPendingIntent: PendingIntent? = null override fun onReceive(context: Context, intent: Intent) { - - screenOffRunnable?.let { runnable -> - screenOffHandler.removeCallbacks(runnable) - } // If allowed, lock and exit if (!TimeoutHelper.temporarilyDisableTimeout) { intent.action?.let { when (it) { + Intent.ACTION_SCREEN_ON -> { + cancelLockPendingIntent(context) + } Intent.ACTION_SCREEN_OFF -> { if (PreferencesUtil.isLockDatabaseWhenScreenShutOffEnable(context)) { - screenOffRunnable = Runnable { - lockAction.invoke() - } + mLockPendingIntent = PendingIntent.getBroadcast(context, + 4575, + Intent(intent).apply { + action = LOCK_ACTION + }, + 0) // Launch the effective action after a small time - screenOffHandler.postDelayed(screenOffRunnable!!, - context.getString(R.string.timeout_screen_off).toLong()) + val first: Long = System.currentTimeMillis() + context.getString(R.string.timeout_screen_off).toLong() + val alarmManager = context.getSystemService(ALARM_SERVICE) as AlarmManager? + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + alarmManager?.setExact(AlarmManager.RTC_WAKEUP, first, mLockPendingIntent) + } else { + alarmManager?.set(AlarmManager.RTC_WAKEUP, first, mLockPendingIntent) + } + } else { + cancelLockPendingIntent(context) } } LOCK_ACTION, @@ -71,6 +82,14 @@ class LockReceiver(var lockAction: () -> Unit) : BroadcastReceiver() { } } } + + private fun cancelLockPendingIntent(context: Context) { + mLockPendingIntent?.let { + val alarmManager = context.getSystemService(ALARM_SERVICE) as AlarmManager? + alarmManager?.cancel(mLockPendingIntent) + mLockPendingIntent = null + } + } } fun Context.registerLockReceiver(lockReceiver: LockReceiver?, diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml index 0f44c87e2..9fb0a4825 100644 --- a/app/src/main/res/values/donottranslate.xml +++ b/app/src/main/res/values/donottranslate.xml @@ -245,7 +245,7 @@ timeout_backup_key 300000 - 3000 + 1500 5000 10000 From 515abb6e147aa952b48f0a38950cde4e7e7462c7 Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Thu, 26 Mar 2020 14:45:51 +0100 Subject: [PATCH 09/18] Better UUID view --- app/src/main/res/layout/view_entry_contents.xml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/app/src/main/res/layout/view_entry_contents.xml b/app/src/main/res/layout/view_entry_contents.xml index 496cf079e..73c73ee0f 100644 --- a/app/src/main/res/layout/view_entry_contents.xml +++ b/app/src/main/res/layout/view_entry_contents.xml @@ -428,26 +428,21 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + style="@style/KeepassDXStyle.TextAppearance.LabelTextStyle" /> + android:layout_height="match_parent"> + style="@style/KeepassDXStyle.TextAppearance.TextEntryItem" /> From fffee48918a47155a5a3461c4734e99f02444a49 Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Thu, 26 Mar 2020 14:50:20 +0100 Subject: [PATCH 10/18] Upgrade version to 2.5beta30 --- CHANGELOG | 4 ++++ app/build.gradle | 4 ++-- fastlane/metadata/android/en-US/changelogs/30.txt | 2 ++ fastlane/metadata/android/fr-FR/changelogs/30.txt | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/30.txt create mode 100644 fastlane/metadata/android/fr-FR/changelogs/30.txt diff --git a/CHANGELOG b/CHANGELOG index ad8ae1817..21a24fdc0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +KeePassDX(2.5beta30) + * Fix Lock after screen off (wait 1.5 seconds) + * Upgrade autofill algorithm + KeePassDX(2.5beta29) * Upgrade autofill algorithm * Delete registered KeyFile after save new credentials diff --git a/app/build.gradle b/app/build.gradle index d88804569..4ed1e26eb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,8 +11,8 @@ android { applicationId "com.kunzisoft.keepass" minSdkVersion 14 targetSdkVersion 29 - versionCode = 29 - versionName = "2.5beta29" + versionCode = 30 + versionName = "2.5beta30" multiDexEnabled true testApplicationId = "com.kunzisoft.keepass.tests" diff --git a/fastlane/metadata/android/en-US/changelogs/30.txt b/fastlane/metadata/android/en-US/changelogs/30.txt new file mode 100644 index 000000000..98e156f1b --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/30.txt @@ -0,0 +1,2 @@ + * Fix Lock after screen off (wait 1.5 seconds) + * Upgrade autofill algorithm diff --git a/fastlane/metadata/android/fr-FR/changelogs/30.txt b/fastlane/metadata/android/fr-FR/changelogs/30.txt new file mode 100644 index 000000000..14150cedc --- /dev/null +++ b/fastlane/metadata/android/fr-FR/changelogs/30.txt @@ -0,0 +1,2 @@ + * Correction du verrouillage après la désactivation de l'écran (attendre 1,5 seconde) + * Mise à niveau de l'algorithme de remplissage automatique \ No newline at end of file From 0baa7bcbf108dcc0f6411e4dc02bb4204defbbf0 Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Thu, 26 Mar 2020 16:36:17 +0100 Subject: [PATCH 11/18] Change discard button --- .../java/com/kunzisoft/keepass/activities/EntryEditActivity.kt | 2 +- app/src/main/res/values/strings.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/kunzisoft/keepass/activities/EntryEditActivity.kt b/app/src/main/java/com/kunzisoft/keepass/activities/EntryEditActivity.kt index c542464c0..1ea62dcf0 100644 --- a/app/src/main/java/com/kunzisoft/keepass/activities/EntryEditActivity.kt +++ b/app/src/main/java/com/kunzisoft/keepass/activities/EntryEditActivity.kt @@ -509,7 +509,7 @@ class EntryEditActivity : LockingActivity(), AlertDialog.Builder(this) .setMessage(R.string.discard_changes) .setNegativeButton(android.R.string.cancel, null) - .setPositiveButton(android.R.string.ok) { _, _ -> + .setPositiveButton(R.string.discard) { _, _ -> super@EntryEditActivity.onBackPressed() }.create().show() } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 72c716e47..b073247df 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -59,6 +59,7 @@ Entry icon Validate Discard changes? + Discard Password generator Password length Add field From 8ae2edb61a2508db65936d0bcc441d1e81c10e84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=2E=20R=C3=BCdinger?= Date: Wed, 25 Mar 2020 22:44:33 +0000 Subject: [PATCH 12/18] Translated using Weblate (German) Currently translated at 96.4% (411 of 426 strings) Translation: KeePass DX/Strings Translate-URL: https://hosted.weblate.org/projects/keepass-dx/strings/de/ --- app/src/main/res/values-de/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 859f6ec64..205023ae5 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -288,10 +288,10 @@ Diese Funktion ist <strong>in Entwicklung</strong> und erfordert <strong>Ihren Beitrag</strong>, um bald verfügbar zu sein. Durch den Kauf der <strong>Pro-Version</strong>, Durch Ihr <strong>Mitwirken</strong>, - Sie ermutigen die Entwickler:innen, <strong>neue Funktionen</strong> einzuführen und gemäß Ihren<strong> Anmerkungen <strong>Fehler zu beheben</strong>. + Sie ermutigen die Entwickler:innen, neue Funktionen einzuführen und gemäß Ihren Anmerkungen Fehler zu beheben. Vielen Dank für Ihre Unterstützung. Wir bemühen uns, diese Funktion bald zu veröffentlichen. - Vergessen Sie nicht, Ihre App aktuell zu halten indem sie neue Versionen installieren. + Vergessen Sie nicht, Ihre App aktuell zu halten, indem Sie neue Versionen installieren. Download Unterstützen ChaCha20 From 8e40250985a0d4290c2c9b926aea2009dab0ff91 Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 25 Mar 2020 22:58:50 +0000 Subject: [PATCH 13/18] Translated using Weblate (German) Currently translated at 96.4% (411 of 426 strings) Translation: KeePass DX/Strings Translate-URL: https://hosted.weblate.org/projects/keepass-dx/strings/de/ --- app/src/main/res/values-de/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 205023ae5..0686734ea 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -269,7 +269,7 @@ Ein starkes Passwort für den Eintrag erstellen. Erzeugung eines starken Passworts, das mit dem Eintrag verknüpft wird, nach Kriterien, die einfach in einem Formular festgelegt werden. Dabei an die Passwortsicherheit denken. Benutzerdefinierte Felder hinzufügen - Ein wichtiges, nicht mitgeliefertes Feld erfassen, indem ein neues Feld ausgefüllt wird, das sich auch schützen lässt. + Tragen Sie ein zusätzliches Feld ein, fügen Sie einen Wert hinzu und schützen Sie es optional. Die Datenbank entsperren Ein Feld kopieren Kopierte Felder können an beliebiger Stelle eingefügt werden. From 01960e74c1212e8b29d488a4ac58ea4ccc8a2f68 Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Fri, 27 Mar 2020 16:36:57 +0100 Subject: [PATCH 14/18] Fix check file ANR #494 --- .../activities/FileDatabaseSelectActivity.kt | 5 +- .../keepass/activities/PasswordActivity.kt | 8 +- .../adapters/FileDatabaseHistoryAdapter.kt | 15 ++-- .../keepass/utils/FileDatabaseInfo.kt | 65 ++++++++++++-- .../com/kunzisoft/keepass/utils/FileInfo.kt | 84 ------------------- .../com/kunzisoft/keepass/utils/UriUtil.kt | 21 ----- 6 files changed, 75 insertions(+), 123 deletions(-) delete mode 100644 app/src/main/java/com/kunzisoft/keepass/utils/FileInfo.kt diff --git a/app/src/main/java/com/kunzisoft/keepass/activities/FileDatabaseSelectActivity.kt b/app/src/main/java/com/kunzisoft/keepass/activities/FileDatabaseSelectActivity.kt index e3aee34df..2d2fcd7c5 100644 --- a/app/src/main/java/com/kunzisoft/keepass/activities/FileDatabaseSelectActivity.kt +++ b/app/src/main/java/com/kunzisoft/keepass/activities/FileDatabaseSelectActivity.kt @@ -278,9 +278,8 @@ class FileDatabaseSelectActivity : StylishActivity(), // Show only uri accessible historyList.filter { if (hideBrokenLocations) { - UriUtil.parse(it.databaseUri)?.let { historyUri -> - UriUtil.isUriAccessible(contentResolver, historyUri) - } ?: false + FileDatabaseInfo(this@FileDatabaseSelectActivity, + it.databaseUri).exists } else true }) diff --git a/app/src/main/java/com/kunzisoft/keepass/activities/PasswordActivity.kt b/app/src/main/java/com/kunzisoft/keepass/activities/PasswordActivity.kt index c19558ed0..b935f43eb 100644 --- a/app/src/main/java/com/kunzisoft/keepass/activities/PasswordActivity.kt +++ b/app/src/main/java/com/kunzisoft/keepass/activities/PasswordActivity.kt @@ -313,7 +313,13 @@ open class PasswordActivity : StylishActivity() { } private fun initUriFromIntent() { - mForceReadOnly = !UriUtil.isUriWritable(mDatabaseFileUri) + /* + // "canXrite" doesn't work with Google Drive, don't really know why? + mForceReadOnly = mDatabaseFileUri?.let { + !FileDatabaseInfo(this, it).canWrite + } ?: false + */ + mForceReadOnly = false // Post init uri with KeyFile if needed if (mRememberKeyFile && (mDatabaseKeyFileUri == null || mDatabaseKeyFileUri.toString().isEmpty())) { diff --git a/app/src/main/java/com/kunzisoft/keepass/adapters/FileDatabaseHistoryAdapter.kt b/app/src/main/java/com/kunzisoft/keepass/adapters/FileDatabaseHistoryAdapter.kt index 3d01189b4..45a4313df 100644 --- a/app/src/main/java/com/kunzisoft/keepass/adapters/FileDatabaseHistoryAdapter.kt +++ b/app/src/main/java/com/kunzisoft/keepass/adapters/FileDatabaseHistoryAdapter.kt @@ -84,24 +84,25 @@ class FileDatabaseHistoryAdapter(private val context: Context) // File path holder.filePath.text = UriUtil.decode(fileDatabaseInfo.fileUri?.toString()) - if (fileDatabaseInfo.dataAccessible()) { + if (fileDatabaseInfo.exists) { holder.fileInformation.clearColorFilter() } else { holder.fileInformation.setColorFilter(Color.RED, PorterDuff.Mode.MULTIPLY) } // Modification - if (fileDatabaseInfo.lastModificationAccessible()) { - holder.fileModification.text = fileDatabaseInfo.getModificationString() + fileDatabaseInfo.getModificationString()?.let { + holder.fileModification.text = it holder.fileModification.visibility = View.VISIBLE - } else { + } ?: run { holder.fileModification.visibility = View.GONE } + // Size - if (fileDatabaseInfo.sizeAccessible()) { - holder.fileSize.text = fileDatabaseInfo.getSizeString() + fileDatabaseInfo.getSizeString()?.let { + holder.fileSize.text = it holder.fileSize.visibility = View.VISIBLE - } else { + } ?: run { holder.fileSize.visibility = View.GONE } diff --git a/app/src/main/java/com/kunzisoft/keepass/utils/FileDatabaseInfo.kt b/app/src/main/java/com/kunzisoft/keepass/utils/FileDatabaseInfo.kt index e5cb50942..64acb532d 100644 --- a/app/src/main/java/com/kunzisoft/keepass/utils/FileDatabaseInfo.kt +++ b/app/src/main/java/com/kunzisoft/keepass/utils/FileDatabaseInfo.kt @@ -21,25 +21,77 @@ package com.kunzisoft.keepass.utils import android.content.Context import android.net.Uri +import android.text.format.Formatter +import androidx.documentfile.provider.DocumentFile import com.kunzisoft.keepass.app.database.FileDatabaseHistoryAction import com.kunzisoft.keepass.settings.PreferencesUtil +import java.io.Serializable +import java.text.DateFormat +import java.util.* -class FileDatabaseInfo : FileInfo { +class FileDatabaseInfo : Serializable { - constructor(context: Context, fileUri: Uri): super(context, fileUri) + private var context: Context + private var documentFile: DocumentFile? = null + var fileUri: Uri? + private set - constructor(context: Context, filePath: String): super(context, filePath) + constructor(context: Context, fileUri: Uri) { + this.context = context + this.fileUri = fileUri + init() + } + + constructor(context: Context, filePath: String) { + this.context = context + this.fileUri = UriUtil.parse(filePath) + init() + } + + fun init() { + documentFile = UriUtil.getFileData(context, fileUri) + } + + var exists: Boolean = false + get() { + return documentFile?.exists() ?: field + } + private set + + var canRead: Boolean = false + get() { + return documentFile?.canRead() ?: field + } + private set + + var canWrite: Boolean = false + get() { + return documentFile?.canWrite() ?: field + } + private set + + fun getModificationString(): String? { + return documentFile?.lastModified()?.let { + DateFormat.getDateTimeInstance() + .format(Date(it)) + } + } + + fun getSizeString(): String? { + return documentFile?.let { + Formatter.formatFileSize(context, it.length()) + } + } fun retrieveDatabaseAlias(alias: String): String { return when { alias.isNotEmpty() -> alias - PreferencesUtil.isFullFilePathEnable(context) -> filePath ?: "" - else -> fileName ?: "" + PreferencesUtil.isFullFilePathEnable(context) -> fileUri?.path ?: "" + else -> if (exists) documentFile?.name ?: "" else fileUri?.path ?: "" } } fun retrieveDatabaseTitle(titleCallback: (String)->Unit) { - fileUri?.let { fileUri -> FileDatabaseHistoryAction.getInstance(context.applicationContext) .getFileDatabaseHistory(fileUri) { fileDatabaseHistoryEntity -> @@ -48,5 +100,4 @@ class FileDatabaseInfo : FileInfo { } } } - } \ No newline at end of file diff --git a/app/src/main/java/com/kunzisoft/keepass/utils/FileInfo.kt b/app/src/main/java/com/kunzisoft/keepass/utils/FileInfo.kt deleted file mode 100644 index d7a4a2b72..000000000 --- a/app/src/main/java/com/kunzisoft/keepass/utils/FileInfo.kt +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2019 Jeremy Jamet / Kunzisoft. - * - * This file is part of KeePassDX. - * - * KeePassDX is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * KeePassDX is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with KeePassDX. If not, see . - * - */ -package com.kunzisoft.keepass.utils - -import android.content.Context -import android.net.Uri -import android.text.format.Formatter -import java.io.Serializable -import java.text.DateFormat -import java.util.* - -open class FileInfo : Serializable { - - var context: Context - var fileUri: Uri? - var filePath: String? = null - var fileName: String? = "" - var lastModification = Date(0L) - var size: Long = 0L - - constructor(context: Context, fileUri: Uri) { - this.context = context - this.fileUri = fileUri - init() - } - - constructor(context: Context, filePath: String) { - this.context = context - this.fileUri = UriUtil.parse(filePath) - init() - } - - fun init() { - this.filePath = fileUri?.path - - UriUtil.getFileData(context, fileUri)?.let { file -> - size = file.length() - fileName = file.name - lastModification = Date(file.lastModified()) - } - - if (fileName == null || fileName!!.isEmpty()) { - fileName = filePath - } - } - - fun lastModificationAccessible(): Boolean { - return lastModification.after(Date(0L)) - } - - fun sizeAccessible(): Boolean { - return size != 0L - } - - fun dataAccessible(): Boolean { - return UriUtil.isUriAccessible(context.contentResolver, fileUri) - } - - fun getModificationString(): String { - return DateFormat.getDateTimeInstance() - .format(lastModification) - } - - fun getSizeString(): String { - return Formatter.formatFileSize(context, size) - } -} diff --git a/app/src/main/java/com/kunzisoft/keepass/utils/UriUtil.kt b/app/src/main/java/com/kunzisoft/keepass/utils/UriUtil.kt index 4872055d1..14b17346c 100644 --- a/app/src/main/java/com/kunzisoft/keepass/utils/UriUtil.kt +++ b/app/src/main/java/com/kunzisoft/keepass/utils/UriUtil.kt @@ -24,7 +24,6 @@ import android.content.Context import android.content.Intent import android.net.Uri import android.os.Build -import android.util.Log import android.widget.Toast import androidx.documentfile.provider.DocumentFile import com.kunzisoft.keepass.R @@ -37,26 +36,6 @@ import java.util.* object UriUtil { - fun isUriAccessible(contentResolver: ContentResolver, fileUri: Uri?): Boolean { - if (fileUri == null) - return false - return try { - //https://developer.android.com/reference/android/content/res/AssetFileDescriptor - contentResolver.openInputStream(fileUri)?.close() - true - } catch (e: Exception) { - Log.e(UriUtil.javaClass.name, "Unable to access uri $fileUri : ${e.message}") - false - } - } - - fun isUriWritable(fileUri: Uri?): Boolean { - if (fileUri == null) - return false - // TODO Uri writeable detection - return true - } - fun getFileData(context: Context, fileUri: Uri?): DocumentFile? { if (fileUri == null) return null From 7d0340ac077380199a47e2de69262dd9a2d740aa Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Fri, 27 Mar 2020 16:57:35 +0100 Subject: [PATCH 15/18] Upgrade CHANGELOG --- CHANGELOG | 1 + fastlane/metadata/android/en-US/changelogs/30.txt | 1 + fastlane/metadata/android/fr-FR/changelogs/30.txt | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 21a24fdc0..d1526d50b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ KeePassDX(2.5beta30) * Fix Lock after screen off (wait 1.5 seconds) * Upgrade autofill algorithm + * Fix ANR during file verifications KeePassDX(2.5beta29) * Upgrade autofill algorithm diff --git a/fastlane/metadata/android/en-US/changelogs/30.txt b/fastlane/metadata/android/en-US/changelogs/30.txt index 98e156f1b..6cc4e68f0 100644 --- a/fastlane/metadata/android/en-US/changelogs/30.txt +++ b/fastlane/metadata/android/en-US/changelogs/30.txt @@ -1,2 +1,3 @@ * Fix Lock after screen off (wait 1.5 seconds) * Upgrade autofill algorithm + * Fix ANR during file verification diff --git a/fastlane/metadata/android/fr-FR/changelogs/30.txt b/fastlane/metadata/android/fr-FR/changelogs/30.txt index 14150cedc..e440e0489 100644 --- a/fastlane/metadata/android/fr-FR/changelogs/30.txt +++ b/fastlane/metadata/android/fr-FR/changelogs/30.txt @@ -1,2 +1,3 @@ * Correction du verrouillage après la désactivation de l'écran (attendre 1,5 seconde) - * Mise à niveau de l'algorithme de remplissage automatique \ No newline at end of file + * Mise à niveau de l'algorithme de remplissage automatique + * Correction de l'ANR lors de la vérification de fichier \ No newline at end of file From 729e062c3ad65fc86e8b24fdfc7dfb2fa23a4162 Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Fri, 27 Mar 2020 17:12:54 +0100 Subject: [PATCH 16/18] Add error when create database file --- .../activities/FileDatabaseSelectActivity.kt | 16 ++++++++++++---- app/src/main/res/values/strings.xml | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/kunzisoft/keepass/activities/FileDatabaseSelectActivity.kt b/app/src/main/java/com/kunzisoft/keepass/activities/FileDatabaseSelectActivity.kt index 2d2fcd7c5..4d7d0dbf5 100644 --- a/app/src/main/java/com/kunzisoft/keepass/activities/FileDatabaseSelectActivity.kt +++ b/app/src/main/java/com/kunzisoft/keepass/activities/FileDatabaseSelectActivity.kt @@ -35,6 +35,7 @@ import android.view.View import android.widget.TextView import androidx.annotation.RequiresApi import androidx.appcompat.widget.Toolbar +import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.SimpleItemAnimator @@ -61,6 +62,7 @@ class FileDatabaseSelectActivity : StylishActivity(), AssignMasterKeyDialogFragment.AssignPasswordDialogListener { // Views + private var coordinatorLayout: CoordinatorLayout? = null private var fileListContainer: View? = null private var createButtonView: View? = null private var openDatabaseButtonView: View? = null @@ -82,6 +84,7 @@ class FileDatabaseSelectActivity : StylishActivity(), mFileDatabaseHistoryAction = FileDatabaseHistoryAction.getInstance(applicationContext) setContentView(R.layout.activity_file_selection) + coordinatorLayout = findViewById(R.id.activity_file_selection_coordinator_layout) fileListContainer = findViewById(R.id.container_file_list) val toolbar = findViewById(R.id.toolbar) @@ -179,7 +182,9 @@ class FileDatabaseSelectActivity : StylishActivity(), private fun fileNoFoundAction(e: FileNotFoundException) { val error = getString(R.string.file_not_found_content) - Snackbar.make(activity_file_selection_coordinator_layout, error, Snackbar.LENGTH_LONG).asError().show() + coordinatorLayout?.let { + Snackbar.make(it, error, Snackbar.LENGTH_LONG).asError().show() + } Log.e(TAG, error, e) } @@ -368,10 +373,13 @@ class FileDatabaseSelectActivity : StylishActivity(), if (mDatabaseFileUri != null) { AssignMasterKeyDialogFragment.getInstance(true) .show(supportFragmentManager, "passwordDialog") + } else { + val error = getString(R.string.error_create_database) + coordinatorLayout?.let { + Snackbar.make(it, error, Snackbar.LENGTH_LONG).asError().show() + } + Log.e(TAG, error) } - // else { - // TODO Show error - // } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b073247df..6f21b8fcd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -124,6 +124,7 @@ You can not move an entry here. You can not copy an entry here. You can not copy a group here. + Unable to create database file. Unable to create database with this password and keyfile. Could not save database. Secret key must be in Base32 format. From 8ff19f7e68888785b2f5cb80e8a952ae04b99326 Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Fri, 27 Mar 2020 17:43:31 +0100 Subject: [PATCH 17/18] First string pass according to #460 --- app/src/main/res/values/strings.xml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6f21b8fcd..3367183dd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -209,7 +209,7 @@ Write-protected Depending on your file manager, KeePassDX may not allowed to write in your storage. The database contains duplicate UUIDs. - By validating this dialog, KeePassDX will fix the problem (by generating new UUIDs for duplicates) and continue. + Solve problem by generating new UUIDs for duplicates to continue? Selection mode Save location of databases Remember the location of databases @@ -254,9 +254,9 @@ Avoid password characters outside of text encoding format in database file (unrecognized chars are converted to the same letter). Grant file write access to save database changes Mount the memory card to create or load a database. - Do you really want no password unlocking protection? - Are you sure you do not want to use any encryption key? - Are you sure you want to permanently delete the selected nodes? + Continue without password unlocking protection? + Continue without encryption key? + Permanently delete selected nodes? Version %1$s Build %1$s Biometric prompt is supported but not set up. @@ -302,11 +302,11 @@ Use advanced unlocking to open a database more easily Biometric unlocking Lets you scan your biometric to open the database - Auto open biometric prompt + Auto-open biometric prompt Automatically open biometric prompt when a biometric key is defined for a database Delete encryption keys Delete all encryption keys related to biometric recognition - Are you sure you want to delete all keys related to biometric recognition? + Delete all encryption keys related to biometric recognition? Could not start this feature. Your Android version %1$s does not meet the minimum version %2$s required. Could not find the corresponding hardware. @@ -328,7 +328,7 @@ Recommend changing the master key (days) Force renewal Require changing the master key (days) - Force renewal the next time + Force renewal next time Require changing the master key the next time (once) Field font Change font used in fields for better character visibility @@ -354,7 +354,7 @@ Keyboard Magikeyboard Activate a custom keyboard populating your passwords and all identity fields - Device keyboard Settings + Device keyboard settings Magikeyboard Magikeyboard (KeePassDX) Magikeyboard settings @@ -374,7 +374,7 @@ Keyboard theme Keys Auto key action - Action of the "Go" key performed automatically after pressing a "Field" key + \"Go\" key action after pressing a \"Field\" key Vibratory keypresses Audible keypresses Allow no master key @@ -384,7 +384,7 @@ Write-protected Open the database read-only by default Autosave database - Automatically save the database after an important action (only in \"Modifiable\" mode) + Save the database after every important action (in \"Modifiable\" mode) Educational screens Highlight the elements to learn how the app works Reset educational screens @@ -476,5 +476,5 @@ Icon pack Icon pack used in the app Hide expired entries - Expired entries will be hidden + Expired entries are hidden \ No newline at end of file From cb982b351381239219fa35797432b6d44a613eb0 Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Fri, 27 Mar 2020 17:53:42 +0100 Subject: [PATCH 18/18] Fix strong tag --- app/src/main/res/values-de/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 0686734ea..a8e1f7a95 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -288,7 +288,7 @@ Diese Funktion ist <strong>in Entwicklung</strong> und erfordert <strong>Ihren Beitrag</strong>, um bald verfügbar zu sein. Durch den Kauf der <strong>Pro-Version</strong>, Durch Ihr <strong>Mitwirken</strong>, - Sie ermutigen die Entwickler:innen, neue Funktionen einzuführen und gemäß Ihren Anmerkungen Fehler zu beheben. + Sie ermutigen die Entwickler:innen, <strong>neue Funktionen</strong> einzuführen und gemäß Ihren Anmerkungen <strong>Fehler zu beheben</strong>. Vielen Dank für Ihre Unterstützung. Wir bemühen uns, diese Funktion bald zu veröffentlichen. Vergessen Sie nicht, Ihre App aktuell zu halten, indem Sie neue Versionen installieren.