From f40af66788b0e7da5458d12d38833db3c8c9a81f Mon Sep 17 00:00:00 2001 From: Fox2Code Date: Fri, 3 Jun 2022 21:15:38 +0200 Subject: [PATCH] Update Androidacy API to support newest API format --- .../fox2code/mmm/androidacy/AndroidacyRepoData.java | 12 ++++++++++-- .../main/java/com/fox2code/mmm/repo/RepoData.java | 4 ++++ .../main/java/com/fox2code/mmm/repo/RepoUpdater.java | 2 +- app/src/main/res/xml/network_security_config.xml | 6 +++--- app/src/main/res/xml/root_preferences.xml | 7 ------- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java b/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java index 0e9d4bb..a87c4ee 100644 --- a/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java +++ b/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java @@ -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; + } } diff --git a/app/src/main/java/com/fox2code/mmm/repo/RepoData.java b/app/src/main/java/com/fox2code/mmm/repo/RepoData.java index 649c990..f55a472 100644 --- a/app/src/main/java/com/fox2code/mmm/repo/RepoData.java +++ b/app/src/main/java/com/fox2code/mmm/repo/RepoData.java @@ -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; + } } diff --git a/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java b/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java index 3781e15..74d8e30 100644 --- a/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java +++ b/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java @@ -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 diff --git a/app/src/main/res/xml/network_security_config.xml b/app/src/main/res/xml/network_security_config.xml index 9510e98..4271b6d 100644 --- a/app/src/main/res/xml/network_security_config.xml +++ b/app/src/main/res/xml/network_security_config.xml @@ -2,9 +2,9 @@ androidacy.com - - V6pbbd2/CCaa1dr+vGnpUrA1xoZ/GgncNuYzD26dikw= - FEzVOUp4dF3gI0ZVPRJhFbSJVXR+uQmMH65xhs1glH4= + + 6x/7mHVkS/6XLcenTc5gxonnGPTB1MD5mPQFqHTbfa4= + Y9mvm0exBk1JoQ57f9Vm28jKo5lFm/woKcVxrYxu80o= \ No newline at end of file diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml index 11ba3c0..11e32ce 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -62,13 +62,6 @@ app:title="@string/force_dark_terminal_title" app:singleLineTitle="false" /> - -