mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-27 20:15:29 +00:00
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.
This commit is contained in:
parent
9e66310c28
commit
588e94c11d
@ -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<MainViewModel, ActivityMainMd2Binding>(
|
||||
override val baseFragments: List<KClass<out Fragment>> = 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<MainViewModel, ActivityMainMd2Binding>(
|
||||
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<MainViewModel, ActivityMainMd2Binding>(
|
||||
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<MainViewModel, ActivityMainMd2Binding>(
|
||||
val isRoot = Shell.rootAccess()
|
||||
findItem(R.id.modulesFragment)?.isEnabled = isRoot
|
||||
findItem(R.id.superuserFragment)?.isEnabled = isRoot
|
||||
findItem(R.id.logFragment)?.isEnabled = isRoot
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,4 +42,6 @@ abstract class CompatFragment<ViewModel : CompatViewModel, Binding : ViewDataBin
|
||||
delegate.onEventExecute(event, this)
|
||||
}
|
||||
|
||||
protected fun ViewEvent.dispatchOnSelf() = delegate.onEventExecute(this, this@CompatFragment)
|
||||
|
||||
}
|
@ -1,8 +1,12 @@
|
||||
package com.topjohnwu.magisk.redesign.home
|
||||
|
||||
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.FragmentHomeMd2Binding
|
||||
import com.topjohnwu.magisk.model.navigation.Navigation
|
||||
import com.topjohnwu.magisk.redesign.compat.CompatFragment
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
|
||||
@ -16,6 +20,16 @@ class HomeFragment : CompatFragment<HomeViewModel, FragmentHomeMd2Binding>() {
|
||||
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)
|
||||
|
||||
}
|
@ -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<SuperuserViewModel, FragmentSuperuserMd
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
|
||||
activity.title = resources.getString(R.string.section_superuser)
|
||||
setHasOptionsMenu(true)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
inflater.inflate(R.menu.menu_superuser_md2, menu)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
|
||||
R.id.action_log -> Navigation.log().dispatchOnSelf()
|
||||
else -> null
|
||||
}?.let { true } ?: super.onOptionsItemSelected(item)
|
||||
|
||||
}
|
@ -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}"
|
||||
|
@ -8,12 +8,6 @@
|
||||
android:title="@string/section_home"
|
||||
tools:showAsAction="always" />
|
||||
|
||||
<item
|
||||
android:id="@+id/modulesFragment"
|
||||
android:icon="@drawable/ic_module_md2"
|
||||
android:title="@string/section_modules"
|
||||
tools:showAsAction="always" />
|
||||
|
||||
<item
|
||||
android:id="@+id/superuserFragment"
|
||||
android:icon="@drawable/ic_superuser_md2"
|
||||
@ -21,15 +15,9 @@
|
||||
tools:showAsAction="always" />
|
||||
|
||||
<item
|
||||
android:id="@+id/logFragment"
|
||||
android:icon="@drawable/ic_bug_md2"
|
||||
android:title="@string/section_log"
|
||||
tools:showAsAction="always" />
|
||||
|
||||
<item
|
||||
android:id="@+id/settingsFragment"
|
||||
android:icon="@drawable/ic_settings_md2"
|
||||
android:title="@string/section_settings"
|
||||
android:id="@+id/modulesFragment"
|
||||
android:icon="@drawable/ic_module_md2"
|
||||
android:title="@string/section_modules"
|
||||
tools:showAsAction="always" />
|
||||
|
||||
</menu>
|
11
app/src/main/res/menu/menu_home_md2.xml
Normal file
11
app/src/main/res/menu/menu_home_md2.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:icon="@drawable/ic_settings_md2"
|
||||
android:title="@string/section_settings"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
</menu>
|
11
app/src/main/res/menu/menu_superuser_md2.xml
Normal file
11
app/src/main/res/menu/menu_superuser_md2.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_log"
|
||||
android:icon="@drawable/ic_bug_md2"
|
||||
android:title="@string/section_log"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
</menu>
|
Loading…
Reference in New Issue
Block a user