Fix adding media player widget from settings (#2813)

- Adding a media player widget from settings didn't work because the list used to check that entities have been selected isn't updated immediately, but only on load or in a callback after pinning the widget. To work around this, manually check it before pinning the widget.
This commit is contained in:
Joris Pelgröm 2022-08-30 02:26:39 +02:00 committed by GitHub
parent db8913c712
commit af0371fb7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,7 +66,10 @@ class MediaPlayerControlsWidgetConfigureActivity : BaseWidgetConfigureActivity()
binding.addButton.setOnClickListener {
if (requestLauncherSetup) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && selectedEntities.size > 0) {
if (
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
binding.widgetTextConfigEntityId.text.split(",").any { entities[it.trim()] != null }
) {
getSystemService<AppWidgetManager>()?.requestPinAppWidget(
ComponentName(this, MediaPlayerControlsWidget::class.java),
null,