mirror of
https://github.com/gedoor/legado.git
synced 2024-07-04 23:36:56 +08:00
支持kotlin 1.9.0
更新kotlin 1.9.0 迁移到ksp
This commit is contained in:
parent
d592122192
commit
953a947715
|
@ -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'
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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")
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -286,15 +286,15 @@ interface BookSourceDao {
|
|||
}
|
||||
}
|
||||
|
||||
val allGroups: List<String>
|
||||
get() {
|
||||
return dealGroups(allGroupsUnProcessed)
|
||||
}
|
||||
fun allGroups(): List<String> = dealGroups(allGroupsUnProcessed)
|
||||
// get() {
|
||||
// return dealGroups(allGroupsUnProcessed)
|
||||
// }
|
||||
|
||||
val allEnabledGroups: List<String>
|
||||
get() {
|
||||
return dealGroups(allEnabledGroupsUnProcessed)
|
||||
}
|
||||
fun allEnabledGroups(): List<String> = dealGroups(allEnabledGroupsUnProcessed)
|
||||
// get() {
|
||||
// return dealGroups(allEnabledGroupsUnProcessed)
|
||||
// }
|
||||
|
||||
fun flowGroups(): Flow<List<String>> {
|
||||
return flowGroupsUnProcessed().map { list ->
|
||||
|
|
|
@ -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 ->
|
||||
|
|
|
@ -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 ->
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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'
|
||||
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
6
gradle/wrapper/gradle-wrapper.properties
vendored
6
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user