-
-
Notifications
You must be signed in to change notification settings - Fork 232
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
Document how to use package with Jetpack Glance #181
Conversation
Thank you so much for this! Would you have time to work on this a bit more? I think we should definitely check that also interactivity is working with Glance. |
@ABausG hi, I am not really sure about that. Glance makes a lot of things and even the current widget update does not work. Now I discovered that the update using intent actually works, but still we have to update Preferences to make it work, so Glance probably only refresh widget when the state actually changes? That however does not modify the code since we need to update the Glance state first... We could probably make custom provider/receiver that extends So I am not really sure how to improve that... |
LMAO I figured it out! It seems using ... seems as a Glance way of doing ^^ which is also not mentioned that you have to do btw... So we should probably also mention it? Because w/o it even regular widgets won't update. |
That's all @ABausG. This is what I tried/know about Jetpack Glance and this package:
|
@ABausG what do you think about these changes? |
Could you also review this Note I tried to use getActivity and then .send() on it, which does not work. 🤔 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #181 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 67 67
=========================================
Hits 67 67 ☔ View full report in Codecov by Sentry. |
So you can use glance widgets without a problem? Or you are going to work on it again? |
Yes, we are using Jetpack Glance for our Flutter app with no problem (we are almost production ready). And we are using this home_widget package to help us with widget updating from an app, handling app initial opening and widget clicks etc. (we are not using that get/save widget data helper since we decided to use shared preferences and secure storage for that directly) We plan to write (hopefully till the end of the year) an article on our blog, as mentioned in my tweet https://twitter.com/tenhobi/status/1729969425057567149. So I hope that will help people with making a home widget for Flutter apps 👍 |
Thank you for your quick response 👍 And good luck with your project :) |
Thanks for this contribution @tenhobi here is my plan: I am preparing right now the release of 0.3.1 which will include some general fixes for Android. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you again so much for this. Apart from the comments some wishes/questions:
- Could you please make this target the
dev
branch? As I described I plan to release this as 0.5.0 after iOS Interactivity is released (should be beginning of this week) and there are some changes to the README Structure that might affect this PR - I think it would be great if we could add an example Widget using Glance to the example App on top of the available Widget. This does not need to be in this PR. Let me know if you would have time for that. Otherwise I should be able to do this as well.
- Regarding updating the Glance Widget. Have you played around at all if it is somehow possible to detect that whatever class is being found in the updateWidget method in the Plugin and update the state from there? https://developer.android.com/jetpack/compose/glance/glance-app-widget#update-glanceappwidget
README.md
Outdated
// Shared Preferences used by Flutter | ||
context.getSharedPreferences("FlutterSharedPreferences", Context.MODE_PRIVATE) | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that you are using the default SharedPreferences however I think this might be confusing for people as I think the default should be for people to simply use the data from HomeWidget.
Not sure if maybe an extension exposed by the package that has a getter for the HomeWidget Data might make sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, you are probably right! I will delete this note then. :)
README.md
Outdated
@@ -133,6 +153,58 @@ This Name needs to be equal to the Classname of the [WidgetProvider](#Write-your | |||
The name for iOS will be chosen by checking `iOSName` if that was not provided it will fallback to `name`. | |||
This name needs to be equal to the Kind specified in you Widget | |||
|
|||
#### Standard widgets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might need an ### Android
Title
@@ -79,13 +79,16 @@ class HomeWidgetPlugin : FlutterPlugin, MethodCallHandler, ActivityAware, | |||
"updateWidget" -> { | |||
val qualifiedName = call.argument<String>("qualifiedAndroidName") | |||
val className = call.argument<String>("android") ?: call.argument<String>("name") | |||
val androidIsUsingGlance = call.argument<Boolean>("androidIsUsingGlance") ?: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed anymore is it?
|
No worries. Let's sync before starting it and we'll get that added 👍
Yes! And I think it would be enough if my idea doesn't work. |
I am not sure if you can, since the provider/receiver should probable handle that (the same way as for regular android widget here https://github.com/ABausG/home_widget/blob/main/example/android/app/src/main/kotlin/es/antonborri/home_widget_example/HomeWidgetExampleProvider.kt#L54). And you need that update anyway. The regular 30 minute refresh triggers this method on provider/receiver, not the plugin. And it might be contraproductive to doing it automatically (if somehow possible) for updates from Flutter, and not for this. And what more: for Glance, as shown in the initial draft, you must use the YourWidget class and call updates on that. And I was only able to do that using some static variable and adding an initializer (which I wrongly put in Flutter activity, not to the Flutter App itself and therefore if no app is ran and only widget is running it might fail hah). |
@tenhobi Not sure what happened here. But for some reason the PR got closed. Says it is merged however it not really is merged. Would you mind reopening the PR? Think this is mergeable to the dev branch now! |
Interesting. Sure, will do that all on Friday probably |
@tenhobi would you mind reopening this (against main)? |
I will reopen this from a new branch. I have to recover the changes from the PR. |
Hello @tenhobi, thankyou so much for this great plugin. Any update on the example app using Glance. |
I'm working on it! Hope to get it done soon!! |
When trying to update my Jetpack Glance from Flutter app, it does not trigger the update. I therefore did update this package so it works with Glance.
Firstly I wanted to make a superclass that would my glance widget had to import, but that did not work. So I changed the code so it uses config where I "register" the Glance widget so the plugin can use the concrete widget class to trigger updates.
This is partially related to #134
//
Btw. while trying out this package, I tested that initial launch as well as widget clicked listener works. 👍 (other things I did not try)