Added log as primary fragment
This commit is contained in:
parent
aa72a080b0
commit
edff094626
@ -21,6 +21,7 @@ import com.topjohnwu.magisk.model.navigation.Navigation
|
|||||||
import com.topjohnwu.magisk.ui.base.BaseUIActivity
|
import com.topjohnwu.magisk.ui.base.BaseUIActivity
|
||||||
import com.topjohnwu.magisk.ui.base.CompatNavigationDelegate
|
import com.topjohnwu.magisk.ui.base.CompatNavigationDelegate
|
||||||
import com.topjohnwu.magisk.ui.home.HomeFragment
|
import com.topjohnwu.magisk.ui.home.HomeFragment
|
||||||
|
import com.topjohnwu.magisk.ui.log.LogFragment
|
||||||
import com.topjohnwu.magisk.ui.module.ModuleFragment
|
import com.topjohnwu.magisk.ui.module.ModuleFragment
|
||||||
import com.topjohnwu.magisk.ui.superuser.SuperuserFragment
|
import com.topjohnwu.magisk.ui.superuser.SuperuserFragment
|
||||||
import com.topjohnwu.magisk.utils.HideBottomViewOnScrollBehavior
|
import com.topjohnwu.magisk.utils.HideBottomViewOnScrollBehavior
|
||||||
@ -43,7 +44,8 @@ open class MainActivity : BaseUIActivity<MainViewModel, ActivityMainMd2Binding>(
|
|||||||
override val baseFragments: List<KClass<out Fragment>> = listOf(
|
override val baseFragments: List<KClass<out Fragment>> = listOf(
|
||||||
HomeFragment::class,
|
HomeFragment::class,
|
||||||
ModuleFragment::class,
|
ModuleFragment::class,
|
||||||
SuperuserFragment::class
|
SuperuserFragment::class,
|
||||||
|
LogFragment::class
|
||||||
)
|
)
|
||||||
|
|
||||||
//This temporarily fixes unwanted feature of BottomNavigationView - where the view applies
|
//This temporarily fixes unwanted feature of BottomNavigationView - where the view applies
|
||||||
@ -81,6 +83,7 @@ open class MainActivity : BaseUIActivity<MainViewModel, ActivityMainMd2Binding>(
|
|||||||
R.id.homeFragment -> Navigation.home()
|
R.id.homeFragment -> Navigation.home()
|
||||||
R.id.modulesFragment -> Navigation.modules()
|
R.id.modulesFragment -> Navigation.modules()
|
||||||
R.id.superuserFragment -> Navigation.superuser()
|
R.id.superuserFragment -> Navigation.superuser()
|
||||||
|
R.id.logFragment -> Navigation.log()
|
||||||
else -> throw NotImplementedError("Id ${it.itemId} is not defined as selectable")
|
else -> throw NotImplementedError("Id ${it.itemId} is not defined as selectable")
|
||||||
}.dispatchOnSelf()
|
}.dispatchOnSelf()
|
||||||
true
|
true
|
||||||
|
@ -23,7 +23,7 @@ class LogFragment : BaseUIFragment<LogViewModel, FragmentLogMd2Binding>() {
|
|||||||
get() = binding.logFilter.isVisible
|
get() = binding.logFilter.isVisible
|
||||||
set(value) {
|
set(value) {
|
||||||
MotionRevealHelper.withViews(binding.logFilter, binding.logFilterToggle, value)
|
MotionRevealHelper.withViews(binding.logFilter, binding.logFilterToggle, value)
|
||||||
actionSave?.isVisible = value
|
actionSave?.isVisible = !value
|
||||||
(activity as MainActivity).invalidateToolbar()
|
(activity as MainActivity).invalidateToolbar()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class LogFragment : BaseUIFragment<LogViewModel, FragmentLogMd2Binding>() {
|
|||||||
super.onCreateOptionsMenu(menu, inflater)
|
super.onCreateOptionsMenu(menu, inflater)
|
||||||
inflater.inflate(R.menu.menu_log_md2, menu)
|
inflater.inflate(R.menu.menu_log_md2, menu)
|
||||||
actionSave = menu.findItem(R.id.action_save)?.also {
|
actionSave = menu.findItem(R.id.action_save)?.also {
|
||||||
it.isVisible = isMagiskLogVisible
|
it.isVisible = !isMagiskLogVisible
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ class LogFragment : BaseUIFragment<LogViewModel, FragmentLogMd2Binding>() {
|
|||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.action_save -> viewModel.saveMagiskLog()
|
R.id.action_save -> viewModel.saveMagiskLog()
|
||||||
R.id.action_clear ->
|
R.id.action_clear ->
|
||||||
if (isMagiskLogVisible) viewModel.clearMagiskLog()
|
if (!isMagiskLogVisible) viewModel.clearMagiskLog()
|
||||||
else viewModel.clearLog()
|
else viewModel.clearLog()
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item)
|
return super.onOptionsItemSelected(item)
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
package com.topjohnwu.magisk.ui.superuser
|
package com.topjohnwu.magisk.ui.superuser
|
||||||
|
|
||||||
import android.view.Menu
|
|
||||||
import android.view.MenuInflater
|
|
||||||
import android.view.MenuItem
|
|
||||||
import com.topjohnwu.magisk.R
|
import com.topjohnwu.magisk.R
|
||||||
import com.topjohnwu.magisk.databinding.FragmentSuperuserMd2Binding
|
import com.topjohnwu.magisk.databinding.FragmentSuperuserMd2Binding
|
||||||
import com.topjohnwu.magisk.model.navigation.Navigation
|
|
||||||
import com.topjohnwu.magisk.ui.base.BaseUIFragment
|
import com.topjohnwu.magisk.ui.base.BaseUIFragment
|
||||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
|
|
||||||
@ -17,16 +13,6 @@ class SuperuserFragment : BaseUIFragment<SuperuserViewModel, FragmentSuperuserMd
|
|||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
activity.title = resources.getString(R.string.superuser)
|
activity.title = resources.getString(R.string.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)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,20 +15,12 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<include
|
||||||
itemBinding="@{viewModel.itemBinding}"
|
android:id="@+id/log_filter_magisk"
|
||||||
items="@{viewModel.items}"
|
layout="@layout/include_log_magisk"
|
||||||
|
viewModel="@{viewModel}"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent" />
|
||||||
android:clipToPadding="false"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:paddingStart="@dimen/l1"
|
|
||||||
android:paddingTop="@{viewModel.insets.top + (int) @dimen/internal_action_bar_size}"
|
|
||||||
android:paddingEnd="@dimen/l1"
|
|
||||||
android:paddingBottom="@{viewModel.insets.bottom}"
|
|
||||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
|
||||||
tools:listitem="@layout/item_log_access_md2"
|
|
||||||
tools:paddingTop="24dp" />
|
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
android:id="@+id/log_filter_toggle"
|
android:id="@+id/log_filter_toggle"
|
||||||
@ -53,28 +45,14 @@
|
|||||||
app:cardCornerRadius="0dp">
|
app:cardCornerRadius="0dp">
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/log_filter_include"
|
android:id="@+id/log_filter_superuser"
|
||||||
layout="@layout/include_log_magisk"
|
layout="@layout/include_log_superuser"
|
||||||
viewModel="@{viewModel}"
|
viewModel="@{viewModel}"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
</com.google.android.material.circularreveal.cardview.CircularRevealCardView>
|
</com.google.android.material.circularreveal.cardview.CircularRevealCardView>
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
gone="@{!viewModel.items.empty}"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center">
|
|
||||||
|
|
||||||
<include
|
|
||||||
item="@{viewModel.itemEmpty}"
|
|
||||||
layout="@layout/item_text"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
49
app/src/main/res/layout/include_log_superuser.xml
Normal file
49
app/src/main/res/layout/include_log_superuser.xml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<variable
|
||||||
|
name="viewModel"
|
||||||
|
type="com.topjohnwu.magisk.ui.log.LogViewModel" />
|
||||||
|
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
itemBinding="@{viewModel.itemBinding}"
|
||||||
|
items="@{viewModel.items}"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingStart="@dimen/l1"
|
||||||
|
android:paddingTop="@{viewModel.insets.top + (int) @dimen/internal_action_bar_size}"
|
||||||
|
android:paddingEnd="@dimen/l1"
|
||||||
|
android:paddingBottom="@{viewModel.insets.bottom}"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
|
tools:listitem="@layout/item_log_access_md2"
|
||||||
|
tools:paddingTop="24dp" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
gone="@{!viewModel.items.empty}"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center">
|
||||||
|
|
||||||
|
<include
|
||||||
|
item="@{viewModel.itemEmpty}"
|
||||||
|
layout="@layout/item_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</layout>
|
@ -14,6 +14,12 @@
|
|||||||
android:title="@string/superuser"
|
android:title="@string/superuser"
|
||||||
tools:showAsAction="always" />
|
tools:showAsAction="always" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/logFragment"
|
||||||
|
android:icon="@drawable/ic_bug_md2"
|
||||||
|
android:title="@string/logs"
|
||||||
|
tools:showAsAction="always" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/modulesFragment"
|
android:id="@+id/modulesFragment"
|
||||||
android:icon="@drawable/ic_module_md2"
|
android:icon="@drawable/ic_module_md2"
|
||||||
|
Loading…
Reference in New Issue
Block a user