Added back press closing filters in hide and module screens

This commit is contained in:
Viktor De Pasquale 2019-11-17 13:53:41 +01:00
parent 8e34baa59f
commit 784a7a7f24
2 changed files with 21 additions and 2 deletions

View File

@ -55,6 +55,18 @@ class HideFragment : CompatFragment<HideViewModel, FragmentHideMd2Binding>() {
lama.isAutoMeasureEnabled = false lama.isAutoMeasureEnabled = false
} }
override fun onPreBind(binding: FragmentHideMd2Binding) = Unit
override fun onBackPressed(): Boolean {
if (binding.hideFilter.isVisible) {
binding.hideFilterInclude.hideFilterDone.performClick()
return true
}
return super.onBackPressed()
}
// ---
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.menu_hide_md2, menu) inflater.inflate(R.menu.menu_hide_md2, menu)
} }
@ -70,8 +82,6 @@ class HideFragment : CompatFragment<HideViewModel, FragmentHideMd2Binding>() {
return super.onOptionsItemSelected(item) return super.onOptionsItemSelected(item)
} }
override fun onPreBind(binding: FragmentHideMd2Binding) = Unit
} }
object MotionRevealHelper { object MotionRevealHelper {

View File

@ -7,6 +7,7 @@ import android.view.Menu
import android.view.MenuInflater import android.view.MenuInflater
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import androidx.core.view.isVisible
import androidx.recyclerview.widget.StaggeredGridLayoutManager import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.topjohnwu.magisk.R import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.databinding.FragmentModuleMd2Binding import com.topjohnwu.magisk.databinding.FragmentModuleMd2Binding
@ -64,6 +65,14 @@ class ModuleFragment : CompatFragment<ModuleViewModel, FragmentModuleMd2Binding>
super.onDestroyView() super.onDestroyView()
} }
override fun onBackPressed(): Boolean {
if (binding.moduleFilter.isVisible) {
binding.moduleFilterInclude.moduleFilterDone.performClick()
return true
}
return super.onBackPressed()
}
// --- // ---
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {