Update Androidacy API to support newest API format

pull/159/head
Fox2Code 2 years ago
parent d6829b7d11
commit f40af66788

@ -38,6 +38,7 @@ public class AndroidacyRepoData extends RepoData {
}
// Avoid spamming requests to Androidacy
private long androidacyBlockade = 0;
private String token = null;
public AndroidacyRepoData(String url, File cacheRoot,
SharedPreferences cachedPreferences) {
@ -82,7 +83,7 @@ public class AndroidacyRepoData extends RepoData {
}
if (token != null) {
try {
Http.doHttpGet("https://api.androidacy.com/auth/me",true);
Http.doHttpGet("https://api.androidacy.com/auth/me?token=" + token, true);
} catch (Exception e) {
if ("Received error code: 419".equals(e.getMessage()) ||
"Received error code: 429".equals(e.getMessage())) {
@ -99,7 +100,7 @@ public class AndroidacyRepoData extends RepoData {
Http.getCookieJar().saveFromResponse(
OK_HTTP_URL, Collections.emptyList());
}
token = null;
this.token = token = null;
}
}
if (token == null) {
@ -130,6 +131,7 @@ public class AndroidacyRepoData extends RepoData {
return false;
}
}
this.token = token;
return true;
}
@ -250,4 +252,10 @@ public class AndroidacyRepoData extends RepoData {
ModuleInfo.FLAG_METADATA_INVALID;
return false;
}
@Override
public String getUrl() {
return this.token == null ? this.url :
this.url + "?token=" + this.token;
}
}

@ -188,4 +188,8 @@ public class RepoData extends XRepo {
this.enabled = MainApplication.getSharedPreferences()
.getBoolean("pref_" + this.id + "_enabled", this.isEnabledByDefault());
}
public String getUrl() {
return this.url;
}
}

@ -40,7 +40,7 @@ public class RepoUpdater {
this.toApply = this.repoData.moduleHashMap.values();
return 0;
}
this.indexRaw = Http.doHttpGet(this.repoData.url, false);
this.indexRaw = Http.doHttpGet(this.repoData.getUrl(), false);
this.toUpdate = this.repoData.populate(new JSONObject(
new String(this.indexRaw, StandardCharsets.UTF_8)));
// Since we reuse instances this should work

@ -2,9 +2,9 @@
<network-security-config>
<domain-config>
<domain includeSubdomains="true">androidacy.com</domain>
<pin-set expiration="2023-01-02">
<pin digest="SHA-256">V6pbbd2/CCaa1dr+vGnpUrA1xoZ/GgncNuYzD26dikw=</pin>
<pin digest="SHA-256">FEzVOUp4dF3gI0ZVPRJhFbSJVXR+uQmMH65xhs1glH4=</pin>
<pin-set expiration="2023-03-16">
<pin digest="SHA-256">6x/7mHVkS/6XLcenTc5gxonnGPTB1MD5mPQFqHTbfa4=</pin>
<pin digest="SHA-256">Y9mvm0exBk1JoQ57f9Vm28jKo5lFm/woKcVxrYxu80o=</pin>
</pin-set>
</domain-config>
</network-security-config>

@ -62,13 +62,6 @@
app:title="@string/force_dark_terminal_title"
app:singleLineTitle="false" />
<SwitchPreferenceCompat
app:defaultValue="false"
app:key="pref_disable_chips"
app:icon="@drawable/ic_baseline_chip_24"
app:title="@string/disable_chips_in_description"
app:singleLineTitle="false" />
<SwitchPreferenceCompat
app:defaultValue="false"
app:key="pref_enable_monet"

Loading…
Cancel
Save