Several home screen changes

This commit is contained in:
topjohnwu 2020-08-09 02:32:13 -07:00
parent 1276c28e03
commit da2b00de59
9 changed files with 57 additions and 37 deletions

View File

@ -31,11 +31,6 @@ sealed class TappableHeadlineItem : ComparableRvItem<TappableHeadlineItem>() {
override val icon = R.drawable.ic_hide_md2
}
object Safetynet : TappableHeadlineItem() {
override val title = R.string.safetynet
override val icon = R.drawable.ic_safetynet_md2
}
object ThemeMode : TappableHeadlineItem() {
override val title = R.string.settings_dark_mode_title
override val icon = R.drawable.ic_day_night

View File

@ -134,6 +134,9 @@ class HomeViewModel(
HomeFragmentDirections.actionHomeFragmentToInstallFragment().publish()
}
fun onSafetyNetPressed() =
HomeFragmentDirections.actionHomeFragmentToSafetynetFragment().publish()
fun hideNotice() {
Config.safetyNotice = false
isNoticeVisible = false

View File

@ -42,7 +42,6 @@ class SuperuserViewModel(
val adapter = adapterOf<ComparableRvItem<*>>()
val items = MergeObservableList<ComparableRvItem<*>>()
.insertItem(TappableHeadlineItem.Hide)
.insertItem(TappableHeadlineItem.Safetynet)
.insertList(itemsHelpers)
.insertList(itemsPolicies)
val itemBinding = itemBindingOf<ComparableRvItem<*>> {
@ -75,13 +74,9 @@ class SuperuserViewModel(
@Suppress("REDUNDANT_ELSE_IN_WHEN")
override fun onItemPressed(item: TappableHeadlineItem) = when (item) {
TappableHeadlineItem.Hide -> hidePressed()
TappableHeadlineItem.Safetynet -> safetynetPressed()
else -> Unit
}
private fun safetynetPressed() =
SuperuserFragmentDirections.actionSuperuserFragmentToSafetynetFragment().publish()
private fun hidePressed() =
SuperuserFragmentDirections.actionSuperuserFragmentToHideFragment().publish()

View File

@ -5,6 +5,10 @@
<data>
<import type="com.topjohnwu.magisk.core.Info" />
<import type="com.topjohnwu.magisk.ui.home.MagiskState" />
<variable
name="viewModel"
type="com.topjohnwu.magisk.ui.home.HomeViewModel" />
@ -99,6 +103,35 @@
android:layout_marginTop="@dimen/l1"
app:layout_constraintTop_toBottomOf="@+id/home_magisk_wrapper" />
<com.google.android.material.button.MaterialButton
style="@style/WidgetFoundation.Button.Outlined"
android:layout_marginStart="@dimen/l1"
android:layout_marginEnd="@dimen/l1"
android:layout_marginTop="@dimen/l1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/home_check_safetynet"
android:textAllCaps="false"
android:textSize="12sp"
android:onClick="@{() -> viewModel.onSafetyNetPressed()}"
app:cornerRadius="@dimen/r1"
app:icon="@drawable/ic_safetynet_md2" />
<com.google.android.material.button.MaterialButton
style="@style/WidgetFoundation.Button.Outlined.Error"
android:layout_marginStart="@dimen/l1"
android:layout_marginEnd="@dimen/l1"
android:layout_marginTop="@dimen/l_125"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/uninstall_magisk_title"
android:textAllCaps="false"
android:textSize="12sp"
android:onClick="@{() -> viewModel.onDeletePressed()}"
gone="@{Info.env.magiskVersionCode &lt; 0 || viewModel.stateMagisk == MagiskState.LOADING || !viewModel.isConnected}"
app:cornerRadius="@dimen/r1"
app:icon="@drawable/ic_delete_md2" />
<com.google.android.material.card.MaterialCardView
style="@style/WidgetFoundation.Card"
android:layout_width="match_parent"

View File

@ -7,8 +7,6 @@
<import type="com.topjohnwu.magisk.core.Info" />
<import type="com.topjohnwu.magisk.core.InfoKt" />
<import type="com.topjohnwu.magisk.ui.home.MagiskState" />
<variable
@ -48,22 +46,10 @@
android:textAppearance="@style/AppearanceFoundation.Title"
android:textColor="?colorPrimary"
app:layout_constraintBottom_toBottomOf="@+id/home_magisk_icon"
app:layout_constraintEnd_toStartOf="@+id/home_magisk_uninstall"
app:layout_constraintEnd_toStartOf="@+id/home_magisk_action"
app:layout_constraintStart_toEndOf="@+id/home_magisk_icon"
app:layout_constraintTop_toTopOf="@+id/home_magisk_icon" />
<ImageView
android:id="@+id/home_magisk_uninstall"
style="@style/WidgetFoundation.Icon.Error"
android:background="?attr/selectableItemBackground"
android:clickable="true"
gone="@{Info.env.magiskVersionCode &lt; 0 || viewModel.stateMagisk == MagiskState.LOADING || !viewModel.isConnected}"
android:onClick="@{() -> viewModel.onDeletePressed()}"
app:layout_constraintBottom_toBottomOf="@+id/home_magisk_title"
app:layout_constraintEnd_toStartOf="@+id/home_magisk_action"
app:layout_constraintTop_toTopOf="@+id/home_magisk_title"
app:srcCompat="@drawable/ic_delete_md2" />
<FrameLayout
android:id="@+id/home_magisk_action"
invisible="@{viewModel.stateMagisk == MagiskState.LOADING || !viewModel.isConnected}"

View File

@ -48,7 +48,7 @@
app:layout_constraintEnd_toStartOf="@+id/headline_icon_pointer"
app:layout_constraintStart_toEndOf="@+id/tappable_icon"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/magisk_hide_md2" />
tools:text="@string/magiskhide" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/headline_icon_pointer"

View File

@ -33,6 +33,14 @@
app:popEnterAnim="@anim/fragment_enter_pop"
app:popExitAnim="@anim/fragment_exit_pop" />
<action
android:id="@+id/action_homeFragment_to_safetynetFragment"
app:destination="@id/safetynetFragment"
app:enterAnim="@anim/fragment_enter"
app:exitAnim="@anim/fragment_exit"
app:popEnterAnim="@anim/fragment_enter_pop"
app:popExitAnim="@anim/fragment_exit_pop" />
</fragment>
<fragment
@ -108,14 +116,6 @@
android:label="SuperuserFragment"
tools:layout="@layout/fragment_superuser_md2">
<action
android:id="@+id/action_superuserFragment_to_safetynetFragment"
app:destination="@id/safetynetFragment"
app:enterAnim="@anim/fragment_enter"
app:exitAnim="@anim/fragment_exit"
app:popEnterAnim="@anim/fragment_enter_pop"
app:popExitAnim="@anim/fragment_exit_pop" />
<action
android:id="@+id/action_superuserFragment_to_hideFragment"
app:destination="@id/hideFragment"

View File

@ -43,6 +43,7 @@
<string name="invalid_update_channel">Invalid Update Channel</string>
<string name="uninstall_magisk_title">Uninstall Magisk</string>
<string name="uninstall_magisk_msg">All modules will be disabled/removed!\nRoot will be removed!\nYour data potentially encrypted if not already!</string>
<string name="home_check_safetynet">Check SafetyNet</string>
<!--Install-->
<string name="keep_force_encryption">Preserve force encryption</string>

View File

@ -87,6 +87,13 @@
<item name="iconTint">?colorOnPrimary</item>
</style>
<style name="WidgetFoundation.Button.Outlined.Error">
<item name="strokeColor">@color/color_error_transient</item>
<item name="rippleColor">@color/color_error_transient</item>
<item name="android:textColor">@color/color_error_transient</item>
<item name="iconTint">@color/color_error_transient</item>
</style>
<style name="WidgetFoundation.Button.Flat" parent="Widget.MaterialComponents.Button.UnelevatedButton">
<item name="android:textStyle">bold</item>
<item name="iconGravity">textStart</item>