diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..1b8d08e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,2 @@ +[*.{kt,kts}] +ktlint_code_style = android \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7bf74f2..4d57671 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-java@v1 with: - java-version: 11 + java-version: 17 - if: ${{ !startsWith(github.ref, 'refs/tags/v') }} run: ./gradlew build --stacktrace - if: ${{ startsWith(github.ref, 'refs/tags/v') }} diff --git a/README.md b/README.md index d458649..ce956be 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ The foreground notification showing the connection status can be manually minimi ## Building -Use Java 11 and execute the following command to build the apk. +Use Java 17 and execute the following command to build the apk. ```bash $ ./gradlew build diff --git a/app/build.gradle b/app/build.gradle index d835026..a18c104 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,7 +1,7 @@ plugins { id 'com.android.application' id 'kotlin-android' - id 'org.jmailen.kotlinter' version '3.13.0' + id 'org.jmailen.kotlinter' version '3.15.0' } android { @@ -33,18 +33,20 @@ android { viewBinding true } compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = '11' - } - lintOptions { - disable 'GoogleAppIndexingWarning' - lintConfig file('../lint.xml') + jvmTarget = '17' } packagingOptions { - exclude 'META-INF/DEPENDENCIES' + resources { + excludes += ['META-INF/DEPENDENCIES'] + } + } + lint { + disable 'GoogleAppIndexingWarning' + lintConfig file('../lint.xml') } } @@ -64,13 +66,13 @@ if (project.hasProperty('sign')) { dependencies { implementation project(':client') - implementation 'androidx.appcompat:appcompat:1.5.1' - implementation 'androidx.core:core-splashscreen:1.0.0' - implementation 'com.google.android.material:material:1.7.0' + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'androidx.core:core-splashscreen:1.0.1' + implementation 'com.google.android.material:material:1.9.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation 'androidx.vectordrawable:vectordrawable:1.1.0' - implementation 'androidx.preference:preference:1.2.0' + implementation 'androidx.preference:preference-ktx:1.2.0' implementation 'com.github.cyb3rko:QuickPermissions-Kotlin:1.0.2' implementation 'com.hypertrack:hyperlog:0.0.10' diff --git a/app/src/main/kotlin/com/github/gotify/Utils.kt b/app/src/main/kotlin/com/github/gotify/Utils.kt index 07193e9..772d562 100644 --- a/app/src/main/kotlin/com/github/gotify/Utils.kt +++ b/app/src/main/kotlin/com/github/gotify/Utils.kt @@ -17,12 +17,6 @@ import com.google.android.material.snackbar.Snackbar import com.google.gson.Gson import com.squareup.picasso.Picasso.LoadedFrom import com.squareup.picasso.Target -import kotlinx.coroutines.CoroutineDispatcher -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch -import okio.Buffer -import org.threeten.bp.OffsetDateTime import java.io.BufferedReader import java.io.IOException import java.io.InputStream @@ -31,6 +25,12 @@ import java.net.MalformedURLException import java.net.URI import java.net.URISyntaxException import java.net.URL +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import okio.Buffer +import org.threeten.bp.OffsetDateTime internal object Utils { val JSON: Gson = JSON().gson diff --git a/app/src/main/kotlin/com/github/gotify/api/Api.kt b/app/src/main/kotlin/com/github/gotify/api/Api.kt index 7b09a5a..a6640f6 100644 --- a/app/src/main/kotlin/com/github/gotify/api/Api.kt +++ b/app/src/main/kotlin/com/github/gotify/api/Api.kt @@ -1,7 +1,7 @@ package com.github.gotify.api -import retrofit2.Call import java.io.IOException +import retrofit2.Call internal object Api { @Throws(ApiException::class) diff --git a/app/src/main/kotlin/com/github/gotify/api/ApiException.kt b/app/src/main/kotlin/com/github/gotify/api/ApiException.kt index e746bfb..91f2c98 100644 --- a/app/src/main/kotlin/com/github/gotify/api/ApiException.kt +++ b/app/src/main/kotlin/com/github/gotify/api/ApiException.kt @@ -1,7 +1,7 @@ package com.github.gotify.api -import retrofit2.Response import java.io.IOException +import retrofit2.Response internal class ApiException : Exception { var body: String = "" diff --git a/app/src/main/kotlin/com/github/gotify/api/Callback.kt b/app/src/main/kotlin/com/github/gotify/api/Callback.kt index 8c1e1c8..0ef273c 100644 --- a/app/src/main/kotlin/com/github/gotify/api/Callback.kt +++ b/app/src/main/kotlin/com/github/gotify/api/Callback.kt @@ -51,7 +51,10 @@ internal class Callback private constructor( ) } - fun call(onSuccess: SuccessCallback = SuccessCallback {}, onError: ErrorCallback = ErrorCallback {}): retrofit2.Callback { + fun call( + onSuccess: SuccessCallback = SuccessCallback {}, + onError: ErrorCallback = ErrorCallback {} + ): retrofit2.Callback { return RetrofitCallback(merge(of(onSuccess, onError), errorCallback())) } diff --git a/app/src/main/kotlin/com/github/gotify/api/CertUtils.kt b/app/src/main/kotlin/com/github/gotify/api/CertUtils.kt index f75cfc7..60a295b 100644 --- a/app/src/main/kotlin/com/github/gotify/api/CertUtils.kt +++ b/app/src/main/kotlin/com/github/gotify/api/CertUtils.kt @@ -4,7 +4,6 @@ import android.annotation.SuppressLint import com.github.gotify.SSLSettings import com.github.gotify.Utils import com.github.gotify.log.Log -import okhttp3.OkHttpClient import java.io.IOException import java.security.GeneralSecurityException import java.security.KeyStore @@ -16,6 +15,7 @@ import javax.net.ssl.SSLContext import javax.net.ssl.TrustManager import javax.net.ssl.TrustManagerFactory import javax.net.ssl.X509TrustManager +import okhttp3.OkHttpClient internal object CertUtils { @SuppressLint("CustomX509TrustManager") diff --git a/app/src/main/kotlin/com/github/gotify/login/LoginActivity.kt b/app/src/main/kotlin/com/github/gotify/login/LoginActivity.kt index ac31707..402ffd0 100644 --- a/app/src/main/kotlin/com/github/gotify/login/LoginActivity.kt +++ b/app/src/main/kotlin/com/github/gotify/login/LoginActivity.kt @@ -31,8 +31,8 @@ import com.github.gotify.log.LogsActivity import com.github.gotify.log.UncaughtExceptionHandler import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.textfield.TextInputEditText -import okhttp3.HttpUrl import java.security.cert.X509Certificate +import okhttp3.HttpUrl internal class LoginActivity : AppCompatActivity() { companion object { diff --git a/app/src/main/kotlin/com/github/gotify/messages/ListMessageAdapter.kt b/app/src/main/kotlin/com/github/gotify/messages/ListMessageAdapter.kt index 0304528..04d092f 100644 --- a/app/src/main/kotlin/com/github/gotify/messages/ListMessageAdapter.kt +++ b/app/src/main/kotlin/com/github/gotify/messages/ListMessageAdapter.kt @@ -26,9 +26,9 @@ import com.github.gotify.databinding.MessageItemCompactBinding import com.github.gotify.messages.provider.MessageWithImage import com.squareup.picasso.Picasso import io.noties.markwon.Markwon -import org.threeten.bp.OffsetDateTime import java.text.DateFormat import java.util.Date +import org.threeten.bp.OffsetDateTime internal class ListMessageAdapter( private val context: Context, diff --git a/app/src/main/kotlin/com/github/gotify/messages/MessagesActivity.kt b/app/src/main/kotlin/com/github/gotify/messages/MessagesActivity.kt index d535cde..927bdca 100644 --- a/app/src/main/kotlin/com/github/gotify/messages/MessagesActivity.kt +++ b/app/src/main/kotlin/com/github/gotify/messages/MessagesActivity.kt @@ -56,9 +56,9 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.navigation.NavigationView import com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback import com.google.android.material.snackbar.Snackbar +import java.io.IOException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext -import java.io.IOException internal class MessagesActivity : AppCompatActivity(), diff --git a/app/src/main/kotlin/com/github/gotify/picasso/PicassoHandler.kt b/app/src/main/kotlin/com/github/gotify/picasso/PicassoHandler.kt index bddc3a4..1a80bdb 100644 --- a/app/src/main/kotlin/com/github/gotify/picasso/PicassoHandler.kt +++ b/app/src/main/kotlin/com/github/gotify/picasso/PicassoHandler.kt @@ -11,10 +11,10 @@ import com.github.gotify.client.model.Application import com.github.gotify.log.Log import com.squareup.picasso.OkHttp3Downloader import com.squareup.picasso.Picasso -import okhttp3.Cache -import okhttp3.OkHttpClient import java.io.File import java.io.IOException +import okhttp3.Cache +import okhttp3.OkHttpClient internal class PicassoHandler(private val context: Context, private val settings: Settings) { companion object { diff --git a/app/src/main/kotlin/com/github/gotify/service/WebSocketConnection.kt b/app/src/main/kotlin/com/github/gotify/service/WebSocketConnection.kt index f0b80ec..9ff0e4e 100644 --- a/app/src/main/kotlin/com/github/gotify/service/WebSocketConnection.kt +++ b/app/src/main/kotlin/com/github/gotify/service/WebSocketConnection.kt @@ -10,15 +10,15 @@ import com.github.gotify.Utils import com.github.gotify.api.CertUtils import com.github.gotify.client.model.Message import com.github.gotify.log.Log +import java.util.Calendar +import java.util.concurrent.TimeUnit +import java.util.concurrent.atomic.AtomicLong import okhttp3.HttpUrl import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.Response import okhttp3.WebSocket import okhttp3.WebSocketListener -import java.util.Calendar -import java.util.concurrent.TimeUnit -import java.util.concurrent.atomic.AtomicLong internal class WebSocketConnection( private val baseUrl: String, diff --git a/app/src/main/kotlin/com/github/gotify/service/WebSocketService.kt b/app/src/main/kotlin/com/github/gotify/service/WebSocketService.kt index 108d054..de63a91 100644 --- a/app/src/main/kotlin/com/github/gotify/service/WebSocketService.kt +++ b/app/src/main/kotlin/com/github/gotify/service/WebSocketService.kt @@ -141,7 +141,7 @@ internal class WebSocketService : Service() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationSupport.createChannels( this, - (this.getSystemService(NOTIFICATION_SERVICE) as NotificationManager), + (getSystemService(NOTIFICATION_SERVICE) as NotificationManager), apps ) } diff --git a/build.gradle b/build.gradle index d8ddb3f..70ea2df 100644 --- a/build.gradle +++ b/build.gradle @@ -6,8 +6,8 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:7.3.1' - classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20' + classpath 'com.android.tools.build:gradle:8.0.2' + classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle.properties b/gradle.properties index 8de5058..65539cb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,9 +6,13 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. +android.defaults.buildfeatures.buildconfig=true android.enableJetifier=true +android.nonFinalResIds=true +android.nonTransitiveRClass=true android.useAndroidX=true -org.gradle.jvmargs=-Xmx1536m +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +org.gradle.unsafe.configuration-cache=true # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ae04661..e999d40 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distrubutionSha256Sum=e111cb9948407e26351227dabce49822fb88c37ee72f1d1582a69c68af2e702f +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists