Improve full clear button, don't require reboot for just installed modules. (Fix #51)

pull/55/head
Fox2Code 2 years ago
parent 781020ec96
commit 1969e052d3

@ -122,9 +122,8 @@ public enum ActionButtonType {
public void update(ImageButton button, ModuleHolder moduleHolder) {
int icon = moduleHolder.hasFlag(ModuleInfo.FLAG_MODULE_UNINSTALLING) ?
R.drawable.ic_baseline_delete_outline_24 : (
// We can't trust active flag on first boot
MainApplication.isFirstBoot() ||
moduleHolder.hasFlag(ModuleInfo.FLAG_MODULE_ACTIVE)) ?
!moduleHolder.hasFlag(ModuleInfo.FLAG_MODULE_UPDATING) ||
moduleHolder.hasFlag(ModuleInfo.FLAGS_MODULE_ACTIVE)) ?
R.drawable.ic_baseline_delete_24 :
R.drawable.ic_baseline_delete_forever_24;
button.setImageResource(icon);
@ -132,8 +131,14 @@ public enum ActionButtonType {
@Override
public void doAction(ImageButton button, ModuleHolder moduleHolder) {
if (!moduleHolder.hasFlag(ModuleInfo.FLAGS_MODULE_ACTIVE |
ModuleInfo.FLAG_MODULE_UNINSTALLING) &&
moduleHolder.hasFlag(ModuleInfo.FLAG_MODULE_UPDATING)) {
doActionLong(button, moduleHolder);
return;
}
if (!ModuleManager.getINSTANCE().setUninstallState(moduleHolder.moduleInfo,
!moduleHolder.moduleInfo.hasFlag(ModuleInfo.FLAG_MODULE_UNINSTALLING))) {
!moduleHolder.hasFlag(ModuleInfo.FLAG_MODULE_UNINSTALLING))) {
Log.e("ActionButtonType", "Failed to switch uninstalled state!");
}
update(button, moduleHolder);
@ -142,8 +147,7 @@ public enum ActionButtonType {
@Override
public boolean doActionLong(ImageButton button, ModuleHolder moduleHolder) {
// We can't trust active flag on first boot
if (moduleHolder.moduleInfo.hasFlag(ModuleInfo.FLAG_MODULE_ACTIVE)
|| MainApplication.isFirstBoot()) return false;
if (moduleHolder.moduleInfo.hasFlag(ModuleInfo.FLAGS_MODULE_ACTIVE)) return false;
new AlertDialog.Builder(button.getContext()).setTitle(R.string.master_delete)
.setPositiveButton(R.string.master_delete_yes, (v, i) -> {
if (!ModuleManager.getINSTANCE().masterClear(moduleHolder.moduleInfo)) {

@ -11,6 +11,10 @@ public class ModuleInfo {
public static final int FLAG_MODULE_ACTIVE = 0x04;
public static final int FLAG_MODULE_UNINSTALLING = 0x08;
public static final int FLAG_MODULE_UPDATING_ONLY = 0x10;
public static final int FLAG_MODULE_MAYBE_ACTIVE = 0x20;
public static final int FLAGS_MODULE_ACTIVE =
FLAG_MODULE_ACTIVE | FLAG_MODULE_MAYBE_ACTIVE;
public static final int FLAG_METADATA_INVALID = 0x80000000;

@ -72,6 +72,7 @@ public final class ModuleManager {
}
private void scanInternal() {
boolean firstBoot = MainApplication.isFirstBoot();
boolean firstScan = this.bootPrefs.getBoolean("mm_first_scan", true);
SharedPreferences.Editor editor = firstScan ? this.bootPrefs.edit() : null;
for (ModuleInfo v : this.moduleInfos.values()) {
@ -102,11 +103,16 @@ public final class ModuleManager {
"/data/adb/modules/" + module + "/disable").exists();
if (disabled) {
moduleInfo.flags |= ModuleInfo.FLAG_MODULE_DISABLED;
if (firstBoot && firstScan) {
editor.putBoolean("module_" + moduleInfo.id + "_active", true);
moduleInfo.flags |= ModuleInfo.FLAG_MODULE_MAYBE_ACTIVE;
}
} else {
if (firstScan) {
moduleInfo.flags |= ModuleInfo.FLAG_MODULE_ACTIVE;
editor.putBoolean("module_" + moduleInfo.id + "_active", true);
} else if (bootPrefs.getBoolean("module_" + moduleInfo.id + "_active", false)) {
} else if (!moduleInfo.hasFlag(ModuleInfo.FLAG_MODULE_MAYBE_ACTIVE) &&
bootPrefs.getBoolean("module_" + moduleInfo.id + "_active", false)) {
moduleInfo.flags |= ModuleInfo.FLAG_MODULE_ACTIVE;
}
}
@ -221,7 +227,7 @@ public final class ModuleManager {
}
public boolean masterClear(ModuleInfo moduleInfo) {
if (moduleInfo.hasFlag(ModuleInfo.FLAG_MODULE_ACTIVE)) return false;
if (moduleInfo.hasFlag(ModuleInfo.FLAGS_MODULE_ACTIVE)) return false;
String escapedId = moduleInfo.id.replace("\\", "\\\\")
.replace("\"", "\\\"").replace(" ", "\\ ");
try { // Check for module that declare having file outside their own folder.

@ -3,7 +3,7 @@
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
android:tint="?attr/colorError">
<path
android:fillColor="@android:color/white"
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2L18,7L6,7v12zM8.46,11.88l1.41,-1.41L12,12.59l2.12,-2.12 1.41,1.41L13.41,14l2.12,2.12 -1.41,1.41L12,15.41l-2.12,2.12 -1.41,-1.41L10.59,14l-2.13,-2.12zM15.5,4l-1,-1h-5l-1,1L5,4v2h14L19,4z"/>

Loading…
Cancel
Save