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

Commit d92bda85 authored by Bryce Lee's avatar Bryce Lee
Browse files

Refactor Dream Overlay.

This changelist refactors dream overlay to distinguish
the overlay from the configured components it houses.
These components are hereafter referred to as
complications.

Test: atest ComplicationPrimerTest
Test: atest ComplicationProviderTest
Test: atest DreamOverlayServiceTest
Test: atest DreamOverlayStateControllerTest
Bug: 211446330
Change-Id: I311bf8f1d7977e74bbd96b6ddf2419b8f0613626
parent 3f265b79
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -714,19 +714,19 @@
    <bool name="config_enablePrivacyDot">true</bool>

    <!-- The positions widgets can be in defined as View.Gravity constants -->
    <integer-array name="config_dreamOverlayPositions">
    <integer-array name="config_dreamComplicationPositions">
    </integer-array>

    <!-- Widget components to show as dream overlays -->
    <string-array name="config_dreamOverlayComponents" translatable="false">
    <!-- Widget components to show as dream complications -->
    <string-array name="config_dreamAppWidgetComplications" translatable="false">
    </string-array>

    <!-- Width percentage of dream overlay components -->
    <item name="config_dreamOverlayComponentWidthPercent" translatable="false" format="float"
    <!-- Width percentage of dream complications -->
    <item name="config_dreamComplicationWidthPercent" translatable="false" format="float"
          type="dimen">0.33</item>

    <!-- Height percentage of dream overlay components -->
    <item name="config_dreamOverlayComponentHeightPercent" translatable="false" format="float"
    <!-- Height percentage of dream complications -->
    <item name="config_dreamComplicationHeightPercent" translatable="false" format="float"
          type="dimen">0.25</item>

    <!-- Flag to enable dream overlay service and its registration -->
+3 −3
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ import com.android.systemui.accessibility.WindowMagnification;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.communal.CommunalManagerUpdater;
import com.android.systemui.dreams.DreamOverlayRegistrant;
import com.android.systemui.dreams.appwidgets.AppWidgetOverlayPrimer;
import com.android.systemui.dreams.appwidgets.ComplicationPrimer;
import com.android.systemui.globalactions.GlobalActionsComponent;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.keyguard.dagger.KeyguardModule;
@@ -202,9 +202,9 @@ public abstract class SystemUIBinder {
    /** Inject into AppWidgetOverlayPrimer. */
    @Binds
    @IntoMap
    @ClassKey(AppWidgetOverlayPrimer.class)
    @ClassKey(ComplicationPrimer.class)
    public abstract CoreStartable bindAppWidgetOverlayPrimer(
            AppWidgetOverlayPrimer appWidgetOverlayPrimer);
            ComplicationPrimer complicationPrimer);

    /** Inject into CommunalManagerUpdater. */
    @Binds
+10 −10
Original line number Diff line number Diff line
@@ -19,29 +19,29 @@ package com.android.systemui.dreams;
import android.view.View;

/**
 * A collection of interfaces related to hosting an overlay.
 * A collection of interfaces related to hosting a complication.
 */
public abstract class OverlayHost {
public abstract class ComplicationHost {
    /**
     * An interface for the callback from the overlay provider to indicate when the overlay is
     * ready.
     * An interface for the callback from the complication provider to indicate when the
     * complication is ready.
     */
    public interface CreationCallback {
        /**
         * Called to inform the overlay view is ready to be placed within the visual space.
         * @param view The view representing the overlay.
         * Called to inform the complication view is ready to be placed within the visual space.
         * @param view The view representing the complication.
         * @param layoutParams The parameters to create the view with.
         */
        void onCreated(View view, OverlayHostView.LayoutParams layoutParams);
        void onCreated(View view, ComplicationHostView.LayoutParams layoutParams);
    }

    /**
     * An interface for the callback from the overlay provider to signal interactions in the
     * overlay.
     * An interface for the callback from the complication provider to signal interactions in the
     * complication.
     */
    public interface InteractionCallback {
        /**
         * Called to signal the calling overlay would like to exit the dream.
         * Called to signal the calling complication would like to exit the dream.
         */
        void onExit();
    }
+7 −6
Original line number Diff line number Diff line
@@ -22,22 +22,23 @@ import android.util.AttributeSet;
import androidx.constraintlayout.widget.ConstraintLayout;

/**
 * {@link OverlayHostView} is the container view for housing overlays ontop of a dream.
 * {@link ComplicationHostView} is the container view for housing complications above of a dream.
 */
public class OverlayHostView extends ConstraintLayout {
    public OverlayHostView(Context context) {
public class ComplicationHostView extends ConstraintLayout {
    public ComplicationHostView(Context context) {
        super(context, null);
    }

    public OverlayHostView(Context context, AttributeSet attrs) {
    public ComplicationHostView(Context context, AttributeSet attrs) {
        super(context, attrs, 0);
    }

    public OverlayHostView(Context context, AttributeSet attrs, int defStyleAttr) {
    public ComplicationHostView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr, 0);
    }

    public OverlayHostView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    public ComplicationHostView(Context context, AttributeSet attrs, int defStyleAttr,
            int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }
}
+8 −8
Original line number Diff line number Diff line
@@ -19,18 +19,18 @@ package com.android.systemui.dreams;
import android.content.Context;

/**
 * {@link OverlayProvider} is an interface for defining entities that can supply overlays to show
 * over a dream. Presentation components such as the {@link DreamOverlayService} supply
 * {@link ComplicationProvider} is an interface for defining entities that can supply complications
 * to show over a dream. Presentation components such as the {@link DreamOverlayService} supply
 * implementations with the necessary context for constructing such overlays.
 */
public interface OverlayProvider {
public interface ComplicationProvider {
    /**
     * Called when the {@link OverlayHost} requests the associated overlay be produced.
     * Called when the {@link ComplicationHost} requests the associated complication be produced.
     *
     * @param context The {@link Context} used to construct the view.
     * @param creationCallback The callback to inform when the overlay has been created.
     * @param interactionCallback The callback to inform when the overlay has been interacted with.
     * @param creationCallback The callback to inform the complication has been created.
     * @param interactionCallback The callback to inform the complication has been interacted with.
     */
    void onCreateOverlay(Context context, OverlayHost.CreationCallback creationCallback,
            OverlayHost.InteractionCallback interactionCallback);
    void onCreateComplication(Context context, ComplicationHost.CreationCallback creationCallback,
            ComplicationHost.InteractionCallback interactionCallback);
}
Loading