From f0f4010f087c36f7a138100df04d00b00cf461e0 Mon Sep 17 00:00:00 2001 From: sjshb57 <1290848232a@gmail.com> Date: Wed, 7 Jan 2026 21:00:52 +0800 Subject: [PATCH 1/3] chore: migrate build scripts to Kotlin DSL && update dependencies --- .github/workflows/build.yml | 2 +- .github/workflows/publish.yml | 2 +- app/build.gradle | 104 --------------- app/build.gradle.kts | 118 ++++++++++++++++++ .../1.json | 81 ++++++++++++ build.gradle => build.gradle.kts | 6 +- gradle/libs.versions.toml | 34 ++--- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle => settings.gradle.kts | 6 +- 9 files changed, 227 insertions(+), 128 deletions(-) delete mode 100644 app/build.gradle create mode 100644 app/build.gradle.kts create mode 100644 app/schemas/com.github.capntrips.kernelflasher.common.types.room.AppDatabase/1.json rename build.gradle => build.gradle.kts (61%) rename settings.gradle => settings.gradle.kts (78%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d70463ac..aceb4f23 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -48,7 +48,7 @@ jobs: echo "NEW_VERSION_NAME=${new_version}" >> $GITHUB_ENV echo "NEW_VERSION_CODE=${version_code}" >> $GITHUB_ENV - - name: Update build.gradle with new version code and version name + - name: Update build.gradle.kts with new version code and version name run: | # Update versionCode and versionName in build.gradle sed -i "s/versionCode [0-9]\+/versionCode ${NEW_VERSION_CODE}/" app/build.gradle diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b473b3b6..5a49e1e2 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -72,7 +72,7 @@ jobs: echo "NEW_VERSION_NAME=${new_version}" >> $GITHUB_ENV echo "NEW_VERSION_CODE=${version_code}" >> $GITHUB_ENV - - name: Update build.gradle with new version code and version name + - name: Update build.gradle.kts with new version code and version name run: | # Update versionCode and versionName in build.gradle sed -i "s/versionCode [0-9]\+/versionCode ${NEW_VERSION_CODE}/" app/build.gradle diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index e0f97ec6..00000000 --- a/app/build.gradle +++ /dev/null @@ -1,104 +0,0 @@ -plugins { - alias(libs.plugins.android.application) - alias(libs.plugins.devtools.ksp) - alias(libs.plugins.kotlin.android) - alias(libs.plugins.kotlin.serialization) - alias(libs.plugins.compose.compiler) -} - -android { - compileSdk 35 - defaultConfig { - applicationId "com.github.capntrips.kernelflasher" - minSdk 29 - targetSdk 34 - versionCode 10600 - versionName "1.6.0" - - javaCompileOptions { - annotationProcessorOptions { - arguments += [ - "room.schemaLocation": "$projectDir/schemas".toString(), - "room.incremental": "true" - ] - } - } - ndk { - //noinspection ChromeOsAbiSupport - abiFilters = ['armeabi-v7a', 'arm64-v8a'] - } - vectorDrawables { - useSupportLibrary true - } - } - buildTypes { - release { - minifyEnabled true - shrinkResources true - zipAlignEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - sourceSets { - main { - jniLibs.srcDirs = ['src/main/jniLibs'] - } - } - buildFeatures { - compose true - aidl true - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = '17' - freeCompilerArgs += "-Xno-param-assertions" - freeCompilerArgs += "-Xno-call-assertions" - } - composeOptions { - kotlinCompilerExtensionVersion libs.versions.compose.compiler.get() - } - packagingOptions { - resources { - excludes += '/META-INF/{AL2.0,LGPL2.1}' - } - jniLibs { - useLegacyPackaging true - } - dex { - useLegacyPackaging true - } - } - androidResources { - generateLocaleConfig = true - } - namespace 'com.github.capntrips.kernelflasher' -} - -dependencies { - implementation(libs.androidx.activity.compose) - implementation(libs.androidx.appcompat) - implementation(libs.androidx.compose.material) - implementation(libs.androidx.compose.material3) - implementation(libs.androidx.compose.foundation) - implementation(libs.androidx.compose.ui) - implementation(libs.androidx.core.ktx) - implementation(libs.androidx.core.splashscreen) - implementation(libs.androidx.lifecycle.runtime.ktx) - implementation(libs.androidx.lifecycle.viewmodel.compose) - implementation(libs.androidx.navigation.compose) - implementation(libs.androidx.room.runtime) - annotationProcessor(libs.androidx.room.compiler) - ksp(libs.androidx.room.compiler) - implementation(libs.libsu.core) - implementation(libs.libsu.io) - implementation(libs.libsu.nio) - implementation(libs.libsu.service) - implementation(libs.material) - implementation(libs.okhttp) - implementation(libs.kotlinx.serialization.json) - implementation 'com.squareup.retrofit2:retrofit:3.0.0' - implementation 'com.squareup.retrofit2:converter-gson:3.0.0' -} \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 00000000..7c8c2aa3 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,118 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.devtools.ksp) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.serialization) + alias(libs.plugins.kotlin.compose.compiler) +} + +android { + compileSdk = 36 + namespace = "com.github.capntrips.kernelflasher" + + defaultConfig { + applicationId = "com.github.capntrips.kernelflasher" + minSdk = 29 + targetSdk = 36 + versionCode = 10600 + versionName = "1.6.0" + + javaCompileOptions { + annotationProcessorOptions { + arguments += mapOf( + "room.schemaLocation" to "$projectDir/schemas", + "room.incremental" to "true", + ) + } + } + + ndk { + //noinspection ChromeOsAbiSupport + abiFilters.add("arm64-v8a") + } + + vectorDrawables { + useSupportLibrary = true + } + } + + buildTypes { + release { + isMinifyEnabled = false + isShrinkResources = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" + ) + } + } + + sourceSets { + getByName("main") { + jniLibs.srcDirs("src/main/jniLibs") + } + } + + buildFeatures { + buildConfig = true + aidl = true + compose = true + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 + } + + kotlin { + jvmToolchain(21) + + } + + packaging { + resources { + excludes += setOf("/META-INF/{AL2.0,LGPL2.1}") + } + jniLibs { + useLegacyPackaging = true + } + dex { + useLegacyPackaging = true + } + } + + androidResources { + generateLocaleConfig = true + } + + ksp { + arg("room.schemaLocation", "$projectDir/schemas") + arg("room.incremental", "true") + } +} + + dependencies { + implementation(libs.androidx.activity.compose) + implementation(libs.androidx.appcompat) + implementation(libs.androidx.compose.material) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.foundation) + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.core.splashscreen) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.viewmodel.compose) + implementation(libs.androidx.navigation.compose) + implementation(libs.androidx.room.runtime) + annotationProcessor(libs.androidx.room.compiler) + ksp(libs.androidx.room.compiler) + implementation(libs.libsu.core) + implementation(libs.libsu.io) + implementation(libs.libsu.nio) + implementation(libs.libsu.service) + implementation(libs.material) + implementation(libs.okhttp) + implementation(libs.kotlinx.serialization.json) + implementation(libs.kotlinx.serialization.json) + implementation(libs.retrofit) + implementation(libs.converter.gson) + } \ No newline at end of file diff --git a/app/schemas/com.github.capntrips.kernelflasher.common.types.room.AppDatabase/1.json b/app/schemas/com.github.capntrips.kernelflasher.common.types.room.AppDatabase/1.json new file mode 100644 index 00000000..a1aa1369 --- /dev/null +++ b/app/schemas/com.github.capntrips.kernelflasher.common.types.room.AppDatabase/1.json @@ -0,0 +1,81 @@ +{ + "formatVersion": 1, + "database": { + "version": 1, + "identityHash": "bbe3033de836fa33fb2ed46b5272124e", + "entities": [ + { + "tableName": "Update", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER, `update_uri` TEXT, `kernel_name` TEXT NOT NULL, `kernel_version` TEXT NOT NULL, `kernel_link` TEXT NOT NULL, `kernel_changelog_url` TEXT NOT NULL, `kernel_date` INTEGER NOT NULL, `kernel_sha1` TEXT NOT NULL, `support_link` TEXT, `last_updated` INTEGER, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER" + }, + { + "fieldPath": "updateUri", + "columnName": "update_uri", + "affinity": "TEXT" + }, + { + "fieldPath": "kernelName", + "columnName": "kernel_name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "kernelVersion", + "columnName": "kernel_version", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "kernelLink", + "columnName": "kernel_link", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "kernelChangelogUrl", + "columnName": "kernel_changelog_url", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "kernelDate", + "columnName": "kernel_date", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "kernelSha1", + "columnName": "kernel_sha1", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "supportLink", + "columnName": "support_link", + "affinity": "TEXT" + }, + { + "fieldPath": "lastUpdated", + "columnName": "last_updated", + "affinity": "INTEGER" + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + } + } + ], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'bbe3033de836fa33fb2ed46b5272124e')" + ] + } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle.kts similarity index 61% rename from build.gradle rename to build.gradle.kts index 8b142f6f..ddadb811 100644 --- a/build.gradle +++ b/build.gradle.kts @@ -3,9 +3,9 @@ plugins { alias(libs.plugins.devtools.ksp) apply false alias(libs.plugins.kotlin.android) apply false alias(libs.plugins.kotlin.serialization) apply false - alias(libs.plugins.compose.compiler) apply false + // alias(libs.plugins.compose.compiler) apply false } -tasks.register('clean', Delete) { - delete rootProject.buildDir +tasks.register("clean", Delete::class) { + delete(rootProject.layout.buildDirectory) } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fecc67ed..1f91d686 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,23 +1,23 @@ [versions] -kotlin = "2.1.21" -compose-compiler = "1.5.6" +kotlin = "2.3.0" -androidx-activity-compose = "1.10.1" -androidx-appcompat = "1.7.0" -androidx-compose = "1.8.2" +androidx-activity-compose = "1.12.2" +androidx-appcompat = "1.7.1" +androidx-compose = "1.10.0" androidx-compose-material3 = "1.3.2" -androidx-core-ktx = "1.16.0" -androidx-core-splashscreen = "1.0.1" -androidx-lifecycle = "2.9.2" -androidx-navigation-compose = "2.9.0" -androidx-room = "2.7.1" -kotlinx-serialization-json = "1.8.1" +androidx-core-ktx = "1.17.0" +androidx-core-splashscreen = "1.2.0" +androidx-lifecycle = "2.10.0" +androidx-navigation-compose = "2.9.6" +androidx-room = "2.8.4" +kotlinx-serialization-json = "1.9.0" libsu = "6.0.0" -material = "1.12.0" -okhttp = "5.2.1" +material = "1.13.0" +okhttp = "5.3.2" -android-application = "8.10.0" -devtools-ksp = "2.1.20-2.0.1" +android-application = "8.13.2" +devtools-ksp = "2.3.4" +retrofit = "3.0.0" [libraries] androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "androidx-activity-compose" } @@ -33,6 +33,7 @@ androidx-lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "l androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "androidx-navigation-compose" } androidx-room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "androidx-room" } androidx-room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "androidx-room" } +converter-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofit" } kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinx-serialization-json" } libsu-core = { group = "com.github.topjohnwu.libsu", name = "core", version.ref = "libsu" } libsu-io = { group = "com.github.topjohnwu.libsu", name = "io", version.ref = "libsu" } @@ -40,10 +41,11 @@ libsu-nio = { group = "com.github.topjohnwu.libsu", name = "nio", version.ref = libsu-service = { group = "com.github.topjohnwu.libsu", name = "service", version.ref = "libsu" } material = { group = "com.google.android.material", name = "material", version.ref = "material" } okhttp = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttp" } +retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" } [plugins] android-application = { id = "com.android.application", version.ref = "android-application" } devtools-ksp = { id = "com.google.devtools.ksp", version.ref = "devtools-ksp" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } -compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } +kotlin-compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 338a8f78..7f839b65 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Fri Apr 14 13:36:42 CDT 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle.kts similarity index 78% rename from settings.gradle rename to settings.gradle.kts index 4fa6fbe4..35028225 100644 --- a/settings.gradle +++ b/settings.gradle.kts @@ -10,8 +10,10 @@ dependencyResolutionManagement { repositories { google() mavenCentral() - maven { url 'https://jitpack.io' } + maven { + url = uri("https://jitpack.io") + } } } rootProject.name = "Kernel Flasher" -include ':app' +include(":app") \ No newline at end of file From 0db2eeb8df10fd311470d86b369b265c794d0c19 Mon Sep 17 00:00:00 2001 From: sjshb57 <1290848232a@gmail.com> Date: Tue, 16 Jun 2026 12:52:26 +0800 Subject: [PATCH 2/3] build: upgrade Gradle to 9.5, AGP to 9.2, and update dependencies - Upgrade Gradle wrapper to 9.5.1 and Android Gradle Plugin to 9.2.1. - Update `compileSdk` to 37 and Kotlin to 2.4.0. - Configure Java 21 toolchain using the Foojay resolver convention. - Update multiple dependencies including Compose, Core-KTX, Activity, and Navigation. - Enable R8 minification and resource shrinking for release builds. - Migrate `ArrowBack` icons to `AutoMirrored` versions for better RTL support. - Refactor `UpdatesViewModel` and `BackupsContent` to improve null safety and use modern Kotlin idioms like `toUri()`. - Clean up `app/build.gradle.kts` structure and remove redundant plugins/dependencies. --- app/build.gradle.kts | 140 +++++++++--------- .../ui/screens/RefreshableScreen.kt | 4 +- .../ui/screens/backups/BackupsContent.kt | 3 +- .../ui/screens/updates/UpdatesViewModel.kt | 15 +- gradle.properties | 6 +- gradle/gradle-daemon-jvm.properties | 13 ++ gradle/libs.versions.toml | 20 +-- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle.kts | 3 + 9 files changed, 112 insertions(+), 94 deletions(-) create mode 100644 gradle/gradle-daemon-jvm.properties diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 7c8c2aa3..716da607 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,13 +1,12 @@ plugins { alias(libs.plugins.android.application) alias(libs.plugins.devtools.ksp) - alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.serialization) alias(libs.plugins.kotlin.compose.compiler) } android { - compileSdk = 36 + compileSdk = 37 namespace = "com.github.capntrips.kernelflasher" defaultConfig { @@ -34,85 +33,84 @@ android { vectorDrawables { useSupportLibrary = true } - } + } - buildTypes { - release { - isMinifyEnabled = false - isShrinkResources = false - proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" - ) - } + buildTypes { + release { + isMinifyEnabled = true + isShrinkResources = true + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" + ) } + } - sourceSets { - getByName("main") { - jniLibs.srcDirs("src/main/jniLibs") - } + sourceSets { + getByName("main") { + jniLibs.directories += "src/main/jniLibs" } + } - buildFeatures { - buildConfig = true - aidl = true - compose = true - } + buildFeatures { + buildConfig = true + aidl = true + compose = true + } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 - } - - kotlin { - jvmToolchain(21) + compileOptions { + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 + } + packaging { + resources { + excludes += setOf("/META-INF/{AL2.0,LGPL2.1}") } - - packaging { - resources { - excludes += setOf("/META-INF/{AL2.0,LGPL2.1}") - } - jniLibs { - useLegacyPackaging = true - } - dex { - useLegacyPackaging = true - } + jniLibs { + useLegacyPackaging = true } - - androidResources { - generateLocaleConfig = true + dex { + useLegacyPackaging = true } + } - ksp { - arg("room.schemaLocation", "$projectDir/schemas") - arg("room.incremental", "true") - } + androidResources { + generateLocaleConfig = true + } +} + +kotlin { + jvmToolchain(21) +} + +ksp { + arg("room.schemaLocation", "$projectDir/schemas") + arg("room.incremental", "true") } - dependencies { - implementation(libs.androidx.activity.compose) - implementation(libs.androidx.appcompat) - implementation(libs.androidx.compose.material) - implementation(libs.androidx.compose.material3) - implementation(libs.androidx.compose.foundation) - implementation(libs.androidx.compose.ui) - implementation(libs.androidx.core.ktx) - implementation(libs.androidx.core.splashscreen) - implementation(libs.androidx.lifecycle.runtime.ktx) - implementation(libs.androidx.lifecycle.viewmodel.compose) - implementation(libs.androidx.navigation.compose) - implementation(libs.androidx.room.runtime) - annotationProcessor(libs.androidx.room.compiler) - ksp(libs.androidx.room.compiler) - implementation(libs.libsu.core) - implementation(libs.libsu.io) - implementation(libs.libsu.nio) - implementation(libs.libsu.service) - implementation(libs.material) - implementation(libs.okhttp) - implementation(libs.kotlinx.serialization.json) - implementation(libs.kotlinx.serialization.json) - implementation(libs.retrofit) - implementation(libs.converter.gson) - } \ No newline at end of file +dependencies { + implementation(libs.androidx.activity.compose) + implementation(libs.androidx.appcompat) + implementation(libs.androidx.compose.material) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.material.icons.core) + implementation(libs.androidx.compose.foundation) + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.core.splashscreen) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.viewmodel.compose) + implementation(libs.androidx.navigation.compose) + implementation(libs.androidx.room.runtime) + annotationProcessor(libs.androidx.room.compiler) + ksp(libs.androidx.room.compiler) + implementation(libs.libsu.core) + implementation(libs.libsu.io) + implementation(libs.libsu.nio) + implementation(libs.libsu.service) + implementation(libs.material) + implementation(libs.okhttp) + implementation(libs.kotlinx.serialization.json) + implementation(libs.retrofit) + implementation(libs.converter.gson) +} \ No newline at end of file diff --git a/app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/RefreshableScreen.kt b/app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/RefreshableScreen.kt index 2d9af1d0..0c45e8eb 100644 --- a/app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/RefreshableScreen.kt +++ b/app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/RefreshableScreen.kt @@ -19,7 +19,7 @@ import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.pullrefresh.PullRefreshIndicator import androidx.compose.material.pullrefresh.pullRefresh import androidx.compose.material.pullrefresh.rememberPullRefreshState @@ -73,7 +73,7 @@ fun RefreshableScreen( modifier = Modifier.padding(16.dp, 8.dp, 0.dp, 8.dp) ) { Icon( - Icons.Filled.ArrowBack, + Icons.AutoMirrored.Filled.ArrowBack, contentDescription = stringResource(R.string.back), tint = MaterialTheme.colorScheme.onSurface ) diff --git a/app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/backups/BackupsContent.kt b/app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/backups/BackupsContent.kt index f502b7fb..8d886e68 100644 --- a/app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/backups/BackupsContent.kt +++ b/app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/backups/BackupsContent.kt @@ -47,8 +47,7 @@ fun ColumnScope.BackupsContent( DataCard (viewModel.currentBackup!!) { val cardWidth = remember { mutableIntStateOf(0) } val backupId = viewModel.currentBackup!! - val currentBackup = viewModel.backups[backupId] - if(currentBackup == null) return@DataCard + val currentBackup = viewModel.backups[backupId] ?: return@DataCard DataRow(stringResource(R.string.backup_type), currentBackup.type, mutableMaxWidth = cardWidth) DataRow(stringResource(R.string.kernel_version), currentBackup.kernelVersion, mutableMaxWidth = cardWidth, clickable = true) if (currentBackup.type == "raw") { diff --git a/app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/updates/UpdatesViewModel.kt b/app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/updates/UpdatesViewModel.kt index df2a6ef3..35fc9cd0 100644 --- a/app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/updates/UpdatesViewModel.kt +++ b/app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/updates/UpdatesViewModel.kt @@ -31,6 +31,7 @@ import java.util.Date import java.util.Locale import kotlin.io.path.Path import kotlin.io.path.name +import androidx.core.net.toUri @ExperimentalSerializationApi class UpdatesViewModel( @@ -73,8 +74,8 @@ class UpdatesViewModel( } try { block() - } catch (e: Exception) { - withContext (Dispatchers.Main) { + } catch (e: Throwable) { + withContext(Dispatchers.Main) { Log.e(TAG, e.message, e) navController.navigate("error/${e.message}") { popUpTo("main") @@ -112,7 +113,7 @@ class UpdatesViewModel( client.newCall(request).execute().use { response -> if (!response.isSuccessful) throw IOException("Unexpected response: $response") - val update: Update = Json.decodeFromString(UpdateSerializer, response.body!!.string()) + val update: Update = Json.decodeFromString(UpdateSerializer, response.body.string()) update.updateUri = url update.lastUpdated = Date() val updateId = updateDao.insert(update).toInt() @@ -133,7 +134,7 @@ class UpdatesViewModel( client.newCall(request).execute().use { response -> if (!response.isSuccessful) throw IOException("Unexpected response: $response") - val update: Update = Json.decodeFromString(UpdateSerializer, response.body!!.string()) + val update: Update = Json.decodeFromString(UpdateSerializer, response.body.string()) currentUpdate!!.let { withContext (Dispatchers.Main) { it.kernelName = update.kernelName @@ -161,7 +162,7 @@ class UpdatesViewModel( client.newCall(request).execute().use { response -> if (!response.isSuccessful) throw IOException("Unexpected response: $response") - changelog = response.body!!.string() + changelog = response.body.string() withContext (Dispatchers.Main) { callback.invoke() } @@ -180,7 +181,7 @@ class UpdatesViewModel( fun downloadKernel(context: Context) { launch { - val remoteUri = Uri.parse(currentUpdate!!.kernelLink) + val remoteUri = currentUpdate!!.kernelLink.toUri() val filename = Path(remoteUri.path!!).name val localUri = insertDownload(context, filename) localUri!!.let { uri -> @@ -190,7 +191,7 @@ class UpdatesViewModel( client.newCall(request).execute().use { response -> if (!response.isSuccessful) throw IOException("Unexpected response: $response") - response.body!!.byteStream().use { inputStream -> + response.body.byteStream().use { inputStream -> context.contentResolver.openOutputStream(uri)!!.use { outputStream -> inputStream.copyTo(outputStream) } diff --git a/gradle.properties b/gradle.properties index 506c3664..6929e443 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,5 +21,7 @@ kotlin.code.style=official # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library android.nonTransitiveRClass=true - -android.defaults.buildfeatures.buildconfig=true \ No newline at end of file +android.uniquePackageNames=false +android.dependency.useConstraints=true +android.r8.strictFullModeForKeepRules=false +android.generateSyncIssueWhenLibraryConstraintsAreEnabled=false \ No newline at end of file diff --git a/gradle/gradle-daemon-jvm.properties b/gradle/gradle-daemon-jvm.properties new file mode 100644 index 00000000..baa28d15 --- /dev/null +++ b/gradle/gradle-daemon-jvm.properties @@ -0,0 +1,13 @@ +#This file is generated by updateDaemonJvm +toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/491f83666ae7f4d6ebb28fee72ebb035/redirect +toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/0d1a1acdc708062093673f65aa9aba4b/redirect +toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/491f83666ae7f4d6ebb28fee72ebb035/redirect +toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/0d1a1acdc708062093673f65aa9aba4b/redirect +toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/7083b89563e7ce20943037b8cd2b8cc2/redirect +toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/060bbb778a1f55ea705fdebd2ccfeab9/redirect +toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/491f83666ae7f4d6ebb28fee72ebb035/redirect +toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/0d1a1acdc708062093673f65aa9aba4b/redirect +toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/d09679dc60fe5aa05ef7d03efdefac20/redirect +toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/ed4e3bf2f5e7c5d9aabc4cbd8acd555e/redirect +toolchainVendor=JETBRAINS +toolchainVersion=21 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1f91d686..160f9d33 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,21 +1,22 @@ [versions] -kotlin = "2.3.0" +kotlin = "2.4.0" -androidx-activity-compose = "1.12.2" +androidx-activity-compose = "1.13.0" androidx-appcompat = "1.7.1" -androidx-compose = "1.10.0" -androidx-compose-material3 = "1.3.2" -androidx-core-ktx = "1.17.0" +androidx-compose = "1.11.2" +androidx-compose-material3 = "1.4.0" +androidx-compose-material-icons = "1.7.8" +androidx-core-ktx = "1.19.0" androidx-core-splashscreen = "1.2.0" androidx-lifecycle = "2.10.0" -androidx-navigation-compose = "2.9.6" +androidx-navigation-compose = "2.9.8" androidx-room = "2.8.4" kotlinx-serialization-json = "1.9.0" libsu = "6.0.0" -material = "1.13.0" -okhttp = "5.3.2" +material = "1.14.0" +okhttp = "5.4.0" -android-application = "8.13.2" +android-application = "9.2.1" devtools-ksp = "2.3.4" retrofit = "3.0.0" @@ -24,6 +25,7 @@ androidx-activity-compose = { group = "androidx.activity", name = "activity-comp androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat" } androidx-compose-foundation = { group = "androidx.compose.foundation", name = "foundation", version.ref = "androidx-compose" } androidx-compose-material = { group = "androidx.compose.material", name = "material", version.ref = "androidx-compose" } +androidx-compose-material-icons-core = { group = "androidx.compose.material", name = "material-icons-core", version.ref = "androidx-compose-material-icons" } androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "androidx-compose-material3" } androidx-compose-ui = { group = "androidx.compose.ui", name="ui", version.ref = "androidx-compose" } androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidx-core-ktx" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7f839b65..cb496d17 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Fri Apr 14 13:36:42 CDT 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle.kts b/settings.gradle.kts index 35028225..07cc780b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,6 +5,9 @@ pluginManagement { mavenCentral() } } +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.10.0" +} dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { From 68ea675cae57788b13a72d7cdf0bb06e15a42ca9 Mon Sep 17 00:00:00 2001 From: sjshb57 <1290848232a@gmail.com> Date: Tue, 16 Jun 2026 13:18:13 +0800 Subject: [PATCH 3/3] refactor: catch Exception instead of Throwable in UpdatesViewModel && update KSP to 2.3.9 - In `UpdatesViewModel`, change error handling to catch `Exception` instead of `Throwable` to avoid capturing fatal system errors. - Update `devtools-ksp` from 2.3.4 to 2.3.9 in `libs.versions.toml`. --- .../kernelflasher/ui/screens/updates/UpdatesViewModel.kt | 2 +- gradle/libs.versions.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/updates/UpdatesViewModel.kt b/app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/updates/UpdatesViewModel.kt index 35fc9cd0..1a32974d 100644 --- a/app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/updates/UpdatesViewModel.kt +++ b/app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/updates/UpdatesViewModel.kt @@ -74,7 +74,7 @@ class UpdatesViewModel( } try { block() - } catch (e: Throwable) { + } catch (e: Exception) { withContext(Dispatchers.Main) { Log.e(TAG, e.message, e) navController.navigate("error/${e.message}") { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 160f9d33..85648e34 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -17,7 +17,7 @@ material = "1.14.0" okhttp = "5.4.0" android-application = "9.2.1" -devtools-ksp = "2.3.4" +devtools-ksp = "2.3.9" retrofit = "3.0.0" [libraries]