diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1a34ae3b2..7a8a7c807 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,7 @@ All notable changes to this project will be documented in this file.
- Pressing the back button in the navigation bar and the one in the toolbar behaved differently
- Editing a password allowed accidentally overwriting an existing one
- App shortcuts would never update once the first 4 were set
+- Clipboard history now attempts to flush through 35 times rather than 20 to combat increased clipboard history item count in Samsung devices
### Changed
diff --git a/app/src/androidTest/java/dev/msfjarvis/aps/util/settings/MigrationsTest.kt b/app/src/androidTest/java/dev/msfjarvis/aps/util/settings/MigrationsTest.kt
index d27b4c1c3..0c3afebe7 100644
--- a/app/src/androidTest/java/dev/msfjarvis/aps/util/settings/MigrationsTest.kt
+++ b/app/src/androidTest/java/dev/msfjarvis/aps/util/settings/MigrationsTest.kt
@@ -13,6 +13,7 @@ import dev.msfjarvis.aps.Application
import dev.msfjarvis.aps.util.extensions.getString
import dev.msfjarvis.aps.util.extensions.sharedPrefs
import org.junit.Assert.assertEquals
+import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Test
@@ -104,4 +105,16 @@ class MigrationsTest {
assertEquals(false, context.sharedPrefs.getBoolean(PreferenceKeys.SHOW_HIDDEN_FOLDERS, false))
assertEquals(true, context.sharedPrefs.getBoolean(PreferenceKeys.SHOW_HIDDEN_CONTENTS, false))
}
+
+ @Test
+ fun verifyClearClipboardHistoryMigration() {
+ val context = Application.instance.applicationContext
+ context.sharedPrefs.edit {
+ clear()
+ putBoolean(PreferenceKeys.CLEAR_CLIPBOARD_20X, true)
+ }
+ runMigrations(context)
+ assertEquals(true, context.sharedPrefs.getBoolean(PreferenceKeys.CLEAR_CLIPBOARD_HISTORY, false))
+ assertFalse(context.sharedPrefs.contains(PreferenceKeys.CLEAR_CLIPBOARD_20X))
+ }
}
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/settings/MiscSettings.kt b/app/src/main/java/dev/msfjarvis/aps/ui/settings/MiscSettings.kt
index cb03878df..30a5db860 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/settings/MiscSettings.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/settings/MiscSettings.kt
@@ -60,7 +60,7 @@ class MiscSettings(activity: FragmentActivity) : SettingsProvider {
true
}
}
- checkBox(PreferenceKeys.CLEAR_CLIPBOARD_20X) {
+ checkBox(PreferenceKeys.CLEAR_CLIPBOARD_HISTORY) {
defaultValue = false
titleRes = R.string.pref_clear_clipboard_title
summaryRes = R.string.pref_clear_clipboard_summary
diff --git a/app/src/main/java/dev/msfjarvis/aps/util/services/ClipboardService.kt b/app/src/main/java/dev/msfjarvis/aps/util/services/ClipboardService.kt
index c0130ff12..bf62b5063 100644
--- a/app/src/main/java/dev/msfjarvis/aps/util/services/ClipboardService.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/util/services/ClipboardService.kt
@@ -80,7 +80,7 @@ class ClipboardService : Service() {
}
private fun clearClipboard() {
- val deepClear = sharedPrefs.getBoolean(PreferenceKeys.CLEAR_CLIPBOARD_20X, false)
+ val deepClear = sharedPrefs.getBoolean(PreferenceKeys.CLEAR_CLIPBOARD_HISTORY, false)
val clipboard = clipboard
if (clipboard != null) {
@@ -90,7 +90,7 @@ class ClipboardService : Service() {
clipboard.setPrimaryClip(clip)
if (deepClear) {
withContext(Dispatchers.IO) {
- repeat(20) {
+ repeat(CLIPBOARD_CLEAR_COUNT) {
val count = (it * 500).toString()
clipboard.setPrimaryClip(ClipData.newPlainText(count, count))
}
@@ -179,5 +179,8 @@ class ClipboardService : Service() {
const val EXTRA_NOTIFICATION_TIME = "EXTRA_NOTIFICATION_TIME"
private const val ACTION_CLEAR = "ACTION_CLEAR_CLIPBOARD"
private const val CHANNEL_ID = "NotificationService"
+ // Newest Samsung phones now feature a history of up to 30 items. To err on the side of caution,
+ // push 35 fake ones.
+ private const val CLIPBOARD_CLEAR_COUNT = 35
}
}
diff --git a/app/src/main/java/dev/msfjarvis/aps/util/settings/Migrations.kt b/app/src/main/java/dev/msfjarvis/aps/util/settings/Migrations.kt
index fe855f3f1..157a26655 100644
--- a/app/src/main/java/dev/msfjarvis/aps/util/settings/Migrations.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/util/settings/Migrations.kt
@@ -24,6 +24,7 @@ fun runMigrations(context: Context) {
migrateToGitUrlBasedConfig(sharedPrefs)
migrateToHideAll(sharedPrefs)
migrateToSshKey(context, sharedPrefs)
+ migrateToClipboardHistory(sharedPrefs)
}
private fun migrateToGitUrlBasedConfig(sharedPrefs: SharedPreferences) {
@@ -112,3 +113,15 @@ private fun migrateToSshKey(context: Context, sharedPrefs: SharedPreferences) {
}
}
}
+
+private fun migrateToClipboardHistory(sharedPrefs: SharedPreferences) {
+ if (sharedPrefs.contains(PreferenceKeys.CLEAR_CLIPBOARD_20X)) {
+ sharedPrefs.edit {
+ putBoolean(
+ PreferenceKeys.CLEAR_CLIPBOARD_HISTORY,
+ sharedPrefs.getBoolean(PreferenceKeys.CLEAR_CLIPBOARD_20X, false)
+ )
+ remove(PreferenceKeys.CLEAR_CLIPBOARD_20X)
+ }
+ }
+}
diff --git a/app/src/main/java/dev/msfjarvis/aps/util/settings/PreferenceKeys.kt b/app/src/main/java/dev/msfjarvis/aps/util/settings/PreferenceKeys.kt
index 930a54278..084b70c2b 100644
--- a/app/src/main/java/dev/msfjarvis/aps/util/settings/PreferenceKeys.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/util/settings/PreferenceKeys.kt
@@ -11,7 +11,12 @@ object PreferenceKeys {
const val APP_VERSION = "app_version"
const val AUTOFILL_ENABLE = "autofill_enable"
const val BIOMETRIC_AUTH = "biometric_auth"
+ @Deprecated(
+ message = "Use CLEAR_CLIPBOARD_HISTORY instead",
+ replaceWith = ReplaceWith("PreferenceKeys.CLEAR_CLIPBOARD_HISTORY"),
+ )
const val CLEAR_CLIPBOARD_20X = "clear_clipboard_20x"
+ const val CLEAR_CLIPBOARD_HISTORY = "clear_clipboard_history"
const val CLEAR_SAVED_PASS = "clear_saved_pass"
const val COPY_ON_DECRYPT = "copy_on_decrypt"
const val ENABLE_DEBUG_LOGGING = "enable_debug_logging"
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 50de1a025..119b1ed62 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -117,8 +117,6 @@
Automatisch ausfüllen
Autofill aktivieren
Verschiedenes
- Lösche die Zwischenablage 20-mal
- Speichert Nonsense 20-mal anstatt 1-mal in der Zwischenablage. Nützlich bspw. auf Samsung-Geräten, die den Verlauf der Zwischenablage speichern.
Lösche das lokale (versteckte) Repository
Externes Repository
Nutze ein externes Repository
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index 73008ecfc..16c85794e 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -119,8 +119,6 @@
Saisie automatique
Saisie automatique
Divers
- Effacer le presse-papier 20 fois
- Enregistre des informations absurdes dans le presse-papier 20 fois à la place d\'une seule. Utile sur les téléphones Samsung qui disposent d\'un historique du presse-papier.
Supprime le dépot local (caché)
Dépôt externe
Utilise un dépôt externe pour les mots de passe
diff --git a/app/src/main/res/values-gl/strings.xml b/app/src/main/res/values-gl/strings.xml
index aec320b87..fd4d87344 100644
--- a/app/src/main/res/values-gl/strings.xml
+++ b/app/src/main/res/values-gl/strings.xml
@@ -121,8 +121,6 @@
Completado automático
Activar completado automático
Varios
- Baleirar portapapeis 20 veces
- Gardar números consecutivos no portapapeis 20 veces. Resulta útil nos móbiles Samsung que gardan historial no portapapeis.
Elimina repositorio local (oculto).
Repositorio externo
Usar un repositorio externo de contrasinais
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index ccce743c7..8ae409510 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -121,8 +121,6 @@
Auto-compilazione
Abilita Auto-Compilazione
Varie
- Cancella 20 volte gli appunti
- Archivia i numeri consecutivi negli appunti per 20 volte. Utile sui telefoni Samsung che presentano la cronologia degli appunti.
Elimina repository locale (nascosta)
Repository Esterna
Usa una repository di password esterna
diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml
index 27094d17e..7d616839f 100644
--- a/app/src/main/res/values-pt-rBR/strings.xml
+++ b/app/src/main/res/values-pt-rBR/strings.xml
@@ -121,8 +121,6 @@
Preenchimento Automático
Ativar preenchimento automático
Outros
- Limpar área de transferência 20 vezes
- Armazene números consecutivos na área de transferência 20 vezes. Útil em telefones Samsung que apresentam o histórico da área de transferência.
Exclui o repositório local (oculto)
Repositório externo
Use um repositório de senha externo
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index 397018178..ba5745fb8 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -125,8 +125,6 @@
Автозаполнение
Включить автозаполнение
Другое
- Очистить буфер 20 раз
- Вставлять чепуху в буфер обмена 20 раз вместо одного. Полезно на некоторых моделях телефонов с запоминанием истории буфера обмена
Удалить локальный (скрытый) репозиторий
Внешний репозиторий
Использовать внешний репозиторий
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 57af2db3a..230be155d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -138,8 +138,8 @@
Autofill
Enable Autofill
Misc
- Clear clipboard 20 times
- Store consecutive numbers in the clipboard 20 times. Useful on Samsung phones that feature clipboard history.
+ Workaround clipboard history feature
+ Enable to flood clipboard history on devices that include such a feature with consecutive numbers, flushing out any passwords
Deletes local (hidden) repository
External repository
Use an external password repository