pull/107/head
Der_Googler 3 years ago
parent 189f3d9563
commit df8fd6e0eb

@ -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;

@ -22,6 +22,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.repo.RepoModule; import com.fox2code.mmm.repo.RepoModule;
import com.google.android.material.card.MaterialCardView;
import com.google.android.material.switchmaterial.SwitchMaterial; import com.google.android.material.switchmaterial.SwitchMaterial;
import com.topjohnwu.superuser.internal.UiThreadHandler; import com.topjohnwu.superuser.internal.UiThreadHandler;
@ -125,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, moduleHolder); .doAction((ImageButton) v, (MaterialCardView) cardView, moduleHolder);
if (moduleHolder.shouldRemove()) { if (moduleHolder.shouldRemove()) {
this.cardView.setVisibility(View.GONE); this.cardView.setVisibility(View.GONE);
} }
@ -233,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, moduleHolder); button.update(imageButton, (MaterialCardView) cardView, moduleHolder);
imageButton.setContentDescription(button.name()); imageButton.setContentDescription(button.name());
} else { } else {
imageButton.setVisibility(View.GONE); imageButton.setVisibility(View.GONE);
@ -322,7 +323,7 @@ public final class ModuleViewAdapter extends RecyclerView.Adapter<ModuleViewAdap
bgColor = 0xFFF8F8F8; bgColor = 0xFFF8F8F8;
} else { } else {
bgColor = 0xFF1E1E1E; bgColor = 0xFF1E1E1E;
}; }
this.titleText.setTextColor(fgColor); this.titleText.setTextColor(fgColor);
this.buttonAction.setColorFilter(fgColor); this.buttonAction.setColorFilter(fgColor);
this.cardView.setCardBackgroundColor(bgColor); this.cardView.setCardBackgroundColor(bgColor);

Loading…
Cancel
Save