diff --git a/android/build.gradle b/android/build.gradle index 07e6c4c..9feeae9 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -8,7 +8,7 @@ group='com.github.ivanisidrowu' android { compileSdkVersion 30 - buildToolsVersion "30.0.0" + buildToolsVersion "30.0.3" defaultConfig { minSdkVersion 23 @@ -20,6 +20,11 @@ android { consumerProguardFiles "consumer-rules.pro" } + compileOptions { + sourceCompatibility 1.8 + targetCompatibility 1.8 + } + buildTypes { release { minifyEnabled false @@ -33,6 +38,10 @@ android { '-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi', ] } + + lintOptions { + abortOnError false + } } dependencies { diff --git a/android/src/main/java/tw/ktrssreader/config/KtRssReaderConfig.kt b/android/src/main/java/tw/ktrssreader/config/KtRssReaderConfig.kt index 50345e6..3716232 100644 --- a/android/src/main/java/tw/ktrssreader/config/KtRssReaderConfig.kt +++ b/android/src/main/java/tw/ktrssreader/config/KtRssReaderConfig.kt @@ -17,6 +17,7 @@ package tw.ktrssreader.config import java.nio.charset.Charset +import kotlin.time.Duration import kotlin.time.ExperimentalTime import kotlin.time.days @@ -28,5 +29,5 @@ class KtRssReaderConfig { var flushCache: Boolean = false @ExperimentalTime - var expiredTimeMillis: Long = 1.days.toLongMilliseconds() + var expiredTimeMillis: Long = Duration.days(1).inWholeMilliseconds } \ No newline at end of file diff --git a/android/src/main/java/tw/ktrssreader/parser/AndroidParserBase.kt b/android/src/main/java/tw/ktrssreader/parser/AndroidParserBase.kt index ef29f9a..806f7cb 100644 --- a/android/src/main/java/tw/ktrssreader/parser/AndroidParserBase.kt +++ b/android/src/main/java/tw/ktrssreader/parser/AndroidParserBase.kt @@ -151,7 +151,7 @@ abstract class AndroidParserBase : tw.ktrssreader.ko } protected fun String.toBoolOrNull(): Boolean? { - return when (toLowerCase()) { + return when (lowercase()) { "yes", "true" -> true "no", "false" -> false else -> null diff --git a/app/build.gradle b/app/build.gradle index d0ac4f2..0336205 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,7 +5,7 @@ apply plugin: 'kotlin-kapt' android { compileSdkVersion 30 - buildToolsVersion "30.0.0" + buildToolsVersion "30.0.3" defaultConfig { applicationId "tw.ktrssreader" @@ -17,6 +17,11 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } + compileOptions { + sourceCompatibility 1.8 + targetCompatibility 1.8 + } + buildTypes { release { minifyEnabled false diff --git a/build.gradle b/build.gradle index 7af8c57..286a926 100644 --- a/build.gradle +++ b/build.gradle @@ -2,13 +2,13 @@ buildscript { ext { - def coroutines_version = '1.3.9' + def coroutines_version = '1.5.0' def okhttp_version = '4.9.0' - def room_version = '2.2.5' + def room_version = '2.2.6' def startup_version = '1.0.0' def mockk_version = '1.10.0' - def turbine_version = '0.2.1' + def turbine_version = '0.5.0' deps = [ 'kotlinxCoroutinesCore' : "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version", @@ -24,7 +24,7 @@ buildscript { 'turbine': "app.cash.turbine:turbine:$turbine_version" ] - kotlin_version = "1.4.0" + kotlin_version = "1.5.0" } repositories { @@ -32,7 +32,7 @@ buildscript { jcenter() } dependencies { - classpath "com.android.tools.build:gradle:4.0.1" + classpath "com.android.tools.build:gradle:4.1.3" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 74e0ad7..f705ea8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip diff --git a/kotlin/src/main/java/tw/ktrssreader/kotlin/parser/ParserBase.kt b/kotlin/src/main/java/tw/ktrssreader/kotlin/parser/ParserBase.kt index fecd2f6..3e49b77 100644 --- a/kotlin/src/main/java/tw/ktrssreader/kotlin/parser/ParserBase.kt +++ b/kotlin/src/main/java/tw/ktrssreader/kotlin/parser/ParserBase.kt @@ -247,7 +247,7 @@ abstract class ParserBase : Parser { } protected fun String.toBoolOrNull(): Boolean? { - return when (toLowerCase()) { + return when (lowercase()) { "yes", "true" -> true "no", "false" -> false else -> null diff --git a/processor/src/main/java/tw/ktrssreader/processor/util/TypeExtensions.kt b/processor/src/main/java/tw/ktrssreader/processor/util/TypeExtensions.kt index 7860ec4..8c9d2dd 100644 --- a/processor/src/main/java/tw/ktrssreader/processor/util/TypeExtensions.kt +++ b/processor/src/main/java/tw/ktrssreader/processor/util/TypeExtensions.kt @@ -45,22 +45,30 @@ fun String.isPrimitive(): Boolean = primitiveJavaPaths.any { this.contains(other fun String.getFuncName(): String { return when { this.startsWith(GOOGLE_PREFIX) || this.startsWith(ITUNES_PREFIX) -> - "get${this.substringAfterLast(':').capitalize(Locale.ROOT)}" - else -> "get${this.capitalize(Locale.ROOT)}" + "get${this.substringAfterLast(':').capitalize()}" + else -> "get${this.capitalize()}" } } fun String.getListFuncName(): String { - val tagCapitalized = substringAfterLast(':').capitalize(Locale.ROOT) + val tagCapitalized = substringAfterLast(':').capitalize() return when { - startsWith(GOOGLE_PREFIX) -> "get${GOOGLE_PREFIX.capitalize(Locale.ROOT)}${tagCapitalized}List" - startsWith(ITUNES_PREFIX) -> "get${ITUNES_PREFIX.capitalize(Locale.ROOT)}${tagCapitalized}List" + startsWith(GOOGLE_PREFIX) -> "get${GOOGLE_PREFIX.capitalize()}${tagCapitalized}List" + startsWith(ITUNES_PREFIX) -> "get${ITUNES_PREFIX.capitalize()}${tagCapitalized}List" else -> "get${tagCapitalized}List" } } +internal fun String.capitalize(): String = replaceFirstChar { + if (it.isLowerCase()) { + it.titlecase(Locale.ROOT) + } else { + it.toString() + } +} + fun String.getGeneratedClassPath() = - "${GENERATOR_PACKAGE}.${this.capitalize(Locale.ROOT)}${PARSER_SUFFIX}" + "${GENERATOR_PACKAGE}.${this.capitalize()}${PARSER_SUFFIX}" fun String.extractListType() = this.substringAfter('<') @@ -95,10 +103,10 @@ fun Element.getPackage(): String { } fun String.getVariableName(tag: String): String { - val tagCapitalized = tag.substringAfterLast(':').capitalize(Locale.ROOT) + val tagCapitalized = tag.substringAfterLast(':').capitalize() return when { - tag.startsWith(GOOGLE_PREFIX) -> "$this${GOOGLE_PREFIX.capitalize(Locale.ROOT)}$tagCapitalized" - tag.startsWith(ITUNES_PREFIX) -> "$this${ITUNES_PREFIX.capitalize(Locale.ROOT)}$tagCapitalized" + tag.startsWith(GOOGLE_PREFIX) -> "$this${GOOGLE_PREFIX.capitalize()}$tagCapitalized" + tag.startsWith(ITUNES_PREFIX) -> "$this${ITUNES_PREFIX.capitalize()}$tagCapitalized" else -> "$this$tagCapitalized" } } @@ -126,7 +134,7 @@ fun Name.extractNameFromMethod(): String { } return withoutPrefix - .decapitalize(Locale.ROOT) + .replaceFirstChar { it.lowercase(Locale.ROOT) } .substringBeforeLast('$') }