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 fixes #1488

Merged
merged 5 commits into from
Sep 10, 2022
Merged

Widget fixes #1488

merged 5 commits into from
Sep 10, 2022

Conversation

iSoron
Copy link
Owner

@iSoron iSoron commented Sep 3, 2022

This PR implements some last-minute fixes related to widgets:

  1. As mentioned in Checkmark widget (update) does not work in Android 13 #1463, API 33 apparently requires us to use setPendingIntentTemplate and setOnClickFillInIntent instead of setOnClickPendingIntent, otherwise the clicks have no effect. This PR implements those changes.

    @hiqua Could you try it out and confirm that it has fixed the issue?

    Unfortunately this intent template system requires all widgets in the collection to have the same type of intent; so if one of the habits in the StackWidget is numerical (and therefore requires us to launch an activity with a number picker), then, from what I understand, all widgets in the stack must also launch an activity. One potential workaround would be to have all widgets launch a BroadcastReceiver, then the receiver could launch an activity conditionally, but unfortunately this behavior is now also forbidden since API 32.

  2. This PR also fixes The measurable checkmark widget is not working as intended #1468

@iSoron iSoron changed the title Use pending intent templates on StackWidget Widget fixes Sep 3, 2022
@hiqua
Copy link
Collaborator

hiqua commented Sep 5, 2022

I think I got a crash while creating a widget:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: org.isoron.uhabits, PID: 1780
    java.lang.RuntimeException: Unable to bind to service org.isoron.uhabits.widgets.StackWidgetService@d5ed17e with Intent { dat=intent: cmp=org.isoron.uhabits/.widgets.StackWidgetService (has extras) }: java.lang.NumberFormatException: For input string: ""
        at android.app.ActivityThread.handleBindService(ActivityThread.java:4560)
        at android.app.ActivityThread.-$$Nest$mhandleBindService(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2167)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7898)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
     Caused by: java.lang.NumberFormatException: For input string: ""
        at java.lang.Long.parseLong(Long.java:746)
        at java.lang.Long.parseLong(Long.java:861)
        at org.isoron.platform.utils.StringUtils$Companion.splitLongs(StringUtils.kt:28)
        at org.isoron.uhabits.widgets.StackRemoteViewsFactory.<init>(StackWidgetService.kt:168)
        at org.isoron.uhabits.widgets.StackWidgetService.onGetViewFactory(StackWidgetService.kt:43)
        at android.widget.RemoteViewsService.onBind(RemoteViewsService.java:241)
        at android.app.ActivityThread.handleBindService(ActivityThread.java:4545)
        at android.app.ActivityThread.-$$Nest$mhandleBindService(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2167) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loopOnce(Looper.java:201) 
        at android.os.Looper.loop(Looper.java:288) 
        at android.app.ActivityThread.main(ActivityThread.java:7898) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) 
W/System.err: java.lang.RuntimeException: Unable to bind to service org.isoron.uhabits.widgets.StackWidgetService@d5ed17e with Intent { dat=intent: cmp=org.isoron.uhabits/.widgets.StackWidgetService (has extras) }: java.lang.NumberFormatException: For input string: ""
W/System.err:     at android.app.ActivityThread.handleBindService(ActivityThread.java:4560)
W/System.err:     at android.app.ActivityThread.-$$Nest$mhandleBindService(Unknown Source:0)
W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2167)
W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:106)
W/System.err:     at android.os.Looper.loopOnce(Looper.java:201)
W/System.err:     at android.os.Looper.loop(Looper.java:288)
W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7898)
W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
W/System.err: Caused by: java.lang.NumberFormatException: For input string: ""
W/System.err:     at java.lang.Long.parseLong(Long.java:746)
W/System.err:     at java.lang.Long.parseLong(Long.java:861)
W/System.err:     at org.isoron.platform.utils.StringUtils$Companion.splitLongs(StringUtils.kt:28)
W/System.err:     at org.isoron.uhabits.widgets.StackRemoteViewsFactory.<init>(StackWidgetService.kt:168)
W/System.err:     at org.isoron.uhabits.widgets.StackWidgetService.onGetViewFactory(StackWidgetService.kt:43)
W/System.err:     at android.widget.RemoteViewsService.onBind(RemoteViewsService.java:241)
W/System.err:     at android.app.ActivityThread.handleBindService(ActivityThread.java:4545)
W/System.err: 	... 9 more
I/Process: Sending signal. PID: 1780 SIG: 9

Not sure if it's just my emulator (which also crashed afterwards) or the app...

After rebooting it, the simple widgets seem to work, but the stacked widget tends to disappear for some reason, see video

simplescreenrecorder-2022-09-05_20.28.54.mp4

Do you have the same issues in the emulator?

@iSoron
Copy link
Owner Author

iSoron commented Sep 9, 2022

@hiqua I couldn't reproduce the first exception, but it should be impossible after ae8cf18.

Are the widgets slightly more reliable after ee39ff0 and 2154d8c, or about the same?

Edit: I just tested, and the StackWidget is also unreliable on Loop 2.0.3 and API 31. If anyone has a fix for this, PRs would be appreciated. On the other hand, since it's already broken in the current version, I don't consider it a blocker for 2.1.0.

@iSoron iSoron force-pushed the fix/stackwidget-api33 branch 2 times, most recently from 054964a to fe05cdc Compare September 9, 2022 09:58
@iSoron iSoron force-pushed the fix/stackwidget-api33 branch from fe05cdc to 4c5a722 Compare September 9, 2022 10:17
@iSoron iSoron merged commit bf50464 into dev Sep 10, 2022
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.

The measurable checkmark widget is not working as intended
2 participants