Skip to content

Commit

Permalink
Fixes #42 (the answer to everything)
Browse files Browse the repository at this point in the history
  • Loading branch information
samolego committed Mar 15, 2024
1 parent fe4e826 commit 7f2444f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
7 changes: 3 additions & 4 deletions android/app/src/main/kotlin/org/samo_lego/canta/BloatUtils.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -29,7 +28,7 @@ class BloatUtils {

return json
} catch (e: Exception) {
return JSONArray()
return JSONObject()
}
}

Expand Down
12 changes: 6 additions & 6 deletions android/app/src/main/kotlin/org/samo_lego/canta/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions lib/components/dialogues/app_info_dialogue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 7f2444f

Please sign in to comment.