aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2021-09-13 21:57:45 -0700
committerAllan Wang <me@allanwang.ca>2021-09-13 21:57:45 -0700
commit22972373e5a9a74250971eb869c626ae6397ad76 (patch)
tree311ce3b9da0279bd00877c94e10c7934b416a7cb /app/src
parentd4c64b800ffcfd5590c3a18c8bf5cf75ee74f3b4 (diff)
downloadfrost-22972373e5a9a74250971eb869c626ae6397ad76.tar.gz
frost-22972373e5a9a74250971eb869c626ae6397ad76.tar.bz2
frost-22972373e5a9a74250971eb869c626ae6397ad76.zip
Fix pending intent for Android 12
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/widgets/NotificationWidget.kt6
-rw-r--r--app/src/main/play/en-US/whatsnew3
-rw-r--r--app/src/main/res/xml/frost_changelog.xml1
4 files changed, 14 insertions, 4 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
index 5b260dee..e050ad5a 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
@@ -59,6 +59,10 @@ import kotlin.math.abs
*/
private val _40_DP = 40.dpToPx
+private val pendingIntentFlagUpdateCurrent: Int
+ get() = PendingIntent.FLAG_UPDATE_CURRENT or
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) PendingIntent.FLAG_IMMUTABLE else 0
+
/**
* Enum to handle notification creations
*/
@@ -227,7 +231,7 @@ enum class NotificationType(
putContentExtra(intent, content)
val group = "${groupPrefix}_${data.id}"
val pendingIntent =
- PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
+ PendingIntent.getActivity(context, 0, intent, pendingIntentFlagUpdateCurrent)
val notifBuilder = context.frostNotification(channelId)
.setContentTitle(title ?: context.string(R.string.frost_name))
.setContentText(text)
@@ -266,7 +270,7 @@ enum class NotificationType(
intent.data = Uri.parse(fbItem.url)
val group = "${groupPrefix}_$userId"
val pendingIntent =
- PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
+ PendingIntent.getActivity(context, 0, intent, pendingIntentFlagUpdateCurrent)
val notifBuilder = context.frostNotification(channelId)
.setContentTitle(context.string(R.string.frost_name))
.setContentText("$count ${context.string(fbItem.titleId)}")
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/widgets/NotificationWidget.kt b/app/src/main/kotlin/com/pitchedapps/frost/widgets/NotificationWidget.kt
index 9c5fbb7d..d610a535 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/widgets/NotificationWidget.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/widgets/NotificationWidget.kt
@@ -86,7 +86,7 @@ class NotificationWidget : AppWidgetProvider() {
context,
0,
type.createCommonIntent(context, userId),
- PendingIntent.FLAG_UPDATE_CURRENT
+ pendingIntentFlagUpdateCurrent
)
views.setPendingIntentTemplate(R.id.widget_notification_list, pendingIntentTemplate)
@@ -96,6 +96,10 @@ class NotificationWidget : AppWidgetProvider() {
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.widget_notification_list)
}
+ private val pendingIntentFlagUpdateCurrent: Int
+ get() = PendingIntent.FLAG_UPDATE_CURRENT or
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) PendingIntent.FLAG_IMMUTABLE else 0
+
companion object {
fun forceUpdate(context: Context) {
val manager = AppWidgetManager.getInstance(context)
diff --git a/app/src/main/play/en-US/whatsnew b/app/src/main/play/en-US/whatsnew
index ea4ee41f..f9e930b8 100644
--- a/app/src/main/play/en-US/whatsnew
+++ b/app/src/main/play/en-US/whatsnew
@@ -2,4 +2,5 @@ v3.1.0
* Fix multi account sign in
* Only clear out cookies on explicit logout; Facebook logout redirects no longer erase cookies
-* Update themes \ No newline at end of file
+* Update themes
+* Big infra changes (please file bugs for new crashes) \ No newline at end of file
diff --git a/app/src/main/res/xml/frost_changelog.xml b/app/src/main/res/xml/frost_changelog.xml
index ed3ea6e7..292d62bb 100644
--- a/app/src/main/res/xml/frost_changelog.xml
+++ b/app/src/main/res/xml/frost_changelog.xml
@@ -10,6 +10,7 @@
<item text="Fix multi account sign in" />
<item text="Only clear out cookies on explicit logout; Facebook logout redirects no longer erase cookies" />
<item text="Update themes" />
+ <item text="Big infra changes (please file bugs for new crashes)" />
<version title="v3.0.0" />
<item text="Removed email support. Please use GitHub for all inquiries as I no longer have time to look through all emails" />