From 8eac6c0b48d0d606e0e31efb6153643e11406cb6 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 22 Jan 2022 14:42:34 -0800 Subject: [PATCH] Cleanup arch classes --- .../{BaseUIFragment.kt => BaseFragment.kt} | 8 ++--- .../topjohnwu/magisk/arch/BaseMainActivity.kt | 3 +- .../magisk/arch/NavigationActivity.kt | 35 +++++++++++++++++++ .../arch/{BaseUIActivity.kt => UIActivity.kt} | 33 ++--------------- .../com/topjohnwu/magisk/arch/ViewEvent.kt | 4 +-- ...{BaseUIComponent.kt => ViewModelHolder.kt} | 6 ++-- .../topjohnwu/magisk/events/SnackbarEvent.kt | 4 +-- .../com/topjohnwu/magisk/events/ViewEvents.kt | 18 +++++----- .../magisk/events/dialog/BiometricEvent.kt | 4 +-- .../magisk/events/dialog/DialogEvent.kt | 4 +-- .../magisk/events/dialog/UninstallDialog.kt | 6 ++-- .../com/topjohnwu/magisk/ui/MainActivity.kt | 2 +- .../magisk/ui/deny/DenyListFragment.kt | 4 +-- .../magisk/ui/flash/FlashFragment.kt | 4 +-- .../topjohnwu/magisk/ui/home/HomeFragment.kt | 4 +-- .../topjohnwu/magisk/ui/home/HomeViewModel.kt | 2 +- .../magisk/ui/install/InstallFragment.kt | 4 +-- .../topjohnwu/magisk/ui/log/LogFragment.kt | 4 +-- .../magisk/ui/module/ModuleFragment.kt | 4 +-- .../magisk/ui/settings/SettingsFragment.kt | 4 +-- .../magisk/ui/superuser/SuperuserFragment.kt | 4 +-- .../magisk/ui/surequest/SuRequestActivity.kt | 6 ++-- .../magisk/ui/theme/ThemeFragment.kt | 4 +-- 23 files changed, 85 insertions(+), 86 deletions(-) rename app/src/main/java/com/topjohnwu/magisk/arch/{BaseUIFragment.kt => BaseFragment.kt} (88%) create mode 100644 app/src/main/java/com/topjohnwu/magisk/arch/NavigationActivity.kt rename app/src/main/java/com/topjohnwu/magisk/arch/{BaseUIActivity.kt => UIActivity.kt} (72%) rename app/src/main/java/com/topjohnwu/magisk/arch/{BaseUIComponent.kt => ViewModelHolder.kt} (71%) diff --git a/app/src/main/java/com/topjohnwu/magisk/arch/BaseUIFragment.kt b/app/src/main/java/com/topjohnwu/magisk/arch/BaseFragment.kt similarity index 88% rename from app/src/main/java/com/topjohnwu/magisk/arch/BaseUIFragment.kt rename to app/src/main/java/com/topjohnwu/magisk/arch/BaseFragment.kt index a71e4e0da..9a6b6a59d 100644 --- a/app/src/main/java/com/topjohnwu/magisk/arch/BaseUIFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/arch/BaseFragment.kt @@ -13,14 +13,12 @@ import androidx.navigation.NavDirections import com.topjohnwu.magisk.BR import com.topjohnwu.magisk.ktx.startAnimations -abstract class BaseUIFragment : - Fragment(), BaseUIComponent { +abstract class BaseFragment : Fragment(), ViewModelHolder { - val activity get() = requireActivity() as BaseUIActivity<*, *> + val activity get() = requireActivity() as NavigationActivity<*> protected lateinit var binding: Binding protected abstract val layoutRes: Int - override val viewRoot: View get() = binding.root private val navigation get() = activity.navigation open val snackbarAnchorView: View? get() = null @@ -64,7 +62,7 @@ abstract class BaseUIFragment : super.onViewCreated(view, savedInstanceState) binding.addOnRebindCallback(object : OnRebindCallback() { override fun onPreBind(binding: Binding): Boolean { - this@BaseUIFragment.onPreBind(binding) + this@BaseFragment.onPreBind(binding) return true } }) diff --git a/app/src/main/java/com/topjohnwu/magisk/arch/BaseMainActivity.kt b/app/src/main/java/com/topjohnwu/magisk/arch/BaseMainActivity.kt index 24ed4cf81..c06a3b638 100644 --- a/app/src/main/java/com/topjohnwu/magisk/arch/BaseMainActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/arch/BaseMainActivity.kt @@ -21,8 +21,7 @@ import com.topjohnwu.superuser.Shell import java.util.concurrent.CountDownLatch import java.util.concurrent.TimeUnit -abstract class BaseMainActivity - : BaseUIActivity() { +abstract class BaseMainActivity : NavigationActivity() { companion object { private var doPreload = true diff --git a/app/src/main/java/com/topjohnwu/magisk/arch/NavigationActivity.kt b/app/src/main/java/com/topjohnwu/magisk/arch/NavigationActivity.kt new file mode 100644 index 000000000..abcd52b5d --- /dev/null +++ b/app/src/main/java/com/topjohnwu/magisk/arch/NavigationActivity.kt @@ -0,0 +1,35 @@ +package com.topjohnwu.magisk.arch + +import android.view.KeyEvent +import androidx.databinding.ViewDataBinding +import androidx.navigation.NavController +import androidx.navigation.NavDirections +import androidx.navigation.fragment.NavHostFragment + +abstract class NavigationActivity : UIActivity() { + + abstract val navHostId: Int + + private val navHostFragment by lazy { + supportFragmentManager.findFragmentById(navHostId) as NavHostFragment + } + + protected val currentFragment get() = + navHostFragment.childFragmentManager.fragments.getOrNull(0) as? BaseFragment<*> + + val navigation: NavController get() = navHostFragment.navController + + override fun dispatchKeyEvent(event: KeyEvent): Boolean { + return currentFragment?.onKeyEvent(event) == true || super.dispatchKeyEvent(event) + } + + override fun onBackPressed() { + if (currentFragment?.onBackPressed()?.not() == true) { + super.onBackPressed() + } + } + + fun NavDirections.navigate() { + navigation.navigate(this) + } +} diff --git a/app/src/main/java/com/topjohnwu/magisk/arch/BaseUIActivity.kt b/app/src/main/java/com/topjohnwu/magisk/arch/UIActivity.kt similarity index 72% rename from app/src/main/java/com/topjohnwu/magisk/arch/BaseUIActivity.kt rename to app/src/main/java/com/topjohnwu/magisk/arch/UIActivity.kt index 81d38b0a4..43c71a64f 100644 --- a/app/src/main/java/com/topjohnwu/magisk/arch/BaseUIActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/arch/UIActivity.kt @@ -4,37 +4,22 @@ import android.content.res.Resources import android.graphics.Color import android.os.Build import android.os.Bundle -import android.view.KeyEvent import android.view.View import androidx.appcompat.app.AppCompatDelegate import androidx.core.content.res.use import androidx.databinding.DataBindingUtil import androidx.databinding.ViewDataBinding -import androidx.navigation.NavController -import androidx.navigation.NavDirections -import androidx.navigation.fragment.NavHostFragment import com.topjohnwu.magisk.BR import com.topjohnwu.magisk.core.Config import com.topjohnwu.magisk.core.base.BaseActivity import rikka.insets.WindowInsetsHelper import rikka.layoutinflater.view.LayoutInflaterFactory -abstract class BaseUIActivity : - BaseActivity(), BaseUIComponent { +abstract class UIActivity : BaseActivity(), ViewModelHolder { protected lateinit var binding: Binding protected abstract val layoutRes: Int - private val navHostFragment by lazy { - supportFragmentManager.findFragmentById(navHostId) as? NavHostFragment - } - private val topFragment get() = navHostFragment?.childFragmentManager?.fragments?.getOrNull(0) - protected val currentFragment get() = topFragment as? BaseUIFragment<*, *> - - override val viewRoot: View get() = binding.root - open val navigation: NavController? get() = navHostFragment?.navController - - open val navHostId: Int = 0 open val snackbarView get() = binding.root open val snackbarAnchorView: View? get() = null @@ -89,7 +74,7 @@ abstract class BaseUIActivity : } fun setAccessibilityDelegate(delegate: View.AccessibilityDelegate?) { - viewRoot.rootView.accessibilityDelegate = delegate + binding.root.rootView.accessibilityDelegate = delegate } override fun onResume() { @@ -97,23 +82,9 @@ abstract class BaseUIActivity : viewModel.requestRefresh() } - override fun dispatchKeyEvent(event: KeyEvent): Boolean { - return currentFragment?.onKeyEvent(event) == true || super.dispatchKeyEvent(event) - } - override fun onEventDispatched(event: ViewEvent) = when (event) { is ContextExecutor -> event(this) is ActivityExecutor -> event(this) else -> Unit } - - override fun onBackPressed() { - if (navigation == null || currentFragment?.onBackPressed()?.not() == true) { - super.onBackPressed() - } - } - - fun NavDirections.navigate() { - navigation?.navigate(this) - } } diff --git a/app/src/main/java/com/topjohnwu/magisk/arch/ViewEvent.kt b/app/src/main/java/com/topjohnwu/magisk/arch/ViewEvent.kt index 050e2dc0d..5bb1c1940 100644 --- a/app/src/main/java/com/topjohnwu/magisk/arch/ViewEvent.kt +++ b/app/src/main/java/com/topjohnwu/magisk/arch/ViewEvent.kt @@ -18,9 +18,9 @@ interface ContextExecutor { } interface ActivityExecutor { - operator fun invoke(activity: BaseUIActivity<*, *>) + operator fun invoke(activity: UIActivity<*>) } interface FragmentExecutor { - operator fun invoke(fragment: BaseUIFragment<*, *>) + operator fun invoke(fragment: BaseFragment<*>) } diff --git a/app/src/main/java/com/topjohnwu/magisk/arch/BaseUIComponent.kt b/app/src/main/java/com/topjohnwu/magisk/arch/ViewModelHolder.kt similarity index 71% rename from app/src/main/java/com/topjohnwu/magisk/arch/BaseUIComponent.kt rename to app/src/main/java/com/topjohnwu/magisk/arch/ViewModelHolder.kt index 741ddaa1a..9e90ce227 100644 --- a/app/src/main/java/com/topjohnwu/magisk/arch/BaseUIComponent.kt +++ b/app/src/main/java/com/topjohnwu/magisk/arch/ViewModelHolder.kt @@ -1,12 +1,10 @@ package com.topjohnwu.magisk.arch -import android.view.View import androidx.lifecycle.LifecycleOwner -interface BaseUIComponent : LifecycleOwner { +interface ViewModelHolder : LifecycleOwner { - val viewRoot: View - val viewModel: VM + val viewModel: BaseViewModel fun startObserveEvents() { viewModel.viewEvents.observe(this) { diff --git a/app/src/main/java/com/topjohnwu/magisk/events/SnackbarEvent.kt b/app/src/main/java/com/topjohnwu/magisk/events/SnackbarEvent.kt index d8a488604..9f67021dc 100644 --- a/app/src/main/java/com/topjohnwu/magisk/events/SnackbarEvent.kt +++ b/app/src/main/java/com/topjohnwu/magisk/events/SnackbarEvent.kt @@ -4,7 +4,7 @@ import android.view.View import androidx.annotation.StringRes import com.google.android.material.snackbar.Snackbar import com.topjohnwu.magisk.arch.ActivityExecutor -import com.topjohnwu.magisk.arch.BaseUIActivity +import com.topjohnwu.magisk.arch.UIActivity import com.topjohnwu.magisk.arch.ViewEvent import com.topjohnwu.magisk.utils.TextHolder import com.topjohnwu.magisk.utils.asText @@ -36,7 +36,7 @@ class SnackbarEvent constructor( builder: Snackbar.() -> Unit ) = Snackbar.make(view, message, length).setAnchorView(anchor).apply(builder).show() - override fun invoke(activity: BaseUIActivity<*, *>) { + override fun invoke(activity: UIActivity<*>) { snackbar(activity.snackbarView, activity.snackbarAnchorView, msg.getText(activity.resources).toString(), length, builder) diff --git a/app/src/main/java/com/topjohnwu/magisk/events/ViewEvents.kt b/app/src/main/java/com/topjohnwu/magisk/events/ViewEvents.kt index 023d952b8..22f227d78 100644 --- a/app/src/main/java/com/topjohnwu/magisk/events/ViewEvents.kt +++ b/app/src/main/java/com/topjohnwu/magisk/events/ViewEvents.kt @@ -18,32 +18,32 @@ class PermissionEvent( private val callback: (Boolean) -> Unit ) : ViewEvent(), ActivityExecutor { - override fun invoke(activity: BaseUIActivity<*, *>) = + override fun invoke(activity: UIActivity<*>) = activity.withPermission(permission, callback) } class BackPressEvent : ViewEvent(), ActivityExecutor { - override fun invoke(activity: BaseUIActivity<*, *>) { + override fun invoke(activity: UIActivity<*>) { activity.onBackPressed() } } class DieEvent : ViewEvent(), ActivityExecutor { - override fun invoke(activity: BaseUIActivity<*, *>) { + override fun invoke(activity: UIActivity<*>) { activity.finish() } } class ShowUIEvent(private val delegate: View.AccessibilityDelegate?) : ViewEvent(), ActivityExecutor { - override fun invoke(activity: BaseUIActivity<*, *>) { + override fun invoke(activity: UIActivity<*>) { activity.setContentView() activity.setAccessibilityDelegate(delegate) } } class RecreateEvent : ViewEvent(), ActivityExecutor { - override fun invoke(activity: BaseUIActivity<*, *>) { + override fun invoke(activity: UIActivity<*>) { activity.recreate() } } @@ -51,7 +51,7 @@ class RecreateEvent : ViewEvent(), ActivityExecutor { class MagiskInstallFileEvent( private val callback: (Uri) -> Unit ) : ViewEvent(), ActivityExecutor { - override fun invoke(activity: BaseUIActivity<*, *>) { + override fun invoke(activity: UIActivity<*>) { try { activity.getContent("*/*", callback) Utils.toast(R.string.patch_file_msg, Toast.LENGTH_LONG) @@ -65,8 +65,8 @@ class NavigationEvent( private val directions: NavDirections, private val pop: Boolean ) : ViewEvent(), ActivityExecutor { - override fun invoke(activity: BaseUIActivity<*, *>) { - (activity as? BaseUIActivity<*, *>)?.apply { + override fun invoke(activity: UIActivity<*>) { + (activity as? NavigationActivity<*>)?.apply { if (pop) navigation?.popBackStack() directions.navigate() } @@ -80,7 +80,7 @@ class AddHomeIconEvent : ViewEvent(), ContextExecutor { } class SelectModuleEvent : ViewEvent(), FragmentExecutor { - override fun invoke(fragment: BaseUIFragment<*, *>) { + override fun invoke(fragment: BaseFragment<*>) { try { fragment.apply { activity.getContent("application/zip") { diff --git a/app/src/main/java/com/topjohnwu/magisk/events/dialog/BiometricEvent.kt b/app/src/main/java/com/topjohnwu/magisk/events/dialog/BiometricEvent.kt index 63a4f247d..e98a985e2 100644 --- a/app/src/main/java/com/topjohnwu/magisk/events/dialog/BiometricEvent.kt +++ b/app/src/main/java/com/topjohnwu/magisk/events/dialog/BiometricEvent.kt @@ -1,7 +1,7 @@ package com.topjohnwu.magisk.events.dialog import com.topjohnwu.magisk.arch.ActivityExecutor -import com.topjohnwu.magisk.arch.BaseUIActivity +import com.topjohnwu.magisk.arch.UIActivity import com.topjohnwu.magisk.arch.ViewEvent import com.topjohnwu.magisk.core.utils.BiometricHelper @@ -16,7 +16,7 @@ class BiometricEvent( builder(Builder()) } - override fun invoke(activity: BaseUIActivity<*, *>) { + override fun invoke(activity: UIActivity<*>) { BiometricHelper.authenticate( activity, onError = listenerOnFailure, diff --git a/app/src/main/java/com/topjohnwu/magisk/events/dialog/DialogEvent.kt b/app/src/main/java/com/topjohnwu/magisk/events/dialog/DialogEvent.kt index e7b5886d5..1ad528d4d 100644 --- a/app/src/main/java/com/topjohnwu/magisk/events/dialog/DialogEvent.kt +++ b/app/src/main/java/com/topjohnwu/magisk/events/dialog/DialogEvent.kt @@ -1,13 +1,13 @@ package com.topjohnwu.magisk.events.dialog import com.topjohnwu.magisk.arch.ActivityExecutor -import com.topjohnwu.magisk.arch.BaseUIActivity +import com.topjohnwu.magisk.arch.UIActivity import com.topjohnwu.magisk.arch.ViewEvent import com.topjohnwu.magisk.view.MagiskDialog abstract class DialogEvent : ViewEvent(), ActivityExecutor { - override fun invoke(activity: BaseUIActivity<*, *>) { + override fun invoke(activity: UIActivity<*>) { MagiskDialog(activity) .apply { setOwnerActivity(activity) } .apply(this::build).show() diff --git a/app/src/main/java/com/topjohnwu/magisk/events/dialog/UninstallDialog.kt b/app/src/main/java/com/topjohnwu/magisk/events/dialog/UninstallDialog.kt index 99a8848f1..7a07bffbd 100644 --- a/app/src/main/java/com/topjohnwu/magisk/events/dialog/UninstallDialog.kt +++ b/app/src/main/java/com/topjohnwu/magisk/events/dialog/UninstallDialog.kt @@ -4,7 +4,7 @@ import android.app.ProgressDialog import android.content.Context import android.widget.Toast import com.topjohnwu.magisk.R -import com.topjohnwu.magisk.arch.BaseUIActivity +import com.topjohnwu.magisk.arch.NavigationActivity import com.topjohnwu.magisk.ui.flash.FlashFragment import com.topjohnwu.magisk.utils.Utils import com.topjohnwu.magisk.view.MagiskDialog @@ -45,8 +45,8 @@ class UninstallDialog : DialogEvent() { } private fun completeUninstall(dialog: MagiskDialog) { - (dialog.ownerActivity as BaseUIActivity<*, *>) - .navigation?.navigate(FlashFragment.uninstall()) + (dialog.ownerActivity as NavigationActivity<*>) + .navigation.navigate(FlashFragment.uninstall()) } } diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt b/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt index deacd252d..98b93745b 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt @@ -27,7 +27,7 @@ import java.io.File class MainViewModel : BaseViewModel() -class MainActivity : BaseMainActivity() { +class MainActivity : BaseMainActivity() { override val layoutRes = R.layout.activity_main_md2 override val viewModel by viewModel() diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListFragment.kt index 124429c28..1b9698242 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListFragment.kt @@ -9,7 +9,7 @@ import android.view.View import androidx.appcompat.widget.SearchView import androidx.recyclerview.widget.RecyclerView import com.topjohnwu.magisk.R -import com.topjohnwu.magisk.arch.BaseUIFragment +import com.topjohnwu.magisk.arch.BaseFragment import com.topjohnwu.magisk.databinding.FragmentDenyMd2Binding import com.topjohnwu.magisk.di.viewModel import com.topjohnwu.magisk.ktx.hideKeyboard @@ -17,7 +17,7 @@ import rikka.recyclerview.addEdgeSpacing import rikka.recyclerview.addItemSpacing import rikka.recyclerview.fixEdgeEffect -class DenyListFragment : BaseUIFragment() { +class DenyListFragment : BaseFragment() { override val layoutRes = R.layout.fragment_deny_md2 override val viewModel by viewModel() diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashFragment.kt index 9151dc3a9..793e1fb02 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashFragment.kt @@ -9,14 +9,14 @@ import android.view.* import androidx.navigation.NavDeepLinkBuilder import com.topjohnwu.magisk.MainDirections import com.topjohnwu.magisk.R -import com.topjohnwu.magisk.arch.BaseUIFragment +import com.topjohnwu.magisk.arch.BaseFragment import com.topjohnwu.magisk.core.Const import com.topjohnwu.magisk.core.cmp import com.topjohnwu.magisk.databinding.FragmentFlashMd2Binding import com.topjohnwu.magisk.di.viewModel import com.topjohnwu.magisk.ui.MainActivity -class FlashFragment : BaseUIFragment() { +class FlashFragment : BaseFragment() { override val layoutRes = R.layout.fragment_flash_md2 override val viewModel by viewModel() diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeFragment.kt index d542a931e..8fc5fc22f 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeFragment.kt @@ -5,14 +5,14 @@ import android.view.* import android.widget.ImageView import android.widget.TextView import com.topjohnwu.magisk.R -import com.topjohnwu.magisk.arch.BaseUIFragment +import com.topjohnwu.magisk.arch.BaseFragment import com.topjohnwu.magisk.core.download.DownloadService import com.topjohnwu.magisk.databinding.FragmentHomeMd2Binding import com.topjohnwu.magisk.di.viewModel import com.topjohnwu.magisk.events.RebootEvent import com.topjohnwu.superuser.Shell -class HomeFragment : BaseUIFragment() { +class HomeFragment : BaseFragment() { override val layoutRes = R.layout.fragment_home_md2 override val viewModel by viewModel() diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt index 0edcd405c..ea9a20cd5 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt @@ -106,7 +106,7 @@ class HomeViewModel( val showTest = false fun onTestPressed() = object : ViewEvent(), ActivityExecutor { - override fun invoke(activity: BaseUIActivity<*, *>) { + override fun invoke(activity: UIActivity<*>) { /* Entry point to trigger test events within the app */ } }.publish() diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallFragment.kt index e4ce11e78..aad114f83 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallFragment.kt @@ -5,11 +5,11 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import com.topjohnwu.magisk.R -import com.topjohnwu.magisk.arch.BaseUIFragment +import com.topjohnwu.magisk.arch.BaseFragment import com.topjohnwu.magisk.databinding.FragmentInstallMd2Binding import com.topjohnwu.magisk.di.viewModel -class InstallFragment : BaseUIFragment() { +class InstallFragment : BaseFragment() { override val layoutRes = R.layout.fragment_install_md2 override val viewModel by viewModel() diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/log/LogFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/log/LogFragment.kt index f28ecd587..bb9fe37d2 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/log/LogFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/log/LogFragment.kt @@ -7,7 +7,7 @@ import android.view.MenuItem import android.view.View import androidx.core.view.isVisible import com.topjohnwu.magisk.R -import com.topjohnwu.magisk.arch.BaseUIFragment +import com.topjohnwu.magisk.arch.BaseFragment import com.topjohnwu.magisk.databinding.FragmentLogMd2Binding import com.topjohnwu.magisk.di.viewModel import com.topjohnwu.magisk.ui.MainActivity @@ -16,7 +16,7 @@ import rikka.recyclerview.addEdgeSpacing import rikka.recyclerview.addItemSpacing import rikka.recyclerview.fixEdgeEffect -class LogFragment : BaseUIFragment() { +class LogFragment : BaseFragment() { override val layoutRes = R.layout.fragment_log_md2 override val viewModel by viewModel() diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleFragment.kt index 912c995f0..8d4d06807 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleFragment.kt @@ -3,7 +3,7 @@ package com.topjohnwu.magisk.ui.module import android.os.Bundle import android.view.View import com.topjohnwu.magisk.R -import com.topjohnwu.magisk.arch.BaseUIFragment +import com.topjohnwu.magisk.arch.BaseFragment import com.topjohnwu.magisk.databinding.FragmentModuleMd2Binding import com.topjohnwu.magisk.di.viewModel import rikka.recyclerview.addEdgeSpacing @@ -11,7 +11,7 @@ import rikka.recyclerview.addInvalidateItemDecorationsObserver import rikka.recyclerview.addItemSpacing import rikka.recyclerview.fixEdgeEffect -class ModuleFragment : BaseUIFragment() { +class ModuleFragment : BaseFragment() { override val layoutRes = R.layout.fragment_module_md2 override val viewModel by viewModel() diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.kt index aa7f62ed1..8912f17b3 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.kt @@ -3,14 +3,14 @@ package com.topjohnwu.magisk.ui.settings import android.os.Bundle import android.view.View import com.topjohnwu.magisk.R -import com.topjohnwu.magisk.arch.BaseUIFragment +import com.topjohnwu.magisk.arch.BaseFragment import com.topjohnwu.magisk.databinding.FragmentSettingsMd2Binding import com.topjohnwu.magisk.di.viewModel import rikka.recyclerview.addEdgeSpacing import rikka.recyclerview.addItemSpacing import rikka.recyclerview.fixEdgeEffect -class SettingsFragment : BaseUIFragment() { +class SettingsFragment : BaseFragment() { override val layoutRes = R.layout.fragment_settings_md2 override val viewModel by viewModel() diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserFragment.kt index 5ecf595c7..04bb3849a 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserFragment.kt @@ -3,14 +3,14 @@ package com.topjohnwu.magisk.ui.superuser import android.os.Bundle import android.view.View import com.topjohnwu.magisk.R -import com.topjohnwu.magisk.arch.BaseUIFragment +import com.topjohnwu.magisk.arch.BaseFragment import com.topjohnwu.magisk.databinding.FragmentSuperuserMd2Binding import com.topjohnwu.magisk.di.viewModel import rikka.recyclerview.addEdgeSpacing import rikka.recyclerview.addItemSpacing import rikka.recyclerview.fixEdgeEffect -class SuperuserFragment : BaseUIFragment() { +class SuperuserFragment : BaseFragment() { override val layoutRes = R.layout.fragment_superuser_md2 override val viewModel by viewModel() diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestActivity.kt b/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestActivity.kt index dcfb12e35..016c96609 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestActivity.kt @@ -7,20 +7,18 @@ import android.os.Build import android.os.Bundle import android.view.Window import android.view.WindowManager -import androidx.navigation.NavController import com.topjohnwu.magisk.R -import com.topjohnwu.magisk.arch.BaseUIActivity +import com.topjohnwu.magisk.arch.UIActivity import com.topjohnwu.magisk.core.su.SuCallbackHandler import com.topjohnwu.magisk.core.su.SuCallbackHandler.REQUEST import com.topjohnwu.magisk.databinding.ActivityRequestBinding import com.topjohnwu.magisk.di.viewModel import com.topjohnwu.magisk.ui.theme.Theme -open class SuRequestActivity : BaseUIActivity() { +open class SuRequestActivity : UIActivity() { override val layoutRes: Int = R.layout.activity_request override val viewModel: SuRequestViewModel by viewModel() - override val navigation: NavController? = null override fun onBackPressed() { viewModel.denyPressed() diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/theme/ThemeFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/theme/ThemeFragment.kt index af57c2dec..802035b44 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/theme/ThemeFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/theme/ThemeFragment.kt @@ -8,12 +8,12 @@ import android.view.ViewGroup import android.widget.FrameLayout import com.topjohnwu.magisk.BR import com.topjohnwu.magisk.R -import com.topjohnwu.magisk.arch.BaseUIFragment +import com.topjohnwu.magisk.arch.BaseFragment import com.topjohnwu.magisk.databinding.FragmentThemeMd2Binding import com.topjohnwu.magisk.databinding.ItemThemeBindingImpl import com.topjohnwu.magisk.di.viewModel -class ThemeFragment : BaseUIFragment() { +class ThemeFragment : BaseFragment() { override val layoutRes = R.layout.fragment_theme_md2 override val viewModel by viewModel()