Skip to content

Commit

Permalink
feat: Upgrade to Kotlin 2.0 & enable enableStrongSkippingMode for com…
Browse files Browse the repository at this point in the history
…pose 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 <[email protected]>
  • Loading branch information
starry-shivam committed Jun 1, 2024
1 parent 2072d18 commit 6d214cf
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.iml
.gradle
.kotlin
/local.properties
/.idea/caches
/.idea/libraries
Expand Down
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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}'
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/starry/myne/helpers/Paginator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ package com.starry.myne.helpers
*/
class Paginator<Page, BookSet>(
private val initialPage: Page,
private inline val onLoadUpdated: (Boolean) -> Unit,
private inline val onRequest: suspend (nextPage: Page) -> Result<BookSet>,
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<BookSet>,
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
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/starry/myne/helpers/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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'
}
Expand All @@ -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
}

0 comments on commit 6d214cf

Please sign in to comment.