From 5109b9abfd409b28ae103c13e0aaa4738d0be79d Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 7 Aug 2018 16:31:00 +0800 Subject: [PATCH] Allow modules be managed in core only mode, and add notice in UI --- .../com/topjohnwu/magisk/MagiskFragment.java | 3 ++ .../com/topjohnwu/magisk/MainActivity.java | 13 +++---- .../{ic_su_warning.xml => ic_warning.xml} | 0 app/src/full/res/layout/activity_request.xml | 2 +- app/src/full/res/layout/fragment_magisk.xml | 39 +++++++++++++++++++ 5 files changed, 49 insertions(+), 8 deletions(-) rename app/src/full/res/drawable/{ic_su_warning.xml => ic_warning.xml} (100%) diff --git a/app/src/full/java/com/topjohnwu/magisk/MagiskFragment.java b/app/src/full/java/com/topjohnwu/magisk/MagiskFragment.java index 48fd26c80..26a5108a0 100644 --- a/app/src/full/java/com/topjohnwu/magisk/MagiskFragment.java +++ b/app/src/full/java/com/topjohnwu/magisk/MagiskFragment.java @@ -50,6 +50,8 @@ public class MagiskFragment extends BaseFragment @BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout; + @BindView(R.id.core_only_notice) CardView coreOnlyNotice; + @BindView(R.id.magisk_update) RelativeLayout magiskUpdate; @BindView(R.id.magisk_update_icon) ImageView magiskUpdateIcon; @BindView(R.id.magisk_update_status) TextView magiskUpdateText; @@ -217,6 +219,7 @@ public class MagiskFragment extends BaseFragment safetyNetCard.setVisibility(hasNetwork ? View.VISIBLE : View.GONE); installOptionCard.setVisibility(hasNetwork ? View.VISIBLE : View.GONE); uninstallButton.setVisibility(isUpToDate && hasRoot ? View.VISIBLE : View.GONE); + coreOnlyNotice.setVisibility(mm.prefs.getBoolean(Const.Key.COREONLY, false) ? View.VISIBLE : View.GONE); int image, color; diff --git a/app/src/full/java/com/topjohnwu/magisk/MainActivity.java b/app/src/full/java/com/topjohnwu/magisk/MainActivity.java index ea8e56c9b..83c5a52ac 100644 --- a/app/src/full/java/com/topjohnwu/magisk/MainActivity.java +++ b/app/src/full/java/com/topjohnwu/magisk/MainActivity.java @@ -119,13 +119,12 @@ public class MainActivity extends BaseActivity public void checkHideSection() { Menu menu = navigationView.getMenu(); - menu.findItem(R.id.magiskhide).setVisible( - Shell.rootAccess() && Data.magiskVersionCode >= Const.MAGISK_VER.UNIFIED - && mm.prefs.getBoolean(Const.Key.MAGISKHIDE, false)); - menu.findItem(R.id.modules).setVisible(!mm.prefs.getBoolean(Const.Key.COREONLY, false) && - Shell.rootAccess() && Data.magiskVersionCode >= 0); - menu.findItem(R.id.downloads).setVisible(!mm.prefs.getBoolean(Const.Key.COREONLY, false) - && Download.checkNetworkStatus(this) && Shell.rootAccess() && Data.magiskVersionCode >= 0); + menu.findItem(R.id.magiskhide).setVisible(Shell.rootAccess() && + Data.magiskVersionCode >= Const.MAGISK_VER.UNIFIED && + mm.prefs.getBoolean(Const.Key.MAGISKHIDE, false)); + menu.findItem(R.id.modules).setVisible(Shell.rootAccess() && Data.magiskVersionCode >= 0); + menu.findItem(R.id.downloads).setVisible(Download.checkNetworkStatus(this) + && Shell.rootAccess() && Data.magiskVersionCode >= 0); menu.findItem(R.id.log).setVisible(Shell.rootAccess()); menu.findItem(R.id.superuser).setVisible(Shell.rootAccess() && !(Const.USER_ID > 0 && Data.multiuserMode == Const.Value.MULTIUSER_MODE_OWNER_MANAGED)); diff --git a/app/src/full/res/drawable/ic_su_warning.xml b/app/src/full/res/drawable/ic_warning.xml similarity index 100% rename from app/src/full/res/drawable/ic_su_warning.xml rename to app/src/full/res/drawable/ic_warning.xml diff --git a/app/src/full/res/layout/activity_request.xml b/app/src/full/res/layout/activity_request.xml index 9a37d32e6..10fa98672 100644 --- a/app/src/full/res/layout/activity_request.xml +++ b/app/src/full/res/layout/activity_request.xml @@ -82,7 +82,7 @@ android:id="@+id/warning" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:drawableStart="@drawable/ic_su_warning" + android:drawableStart="@drawable/ic_warning" android:textColor="?android:textColorSecondary" android:text="@string/su_warning" android:layout_gravity="center_horizontal" diff --git a/app/src/full/res/layout/fragment_magisk.xml b/app/src/full/res/layout/fragment_magisk.xml index 6e86c2eed..e64824708 100644 --- a/app/src/full/res/layout/fragment_magisk.xml +++ b/app/src/full/res/layout/fragment_magisk.xml @@ -20,6 +20,45 @@ android:layout_height="wrap_content" android:orientation="vertical"> + + + + + + + + + +