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

Commit 7e6f02c

Browse files
committed
Add mmm.setAndroidacyToken() and for Androidacy integration.
1 parent 9cde329 commit 7e6f02c

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ public void run() {
254254
try {
255255
JSONObject jsonObject = new JSONObject();
256256
jsonObject.put("moduleId", moduleId);
257-
jsonObject.put("token", RepoManager.getINSTANCE()
258-
.getAndroidacyRepoData().getToken());
257+
jsonObject.put("token", AndroidacyRepoData
258+
.getInstance().getToken());
259259
jsonObject.put("_token", result);
260260
String realUrl = Http.doHttpPostRedirect(downloadUrl,
261261
jsonObject.toString(), true);

app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ private static String getCookies() {
8080
}
8181
}
8282

83+
public static AndroidacyRepoData getInstance() {
84+
return RepoManager.getINSTANCE().getAndroidacyRepoData();
85+
}
86+
8387
@Override
8488
protected boolean prepare() {
8589
// Implementation details discussed on telegram
@@ -308,4 +312,13 @@ public String getName() {
308312
String getToken() {
309313
return this.token;
310314
}
315+
316+
void setToken(String token) {
317+
if (Http.hasWebView()) {
318+
CookieManager.getInstance().setCookie("https://.androidacy.com/",
319+
"USER=" + token + "; expires=Fri, 31 Dec 9999 23:59:59 GMT;" +
320+
" path=/; secure; domain=.androidacy.com");
321+
this.token = token;
322+
}
323+
}
311324
}

app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyWebAPI.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ public class AndroidacyWebAPI {
4848
boolean downloadMode;
4949
int effectiveCompatMode;
5050
int notifiedCompatMode;
51-
String nonceToken;
52-
Runnable nonceTask;
5351

5452
public AndroidacyWebAPI(AndroidacyActivity activity, boolean allowInstall) {
5553
this.activity = activity;
@@ -66,8 +64,8 @@ void forceQuitRaw(String error) {
6664
void openNativeModuleDialogRaw(String moduleUrl, String installTitle,
6765
String checksum, boolean canInstall) {
6866
this.downloadMode = false;
69-
RepoModule repoModule = RepoManager.getINSTANCE()
70-
.getAndroidacyRepoData().moduleHashMap.get(installTitle);
67+
RepoModule repoModule = AndroidacyRepoData
68+
.getInstance().moduleHashMap.get(installTitle);
7169
String title, description;
7270
if (repoModule != null) {
7371
title = repoModule.moduleInfo.name;
@@ -246,8 +244,8 @@ public void install(String moduleUrl, String installTitle, String checksum) {
246244
this.openNativeModuleDialogRaw(moduleUrl, installTitle, checksum, true);
247245
}
248246
} else {
249-
RepoModule repoModule = RepoManager.getINSTANCE()
250-
.getAndroidacyRepoData().moduleHashMap.get(installTitle);
247+
RepoModule repoModule = AndroidacyRepoData
248+
.getInstance().moduleHashMap.get(installTitle);
251249
String config = null;
252250
if (repoModule != null && repoModule.moduleInfo.name.length() >= 3) {
253251
installTitle = repoModule.moduleInfo.name; // Set title to module name
@@ -510,13 +508,8 @@ public String getMonetColor(String id) {
510508
}
511509

512510
@JavascriptInterface
513-
public void setNonceToken(String nonceToken) {
514-
this.nonceToken = nonceToken;
515-
Runnable nonceTask = this.nonceTask;
516-
if (nonceTask != null) {
517-
this.nonceTask = null;
518-
nonceTask.run();
519-
}
511+
public void setAndroidacyToken(String token) {
512+
AndroidacyRepoData.getInstance().setToken(token);
520513
}
521514

522515
// Androidacy feature level declaration method

0 commit comments

Comments
 (0)