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

Commit 63224b7

Browse files
committed
Fix top inset bug, try to workaround no root/magisk issues.
1 parent 2a97cba commit 63224b7

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ public void commonNext() {
154154
runOnUiThread(() -> {
155155
progressIndicator.setIndeterminate(false);
156156
progressIndicator.setMax(PRECISION);
157+
// Fix insets not being accounted for correctly
158+
updateScreenInsets(getResources().getConfiguration());
157159
});
158160
Log.i(TAG, "Scanning for modules!");
159161
final int max = ModuleManager.getINSTANCE().getUpdatableModuleCount();

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void applyTo(final RecyclerView moduleList,final ModuleViewAdapter module
120120
moduleHolders.add(new ModuleHolder(notificationType));
121121
}
122122
}
123-
newNotificationsLen = this.notifications.size() - special;
123+
newNotificationsLen = this.notifications.size() + 1 - special;
124124
EnumSet<ModuleHolder.Type> headerTypes = EnumSet.of(ModuleHolder.Type.SEPARATOR,
125125
ModuleHolder.Type.NOTIFICATION, ModuleHolder.Type.FOOTER);
126126
Iterator<ModuleHolder> moduleHolderIterator = this.mappedModuleHolders.values().iterator();
@@ -170,7 +170,9 @@ public void applyTo(final RecyclerView moduleList,final ModuleViewAdapter module
170170
this.updateInsets = RUNNABLE;
171171
final EnumSet<NotificationType> oldNotifications =
172172
EnumSet.noneOf(NotificationType.class);
173-
boolean isTop = !moduleList.canScrollVertically(-1);
173+
boolean isTop = // Force isTop if empty
174+
moduleViewAdapter.moduleHolders.isEmpty() ||
175+
!moduleList.canScrollVertically(-1);
174176
boolean isBottom = !isTop && !moduleList.canScrollVertically(1);
175177
int oldNotificationsLen = 0;
176178
int oldOfflineModulesLen = 0;
@@ -199,10 +201,16 @@ public void applyTo(final RecyclerView moduleList,final ModuleViewAdapter module
199201
int oldLen = moduleViewAdapter.moduleHolders.size();
200202
moduleViewAdapter.moduleHolders.clear();
201203
moduleViewAdapter.moduleHolders.addAll(moduleHolders);
204+
synchronized (this.updateLock) {
205+
headerFooter[0].footerPx = this.headerPx;
206+
headerFooter[1].footerPx = this.footerPx;
207+
}
202208
if (oldNotificationsLen != newNotificationsLen ||
203209
!oldNotifications.equals(this.notifications)) {
204210
notifySizeChanged(moduleViewAdapter, 0,
205211
oldNotificationsLen, newNotificationsLen);
212+
} else {
213+
notifySizeChanged(moduleViewAdapter, 0, 1, 1);
206214
}
207215
if (newLen - newNotificationsLen == 0) {
208216
notifySizeChanged(moduleViewAdapter, newNotificationsLen,

app/src/main/java/com/fox2code/mmm/installer/InstallerInitializer.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
public class InstallerInitializer extends Shell.Initializer {
1717
private static final String TAG = "InstallerInitializer";
18+
private static final File MAGISK_SYSTEM =
19+
new File("/system/bin/magisk");
1820
private static String MAGISK_PATH;
1921
private static int MAGISK_VERSION_CODE;
2022

@@ -64,6 +66,9 @@ public void run() {
6466
}
6567
if (forceCheck) {
6668
InstallerInitializer.MAGISK_PATH = MAGISK_PATH;
69+
if (MAGISK_PATH == null) {
70+
InstallerInitializer.MAGISK_VERSION_CODE = 0;
71+
}
6772
}
6873
if (MAGISK_PATH != null) {
6974
MainApplication.setHasGottenRootAccess(true);
@@ -112,9 +117,15 @@ public boolean onInit(@NonNull Context context, @NonNull Shell shell) {
112117
Log.w(TAG, "Unable to detect magisk path!");
113118
} else {
114119
newJob.add("export ASH_STANDALONE=1");
115-
newJob.add("export PATH=\"" + MAGISK_PATH + "/.magisk/busybox;$PATH\"");
120+
if (!MAGISK_PATH.equals("/sbin") && !MAGISK_SYSTEM.exists()) {
121+
newJob.add("export PATH=" + MAGISK_PATH + ";$PATH;" +
122+
MAGISK_PATH + "/.magisk/busybox");
123+
} else {
124+
newJob.add("export PATH=$PATH;" +
125+
MAGISK_PATH + "/.magisk/busybox");
126+
}
116127
newJob.add("export MAGISKTMP=\"" + MAGISK_PATH + "/.magisk\"");
117-
newJob.add("busybox sh");
128+
newJob.add("$(which busybox 2> /dev/null) sh");
118129
}
119130
return true;
120131
}

0 commit comments

Comments
 (0)