Merge pull request #325 from cyb3rko/update-build
This commit is contained in:
@@ -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"
|
||||
@@ -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">
|
||||
|
||||
@@ -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,
|
||||
@@ -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
|
||||
|
||||
@@ -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/",
|
||||
|
||||
@@ -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 ->
|
||||
|
||||
@@ -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
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user