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

Add a homescreen widget #144

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

Abestanis
Copy link
Collaborator

@Abestanis Abestanis commented Jul 14, 2024

Depends on #130.

Adds a adaptable homescreen widget. Closes #111.

Pictures

Homescreen widget
Homescreen widget more sizes

@Abestanis Abestanis force-pushed the feature/homescreen_widget branch from 101e1f8 to 2c94781 Compare July 14, 2024 21:56
@Abestanis Abestanis force-pushed the feature/homescreen_widget branch 2 times, most recently from 8301183 to d9b576d Compare October 14, 2024 09:38
@Abestanis Abestanis marked this pull request as ready for review October 14, 2024 09:38
@Abestanis Abestanis force-pushed the feature/homescreen_widget branch from d9b576d to ac09a01 Compare October 15, 2024 22:13
@Abestanis Abestanis requested a review from nt4f04uNd October 19, 2024 18:28
@nt4f04uNd
Copy link
Owner

First impression - this works crazy awesome!

@nt4f04uNd
Copy link
Owner

image

Can we give this bar some bottom padding? Around 8 dp

lib/logic/app_widget.dart Outdated Show resolved Hide resolved
pubspec.yaml Outdated Show resolved Hide resolved
test/routes/home_route_test.dart Outdated Show resolved Hide resolved
test/routes/home_route_test.dart Outdated Show resolved Hide resolved
test/routes/home_route_test.dart Outdated Show resolved Hide resolved
@nt4f04uNd
Copy link
Owner

As a side note - we probably would like to show title and artist in the widget, but I'm in favor of doing this in a separate PR

<resources>
<dimen name="musicPlayerWidgetButtonSize">48dp</dimen>
<dimen name="appWidgetRadius">16dp</dimen>
<dimen name="appWidgetInnerRadius">8dp</dimen>
Copy link
Owner

Choose a reason for hiding this comment

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

Why do they differ?

Copy link
Owner

@nt4f04uNd nt4f04uNd Oct 20, 2024

Choose a reason for hiding this comment

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

Can you also help me understand what do these radiuses practically mean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is part of the rounded corner implementation, see the docs.
The appWidgetRadius refers to the corner radius of the background element of the widget (in our case it's the album art), and the appWidgetInnerRadius is the corner radius of any foreground element in the widget (in our case it's the button bar).

Prior to Android 31 there was no guideline about these, but on 31 and up they are given by the launcher via @android:dimen/system_app_widget_background_radius and @android:dimen/system_app_widget_inner_radius, and the description of system_app_widget_inner_radius says:

This is exactly 8 dp less than the background radius, to align nicely when using an 8 dp padding.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I renamed appWidgetRadius to appWidgetBackgroundRadius which hopefully makes it a bit clearer.

Copy link
Owner

Choose a reason for hiding this comment

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

Thanks
Maybe we should write this explanation down in the comments

@nt4f04uNd
Copy link
Owner

While I was testing the buld from this PR, one time after changing a song and then immediately minimizing the app to the home page, where there was a widget visible, I got the "The app is not responding notification" from the system. It was also the default art.

I didn't get it anymore since, but maybe it's something to dig into. Maybe it was reported to firebase, I didn't check

@nt4f04uNd
Copy link
Owner

nt4f04uNd commented Oct 20, 2024

I suppose that's the error I got

  Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: PlatformException(error, Service.startForeground() not allowed due to mAllowStartForeground false: service com.nt4f04und.sweyer/com.ryanheise.audioservice.AudioService, null, android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service com.nt4f04und.sweyer/com.ryanheise.audioservice.AudioService
	at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
	at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
	at android.os.Parcel.readParcelableInternal(Parcel.java:4804)
	at android.os.Parcel.readParcelable(Parcel.java:4772)
	at android.os.Parcel.createExceptionOrNull(Parcel.java:3035)
	at android.os.Parcel.createException(Parcel.java:3024)
	at android.os.Parcel.readException(Parcel.java:3007)
	at android.os.Parcel.readException(Parcel.java:2949)
	at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6079)
	at android.app.Service.startForeground(Service.java:797)
	at com.ryanheise.audioservice.AudioService.Q(Unknown Source:21)
	at com.ryanheise.audioservice.AudioService.F(Unknown Source:34)
	at com.ryanheise.audioservice.AudioService.Z(Unknown Source:159)
	at com.ryanheise.audioservice.a$d.E(Unknown Source:481)
	at i6.k$a.a(Unknown Source:17)
	at w5.c.l(Unknown Source:18)
	at w5.c.m(Unknown Source:40)
	at w5.c.i(Unknown Source:0)
	at w5.b.run(Unknown Source:12)
	at android.os.Handler.handleCallback(Handler.java:942)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loopOnce(Looper.java:240)
	at android.os.Looper.loop(Looper.java:351)
	at android.app.ActivityThread.main(ActivityThread.java:8370)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
)
#00 pc 0x64c647 com.nt4f04und.sweyer (StandardMethodCodec.decodeEnvelope [message_codecs.dart:653]) (BuildId: bca64abf2e8413c431bb8f1cc572ed9d)
#01 pc 0x6a2c23 com.nt4f04und.sweyer (MethodChannel._invokeMethod [platform_channel.dart:315]) (BuildId: bca64abf2e8413c431bb8f1cc572ed9d)
#02 pc 0x6909f7 com.nt4f04und.sweyer (_SuspendState._createAsyncStarCallback.<anonymous closure> [async_patch.dart:353]) (BuildId: bca64abf2e8413c431bb8f1cc572ed9d)
#03 pc 0x1bff8b com.nt4f04und.sweyer (_FutureListener.handleValue [zone.dart:1660]) (BuildId: bca64abf2e8413c431bb8f1cc572ed9d)
#04 pc 0x696353 com.nt4f04und.sweyer (Future._propagateToListeners.handleValueCallback [future_impl.dart:767]) (BuildId: bca64abf2e8413c431bb8f1cc572ed9d)
#05 pc 0x1bed8f com.nt4f04und.sweyer (Future._propagateToListeners [future_impl.dart:796]) (BuildId: bca64abf2e8413c431bb8f1cc572ed9d)
#06 pc 0x1c3dfb com.nt4f04und.sweyer (Future._completeWithValue [future_impl.dart:567]) (BuildId: bca64abf2e8413c431bb8f1cc572ed9d)
#07 pc 0x1c098f com.nt4f04und.sweyer (Future._asyncCompleteWithValue.<anonymous closure> [future_impl.dart:640]) (BuildId: bca64abf2e8413c431bb8f1cc572ed9d)
#08 pc 0x1be45f com.nt4f04und.sweyer (_microtaskLoop [schedule_microtask.dart:40]) (BuildId: bca64abf2e8413c431bb8f1cc572ed9d)
#09 pc 0x6953c7 com.nt4f04und.sweyer (_startMicrotaskLoop [schedule_microtask.dart:49]) (BuildId: bca64abf2e8413c431bb8f1cc572ed9d)
#10 pc 0x1be3d3 com.nt4f04und.sweyer (_startMicrotaskLoop [schedule_microtask.dart:44]) (BuildId: bca64abf2e8413c431bb8f1cc572ed9d)
        

https://console.firebase.google.com/u/0/project/sweyer-def42/crashlytics/app/android:com.nt4f04und.sweyer/issues/46654a54d48703098a19382a34e51e44?time=last-ninety-days&types=crash&sessionEventKey=6714C7E6005600013DE77BBFCAB31106_2006310376430476968

It's almost an exact duplicate of the other one that we have

https://console.firebase.google.com/u/0/project/sweyer-def42/crashlytics/app/android:com.nt4f04und.sweyer/issues/74dfca6f536b0c14f4e05937e3aaf53f?time=last-ninety-days&types=crash

          Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: PlatformException(error, Service.startForeground() not allowed due to mAllowStartForeground false: service com.nt4f04und.sweyer/com.ryanheise.audioservice.AudioService, null, android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service com.nt4f04und.sweyer/com.ryanheise.audioservice.AudioService
	at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
	at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
	at android.os.Parcel.readParcelableInternal(Parcel.java:5016)
	at android.os.Parcel.readParcelable(Parcel.java:4998)
	at android.os.Parcel.createExceptionOrNull(Parcel.java:3178)
	at android.os.Parcel.createException(Parcel.java:3167)
	at android.os.Parcel.readException(Parcel.java:3150)
	at android.os.Parcel.readException(Parcel.java:3092)
	at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6960)
	at android.app.Service.startForeground(Service.java:863)
	at com.ryanheise.audioservice.AudioService.internalStartForeground(AudioService.java:684)
	at com.ryanheise.audioservice.AudioService.enterPlayingState(AudioService.java:665)
	at com.ryanheise.audioservice.AudioService.setState(AudioService.java:529)
	at com.ryanheise.audioservice.AudioServicePlugin$AudioHandlerInterface.onMethodCall(AudioServicePlugin.java:864)
	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
	at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
	at android.os.Handler.handleCallback(Handler.java:959)
	at android.os.Handler.dispatchMessage(Handler.java:100)<truncated: 358 chars>
       at StandardMethodCodec.decodeEnvelope(message_codecs.dart:648)
       at MethodChannel._invokeMethod(platform_channel.dart:334)
       at MethodChannelAudioService.setState(method_channel_audio_service.dart:19)
       at AudioService.init.<fn>(audio_service.dart:958)
        

@Abestanis
Copy link
Collaborator Author

As a side note - we probably would like to show title and artist in the widget, but I'm in favor of doing this in a separate PR

I personally am not a fan of having any text in the widget, but we can definiert provide a second widget with more information, or maybe even allow to configure it when creating the widget.

@Abestanis Abestanis force-pushed the feature/homescreen_widget branch from 06c3309 to 7a1dee0 Compare October 21, 2024 02:07
Copy link
Owner

Choose a reason for hiding this comment

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

In the code it says @drawable/round_play_arrow

https://github.com/nt4f04uNd/sweyer/pull/144/files#diff-5b2e5e484d398f30f9f9101bb273e02db9457eaa4594693474f34bed3c67df3dR42

But the image has changed to the pause icon

Is this intended?

Copy link
Owner

Choose a reason for hiding this comment

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

Also the diff from this commit 7a1dee0 didn't seem to change the radius of the button bar

I would have expected this to align with the outer radius with your changes

@nt4f04uNd
Copy link
Owner

As a side note - we probably would like to show title and artist in the widget, but I'm in favor of doing this in a separate PR

I personally am not a fan of having any text in the widget, but we can definiert provide a second widget with more information, or maybe even allow to configure it when creating the widget.

Yeah, sounds nice

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.

Add home widget
2 participants