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

Commit f9646b05 authored by Android Build Prod User's avatar Android Build Prod User Committed by Automerger Merge Worker
Browse files

Merge "Revert "Moving smartspace to the right on the lockscreen for split...

Merge "Revert "Moving smartspace to the right on the lockscreen for split shade"" into sc-v2-dev am: f8503766

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15639110

Change-Id: I5d11db1b52d1b7d0c67a56314949232043452606
parents 6613f507 f8503766
Loading
Loading
Loading
Loading
+0 −10
Original line number Original line Diff line number Diff line
@@ -68,16 +68,6 @@
            lockScreenWeight="400"
            lockScreenWeight="400"
        />
        />
    </FrameLayout>
    </FrameLayout>
    <FrameLayout
        android:id="@+id/keyguard_smartspace_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingStart="@dimen/below_clock_padding_start"
        android:paddingEnd="@dimen/below_clock_padding_end"
        android:layout_alignParentStart="true"
        android:layout_below="@id/lockscreen_clock_view"
        />
    <!-- either keyguard_status_area or keyguard_smartspace_container is visible -->
    <include layout="@layout/keyguard_status_area"
    <include layout="@layout/keyguard_status_area"
        android:id="@+id/keyguard_status_area"
        android:id="@+id/keyguard_status_area"
        android:layout_width="match_parent"
        android:layout_width="match_parent"
+1 −13
Original line number Original line Diff line number Diff line
@@ -86,18 +86,6 @@
            layout="@layout/keyguard_status_view"
            layout="@layout/keyguard_status_view"
            android:visibility="gone"/>
            android:visibility="gone"/>


        <FrameLayout
            android:id="@+id/split_shade_smartspace_container"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:paddingStart="@dimen/notification_side_paddings"
            android:paddingEnd="@dimen/notification_side_paddings"
            systemui:layout_constraintStart_toStartOf="@id/qs_edge_guideline"
            systemui:layout_constraintEnd_toEndOf="parent"
            systemui:layout_constraintTop_toTopOf="parent"
            android:visibility="gone">
        </FrameLayout>

        <include layout="@layout/dock_info_overlay"/>
        <include layout="@layout/dock_info_overlay"/>


        <FrameLayout
        <FrameLayout
+34 −22
Original line number Original line Diff line number Diff line
@@ -17,13 +17,13 @@
package com.android.keyguard;
package com.android.keyguard;


import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;


import static com.android.keyguard.KeyguardClockSwitch.LARGE;
import static com.android.keyguard.KeyguardClockSwitch.LARGE;


import android.app.WallpaperManager;
import android.app.WallpaperManager;
import android.text.TextUtils;
import android.text.TextUtils;
import android.view.View;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout;


@@ -93,7 +93,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS


    private final ClockManager.ClockChangedListener mClockChangedListener = this::setClockPlugin;
    private final ClockManager.ClockChangedListener mClockChangedListener = this::setClockPlugin;


    private ViewGroup mSmartspaceContainer;
    // If set, will replace keyguard_status_area
    private View mSmartspaceView;


    private final KeyguardUnlockAnimationController mKeyguardUnlockAnimationController;
    private final KeyguardUnlockAnimationController mKeyguardUnlockAnimationController;
    private SmartspaceTransitionController mSmartspaceTransitionController;
    private SmartspaceTransitionController mSmartspaceTransitionController;
@@ -147,8 +148,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS


        mClockFrame = mView.findViewById(R.id.lockscreen_clock_view);
        mClockFrame = mView.findViewById(R.id.lockscreen_clock_view);
        mLargeClockFrame = mView.findViewById(R.id.lockscreen_clock_view_large);
        mLargeClockFrame = mView.findViewById(R.id.lockscreen_clock_view_large);
        mSmartspaceContainer = mView.findViewById(R.id.keyguard_smartspace_container);
        mSmartspaceController.setKeyguardStatusContainer(mSmartspaceContainer);


        mClockViewController =
        mClockViewController =
                new AnimatableClockController(
                new AnimatableClockController(
@@ -190,25 +189,35 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
        }
        }
        updateAodIcons();
        updateAodIcons();


        if (mSmartspaceController.isSmartspaceEnabled()) {
        if (mSmartspaceController.isEnabled()) {
            // "Enabled" doesn't mean smartspace is displayed here - inside mSmartspaceContainer -
            mSmartspaceView = mSmartspaceController.buildAndConnectView(mView);
            // it might be a part of another view when in split shade. But it means that it CAN be
            // displayed here, so we want to hide keyguard_status_area and set views relations
            // accordingly.


            View ksa = mView.findViewById(R.id.keyguard_status_area);
            View ksa = mView.findViewById(R.id.keyguard_status_area);
            // we show either keyguard_status_area or smartspace, so when smartspace can be visible,
            int ksaIndex = mView.indexOfChild(ksa);
            // keyguard_status_area should be hidden
            ksa.setVisibility(View.GONE);
            ksa.setVisibility(View.GONE);


            // Place smartspace view below normal clock...
            RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                    MATCH_PARENT, WRAP_CONTENT);
            lp.addRule(RelativeLayout.BELOW, R.id.lockscreen_clock_view);

            mView.addView(mSmartspaceView, ksaIndex, lp);
            int startPadding = getContext().getResources()
                    .getDimensionPixelSize(R.dimen.below_clock_padding_start);
            int endPadding = getContext().getResources()
                    .getDimensionPixelSize(R.dimen.below_clock_padding_end);
            mSmartspaceView.setPaddingRelative(startPadding, 0, endPadding, 0);

            updateClockLayout();
            updateClockLayout();


            View nic = mView.findViewById(R.id.left_aligned_notification_icon_container);
            View nic = mView.findViewById(
            RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) nic.getLayoutParams();
                    R.id.left_aligned_notification_icon_container);
            lp.addRule(RelativeLayout.BELOW, mSmartspaceContainer.getId());
            lp = (RelativeLayout.LayoutParams) nic.getLayoutParams();
            lp.addRule(RelativeLayout.BELOW, mSmartspaceView.getId());
            nic.setLayoutParams(lp);
            nic.setLayoutParams(lp);
            mView.setSmartspaceView(mSmartspaceContainer);

            mSmartspaceTransitionController.setLockscreenSmartspace(mSmartspaceContainer);
            mView.setSmartspaceView(mSmartspaceView);
            mSmartspaceTransitionController.setLockscreenSmartspace(mSmartspaceView);
        }
        }
    }
    }


@@ -231,7 +240,10 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
        // instance of this class. In order to fix this, we need to modify the plugin so that
        // instance of this class. In order to fix this, we need to modify the plugin so that
        // (a) we get a new view each time and (b) we can properly clean up an old view by making
        // (a) we get a new view each time and (b) we can properly clean up an old view by making
        // it unregister itself as a plugin listener.
        // it unregister itself as a plugin listener.
        mSmartspaceContainer.removeAllViews();
        if (mSmartspaceView != null) {
            mView.removeView(mSmartspaceView);
            mSmartspaceView = null;
        }
    }
    }


    /**
    /**
@@ -244,7 +256,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
    }
    }


    private void updateClockLayout() {
    private void updateClockLayout() {
        if (mSmartspaceController.isSmartspaceEnabled()) {
        if (mSmartspaceController.isEnabled()) {
            RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(MATCH_PARENT,
            RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(MATCH_PARENT,
                    MATCH_PARENT);
                    MATCH_PARENT);
            lp.topMargin = getContext().getResources().getDimensionPixelSize(
            lp.topMargin = getContext().getResources().getDimensionPixelSize(
@@ -309,8 +321,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
        PropertyAnimator.setProperty(mLargeClockFrame, AnimatableProperty.SCALE_Y,
        PropertyAnimator.setProperty(mLargeClockFrame, AnimatableProperty.SCALE_Y,
                scale, props, animate);
                scale, props, animate);


        if (mSmartspaceContainer != null) {
        if (mSmartspaceView != null) {
            PropertyAnimator.setProperty(mSmartspaceContainer, AnimatableProperty.TRANSLATION_X,
            PropertyAnimator.setProperty(mSmartspaceView, AnimatableProperty.TRANSLATION_X,
                    x, props, animate);
                    x, props, animate);


            // If we're unlocking with the SmartSpace shared element transition, let the controller
            // If we're unlocking with the SmartSpace shared element transition, let the controller
@@ -328,8 +340,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
    public void setChildrenAlphaExcludingSmartspace(float alpha) {
    public void setChildrenAlphaExcludingSmartspace(float alpha) {
        final Set<View> excludedViews = new HashSet<>();
        final Set<View> excludedViews = new HashSet<>();


        if (mSmartspaceContainer != null) {
        if (mSmartspaceView != null) {
            excludedViews.add(mSmartspaceContainer);
            excludedViews.add(mSmartspaceView);
        }
        }


        setChildrenAlphaExcluding(alpha, excludedViews);
        setChildrenAlphaExcluding(alpha, excludedViews);
+4 −89
Original line number Original line Diff line number Diff line
@@ -31,8 +31,6 @@ import android.os.Handler
import android.os.UserHandle
import android.os.UserHandle
import android.provider.Settings
import android.provider.Settings
import android.view.View
import android.view.View
import android.view.View.GONE
import android.view.View.VISIBLE
import android.view.ViewGroup
import android.view.ViewGroup
import com.android.settingslib.Utils
import com.android.settingslib.Utils
import com.android.systemui.R
import com.android.systemui.R
@@ -46,21 +44,14 @@ import com.android.systemui.plugins.FalsingManager
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.settings.UserTracker
import com.android.systemui.settings.UserTracker
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.statusbar.StatusBarState
import com.android.systemui.statusbar.notification.AnimatableProperty
import com.android.systemui.statusbar.notification.PropertyAnimator
import com.android.systemui.statusbar.notification.stack.AnimationProperties
import com.android.systemui.statusbar.notification.stack.StackStateAnimator
import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.util.concurrency.Execution
import com.android.systemui.util.concurrency.Execution
import com.android.systemui.util.settings.SecureSettings
import com.android.systemui.util.settings.SecureSettings
import java.lang.RuntimeException
import java.util.Optional
import java.util.Optional
import java.util.concurrent.Executor
import java.util.concurrent.Executor
import javax.inject.Inject
import javax.inject.Inject


private val ANIMATION_PROPERTIES = AnimationProperties()
        .setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD.toLong())

/**
/**
 * Controller for managing the smartspace view on the lockscreen
 * Controller for managing the smartspace view on the lockscreen
 */
 */
@@ -81,15 +72,10 @@ class LockscreenSmartspaceController @Inject constructor(
    @Main private val handler: Handler,
    @Main private val handler: Handler,
    optionalPlugin: Optional<BcSmartspaceDataPlugin>
    optionalPlugin: Optional<BcSmartspaceDataPlugin>
) {
) {

    var splitShadeContainer: ViewGroup? = null
    private var singlePaneContainer: ViewGroup? = null

    private var session: SmartspaceSession? = null
    private var session: SmartspaceSession? = null
    private val plugin: BcSmartspaceDataPlugin? = optionalPlugin.orElse(null)
    private val plugin: BcSmartspaceDataPlugin? = optionalPlugin.orElse(null)
    private lateinit var smartspaceView: SmartspaceView
    private lateinit var smartspaceView: SmartspaceView


    // smartspace casted to View
    lateinit var view: View
    lateinit var view: View
        private set
        private set


@@ -97,60 +83,12 @@ class LockscreenSmartspaceController @Inject constructor(
    private var showSensitiveContentForManagedUser = false
    private var showSensitiveContentForManagedUser = false
    private var managedUserHandle: UserHandle? = null
    private var managedUserHandle: UserHandle? = null


    private var isAod = false
    fun isEnabled(): Boolean {
    private var isSplitShade = false

    fun isSmartspaceEnabled(): Boolean {
        execution.assertIsMainThread()
        execution.assertIsMainThread()


        return featureFlags.isSmartspaceEnabled && plugin != null
        return featureFlags.isSmartspaceEnabled && plugin != null
    }
    }


    fun setKeyguardStatusContainer(container: ViewGroup) {
        singlePaneContainer = container
        // reattach smartspace if necessary as this might be a new container
        updateSmartSpaceContainer()
    }

    fun onSplitShadeChanged(splitShade: Boolean) {
        isSplitShade = splitShade
        updateSmartSpaceContainer()
    }

    private fun updateSmartSpaceContainer() {
        if (!isSmartspaceEnabled()) return
        // in AOD we always want to show smartspace on the left i.e. in singlePaneContainer
        if (isSplitShade && !isAod) {
            switchContainerVisibility(
                    newParent = splitShadeContainer,
                    oldParent = singlePaneContainer)
        } else {
            switchContainerVisibility(
                    newParent = singlePaneContainer,
                    oldParent = splitShadeContainer)
        }
        requestSmartspaceUpdate()
    }

    private fun switchContainerVisibility(newParent: ViewGroup?, oldParent: ViewGroup?) {
        // it might be the case that smartspace was already attached and we just needed to update
        // visibility, e.g. going from lockscreen -> unlocked -> lockscreen
        if (newParent?.childCount == 0) {
            oldParent?.removeAllViews()
            newParent.addView(buildAndConnectView(newParent))
        }
        oldParent?.visibility = GONE
        newParent?.visibility = VISIBLE
    }

    fun setSplitShadeSmartspaceAlpha(alpha: Float) {
        // the other container's alpha is modified as a part of keyguard status view, so we don't
        // have to do that here
        if (splitShadeContainer?.visibility == VISIBLE) {
            splitShadeContainer?.alpha = alpha
        }
    }

    /**
    /**
     * Constructs the smartspace view and connects it to the smartspace service. Subsequent calls
     * Constructs the smartspace view and connects it to the smartspace service. Subsequent calls
     * are idempotent until [disconnect] is called.
     * are idempotent until [disconnect] is called.
@@ -158,7 +96,7 @@ class LockscreenSmartspaceController @Inject constructor(
    fun buildAndConnectView(parent: ViewGroup): View {
    fun buildAndConnectView(parent: ViewGroup): View {
        execution.assertIsMainThread()
        execution.assertIsMainThread()


        if (!isSmartspaceEnabled()) {
        if (!isEnabled()) {
            throw RuntimeException("Cannot build view when not enabled")
            throw RuntimeException("Cannot build view when not enabled")
        }
        }


@@ -244,6 +182,7 @@ class LockscreenSmartspaceController @Inject constructor(
        userTracker.removeCallback(userTrackerCallback)
        userTracker.removeCallback(userTrackerCallback)
        contentResolver.unregisterContentObserver(settingsObserver)
        contentResolver.unregisterContentObserver(settingsObserver)
        configurationController.removeCallback(configChangeListener)
        configurationController.removeCallback(configChangeListener)
        statusBarStateController.removeCallback(statusBarStateListener)
        session = null
        session = null


        plugin?.onTargetsAvailable(emptyList())
        plugin?.onTargetsAvailable(emptyList())
@@ -259,13 +198,6 @@ class LockscreenSmartspaceController @Inject constructor(
        plugin?.unregisterListener(listener)
        plugin?.unregisterListener(listener)
    }
    }


    fun shiftSplitShadeSmartspace(y: Int, animate: Boolean) {
        if (splitShadeContainer?.visibility == VISIBLE) {
            PropertyAnimator.setProperty(splitShadeContainer, AnimatableProperty.Y, y.toFloat(),
                    ANIMATION_PROPERTIES, animate)
        }
    }

    private val sessionListener = SmartspaceSession.OnTargetsAvailableListener { targets ->
    private val sessionListener = SmartspaceSession.OnTargetsAvailableListener { targets ->
        execution.assertIsMainThread()
        execution.assertIsMainThread()
        val filteredTargets = targets.filter(::filterSmartspaceTarget)
        val filteredTargets = targets.filter(::filterSmartspaceTarget)
@@ -301,23 +233,6 @@ class LockscreenSmartspaceController @Inject constructor(
            execution.assertIsMainThread()
            execution.assertIsMainThread()
            smartspaceView.setDozeAmount(eased)
            smartspaceView.setDozeAmount(eased)
        }
        }

        override fun onDozingChanged(isDozing: Boolean) {
            isAod = isDozing
            updateSmartSpaceContainer()
        }

        override fun onStateChanged(newState: Int) {
            if (newState == StatusBarState.KEYGUARD) {
                if (isSmartspaceEnabled()) {
                    updateSmartSpaceContainer()
                }
            } else {
                splitShadeContainer?.visibility = GONE
                singlePaneContainer?.visibility = GONE
                disconnect()
            }
        }
    }
    }


    private fun filterSmartspaceTarget(t: SmartspaceTarget): Boolean {
    private fun filterSmartspaceTarget(t: SmartspaceTarget): Boolean {
+36 −7
Original line number Original line Diff line number Diff line
@@ -32,11 +32,23 @@ import com.android.systemui.statusbar.policy.KeyguardUserSwitcherListView;
 * Utility class to calculate the clock position and top padding of notifications on Keyguard.
 * Utility class to calculate the clock position and top padding of notifications on Keyguard.
 */
 */
public class KeyguardClockPositionAlgorithm {
public class KeyguardClockPositionAlgorithm {
    /**
     * How much the clock height influences the shade position.
     * 0 means nothing, 1 means move the shade up by the height of the clock
     * 0.5f means move the shade up by half of the size of the clock.
     */
    private static float CLOCK_HEIGHT_WEIGHT = 0.7f;

    /**
    /**
     * Margin between the bottom of the status view and the notification shade.
     * Margin between the bottom of the status view and the notification shade.
     */
     */
    private int mStatusViewBottomMargin;
    private int mStatusViewBottomMargin;


    /**
     * Height of the parent view - display size in px.
     */
    private int mHeight;

    /**
    /**
     * Height of {@link KeyguardStatusView}.
     * Height of {@link KeyguardStatusView}.
     */
     */
@@ -55,6 +67,21 @@ public class KeyguardClockPositionAlgorithm {
     */
     */
    private int mUserSwitchPreferredY;
    private int mUserSwitchPreferredY;


    /**
     * Whether or not there is a custom clock face on keyguard.
     */
    private boolean mHasCustomClock;

    /**
     * Whether or not the NSSL contains any visible notifications.
     */
    private boolean mHasVisibleNotifs;

    /**
     * Height of notification stack: Sum of height of each notification.
     */
    private int mNotificationStackHeight;

    /**
    /**
     * Minimum top margin to avoid overlap with status bar, lock icon, or multi-user switcher
     * Minimum top margin to avoid overlap with status bar, lock icon, or multi-user switcher
     * avatar.
     * avatar.
@@ -121,7 +148,6 @@ public class KeyguardClockPositionAlgorithm {
    private int mUnlockedStackScrollerPadding;
    private int mUnlockedStackScrollerPadding;


    private boolean mIsSplitShade;
    private boolean mIsSplitShade;
    private int mSplitShadeSmartspaceHeight;


    /**
    /**
     * Refreshes the dimension values.
     * Refreshes the dimension values.
@@ -144,25 +170,28 @@ public class KeyguardClockPositionAlgorithm {
     * Sets up algorithm values.
     * Sets up algorithm values.
     */
     */
    public void setup(int keyguardStatusBarHeaderHeight, int maxShadeBottom,
    public void setup(int keyguardStatusBarHeaderHeight, int maxShadeBottom,
            float panelExpansion,
            int notificationStackHeight, float panelExpansion, int parentHeight,
            int keyguardStatusHeight, int userSwitchHeight, int userSwitchPreferredY, float dark,
            int keyguardStatusHeight, int userSwitchHeight, int userSwitchPreferredY,
            boolean hasCustomClock, boolean hasVisibleNotifs, float dark,
            float overStrechAmount, boolean bypassEnabled, int unlockedStackScrollerPadding,
            float overStrechAmount, boolean bypassEnabled, int unlockedStackScrollerPadding,
            float qsExpansion, int cutoutTopInset, int splitShadeSmartspaceHeight,
            float qsExpansion, int cutoutTopInset, boolean isSplitShade) {
            boolean isSplitShade) {
        mMinTopMargin = keyguardStatusBarHeaderHeight + Math.max(mContainerTopPadding,
        mMinTopMargin = keyguardStatusBarHeaderHeight + Math.max(mContainerTopPadding,
                userSwitchHeight);
                userSwitchHeight);
        mMaxShadeBottom = maxShadeBottom;
        mMaxShadeBottom = maxShadeBottom;
        mNotificationStackHeight = notificationStackHeight;
        mPanelExpansion = panelExpansion;
        mPanelExpansion = panelExpansion;
        mHeight = parentHeight;
        mKeyguardStatusHeight = keyguardStatusHeight + mStatusViewBottomMargin;
        mKeyguardStatusHeight = keyguardStatusHeight + mStatusViewBottomMargin;
        mUserSwitchHeight = userSwitchHeight;
        mUserSwitchHeight = userSwitchHeight;
        mUserSwitchPreferredY = userSwitchPreferredY;
        mUserSwitchPreferredY = userSwitchPreferredY;
        mHasCustomClock = hasCustomClock;
        mHasVisibleNotifs = hasVisibleNotifs;
        mDarkAmount = dark;
        mDarkAmount = dark;
        mOverStretchAmount = overStrechAmount;
        mOverStretchAmount = overStrechAmount;
        mBypassEnabled = bypassEnabled;
        mBypassEnabled = bypassEnabled;
        mUnlockedStackScrollerPadding = unlockedStackScrollerPadding;
        mUnlockedStackScrollerPadding = unlockedStackScrollerPadding;
        mQsExpansion = qsExpansion;
        mQsExpansion = qsExpansion;
        mCutoutTopInset = cutoutTopInset;
        mCutoutTopInset = cutoutTopInset;
        mSplitShadeSmartspaceHeight = splitShadeSmartspaceHeight;
        mIsSplitShade = isSplitShade;
        mIsSplitShade = isSplitShade;
    }
    }


@@ -184,7 +213,7 @@ public class KeyguardClockPositionAlgorithm {
        if (mBypassEnabled) {
        if (mBypassEnabled) {
            return (int) (mUnlockedStackScrollerPadding + mOverStretchAmount);
            return (int) (mUnlockedStackScrollerPadding + mOverStretchAmount);
        } else if (mIsSplitShade) {
        } else if (mIsSplitShade) {
            return clockYPosition + mSplitShadeSmartspaceHeight;
            return clockYPosition;
        } else {
        } else {
            return clockYPosition + mKeyguardStatusHeight;
            return clockYPosition + mKeyguardStatusHeight;
        }
        }
Loading