Closed frmz closed 9 years ago
Hmm, got it. Can you write me some steps to reproduce the issue? Setting clock widget (KWGT) worked perfectly fine.
So KWGT has 2 ways of getting its size, the first one is to use AppWidgetManager.getAppWidgetOptions() to ask the WidgetHost the pixel size, this is the preferred way because this is done every time the widget updates. If this returns 0 (like in AC display), KWGT will use the size returned in the Bundle when the user clicks on the widget, this works but its not capable of handling sizes change (so if AC Display scales the widget because of a rotation or things like that the widget will not know this and result might not be perfect).
So this would be a nice to have, Launcher3 correctly implements this as many WidgetHosts do so it should be easy to copy code from there.
Thanks. So updateAppWidgetSize(Bundle newOptions, int minWidth, int minHeight, int maxWidth, int maxHeight)
. Will it be better to set the current width/height as both min and max, or pass really minimum and maximum values (so widget can be scaled between them)?
So the way Launcher 3 does this is the following: updateAppWidgetSize(Bundle newOptions, int portraitWidth, int landscapeHeight, int landscapeWidth, int portraitHeight)
It does this way because a widget is larger in landscape and taller in portrait. A widget generally will use "minWidth" x "maxHeight" when screen is in portrait and "maxWidth" x "minHeight" when screen is in landscape.
I think best option for you is to set both min and max to the current size as you said. Then you call this method again in case screen is rotated or in case the area changes its size, the widget will update as soon as its get the update.
Great!
Currently ACDisplay is not correctly setting widget width / height via AppWidgetHostView.updateAppWidgetSize(), this causes widget that rely on this to not work properly (KWGT). This should be easy to implement since AC Display already knows the size.