From 784a7a7f24a7a7a0e2eb4981754ef5120639aa0a Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Sun, 17 Nov 2019 13:53:41 +0100 Subject: [PATCH] Added back press closing filters in hide and module screens --- .../topjohnwu/magisk/redesign/hide/HideFragment.kt | 14 ++++++++++++-- .../magisk/redesign/module/ModuleFragment.kt | 9 +++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/hide/HideFragment.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/hide/HideFragment.kt index 0bca3e37b..3d812a93e 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/hide/HideFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/hide/HideFragment.kt @@ -55,6 +55,18 @@ class HideFragment : CompatFragment() { 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) { inflater.inflate(R.menu.menu_hide_md2, menu) } @@ -70,8 +82,6 @@ class HideFragment : CompatFragment() { return super.onOptionsItemSelected(item) } - override fun onPreBind(binding: FragmentHideMd2Binding) = Unit - } object MotionRevealHelper { diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/module/ModuleFragment.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/module/ModuleFragment.kt index 09bcdeb44..c3cf5b993 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/module/ModuleFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/module/ModuleFragment.kt @@ -7,6 +7,7 @@ import android.view.Menu import android.view.MenuInflater import android.view.MenuItem import android.view.View +import androidx.core.view.isVisible import androidx.recyclerview.widget.StaggeredGridLayoutManager import com.topjohnwu.magisk.R import com.topjohnwu.magisk.databinding.FragmentModuleMd2Binding @@ -64,6 +65,14 @@ class ModuleFragment : CompatFragment 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) {