From 588e94c11d4aa8461b25ebd31854973c2e3191f6 Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Wed, 30 Oct 2019 17:11:42 +0100 Subject: [PATCH] Updated locations of certain elements Settings are now only on home screen as it directly relates to what user might want to do. It is highly unlikely that they would jump from any other screen to settings. Log is no longer main destination as it's not used very widely; it's been moved to Superuser screen. This screen now encapsulates all root-related stuff. Home screen is now strictly info-based, except install buttons, of course. --- .../topjohnwu/magisk/redesign/MainActivity.kt | 11 ++--------- .../magisk/redesign/compat/CompatFragment.kt | 2 ++ .../magisk/redesign/home/HomeFragment.kt | 14 ++++++++++++++ .../redesign/superuser/SuperuserFragment.kt | 15 ++++++++++++++- app/src/main/res/layout/activity_main_md2.xml | 2 +- app/src/main/res/menu/menu_bottom_nav.xml | 18 +++--------------- app/src/main/res/menu/menu_home_md2.xml | 11 +++++++++++ app/src/main/res/menu/menu_superuser_md2.xml | 11 +++++++++++ 8 files changed, 58 insertions(+), 26 deletions(-) create mode 100644 app/src/main/res/menu/menu_home_md2.xml create mode 100644 app/src/main/res/menu/menu_superuser_md2.xml diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt index 6563bb886..75571b3e6 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt @@ -21,9 +21,7 @@ import com.topjohnwu.magisk.model.navigation.Navigation import com.topjohnwu.magisk.redesign.compat.CompatActivity import com.topjohnwu.magisk.redesign.compat.CompatNavigationDelegate import com.topjohnwu.magisk.redesign.home.HomeFragment -import com.topjohnwu.magisk.redesign.log.LogFragment import com.topjohnwu.magisk.redesign.module.ModuleFragment -import com.topjohnwu.magisk.redesign.settings.SettingsFragment import com.topjohnwu.magisk.redesign.superuser.SuperuserFragment import com.topjohnwu.magisk.utils.HideBottomViewOnScrollBehavior import com.topjohnwu.magisk.utils.HideTopViewOnScrollBehavior @@ -43,9 +41,7 @@ open class MainActivity : CompatActivity( override val baseFragments: List> = listOf( HomeFragment::class, ModuleFragment::class, - SuperuserFragment::class, - LogFragment::class, - SettingsFragment::class + SuperuserFragment::class ) //This temporarily fixes unwanted feature of BottomNavigationView - where the view applies @@ -72,8 +68,6 @@ open class MainActivity : CompatActivity( R.id.homeFragment -> Navigation.home() R.id.modulesFragment -> Navigation.modules() R.id.superuserFragment -> Navigation.superuser() - R.id.logFragment -> Navigation.log() - R.id.settingsFragment -> Navigation.settings() else -> throw NotImplementedError("Id ${it.itemId} is not defined as selectable") }.dispatchOnSelf() true @@ -82,7 +76,7 @@ open class MainActivity : CompatActivity( binding.mainNavigation.viewTreeObserver.addOnGlobalLayoutListener(navObserver) if (intent.getBooleanExtra(Const.Key.OPEN_SETTINGS, false)) { - binding.mainNavigation.selectedItemId = R.id.settingsFragment + Navigation.settings().dispatchOnSelf() } if (savedInstanceState != null) { @@ -97,7 +91,6 @@ open class MainActivity : CompatActivity( val isRoot = Shell.rootAccess() findItem(R.id.modulesFragment)?.isEnabled = isRoot findItem(R.id.superuserFragment)?.isEnabled = isRoot - findItem(R.id.logFragment)?.isEnabled = isRoot } } diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatFragment.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatFragment.kt index b25d324d5..a773770c1 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatFragment.kt @@ -42,4 +42,6 @@ abstract class CompatFragment() { override fun onStart() { super.onStart() activity.title = resources.getString(R.string.section_home) + setHasOptionsMenu(true) } + override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { + inflater.inflate(R.menu.menu_home_md2, menu) + } + + override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) { + R.id.action_settings -> Navigation.settings().dispatchOnSelf() + else -> null + }?.let { true } ?: super.onOptionsItemSelected(item) + } \ No newline at end of file diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/superuser/SuperuserFragment.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/superuser/SuperuserFragment.kt index 1e3d3a772..8575aa357 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/superuser/SuperuserFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/superuser/SuperuserFragment.kt @@ -1,8 +1,12 @@ package com.topjohnwu.magisk.redesign.superuser import android.graphics.Insets +import android.view.Menu +import android.view.MenuInflater +import android.view.MenuItem import com.topjohnwu.magisk.R import com.topjohnwu.magisk.databinding.FragmentSuperuserMd2Binding +import com.topjohnwu.magisk.model.navigation.Navigation import com.topjohnwu.magisk.redesign.compat.CompatFragment import org.koin.androidx.viewmodel.ext.android.viewModel @@ -15,8 +19,17 @@ class SuperuserFragment : CompatFragment Navigation.log().dispatchOnSelf() + else -> null + }?.let { true } ?: super.onOptionsItemSelected(item) + } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main_md2.xml b/app/src/main/res/layout/activity_main_md2.xml index d5593e444..703ca8054 100644 --- a/app/src/main/res/layout/activity_main_md2.xml +++ b/app/src/main/res/layout/activity_main_md2.xml @@ -47,7 +47,7 @@ style="?styleCardElevated" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_gravity="bottom" + android:layout_gravity="bottom|center_horizontal" android:layout_marginStart="@dimen/l1" android:layout_marginEnd="@dimen/l1" android:layout_marginBottom="@{(int) @dimen/l1 + viewModel.insets.bottom}" diff --git a/app/src/main/res/menu/menu_bottom_nav.xml b/app/src/main/res/menu/menu_bottom_nav.xml index 31c468243..dd797ea46 100644 --- a/app/src/main/res/menu/menu_bottom_nav.xml +++ b/app/src/main/res/menu/menu_bottom_nav.xml @@ -8,12 +8,6 @@ android:title="@string/section_home" tools:showAsAction="always" /> - - - - \ No newline at end of file diff --git a/app/src/main/res/menu/menu_home_md2.xml b/app/src/main/res/menu/menu_home_md2.xml new file mode 100644 index 000000000..0825147da --- /dev/null +++ b/app/src/main/res/menu/menu_home_md2.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/menu_superuser_md2.xml b/app/src/main/res/menu/menu_superuser_md2.xml new file mode 100644 index 000000000..c5e26ffd2 --- /dev/null +++ b/app/src/main/res/menu/menu_superuser_md2.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file