Expand interface for XPosed modules

pull/155/head
Fox2Code 2 years ago
parent c8f0b55415
commit c1613ec944

@ -8,6 +8,7 @@ import android.webkit.WebView;
import androidx.annotation.Keep;
import com.fox2code.mmm.manager.ModuleManager;
import com.fox2code.mmm.repo.RepoManager;
/**
* Class made to expose some manager functions to xposed modules.
@ -38,4 +39,14 @@ public class XHooks {
public static void onWebViewInitialize(WebView webView,boolean allowInstall) {
if (webView == null) throw new NullPointerException("WebView is null!");
}
@Keep
public static XRepo addXRepo(String url, String fallbackName) {
return RepoManager.getINSTANCE().addOrGet(url);
}
@Keep
public static XRepo getXRepo(String url) {
return RepoManager.getINSTANCE().get(url);
}
}

@ -0,0 +1,19 @@
package com.fox2code.mmm;
import androidx.annotation.Keep;
/**
* Class made to expose some repo functions to xposed modules.
* It will not be obfuscated on release builds
*/
@Keep
public abstract class XRepo {
@Keep
public abstract boolean isEnabledByDefault();
@Keep
public abstract boolean isEnabled();
@Keep
public abstract void setEnabled(boolean enabled);
}

@ -5,6 +5,7 @@ import android.content.SharedPreferences;
import com.fox2code.mmm.BuildConfig;
import com.fox2code.mmm.MainApplication;
import com.fox2code.mmm.R;
import com.fox2code.mmm.XRepo;
import com.fox2code.mmm.manager.ModuleInfo;
import com.fox2code.mmm.utils.Files;
import com.fox2code.mmm.utils.PropUtils;
@ -21,7 +22,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
public class RepoData {
public class RepoData extends XRepo {
private static final String TAG = "RepoData";
private final Object populateLock = new Object();
public final String url;
@ -43,7 +44,7 @@ public class RepoData {
this.moduleHashMap = new HashMap<>();
this.name = this.url; // Set url as default name
this.enabled = MainApplication.getSharedPreferences()
.getBoolean("pref_" + this.id + "_enabled", this.isEnabledByDefault(this.id));
.getBoolean("pref_" + this.id + "_enabled", this.isEnabledByDefault());
if (!this.cacheRoot.isDirectory()) {
this.cacheRoot.mkdirs();
} else {
@ -136,8 +137,9 @@ public class RepoData {
return newModules;
}
protected boolean isEnabledByDefault(String id) {
return !BuildConfig.DISABLED_REPOS.contains(id);
@Override
public boolean isEnabledByDefault() {
return !BuildConfig.DISABLED_REPOS.contains(this.id);
}
public void storeMetadata(RepoModule repoModule,byte[] data) throws IOException {
@ -170,10 +172,12 @@ public class RepoData {
fallback : this.name;
}
@Override
public boolean isEnabled() {
return this.enabled;
}
@Override
public void setEnabled(boolean enabled) {
this.enabled = enabled;
MainApplication.getSharedPreferences().edit()
@ -182,6 +186,6 @@ public class RepoData {
public void updateEnabledState() {
this.enabled = MainApplication.getSharedPreferences()
.getBoolean("pref_" + this.id + "_enabled", this.isEnabledByDefault(this.id));
.getBoolean("pref_" + this.id + "_enabled", this.isEnabledByDefault());
}
}

Loading…
Cancel
Save