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

Commit 31e2d988 authored by Lucas Silva's avatar Lucas Silva Committed by Android (Google) Code Review
Browse files

Merge changes I5fa9eed5,I93f6dd4b into tm-dev

* changes:
  Hide smartspace dream complication in preview mode.
  Create dream preview complication
parents 08a5d6d8 5f63f08e
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ 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.
  -->
<TextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/dream_preview_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="@dimen/dream_overlay_complication_preview_text_size"
    android:textColor="@android:color/white"
    android:shadowColor="@color/keyguard_shadow_color"
    android:shadowRadius="?attr/shadowRadius"
    android:gravity="center_vertical"
    android:drawableStart="@drawable/ic_arrow_back"
    android:drawablePadding="@dimen/dream_overlay_complication_preview_icon_padding"
    android:drawableTint="@android:color/white"/>
+2 −0
Original line number Diff line number Diff line
@@ -1347,6 +1347,8 @@
    <dimen name="dream_overlay_complication_clock_time_text_size">72sp</dimen>
    <dimen name="dream_overlay_complication_clock_date_text_size">18sp</dimen>
    <dimen name="dream_overlay_complication_weather_text_size">18sp</dimen>
    <dimen name="dream_overlay_complication_preview_text_size">36sp</dimen>
    <dimen name="dream_overlay_complication_preview_icon_padding">28dp</dimen>

    <!-- The position of the end guide, which dream overlay complications can align their start with
         if their end is aligned with the parent end. Represented as the percentage over from the
+13 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dreams.complication.Complication;
import com.android.systemui.dreams.complication.DreamPreviewComplication;
import com.android.systemui.dreams.dagger.DreamOverlayComponent;
import com.android.systemui.dreams.touch.DreamOverlayTouchMonitor;

@@ -57,6 +58,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ
    // content area).
    private final DreamOverlayContainerViewController mDreamOverlayContainerViewController;
    private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
    private final DreamPreviewComplication mPreviewComplication;

    // A reference to the {@link Window} used to hold the dream overlay.
    private Window mWindow;
@@ -96,12 +98,14 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ
            @Main Executor executor,
            DreamOverlayComponent.Factory dreamOverlayComponentFactory,
            DreamOverlayStateController stateController,
            KeyguardUpdateMonitor keyguardUpdateMonitor) {
            KeyguardUpdateMonitor keyguardUpdateMonitor,
            DreamPreviewComplication previewComplication) {
        mContext = context;
        mExecutor = executor;
        mKeyguardUpdateMonitor = keyguardUpdateMonitor;
        mKeyguardUpdateMonitor.registerCallback(mKeyguardCallback);
        mStateController = stateController;
        mPreviewComplication = previewComplication;

        final DreamOverlayComponent component =
                dreamOverlayComponentFactory.create(mViewModelStore, mHost);
@@ -125,6 +129,9 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ
            windowManager.removeView(mWindow.getDecorView());
        }
        mStateController.setOverlayActive(false);
        mPreviewComplication.setDreamLabel(null);
        mStateController.removeComplication(mPreviewComplication);
        mStateController.setPreviewMode(false);
        super.onDestroy();
    }

@@ -133,6 +140,11 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ
        setCurrentState(Lifecycle.State.STARTED);
        mExecutor.execute(() -> {
            mStateController.setShouldShowComplications(shouldShowComplications());
            mStateController.setPreviewMode(isPreviewMode());
            if (isPreviewMode()) {
                mPreviewComplication.setDreamLabel(getDreamLabel());
                mStateController.addComplication(mPreviewComplication);
            }
            addOverlayWindowLocked(layoutParams);
            setCurrentState(Lifecycle.State.RESUMED);
            mStateController.setOverlayActive(true);
+15 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ public class DreamOverlayStateController implements
    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);

    public static final int STATE_DREAM_OVERLAY_ACTIVE = 1 << 0;
    public static final int STATE_PREVIEW_MODE = 1 << 1;

    private static final int OP_CLEAR_STATE = 1;
    private static final int OP_SET_STATE = 2;
@@ -249,4 +250,18 @@ public class DreamOverlayStateController implements
            mCallbacks.forEach(Callback::onAvailableComplicationTypesChanged);
        });
    }

    /**
     * Sets whether the dream is running in preview mode.
     */
    public void setPreviewMode(boolean isPreviewMode) {
        modifyState(isPreviewMode ? OP_SET_STATE : OP_CLEAR_STATE, STATE_PREVIEW_MODE);
    }

    /**
     * Returns whether the dream is running in preview mode.
     */
    public boolean isPreviewMode() {
        return containsState(STATE_PREVIEW_MODE);
    }
}
+13 −1
Original line number Diff line number Diff line
@@ -59,7 +59,19 @@ public class SmartSpaceComplication implements Complication {

        @Override
        public void start() {
            if (mSmartSpaceController.isEnabled()) {
            addOrRemoveOverlay();
            mDreamOverlayStateController.addCallback(new DreamOverlayStateController.Callback() {
                @Override
                public void onStateChanged() {
                    addOrRemoveOverlay();
                }
            });
        }

        private void addOrRemoveOverlay() {
            if (mDreamOverlayStateController.isPreviewMode()) {
                mDreamOverlayStateController.removeComplication(mComplication);
            } else if (mSmartSpaceController.isEnabled()) {
                mDreamOverlayStateController.addComplication(mComplication);
            }
        }
Loading