feat: allow configuring widgetCategory - #153
Open
lebowr wants to merge 1 commit into
Open
Conversation
The generated appwidget-provider XML hardcoded android:widgetCategory="home_screen", so a widget could not declare itself eligible for the lock screen. Android shows third-party widgets on the lock screen from Android 16 QPR2, and on some tablets from Android 15 QPR1. Widgets are eligible by default there, but a host that filters on the declared category only offers widgets naming it, and there was no way to opt in — or, with not_keyguard, to opt out. Defaults to home_screen, so generated XML is unchanged unless the new option is set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The generated
appwidget-providerXML hardcodesandroid:widgetCategory="home_screen", so a widget built with this library cannot declare itself eligible for the lock screen.Android shows third-party widgets on the lock screen from Android 16 QPR2 (and on some tablets from Android 15 QPR1). Widgets are eligible by default there, but a host that filters on the declared category only offers widgets that name it — and there was no way to opt in, nor to opt out with
not_keyguard.Today the only workaround is patch-package on
app.plugin.js, which is how I found this.Change
Adds an optional
widgetCategoryto theWidgetconfig type, used by the XML template:Backward compatible: it falls back to
'home_screen', so generated XML is byte-identical for every existing config.Verification
I've been running the equivalent change as a patch in a shipping app with three widgets. After
expo prebuild, all three providers generate:and
adb shell dumpsys appwidgetreportswidgetCategory=3(HOME_SCREEN|KEYGUARD). Home-screen behaviour is unchanged — launchers ignore the extra bit.I did not add a test, since
src/__tests__is currentlyit.todo('write a test')and the plugin has no test harness to extend; happy to add one if you'd like to seed that.Docs
Added the attribute to the manual-registration tutorial's attribute list, alongside
updatePeriodMillisand friends.References
AppWidgetProviderInfo#widgetCategory