Merge pull request #3247 from ag2s20150909/master

支持kotlin 1.9.0
This commit is contained in:
kunfei
2023-07-22 21:55:57 +08:00
committed by GitHub
15 changed files with 71 additions and 54 deletions
+14 -3
View File
@@ -2,7 +2,8 @@ plugins {
id "com.android.application" id "com.android.application"
id 'org.jetbrains.kotlin.android' id 'org.jetbrains.kotlin.android'
id 'kotlin-parcelize' id 'kotlin-parcelize'
id 'kotlin-kapt' //id 'kotlin-kapt'
id 'com.google.devtools.ksp'
//id "com.google.gms.google-services" //id "com.google.gms.google-services"
} }
apply from: 'download.gradle' 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 { compileOptions {
// Flag to enable support for the new language APIs // Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true coreLibraryDesugaringEnabled true
@@ -194,7 +203,8 @@ dependencies {
//room sql语句不高亮解决方法https://issuetracker.google.com/issues/234612964#comment6 //room sql语句不高亮解决方法https://issuetracker.google.com/issues/234612964#comment6
implementation("androidx.room:room-runtime:$room_version") implementation("androidx.room:room-runtime:$room_version")
implementation("androidx.room:room-ktx:$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") androidTestImplementation("androidx.room:room-testing:$room_version")
//liveEventBus //liveEventBus
@@ -219,7 +229,8 @@ dependencies {
//Glide //Glide
def glideVersion = "4.15.1" def glideVersion = "4.15.1"
implementation("com.github.bumptech.glide:glide:$glideVersion") 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 //Svg
implementation("com.caverock:androidsvg-aar:1.4") implementation("com.caverock:androidsvg-aar:1.4")
@@ -7,7 +7,7 @@ import io.legado.app.data.entities.BookGroup
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
@Dao @Dao
interface BookGroupDao { abstract interface BookGroupDao {
@Query("select * from book_groups where groupId = :id") @Query("select * from book_groups where groupId = :id")
fun getByID(id: Long): BookGroup? fun getByID(id: Long): BookGroup?
@@ -286,15 +286,15 @@ interface BookSourceDao {
} }
} }
val allGroups: List<String> fun allGroups(): List<String> = dealGroups(allGroupsUnProcessed)
get() { // get() {
return dealGroups(allGroupsUnProcessed) // return dealGroups(allGroupsUnProcessed)
} // }
val allEnabledGroups: List<String> fun allEnabledGroups(): List<String> = dealGroups(allEnabledGroupsUnProcessed)
get() { // get() {
return dealGroups(allEnabledGroupsUnProcessed) // return dealGroups(allEnabledGroupsUnProcessed)
} // }
fun flowGroups(): Flow<List<String>> { fun flowGroups(): Flow<List<String>> {
return flowGroupsUnProcessed().map { list -> return flowGroupsUnProcessed().map { list ->
@@ -97,10 +97,10 @@ interface ReplaceRuleDao {
} }
} }
val allGroups: List<String> fun allGroups(): List<String> =dealGroups(allGroupsUnProcessed)
get() { // get() {
return dealGroups(allGroupsUnProcessed) // return dealGroups(allGroupsUnProcessed)
} // }
fun flowGroups(): Flow<List<String>> { fun flowGroups(): Flow<List<String>> {
return flowGroupsUnProcessed().map { list -> return flowGroupsUnProcessed().map { list ->
@@ -128,10 +128,10 @@ interface RssSourceDao {
} }
} }
val allGroups: List<String> fun allGroups(): List<String> =dealGroups(allGroupsUnProcessed)
get() { // get() {
return dealGroups(allGroupsUnProcessed) // return dealGroups(allGroupsUnProcessed)
} // }
fun flowGroups(): Flow<List<String>> { fun flowGroups(): Flow<List<String>> {
return flowGroupsUnProcessed().map { list -> return flowGroupsUnProcessed().map { list ->
@@ -5,12 +5,15 @@ import android.graphics.Bitmap
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.net.Uri import android.net.Uri
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import com.bumptech.glide.Glide
import com.bumptech.glide.RequestBuilder import com.bumptech.glide.RequestBuilder
import io.legado.app.utils.isAbsUrl import io.legado.app.utils.isAbsUrl
import io.legado.app.utils.isContentScheme import io.legado.app.utils.isContentScheme
import io.legado.app.utils.isDataUrl import io.legado.app.utils.isDataUrl
import java.io.File import java.io.File
//https://bumptech.github.io/glide/doc/generatedapi.html
//Instead of GlideApp, use com.bumptech.Glide
@Suppress("unused") @Suppress("unused")
object ImageLoader { object ImageLoader {
@@ -19,67 +22,67 @@ object ImageLoader {
*/ */
fun load(context: Context, path: String?): RequestBuilder<Drawable> { fun load(context: Context, path: String?): RequestBuilder<Drawable> {
return when { return when {
path.isNullOrEmpty() -> GlideApp.with(context).load(path) path.isNullOrEmpty() -> Glide.with(context).load(path)
path.isDataUrl() -> GlideApp.with(context).load(path) path.isDataUrl() -> Glide.with(context).load(path)
path.isAbsUrl() -> GlideApp.with(context).load(path) path.isAbsUrl() -> Glide.with(context).load(path)
path.isContentScheme() -> GlideApp.with(context).load(Uri.parse(path)) path.isContentScheme() -> Glide.with(context).load(Uri.parse(path))
else -> kotlin.runCatching { else -> kotlin.runCatching {
GlideApp.with(context).load(File(path)) Glide.with(context).load(File(path))
}.getOrElse { }.getOrElse {
GlideApp.with(context).load(path) Glide.with(context).load(path)
} }
} }
} }
fun loadBitmap(context: Context, path: String?): RequestBuilder<Bitmap> { fun loadBitmap(context: Context, path: String?): RequestBuilder<Bitmap> {
return when { return when {
path.isNullOrEmpty() -> GlideApp.with(context).asBitmap().load(path) path.isNullOrEmpty() -> Glide.with(context).asBitmap().load(path)
path.isDataUrl() -> GlideApp.with(context).asBitmap().load(path) path.isDataUrl() -> Glide.with(context).asBitmap().load(path)
path.isAbsUrl() -> GlideApp.with(context).asBitmap().load(path) path.isAbsUrl() -> Glide.with(context).asBitmap().load(path)
path.isContentScheme() -> GlideApp.with(context).asBitmap().load(Uri.parse(path)) path.isContentScheme() -> Glide.with(context).asBitmap().load(Uri.parse(path))
else -> kotlin.runCatching { else -> kotlin.runCatching {
GlideApp.with(context).asBitmap().load(File(path)) Glide.with(context).asBitmap().load(File(path))
}.getOrElse { }.getOrElse {
GlideApp.with(context).asBitmap().load(path) Glide.with(context).asBitmap().load(path)
} }
} }
} }
fun loadFile(context: Context, path: String?): RequestBuilder<File> { fun loadFile(context: Context, path: String?): RequestBuilder<File> {
return when { return when {
path.isNullOrEmpty() -> GlideApp.with(context).asFile().load(path) path.isNullOrEmpty() -> Glide.with(context).asFile().load(path)
path.isAbsUrl() -> GlideApp.with(context).asFile().load(path) path.isAbsUrl() -> Glide.with(context).asFile().load(path)
path.isContentScheme() -> GlideApp.with(context).asFile().load(Uri.parse(path)) path.isContentScheme() -> Glide.with(context).asFile().load(Uri.parse(path))
else -> kotlin.runCatching { else -> kotlin.runCatching {
GlideApp.with(context).asFile().load(File(path)) Glide.with(context).asFile().load(File(path))
}.getOrElse { }.getOrElse {
GlideApp.with(context).asFile().load(path) Glide.with(context).asFile().load(path)
} }
} }
} }
fun load(context: Context, @DrawableRes resId: Int?): RequestBuilder<Drawable> { 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> { 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> { 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> { 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> { 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> { 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) { private fun upSpeed(adjust: Float) {
kotlin.runCatching { kotlin.runCatching {
@SuppressLint("ObsoleteSdkInt")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
playSpeed += adjust playSpeed += adjust
exoPlayer.setPlaybackSpeed(playSpeed) exoPlayer.setPlaybackSpeed(playSpeed)
@@ -186,7 +186,7 @@ class ImportBookSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_vie
private fun alertCustomGroup(item: MenuItem) { private fun alertCustomGroup(item: MenuItem) {
alert(R.string.diy_edit_source_group) { alert(R.string.diy_edit_source_group) {
val alertBinding = DialogCustomGroupBinding.inflate(layoutInflater).apply { val alertBinding = DialogCustomGroupBinding.inflate(layoutInflater).apply {
val groups = appDb.bookSourceDao.allGroups val groups = appDb.bookSourceDao.allGroups()
textInputLayout.setHint(R.string.group_name) textInputLayout.setHint(R.string.group_name)
editView.setFilterValues(groups.toList()) editView.setFilterValues(groups.toList())
editView.dropDownHeight = 180.dpToPx() editView.dropDownHeight = 180.dpToPx()
@@ -133,7 +133,7 @@ class ImportReplaceRuleDialog() : BaseDialogFragment(R.layout.dialog_recycler_vi
private fun alertCustomGroup(item: MenuItem) { private fun alertCustomGroup(item: MenuItem) {
alert(R.string.diy_edit_source_group) { alert(R.string.diy_edit_source_group) {
val alertBinding = DialogCustomGroupBinding.inflate(layoutInflater).apply { val alertBinding = DialogCustomGroupBinding.inflate(layoutInflater).apply {
val groups = appDb.replaceRuleDao.allGroups val groups = appDb.replaceRuleDao.allGroups()
textInputLayout.setHint(R.string.group_name) textInputLayout.setHint(R.string.group_name)
editView.setFilterValues(groups.toList()) editView.setFilterValues(groups.toList())
editView.dropDownHeight = 180.dpToPx() editView.dropDownHeight = 180.dpToPx()
@@ -165,7 +165,7 @@ class ImportRssSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_view
private fun alertCustomGroup(item: MenuItem) { private fun alertCustomGroup(item: MenuItem) {
alert(R.string.diy_edit_source_group) { alert(R.string.diy_edit_source_group) {
val alertBinding = DialogCustomGroupBinding.inflate(layoutInflater).apply { val alertBinding = DialogCustomGroupBinding.inflate(layoutInflater).apply {
val groups = appDb.rssSourceDao.allGroups val groups = appDb.rssSourceDao.allGroups()
textInputLayout.setHint(R.string.group_name) textInputLayout.setHint(R.string.group_name)
editView.setFilterValues(groups.toList()) editView.setFilterValues(groups.toList())
editView.dropDownHeight = 180.dpToPx() editView.dropDownHeight = 180.dpToPx()
@@ -102,7 +102,7 @@ class SearchScopeDialog : BaseDialogFragment(R.layout.dialog_search_scope) {
private fun initData() { private fun initData() {
launch { launch {
groups = withContext(IO) { groups = withContext(IO) {
appDb.bookSourceDao.allEnabledGroups appDb.bookSourceDao.allEnabledGroups()
} }
sources = withContext(IO) { sources = withContext(IO) {
appDb.bookSourceDao.allEnabled appDb.bookSourceDao.allEnabled
@@ -558,7 +558,7 @@ class BookSourceEditActivity :
private fun alertGroups() { private fun alertGroups() {
launch { launch {
val groups = withContext(IO) { val groups = withContext(IO) {
appDb.bookSourceDao.allGroups appDb.bookSourceDao.allGroups()
} }
selector(groups) { _, s, _ -> selector(groups) { _, s, _ ->
sendText(s) sendText(s)
+3 -1
View File
@@ -4,7 +4,8 @@ buildscript {
ext{ ext{
compile_sdk_version = 33 compile_sdk_version = 33
build_tool_version = '33.0.1' 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' agp_version = '8.0.2'
media3_version = "1.1.0" media3_version = "1.1.0"
splitties_version = '3.0.0' splitties_version = '3.0.0'
@@ -16,6 +17,7 @@ plugins {
id 'com.android.application' version "$agp_version" apply false id 'com.android.application' version "$agp_version" apply false
id 'com.android.library' 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 '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 "de.undercouch.download" version "5.4.0" apply false
id "com.google.gms.google-services" version "4.3.15" apply false id "com.google.gms.google-services" version "4.3.15" apply false
} }
+1
View File
@@ -22,6 +22,7 @@ android.enableJetifier=false
# Kotlin code style for this project: "official" or "obsolete": # Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official kotlin.code.style=official
kotlin.incremental.useClasspathSnapshot=true kotlin.incremental.useClasspathSnapshot=true
kotlin.experimental.tryK2=true
android.enableResourceOptimizations=true android.enableResourceOptimizations=true
# android.enableNewResourceShrinker' is deprecated. # android.enableNewResourceShrinker' is deprecated.
# It was removed in version 8.0 of the Android Gradle plugin. # It was removed in version 8.0 of the Android Gradle plugin.
+3 -3
View File
@@ -1,6 +1,6 @@
#Mon Sep 26 08:03:55 CST 2022 #Sat Jul 22 18:39:27 CST 2023
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists