diff --git a/app/src/main/java/com/fox2code/mmm/ActionButtonType.java b/app/src/main/java/com/fox2code/mmm/ActionButtonType.java index 9066b0a..383d1e3 100644 --- a/app/src/main/java/com/fox2code/mmm/ActionButtonType.java +++ b/app/src/main/java/com/fox2code/mmm/ActionButtonType.java @@ -15,9 +15,14 @@ import com.fox2code.mmm.installer.InstallerInitializer; import com.fox2code.mmm.manager.LocalModuleInfo; import com.fox2code.mmm.manager.ModuleInfo; import com.fox2code.mmm.manager.ModuleManager; +import com.fox2code.mmm.utils.Http; import com.fox2code.mmm.utils.IntentHelper; import com.google.android.material.dialog.MaterialAlertDialogBuilder; +import java.nio.charset.StandardCharsets; + +import io.noties.markwon.Markwon; + public enum ActionButtonType { INFO(R.drawable.ic_baseline_info_24) { @Override @@ -71,28 +76,23 @@ public enum ActionButtonType { new MaterialAlertDialogBuilder(button.getContext()); builder.setTitle(moduleInfo.name).setCancelable(true) .setIcon(R.drawable.ic_baseline_extension_24); - String desc; + CharSequence desc = moduleInfo.description; + final boolean noPatch; if (moduleInfo instanceof LocalModuleInfo) { LocalModuleInfo localModuleInfo = (LocalModuleInfo) moduleInfo; - desc = localModuleInfo.updateChangeLog.isEmpty() ? - moduleInfo.description : localModuleInfo.updateChangeLog; + if (!localModuleInfo.updateChangeLog.isEmpty()) { + Markwon markwon = MainApplication.getINSTANCE().getMarkwon(); + // Re-render each time in cse of config changes + desc = markwon.render(markwon.parse(localModuleInfo.updateChangeLog)); + } + noPatch = true; } else { - desc = moduleInfo.description; + noPatch = false; } - if (desc == null || desc.isEmpty()) { + if (desc == null || desc.length() == 0) { builder.setMessage(R.string.no_desc_found); } else { - if (desc.length() == 1000) { - int lastDot = desc.lastIndexOf('.'); - if (lastDot == -1) { - int lastSpace = desc.lastIndexOf(' '); - if (lastSpace == -1) - desc = desc.substring(0, lastSpace); - } else { - desc = desc.substring(0, lastDot + 1); - } - } builder.setMessage(desc); } Log.d("Test", "URL: " + updateZipUrl); @@ -103,7 +103,7 @@ public enum ActionButtonType { R.string.update_module : R.string.install_module, (x, y) -> { String updateZipChecksum = moduleHolder.getUpdateZipChecksum(); IntentHelper.openInstaller(button.getContext(), updateZipUrl, - moduleInfo.name, moduleInfo.config, updateZipChecksum); + moduleInfo.name, moduleInfo.config, updateZipChecksum, noPatch); }); } int dim5dp = CompatDisplay.dpToPixel(5); diff --git a/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyWebAPI.java b/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyWebAPI.java index acdb75f..f3b76c4 100644 --- a/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyWebAPI.java +++ b/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyWebAPI.java @@ -86,8 +86,9 @@ public class AndroidacyWebAPI { Uri uri = Uri.parse(moduleUrl); if (uri.getScheme().equals("https") && uri.getHost().endsWith(".androidacy.com")) { this.activity.backOnResume = true; - IntentHelper.openInstaller(this.activity, - moduleUrl, installTitle, null, checksum); + IntentHelper.openInstaller( + this.activity, moduleUrl, installTitle, + null, checksum, true); } else { this.activity.forceBackPressed(); } diff --git a/app/src/main/java/com/fox2code/mmm/manager/LocalModuleInfo.java b/app/src/main/java/com/fox2code/mmm/manager/LocalModuleInfo.java index 507161a..8547c5f 100644 --- a/app/src/main/java/com/fox2code/mmm/manager/LocalModuleInfo.java +++ b/app/src/main/java/com/fox2code/mmm/manager/LocalModuleInfo.java @@ -8,12 +8,16 @@ import com.fox2code.mmm.utils.PropUtils; import org.json.JSONObject; +import java.io.IOException; import java.nio.charset.StandardCharsets; +import io.noties.markwon.Markwon; + public class LocalModuleInfo extends ModuleInfo { public String updateVersion; public long updateVersionCode = Long.MIN_VALUE; public String updateZipUrl; + public String updateChangeLogUrl; public String updateChangeLog = ""; public String updateChecksum; @@ -25,11 +29,21 @@ public class LocalModuleInfo extends ModuleInfo { if (this.updateJson != null) { try { JSONObject jsonUpdate = new JSONObject(new String(Http.doHttpGet( - this.updateJson, false), StandardCharsets.UTF_8)); + this.updateJson, true), StandardCharsets.UTF_8)); this.updateVersion = jsonUpdate.optString("version"); this.updateVersionCode = jsonUpdate.getLong("versionCode"); this.updateZipUrl = jsonUpdate.getString("zipUrl"); - this.updateChangeLog = jsonUpdate.optString("changelog"); + this.updateChangeLogUrl = jsonUpdate.optString("changelog"); + try { + String desc = new String(Http.doHttpGet( + this.updateChangeLogUrl, true), StandardCharsets.UTF_8); + if (desc.length() > 1000) { + desc = desc.substring(0, 1000); + } + this.updateChangeLog = desc; + } catch (IOException ioe) { + this.updateChangeLog = ""; + } this.updateChecksum = jsonUpdate.optString("checksum"); if (this.updateZipUrl.isEmpty()) throw FastException.INSTANCE; this.updateVersion = PropUtils.shortenVersionName( diff --git a/app/src/main/java/com/fox2code/mmm/utils/IntentHelper.java b/app/src/main/java/com/fox2code/mmm/utils/IntentHelper.java index dd4bb87..d0678ac 100644 --- a/app/src/main/java/com/fox2code/mmm/utils/IntentHelper.java +++ b/app/src/main/java/com/fox2code/mmm/utils/IntentHelper.java @@ -125,6 +125,11 @@ public class IntentHelper { openInstaller(context, url, title, config, checksum, false, false); } + public static void openInstaller(Context context, String url, String title, String config, + String checksum, boolean noPatch) { + openInstaller(context, url, title, config, checksum, noPatch, false); + } + public static void openInstaller(Context context, String url, String title, String config, String checksum, boolean noPatch,boolean testDebug) { try {