From 7d5555f82e81c72973ea9ecd3643d41eaa3c4f01 Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Fri, 1 Nov 2019 19:02:30 +0100 Subject: [PATCH] Added safety notice and support section description --- .../main/java/com/topjohnwu/magisk/Config.kt | 2 + .../magisk/redesign/home/HomeViewModel.kt | 8 ++ app/src/main/res/layout/fragment_home_md2.xml | 81 ++++++++++++++----- app/src/main/res/layout/item_developer.xml | 2 +- app/src/main/res/values/strings_md2.xml | 5 ++ 5 files changed, 79 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/Config.kt b/app/src/main/java/com/topjohnwu/magisk/Config.kt index a988c7284..2d159e1e1 100644 --- a/app/src/main/java/com/topjohnwu/magisk/Config.kt +++ b/app/src/main/java/com/topjohnwu/magisk/Config.kt @@ -52,6 +52,7 @@ object Config : PreferenceModel, DBConfig { const val SHOW_SYSTEM_APP = "show_system" const val DOWNLOAD_PATH = "download_path" const val REDESIGN = "redesign" + const val SAFETY = "safety_notice" // system state const val MAGISKHIDE = "magiskhide" @@ -117,6 +118,7 @@ object Config : PreferenceModel, DBConfig { var suNotification by preferenceStrInt(Key.SU_NOTIFICATION, Value.NOTIFICATION_TOAST) var updateChannel by preferenceStrInt(Key.UPDATE_CHANNEL, defaultChannel) + var safetyNotice by preference(Key.SAFETY, true) var redesign by preference(Key.REDESIGN, false) @Deprecated("Use extended dark theme") var darkTheme by preference(Key.DARK_THEME, true) diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt index 72496892e..86078999a 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt @@ -2,6 +2,7 @@ package com.topjohnwu.magisk.redesign.home import android.Manifest import com.topjohnwu.magisk.BuildConfig +import com.topjohnwu.magisk.Config import com.topjohnwu.magisk.Info import com.topjohnwu.magisk.R import com.topjohnwu.magisk.data.repository.MagiskRepository @@ -34,6 +35,8 @@ class HomeViewModel( private val repoMagisk: MagiskRepository ) : CompatViewModel() { + val isNoticeVisible = KObservableField(Config.safetyNotice) + val stateMagisk = KObservableField(MagiskState.LOADING) val stateManager = KObservableField(MagiskState.LOADING) val stateTextMagisk = Observer(stateMagisk) { @@ -143,6 +146,11 @@ class HomeViewModel( fun toggle(kof: KObservableField) = kof.toggle() + fun hideNotice() { + Config.safetyNotice = false + isNoticeVisible.value = false + } + private fun ensureEnv() { val invalidStates = listOf( MagiskState.NOT_INSTALLED, diff --git a/app/src/main/res/layout/fragment_home_md2.xml b/app/src/main/res/layout/fragment_home_md2.xml index 1ea204b03..5e6f141a8 100644 --- a/app/src/main/res/layout/fragment_home_md2.xml +++ b/app/src/main/res/layout/fragment_home_md2.xml @@ -44,6 +44,46 @@ android:orientation="vertical" android:paddingTop="@dimen/l1"> + + + + + + + + + + + + - + android:layout_marginTop="@dimen/l2" + android:layout_marginEnd="@dimen/l1" + android:text="@string/home_support_title" + android:textAppearance="?appearanceTextTitleNormal" /> - + android:layout_marginTop="@dimen/l_50" + android:layout_marginEnd="@dimen/l1" + android:text="@string/home_support_content" + android:textAppearance="?appearanceTextCaptionVariant" /> - + 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" /> diff --git a/app/src/main/res/layout/item_developer.xml b/app/src/main/res/layout/item_developer.xml index 420b7831e..e4a8baa04 100644 --- a/app/src/main/res/layout/item_developer.xml +++ b/app/src/main/res/layout/item_developer.xml @@ -24,6 +24,7 @@ android:id="@+id/developer_icon" style="?styleIconNormal" android:padding="@dimen/l_50" + android:visibility="gone" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:srcCompat="@{item.icon}" @@ -34,7 +35,6 @@ style="?styleCardNormal" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="@dimen/l1" app:layout_constrainedWidth="true" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" diff --git a/app/src/main/res/values/strings_md2.xml b/app/src/main/res/values/strings_md2.xml index 278e3cb14..71c9a28fd 100644 --- a/app/src/main/res/values/strings_md2.xml +++ b/app/src/main/res/values/strings_md2.xml @@ -30,6 +30,11 @@ Source XDA + Always make sure you\'re using open-source Magisk Manager. Manager of unknown source can perform malicious actions. + Hide + Support Us + Magisk is, and always will be, free and open-source. You can however show us that you care by sending a small donation. + Security System A/B