mediathekview / zapp

German public broadcasting live streams as an Android app
https://mediathekview.de/news/zapp/
MIT License
199 stars 33 forks source link

Add preference to use dynamic colors #343

Closed Bnyro closed 1 year ago

Bnyro commented 1 year ago

Hey, as the app recently got migrated to MD3 (which is awesome :) ), I thought it'd be a nice addition to allow users to use Dynamic Colors instead of the default red/pink accent colors. Changing the preference requires an app restart as dynamic colors need to get initialized before super#onCreate() of the activities is getting called. If there are any suggestions for improvements, I'm open for it. Cheers

cemrich commented 1 year ago

Thank you very, very much for your work!

I pushed this changes to zapp/dynamic-colors and refactored a little bit. There are only a few things to do, that I'll implement the next days:

Bnyro commented 1 year ago

I could have a look on point 2 and 4 if you want me to tomorrow :) For 2. I wouldn't use an external library as it would increase the apk size which could be avoided by doing something like

val pm: PackageManager = context.packageManager
val intent = pm.getLaunchIntentForPackage(context.packageName)
intent?.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK 
context.startActivity(intent) 
android.os.Process.killProcess(android.os.Process.myPid())

although it might need to get changed a bit since there are different launch intents on Android TV and on mobile (might still work, not tested though).

I don't mind if you want finish that up though, really appreciate all your efforts into the app, it's awesome <3

Bnyro commented 1 year ago

I just saw you default the dynamic colors pref to false now, then DynamicColors#isDynamicColorsAvailable in line 61 of the ZeppApplicationBase.kt shouldn't be needed anymore :)

cemrich commented 1 year ago

One final testing round on some legacy versions - then this feature is done!

@Bnyro Thanks again very much!

cemrich commented 1 year ago

I wouldn't use an external library as it would increase the apk size which could be avoided by doing something like

The library is tiny and maintained by a trusted developer. It is much more robust (cross api level) than what I could write in my limited time.

Bnyro commented 1 year ago

Awesome, happy I was able to help :) I get your point with Phoenix, it's commonly used among Android apps so the dependency shouldn't be an issue :)

I saw your recent commits, do you thing it's the tight way to restart the app without warning the user before? I would have added a restart action to the snackbar with the warning instead to maintain a better UX, but that's only my personal opinion of course.

Anyways thanks for your great work on that, already waiting for the update patiently ;)

cemrich commented 1 year ago

I saw your recent commits, do you thing it's the tight way to restart the app without warning the user before?

Yeah, that's fine in this case. The user is clearly seeing why this happened and nothing is breaking.

Version 8.2.0 is released and hit F-Droid in a few days.