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

Commit 37e95f0b authored by Bryce Lee's avatar Bryce Lee Committed by Android (Google) Code Review
Browse files

Merge "Media Complication Introduction."

parents 2cf96368 294de89b
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import com.android.systemui.globalactions.GlobalActionsComponent;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.keyguard.dagger.KeyguardModule;
import com.android.systemui.log.SessionTracker;
import com.android.systemui.media.dream.MediaDreamSentinel;
import com.android.systemui.media.systemsounds.HomeSoundEffectController;
import com.android.systemui.power.PowerUI;
import com.android.systemui.privacy.television.TvOngoingPrivacyChip;
@@ -226,4 +227,11 @@ public abstract class SystemUIBinder {
    @ClassKey(SmartSpaceComplication.Registrant.class)
    public abstract CoreStartable bindSmartSpaceComplicationRegistrant(
            SmartSpaceComplication.Registrant registrant);

    /** Inject into MediaDreamSentinel. */
    @Binds
    @IntoMap
    @ClassKey(MediaDreamSentinel.class)
    public abstract CoreStartable bindMediaDreamSentinel(
            MediaDreamSentinel sentinel);
}
+27 −2
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import androidx.annotation.VisibleForTesting
import com.android.systemui.R
import com.android.systemui.animation.Interpolators
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dreams.DreamOverlayStateController
import com.android.systemui.keyguard.WakefulnessLifecycle
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.statusbar.CrossFadeHelper
@@ -82,7 +83,8 @@ class MediaHierarchyManager @Inject constructor(
    private val notifLockscreenUserManager: NotificationLockscreenUserManager,
    configurationController: ConfigurationController,
    wakefulnessLifecycle: WakefulnessLifecycle,
    private val statusBarKeyguardViewManager: StatusBarKeyguardViewManager
    private val statusBarKeyguardViewManager: StatusBarKeyguardViewManager,
    private val dreamOverlayStateController: DreamOverlayStateController
) {

    /**
@@ -167,7 +169,7 @@ class MediaHierarchyManager @Inject constructor(
        })
    }

    private val mediaHosts = arrayOfNulls<MediaHost>(LOCATION_LOCKSCREEN + 1)
    private val mediaHosts = arrayOfNulls<MediaHost>(LOCATION_DREAM_OVERLAY + 1)
    /**
     * The last location where this view was at before going to the desired location. This is
     * useful for guided transitions.
@@ -348,6 +350,17 @@ class MediaHierarchyManager @Inject constructor(
            }
        }

    /**
     * Is the doze animation currently Running
     */
    private var dreamOverlayActive: Boolean = false
        private set(value) {
            if (field != value) {
                field = value
                updateDesiredLocation(forceNoAnimation = true)
            }
        }

    /**
     * The current cross fade progress. 0.5f means it's just switching
     * between the start and the end location and the content is fully faded, while 0.75f means
@@ -444,6 +457,12 @@ class MediaHierarchyManager @Inject constructor(
            }
        })

        dreamOverlayStateController.addCallback(object : DreamOverlayStateController.Callback {
            override fun onStateChanged() {
                dreamOverlayStateController.isOverlayActive.also { dreamOverlayActive = it }
            }
        })

        wakefulnessLifecycle.addObserver(object : WakefulnessLifecycle.Observer {
            override fun onFinishedGoingToSleep() {
                goingToSleep = false
@@ -940,6 +959,7 @@ class MediaHierarchyManager @Inject constructor(
                statusbarState == StatusBarState.FULLSCREEN_USER_SWITCHER))
        val allowedOnLockscreen = notifLockscreenUserManager.shouldShowLockscreenNotifications()
        val location = when {
            dreamOverlayActive -> LOCATION_DREAM_OVERLAY
            (qsExpansion > 0.0f || inSplitShade) && !onLockscreen -> LOCATION_QS
            qsExpansion > 0.4f && onLockscreen -> LOCATION_QS
            !hasActiveMedia -> LOCATION_QS
@@ -1034,6 +1054,11 @@ class MediaHierarchyManager @Inject constructor(
         */
        const val LOCATION_LOCKSCREEN = 2

        /**
         * Attached on the dream overlay
         */
        const val LOCATION_DREAM_OVERLAY = 3

        /**
         * Attached at the root of the hierarchy in an overlay
         */
+15 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.systemui.media.MediaDataManager;
import com.android.systemui.media.MediaHierarchyManager;
import com.android.systemui.media.MediaHost;
import com.android.systemui.media.MediaHostStatesManager;
import com.android.systemui.media.dream.dagger.MediaComplicationComponent;
import com.android.systemui.media.taptotransfer.MediaTttCommandLineHelper;
import com.android.systemui.media.taptotransfer.MediaTttFlags;
import com.android.systemui.media.taptotransfer.receiver.MediaTttChipControllerReceiver;
@@ -43,11 +44,14 @@ import dagger.multibindings.ClassKey;
import dagger.multibindings.IntoMap;

/** Dagger module for the media package. */
@Module
@Module(subcomponents = {
        MediaComplicationComponent.class,
})
public interface MediaModule {
    String QS_PANEL = "media_qs_panel";
    String QUICK_QS_PANEL = "media_quick_qs_panel";
    String KEYGUARD = "media_keyguard";
    String DREAM = "dream";

    /** */
    @Provides
@@ -79,6 +83,16 @@ public interface MediaModule {
        return new MediaHost(stateHolder, hierarchyManager, dataManager, statesManager);
    }

    /** */
    @Provides
    @SysUISingleton
    @Named(DREAM)
    static MediaHost providesDreamMediaHost(MediaHost.MediaHostStateHolder stateHolder,
            MediaHierarchyManager hierarchyManager, MediaDataManager dataManager,
            MediaHostStatesManager statesManager) {
        return new MediaHost(stateHolder, hierarchyManager, dataManager, statesManager);
    }

    /** */
    @Provides
    @SysUISingleton
+68 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.media.dream;

import static com.android.systemui.media.dagger.MediaModule.DREAM;
import static com.android.systemui.media.dream.dagger.MediaComplicationComponent.MediaComplicationModule.MEDIA_COMPLICATION_CONTAINER;

import android.widget.FrameLayout;

import com.android.systemui.media.MediaHierarchyManager;
import com.android.systemui.media.MediaHost;
import com.android.systemui.media.MediaHostState;
import com.android.systemui.util.ViewController;

import javax.inject.Inject;
import javax.inject.Named;

/**
 * {@link MediaComplicationViewController} handles connecting the
 * {@link com.android.systemui.dreams.complication.Complication} view to the {@link MediaHost}.
 */
public class MediaComplicationViewController extends ViewController<FrameLayout> {
    private final MediaHost mMediaHost;

    @Inject
    public MediaComplicationViewController(
            @Named(MEDIA_COMPLICATION_CONTAINER) FrameLayout view,
            @Named(DREAM) MediaHost mediaHost) {
        super(view);
        mMediaHost = mediaHost;
    }

    @Override
    protected void onInit() {
        super.onInit();
        mMediaHost.setExpansion(MediaHostState.COLLAPSED);
        mMediaHost.setShowsOnlyActiveMedia(true);
        mMediaHost.setFalsingProtectionNeeded(true);
        mMediaHost.init(MediaHierarchyManager.LOCATION_DREAM_OVERLAY);
    }

    @Override
    protected void onViewAttached() {
        mMediaHost.hostView.setLayoutParams(new FrameLayout.LayoutParams(
                FrameLayout.LayoutParams.MATCH_PARENT,
                FrameLayout.LayoutParams.WRAP_CONTENT));
        mView.addView(mMediaHost.hostView);
    }

    @Override
    protected void onViewDetached() {
        mView.removeView(mMediaHost.hostView);
    }
}
+43 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.media.dream;

import com.android.systemui.dreams.complication.Complication;
import com.android.systemui.dreams.complication.ComplicationViewModel;
import com.android.systemui.media.dream.dagger.MediaComplicationComponent;

import javax.inject.Inject;

/**
 * Media control complication for dream overlay.
 */
public class MediaDreamComplication implements Complication {
    MediaComplicationComponent.Factory mComponentFactory;

    /**
     * Default constructor for {@link MediaDreamComplication}.
     */
    @Inject
    public MediaDreamComplication(MediaComplicationComponent.Factory componentFactory) {
        mComponentFactory = componentFactory;
    }

    @Override
    public ViewHolder createView(ComplicationViewModel model) {
        return mComponentFactory.create().getViewHolder();
    }
}
Loading