Add album art to media notification and lock screen
ClosedPublic

Authored by mtijink on Feb 24 2018, 4:23 PM.

Details

Summary

Adds the album art to the media notification and lock screen.

How it looks on my phone (disregard the somewhat weird look, that's just the weird UI my phone vendor uses):

Google images shows how it'll look on other phones (this one includes the lock screen image):

And Android Oreo automatically colors the notification based on the album art color (untested, but should work):

Test Plan

Changes are minor and it works fine for me.

Diff Detail

Repository
R225 KDE Connect - Android application
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
mtijink requested review of this revision.Feb 24 2018, 4:23 PM
mtijink created this revision.
mtijink edited the summary of this revision. (Show Details)Feb 24 2018, 4:26 PM
nicolasfella requested changes to this revision.Feb 24 2018, 4:33 PM
nicolasfella added a subscriber: nicolasfella.

Crashes on my Oreo phone as soon as it tries to display the notification

E/AndroidRuntime: FATAL EXCEPTION: main

Process: org.kde.kdeconnect_tp, PID: 16709
android.app.RemoteServiceException: Bad notification posted from package org.kde.kdeconnect_tp: Couldn't inflate contentViewsjava.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.Bitmap.setHasAlpha(boolean)' on a null object reference
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
    at android.os.Handler.dispatchMessage(Handler.java:105)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6809)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
This revision now requires changes to proceed.Feb 24 2018, 4:33 PM

Crashes on my Oreo phone as soon as it tries to display the notification

E/AndroidRuntime: FATAL EXCEPTION: main

Process: org.kde.kdeconnect_tp, PID: 16709
android.app.RemoteServiceException: Bad notification posted from package org.kde.kdeconnect_tp: Couldn't inflate contentViewsjava.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.Bitmap.setHasAlpha(boolean)' on a null object reference
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
    at android.os.Handler.dispatchMessage(Handler.java:105)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6809)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Weird, I do check on null, as you can see in the code. It might be related to using outdated appcompat libraries, but I'm not sure. Maybe we can look into this during the sprint, if it's not resolved beforehand.

mtijink updated this revision to Diff 30416.Mar 24 2018, 5:34 PM

Fixed the bug happening on Oreo.

albertvaka accepted this revision.Mar 25 2018, 11:30 AM
nicolasfella accepted this revision.Mar 25 2018, 11:36 AM
This revision is now accepted and ready to land.Mar 25 2018, 11:36 AM
This revision was automatically updated to reflect the committed changes.