Added safety notice and support section description

This commit is contained in:
Viktor De Pasquale 2019-11-01 19:02:30 +01:00
parent 6720725d27
commit 7d5555f82e
5 changed files with 79 additions and 19 deletions

View File

@ -52,6 +52,7 @@ object Config : PreferenceModel, DBConfig {
const val SHOW_SYSTEM_APP = "show_system" const val SHOW_SYSTEM_APP = "show_system"
const val DOWNLOAD_PATH = "download_path" const val DOWNLOAD_PATH = "download_path"
const val REDESIGN = "redesign" const val REDESIGN = "redesign"
const val SAFETY = "safety_notice"
// system state // system state
const val MAGISKHIDE = "magiskhide" const val MAGISKHIDE = "magiskhide"
@ -117,6 +118,7 @@ object Config : PreferenceModel, DBConfig {
var suNotification by preferenceStrInt(Key.SU_NOTIFICATION, Value.NOTIFICATION_TOAST) var suNotification by preferenceStrInt(Key.SU_NOTIFICATION, Value.NOTIFICATION_TOAST)
var updateChannel by preferenceStrInt(Key.UPDATE_CHANNEL, defaultChannel) var updateChannel by preferenceStrInt(Key.UPDATE_CHANNEL, defaultChannel)
var safetyNotice by preference(Key.SAFETY, true)
var redesign by preference(Key.REDESIGN, false) var redesign by preference(Key.REDESIGN, false)
@Deprecated("Use extended dark theme") @Deprecated("Use extended dark theme")
var darkTheme by preference(Key.DARK_THEME, true) var darkTheme by preference(Key.DARK_THEME, true)

View File

@ -2,6 +2,7 @@ package com.topjohnwu.magisk.redesign.home
import android.Manifest import android.Manifest
import com.topjohnwu.magisk.BuildConfig import com.topjohnwu.magisk.BuildConfig
import com.topjohnwu.magisk.Config
import com.topjohnwu.magisk.Info import com.topjohnwu.magisk.Info
import com.topjohnwu.magisk.R import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.data.repository.MagiskRepository import com.topjohnwu.magisk.data.repository.MagiskRepository
@ -34,6 +35,8 @@ class HomeViewModel(
private val repoMagisk: MagiskRepository private val repoMagisk: MagiskRepository
) : CompatViewModel() { ) : CompatViewModel() {
val isNoticeVisible = KObservableField(Config.safetyNotice)
val stateMagisk = KObservableField(MagiskState.LOADING) val stateMagisk = KObservableField(MagiskState.LOADING)
val stateManager = KObservableField(MagiskState.LOADING) val stateManager = KObservableField(MagiskState.LOADING)
val stateTextMagisk = Observer(stateMagisk) { val stateTextMagisk = Observer(stateMagisk) {
@ -143,6 +146,11 @@ class HomeViewModel(
fun toggle(kof: KObservableField<Boolean>) = kof.toggle() fun toggle(kof: KObservableField<Boolean>) = kof.toggle()
fun hideNotice() {
Config.safetyNotice = false
isNoticeVisible.value = false
}
private fun ensureEnv() { private fun ensureEnv() {
val invalidStates = listOf( val invalidStates = listOf(
MagiskState.NOT_INSTALLED, MagiskState.NOT_INSTALLED,

View File

@ -44,6 +44,46 @@
android:orientation="vertical" android:orientation="vertical"
android:paddingTop="@dimen/l1"> android:paddingTop="@dimen/l1">
<com.google.android.material.card.MaterialCardView
style="?styleCardOnPrimary"
goneUnless="@{viewModel.noticeVisible}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/l1"
android:layout_marginEnd="@dimen/l1"
android:layout_marginBottom="@dimen/l1">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/home_notice_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="@dimen/l1"
android:text="@string/home_notice_content"
android:textAppearance="?appearanceTextCaptionOnPrimary"
app:layout_constraintEnd_toStartOf="@+id/home_notice_hide"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.button.MaterialButton
android:id="@+id/home_notice_hide"
style="?styleButtonTextOnPrimary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="@{() -> viewModel.hideNotice()}"
android:text="@string/home_notice_hide"
android:textAllCaps="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -703,35 +743,40 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<include <androidx.appcompat.widget.AppCompatTextView
item="@{viewModel.items[0]}"
layout="@layout/item_developer"
viewModel="@{viewModel}"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/l1" android:layout_marginStart="@dimen/l1"
android:layout_marginTop="@dimen/l1" android:layout_marginTop="@dimen/l2"
android:layout_marginEnd="@dimen/l1" /> android:layout_marginEnd="@dimen/l1"
android:text="@string/home_support_title"
android:textAppearance="?appearanceTextTitleNormal" />
<include <androidx.appcompat.widget.AppCompatTextView
item="@{viewModel.items[1]}"
layout="@layout/item_developer"
viewModel="@{viewModel}"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/l1" android:layout_marginStart="@dimen/l1"
android:layout_marginTop="@dimen/l1" android:layout_marginTop="@dimen/l_50"
android:layout_marginEnd="@dimen/l1" /> android:layout_marginEnd="@dimen/l1"
android:text="@string/home_support_content"
android:textAppearance="?appearanceTextCaptionVariant" />
<include <androidx.recyclerview.widget.RecyclerView
item="@{viewModel.items[2]}" dividerHorizontal="@{R.drawable.divider_l1}"
layout="@layout/item_developer" dividerVertical="@{R.drawable.divider_l1}"
viewModel="@{viewModel}" itemBinding="@{viewModel.itemDeveloperBinding}"
items="@{viewModel.items}"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/l1"
android:layout_marginTop="@dimen/l1" android:layout_marginTop="@dimen/l1"
android:layout_marginEnd="@dimen/l1" /> android:clipToPadding="false"
android:orientation="horizontal"
android:overScrollMode="ifContentScrolls"
android:paddingStart="@dimen/l1"
app:layoutManager="androidx.recyclerview.widget.StaggeredGridLayoutManager"
app:spanCount="2"
tools:itemCount="3"
tools:listitem="@layout/item_developer" />
</LinearLayout> </LinearLayout>

View File

@ -24,6 +24,7 @@
android:id="@+id/developer_icon" android:id="@+id/developer_icon"
style="?styleIconNormal" style="?styleIconNormal"
android:padding="@dimen/l_50" android:padding="@dimen/l_50"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:srcCompat="@{item.icon}" app:srcCompat="@{item.icon}"
@ -34,7 +35,6 @@
style="?styleCardNormal" style="?styleCardNormal"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/l1"
app:layout_constrainedWidth="true" app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"

View File

@ -30,6 +30,11 @@
<string name="home_item_source">Source</string> <string name="home_item_source">Source</string>
<string name="home_item_xda">XDA</string> <string name="home_item_xda">XDA</string>
<string name="home_notice_content">Always make sure you\'re using open-source Magisk Manager. Manager of unknown source can perform malicious actions.</string>
<string name="home_notice_hide">Hide</string>
<string name="home_support_title">Support Us</string>
<string name="home_support_content">Magisk is, and always will be, free and open-source. You can however show us that you care by sending a small donation.</string>
<string name="home_device_security">Security</string> <string name="home_device_security">Security</string>
<string name="home_device_system">System</string> <string name="home_device_system">System</string>
<string name="home_device_build_style">A/B</string> <string name="home_device_build_style">A/B</string>