Remove blacklist flag

This commit is contained in:
NekoInverter 2021-01-25 19:13:29 +08:00
parent 0be570bcad
commit ad19c1b1f6
No known key found for this signature in database
GPG Key ID: 280D6CCCF95715F9
5 changed files with 15 additions and 83 deletions

View File

@ -77,7 +77,6 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.ViewHolder> impl
List<ApplicationInfo> rmList = new ArrayList<>(); List<ApplicationInfo> rmList = new ArrayList<>();
for (ApplicationInfo info : fullList) { for (ApplicationInfo info : fullList) {
if (this instanceof ScopeAdapter) { if (this instanceof ScopeAdapter) {
if (AppHelper.isBlackListMode()) {
if (AppHelper.isWhiteListMode()) { if (AppHelper.isWhiteListMode()) {
List<String> whiteList = AppHelper.getWhiteList(); List<String> whiteList = AppHelper.getWhiteList();
if (!whiteList.contains(info.packageName)) { if (!whiteList.contains(info.packageName)) {
@ -91,7 +90,6 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.ViewHolder> impl
continue; continue;
} }
} }
}
if (info.packageName.equals(((ScopeAdapter) this).modulePackageName)) { if (info.packageName.equals(((ScopeAdapter) this).modulePackageName)) {
rmList.add(info); rmList.add(info);
} }

View File

@ -44,7 +44,6 @@ public class AppHelper {
private static final String BLACK_LIST_PATH = "conf/blacklist/"; private static final String BLACK_LIST_PATH = "conf/blacklist/";
private static final String SCOPE_LIST_PATH = "conf/%s.conf"; private static final String SCOPE_LIST_PATH = "conf/%s.conf";
private static final String WHITE_LIST_MODE = "conf/usewhitelist"; private static final String WHITE_LIST_MODE = "conf/usewhitelist";
private static final String BLACK_LIST_MODE = "conf/blackwhitelist";
private static final List<String> FORCE_WHITE_LIST = new ArrayList<>(Collections.singletonList(BuildConfig.APPLICATION_ID)); private static final List<String> FORCE_WHITE_LIST = new ArrayList<>(Collections.singletonList(BuildConfig.APPLICATION_ID));
public static List<String> FORCE_WHITE_LIST_MODULE = new ArrayList<>(FORCE_WHITE_LIST); public static List<String> FORCE_WHITE_LIST_MODULE = new ArrayList<>(FORCE_WHITE_LIST);
@ -60,10 +59,6 @@ public class AppHelper {
return new File(BASE_PATH + WHITE_LIST_MODE).exists(); return new File(BASE_PATH + WHITE_LIST_MODE).exists();
} }
public static boolean isBlackListMode() {
return new File(BASE_PATH + BLACK_LIST_MODE).exists();
}
private static boolean addWhiteList(String packageName) { private static boolean addWhiteList(String packageName) {
return whiteListFileName(packageName, true); return whiteListFileName(packageName, true);
} }

View File

@ -1,6 +1,5 @@
package org.meowcat.edxposed.manager.ui.activity; package org.meowcat.edxposed.manager.ui.activity;
import android.content.Intent;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
@ -13,8 +12,6 @@ import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.SearchView; import androidx.appcompat.widget.SearchView;
import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.DividerItemDecoration;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import org.meowcat.edxposed.manager.App; import org.meowcat.edxposed.manager.App;
import org.meowcat.edxposed.manager.R; import org.meowcat.edxposed.manager.R;
import org.meowcat.edxposed.manager.adapters.AppAdapter; import org.meowcat.edxposed.manager.adapters.AppAdapter;
@ -95,38 +92,19 @@ public class BlackListActivity extends BaseActivity implements AppAdapter.Callba
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if (!AppHelper.isBlackListMode()) { changeTitle(isWhiteListMode());
new MaterialAlertDialogBuilder(this)
.setMessage(R.string.warning_list_not_enabled)
.setPositiveButton(R.string.Settings, (dialog, which) -> {
Intent intent = new Intent();
intent.setClass(BlackListActivity.this, SettingsActivity.class);
startActivity(intent);
})
.setNegativeButton(android.R.string.cancel, (dialog, which) -> finish())
.setCancelable(false)
.show();
}
changeTitle(isBlackListMode(), isWhiteListMode());
} }
private void changeTitle(boolean isBlackListMode, boolean isWhiteListMode) { private void changeTitle(boolean isWhiteListMode) {
if (isBlackListMode) {
setTitle(isWhiteListMode ? R.string.title_white_list : R.string.title_black_list); setTitle(isWhiteListMode ? R.string.title_white_list : R.string.title_black_list);
} else {
setTitle(R.string.nav_title_black_list);
}
} }
private boolean isWhiteListMode() { private boolean isWhiteListMode() {
return AppHelper.isWhiteListMode(); return AppHelper.isWhiteListMode();
} }
private boolean isBlackListMode() {
return AppHelper.isBlackListMode();
}
@Override @Override
public void onDataReady() { public void onDataReady() {
handler.removeCallbacks(runnable); handler.removeCallbacks(runnable);

View File

@ -114,7 +114,6 @@ public class SettingsActivity extends BaseActivity {
private static final File dynamicModulesFlag = new File(Constants.getBaseDir() + "conf/dynamicmodules"); private static final File dynamicModulesFlag = new File(Constants.getBaseDir() + "conf/dynamicmodules");
private static final File deoptBootFlag = new File(Constants.getBaseDir() + "conf/deoptbootimage"); private static final File deoptBootFlag = new File(Constants.getBaseDir() + "conf/deoptbootimage");
private static final File whiteListModeFlag = new File(Constants.getBaseDir() + "conf/usewhitelist"); private static final File whiteListModeFlag = new File(Constants.getBaseDir() + "conf/usewhitelist");
private static final File blackWhiteListModeFlag = new File(Constants.getBaseDir() + "conf/blackwhitelist");
private static final File disableVerboseLogsFlag = new File(Constants.getBaseDir() + "conf/disable_verbose_log"); private static final File disableVerboseLogsFlag = new File(Constants.getBaseDir() + "conf/disable_verbose_log");
private static final File disableModulesLogsFlag = new File(Constants.getBaseDir() + "conf/disable_modules_log"); private static final File disableModulesLogsFlag = new File(Constants.getBaseDir() + "conf/disable_modules_log");
private static final File verboseLogProcessID = new File(Constants.getBaseDir() + "log/all.pid"); private static final File verboseLogProcessID = new File(Constants.getBaseDir() + "log/all.pid");
@ -244,38 +243,6 @@ public class SettingsActivity extends BaseActivity {
}); });
} }
SwitchPreferenceCompat prefBlackWhiteListMode = findPreference("black_white_list_switch");
if (prefBlackWhiteListMode != null) {
prefBlackWhiteListMode.setChecked(blackWhiteListModeFlag.exists());
prefBlackWhiteListMode.setOnPreferenceChangeListener((preference, newValue) -> {
boolean enabled = (Boolean) newValue;
if (enabled) {
FileOutputStream fos = null;
try {
fos = new FileOutputStream(blackWhiteListModeFlag.getPath());
} catch (FileNotFoundException e) {
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
try {
blackWhiteListModeFlag.createNewFile();
} catch (IOException e1) {
Toast.makeText(getActivity(), e1.getMessage(), Toast.LENGTH_SHORT).show();
}
}
}
}
} else {
blackWhiteListModeFlag.delete();
}
return (enabled == blackWhiteListModeFlag.exists());
});
}
SwitchPreferenceCompat prefEnableDeopt = findPreference("enable_boot_image_deopt"); SwitchPreferenceCompat prefEnableDeopt = findPreference("enable_boot_image_deopt");
if (prefEnableDeopt != null) { if (prefEnableDeopt != null) {
prefEnableDeopt.setChecked(deoptBootFlag.exists()); prefEnableDeopt.setChecked(deoptBootFlag.exists());

View File

@ -114,12 +114,6 @@
android:key="group_framework" android:key="group_framework"
android:title="@string/settings_group_framework" android:title="@string/settings_group_framework"
app:iconSpaceReserved="false"> app:iconSpaceReserved="false">
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="black_white_list_switch"
android:summary="@string/pref_black_white_list_summary"
android:title="@string/pref_title_black_white_list"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:defaultValue="false" android:defaultValue="false"