From 6d214cff05dd01418dbd350818dbabac3bfbebe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C9=91rry=20Shiv=C9=91m?= Date: Tue, 28 May 2024 07:59:58 +0530 Subject: [PATCH] feat: Upgrade to Kotlin 2.0 & enable enableStrongSkippingMode for compose compiler (#178) See: https://kotlinlang.org/docs/whatsnew20.html While on that, also optimise MIUI checker function to not run on non Xiaomi devices. --------- Signed-off-by: starry-shivam --- .gitignore | 1 + .idea/kotlinc.xml | 2 +- app/build.gradle | 11 ++++++----- .../main/java/com/starry/myne/helpers/Paginator.kt | 10 +++++----- app/src/main/java/com/starry/myne/helpers/Utils.kt | 5 +++++ build.gradle | 7 ++++--- 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index aa724b77..04f46af2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.iml .gradle +.kotlin /local.properties /.idea/caches /.idea/libraries diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index 8d81632f..6d0ee1c2 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index d2b4576f..81816a18 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,7 @@ plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' + id 'org.jetbrains.kotlin.plugin.compose' id 'dagger.hilt.android.plugin' id 'com.google.devtools.ksp' id "com.mikepenz.aboutlibraries.plugin" version "11.1.3" @@ -61,19 +62,19 @@ android { targetCompatibility JavaVersion.VERSION_17 } lintOptions { - abortOnError false + abortOnError true } kotlinOptions { jvmTarget = '17' freeCompilerArgs = ['-Xjvm-default=all-compatibility'] } + composeCompiler { + enableStrongSkippingMode = true + } buildFeatures { compose true buildConfig = true } - composeOptions { - kotlinCompilerExtensionVersion '1.5.10' - } packagingOptions { resources { excludes += '/META-INF/{AL2.0,LGPL2.1}' @@ -135,7 +136,7 @@ dependencies { // Lottie animations. implementation "com.airbnb.android:lottie-compose:6.4.0" // TapTarget Compose - implementation "com.pierfrancescosoffritti.taptargetcompose:core:1.1.1" + implementation "com.pierfrancescosoffritti.taptargetcompose:core:1.1.2" // DataStore Preferences. implementation("androidx.datastore:datastore-preferences:1.1.1") // Open Source Libraries Screen. diff --git a/app/src/main/java/com/starry/myne/helpers/Paginator.kt b/app/src/main/java/com/starry/myne/helpers/Paginator.kt index 420fffb1..e0e18934 100644 --- a/app/src/main/java/com/starry/myne/helpers/Paginator.kt +++ b/app/src/main/java/com/starry/myne/helpers/Paginator.kt @@ -30,11 +30,11 @@ package com.starry.myne.helpers */ class Paginator( private val initialPage: Page, - private inline val onLoadUpdated: (Boolean) -> Unit, - private inline val onRequest: suspend (nextPage: Page) -> Result, - private inline val getNextPage: suspend (BookSet) -> Page, - private inline val onError: suspend (Throwable?) -> Unit, - private inline val onSuccess: suspend (item: BookSet, newPage: Page) -> Unit + private val onLoadUpdated: (Boolean) -> Unit, + private val onRequest: suspend (nextPage: Page) -> Result, + private val getNextPage: suspend (BookSet) -> Page, + private val onError: suspend (Throwable?) -> Unit, + private val onSuccess: suspend (item: BookSet, newPage: Page) -> Unit ) { private var currentPage = initialPage diff --git a/app/src/main/java/com/starry/myne/helpers/Utils.kt b/app/src/main/java/com/starry/myne/helpers/Utils.kt index fcad3cba..13aac783 100644 --- a/app/src/main/java/com/starry/myne/helpers/Utils.kt +++ b/app/src/main/java/com/starry/myne/helpers/Utils.kt @@ -17,6 +17,7 @@ package com.starry.myne.helpers +import android.os.Build import java.io.BufferedReader import java.io.IOException import java.io.InputStreamReader @@ -57,6 +58,10 @@ object Utils { * @return True if the device is running on MIUI, false otherwise */ fun isMiui(excludeHyperOS: Boolean = true): Boolean { + // Return false if the device is not from Xiaomi, Redmi, or POCO. + val brand = Build.BRAND.lowercase() + if (!setOf("xiaomi", "redmi", "poco").contains(brand)) return false + // Check if the device is running on MIUI and not HyperOS. val isMiui = !getProperty("ro.miui.ui.version.name").isNullOrBlank() val isHyperOS = !getProperty("ro.mi.os.version.name").isNullOrBlank() return isMiui && (!excludeHyperOS || !isHyperOS) diff --git a/build.gradle b/build.gradle index 5e133756..50d2c105 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ buildscript { ext { - kotlin_version = '1.9.22' - gradle_version = '8.4.0' + kotlin_version = '2.0.0' + gradle_version = '8.4.1' hilt_version = '2.50' room_version = '2.6.1' } @@ -24,5 +24,6 @@ plugins { id 'com.android.application' version "$gradle_version" apply false id 'com.android.library' version "$gradle_version" apply false id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false - id 'com.google.devtools.ksp' version '1.9.22-1.0.17' apply false + id 'org.jetbrains.kotlin.plugin.compose' version "$kotlin_version" apply false + id 'com.google.devtools.ksp' version '2.0.0-1.0.21' apply false } \ No newline at end of file