Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[*.{kt,kts}]
Comment thread
cyb3rko marked this conversation as resolved.
ktlint_code_style = android
ktlint_code_style = android_studio
14 changes: 7 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'org.jmailen.kotlinter' version '3.15.0'
id 'org.jmailen.kotlinter' version '4.0.0'
}

android {
namespace "com.github.gotify"
compileSdk 33
compileSdk 34
defaultConfig {
applicationId "com.github.gotify"
minSdk 23
targetSdk 33
targetSdk 34
versionCode 30
versionName "2.7.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -68,13 +68,13 @@ dependencies {
implementation project(':client')
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 'com.google.android.material:material:1.10.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-ktx:1.2.0'
implementation 'androidx.preference:preference-ktx:1.2.1'

implementation 'com.github.cyb3rko:QuickPermissions-Kotlin:1.1.2'
implementation 'com.github.cyb3rko:QuickPermissions-Kotlin:1.1.3'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'io.noties.markwon:core:4.6.2'
implementation 'io.noties.markwon:image-picasso:4.6.2'
Expand All @@ -87,7 +87,7 @@ dependencies {
}

configurations {
all {
configureEach {
exclude group: 'org.json', module: 'json'
exclude group: 'androidx.lifecycle', module: 'lifecycle-viewmodel-ktx'
}
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />

<application
android:name=".GotifyApplication"
Expand Down Expand Up @@ -73,7 +74,13 @@
android:exported="false"
android:theme="@style/AppTheme.Dialog" />

<service android:name=".service.WebSocketService" />
<service
android:name=".service.WebSocketService"
android:foregroundServiceType="specialUse">
<property
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="This is the main feature of this application. The foreground notification displays the connectivity status to the configurable remote server and the service notifies the user when a new message has been published on the remote server." />
</service>

<receiver android:name=".init.BootCompletedReceiver"
android:exported="true">
Expand Down
11 changes: 2 additions & 9 deletions app/src/main/kotlin/com/github/gotify/NotificationSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ internal object NotificationSupport {
}

@RequiresApi(Build.VERSION_CODES.O)
private fun createGeneralChannels(
context: Context,
notificationManager: NotificationManager
) {
private fun createGeneralChannels(context: Context, notificationManager: NotificationManager) {
try {
val messagesImportanceMin = NotificationChannel(
Channel.MESSAGES_IMPORTANCE_MIN,
Expand Down Expand Up @@ -98,11 +95,7 @@ internal object NotificationSupport {
}

@RequiresApi(api = Build.VERSION_CODES.O)
fun createChannelIfNonexistent(
context: Context,
groupId: String,
channelId: String
) {
fun createChannelIfNonexistent(context: Context, groupId: String, channelId: String) {
if (!doesNotificationChannelExist(context, channelId)) {
val notificationManager = (context as Service)
.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
Expand Down
6 changes: 1 addition & 5 deletions app/src/main/kotlin/com/github/gotify/api/ClientFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ internal object ClientFactory {
return client
}

fun clientToken(
baseUrl: String,
sslSettings: SSLSettings,
token: String?
): ApiClient {
fun clientToken(baseUrl: String, sslSettings: SSLSettings, token: String?): ApiClient {
val client = defaultClient(
arrayOf("clientTokenHeader"),
"$baseUrl/",
Expand Down
6 changes: 1 addition & 5 deletions app/src/main/kotlin/com/github/gotify/messages/Extras.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ internal object Extras {
return "text/markdown" == display["contentType"]
}

fun <T> getNestedValue(
clazz: Class<T>,
extras: Map<String, Any>?,
vararg keys: String
): T? {
fun <T> getNestedValue(clazz: Class<T>, extras: Map<String, Any>?, vararg keys: String): T? {
var value: Any? = extras

keys.forEach { key ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.graphics.Canvas
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
Expand Down Expand Up @@ -310,7 +311,11 @@ internal class MessagesActivity :
nManager.cancelAll()
val filter = IntentFilter()
filter.addAction(WebSocketService.NEW_MESSAGE_BROADCAST)
registerReceiver(receiver, filter)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
registerReceiver(receiver, filter, RECEIVER_EXPORTED)
} else {
registerReceiver(receiver, filter)
}
launchCoroutine {
updateMissedMessages(viewModel.messages.getLastReceivedMessage())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.app.NotificationManager
import android.app.PendingIntent
import android.app.Service
import android.content.Intent
import android.content.pm.ServiceInfo
import android.graphics.Color
import android.net.ConnectivityManager
import android.net.Network
Expand Down Expand Up @@ -285,7 +286,15 @@ internal class WebSocketService : Service() {

notificationBuilder.setContentIntent(pendingIntent)
notificationBuilder.color = ContextCompat.getColor(applicationContext, R.color.colorPrimary)
startForeground(NotificationSupport.ID.FOREGROUND, notificationBuilder.build())
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
startForeground(
NotificationSupport.ID.FOREGROUND,
notificationBuilder.build(),
ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
)
} else {
startForeground(NotificationSupport.ID.FOREGROUND, notificationBuilder.build())
}
}

private fun showNotification(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ internal class SettingsActivity : AppCompatActivity(), OnSharedPreferenceChangeL
return false
}

override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
if (sharedPreferences == null) return
when (key) {
getString(R.string.setting_key_theme) -> {
ThemeHelper.setTheme(
Expand Down
11 changes: 6 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.0.2'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20'
classpath 'com.android.tools.build:gradle:8.1.3'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -26,12 +26,12 @@ ext {
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://jitpack.io/" }
}
}

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}

Expand All @@ -45,7 +45,8 @@ static def download(String url, String filename ) {
}
}
}
task downloadSpec {

tasks.register('downloadSpec') {
inputs.property 'version', gotifyVersion
doFirst {
buildDir.mkdirs()
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distrubutionSha256Sum=e111cb9948407e26351227dabce49822fb88c37ee72f1d1582a69c68af2e702f
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
35 changes: 22 additions & 13 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.