From a12623f8e4bbc2dbaba9ff7b0db290174029b72d Mon Sep 17 00:00:00 2001 From: davidoskky Date: Thu, 7 Oct 2021 21:01:12 +0200 Subject: [PATCH] Upgrade dependencies (#352) * Upgrade gradle to version 7.0.2 * Disable deprecated options * Upgrade to latest SDK * Upgrade kotlin * Upgrade dependencies --- app/build.gradle | 29 +++++++++---------- app/src/main/AndroidManifest.xml | 6 ++-- .../api/selfoss/SelfossApi.kt | 8 +++-- .../bou/readerforselfoss/utils/LinksUtils.kt | 7 +++-- build.gradle | 16 ++-------- gradle.properties | 1 - gradle/wrapper/gradle-wrapper.properties | 2 +- 7 files changed, 31 insertions(+), 38 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index db02e99..d145624 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -35,7 +35,7 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } - compileSdkVersion 30 + compileSdkVersion 31 buildToolsVersion '30.0.3' buildFeatures { viewBinding true @@ -43,7 +43,7 @@ android { defaultConfig { applicationId "apps.amine.bou.readerforselfoss" minSdkVersion 16 - targetSdkVersion 30 + targetSdkVersion 31 versionCode versionCodeFromGit() versionName versionNameFromGit() @@ -101,14 +101,14 @@ dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // Android Support - implementation "androidx.appcompat:appcompat:1.3.0-alpha02" - implementation 'com.google.android.material:material:1.3.0-beta01' - implementation 'androidx.recyclerview:recyclerview:1.2.0-beta01' + implementation "androidx.appcompat:appcompat:1.4.0-beta01" + implementation 'com.google.android.material:material:1.5.0-alpha04' + implementation 'androidx.recyclerview:recyclerview:1.3.0-alpha01' implementation "androidx.legacy:legacy-support-v4:$android_version" implementation 'androidx.vectordrawable:vectordrawable:1.2.0-alpha02' implementation "androidx.browser:browser:1.3.0" implementation "androidx.cardview:cardview:$android_version" - implementation 'androidx.constraintlayout:constraintlayout:2.1.0-alpha2' + implementation 'androidx.constraintlayout:constraintlayout:2.1.1' implementation 'org.jsoup:jsoup:1.13.1' //multidex @@ -120,13 +120,13 @@ dependencies { } // Async - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0' // Retrofit + http logging + okhttp implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0' + implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' - implementation 'com.burgstaller:okhttp-digest:1.12' + implementation 'com.burgstaller:okhttp-digest:2.5' // Material-ish things implementation 'com.ashokvarma.android:bottom-navigation-bar:2.1.0' @@ -151,14 +151,13 @@ dependencies { //PhotoView implementation 'com.github.chrisbanes:PhotoView:2.0.0' - implementation 'androidx.core:core-ktx:1.5.0-alpha05' + implementation 'androidx.core:core-ktx:1.7.0-beta02' - implementation "androidx.lifecycle:lifecycle-livedata:2.3.0-rc01" - implementation "androidx.lifecycle:lifecycle-common-java8:2.3.0-rc01" + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.0-rc01" + implementation "androidx.lifecycle:lifecycle-common-java8:2.4.0-rc01" - implementation "androidx.room:room-runtime:2.3.0-alpha04" - implementation "androidx.room:room-ktx:2.3.0-alpha04" - kapt "androidx.room:room-compiler:2.3.0-alpha04" + implementation "androidx.room:room-ktx:2.4.0-alpha05" + kapt "androidx.room:room-compiler:2.4.0-alpha05" implementation "android.arch.work:work-runtime-ktx:$work_version" } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 748ff1b..f42790b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,7 +15,8 @@ android:theme="@style/NoBar"> + android:theme="@style/SplashTheme" + android:exported="true"> @@ -48,7 +49,8 @@ + android:parentActivityName=".SourcesActivity" + android:exported="true"> diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossApi.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossApi.kt index 558e503..b29c26e 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossApi.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossApi.kt @@ -14,6 +14,8 @@ import com.burgstaller.okhttp.digest.Credentials import com.burgstaller.okhttp.digest.DigestAuthenticator import com.google.gson.GsonBuilder import okhttp3.* +import okhttp3.MediaType.Companion.toMediaTypeOrNull +import okhttp3.ResponseBody.Companion.toResponseBody import okhttp3.logging.HttpLoggingInterceptor import retrofit2.Call import retrofit2.Retrofit @@ -68,7 +70,7 @@ class SelfossApi( val request: Request = chain.request() val response: Response = chain.proceed(request) - if (response.code() == 408) { + if (response.code == 408) { return response } return response @@ -103,7 +105,7 @@ class SelfossApi( httpClient .addInterceptor { chain -> val res = chain.proceed(chain.request()) - if (res.code() == timeoutCode) { + if (res.code == timeoutCode) { throw SocketTimeoutException("timeout") } res @@ -117,7 +119,7 @@ class SelfossApi( Response.Builder() .code(timeoutCode) .protocol(Protocol.HTTP_2) - .body(ResponseBody.create(MediaType.parse("text/plain"), "")) + .body("".toResponseBody("text/plain".toMediaTypeOrNull())) .message("") .request(request) .build() diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/utils/LinksUtils.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/utils/LinksUtils.kt index b3f42b6..94b1639 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/utils/LinksUtils.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/utils/LinksUtils.kt @@ -20,6 +20,7 @@ import apps.amine.bou.readerforselfoss.ReaderActivity import apps.amine.bou.readerforselfoss.api.selfoss.Item import apps.amine.bou.readerforselfoss.utils.customtabs.CustomTabActivityHelper import okhttp3.HttpUrl +import okhttp3.HttpUrl.Companion.toHttpUrlOrNull fun Context.buildCustomTabsIntent(): CustomTabsIntent { @@ -138,13 +139,13 @@ private fun openInBrowser(linkDecoded: String, app: Activity) { } fun String.isUrlValid(): Boolean = - HttpUrl.parse(this) != null && Patterns.WEB_URL.matcher(this).matches() + this.toHttpUrlOrNull() != null && Patterns.WEB_URL.matcher(this).matches() fun String.isBaseUrlValid(ctx: Context): Boolean { - val baseUrl = HttpUrl.parse(this) + val baseUrl = this.toHttpUrlOrNull() var existsAndEndsWithSlash = false if (baseUrl != null) { - val pathSegments = baseUrl.pathSegments() + val pathSegments = baseUrl.pathSegments existsAndEndsWithSlash = "" == pathSegments[pathSegments.size - 1] } diff --git a/build.gradle b/build.gradle index 4d6928b..958a529 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ buildscript { ext { - kotlin_version = '1.4.21' + kotlin_version = '1.5.31' android_version = '1.0.0' androidx_version = '1.1.0-alpha05' lifecycle_version = '2.2.0-alpha01' @@ -17,7 +17,7 @@ buildscript { } } dependencies { - classpath 'com.android.tools.build:gradle:4.1.1' + classpath 'com.android.tools.build:gradle:7.0.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -37,14 +37,4 @@ task clean(type: Delete) { delete rootProject.buildDir } -project.ext.preDexLibs = !project.hasProperty('disablePreDex') - -subprojects { - project.plugins.whenPluginAdded { plugin -> - if ("com.android.build.gradle.AppPlugin" == plugin.class.name) { - project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs - } else if ("com.android.build.gradle.LibraryPlugin" == plugin.class.name) { - project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs - } - } -} \ No newline at end of file +project.ext.preDexLibs = !project.hasProperty('disablePreDex') \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 9abd3c9..c035bd9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,6 +16,5 @@ org.gradle.jvmargs=-Xmx1536m # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true org.gradle.caching=true -android.enableD8=true android.useAndroidX=true android.enableJetifier=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 999ae0d..f717da0 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.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip