pull/107/head
Der_Googler 2 years ago
parent 7066e2d205
commit 237305fd16

@ -25,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, MaterialCardView cardView, ModuleHolder moduleHolder) { public void doAction(ImageButton button, 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/")) {
@ -49,7 +49,7 @@ public enum ActionButtonType {
}, },
UPDATE_INSTALL() { UPDATE_INSTALL() {
@Override @Override
public void update(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder) { public void update(ImageButton button, 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;
@ -57,7 +57,7 @@ public enum ActionButtonType {
} }
@Override @Override
public void doAction(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder) { public void doAction(ImageButton button, 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();
@ -115,7 +115,7 @@ public enum ActionButtonType {
}, },
UNINSTALL() { UNINSTALL() {
@Override @Override
public void update(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder) { public void update(ImageButton button, 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) ||
@ -126,7 +126,7 @@ public enum ActionButtonType {
} }
@Override @Override
public void doAction(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder) { public void doAction(ImageButton button, 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)) {
@ -137,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, cardView, moduleHolder); update(button, moduleHolder);
} }
@Override @Override
@ -159,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, MaterialCardView cardView, ModuleHolder moduleHolder) { public void doAction(ImageButton button, 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)) {
@ -171,19 +171,19 @@ public enum ActionButtonType {
}, },
SUPPORT() { SUPPORT() {
@Override @Override
public void update(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder) { public void update(ImageButton button, 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, MaterialCardView cardView, ModuleHolder moduleHolder) { public void doAction(ImageButton button, 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, MaterialCardView cardView, ModuleHolder moduleHolder) { public void update(ImageButton button, 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/")) {
@ -195,7 +195,7 @@ public enum ActionButtonType {
} }
@Override @Override
public void doAction(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder) { public void doAction(ImageButton button, ModuleHolder moduleHolder) {
IntentHelper.openUrl(button.getContext(), moduleHolder.getMainModuleInfo().donate); IntentHelper.openUrl(button.getContext(), moduleHolder.getMainModuleInfo().donate);
} }
}; };
@ -227,11 +227,11 @@ public enum ActionButtonType {
this.iconId = iconId; this.iconId = iconId;
} }
public void update(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder) { public void update(ImageButton button, ModuleHolder moduleHolder) {
button.setImageResource(this.iconId); button.setImageResource(this.iconId);
} }
public abstract void doAction(ImageButton button, MaterialCardView cardView, ModuleHolder moduleHolder); public abstract void doAction(ImageButton button, ModuleHolder moduleHolder);
public boolean doActionLong(ImageButton button, ModuleHolder moduleHolder) { public boolean doActionLong(ImageButton button, ModuleHolder moduleHolder) {
return false; return false;

@ -126,7 +126,7 @@ public final class ModuleViewAdapter extends RecyclerView.Adapter<ModuleViewAdap
ModuleHolder moduleHolder = this.moduleHolder; ModuleHolder moduleHolder = this.moduleHolder;
if (index < this.actionButtonsTypes.size() && moduleHolder != null) { if (index < this.actionButtonsTypes.size() && moduleHolder != null) {
this.actionButtonsTypes.get(index) this.actionButtonsTypes.get(index)
.doAction((ImageButton) v, (MaterialCardView) cardView, moduleHolder); .doAction((ImageButton) v, moduleHolder);
if (moduleHolder.shouldRemove()) { if (moduleHolder.shouldRemove()) {
this.cardView.setVisibility(View.GONE); this.cardView.setVisibility(View.GONE);
} }
@ -234,7 +234,7 @@ public final class ModuleViewAdapter extends RecyclerView.Adapter<ModuleViewAdap
imageButton.setImportantForAccessibility( imageButton.setImportantForAccessibility(
View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); View.IMPORTANT_FOR_ACCESSIBILITY_AUTO);
ActionButtonType button = this.actionButtonsTypes.get(i); ActionButtonType button = this.actionButtonsTypes.get(i);
button.update(imageButton, (MaterialCardView) cardView, moduleHolder); button.update(imageButton, moduleHolder);
imageButton.setContentDescription(button.name()); imageButton.setContentDescription(button.name());
} else { } else {
imageButton.setVisibility(View.GONE); imageButton.setVisibility(View.GONE);

Loading…
Cancel
Save