Added safe mode notice to modules screen

This commit is contained in:
Viktor De Pasquale 2019-10-30 17:54:43 +01:00
parent 588e94c11d
commit 86551909fc
4 changed files with 63 additions and 4 deletions

View File

@ -1,5 +1,6 @@
package com.topjohnwu.magisk.redesign.module
import android.graphics.Insets
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.databinding.FragmentModuleMd2Binding
import com.topjohnwu.magisk.redesign.compat.CompatFragment
@ -10,6 +11,8 @@ class ModuleFragment : CompatFragment<ModuleViewModel, FragmentModuleMd2Binding>
override val layoutRes = R.layout.fragment_module_md2
override val viewModel by viewModel<ModuleViewModel>()
override fun consumeSystemWindowInsets(insets: Insets) = insets
override fun onStart() {
super.onStart()

View File

@ -1,5 +1,16 @@
package com.topjohnwu.magisk.redesign.module
import com.topjohnwu.magisk.BR
import com.topjohnwu.magisk.model.entity.recycler.ModuleRvItem
import com.topjohnwu.magisk.redesign.compat.CompatViewModel
import com.topjohnwu.magisk.redesign.home.itemBindingOf
import com.topjohnwu.magisk.redesign.superuser.diffListOf
class ModuleViewModel : CompatViewModel()
class ModuleViewModel : CompatViewModel() {
val items = diffListOf<ModuleRvItem>()
val itemBinding = itemBindingOf<ModuleRvItem> {
it.bindExtra(BR.viewModel, this)
}
}

View File

@ -1,8 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<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>
<import type="com.topjohnwu.magisk.Config" />
<variable
name="viewModel"
type="com.topjohnwu.magisk.redesign.module.ModuleViewModel" />
@ -11,12 +15,51 @@
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:clipToPadding="false"
android:layout_height="match_parent"
android:fillViewport="true">
android:fillViewport="true"
android:paddingTop="@{viewModel.insets.top + (int) @dimen/internal_action_bar_size}"
android:paddingBottom="@{viewModel.insets.bottom + (int) @dimen/l2}"
tools:paddingTop="24dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content">
<com.google.android.material.card.MaterialCardView
android:id="@+id/module_notice"
style="?styleCardNormal"
gone="@{!Config.coreOnly}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/l1"
android:visibility="gone"
app:cardBackgroundColor="?colorError"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="@dimen/l1"
android:text="@string/module_safe_mode_message"
android:textAppearance="?appearanceTextCaptionOnPrimary"
android:textStyle="bold" />
</com.google.android.material.card.MaterialCardView>
<androidx.recyclerview.widget.RecyclerView
itemBinding="@{viewModel.itemBinding}"
items="@{viewModel.items}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/l1"
android:orientation="vertical"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintTop_toBottomOf="@+id/module_notice" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>

View File

@ -68,4 +68,6 @@
<string name="install_next">Next</string>
<string name="install_start">Let\'s go</string>
<string name="module_safe_mode_message">You\'re in safe mode. None of user modules will work.\nThis message will disappear once safe mode is disabled.</string>
</resources>