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

feat: Add a way to to obtain information about the pinned widgets #233

Merged
merged 13 commits into from Mar 24, 2024

Conversation

qwadrox
Copy link
Contributor

@qwadrox qwadrox commented Mar 10, 2024

Would address
#129
#223
#37

@qwadrox
Copy link
Contributor Author

qwadrox commented Mar 10, 2024

ABausG Can you take a look? :)

Copy link
Owner

@ABausG ABausG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a had a quick first glance. All in all looks already really good and will be super helpful!

Am I correct in assuming that getting the size of an installed widget is not possible on Android as the way I understand the API and your implementation of accessing the Info is that using the widgetIds of the Installed/Pinned Widgets it gets the general configuration of the widget so a min/max size would be possible but not the actual size the user is using? I guess that Information is not really relevant to users of home_widget as they are defining that. Do you have any idea/experience if it would be possible to get that information anyway? Ideally in this call?

example/lib/main.dart Outdated Show resolved Hide resolved
@qwadrox
Copy link
Contributor Author

qwadrox commented Mar 11, 2024

Just a had a quick first glance. All in all looks already really good and will be super helpful!

Am I correct in assuming that getting the size of an installed widget is not possible on Android as the way I understand the API and your implementation of accessing the Info is that using the widgetIds of the Installed/Pinned Widgets it gets the general configuration of the widget so a min/max size would be possible but not the actual size the user is using? I guess that Information is not really relevant to users of home_widget as they are defining that. Do you have any idea/experience if it would be possible to get that information anyway? Ideally in this call?

My original idea differed slightly, but you're grasping it well.

Here's what I know:

  • The current approach, using getAppWidgetInfo, retrieves the AppWidgetProviderInfo, with its fields corresponding to those in the XML tag. This means the values are predefined, providing enough information to differentiate each widget instance. Additionally, each instance has a unique widgetId, which can be useful for saving specific information to shared preferences, such as the layout used for the RemoteView or the values being displayed at a given time. So the widgetId offers flexibility in what information we can save.

  • Moreover, it's possible to obtain the actual size in dips of the widgets by relying on getAppWidgetOptions. This size changes when adjusting the width or height. This feature can be useful for size calculations, and these properties are also settable. Although the "actual" size might be irrelevant in some cases, it can still be beneficial for certain applications (?) You can explore this functionality further in the comments on this branch: 8753880. Feel free to try it out as well. 😄

  • In my case it was irrelevant. Thats why I did not include these infos.

  • Installed/Pinned yes. Installed have a different meaning in android. Every widget on your phone even if you didn't place on home screen is installed, from all apps. That's why getInstalledProviders() is not good for us. Maybe we should avoid using "installed" word.

@ABausG

Copy link

codecov bot commented Mar 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (b3b9dd9) to head (fead5c0).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #233   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         3    +1     
  Lines           73       103   +30     
=========================================
+ Hits            73       103   +30     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@qwadrox qwadrox requested a review from ABausG March 15, 2024 18:34
@ABausG ABausG mentioned this pull request Mar 21, 2024
Copy link
Owner

@ABausG ABausG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great!

I just refactored some variables in HomeWidgetInfo to include OS prefixes for all variables to make everything a bit clearer and indicate why certain things might be null.

Excited to fit this in to the next release!

@ABausG ABausG merged commit 8c8a79e into ABausG:main Mar 24, 2024
5 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants