Remove unused codes
This commit is contained in:
parent
d9e8f7636b
commit
d3e0177262
|
|
@ -1,6 +1,5 @@
|
|||
package org.meowcat.edxposed.manager.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
|
@ -26,7 +25,6 @@ import java.nio.file.Paths;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS;
|
||||
|
||||
|
|
@ -51,11 +49,6 @@ public class AppHelper {
|
|||
return new File(BASE_PATH + WHITE_LIST_MODE).exists();
|
||||
}
|
||||
|
||||
|
||||
public static List<String> getAppList() {
|
||||
return getAppList(isWhiteListMode());
|
||||
}
|
||||
|
||||
public static List<String> getAppList(boolean white) {
|
||||
Path dir = Paths.get(BASE_PATH + (white ? WHITE_LIST_PATH : BLACK_LIST_PATH));
|
||||
List<String> s = new ArrayList<>();
|
||||
|
|
@ -108,7 +101,6 @@ public class AppHelper {
|
|||
return createAppListFile(packageName, white, add);
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
public static void showMenu(@NonNull Context context,
|
||||
@NonNull FragmentManager fragmentManager,
|
||||
@NonNull View anchor,
|
||||
|
|
@ -127,9 +119,9 @@ public class AppHelper {
|
|||
} else if (itemId == R.id.app_menu_stop) {
|
||||
try {
|
||||
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
Objects.requireNonNull(manager).killBackgroundProcesses(info.packageName);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
manager.killBackgroundProcesses(info.packageName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (itemId == R.id.app_menu_compile_speed) {
|
||||
CompileUtil.compileSpeed(context, fragmentManager, info);
|
||||
|
|
@ -143,8 +135,8 @@ public class AppHelper {
|
|||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (itemId == R.id.app_menu_info) {
|
||||
context.startActivity(new Intent(ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", info.packageName, null)));
|
||||
|
|
@ -182,7 +174,6 @@ public class AppHelper {
|
|||
return s;
|
||||
}
|
||||
|
||||
@SuppressLint("WorldReadableFiles")
|
||||
static boolean saveScopeList(String modulePackageName, List<String> list) {
|
||||
Path path = Paths.get(BASE_PATH + String.format(SCOPE_LIST_PATH, modulePackageName));
|
||||
if (list.size() == 0) {
|
||||
|
|
|
|||
|
|
@ -5,12 +5,9 @@ import android.widget.CompoundButton;
|
|||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import org.meowcat.edxposed.manager.App;
|
||||
import org.meowcat.edxposed.manager.R;
|
||||
import org.meowcat.edxposed.manager.ui.activity.AppListActivity;
|
||||
import org.meowcat.edxposed.manager.util.ModuleUtil;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
|
@ -25,8 +22,7 @@ public class BlackListAdapter extends AppAdapter {
|
|||
@Override
|
||||
public List<String> generateCheckedList() {
|
||||
AppHelper.makeSurePath();
|
||||
checkedList = AppHelper.getAppList(AppHelper.isWhiteListMode());
|
||||
return checkedList;
|
||||
return checkedList = AppHelper.getAppList(AppHelper.isWhiteListMode());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ package org.meowcat.edxposed.manager.receivers;
|
|||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
|
||||
import org.meowcat.edxposed.manager.util.ModuleUtil;
|
||||
import org.meowcat.edxposed.manager.util.NotificationUtil;
|
||||
|
||||
public class EdServiceReceiver extends BroadcastReceiver {
|
||||
|
|
@ -22,19 +22,15 @@ public class EdServiceReceiver extends BroadcastReceiver {
|
|||
return;
|
||||
}
|
||||
|
||||
String appName = "null";
|
||||
try {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
pm.getApplicationInfo(packageName, 0);
|
||||
appName = (String) pm.getApplicationInfo(packageName, 0).loadLabel(pm);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ModuleUtil.InstalledModule module = ModuleUtil.getInstance().reloadSingleModule(packageName);
|
||||
if (module == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (intent.getAction().equals("io.github.lsposed.action.MODULE_NOT_ACTIVATAED")) {
|
||||
NotificationUtil.showNotActivatedNotification(packageName, appName);
|
||||
NotificationUtil.showNotActivatedNotification(packageName, module.getAppName());
|
||||
} else if (intent.getAction().equals("io.github.lsposed.action.MODULE_UPDATED")) {
|
||||
NotificationUtil.showModulesUpdatedNotification(appName);
|
||||
NotificationUtil.showModulesUpdatedNotification(module.getAppName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,8 +42,4 @@ public class AboutActivity extends BaseActivity {
|
|||
void setupView(View v, final int url) {
|
||||
v.setOnClickListener(v1 -> NavUtil.startURL(this, getString(url)));
|
||||
}
|
||||
|
||||
//public void openLink(View view) {
|
||||
// NavUtil.startURL(this, view.getTag().toString());
|
||||
//}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ public class AppListActivity extends BaseActivity {
|
|||
setSupportActionBar(binding.toolbar);
|
||||
binding.toolbar.setNavigationOnClickListener(view -> finish());
|
||||
ActionBar bar = getSupportActionBar();
|
||||
assert bar != null;
|
||||
bar.setDisplayHomeAsUpEnabled(true);
|
||||
if (!TextUtils.isEmpty(modulePackageName)) {
|
||||
bar.setTitle(R.string.menu_scope);
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ public class LogsActivity extends BaseActivity {
|
|||
}
|
||||
|
||||
private void reloadErrorLog() {
|
||||
//noinspection deprecation
|
||||
new LogsReader().execute(allLog ? fileAllLog : fileErrorLog);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ import org.meowcat.edxposed.manager.util.ModuleUtil;
|
|||
import org.meowcat.edxposed.manager.util.NavUtil;
|
||||
import org.meowcat.edxposed.manager.util.light.Light;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class MainActivity extends BaseActivity implements ModuleUtil.ModuleListener {
|
||||
ActivityMainBinding binding;
|
||||
|
||||
|
|
@ -83,7 +85,7 @@ public class MainActivity extends BaseActivity implements ModuleUtil.ModuleListe
|
|||
String installedXposedVersion = Constants.getXposedVersion();
|
||||
if (installedXposedVersion != null) {
|
||||
binding.statusTitle.setText(R.string.Activated);
|
||||
binding.statusSummary.setText(installedXposedVersion + " (" + Constants.getXposedVariant() + ")");
|
||||
binding.statusSummary.setText(String.format(Locale.US, "%s (%s)", installedXposedVersion, Constants.getXposedVariant()));
|
||||
binding.status.setCardBackgroundColor(ContextCompat.getColor(this, R.color.download_status_update_available));
|
||||
binding.statusIcon.setImageResource(R.drawable.ic_check_circle);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -395,14 +395,6 @@ public class ModulesActivity extends BaseActivity implements ModuleUtil.ModuleLi
|
|||
Snackbar.make(binding.snackbar, R.string.module_no_ui, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
return true;
|
||||
/*} else if (itemId == R.id.menu_download_updates) {
|
||||
Intent intent = new Intent(this, DownloadDetailsActivity.class);
|
||||
intent.setData(Uri.fromParts("package", module.packageName, null));
|
||||
startActivity(intent);
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_support) {
|
||||
//NavUtil.startURL(this, Uri.parse(RepoDb.getModuleSupport(module.packageName)));
|
||||
return true;*/
|
||||
} else if (itemId == R.id.menu_app_store) {
|
||||
Uri uri = Uri.parse("market://details?id=" + module.packageName);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
|
|
@ -536,7 +528,7 @@ public class ModulesActivity extends BaseActivity implements ModuleUtil.ModuleLi
|
|||
boolean changed = moduleUtil.isModuleEnabled(packageName) ^ isChecked;
|
||||
if (changed) {
|
||||
moduleUtil.setModuleEnabled(packageName, isChecked);
|
||||
moduleUtil.updateModulesList(true, binding);
|
||||
moduleUtil.updateModulesList(true, binding.snackbar);
|
||||
}
|
||||
});
|
||||
mSwitch.setChecked(moduleUtil.isModuleEnabled(item.packageName));
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ public class CompileDialogFragment extends AppCompatDialogFragment {
|
|||
appInfo = arguments.getParcelable(KEY_APP_INFO);
|
||||
type = type * 10 + 1;
|
||||
int result = App.checkPermission(type);
|
||||
switch (result){
|
||||
switch (result) {
|
||||
case 0:
|
||||
onRequestPermissionsResult(type, PERMISSION_GRANTED);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import java.io.File;
|
|||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Locale;
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
public class StatusDialogBuilder extends MaterialAlertDialogBuilder {
|
||||
|
|
@ -35,8 +36,8 @@ public class StatusDialogBuilder extends MaterialAlertDialogBuilder {
|
|||
binding.manager.setText(mAppVer);
|
||||
|
||||
if (installedXposedVersion != null) {
|
||||
binding.api.setText(Constants.getXposedApiVersion() + ".0");
|
||||
binding.framework.setText(installedXposedVersion + " (" + Constants.getXposedVariant() + ")");
|
||||
binding.api.setText(String.format(Locale.US, "%s.0", Constants.getXposedVariant()));
|
||||
binding.framework.setText(String.format(Locale.US, "%s (%s)", installedXposedVersion, Constants.getXposedVariant()));
|
||||
}
|
||||
|
||||
binding.androidVersion.setText(context.getString(R.string.android_sdk, getAndroidVersion(), Build.VERSION.RELEASE, Build.VERSION.SDK_INT));
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ public class CompileUtil {
|
|||
sActivity = activity;
|
||||
int type = CompileType.DEXOPT_ALL.ordinal() * 10 + 1;
|
||||
int result = App.checkPermission(type);
|
||||
switch (result){
|
||||
switch (result) {
|
||||
case 0:
|
||||
onRequestPermissionsResult(type, PERMISSION_GRANTED);
|
||||
break;
|
||||
|
|
@ -141,7 +141,7 @@ public class CompileUtil {
|
|||
sActivity = activity;
|
||||
int type = CompileType.SPEED_ALL.ordinal() * 10 + 1;
|
||||
int result = App.checkPermission(type);
|
||||
switch (result){
|
||||
switch (result) {
|
||||
case 0:
|
||||
onRequestPermissionsResult(type, PERMISSION_GRANTED);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import android.content.pm.PackageManager;
|
|||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
|
@ -17,11 +18,9 @@ import org.meowcat.edxposed.manager.App;
|
|||
import org.meowcat.edxposed.manager.Constants;
|
||||
import org.meowcat.edxposed.manager.R;
|
||||
import org.meowcat.edxposed.manager.adapters.AppHelper;
|
||||
import org.meowcat.edxposed.manager.databinding.ActivityModulesBinding;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
|
|
@ -106,7 +105,6 @@ public final class ModuleUtil {
|
|||
try {
|
||||
pkg = pm.getPackageInfo(packageName, PackageManager.GET_META_DATA);
|
||||
} catch (NameNotFoundException e) {
|
||||
//RepoDb.deleteInstalledModule(packageName);
|
||||
InstalledModule old = installedModules.remove(packageName);
|
||||
if (old != null) {
|
||||
for (ModuleListener listener : listeners) {
|
||||
|
|
@ -177,16 +175,12 @@ public final class ModuleUtil {
|
|||
updateModulesList(showToast, null);
|
||||
}
|
||||
|
||||
public synchronized void updateModulesList(boolean showToast, ActivityModulesBinding binding) {
|
||||
public synchronized void updateModulesList(boolean showToast, View view) {
|
||||
try {
|
||||
Log.i(App.TAG, "ModuleUtil -> updating modules.list");
|
||||
int installedXposedVersion = Constants.getXposedApiVersion();
|
||||
if (!prefs.getBoolean("skip_xposedminversion_check", false) && installedXposedVersion <= 0 && showToast) {
|
||||
if (binding != null) {
|
||||
Snackbar.make(binding.snackbar, R.string.notinstalled, Snackbar.LENGTH_SHORT).show();
|
||||
} else {
|
||||
showToast(R.string.notinstalled);
|
||||
}
|
||||
showToast(view, R.string.notinstalled);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -196,11 +190,7 @@ public final class ModuleUtil {
|
|||
for (InstalledModule module : enabledModules) {
|
||||
|
||||
if (!prefs.getBoolean("skip_xposedminversion_check", false) && (module.minVersion > installedXposedVersion || module.minVersion < MIN_MODULE_VERSION) && showToast) {
|
||||
if (binding != null) {
|
||||
Snackbar.make(binding.snackbar, R.string.notinstalled, Snackbar.LENGTH_SHORT).show();
|
||||
} else {
|
||||
showToast(R.string.notinstalled);
|
||||
}
|
||||
showToast(view, R.string.notinstalled);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -211,30 +201,29 @@ public final class ModuleUtil {
|
|||
enabledModulesList.close();
|
||||
|
||||
if (showToast) {
|
||||
if (binding != null) {
|
||||
Snackbar.make(binding.snackbar, R.string.xposed_module_list_updated, Snackbar.LENGTH_SHORT).show();
|
||||
} else {
|
||||
showToast(R.string.xposed_module_list_updated);
|
||||
}
|
||||
showToast(view, R.string.xposed_module_list_updated);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(App.TAG, "ModuleUtil -> cannot write " + Constants.getModulesListFile(), e);
|
||||
if (binding != null) {
|
||||
Snackbar.make(binding.snackbar, "cannot write " + Constants.getModulesListFile() + e, Snackbar.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(App.getInstance(), "cannot write " + Constants.getModulesListFile() + e, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
showToast(view, "cannot write " + Constants.getModulesListFile() + e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
private void showToast(int message) {
|
||||
if (toast != null) {
|
||||
toast.cancel();
|
||||
toast = null;
|
||||
private void showToast(View view, int message) {
|
||||
showToast(view, App.getInstance().getString(message));
|
||||
}
|
||||
|
||||
private void showToast(View view, String message) {
|
||||
if (view != null) {
|
||||
Snackbar.make(view, message, Snackbar.LENGTH_SHORT).show();
|
||||
} else {
|
||||
if (toast != null) {
|
||||
toast.cancel();
|
||||
toast = null;
|
||||
}
|
||||
toast = Toast.makeText(App.getInstance(), message, Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
toast = Toast.makeText(App.getInstance(), App.getInstance().getString(message), Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
|
||||
public void addListener(ModuleListener listener) {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class RebootUtil {
|
|||
|
||||
public static void reboot(RebootType mode) {
|
||||
int result = App.checkPermission(mode.ordinal());
|
||||
switch (result){
|
||||
switch (result) {
|
||||
case 0:
|
||||
onRequestPermissionsResult(mode.ordinal(), PERMISSION_GRANTED);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue