Skip to content

Commit

Permalink
feat(root): add haptics to power button
Browse files Browse the repository at this point in the history
  • Loading branch information
timschneeb committed Aug 2, 2023
1 parent 8890e25 commit 3c48d8f
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3c48d8f

Please sign in to comment.