mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-18 05:58:30 +00:00
Added hiding keyboard when "done" button pressed
This commit is contained in:
parent
eec5b37da1
commit
c69dcf3e20
@ -1,9 +1,12 @@
|
||||
package com.topjohnwu.magisk.redesign.compat
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import androidx.core.content.getSystemService
|
||||
import androidx.databinding.OnRebindCallback
|
||||
import androidx.databinding.ViewDataBinding
|
||||
import androidx.fragment.app.Fragment
|
||||
@ -17,6 +20,7 @@ import com.topjohnwu.magisk.model.navigation.MagiskNavigationEvent
|
||||
import com.topjohnwu.magisk.model.navigation.Navigator
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
|
||||
abstract class CompatActivity<ViewModel : CompatViewModel, Binding : ViewDataBinding> :
|
||||
BaseActivity<ViewModel, Binding>(), CompatView<ViewModel>, Navigator {
|
||||
|
||||
@ -78,4 +82,11 @@ abstract class CompatActivity<ViewModel : CompatViewModel, Binding : ViewDataBin
|
||||
|
||||
protected fun ViewEvent.dispatchOnSelf() = onEventDispatched(this)
|
||||
|
||||
}
|
||||
|
||||
fun Activity.hideKeyboard() {
|
||||
val view = currentFocus ?: return
|
||||
getSystemService<InputMethodManager>()
|
||||
?.hideSoftInputFromWindow(view.windowToken, 0)
|
||||
view.clearFocus()
|
||||
}
|
@ -5,6 +5,7 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.OnRebindCallback
|
||||
import androidx.databinding.ViewDataBinding
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.topjohnwu.magisk.base.BaseFragment
|
||||
import com.topjohnwu.magisk.extensions.startAnimations
|
||||
import com.topjohnwu.magisk.model.events.ViewEvent
|
||||
@ -48,4 +49,8 @@ abstract class CompatFragment<ViewModel : CompatViewModel, Binding : ViewDataBin
|
||||
|
||||
protected fun ViewEvent.dispatchOnSelf() = delegate.onEventExecute(this, this@CompatFragment)
|
||||
|
||||
}
|
||||
|
||||
fun Fragment.hideKeyboard() {
|
||||
activity?.hideKeyboard()
|
||||
}
|
@ -22,6 +22,7 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.databinding.FragmentHideMd2Binding
|
||||
import com.topjohnwu.magisk.redesign.compat.CompatFragment
|
||||
import com.topjohnwu.magisk.redesign.compat.hideKeyboard
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
import kotlin.math.hypot
|
||||
|
||||
@ -45,6 +46,7 @@ class HideFragment : CompatFragment<HideViewModel, FragmentHideMd2Binding>() {
|
||||
MotionRevealHelper.withViews(binding.hideFilter, binding.hideFilterToggle, true)
|
||||
}
|
||||
binding.hideFilterInclude.hideFilterDone.setOnClickListener {
|
||||
hideKeyboard()
|
||||
MotionRevealHelper.withViews(binding.hideFilter, binding.hideFilterToggle, false)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user