From 3c48d8f5e5c294a7205817e2bb3a591929924fd6 Mon Sep 17 00:00:00 2001 From: Tim Schneeberger Date: Wed, 2 Aug 2023 00:46:00 +0200 Subject: [PATCH] feat(root): add haptics to power button --- .../rootlessjamesdsp/activity/MainActivity.kt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/MainActivity.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/MainActivity.kt index f39425e5a..e79d74522 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/MainActivity.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/MainActivity.kt @@ -254,24 +254,26 @@ class MainActivity : BaseActivity() { binding.powerToggle.toggleOnClick = false binding.powerToggle.setOnToggleClickListener(object : FloatingToggleButton.OnToggleClickListener{ override fun onClick() { + sdkAbove(Build.VERSION_CODES.R) { + binding.powerToggle.performHapticFeedback( + if(binding.powerToggle.isToggled) + HapticFeedbackConstants.CONFIRM + else + HapticFeedbackConstants.REJECT + ) + } + if(SdkCheck.isQ && isRootless()) { if (binding.powerToggle.isToggled) { // Currently on, let's turn it off RootlessAudioProcessorService.stop(this@MainActivity) binding.powerToggle.isToggled = false - - sdkAbove(Build.VERSION_CODES.R) { - binding.powerToggle.performHapticFeedback(HapticFeedbackConstants.REJECT) - } } else { // Currently off, let's turn it on - sdkAbove(Build.VERSION_CODES.R) { - binding.powerToggle.performHapticFeedback(HapticFeedbackConstants.CONFIRM) - } requestCapturePermission() } } - else if (!isRootless()) { + else if (isRoot()) { when(JamesDspRemoteEngine.isPluginInstalled() ) { JamesDspRemoteEngine.PluginState.Available -> { binding.powerToggle.isToggled = !binding.powerToggle.isToggled