mirror of
https://github.com/lone-cloud/prism-android
synced 2026-06-03 19:54:44 -07:00
fix lint, better notification title handling
This commit is contained in:
parent
def5f2f76d
commit
719cb769b3
7 changed files with 22 additions and 28 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
<img src="app/src/main/prism.webp" alt="Prism Icon" width="160" height="160" />
|
<img src="app/src/main/prism.webp" alt="Prism Icon" width="80" height="80" />
|
||||||
|
|
||||||
# Prism
|
# Prism
|
||||||
|
|
||||||
|
|
@ -12,4 +12,4 @@ A notification provider for [Prism](https://github.com/lone-cloud/prism) and [Un
|
||||||
|
|
||||||
Use this SHA-256 signing certificate fingerprint to verify releases:
|
Use this SHA-256 signing certificate fingerprint to verify releases:
|
||||||
|
|
||||||
`A7:24:46:C6:C1:DD:C0:77:AE:91:17:2B:F6:14:74:73:A2:40:9D:30:63:53:23:25:F6:99:AC:28:63:8B:8E:B3`
|
`FD:29:86:45:7A:6A:6E:4D:D9:05:6B:3C:A5:A6:9E:0E:DF:D5:AA:9D:D4:5B:3D:78:DB:21:E8:AD:72:FB:AE:AD`
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,9 @@ package app.lonecloud.prism
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import androidx.work.Configuration
|
import androidx.work.Configuration
|
||||||
|
|
||||||
class PrismApplication : Application(), Configuration.Provider {
|
class PrismApplication :
|
||||||
|
Application(),
|
||||||
|
Configuration.Provider {
|
||||||
override val workManagerConfiguration: Configuration
|
override val workManagerConfiguration: Configuration
|
||||||
get() = Configuration.Builder().build()
|
get() = Configuration.Builder().build()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ import org.unifiedpush.android.distributor.callback.CallbackFactory
|
||||||
object BatteryCallbackFactory : CallbackFactory<BatteryCallbackFactory.MainBatteryCallback>() {
|
object BatteryCallbackFactory : CallbackFactory<BatteryCallbackFactory.MainBatteryCallback>() {
|
||||||
|
|
||||||
class MainBatteryCallback : BatteryCallback() {
|
class MainBatteryCallback : BatteryCallback() {
|
||||||
override fun onBatteryLow(context: Context) {}
|
override fun onBatteryLow(context: Context) = Unit
|
||||||
override fun onBatteryOk(context: Context) {}
|
override fun onBatteryOk(context: Context) = Unit
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun new(context: Context): MainBatteryCallback = MainBatteryCallback()
|
override fun new(context: Context): MainBatteryCallback = MainBatteryCallback()
|
||||||
|
|
|
||||||
|
|
@ -49,12 +49,12 @@ class PrismInternalService : InternalService() {
|
||||||
|
|
||||||
override fun getDebugInfo(): String = "Prism Distributor"
|
override fun getDebugInfo(): String = "Prism Distributor"
|
||||||
|
|
||||||
override fun runAppMigration() {}
|
override fun runAppMigration() = Unit
|
||||||
|
|
||||||
override fun account(): IAccount = object : IAccount {
|
override fun account(): IAccount = object : IAccount {
|
||||||
override fun get(): String? = null
|
override fun get(): String? = null
|
||||||
override fun logout() {}
|
override fun logout() = Unit
|
||||||
override fun login(data: Bundle) {}
|
override fun login(data: Bundle) = Unit
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun api(): IApi = object : IApi {
|
override fun api(): IApi = object : IApi {
|
||||||
|
|
@ -116,10 +116,8 @@ class PrismInternalService : InternalService() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun copyEndpoint(token: String?) {
|
override fun copyEndpoint(token: String?) = Unit
|
||||||
}
|
|
||||||
|
|
||||||
override fun addLocal(title: String) {
|
override fun addLocal(title: String) = Unit
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,31 +45,26 @@ object ManualAppNotifications {
|
||||||
|
|
||||||
val hasTitle = payload.title.isNotBlank()
|
val hasTitle = payload.title.isNotBlank()
|
||||||
val hasMessage = payload.message.isNotBlank()
|
val hasMessage = payload.message.isNotBlank()
|
||||||
val sender = if (hasTitle && hasMessage) payload.title else null
|
|
||||||
val bodyText = when {
|
|
||||||
hasMessage -> payload.message
|
|
||||||
hasTitle -> payload.title
|
|
||||||
else -> ""
|
|
||||||
}
|
|
||||||
|
|
||||||
val notificationId = getNotificationId(payload.tag)
|
val notificationId = getNotificationId(payload.tag)
|
||||||
val packageName = resolveTargetPackage(app)
|
val packageName = resolveTargetPackage(app)
|
||||||
|
|
||||||
val contentText = sender?.let { "$it: $bodyText" } ?: bodyText
|
val contentTitle = if (hasTitle) payload.title else appTitle
|
||||||
val bigTextStyle = NotificationCompat.BigTextStyle()
|
val contentText = if (hasMessage) payload.message else ""
|
||||||
.bigText(bodyText)
|
|
||||||
.also { style ->
|
val bigTextStyle = NotificationCompat.BigTextStyle().bigText(contentText)
|
||||||
sender?.let { style.setSummaryText(it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
val notificationBuilder = NotificationCompat.Builder(context, channelId)
|
val notificationBuilder = NotificationCompat.Builder(context, channelId)
|
||||||
.setSmallIcon(R.drawable.ic_notification)
|
.setSmallIcon(R.drawable.ic_notification)
|
||||||
.setContentTitle(appTitle)
|
.setContentTitle(contentTitle)
|
||||||
.setContentText(contentText)
|
.setContentText(contentText)
|
||||||
.setStyle(bigTextStyle)
|
.setStyle(bigTextStyle)
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setGroup(app.connectorToken)
|
.setGroup(app.connectorToken)
|
||||||
|
.apply {
|
||||||
|
if (hasTitle) setSubText(appTitle)
|
||||||
|
}
|
||||||
|
|
||||||
resolveAppIconBitmap(context, packageName)?.let { appIcon ->
|
resolveAppIconBitmap(context, packageName)?.let { appIcon ->
|
||||||
notificationBuilder.setLargeIcon(appIcon)
|
notificationBuilder.setLargeIcon(appIcon)
|
||||||
|
|
@ -108,10 +103,9 @@ object ManualAppNotifications {
|
||||||
incrementMessageCount(context, app)
|
incrementMessageCount(context, app)
|
||||||
refreshMessageCount(context)
|
refreshMessageCount(context)
|
||||||
|
|
||||||
val previewSender = sender ?: ""
|
|
||||||
val logMessage =
|
val logMessage =
|
||||||
"Displayed notification for manual app '${app.title}' " +
|
"Displayed notification for manual app '${app.title}' " +
|
||||||
"sender='$previewSender' body='${bodyText.take(120)}' (tag: ${payload.tag})"
|
"title='${payload.title.take(80)}' body='${contentText.take(120)}' (tag: ${payload.tag})"
|
||||||
Log.d(TAG, logMessage)
|
Log.d(TAG, logMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ object WebPushDecryptor {
|
||||||
val salt = ByteArray(SALT_SIZE)
|
val salt = ByteArray(SALT_SIZE)
|
||||||
record.get(salt)
|
record.get(salt)
|
||||||
|
|
||||||
val recordSize = record.int
|
record.position(record.position() + RECORD_SIZE_LEN)
|
||||||
val publicKeySize = record.get().toInt()
|
val publicKeySize = record.get().toInt()
|
||||||
if (publicKeySize != PUBLIC_KEY_SIZE) return null
|
if (publicKeySize != PUBLIC_KEY_SIZE) return null
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 16 KiB |
Loading…
Add table
Reference in a new issue