diff --git a/app/src/main/java/ru/hepolise/volumekeytrackcontrol/module/VolumeKeyControlModuleHandlers.kt b/app/src/main/java/ru/hepolise/volumekeytrackcontrol/module/VolumeKeyControlModuleHandlers.kt
index 46b717c..67c5e52 100644
--- a/app/src/main/java/ru/hepolise/volumekeytrackcontrol/module/VolumeKeyControlModuleHandlers.kt
+++ b/app/src/main/java/ru/hepolise/volumekeytrackcontrol/module/VolumeKeyControlModuleHandlers.kt
@@ -231,7 +231,7 @@ object VolumeKeyControlModuleHandlers {
val handler = instance.getHandler()
handler.postDelayed(
getRunnable(instance, VOLUME_BOTH_LONG_PRESS),
- SharedPreferencesUtil.prefs().getLongPressDuration()
+ SharedPreferencesUtil.prefs().getLongPressDuration().toLong()
)
}
@@ -243,7 +243,7 @@ object VolumeKeyControlModuleHandlers {
KeyEvent.KEYCODE_VOLUME_DOWN -> getRunnable(instance, VOLUME_DOWN_LONG_PRESS)
else -> return
},
- SharedPreferencesUtil.prefs().getLongPressDuration()
+ SharedPreferencesUtil.prefs().getLongPressDuration().toLong()
)
}
diff --git a/app/src/main/java/ru/hepolise/volumekeytrackcontrol/ui/SettingsActivity.kt b/app/src/main/java/ru/hepolise/volumekeytrackcontrol/ui/SettingsActivity.kt
index e733fcc..bfc1cc9 100644
--- a/app/src/main/java/ru/hepolise/volumekeytrackcontrol/ui/SettingsActivity.kt
+++ b/app/src/main/java/ru/hepolise/volumekeytrackcontrol/ui/SettingsActivity.kt
@@ -55,7 +55,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
-import androidx.compose.runtime.mutableLongStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
@@ -137,9 +136,9 @@ fun VibrationSettingsScreen(vibrator: Vibrator?) {
exitProcess(0)
}
- var longPressDuration by remember { mutableLongStateOf(sharedPreferences.getLongPressDuration()) }
+ var longPressDuration by remember { mutableIntStateOf(sharedPreferences.getLongPressDuration()) }
var selectedEffect by remember { mutableIntStateOf(sharedPreferences.getSelectedEffect()) }
- var vibrationLength by remember { mutableLongStateOf(sharedPreferences.getVibrationLength()) }
+ var vibrationLength by remember { mutableIntStateOf(sharedPreferences.getVibrationLength()) }
var vibrationAmplitude by remember { mutableIntStateOf(sharedPreferences.getVibrationAmplitude()) }
Scaffold(
@@ -167,11 +166,11 @@ fun VibrationSettingsScreen(vibrator: Vibrator?) {
Slider(
value = longPressDuration.toFloat(),
onValueChange = {
- longPressDuration = it.toLong()
+ longPressDuration = it.toInt()
},
valueRange = 100f..1000f,
onValueChangeFinished = {
- sharedPreferences.edit().putLong(LONG_PRESS_DURATION, longPressDuration)
+ sharedPreferences.edit().putInt(LONG_PRESS_DURATION, longPressDuration)
.apply()
},
modifier = Modifier.widthIn(max = 300.dp)
@@ -201,7 +200,7 @@ fun VibrationSettingsScreen(vibrator: Vibrator?) {
onDismissRequest = { showLongPressTimeoutDialog = false },
onConfirm = {
longPressDuration = it
- sharedPreferences.edit().putLong(LONG_PRESS_DURATION, it).apply()
+ sharedPreferences.edit().putInt(LONG_PRESS_DURATION, it).apply()
showLongPressTimeoutDialog = false
}
)
@@ -247,11 +246,11 @@ fun VibrationSettingsScreen(vibrator: Vibrator?) {
Slider(
value = vibrationLength.toFloat(),
onValueChange = {
- vibrationLength = it.toLong()
+ vibrationLength = it.toInt()
},
valueRange = 10f..500f,
onValueChangeFinished = {
- sharedPreferences.edit().putLong(VIBRATION_LENGTH, vibrationLength)
+ sharedPreferences.edit().putInt(VIBRATION_LENGTH, vibrationLength)
.apply()
},
modifier = Modifier.widthIn(max = 300.dp)
@@ -281,7 +280,7 @@ fun VibrationSettingsScreen(vibrator: Vibrator?) {
onDismissRequest = { showManualVibrationLengthDialog = false },
onConfirm = {
vibrationLength = it
- sharedPreferences.edit().putLong(VIBRATION_LENGTH, it).apply()
+ sharedPreferences.edit().putInt(VIBRATION_LENGTH, it).apply()
showManualVibrationLengthDialog = false
}
)
@@ -318,13 +317,13 @@ fun VibrationSettingsScreen(vibrator: Vibrator?) {
if (showVibrationAmplitudeDialog) {
NumberAlertDialog(
title = stringResource(R.string.vibration_amplitude_dialog_title),
- defaultValue = vibrationAmplitude.toLong(),
+ defaultValue = vibrationAmplitude,
minValue = 1,
maxValue = 255,
onDismissRequest = { showVibrationAmplitudeDialog = false },
onConfirm = {
- vibrationAmplitude = it.toInt()
- sharedPreferences.edit().putInt(VIBRATION_AMPLITUDE, it.toInt())
+ vibrationAmplitude = it
+ sharedPreferences.edit().putInt(VIBRATION_AMPLITUDE, it)
.apply()
showVibrationAmplitudeDialog = false
}
@@ -395,13 +394,13 @@ fun dynamicColorScheme(context: Context): ColorScheme {
@Composable
fun NumberAlertDialog(
title: String,
- defaultValue: Long,
+ defaultValue: Int,
onDismissRequest: () -> Unit,
- onConfirm: (Long) -> Unit,
- minValue: Long = 0,
- maxValue: Long = Long.MAX_VALUE,
- validate: (Long) -> Boolean = { it in minValue..maxValue }
+ onConfirm: (Int) -> Unit,
+ minValue: Int,
+ maxValue: Int
) {
+ fun validate(value: Int) = value in minValue..maxValue
var value by remember { mutableStateOf(defaultValue.toString()) }
val focusRequester = remember { FocusRequester() }
AlertDialog(
@@ -414,7 +413,7 @@ fun NumberAlertDialog(
onValueChange = { value = it },
label = { Text(stringResource(R.string.value_in_range, minValue, maxValue)) },
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Number),
- isError = value.toLongOrNull() == null || !validate(value.toLong()),
+ isError = value.toIntOrNull() == null || !validate(value.toInt()),
modifier = Modifier.focusRequester(focusRequester)
)
}
@@ -422,9 +421,9 @@ fun NumberAlertDialog(
confirmButton = {
TextButton(
onClick = {
- onConfirm(value.toLong())
+ onConfirm(value.toInt())
},
- enabled = value.toLongOrNull() != null && validate(value.toLong())
+ enabled = value.toLongOrNull() != null && validate(value.toInt())
) {
Text(text = stringResource(R.string.ok))
}
diff --git a/app/src/main/java/ru/hepolise/volumekeytrackcontrol/util/SharedPreferencesUtil.kt b/app/src/main/java/ru/hepolise/volumekeytrackcontrol/util/SharedPreferencesUtil.kt
index 2808932..9e7cb44 100644
--- a/app/src/main/java/ru/hepolise/volumekeytrackcontrol/util/SharedPreferencesUtil.kt
+++ b/app/src/main/java/ru/hepolise/volumekeytrackcontrol/util/SharedPreferencesUtil.kt
@@ -14,9 +14,9 @@ object SharedPreferencesUtil {
const val LONG_PRESS_DURATION = "longPressDuration"
const val SELECTED_EFFECT_DEFAULT_VALUE = 0
- const val VIBRATION_LENGTH_DEFAULT_VALUE = 50L
+ const val VIBRATION_LENGTH_DEFAULT_VALUE = 50
const val VIBRATION_AMPLITUDE_DEFAULT_VALUE = 128
- val LONG_PRESS_DURATION_DEFAULT_VALUE = ViewConfiguration.getLongPressTimeout().toLong()
+ val LONG_PRESS_DURATION_DEFAULT_VALUE = ViewConfiguration.getLongPressTimeout()
fun SharedPreferences?.getSelectedEffect(): Int {
val defaultValue = SELECTED_EFFECT_DEFAULT_VALUE
@@ -27,9 +27,9 @@ object SharedPreferencesUtil {
return VibrationType.values[getSelectedEffect()]
}
- fun SharedPreferences?.getVibrationLength(): Long {
+ fun SharedPreferences?.getVibrationLength(): Int {
val defaultValue = VIBRATION_LENGTH_DEFAULT_VALUE
- return this?.getLong(VIBRATION_LENGTH, defaultValue) ?: defaultValue
+ return this?.getInt(VIBRATION_LENGTH, defaultValue) ?: defaultValue
}
fun SharedPreferences?.getVibrationAmplitude(): Int {
@@ -37,9 +37,9 @@ object SharedPreferencesUtil {
return this?.getInt(VIBRATION_AMPLITUDE, defaultValue) ?: defaultValue
}
- fun SharedPreferences?.getLongPressDuration(): Long {
+ fun SharedPreferences?.getLongPressDuration(): Int {
val defaultValue = LONG_PRESS_DURATION_DEFAULT_VALUE
- return this?.getLong(LONG_PRESS_DURATION, defaultValue) ?: defaultValue
+ return this?.getInt(LONG_PRESS_DURATION, defaultValue) ?: defaultValue
}
fun prefs(): SharedPreferences? {
diff --git a/app/src/main/java/ru/hepolise/volumekeytrackcontrol/util/VibratorUtil.kt b/app/src/main/java/ru/hepolise/volumekeytrackcontrol/util/VibratorUtil.kt
index 3778f00..92ccadd 100644
--- a/app/src/main/java/ru/hepolise/volumekeytrackcontrol/util/VibratorUtil.kt
+++ b/app/src/main/java/ru/hepolise/volumekeytrackcontrol/util/VibratorUtil.kt
@@ -32,7 +32,7 @@ object VibratorUtil {
} else {
this.vibrate(
VibrationEffect.createOneShot(
- prefs.getVibrationLength(),
+ prefs.getVibrationLength().toLong(),
prefs.getVibrationAmplitude()
)
)
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 9a9314f..cc139b2 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -31,5 +31,5 @@
Cancel
Edit
- Value in range %d..%d
+ Value in range %1$d..%2$d
diff --git a/build.gradle.kts b/build.gradle.kts
index 51d1dfc..53604bb 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -5,8 +5,8 @@ plugins {
id("org.jetbrains.kotlin.plugin.compose") version "2.1.0" apply false
}
-val versionName = "1.15.2"
-val versionCode = 9
+val versionName = "1.15.3"
+val versionCode = 10
rootProject.ext.set("appVersionName", versionName)
rootProject.ext.set("appVersionCode", versionCode)