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

Commit c1613ec

Browse files
committed
Expand interface for XPosed modules
1 parent c8f0b55 commit c1613ec

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import androidx.annotation.Keep;
99

1010
import com.fox2code.mmm.manager.ModuleManager;
11+
import com.fox2code.mmm.repo.RepoManager;
1112

1213
/**
1314
* Class made to expose some manager functions to xposed modules.
@@ -38,4 +39,14 @@ public static Intent getConfigIntent(Context context, String packageName,String
3839
public static void onWebViewInitialize(WebView webView,boolean allowInstall) {
3940
if (webView == null) throw new NullPointerException("WebView is null!");
4041
}
42+
43+
@Keep
44+
public static XRepo addXRepo(String url, String fallbackName) {
45+
return RepoManager.getINSTANCE().addOrGet(url);
46+
}
47+
48+
@Keep
49+
public static XRepo getXRepo(String url) {
50+
return RepoManager.getINSTANCE().get(url);
51+
}
4152
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.fox2code.mmm;
2+
3+
import androidx.annotation.Keep;
4+
5+
/**
6+
* Class made to expose some repo functions to xposed modules.
7+
* It will not be obfuscated on release builds
8+
*/
9+
@Keep
10+
public abstract class XRepo {
11+
@Keep
12+
public abstract boolean isEnabledByDefault();
13+
14+
@Keep
15+
public abstract boolean isEnabled();
16+
17+
@Keep
18+
public abstract void setEnabled(boolean enabled);
19+
}

app/src/main/java/com/fox2code/mmm/repo/RepoData.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.fox2code.mmm.BuildConfig;
66
import com.fox2code.mmm.MainApplication;
77
import com.fox2code.mmm.R;
8+
import com.fox2code.mmm.XRepo;
89
import com.fox2code.mmm.manager.ModuleInfo;
910
import com.fox2code.mmm.utils.Files;
1011
import com.fox2code.mmm.utils.PropUtils;
@@ -21,7 +22,7 @@
2122
import java.util.Iterator;
2223
import java.util.List;
2324

24-
public class RepoData {
25+
public class RepoData extends XRepo {
2526
private static final String TAG = "RepoData";
2627
private final Object populateLock = new Object();
2728
public final String url;
@@ -43,7 +44,7 @@ protected RepoData(String url, File cacheRoot, SharedPreferences cachedPreferenc
4344
this.moduleHashMap = new HashMap<>();
4445
this.name = this.url; // Set url as default name
4546
this.enabled = MainApplication.getSharedPreferences()
46-
.getBoolean("pref_" + this.id + "_enabled", this.isEnabledByDefault(this.id));
47+
.getBoolean("pref_" + this.id + "_enabled", this.isEnabledByDefault());
4748
if (!this.cacheRoot.isDirectory()) {
4849
this.cacheRoot.mkdirs();
4950
} else {
@@ -136,8 +137,9 @@ protected List<RepoModule> populate(JSONObject jsonObject) throws JSONException
136137
return newModules;
137138
}
138139

139-
protected boolean isEnabledByDefault(String id) {
140-
return !BuildConfig.DISABLED_REPOS.contains(id);
140+
@Override
141+
public boolean isEnabledByDefault() {
142+
return !BuildConfig.DISABLED_REPOS.contains(this.id);
141143
}
142144

143145
public void storeMetadata(RepoModule repoModule,byte[] data) throws IOException {
@@ -170,10 +172,12 @@ public String getNameOrFallback(String fallback) {
170172
fallback : this.name;
171173
}
172174

175+
@Override
173176
public boolean isEnabled() {
174177
return this.enabled;
175178
}
176179

180+
@Override
177181
public void setEnabled(boolean enabled) {
178182
this.enabled = enabled;
179183
MainApplication.getSharedPreferences().edit()
@@ -182,6 +186,6 @@ public void setEnabled(boolean enabled) {
182186

183187
public void updateEnabledState() {
184188
this.enabled = MainApplication.getSharedPreferences()
185-
.getBoolean("pref_" + this.id + "_enabled", this.isEnabledByDefault(this.id));
189+
.getBoolean("pref_" + this.id + "_enabled", this.isEnabledByDefault());
186190
}
187191
}

0 commit comments

Comments
 (0)