|
|
@ -17,6 +17,7 @@ import com.fox2code.mmm.manager.LocalModuleInfo;
|
|
|
|
import com.fox2code.mmm.manager.ModuleInfo;
|
|
|
|
import com.fox2code.mmm.manager.ModuleInfo;
|
|
|
|
import com.fox2code.mmm.manager.ModuleManager;
|
|
|
|
import com.fox2code.mmm.manager.ModuleManager;
|
|
|
|
import com.fox2code.mmm.utils.IntentHelper;
|
|
|
|
import com.fox2code.mmm.utils.IntentHelper;
|
|
|
|
|
|
|
|
import com.google.android.material.card.MaterialCardView;
|
|
|
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|
|
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|
|
|
|
|
|
|
|
|
|
|
import io.noties.markwon.Markwon;
|
|
|
|
import io.noties.markwon.Markwon;
|
|
|
@ -24,7 +25,7 @@ import io.noties.markwon.Markwon;
|
|
|
|
public enum ActionButtonType {
|
|
|
|
public enum ActionButtonType {
|
|
|
|
INFO(R.drawable.ic_baseline_info_24) {
|
|
|
|
INFO(R.drawable.ic_baseline_info_24) {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void doAction(ImageButton button, ModuleHolder moduleHolder) {
|
|
|
|
public void doAction(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder) {
|
|
|
|
String notesUrl = moduleHolder.repoModule.notesUrl;
|
|
|
|
String notesUrl = moduleHolder.repoModule.notesUrl;
|
|
|
|
if (notesUrl.startsWith("https://api.androidacy.com/magisk/readme/?module=") ||
|
|
|
|
if (notesUrl.startsWith("https://api.androidacy.com/magisk/readme/?module=") ||
|
|
|
|
notesUrl.startsWith("https://www.androidacy.com/")) {
|
|
|
|
notesUrl.startsWith("https://www.androidacy.com/")) {
|
|
|
@ -48,7 +49,7 @@ public enum ActionButtonType {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
UPDATE_INSTALL() {
|
|
|
|
UPDATE_INSTALL() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void update(ImageButton button, ModuleHolder moduleHolder) {
|
|
|
|
public void update(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder) {
|
|
|
|
int icon = moduleHolder.hasUpdate() ?
|
|
|
|
int icon = moduleHolder.hasUpdate() ?
|
|
|
|
R.drawable.ic_baseline_update_24 :
|
|
|
|
R.drawable.ic_baseline_update_24 :
|
|
|
|
R.drawable.ic_baseline_system_update_24;
|
|
|
|
R.drawable.ic_baseline_system_update_24;
|
|
|
@ -56,7 +57,7 @@ public enum ActionButtonType {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void doAction(ImageButton button, ModuleHolder moduleHolder) {
|
|
|
|
public void doAction(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder) {
|
|
|
|
ModuleInfo moduleInfo = moduleHolder.getMainModuleInfo();
|
|
|
|
ModuleInfo moduleInfo = moduleHolder.getMainModuleInfo();
|
|
|
|
if (moduleInfo == null) return;
|
|
|
|
if (moduleInfo == null) return;
|
|
|
|
String updateZipUrl = moduleHolder.getUpdateZipUrl();
|
|
|
|
String updateZipUrl = moduleHolder.getUpdateZipUrl();
|
|
|
@ -114,7 +115,7 @@ public enum ActionButtonType {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
UNINSTALL() {
|
|
|
|
UNINSTALL() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void update(ImageButton button, ModuleHolder moduleHolder) {
|
|
|
|
public void update(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder) {
|
|
|
|
int icon = moduleHolder.hasFlag(ModuleInfo.FLAG_MODULE_UNINSTALLING) ?
|
|
|
|
int icon = moduleHolder.hasFlag(ModuleInfo.FLAG_MODULE_UNINSTALLING) ?
|
|
|
|
R.drawable.ic_baseline_delete_outline_24 : (
|
|
|
|
R.drawable.ic_baseline_delete_outline_24 : (
|
|
|
|
!moduleHolder.hasFlag(ModuleInfo.FLAG_MODULE_UPDATING) ||
|
|
|
|
!moduleHolder.hasFlag(ModuleInfo.FLAG_MODULE_UPDATING) ||
|
|
|
@ -125,7 +126,7 @@ public enum ActionButtonType {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void doAction(ImageButton button, ModuleHolder moduleHolder) {
|
|
|
|
public void doAction(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder) {
|
|
|
|
if (!moduleHolder.hasFlag(ModuleInfo.FLAGS_MODULE_ACTIVE |
|
|
|
|
if (!moduleHolder.hasFlag(ModuleInfo.FLAGS_MODULE_ACTIVE |
|
|
|
|
ModuleInfo.FLAG_MODULE_UNINSTALLING) &&
|
|
|
|
ModuleInfo.FLAG_MODULE_UNINSTALLING) &&
|
|
|
|
moduleHolder.hasFlag(ModuleInfo.FLAG_MODULE_UPDATING)) {
|
|
|
|
moduleHolder.hasFlag(ModuleInfo.FLAG_MODULE_UPDATING)) {
|
|
|
@ -136,7 +137,7 @@ public enum ActionButtonType {
|
|
|
|
!moduleHolder.hasFlag(ModuleInfo.FLAG_MODULE_UNINSTALLING))) {
|
|
|
|
!moduleHolder.hasFlag(ModuleInfo.FLAG_MODULE_UNINSTALLING))) {
|
|
|
|
Log.e("ActionButtonType", "Failed to switch uninstalled state!");
|
|
|
|
Log.e("ActionButtonType", "Failed to switch uninstalled state!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
update(button, moduleHolder);
|
|
|
|
update(button, cardView, moduleHolder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -158,7 +159,7 @@ public enum ActionButtonType {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
CONFIG(R.drawable.ic_baseline_app_settings_alt_24) {
|
|
|
|
CONFIG(R.drawable.ic_baseline_app_settings_alt_24) {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void doAction(ImageButton button, ModuleHolder moduleHolder) {
|
|
|
|
public void doAction(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder) {
|
|
|
|
String config = moduleHolder.getMainModuleConfig();
|
|
|
|
String config = moduleHolder.getMainModuleConfig();
|
|
|
|
if (config == null) return;
|
|
|
|
if (config == null) return;
|
|
|
|
if (AndroidacyUtil.isAndroidacyLink(config)) {
|
|
|
|
if (AndroidacyUtil.isAndroidacyLink(config)) {
|
|
|
@ -170,19 +171,19 @@ public enum ActionButtonType {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
SUPPORT() {
|
|
|
|
SUPPORT() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void update(ImageButton button, ModuleHolder moduleHolder) {
|
|
|
|
public void update(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder) {
|
|
|
|
ModuleInfo moduleInfo = moduleHolder.getMainModuleInfo();
|
|
|
|
ModuleInfo moduleInfo = moduleHolder.getMainModuleInfo();
|
|
|
|
button.setImageResource(supportIconForUrl(moduleInfo.support));
|
|
|
|
button.setImageResource(supportIconForUrl(moduleInfo.support));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void doAction(ImageButton button, ModuleHolder moduleHolder) {
|
|
|
|
public void doAction(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder) {
|
|
|
|
IntentHelper.openUrl(button.getContext(), moduleHolder.getMainModuleInfo().support);
|
|
|
|
IntentHelper.openUrl(button.getContext(), moduleHolder.getMainModuleInfo().support);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
DONATE() {
|
|
|
|
DONATE() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void update(ImageButton button, ModuleHolder moduleHolder) {
|
|
|
|
public void update(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder) {
|
|
|
|
ModuleInfo moduleInfo = moduleHolder.getMainModuleInfo();
|
|
|
|
ModuleInfo moduleInfo = moduleHolder.getMainModuleInfo();
|
|
|
|
int icon = R.drawable.ic_baseline_monetization_on_24;
|
|
|
|
int icon = R.drawable.ic_baseline_monetization_on_24;
|
|
|
|
if (moduleInfo.donate.startsWith("https://www.paypal.me/")) {
|
|
|
|
if (moduleInfo.donate.startsWith("https://www.paypal.me/")) {
|
|
|
@ -194,7 +195,7 @@ public enum ActionButtonType {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void doAction(ImageButton button, ModuleHolder moduleHolder) {
|
|
|
|
public void doAction(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder) {
|
|
|
|
IntentHelper.openUrl(button.getContext(), moduleHolder.getMainModuleInfo().donate);
|
|
|
|
IntentHelper.openUrl(button.getContext(), moduleHolder.getMainModuleInfo().donate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -226,11 +227,11 @@ public enum ActionButtonType {
|
|
|
|
this.iconId = iconId;
|
|
|
|
this.iconId = iconId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void update(ImageButton button, ModuleHolder moduleHolder) {
|
|
|
|
public void update(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder) {
|
|
|
|
button.setImageResource(this.iconId);
|
|
|
|
button.setImageResource(this.iconId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public abstract void doAction(ImageButton button, ModuleHolder moduleHolder);
|
|
|
|
public abstract void doAction(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder);
|
|
|
|
|
|
|
|
|
|
|
|
public boolean doActionLong(ImageButton button, ModuleHolder moduleHolder) {
|
|
|
|
public boolean doActionLong(ImageButton button, ModuleHolder moduleHolder) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|