Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widget size issues on different Android launchers #34

Open
sAleksovski opened this issue Aug 6, 2023 · 3 comments
Open

Widget size issues on different Android launchers #34

sAleksovski opened this issue Aug 6, 2023 · 3 comments

Comments

@sAleksovski
Copy link
Owner

We cannot render React Native views directly to the widget.
What this library does is render the React Native views to an image, and then show that image in the widget.
For it to look good, we need to know the exact size of the widget, so we can create an image that will fit the widget correctly.

On some Android launchers, the reported and actual size of the widget are not always the same.

Actual size
Actual size (365dp x 318dp)

Reported size
Reported size (365dp x 354dp)

I haven't found a reliable way to get the exact size, the current behavior is to crop the widget if the reported size is smaller.

@OPavliuk-delhaize
Copy link

We have a problem the size of the widget does not come at all, it returns width:0 and height: 0. Of all the tested phones, this is observed only on Samsungs.

Debugging showed that the value 0 is returned by the method

public static int getWidgetSizeInDp(Context context, int widgetId, String key) {
 return AppWidgetManager.getInstance(context).getAppWidgetOptions(widgetId).getInt(key, 0);
 }

in java/com/reactnativeandroidwidget/RNWidgetUtil.java

Do you have ideas about what could be the problem?
Looks like some sort of asynchronous code-handling error.

We've minimized the impact of this bug by setting default sizes for width and height, but even once valid non-zero values ​​are received, they are stored in the app and used in the widget.

@sAleksovski
Copy link
Owner Author

Does it received 0 only when first added?

I don't know any other way to get the widget size.
You can try to request another widget update if you receive 0 sizes.

Btw I have a Samsung phone and I receive correct sizes.

@OPavliuk-delhaize
Copy link

Yes, 0 comes precisely for adding the widget. But this does not always happen.

It's an interesting idea to update the widget again if the value is 0, I'll try.

Maybe you're lucky. We have this problem consistently on Samsung S24+ and Samsung Galaxy A13 Android 14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants