Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit 7b186dc

Browse files
authored
Merge branch 'Fox2Code:master' into master
2 parents 72578b4 + 2d6e5db commit 7b186dc

File tree

9 files changed

+64
-27
lines changed

9 files changed

+64
-27
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android {
1010
applicationId "com.fox2code.mmm"
1111
minSdk 21
1212
targetSdk 32
13-
versionCode 38
14-
versionName "0.4.3"
13+
versionCode 39
14+
versionName "0.4.4"
1515

1616
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1717
}

app/src/main/java/com/fox2code/mmm/ActionButtonType.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.fox2code.mmm;
22

33
import android.content.Context;
4+
import android.text.Spanned;
45
import android.util.Log;
56
import android.widget.Button;
67
import android.widget.ImageButton;
8+
import android.widget.TextView;
79
import android.widget.Toast;
810

911
import androidx.annotation.DrawableRes;
@@ -77,12 +79,13 @@ public void doAction(ImageButton button, ModuleHolder moduleHolder) {
7779
builder.setTitle(moduleInfo.name).setCancelable(true)
7880
.setIcon(R.drawable.ic_baseline_extension_24);
7981
CharSequence desc = moduleInfo.description;
82+
Markwon markwon = null;
8083
if (moduleInfo instanceof LocalModuleInfo) {
8184
LocalModuleInfo localModuleInfo = (LocalModuleInfo) moduleInfo;
8285
if (!localModuleInfo.updateChangeLog.isEmpty()) {
83-
Markwon markwon = MainApplication.getINSTANCE().getMarkwon();
86+
markwon = MainApplication.getINSTANCE().getMarkwon();
8487
// Re-render each time in cse of config changes
85-
desc = markwon.render(markwon.parse(localModuleInfo.updateChangeLog));
88+
desc = markwon.toMarkdown(localModuleInfo.updateChangeLog);
8689
}
8790
}
8891

@@ -111,6 +114,11 @@ public void doAction(ImageButton button, ModuleHolder moduleHolder) {
111114
alertButton.setPadding(dim5dp, dim5dp, dim5dp, dim5dp);
112115
}
113116
}
117+
if (markwon != null) {
118+
TextView messageView = alertDialog.getWindow()
119+
.findViewById(android.R.id.message);
120+
markwon.setParsedMarkdown(messageView, (Spanned) desc);
121+
}
114122
}
115123
},
116124
UNINSTALL() {

app/src/main/java/com/fox2code/mmm/compat/CompatActivity.java

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -265,31 +265,30 @@ public void setActionBarBackground(Drawable drawable) {
265265
}
266266

267267
@Dimension @Px
268-
public int getStatusBarHeight() { // How to improve this?
268+
public int getStatusBarHeight() {
269269
int height = WindowInsetsCompat.CONSUMED.getInsets(
270270
WindowInsetsCompat.Type.statusBars()).top;
271-
if (height == 0) { // Fallback to system resources
272-
int id = Resources.getSystem().getIdentifier(
273-
"status_bar_height", "dimen", "android");
274-
if (id > 0) return Resources.getSystem().getDimensionPixelSize(id);
275-
}
276-
return height;
271+
// Check system resources
272+
int id = Resources.getSystem().getIdentifier(
273+
"status_bar_height", "dimen", "android");
274+
return id <= 0 ? height : Math.max(height,
275+
Resources.getSystem().getDimensionPixelSize(id));
277276
}
278277

279278
public int getNavigationBarHeight() {
280279
int height = WindowInsetsCompat.CONSUMED.getInsets(
281280
WindowInsetsCompat.Type.navigationBars()).bottom;
282-
if (height == 0) { // Fallback to system resources
283-
int id = Resources.getSystem().getIdentifier(
284-
"config_showNavigationBar", "bool", "android");
285-
Log.d(TAG, "Nav 1: " + id);
286-
if ((id > 0 && Resources.getSystem().getBoolean(id))
287-
|| !this.hasHardwareNavBar()) {
288-
id = Resources.getSystem().getIdentifier(
289-
"navigation_bar_height", "dimen", "android");
290-
Log.d(TAG, "Nav 2: " + id);
291-
if (id > 0) return Resources.getSystem().getDimensionPixelSize(id);
292-
}
281+
// Check system resources
282+
int id = Resources.getSystem().getIdentifier(
283+
"config_showNavigationBar", "bool", "android");
284+
Log.d(TAG, "Nav 1: " + id);
285+
if ((id > 0 && Resources.getSystem().getBoolean(id))
286+
|| !this.hasHardwareNavBar()) {
287+
id = Resources.getSystem().getIdentifier(
288+
"navigation_bar_height", "dimen", "android");
289+
Log.d(TAG, "Nav 2: " + id);
290+
return id <= 0 ? height : Math.max(height,
291+
Resources.getSystem().getDimensionPixelSize(id));
293292
}
294293
return height;
295294
}

app/src/main/java/com/fox2code/mmm/manager/LocalModuleInfo.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.util.Log;
44

5+
import com.fox2code.mmm.markdown.MarkdownUrlLinker;
56
import com.fox2code.mmm.utils.FastException;
67
import com.fox2code.mmm.utils.Http;
78
import com.fox2code.mmm.utils.PropUtils;
@@ -48,6 +49,7 @@ public void checkModuleUpdate() {
4849
this.updateVersion.trim(), this.updateVersionCode);
4950
if (this.updateChangeLog.length() > 1000)
5051
this.updateChangeLog = this.updateChangeLog.substring(0, 1000);
52+
this.updateChangeLog = MarkdownUrlLinker.urlLinkify(this.updateChangeLog);
5153
} catch (Exception e) {
5254
this.updateVersion = null;
5355
this.updateVersionCode = Long.MIN_VALUE;

app/src/main/java/com/fox2code/mmm/utils/Files.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package com.fox2code.mmm.utils;
22

3+
import android.os.Build;
4+
5+
import androidx.annotation.NonNull;
6+
37
import com.topjohnwu.superuser.io.SuFile;
48
import com.topjohnwu.superuser.io.SuFileInputStream;
59
import com.topjohnwu.superuser.io.SuFileOutputStream;
@@ -18,6 +22,8 @@
1822
import java.util.zip.ZipOutputStream;
1923

2024
public class Files {
25+
private static final boolean is64bit = Build.SUPPORTED_64_BIT_ABIS.length > 0;
26+
2127
public static void write(File file, byte[] bytes) throws IOException {
2228
try (OutputStream outputStream = new FileOutputStream(file)) {
2329
outputStream.write(bytes);
@@ -63,8 +69,24 @@ public static void closeSilently(Closeable closeable) {
6369
} catch (IOException ignored) {}
6470
}
6571

72+
public static ByteArrayOutputStream makeBuffer(long capacity) {
73+
// Cap buffer to 1 Gib (or 512 Mib for 32bit) to avoid memory errors
74+
return Files.makeBuffer((int) Math.min(capacity, is64bit ? 0x40000000 : 0x20000000));
75+
}
76+
77+
public static ByteArrayOutputStream makeBuffer(int capacity) {
78+
return new ByteArrayOutputStream(Math.max(0x20, capacity)) {
79+
@NonNull
80+
@Override
81+
public byte[] toByteArray() {
82+
return this.buf.length == this.count ?
83+
this.buf : super.toByteArray();
84+
}
85+
};
86+
}
87+
6688
public static byte[] readAllBytes(InputStream inputStream) throws IOException {
67-
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
89+
ByteArrayOutputStream buffer = Files.makeBuffer(inputStream.available());
6890
copy(inputStream, buffer);
6991
return buffer.toByteArray();
7092
}

app/src/main/java/com/fox2code/mmm/utils/Http.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,7 @@ public static byte[] doHttpGet(String url,ProgressListener progressListener) thr
225225
byte[] buff = new byte[1024 * 4];
226226
long downloaded = 0;
227227
long target = responseBody.contentLength();
228-
ByteArrayOutputStream byteArrayOutputStream =
229-
new ByteArrayOutputStream();
228+
ByteArrayOutputStream byteArrayOutputStream = Files.makeBuffer(target);
230229
int divider = 1; // Make everything go in an int
231230
while ((target / divider) > (Integer.MAX_VALUE / 2)) {
232231
divider *= 2;

app/src/main/java/com/fox2code/mmm/utils/PropUtils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ public class PropUtils {
7070
GH_UC + "3arthur6/BluetoothLibraryPatcher/master/update.json");
7171
moduleUpdateJsonFallbacks.put("Detach",
7272
GH_UC + "xerta555/Detach-Files/blob/master/Updater.json");
73+
for (String module : new String[]{"busybox-ndk", "adb-ndk", "twrp-keep",
74+
"adreno-dev", "nano-ndk", "zipsigner", "nexusmedia", "mtd-ndk"}) {
75+
moduleUpdateJsonFallbacks.put(module,
76+
GH_UC + "Magisk-Modules-Repo/" + module + "/master/update.json");
77+
}
7378
moduleUpdateJsonFallbacks.put("riru_ifw_enhance", "https://github.com/" +
7479
"Kr328/Riru-IFWEnhance/releases/latest/download/riru-ifw-enhance.json");
7580
moduleUpdateJsonFallbacks.put("zygisk_ifw_enhance", "https://github.com/" +

app/src/main/res/values-ro/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<string name="failed_download">Descărcarea fișierului a eșuat.</string>
1212
<string name="slow_modules">A durat prea mult pentru pornirea modulelor, ia în considerare dezactivarea unor module</string>
1313
<string name="fail_internet">Conectarea la internet a eșuat</string>
14+
<string name="no_web_view">Nu s-a putut obține WebView de sistem</string>
1415
<string name="title_activity_settings">Setări activitate</string>
1516
<string name="app_update_available">Actualizare aplicație disponibilă</string>
1617
<string name="app_update">Actualizați</string>
@@ -87,4 +88,5 @@
8788
<string name="enable_blur_pref">Activează estomparea</string>
8889
<string name="repo_enabled">Depozit activat</string>
8990
<string name="repo_disabled">Depozit dezactivat</string>
91+
<string name="androidacy_repo_info">Depozitul Androidacy utilizează reclame și instrumente de urmărire.</string>
9092
</resources>

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ buildscript {
55
mavenCentral()
66
gradlePluginPortal()
77
}
8-
project.ext.latestAboutLibsRelease = "10.0.1"
8+
project.ext.latestAboutLibsRelease = "10.1.0"
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:7.1.2'
10+
classpath 'com.android.tools.build:gradle:7.1.3'
1111
classpath "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:${latestAboutLibsRelease}"
1212

1313
// NOTE: Do not place your application dependencies here; they belong

0 commit comments

Comments
 (0)