Remove compat mode

This commit is contained in:
NekoInverter 2021-01-25 19:07:30 +08:00
parent ffb83c0ba8
commit 0be570bcad
No known key found for this signature in database
GPG Key ID: 280D6CCCF95715F9
6 changed files with 5 additions and 128 deletions

View File

@ -42,7 +42,6 @@ public class AppHelper {
private static final String BASE_PATH = Constants.getBaseDir();
private static final String WHITE_LIST_PATH = "conf/whitelist/";
private static final String BLACK_LIST_PATH = "conf/blacklist/";
private static final String COMPAT_LIST_PATH = "conf/compatlist/";
private static final String SCOPE_LIST_PATH = "conf/%s.conf";
private static final String WHITE_LIST_MODE = "conf/usewhitelist";
private static final String BLACK_LIST_MODE = "conf/blackwhitelist";
@ -55,7 +54,6 @@ public class AppHelper {
static void makeSurePath() {
App.mkdir(WHITE_LIST_PATH);
App.mkdir(BLACK_LIST_PATH);
App.mkdir(COMPAT_LIST_PATH);
}
public static boolean isWhiteListMode() {
@ -197,40 +195,6 @@ public class AppHelper {
return returns;
}
@SuppressLint("WorldReadableFiles")
private static Boolean compatListFileName(String packageName, boolean isAdd) {
boolean returns = true;
File file = new File(BASE_PATH + COMPAT_LIST_PATH + packageName);
if (isAdd) {
if (!file.exists()) {
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file.getPath());
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
try {
returns = file.createNewFile();
} catch (IOException e1) {
e.printStackTrace();
}
}
}
}
}
} else {
if (file.exists()) {
returns = file.delete();
}
}
return returns;
}
static boolean addPackageName(boolean isWhiteListMode, String packageName) {
return isWhiteListMode ? addWhiteList(packageName) : addBlackList(packageName);
}
@ -289,27 +253,6 @@ public class AppHelper {
menuHelper.show();
}
static List<String> getCompatList() {
File file = new File(BASE_PATH + COMPAT_LIST_PATH);
File[] files = file.listFiles();
if (files == null) {
return new ArrayList<>();
}
List<String> s = new ArrayList<>();
for (File file1 : files) {
s.add(file1.getName());
}
return s;
}
static boolean addCompatList(String packageName) {
return compatListFileName(packageName, true);
}
static boolean removeCompatList(String packageName) {
return compatListFileName(packageName, false);
}
static List<String> getScopeList(String modulePackageName) {
if (scopeList.containsKey(modulePackageName)) {
return scopeList.get(modulePackageName);

View File

@ -1,41 +0,0 @@
package org.meowcat.edxposed.manager.adapters;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.widget.CompoundButton;
import org.meowcat.edxposed.manager.R;
import org.meowcat.edxposed.manager.util.ToastUtil;
import java.util.List;
public class CompatListAdapter extends AppAdapter {
private List<String> checkedList;
public CompatListAdapter(Context context) {
super(context);
}
@Override
protected List<String> generateCheckedList() {
AppHelper.makeSurePath();
return checkedList = AppHelper.getCompatList();
}
@Override
protected void onCheckedChange(CompoundButton view, boolean isChecked, ApplicationInfo info) {
boolean success = isChecked ?
AppHelper.addCompatList(info.packageName) : AppHelper.removeCompatList(info.packageName);
if (success) {
if (isChecked) {
checkedList.add(info.packageName);
} else {
checkedList.remove(info.packageName);
}
} else {
ToastUtil.showShortToast(context, R.string.add_package_failed);
view.setChecked(!isChecked);
}
}
}

View File

@ -22,7 +22,6 @@ import androidx.annotation.StyleRes;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.content.ContextCompat;
import androidx.core.view.ViewCompat;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.topjohnwu.superuser.Shell;

View File

@ -20,7 +20,6 @@ import org.meowcat.edxposed.manager.R;
import org.meowcat.edxposed.manager.adapters.AppAdapter;
import org.meowcat.edxposed.manager.adapters.AppHelper;
import org.meowcat.edxposed.manager.adapters.BlackListAdapter;
import org.meowcat.edxposed.manager.adapters.CompatListAdapter;
import org.meowcat.edxposed.manager.databinding.ActivityBlackListBinding;
import org.meowcat.edxposed.manager.util.LinearLayoutManagerFix;
@ -39,12 +38,10 @@ public class BlackListActivity extends BaseActivity implements AppAdapter.Callba
}
};
private final Handler handler = new Handler();
private boolean isCompat;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
isCompat = getIntent().getBooleanExtra("compat_list", false);
binding = ActivityBlackListBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
setSupportActionBar(binding.toolbar);
@ -55,7 +52,7 @@ public class BlackListActivity extends BaseActivity implements AppAdapter.Callba
}
setupWindowInsets(binding.snackbar, binding.recyclerView);
final boolean isWhiteListMode = isWhiteListMode();
appAdapter = isCompat ? new CompatListAdapter(this) : new BlackListAdapter(this, isWhiteListMode);
appAdapter = new BlackListAdapter(this, isWhiteListMode);
appAdapter.setHasStableIds(true);
binding.recyclerView.setAdapter(appAdapter);
binding.recyclerView.setLayoutManager(new LinearLayoutManagerFix(this));
@ -98,7 +95,7 @@ public class BlackListActivity extends BaseActivity implements AppAdapter.Callba
@Override
public void onResume() {
super.onResume();
if (!isCompat && !AppHelper.isBlackListMode()) {
if (!AppHelper.isBlackListMode()) {
new MaterialAlertDialogBuilder(this)
.setMessage(R.string.warning_list_not_enabled)
.setPositiveButton(R.string.Settings, (dialog, which) -> {
@ -115,9 +112,7 @@ public class BlackListActivity extends BaseActivity implements AppAdapter.Callba
private void changeTitle(boolean isBlackListMode, boolean isWhiteListMode) {
if (isCompat) {
setTitle(R.string.nav_title_compat_list);
} else if (isBlackListMode) {
if (isBlackListMode) {
setTitle(isWhiteListMode ? R.string.title_white_list : R.string.title_black_list);
} else {
setTitle(R.string.nav_title_black_list);

View File

@ -388,20 +388,6 @@ public class SettingsActivity extends BaseActivity {
});
}
Preference compat_mode = findPreference("compat_mode");
if (compat_mode != null) {
compat_mode.setOnPreferenceClickListener(preference -> {
Activity activity = getActivity();
if (activity != null) {
Intent intent = new Intent();
intent.putExtra("compat_list", true);
intent.setClass(activity, BlackListActivity.class);
activity.startActivity(intent);
}
return true;
});
}
IntegerListPreference theme = findPreference("theme");
if (theme != null) {
theme.setOnPreferenceChangeListener((preference, newValue) -> {
@ -474,8 +460,8 @@ public class SettingsActivity extends BaseActivity {
new MaterialAlertDialogBuilder(activity)
.setTitle(R.string.areyousure)
.setMessage(contentTextId)
.setPositiveButton(android.R.string.yes, listener)
.setNegativeButton(android.R.string.no, null)
.setPositiveButton(android.R.string.ok, listener)
.setNegativeButton(android.R.string.cancel, null)
.show();
}
}

View File

@ -114,11 +114,6 @@
android:key="group_framework"
android:title="@string/settings_group_framework"
app:iconSpaceReserved="false">
<Preference
android:key="compat_mode"
android:summary="@string/pref_compat_mode_summary"
android:title="@string/pref_compat_mode_title"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="black_white_list_switch"