From d30397e9c07ec652cbf0a69934ee08597d424c6f Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Mon, 30 Jan 2017 01:38:30 +0800 Subject: [PATCH] Let users know why blacklist PoGO and AP... --- .../topjohnwu/magisk/MagiskHideFragment.java | 7 --- .../magisk/adapters/ApplicationAdapter.java | 48 ++++++++++++++----- .../com/topjohnwu/magisk/utils/Async.java | 3 +- app/src/main/res/values/strings.xml | 3 +- 4 files changed, 38 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/MagiskHideFragment.java b/app/src/main/java/com/topjohnwu/magisk/MagiskHideFragment.java index 1c264a9a6..299e82a8c 100644 --- a/app/src/main/java/com/topjohnwu/magisk/MagiskHideFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/MagiskHideFragment.java @@ -29,13 +29,6 @@ import butterknife.Unbinder; public class MagiskHideFragment extends Fragment implements CallbackHandler.EventListener { - public static final List HIDEBLACKLIST = Arrays.asList( - "android", - "com.topjohnwu.magisk", - "com.google.android.gms", - "com.google.android.apps.walletnfcrel", - "com.nianticlabs.pokemongo" - ); private Unbinder unbinder; @BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout; @BindView(R.id.recyclerView) RecyclerView recyclerView; diff --git a/app/src/main/java/com/topjohnwu/magisk/adapters/ApplicationAdapter.java b/app/src/main/java/com/topjohnwu/magisk/adapters/ApplicationAdapter.java index a0f600ec1..87a0bb28e 100644 --- a/app/src/main/java/com/topjohnwu/magisk/adapters/ApplicationAdapter.java +++ b/app/src/main/java/com/topjohnwu/magisk/adapters/ApplicationAdapter.java @@ -2,6 +2,7 @@ package com.topjohnwu.magisk.adapters; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; +import android.support.design.widget.Snackbar; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; @@ -16,6 +17,7 @@ import com.topjohnwu.magisk.utils.Async; import com.topjohnwu.magisk.utils.Utils; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -24,6 +26,17 @@ import butterknife.ButterKnife; public class ApplicationAdapter extends RecyclerView.Adapter { + public static final List BLACKLIST = Arrays.asList( + "android", + "com.topjohnwu.magisk", + "com.google.android.gms" + ); + + private static final List SNLIST = Arrays.asList( + "com.google.android.apps.walletnfcrel", + "com.nianticlabs.pokemongo" + ); + private List mOriginalList, mList; private List mHideList; private PackageManager packageManager; @@ -33,6 +46,7 @@ public class ApplicationAdapter extends RecyclerView.Adapter listApps, List hideList) { @@ -55,17 +69,28 @@ public class ApplicationAdapter extends RecyclerView.Adapter { - if (isChecked) { - new Async.MagiskHide().add(info.packageName); - mHideList.add(info.packageName); - } else { - new Async.MagiskHide().rm(info.packageName); - mHideList.remove(info.packageName); - } - }); + + if (SNLIST.contains(info.packageName)) { + holder.checkBox.setChecked(true); + holder.checkBox.setEnabled(false); + holder.itemView.setOnClickListener(v -> + Snackbar.make(holder.itemView, R.string.safetyNet_hide_notice, Snackbar.LENGTH_LONG).show()); + } else { + holder.checkBox.setEnabled(true); + holder.checkBox.setChecked(mHideList.contains(info.packageName)); + holder.checkBox.setOnCheckedChangeListener((v, isChecked) -> { + if (isChecked) { + new Async.MagiskHide().add(info.packageName); + mHideList.add(info.packageName); + } else { + new Async.MagiskHide().rm(info.packageName); + mHideList.remove(info.packageName); + } + }); + } } @Override @@ -74,9 +99,6 @@ public class ApplicationAdapter extends RecyclerView.Adapter listApps = pm.getInstalledApplications(PackageManager.GET_META_DATA); for (Iterator i = listApps.iterator(); i.hasNext(); ) { ApplicationInfo info = i.next(); - if (MagiskHideFragment.HIDEBLACKLIST.contains(info.packageName) || !info.enabled) + if (ApplicationAdapter.BLACKLIST.contains(info.packageName) || !info.enabled) i.remove(); } Collections.sort(listApps, (a, b) -> a.loadLabel(pm).toString().toLowerCase() diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c809a3965..ce408bffb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -113,6 +113,7 @@ Reboot to apply settings Check release notes Repo cache cleared + This app uses SafetyNet\nAlready handled by MagiskHide by default https://api.github.com/orgs/Magisk-Modules-Repo/repos @@ -153,8 +154,6 @@ Enable shell command debug logging Check this to enable logging all shell commands and its output - - Superuser Request Deny%1$s