move "no limit" clipboard history retantion time to the right side

sort of fixes GH-1425 (at least the unclarity about finding the setting)
This commit is contained in:
Helium314 2025-03-22 19:05:24 +01:00
parent a3bada8d25
commit 7228fa06d1
4 changed files with 18 additions and 15 deletions

View file

@ -13,7 +13,7 @@ android {
applicationId = "helium314.keyboard" applicationId = "helium314.keyboard"
minSdk = 21 minSdk = 21
targetSdk = 34 targetSdk = 34
versionCode = 3001 versionCode = 3002
versionName = "3.0-alpha2" versionName = "3.0-alpha2"
ndk { ndk {
abiFilters.clear() abiFilters.clear()

View file

@ -542,6 +542,9 @@ fun checkVersionUpgrade(context: Context) {
} }
} }
} }
if (oldVersion <= 3001 && prefs.getInt(Settings.PREF_CLIPBOARD_HISTORY_RETENTION_TIME, Defaults.PREF_CLIPBOARD_HISTORY_RETENTION_TIME) <= 0) {
prefs.edit().putInt(Settings.PREF_CLIPBOARD_HISTORY_RETENTION_TIME, 121).apply()
}
upgradeToolbarPrefs(prefs) upgradeToolbarPrefs(prefs)
LayoutUtilsCustom.onLayoutFileChanged() // just to be sure LayoutUtilsCustom.onLayoutFileChanged() // just to be sure
prefs.edit { putInt(Settings.PREF_VERSION_CODE, BuildConfig.VERSION_CODE) } prefs.edit { putInt(Settings.PREF_VERSION_CODE, BuildConfig.VERSION_CODE) }

View file

@ -120,7 +120,7 @@ class ClipboardHistoryManager(
private fun checkClipRetentionElapsed() { private fun checkClipRetentionElapsed() {
val mins = latinIME.mSettings.current.mClipboardHistoryRetentionTime val mins = latinIME.mSettings.current.mClipboardHistoryRetentionTime
if (mins <= 0) return // No retention limit if (mins > 120) return // No retention limit, changed from <= 0 because we want it to be larger than all other choices
val maxClipRetentionTime = mins * 60 * 1000L val maxClipRetentionTime = mins * 60 * 1000L
val now = System.currentTimeMillis() val now = System.currentTimeMillis()
historyEntries.removeAll { !it.isPinned && (now - it.timeStamp) > maxClipRetentionTime } historyEntries.removeAll { !it.isPinned && (now - it.timeStamp) > maxClipRetentionTime }

View file

@ -156,10 +156,10 @@ fun createPreferencesSettings(context: Context) = listOf(
key = setting.key, key = setting.key,
default = Defaults.PREF_CLIPBOARD_HISTORY_RETENTION_TIME, default = Defaults.PREF_CLIPBOARD_HISTORY_RETENTION_TIME,
description = { description = {
if (it < 0) stringResource(R.string.settings_no_limit) if (it > 120) stringResource(R.string.settings_no_limit)
else stringResource(R.string.abbreviation_unit_minutes, it.toString()) else stringResource(R.string.abbreviation_unit_minutes, it.toString())
}, },
range = -1f..120f, range = 1f..121f,
) )
}, },
Setting(context, Settings.PREF_VIBRATION_DURATION_SETTINGS, R.string.prefs_keypress_vibration_duration_settings) { setting -> Setting(context, Settings.PREF_VIBRATION_DURATION_SETTINGS, R.string.prefs_keypress_vibration_duration_settings) { setting ->