Skip to content

Commit 028e29a

Browse files
authored
Merge pull request #325 from cyb3rko/update-build
2 parents 6234c3a + 0b79ff6 commit 028e29a

14 files changed

Lines changed: 70 additions & 51 deletions

File tree

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[*.{kt,kts}]
2-
ktlint_code_style = android
2+
ktlint_code_style = android_studio

app/build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
plugins {
22
id 'com.android.application'
33
id 'kotlin-android'
4-
id 'org.jmailen.kotlinter' version '3.15.0'
4+
id 'org.jmailen.kotlinter' version '4.0.0'
55
}
66

77
android {
88
namespace "com.github.gotify"
9-
compileSdk 33
9+
compileSdk 34
1010
defaultConfig {
1111
applicationId "com.github.gotify"
1212
minSdk 23
13-
targetSdk 33
13+
targetSdk 34
1414
versionCode 30
1515
versionName "2.7.1"
1616
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -68,13 +68,13 @@ dependencies {
6868
implementation project(':client')
6969
implementation 'androidx.appcompat:appcompat:1.6.1'
7070
implementation 'androidx.core:core-splashscreen:1.0.1'
71-
implementation 'com.google.android.material:material:1.9.0'
71+
implementation 'com.google.android.material:material:1.10.0'
7272
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
7373
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
7474
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
75-
implementation 'androidx.preference:preference-ktx:1.2.0'
75+
implementation 'androidx.preference:preference-ktx:1.2.1'
7676

77-
implementation 'com.github.cyb3rko:QuickPermissions-Kotlin:1.1.2'
77+
implementation 'com.github.cyb3rko:QuickPermissions-Kotlin:1.1.3'
7878
implementation 'com.squareup.picasso:picasso:2.71828'
7979
implementation 'io.noties.markwon:core:4.6.2'
8080
implementation 'io.noties.markwon:image-picasso:4.6.2'
@@ -87,7 +87,7 @@ dependencies {
8787
}
8888

8989
configurations {
90-
all {
90+
configureEach {
9191
exclude group: 'org.json', module: 'json'
9292
exclude group: 'androidx.lifecycle', module: 'lifecycle-viewmodel-ktx'
9393
}

app/src/main/AndroidManifest.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
1111
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
1212
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
13+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
1314

1415
<application
1516
android:name=".GotifyApplication"
@@ -73,7 +74,13 @@
7374
android:exported="false"
7475
android:theme="@style/AppTheme.Dialog" />
7576

76-
<service android:name=".service.WebSocketService" />
77+
<service
78+
android:name=".service.WebSocketService"
79+
android:foregroundServiceType="specialUse">
80+
<property
81+
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
82+
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." />
83+
</service>
7784

7885
<receiver android:name=".init.BootCompletedReceiver"
7986
android:exported="true">

app/src/main/kotlin/com/github/gotify/NotificationSupport.kt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ internal object NotificationSupport {
5151
}
5252

5353
@RequiresApi(Build.VERSION_CODES.O)
54-
private fun createGeneralChannels(
55-
context: Context,
56-
notificationManager: NotificationManager
57-
) {
54+
private fun createGeneralChannels(context: Context, notificationManager: NotificationManager) {
5855
try {
5956
val messagesImportanceMin = NotificationChannel(
6057
Channel.MESSAGES_IMPORTANCE_MIN,
@@ -98,11 +95,7 @@ internal object NotificationSupport {
9895
}
9996

10097
@RequiresApi(api = Build.VERSION_CODES.O)
101-
fun createChannelIfNonexistent(
102-
context: Context,
103-
groupId: String,
104-
channelId: String
105-
) {
98+
fun createChannelIfNonexistent(context: Context, groupId: String, channelId: String) {
10699
if (!doesNotificationChannelExist(context, channelId)) {
107100
val notificationManager = (context as Service)
108101
.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager

app/src/main/kotlin/com/github/gotify/api/ClientFactory.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ internal object ClientFactory {
3030
return client
3131
}
3232

33-
fun clientToken(
34-
baseUrl: String,
35-
sslSettings: SSLSettings,
36-
token: String?
37-
): ApiClient {
33+
fun clientToken(baseUrl: String, sslSettings: SSLSettings, token: String?): ApiClient {
3834
val client = defaultClient(
3935
arrayOf("clientTokenHeader"),
4036
"$baseUrl/",

app/src/main/kotlin/com/github/gotify/messages/Extras.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ internal object Extras {
1818
return "text/markdown" == display["contentType"]
1919
}
2020

21-
fun <T> getNestedValue(
22-
clazz: Class<T>,
23-
extras: Map<String, Any>?,
24-
vararg keys: String
25-
): T? {
21+
fun <T> getNestedValue(clazz: Class<T>, extras: Map<String, Any>?, vararg keys: String): T? {
2622
var value: Any? = extras
2723

2824
keys.forEach { key ->

app/src/main/kotlin/com/github/gotify/messages/MessagesActivity.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import android.graphics.Canvas
99
import android.graphics.drawable.ColorDrawable
1010
import android.graphics.drawable.Drawable
1111
import android.net.Uri
12+
import android.os.Build
1213
import android.os.Bundle
1314
import android.view.Menu
1415
import android.view.MenuItem
@@ -310,7 +311,11 @@ internal class MessagesActivity :
310311
nManager.cancelAll()
311312
val filter = IntentFilter()
312313
filter.addAction(WebSocketService.NEW_MESSAGE_BROADCAST)
313-
registerReceiver(receiver, filter)
314+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
315+
registerReceiver(receiver, filter, RECEIVER_EXPORTED)
316+
} else {
317+
registerReceiver(receiver, filter)
318+
}
314319
launchCoroutine {
315320
updateMissedMessages(viewModel.messages.getLastReceivedMessage())
316321
}

app/src/main/kotlin/com/github/gotify/service/WebSocketService.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.app.NotificationManager
66
import android.app.PendingIntent
77
import android.app.Service
88
import android.content.Intent
9+
import android.content.pm.ServiceInfo
910
import android.graphics.Color
1011
import android.net.ConnectivityManager
1112
import android.net.Network
@@ -285,7 +286,15 @@ internal class WebSocketService : Service() {
285286

286287
notificationBuilder.setContentIntent(pendingIntent)
287288
notificationBuilder.color = ContextCompat.getColor(applicationContext, R.color.colorPrimary)
288-
startForeground(NotificationSupport.ID.FOREGROUND, notificationBuilder.build())
289+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
290+
startForeground(
291+
NotificationSupport.ID.FOREGROUND,
292+
notificationBuilder.build(),
293+
ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
294+
)
295+
} else {
296+
startForeground(NotificationSupport.ID.FOREGROUND, notificationBuilder.build())
297+
}
289298
}
290299

291300
private fun showNotification(

app/src/main/kotlin/com/github/gotify/settings/SettingsActivity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ internal class SettingsActivity : AppCompatActivity(), OnSharedPreferenceChangeL
5252
return false
5353
}
5454

55-
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
55+
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
56+
if (sharedPreferences == null) return
5657
when (key) {
5758
getString(R.string.setting_key_theme) -> {
5859
ThemeHelper.setTheme(

build.gradle

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ buildscript {
66
google()
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:8.0.2'
10-
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20'
9+
classpath 'com.android.tools.build:gradle:8.1.3'
10+
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10'
1111

1212
// NOTE: Do not place your application dependencies here; they belong
1313
// in the individual module build.gradle files
@@ -26,12 +26,12 @@ ext {
2626
allprojects {
2727
repositories {
2828
google()
29-
jcenter()
29+
mavenCentral()
3030
maven { url "https://jitpack.io/" }
3131
}
3232
}
3333

34-
task clean(type: Delete) {
34+
tasks.register('clean', Delete) {
3535
delete rootProject.buildDir
3636
}
3737

@@ -45,7 +45,8 @@ static def download(String url, String filename ) {
4545
}
4646
}
4747
}
48-
task downloadSpec {
48+
49+
tasks.register('downloadSpec') {
4950
inputs.property 'version', gotifyVersion
5051
doFirst {
5152
buildDir.mkdirs()

0 commit comments

Comments
 (0)