Disable Volumes keys on flash
- Thank Diareuse for helping me
This commit is contained in:
parent
4b8e92f00a
commit
93d5716414
@ -2,6 +2,7 @@ package com.topjohnwu.magisk.ui.base
|
|||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.KeyEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
@ -96,6 +97,10 @@ abstract class BaseUIActivity<ViewModel : BaseViewModel, Binding : ViewDataBindi
|
|||||||
delegate.onResume()
|
delegate.onResume()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
||||||
|
return currentFragment?.onKeyEvent(event) == true || super.dispatchKeyEvent(event)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onEventDispatched(event: ViewEvent) {
|
override fun onEventDispatched(event: ViewEvent) {
|
||||||
delegate.onEventExecute(event, this)
|
delegate.onEventExecute(event, this)
|
||||||
when (event) {
|
when (event) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.topjohnwu.magisk.ui.base
|
package com.topjohnwu.magisk.ui.base
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.KeyEvent
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@ -51,6 +52,10 @@ abstract class BaseUIFragment<ViewModel : BaseViewModel, Binding : ViewDataBindi
|
|||||||
delegate.onEventExecute(event, this)
|
delegate.onEventExecute(event, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun onKeyEvent(event: KeyEvent): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
open fun onBackPressed(): Boolean = false
|
open fun onBackPressed(): Boolean = false
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import android.content.Context
|
|||||||
import android.content.pm.ActivityInfo
|
import android.content.pm.ActivityInfo
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.KeyEvent
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuInflater
|
import android.view.MenuInflater
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
@ -62,6 +63,14 @@ class FlashFragment : BaseUIFragment<FlashViewModel, FragmentFlashMd2Binding>()
|
|||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onKeyEvent(event: KeyEvent): Boolean {
|
||||||
|
return when(event.keyCode) {
|
||||||
|
KeyEvent.KEYCODE_VOLUME_UP,
|
||||||
|
KeyEvent.KEYCODE_VOLUME_DOWN -> true
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onBackPressed(): Boolean {
|
override fun onBackPressed(): Boolean {
|
||||||
if (viewModel.loading) return true
|
if (viewModel.loading) return true
|
||||||
return super.onBackPressed()
|
return super.onBackPressed()
|
||||||
|
Loading…
Reference in New Issue
Block a user