Ensure unique broadcasts

pull/3207/head
Alex Baker 12 months ago
parent f4863b813a
commit 7a51e72ca4

@ -232,19 +232,18 @@ abstract class BaseListSettingsActivity : AppCompatActivity(), ColorPalettePicke
} }
protected fun createWidget() { protected fun createWidget() {
val filter = filter ?: return
val appWidgetManager = getSystemService(AppWidgetManager::class.java) val appWidgetManager = getSystemService(AppWidgetManager::class.java)
if (AndroidUtilities.atLeastOreo() && appWidgetManager.isRequestPinAppWidgetSupported) { if (AndroidUtilities.atLeastOreo() && appWidgetManager.isRequestPinAppWidgetSupported) {
val provider = ComponentName(this, TasksWidget::class.java) val provider = ComponentName(this, TasksWidget::class.java)
val configIntent = Intent(this, RequestPinWidgetReceiver::class.java).apply { val configIntent = Intent(this, RequestPinWidgetReceiver::class.java).apply {
action = RequestPinWidgetReceiver.ACTION_CONFIGURE_WIDGET action = RequestPinWidgetReceiver.ACTION_CONFIGURE_WIDGET
filter?.let { putExtra(EXTRA_FILTER, defaultFilterProvider.getFilterPreferenceValue(filter))
putExtra(EXTRA_FILTER, defaultFilterProvider.getFilterPreferenceValue(it))
}
putExtra(EXTRA_COLOR, baseViewModel.color) putExtra(EXTRA_COLOR, baseViewModel.color)
} }
val successCallback = PendingIntent.getBroadcast( val successCallback = PendingIntent.getBroadcast(
this, this,
0, filter.hashCode(),
configIntent, configIntent,
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) PendingIntent.FLAG_MUTABLE else PendingIntent.FLAG_UPDATE_CURRENT if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) PendingIntent.FLAG_MUTABLE else PendingIntent.FLAG_UPDATE_CURRENT
) )

Loading…
Cancel
Save