Merge branch '6.0-MAINT' into main
This commit is contained in:
commit
391d45d52b
7 changed files with 26 additions and 110 deletions
|
@ -30,15 +30,7 @@ internal open class AuthenticationErrorNotificationController(
|
|||
.setStyle(NotificationCompat.BigTextStyle().bigText(text))
|
||||
.setPublicVersion(createLockScreenNotification(account))
|
||||
.setCategory(NotificationCompat.CATEGORY_ERROR)
|
||||
|
||||
notificationHelper.configureNotification(
|
||||
builder = notificationBuilder,
|
||||
ringtone = null,
|
||||
vibrationPattern = null,
|
||||
ledColor = NotificationHelper.NOTIFICATION_LED_FAILURE_COLOR,
|
||||
ledSpeed = NotificationHelper.NOTIFICATION_LED_BLINK_FAST,
|
||||
ringAndVibrate = true
|
||||
)
|
||||
.setErrorAppearance()
|
||||
|
||||
notificationManager.notify(notificationId, notificationBuilder.build())
|
||||
}
|
||||
|
|
|
@ -30,15 +30,7 @@ internal open class CertificateErrorNotificationController(
|
|||
.setStyle(NotificationCompat.BigTextStyle().bigText(text))
|
||||
.setPublicVersion(createLockScreenNotification(account))
|
||||
.setCategory(NotificationCompat.CATEGORY_ERROR)
|
||||
|
||||
notificationHelper.configureNotification(
|
||||
builder = notificationBuilder,
|
||||
ringtone = null,
|
||||
vibrationPattern = null,
|
||||
ledColor = NotificationHelper.NOTIFICATION_LED_FAILURE_COLOR,
|
||||
ledSpeed = NotificationHelper.NOTIFICATION_LED_BLINK_FAST,
|
||||
ringAndVibrate = true
|
||||
)
|
||||
.setErrorAppearance()
|
||||
|
||||
notificationManager.notify(notificationId, notificationBuilder.build())
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.fsck.k9.notification
|
|||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.text.TextUtils
|
||||
import android.os.Build
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import com.fsck.k9.Account
|
||||
|
@ -13,47 +13,6 @@ class NotificationHelper(
|
|||
private val notificationManager: NotificationManagerCompat,
|
||||
private val channelUtils: NotificationChannelManager
|
||||
) {
|
||||
fun configureNotification(
|
||||
builder: NotificationCompat.Builder,
|
||||
ringtone: String?,
|
||||
vibrationPattern: LongArray?,
|
||||
ledColor: Int?,
|
||||
ledSpeed: Int,
|
||||
ringAndVibrate: Boolean
|
||||
) {
|
||||
|
||||
if (K9.isQuietTime) {
|
||||
builder.setNotificationSilent()
|
||||
return
|
||||
}
|
||||
|
||||
if (ringAndVibrate) {
|
||||
if (ringtone != null && !TextUtils.isEmpty(ringtone)) {
|
||||
builder.setSound(Uri.parse(ringtone))
|
||||
}
|
||||
|
||||
if (vibrationPattern != null) {
|
||||
builder.setVibrate(vibrationPattern)
|
||||
}
|
||||
} else {
|
||||
builder.setNotificationSilent()
|
||||
}
|
||||
|
||||
if (ledColor != null) {
|
||||
val ledOnMS: Int
|
||||
val ledOffMS: Int
|
||||
if (ledSpeed == NOTIFICATION_LED_BLINK_SLOW) {
|
||||
ledOnMS = NOTIFICATION_LED_ON_TIME
|
||||
ledOffMS = NOTIFICATION_LED_OFF_TIME
|
||||
} else {
|
||||
ledOnMS = NOTIFICATION_LED_FAST_ON_TIME
|
||||
ledOffMS = NOTIFICATION_LED_FAST_OFF_TIME
|
||||
}
|
||||
|
||||
builder.setLights(ledColor, ledOnMS, ledOffMS)
|
||||
}
|
||||
}
|
||||
|
||||
fun getContext(): Context {
|
||||
return context
|
||||
}
|
||||
|
@ -75,12 +34,22 @@ class NotificationHelper(
|
|||
companion object {
|
||||
internal const val NOTIFICATION_LED_ON_TIME = 500
|
||||
internal const val NOTIFICATION_LED_OFF_TIME = 2000
|
||||
private const val NOTIFICATION_LED_FAST_ON_TIME = 100
|
||||
private const val NOTIFICATION_LED_FAST_OFF_TIME = 100
|
||||
internal const val NOTIFICATION_LED_FAST_ON_TIME = 100
|
||||
internal const val NOTIFICATION_LED_FAST_OFF_TIME = 100
|
||||
|
||||
internal const val NOTIFICATION_LED_BLINK_SLOW = 0
|
||||
internal const val NOTIFICATION_LED_BLINK_FAST = 1
|
||||
internal const val NOTIFICATION_LED_FAILURE_COLOR = -0x10000
|
||||
internal const val NOTIFICATION_LED_FAILURE_COLOR = 0xFFFF0000L.toInt()
|
||||
}
|
||||
}
|
||||
|
||||
internal fun NotificationCompat.Builder.setErrorAppearance(): NotificationCompat.Builder = apply {
|
||||
setSilent(true)
|
||||
|
||||
if (!K9.isQuietTime) {
|
||||
setLights(
|
||||
NotificationHelper.NOTIFICATION_LED_FAILURE_COLOR,
|
||||
NotificationHelper.NOTIFICATION_LED_FAST_ON_TIME,
|
||||
NotificationHelper.NOTIFICATION_LED_FAST_OFF_TIME
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,7 +59,7 @@ internal fun NotificationCompat.Builder.setAppearance(
|
|||
): NotificationCompat.Builder = apply {
|
||||
if (silent) {
|
||||
setSilent(true)
|
||||
} else {
|
||||
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||
if (!appearance.ringtone.isNullOrEmpty()) {
|
||||
setSound(Uri.parse(appearance.ringtone))
|
||||
}
|
||||
|
|
|
@ -42,15 +42,7 @@ internal class SendFailedNotificationController(
|
|||
.setStyle(NotificationCompat.BigTextStyle().bigText(text))
|
||||
.setPublicVersion(createLockScreenNotification(account))
|
||||
.setCategory(NotificationCompat.CATEGORY_ERROR)
|
||||
|
||||
notificationHelper.configureNotification(
|
||||
builder = notificationBuilder,
|
||||
ringtone = null,
|
||||
vibrationPattern = null,
|
||||
ledColor = NotificationHelper.NOTIFICATION_LED_FAILURE_COLOR,
|
||||
ledSpeed = NotificationHelper.NOTIFICATION_LED_BLINK_FAST,
|
||||
ringAndVibrate = true
|
||||
)
|
||||
.setErrorAppearance()
|
||||
|
||||
notificationManager.notify(notificationId, notificationBuilder.build())
|
||||
}
|
||||
|
|
|
@ -6,8 +6,6 @@ import androidx.core.app.NotificationManagerCompat
|
|||
import com.fsck.k9.Account
|
||||
import com.fsck.k9.mailstore.LocalFolder
|
||||
|
||||
private const val NOTIFICATION_LED_WHILE_SYNCING = false
|
||||
|
||||
internal class SyncNotificationController(
|
||||
private val notificationHelper: NotificationHelper,
|
||||
private val actionBuilder: NotificationActionCreator,
|
||||
|
@ -36,17 +34,6 @@ internal class SyncNotificationController(
|
|||
.setContentIntent(showMessageListPendingIntent)
|
||||
.setPublicVersion(createSendingLockScreenNotification(account))
|
||||
|
||||
if (NOTIFICATION_LED_WHILE_SYNCING) {
|
||||
notificationHelper.configureNotification(
|
||||
builder = notificationBuilder,
|
||||
ringtone = null,
|
||||
vibrationPattern = null,
|
||||
ledColor = account.notificationSettings.light.toColor(account),
|
||||
ledSpeed = NotificationHelper.NOTIFICATION_LED_BLINK_FAST,
|
||||
ringAndVibrate = true
|
||||
)
|
||||
}
|
||||
|
||||
notificationManager.notify(notificationId, notificationBuilder.build())
|
||||
}
|
||||
|
||||
|
@ -83,17 +70,6 @@ internal class SyncNotificationController(
|
|||
.setPublicVersion(createFetchingMailLockScreenNotification(account))
|
||||
.setCategory(NotificationCompat.CATEGORY_SERVICE)
|
||||
|
||||
if (NOTIFICATION_LED_WHILE_SYNCING) {
|
||||
notificationHelper.configureNotification(
|
||||
builder = notificationBuilder,
|
||||
ringtone = null,
|
||||
vibrationPattern = null,
|
||||
ledColor = account.notificationSettings.light.toColor(account),
|
||||
ledSpeed = NotificationHelper.NOTIFICATION_LED_BLINK_FAST,
|
||||
ringAndVibrate = true
|
||||
)
|
||||
}
|
||||
|
||||
notificationManager.notify(notificationId, notificationBuilder.build())
|
||||
}
|
||||
|
||||
|
@ -113,17 +89,6 @@ internal class SyncNotificationController(
|
|||
.setPublicVersion(createFetchingMailLockScreenNotification(account))
|
||||
.setCategory(NotificationCompat.CATEGORY_SERVICE)
|
||||
|
||||
if (NOTIFICATION_LED_WHILE_SYNCING) {
|
||||
notificationHelper.configureNotification(
|
||||
builder = notificationBuilder,
|
||||
ringtone = null,
|
||||
vibrationPattern = null,
|
||||
ledColor = account.notificationSettings.light.toColor(account),
|
||||
ledSpeed = NotificationHelper.NOTIFICATION_LED_BLINK_FAST,
|
||||
ringAndVibrate = true
|
||||
)
|
||||
}
|
||||
|
||||
notificationManager.notify(notificationId, notificationBuilder.build())
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
Locale-specific versions are kept in res/raw-<locale qualifier>/changelog.xml.
|
||||
-->
|
||||
<changelog>
|
||||
<release version="5.916" versioncode="29016" date="2022-04-12">
|
||||
<change>Fixed bug that crashed the app when setting a notification sound on certain devices</change>
|
||||
<change>Fixed crash when rotating the device while a delete confirmation dialog was showing</change>
|
||||
</release>
|
||||
<release version="5.915" versioncode="29015" date="2022-04-06">
|
||||
<change>Fixed settings import</change>
|
||||
<change>Fixed bug where the configuration of a notification category wasn't properly synced with in-app notification settings</change>
|
||||
|
|
2
fastlane/metadata/android/en-US/changelogs/29016.txt
Normal file
2
fastlane/metadata/android/en-US/changelogs/29016.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
- Fixed bug that crashed the app when setting a notification sound on certain devices
|
||||
- Fixed crash when rotating the device while a delete confirmation dialog was showing
|
Loading…
Reference in a new issue