Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 79677d01 authored by beanstown106's avatar beanstown106 Committed by Michael Bestas
Browse files

SystemUI: Allow to enable Lockscreen Media Art

This is a squash of the following commits:

Author: beanstown106 <nbenis106@gmail.com>
Date:   Fri Oct 23 21:07:35 2015 -0400

    SystemUI: Allow to enable Lockscreen Media Art

    Change-Id: Id93e115649df5d6dc680101a8c852644b217c28a

Author: Ezio Lacandia Bijelkic <brabus84@gmail.com>
Date:   Fri Nov 20 00:41:04 2020 +0200

    SystemUI: Hide lockscreen media art if media is not playing

    it's annoying to get the artwork even if the notification gets
    swiped out and media is paused, because the media session is still alive

    Change-Id: Ie65932127e47c463ef9a8b763298fc4dae20f8ae

Change-Id: Idd3033b52b4aa1cf07eb694ea0c9c1c934248f7c
parent d54190de
Loading
Loading
Loading
Loading
+25 −3
Original line number Diff line number Diff line
@@ -72,9 +72,12 @@ import com.android.systemui.statusbar.phone.LockscreenWallpaper;
import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.statusbar.phone.ScrimState;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.util.Utils;
import com.android.systemui.util.concurrency.DelayableExecutor;

import lineageos.providers.LineageSettings;

import java.io.PrintWriter;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@@ -90,10 +93,13 @@ import dagger.Lazy;
 * Handles tasks and state related to media notifications. For example, there is a 'current' media
 * notification, which this class keeps track of.
 */
public class NotificationMediaManager implements Dumpable {
public class NotificationMediaManager implements Dumpable, TunerService.Tunable {
    private static final String TAG = "NotificationMediaManager";
    public static final boolean DEBUG_MEDIA = false;

    private static final String LOCKSCREEN_MEDIA_METADATA =
            "lineagesecure:" + LineageSettings.Secure.LOCKSCREEN_MEDIA_METADATA;

    private final StatusBarStateController mStatusBarStateController
            = Dependency.get(StatusBarStateController.class);
    private final SysuiColorExtractor mColorExtractor = Dependency.get(SysuiColorExtractor.class);
@@ -145,6 +151,8 @@ public class NotificationMediaManager implements Dumpable {
    private ImageView mBackdropFront;
    private ImageView mBackdropBack;

    private boolean mShowMediaMetadata;

    private final MediaController.Callback mMediaListener = new MediaController.Callback() {
        @Override
        public void onPlaybackStateChanged(PlaybackState state) {
@@ -212,6 +220,17 @@ public class NotificationMediaManager implements Dumpable {
        }

        dumpManager.registerDumpable(this);

        final TunerService tunerService = Dependency.get(TunerService.class);
        tunerService.addTunable(this, LOCKSCREEN_MEDIA_METADATA);
    }

    @Override
    public void onTuningChanged(String key, String newValue) {
        if (LOCKSCREEN_MEDIA_METADATA.equals(key)) {
            mShowMediaMetadata = TunerService.parseIntegerSwitch(newValue, false);
            dispatchUpdateMediaMetaData(false /* changed */, true /* allowAnimation */);
        }
    }

    private void setupNotifPipeline() {
@@ -629,7 +648,7 @@ public class NotificationMediaManager implements Dumpable {
            }
            mProcessArtworkTasks.clear();
        }
        if (artworkBitmap != null && !Utils.useQsMediaPlayer(mContext)) {
        if (artworkBitmap != null) {
            mProcessArtworkTasks.add(new ProcessArtworkTask(this, metaDataChanged,
                    allowEnterAnimation).execute(artworkBitmap));
        } else {
@@ -642,11 +661,14 @@ public class NotificationMediaManager implements Dumpable {
    private void finishUpdateMediaMetaData(boolean metaDataChanged, boolean allowEnterAnimation,
            @Nullable Bitmap bmp) {
        Drawable artworkDrawable = null;
        if (bmp != null) {
        // set media artwork as lockscreen wallpaper if player is playing
        if (bmp != null && (mShowMediaMetadata || !ENABLE_LOCKSCREEN_WALLPAPER) &&
                PlaybackState.STATE_PLAYING == getMediaControllerPlaybackState(mMediaController)) {
            artworkDrawable = new BitmapDrawable(mBackdropBack.getResources(), bmp);
        }
        boolean hasMediaArtwork = artworkDrawable != null;
        boolean allowWhenShade = false;
        // if no media artwork, show normal lockscreen wallpaper
        if (ENABLE_LOCKSCREEN_WALLPAPER && artworkDrawable == null) {
            Bitmap lockWallpaper =
                    mLockscreenWallpaper != null ? mLockscreenWallpaper.getBitmap() : null;