Move denylist fragment to its own section

This commit is contained in:
topjohnwu 2021-09-12 00:39:24 -07:00
parent 136d8c39d9
commit fc6b02f607
5 changed files with 18 additions and 31 deletions

View File

@ -11,7 +11,6 @@ import android.view.View
import android.view.WindowManager import android.view.WindowManager
import androidx.core.content.pm.ShortcutManagerCompat import androidx.core.content.pm.ShortcutManagerCompat
import androidx.core.view.forEach import androidx.core.view.forEach
import androidx.core.view.isGone
import androidx.interpolator.view.animation.FastOutLinearInInterpolator import androidx.interpolator.view.animation.FastOutLinearInInterpolator
import androidx.interpolator.view.animation.LinearOutSlowInInterpolator import androidx.interpolator.view.animation.LinearOutSlowInInterpolator
import androidx.navigation.NavDirections import androidx.navigation.NavDirections
@ -61,6 +60,7 @@ open class MainActivity : BaseUIActivity<MainViewModel, ActivityMainMd2Binding>(
R.id.homeFragment, R.id.homeFragment,
R.id.modulesFragment, R.id.modulesFragment,
R.id.superuserFragment, R.id.superuserFragment,
R.id.hideFragment,
R.id.logFragment -> true R.id.logFragment -> true
else -> false else -> false
} }
@ -77,11 +77,11 @@ open class MainActivity : BaseUIActivity<MainViewModel, ActivityMainMd2Binding>(
setSupportActionBar(binding.mainToolbar) setSupportActionBar(binding.mainToolbar)
binding.mainNavigation.setOnNavigationItemSelectedListener { binding.mainNavigation.setOnItemSelectedListener {
getScreen(it.itemId)?.navigate() getScreen(it.itemId)?.navigate()
true true
} }
binding.mainNavigation.setOnNavigationItemReselectedListener { binding.mainNavigation.setOnItemReselectedListener {
(currentFragment as? ReselectionTarget)?.onReselected() (currentFragment as? ReselectionTarget)?.onReselected()
} }
@ -183,6 +183,7 @@ open class MainActivity : BaseUIActivity<MainViewModel, ActivityMainMd2Binding>(
R.id.modulesFragment -> MainDirections.actionModuleFragment() R.id.modulesFragment -> MainDirections.actionModuleFragment()
R.id.superuserFragment -> MainDirections.actionSuperuserFragment() R.id.superuserFragment -> MainDirections.actionSuperuserFragment()
R.id.logFragment -> MainDirections.actionLogFragment() R.id.logFragment -> MainDirections.actionLogFragment()
R.id.hideFragment -> MainDirections.actionHideFragment()
else -> null else -> null
} }
} }

View File

@ -5,7 +5,6 @@ import androidx.lifecycle.viewModelScope
import com.topjohnwu.magisk.BR import com.topjohnwu.magisk.BR
import com.topjohnwu.magisk.R import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.arch.BaseViewModel import com.topjohnwu.magisk.arch.BaseViewModel
import com.topjohnwu.magisk.core.Config
import com.topjohnwu.magisk.core.magiskdb.PolicyDao import com.topjohnwu.magisk.core.magiskdb.PolicyDao
import com.topjohnwu.magisk.core.model.su.SuPolicy import com.topjohnwu.magisk.core.model.su.SuPolicy
import com.topjohnwu.magisk.core.utils.BiometricHelper import com.topjohnwu.magisk.core.utils.BiometricHelper
@ -19,7 +18,6 @@ import com.topjohnwu.magisk.events.dialog.BiometricEvent
import com.topjohnwu.magisk.events.dialog.SuperuserRevokeDialog import com.topjohnwu.magisk.events.dialog.SuperuserRevokeDialog
import com.topjohnwu.magisk.utils.Utils import com.topjohnwu.magisk.utils.Utils
import com.topjohnwu.magisk.utils.asText import com.topjohnwu.magisk.utils.asText
import com.topjohnwu.magisk.view.TappableHeadlineItem
import com.topjohnwu.magisk.view.TextItem import com.topjohnwu.magisk.view.TextItem
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -28,7 +26,7 @@ import me.tatarka.bindingcollectionadapter2.collections.MergeObservableList
class SuperuserViewModel( class SuperuserViewModel(
private val db: PolicyDao private val db: PolicyDao
) : BaseViewModel(), TappableHeadlineItem.Listener { ) : BaseViewModel() {
private val itemNoData = TextItem(R.string.superuser_policy_none) private val itemNoData = TextItem(R.string.superuser_policy_none)
@ -36,10 +34,8 @@ class SuperuserViewModel(
private val itemsHelpers = ObservableArrayList<TextItem>() private val itemsHelpers = ObservableArrayList<TextItem>()
val adapter = adapterOf<AnyDiffRvItem>() val adapter = adapterOf<AnyDiffRvItem>()
val items = MergeObservableList<AnyDiffRvItem>().apply { val items = MergeObservableList<AnyDiffRvItem>()
if (Config.magiskHide) .insertList(itemsHelpers)
insertItem(TappableHeadlineItem.Hide)
}.insertList(itemsHelpers)
.insertList(itemsPolicies) .insertList(itemsPolicies)
val itemBinding = itemBindingOf<AnyDiffRvItem> { val itemBinding = itemBindingOf<AnyDiffRvItem> {
it.bindExtra(BR.listener, this) it.bindExtra(BR.listener, this)
@ -73,14 +69,6 @@ class SuperuserViewModel(
// --- // ---
override fun onItemPressed(item: TappableHeadlineItem) = when (item) {
TappableHeadlineItem.Hide -> hidePressed()
else -> Unit
}
private fun hidePressed() =
SuperuserFragmentDirections.actionSuperuserFragmentToHideFragment().navigate()
fun deletePressed(item: PolicyRvItem) { fun deletePressed(item: PolicyRvItem) {
fun updateState() = viewModelScope.launch { fun updateState() = viewModelScope.launch {
db.delete(item.item.uid) db.delete(item.item.uid)

View File

@ -38,7 +38,7 @@
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:layout_marginStart="@dimen/l1" android:layout_marginStart="@dimen/l1"
android:layout_marginEnd="@dimen/l1" android:layout_marginEnd="@dimen/l1"
android:layout_marginBottom="@dimen/l1" android:layout_marginBottom="72dp"
app:backgroundTint="?colorSurfaceSurfaceVariant" app:backgroundTint="?colorSurfaceSurfaceVariant"
app:layout_fitsSystemWindowsInsets="bottom" app:layout_fitsSystemWindowsInsets="bottom"
app:srcCompat="@drawable/ic_search_md2" app:srcCompat="@drawable/ic_search_md2"
@ -52,6 +52,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:visibility="invisible" android:visibility="invisible"
app:layout_fitsSystemWindowsInsets="bottom"
app:cardCornerRadius="0dp"> app:cardCornerRadius="0dp">
<include <include

View File

@ -14,6 +14,12 @@
android:title="@string/superuser" android:title="@string/superuser"
tools:showAsAction="always" /> tools:showAsAction="always" />
<item
android:id="@+id/hideFragment"
android:icon="@drawable/ic_hide_md2"
android:title="@string/magiskhide"
tools:showAsAction="always" />
<item <item
android:id="@+id/logFragment" android:id="@+id/logFragment"
android:icon="@drawable/ic_bug_md2" android:icon="@drawable/ic_bug_md2"

View File

@ -110,17 +110,7 @@
android:id="@+id/superuserFragment" android:id="@+id/superuserFragment"
android:name="com.topjohnwu.magisk.ui.superuser.SuperuserFragment" android:name="com.topjohnwu.magisk.ui.superuser.SuperuserFragment"
android:label="SuperuserFragment" android:label="SuperuserFragment"
tools:layout="@layout/fragment_superuser_md2"> tools:layout="@layout/fragment_superuser_md2" />
<action
android:id="@+id/action_superuserFragment_to_hideFragment"
app:destination="@id/hideFragment"
app:enterAnim="@anim/fragment_enter"
app:exitAnim="@anim/fragment_exit"
app:popEnterAnim="@anim/fragment_enter_pop"
app:popExitAnim="@anim/fragment_exit_pop" />
</fragment>
<fragment <fragment
android:id="@+id/themeFragment" android:id="@+id/themeFragment"
@ -180,6 +170,7 @@
app:enterAnim="@anim/fragment_enter" app:enterAnim="@anim/fragment_enter"
app:exitAnim="@anim/fragment_exit" app:exitAnim="@anim/fragment_exit"
app:popEnterAnim="@anim/fragment_enter_pop" app:popEnterAnim="@anim/fragment_enter_pop"
app:popExitAnim="@anim/fragment_exit_pop" /> app:popExitAnim="@anim/fragment_exit_pop"
app:popUpTo="@id/homeFragment"/>
</navigation> </navigation>