Hide scope if unsupported
This commit is contained in:
parent
88cb44b60b
commit
8358b1c500
|
|
@ -24,6 +24,7 @@ import org.meowcat.edxposed.manager.util.FileUtils;
|
|||
import org.meowcat.edxposed.manager.util.ModuleUtil;
|
||||
import org.meowcat.edxposed.manager.util.NotificationUtil;
|
||||
import org.meowcat.edxposed.manager.util.RepoLoader;
|
||||
import org.meowcat.edxposed.manager.util.Version;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
|
|
@ -79,6 +80,15 @@ public class App extends XposedApp implements Application.ActivityLifecycleCallb
|
|||
FileUtils.setPermissions(dir, permissions);
|
||||
}
|
||||
|
||||
public static boolean supportScope() {
|
||||
try {
|
||||
String version = App.getXposedProp().getVersion();
|
||||
return new Version(version.substring(6, 13)).compareTo(new Version("0.5.1.3")) >= 0;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
if (!BuildConfig.DEBUG) {
|
||||
|
|
|
|||
|
|
@ -528,6 +528,9 @@ public class ModulesActivity extends BaseActivity implements ModuleUtil.ModuleLi
|
|||
menu.removeItem(R.id.menu_download_updates);
|
||||
menu.removeItem(R.id.menu_support);
|
||||
}
|
||||
if (!App.supportScope()) {
|
||||
menu.removeItem(R.id.menu_scope);
|
||||
}
|
||||
if (installedModule.packageName.equals(BuildConfig.APPLICATION_ID)) {
|
||||
menu.removeItem(R.id.menu_launch);
|
||||
menu.removeItem(R.id.menu_scope);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
package org.meowcat.edxposed.manager.util;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public class Version implements Comparable<Version> {
|
||||
@NonNull
|
||||
public final int[] numbers;
|
||||
|
||||
public Version(@NonNull String version) {
|
||||
final String[] split = version.split("-")[0].split("\\.");
|
||||
numbers = new int[split.length];
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
numbers[i] = Integer.parseInt(split[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NonNull Version another) {
|
||||
final int maxLength = Math.max(numbers.length, another.numbers.length);
|
||||
for (int i = 0; i < maxLength; i++) {
|
||||
final int left = i < numbers.length ? numbers[i] : 0;
|
||||
final int right = i < another.numbers.length ? another.numbers[i] : 0;
|
||||
if (left != right) {
|
||||
return left < right ? -1 : 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue