From 7f2444f4c03c32d79abd9e27c2b91c6ee9824df0 Mon Sep 17 00:00:00 2001 From: samolego <34912839+samolego@users.noreply.github.com> Date: Fri, 15 Mar 2024 14:34:06 +0100 Subject: [PATCH] Fixes #42 (the answer to everything) --- .../main/kotlin/org/samo_lego/canta/BloatUtils.kt | 7 +++---- .../main/kotlin/org/samo_lego/canta/MainActivity.kt | 12 ++++++------ lib/components/dialogues/app_info_dialogue.dart | 1 + pubspec.yaml | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/android/app/src/main/kotlin/org/samo_lego/canta/BloatUtils.kt b/android/app/src/main/kotlin/org/samo_lego/canta/BloatUtils.kt index c5ed265..7075bc6 100644 --- a/android/app/src/main/kotlin/org/samo_lego/canta/BloatUtils.kt +++ b/android/app/src/main/kotlin/org/samo_lego/canta/BloatUtils.kt @@ -1,6 +1,5 @@ package org.samo_lego.canta -import org.json.JSONArray import org.json.JSONObject import java.io.File import java.net.URL @@ -11,12 +10,12 @@ class BloatUtils { private val BLOAT_COMMITS = "https://api.github.com/repos/Universal-Debloater-Alliance/universal-android-debloater-next-generation/commits?path=resources%2Fassets%2Fuad_lists.json" - fun fetchBloatList(uadList: File, config: File): JSONArray { + fun fetchBloatList(uadList: File, config: File): JSONObject { try { // Fetch json from BLOAT_URL and parse it val response = URL(BLOAT_URL).readText() // Parse response to json - val json = JSONArray(response) + val json = JSONObject(response) val commits = URL(BLOAT_COMMITS).readText() // Parse commits to get latest commit hash @@ -29,7 +28,7 @@ class BloatUtils { return json } catch (e: Exception) { - return JSONArray() + return JSONObject() } } diff --git a/android/app/src/main/kotlin/org/samo_lego/canta/MainActivity.kt b/android/app/src/main/kotlin/org/samo_lego/canta/MainActivity.kt index f7cd922..fd2e7cb 100644 --- a/android/app/src/main/kotlin/org/samo_lego/canta/MainActivity.kt +++ b/android/app/src/main/kotlin/org/samo_lego/canta/MainActivity.kt @@ -14,7 +14,7 @@ import android.util.Log import io.flutter.embedding.android.FlutterActivity import io.flutter.embedding.engine.FlutterEngine import io.flutter.plugin.common.MethodChannel -import org.json.JSONArray +import org.json.JSONObject import org.lsposed.hiddenapibypass.HiddenApiBypass import rikka.shizuku.Shizuku import rikka.sui.Sui @@ -44,22 +44,22 @@ class MainActivity : FlutterActivity() { val config = File(filesDir, "canta.conf") val bloatFetcher = BloatUtils() - val jsonList = + val uadLists = if (!uadList.exists() || !config.exists() || bloatFetcher.checkForUpdates(config)) { uadList.createNewFile() bloatFetcher.fetchBloatList(uadList, config) } else { // Just read the file - JSONArray(uadList.readText()) + JSONObject(uadList.readText()) } // Parse json to map - for (key in 0 until jsonList.length()) { - val json = jsonList.getJSONObject(key) + for (key in uadLists.keys()) { + val json = uadLists.getJSONObject(key) val bloatData = BloatData.fromJson(json) - BLOAT_LIST[json.getString("id")] = bloatData + BLOAT_LIST[key] = bloatData } } SETUP_THREAD.start() diff --git a/lib/components/dialogues/app_info_dialogue.dart b/lib/components/dialogues/app_info_dialogue.dart index 35b7dad..939e605 100644 --- a/lib/components/dialogues/app_info_dialogue.dart +++ b/lib/components/dialogues/app_info_dialogue.dart @@ -26,6 +26,7 @@ class AppInfoDialogue extends StatelessWidget { ), ), trailing: IconButton( + padding: const EdgeInsets.only(right: 8), onPressed: () => Navigator.of(context).pop(), icon: const Icon(Icons.close), ), diff --git a/pubspec.yaml b/pubspec.yaml index 195d7c0..6072fd7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.4.0+8 +version: 1.4.1+9 environment: sdk: '>=2.19.6 <3.0.0'