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

Commit f40af66

Browse files
committed
Update Androidacy API to support newest API format
1 parent d6829b7 commit f40af66

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class AndroidacyRepoData extends RepoData {
3838
}
3939
// Avoid spamming requests to Androidacy
4040
private long androidacyBlockade = 0;
41+
private String token = null;
4142

4243
public AndroidacyRepoData(String url, File cacheRoot,
4344
SharedPreferences cachedPreferences) {
@@ -82,7 +83,7 @@ protected boolean prepare() {
8283
}
8384
if (token != null) {
8485
try {
85-
Http.doHttpGet("https://api.androidacy.com/auth/me",true);
86+
Http.doHttpGet("https://api.androidacy.com/auth/me?token=" + token, true);
8687
} catch (Exception e) {
8788
if ("Received error code: 419".equals(e.getMessage()) ||
8889
"Received error code: 429".equals(e.getMessage())) {
@@ -99,7 +100,7 @@ protected boolean prepare() {
99100
Http.getCookieJar().saveFromResponse(
100101
OK_HTTP_URL, Collections.emptyList());
101102
}
102-
token = null;
103+
this.token = token = null;
103104
}
104105
}
105106
if (token == null) {
@@ -130,6 +131,7 @@ protected boolean prepare() {
130131
return false;
131132
}
132133
}
134+
this.token = token;
133135
return true;
134136
}
135137

@@ -250,4 +252,10 @@ public boolean tryLoadMetadata(RepoModule repoModule) {
250252
ModuleInfo.FLAG_METADATA_INVALID;
251253
return false;
252254
}
255+
256+
@Override
257+
public String getUrl() {
258+
return this.token == null ? this.url :
259+
this.url + "?token=" + this.token;
260+
}
253261
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,8 @@ public void updateEnabledState() {
188188
this.enabled = MainApplication.getSharedPreferences()
189189
.getBoolean("pref_" + this.id + "_enabled", this.isEnabledByDefault());
190190
}
191+
192+
public String getUrl() {
193+
return this.url;
194+
}
191195
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public int fetchIndex() {
4040
this.toApply = this.repoData.moduleHashMap.values();
4141
return 0;
4242
}
43-
this.indexRaw = Http.doHttpGet(this.repoData.url, false);
43+
this.indexRaw = Http.doHttpGet(this.repoData.getUrl(), false);
4444
this.toUpdate = this.repoData.populate(new JSONObject(
4545
new String(this.indexRaw, StandardCharsets.UTF_8)));
4646
// Since we reuse instances this should work

app/src/main/res/xml/network_security_config.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<network-security-config>
33
<domain-config>
44
<domain includeSubdomains="true">androidacy.com</domain>
5-
<pin-set expiration="2023-01-02">
6-
<pin digest="SHA-256">V6pbbd2/CCaa1dr+vGnpUrA1xoZ/GgncNuYzD26dikw=</pin>
7-
<pin digest="SHA-256">FEzVOUp4dF3gI0ZVPRJhFbSJVXR+uQmMH65xhs1glH4=</pin>
5+
<pin-set expiration="2023-03-16">
6+
<pin digest="SHA-256">6x/7mHVkS/6XLcenTc5gxonnGPTB1MD5mPQFqHTbfa4=</pin>
7+
<pin digest="SHA-256">Y9mvm0exBk1JoQ57f9Vm28jKo5lFm/woKcVxrYxu80o=</pin>
88
</pin-set>
99
</domain-config>
1010
</network-security-config>

app/src/main/res/xml/root_preferences.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,6 @@
6262
app:title="@string/force_dark_terminal_title"
6363
app:singleLineTitle="false" />
6464

65-
<SwitchPreferenceCompat
66-
app:defaultValue="false"
67-
app:key="pref_disable_chips"
68-
app:icon="@drawable/ic_baseline_chip_24"
69-
app:title="@string/disable_chips_in_description"
70-
app:singleLineTitle="false" />
71-
7265
<SwitchPreferenceCompat
7366
app:defaultValue="false"
7467
app:key="pref_enable_monet"

0 commit comments

Comments
 (0)