Fix widget clicks for older Android versions

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-05-21 14:20:01 +02:00
parent ae5bbf1ab8
commit 7e7c7e676c
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF

View file

@ -84,7 +84,7 @@ class DashboardWidgetUpdater @Inject constructor(
context,
0,
intent,
getPendingIntentFlags()
pendingIntentFlags
)
remoteViews.setPendingIntentTemplate(R.id.list, pendingIntent)
@ -123,7 +123,7 @@ class DashboardWidgetUpdater @Inject constructor(
context,
appWidgetId,
intent,
getPendingIntentFlags()
pendingIntentFlags
)
}
@ -138,17 +138,17 @@ class DashboardWidgetUpdater @Inject constructor(
context,
appWidgetId,
intent,
getPendingIntentFlags()
pendingIntentFlags
)
}
private fun getPendingIntentFlags(): Int {
return PendingIntent.FLAG_UPDATE_CURRENT or if (Build.VERSION.SDK_INT >= 34) {
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT
} else if (Build.VERSION.SDK_INT >= 31) {
PendingIntent.FLAG_MUTABLE
} else {
PendingIntent.FLAG_IMMUTABLE
private val pendingIntentFlags: Int = when {
Build.VERSION.SDK_INT >= 34 -> {
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT
}
else -> {
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
}
}
// endregion