Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持kotlin 1.9.0 #3247

Merged
merged 1 commit into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ plugins {
id "com.android.application"
id 'org.jetbrains.kotlin.android'
id 'kotlin-parcelize'
id 'kotlin-kapt'
//id 'kotlin-kapt'
id 'com.google.devtools.ksp'
//id "com.google.gms.google-services"
}
apply from: 'download.gradle'
Expand Down Expand Up @@ -111,6 +112,14 @@ android {
}
}

// 设定Room的KSP参数
ksp {
arg("room.incremental", "true")
arg("room.expandProjection", "true")
arg("room.schemaLocation", "$projectDir/schemas")

}

compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
Expand Down Expand Up @@ -194,7 +203,8 @@ dependencies {
//room sql语句不高亮解决方法https://issuetracker.google.com/issues/234612964#comment6
implementation("androidx.room:room-runtime:$room_version")
implementation("androidx.room:room-ktx:$room_version")
kapt("androidx.room:room-compiler:$room_version")
//kapt("androidx.room:room-compiler:$room_version")
ksp("androidx.room:room-compiler:$room_version")
androidTestImplementation("androidx.room:room-testing:$room_version")

//liveEventBus
Expand All @@ -219,7 +229,8 @@ dependencies {
//Glide
def glideVersion = "4.15.1"
implementation("com.github.bumptech.glide:glide:$glideVersion")
kapt("com.github.bumptech.glide:compiler:$glideVersion")
//kapt("com.github.bumptech.glide:compiler:$glideVersion")
ksp("com.github.bumptech.glide:ksp:$glideVersion")

//Svg
implementation("com.caverock:androidsvg-aar:1.4")
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import io.legado.app.data.entities.BookGroup
import kotlinx.coroutines.flow.Flow

@Dao
interface BookGroupDao {
abstract interface BookGroupDao {

@Query("select * from book_groups where groupId = :id")
fun getByID(id: Long): BookGroup?
Expand Down
18 changes: 9 additions & 9 deletions app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,15 @@ interface BookSourceDao {
}
}

val allGroups: List<String>
get() {
return dealGroups(allGroupsUnProcessed)
}

val allEnabledGroups: List<String>
get() {
return dealGroups(allEnabledGroupsUnProcessed)
}
fun allGroups(): List<String> = dealGroups(allGroupsUnProcessed)
// get() {
// return dealGroups(allGroupsUnProcessed)
// }

fun allEnabledGroups(): List<String> = dealGroups(allEnabledGroupsUnProcessed)
// get() {
// return dealGroups(allEnabledGroupsUnProcessed)
// }

fun flowGroups(): Flow<List<String>> {
return flowGroupsUnProcessed().map { list ->
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/io/legado/app/data/dao/ReplaceRuleDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ interface ReplaceRuleDao {
}
}

val allGroups: List<String>
get() {
return dealGroups(allGroupsUnProcessed)
}
fun allGroups(): List<String> =dealGroups(allGroupsUnProcessed)
// get() {
// return dealGroups(allGroupsUnProcessed)
// }

fun flowGroups(): Flow<List<String>> {
return flowGroupsUnProcessed().map { list ->
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/io/legado/app/data/dao/RssSourceDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ interface RssSourceDao {
}
}

val allGroups: List<String>
get() {
return dealGroups(allGroupsUnProcessed)
}
fun allGroups(): List<String> =dealGroups(allGroupsUnProcessed)
// get() {
// return dealGroups(allGroupsUnProcessed)
// }

fun flowGroups(): Flow<List<String>> {
return flowGroupsUnProcessed().map { list ->
Expand Down
49 changes: 26 additions & 23 deletions app/src/main/java/io/legado/app/help/glide/ImageLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.net.Uri
import androidx.annotation.DrawableRes
import com.bumptech.glide.Glide
import com.bumptech.glide.RequestBuilder
import io.legado.app.utils.isAbsUrl
import io.legado.app.utils.isContentScheme
import io.legado.app.utils.isDataUrl
import java.io.File

//https://bumptech.github.io/glide/doc/generatedapi.html
//Instead of GlideApp, use com.bumptech.Glide
@Suppress("unused")
object ImageLoader {

Expand All @@ -19,67 +22,67 @@ object ImageLoader {
*/
fun load(context: Context, path: String?): RequestBuilder<Drawable> {
return when {
path.isNullOrEmpty() -> GlideApp.with(context).load(path)
path.isDataUrl() -> GlideApp.with(context).load(path)
path.isAbsUrl() -> GlideApp.with(context).load(path)
path.isContentScheme() -> GlideApp.with(context).load(Uri.parse(path))
path.isNullOrEmpty() -> Glide.with(context).load(path)
path.isDataUrl() -> Glide.with(context).load(path)
path.isAbsUrl() -> Glide.with(context).load(path)
path.isContentScheme() -> Glide.with(context).load(Uri.parse(path))
else -> kotlin.runCatching {
GlideApp.with(context).load(File(path))
Glide.with(context).load(File(path))
}.getOrElse {
GlideApp.with(context).load(path)
Glide.with(context).load(path)
}
}
}

fun loadBitmap(context: Context, path: String?): RequestBuilder<Bitmap> {
return when {
path.isNullOrEmpty() -> GlideApp.with(context).asBitmap().load(path)
path.isDataUrl() -> GlideApp.with(context).asBitmap().load(path)
path.isAbsUrl() -> GlideApp.with(context).asBitmap().load(path)
path.isContentScheme() -> GlideApp.with(context).asBitmap().load(Uri.parse(path))
path.isNullOrEmpty() -> Glide.with(context).asBitmap().load(path)
path.isDataUrl() -> Glide.with(context).asBitmap().load(path)
path.isAbsUrl() -> Glide.with(context).asBitmap().load(path)
path.isContentScheme() -> Glide.with(context).asBitmap().load(Uri.parse(path))
else -> kotlin.runCatching {
GlideApp.with(context).asBitmap().load(File(path))
Glide.with(context).asBitmap().load(File(path))
}.getOrElse {
GlideApp.with(context).asBitmap().load(path)
Glide.with(context).asBitmap().load(path)
}
}
}

fun loadFile(context: Context, path: String?): RequestBuilder<File> {
return when {
path.isNullOrEmpty() -> GlideApp.with(context).asFile().load(path)
path.isAbsUrl() -> GlideApp.with(context).asFile().load(path)
path.isContentScheme() -> GlideApp.with(context).asFile().load(Uri.parse(path))
path.isNullOrEmpty() -> Glide.with(context).asFile().load(path)
path.isAbsUrl() -> Glide.with(context).asFile().load(path)
path.isContentScheme() -> Glide.with(context).asFile().load(Uri.parse(path))
else -> kotlin.runCatching {
GlideApp.with(context).asFile().load(File(path))
Glide.with(context).asFile().load(File(path))
}.getOrElse {
GlideApp.with(context).asFile().load(path)
Glide.with(context).asFile().load(path)
}
}
}

fun load(context: Context, @DrawableRes resId: Int?): RequestBuilder<Drawable> {
return GlideApp.with(context).load(resId)
return Glide.with(context).load(resId)
}

fun load(context: Context, file: File?): RequestBuilder<Drawable> {
return GlideApp.with(context).load(file)
return Glide.with(context).load(file)
}

fun load(context: Context, uri: Uri?): RequestBuilder<Drawable> {
return GlideApp.with(context).load(uri)
return Glide.with(context).load(uri)
}

fun load(context: Context, drawable: Drawable?): RequestBuilder<Drawable> {
return GlideApp.with(context).load(drawable)
return Glide.with(context).load(drawable)
}

fun load(context: Context, bitmap: Bitmap?): RequestBuilder<Drawable> {
return GlideApp.with(context).load(bitmap)
return Glide.with(context).load(bitmap)
}

fun load(context: Context, bytes: ByteArray?): RequestBuilder<Drawable> {
return GlideApp.with(context).load(bytes)
return Glide.with(context).load(bytes)
}

}
4 changes: 2 additions & 2 deletions app/src/main/java/io/legado/app/service/AudioPlayService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ class AudioPlayService : BaseService(),
/**
* 调节速度
*/

@SuppressLint(value = ["ObsoleteSdkInt"])
private fun upSpeed(adjust: Float) {
kotlin.runCatching {
@SuppressLint("ObsoleteSdkInt")

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
playSpeed += adjust
exoPlayer.setPlaybackSpeed(playSpeed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class ImportBookSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_vie
private fun alertCustomGroup(item: MenuItem) {
alert(R.string.diy_edit_source_group) {
val alertBinding = DialogCustomGroupBinding.inflate(layoutInflater).apply {
val groups = appDb.bookSourceDao.allGroups
val groups = appDb.bookSourceDao.allGroups()
textInputLayout.setHint(R.string.group_name)
editView.setFilterValues(groups.toList())
editView.dropDownHeight = 180.dpToPx()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class ImportReplaceRuleDialog() : BaseDialogFragment(R.layout.dialog_recycler_vi
private fun alertCustomGroup(item: MenuItem) {
alert(R.string.diy_edit_source_group) {
val alertBinding = DialogCustomGroupBinding.inflate(layoutInflater).apply {
val groups = appDb.replaceRuleDao.allGroups
val groups = appDb.replaceRuleDao.allGroups()
textInputLayout.setHint(R.string.group_name)
editView.setFilterValues(groups.toList())
editView.dropDownHeight = 180.dpToPx()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class ImportRssSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_view
private fun alertCustomGroup(item: MenuItem) {
alert(R.string.diy_edit_source_group) {
val alertBinding = DialogCustomGroupBinding.inflate(layoutInflater).apply {
val groups = appDb.rssSourceDao.allGroups
val groups = appDb.rssSourceDao.allGroups()
textInputLayout.setHint(R.string.group_name)
editView.setFilterValues(groups.toList())
editView.dropDownHeight = 180.dpToPx()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class SearchScopeDialog : BaseDialogFragment(R.layout.dialog_search_scope) {
private fun initData() {
launch {
groups = withContext(IO) {
appDb.bookSourceDao.allEnabledGroups
appDb.bookSourceDao.allEnabledGroups()
}
sources = withContext(IO) {
appDb.bookSourceDao.allEnabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ class BookSourceEditActivity :
private fun alertGroups() {
launch {
val groups = withContext(IO) {
appDb.bookSourceDao.allGroups
appDb.bookSourceDao.allGroups()
}
selector(groups) { _, s, _ ->
sendText(s)
Expand Down
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ buildscript {
ext{
compile_sdk_version = 33
build_tool_version = '33.0.1'
kotlin_version = '1.8.22'
kotlin_version = '1.9.0'
ksp_version="1.0.12"
agp_version = '8.0.2'
media3_version = "1.1.0"
splitties_version = '3.0.0'
Expand All @@ -16,6 +17,7 @@ plugins {
id 'com.android.application' version "$agp_version" apply false
id 'com.android.library' version "$agp_version" apply false
id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false
id 'com.google.devtools.ksp' version "$kotlin_version-$ksp_version" apply false
id "de.undercouch.download" version "5.4.0" apply false
id "com.google.gms.google-services" version "4.3.15" apply false
}
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ android.enableJetifier=false
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
kotlin.incremental.useClasspathSnapshot=true
kotlin.experimental.tryK2=true
android.enableResourceOptimizations=true
# android.enableNewResourceShrinker' is deprecated.
# It was removed in version 8.0 of the Android Gradle plugin.
Expand Down
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Sep 26 08:03:55 CST 2022
#Sat Jul 22 18:39:27 CST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists