diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 6477297..f593adf 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -13,8 +13,8 @@ android {
applicationId = "com.bartixxx.opflashcontrol"
minSdk = 31
targetSdk = 35
- versionCode = 14
- versionName = "1.1.1"
+ versionCode = 15
+ versionName = "1.1.2"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 5ca1b14..5a121d5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools">
+
Unit
) {
+ var lastIntegerValue = slider.value.toInt() // Track the last integer value
+
slider.addOnChangeListener { _, value, _ ->
val progress = value.toInt() // Convert from Float to Int
- Log.d("SliderProgress", "$label Progress: $progress") // Debugging log
+ // Vibrate only if the integer part of the slider value has changed
+ if (progress != lastIntegerValue) {
+ VibrationUtil.vibrate50(this)
+ lastIntegerValue = progress
+ }
+
+ Log.d("SliderProgress", "$label Progress: $progress") // Debugging log
textView.text = "$label: $progress"
}
diff --git a/app/src/main/java/com/bartixxx/opflashcontrol/MainActivity.kt b/app/src/main/java/com/bartixxx/opflashcontrol/MainActivity.kt
index cf77429..8a8d048 100644
--- a/app/src/main/java/com/bartixxx/opflashcontrol/MainActivity.kt
+++ b/app/src/main/java/com/bartixxx/opflashcontrol/MainActivity.kt
@@ -48,10 +48,22 @@ class MainActivity : BaseActivity() {
}
}
- on.setOnClickListener { toggleLEDs(true) }
- off.setOnClickListener { toggleLEDs(false) }
- destroyer.setOnClickListener { executeExtraFunction() }
- navigateToMainActivity2.setOnClickListener { navigateToMainActivity2() }
+ on.setOnClickListener {
+ VibrationUtil.vibrate100(this@MainActivity)
+ toggleLEDs(true)
+ }
+ off.setOnClickListener {
+ VibrationUtil.vibrate100(this@MainActivity)
+ toggleLEDs(false)
+ }
+ destroyer.setOnClickListener {
+ VibrationUtil.vibrate100(this@MainActivity)
+ executeExtraFunction()
+ }
+ navigateToMainActivity2.setOnClickListener {
+ VibrationUtil.vibrate100(this@MainActivity)
+ navigateToMainActivity2()
+ }
}
}
diff --git a/app/src/main/java/com/bartixxx/opflashcontrol/MainActivity2.kt b/app/src/main/java/com/bartixxx/opflashcontrol/MainActivity2.kt
index e2af0dc..4b5979d 100644
--- a/app/src/main/java/com/bartixxx/opflashcontrol/MainActivity2.kt
+++ b/app/src/main/java/com/bartixxx/opflashcontrol/MainActivity2.kt
@@ -59,10 +59,22 @@ class MainActivity2 : BaseActivity() {
if (isLedOn) controlLeds("on", WHITE_LED_PATH, YELLOW_LED_PATH, WHITE2_LED_PATH, YELLOW2_LED_PATH, whiteBrightness, yellowBrightness, white2Brightness, progress)
}
- on.setOnClickListener { toggleLEDs(true) }
- off.setOnClickListener { toggleLEDs(false) }
- destroyer.setOnClickListener { executeExtraFunction() }
- navigateBackToMainActivity.setOnClickListener { navigateBackToMainActivity() }
+ on.setOnClickListener {
+ VibrationUtil.vibrate100(this@MainActivity2)
+ toggleLEDs(true)
+ }
+ off.setOnClickListener {
+ VibrationUtil.vibrate100(this@MainActivity2)
+ toggleLEDs(false)
+ }
+ destroyer.setOnClickListener {
+ VibrationUtil.vibrate100(this@MainActivity2)
+ executeExtraFunction()
+ }
+ navigateBackToMainActivity.setOnClickListener {
+ VibrationUtil.vibrate100(this@MainActivity2)
+ navigateBackToMainActivity()
+ }
}
}
diff --git a/app/src/main/java/com/bartixxx/opflashcontrol/VibrationUtil.kt b/app/src/main/java/com/bartixxx/opflashcontrol/VibrationUtil.kt
new file mode 100644
index 0000000..26b9e35
--- /dev/null
+++ b/app/src/main/java/com/bartixxx/opflashcontrol/VibrationUtil.kt
@@ -0,0 +1,27 @@
+package com.bartixxx.opflashcontrol
+
+import android.content.Context
+import android.os.Build
+import android.os.VibrationEffect
+import android.os.Vibrator
+
+object VibrationUtil {
+ fun vibrate50(context: Context, duration: Long = 50L) {
+ val vibrator = context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ vibrator.vibrate(VibrationEffect.createOneShot(duration, VibrationEffect.DEFAULT_AMPLITUDE))
+ } else {
+ // Deprecated in API 26
+ vibrator.vibrate(duration)
+ }
+ }
+ fun vibrate100(context: Context, duration: Long = 100L) {
+ val vibrator = context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ vibrator.vibrate(VibrationEffect.createOneShot(duration, VibrationEffect.DEFAULT_AMPLITUDE))
+ } else {
+ // Deprecated in API 26
+ vibrator.vibrate(duration)
+ }
+ }
+}
\ No newline at end of file