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

Commit 384d6ea9 authored by Xiaowen Lei's avatar Xiaowen Lei
Browse files

Add BcSmartspaceView to keyguard bottom area.

Screen capture: (with flag on)
  - cheetah: https://hsv.googleplex.com/5041267101663232
    - Note: ignore the Smartspace at the top.
      - This was taken with a slightly outdated cl.
  - felix: https://hsv.googleplex.com/6552804454825984
    - With the shade pulled down: https://hsv.googleplex.com/4612065063862272

Known limitations for this initial implemention:
  1. In this CL, ambient_indication_container is replaced by
smartspace_container, which contains the Smartspace. This is just for
exploration purpose. The end product should rank UMO and system messages
together with the Smartspace features, per product spec.
  2. Still need to update the logic to show/hide the smartspace when
     applicable. (E.g., when the shade is pulled down.)
  3. Pending UX spec for making it pretty. (at least not overlapping
     with other contents.)
  4. Haven't tested all combinations of devices and orientations.

Flag: ACONFIG com.android.systemui.smartspace_relocate_to_bottom DEVELOPMENT
Bug: 316212788
Test: Trigger Smartspace features (e.g. timer) and check lockscreen
Change-Id: Ib0581a95d44caaa9256a5a06d47b030a6e8f4052
parent 6cb651b1
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -107,4 +107,13 @@

    <include layout="@layout/ambient_indication"
             android:id="@id/ambient_indication_container" />

    <FrameLayout
        android:id="@+id/smartspace_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:layout_marginBottom="@dimen/ambient_indication_margin_bottom"
        android:visibility="gone">
    </FrameLayout>
</com.android.systemui.statusbar.phone.KeyguardBottomAreaView>
+5 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static com.android.keyguard.KeyguardClockSwitch.LARGE;
import static com.android.keyguard.KeyguardClockSwitch.SMALL;
import static com.android.systemui.Flags.migrateClocksToBlueprint;
import static com.android.systemui.Flags.smartspaceRelocateToBottom;
import static com.android.systemui.flags.Flags.LOCKSCREEN_WALLPAPER_DREAM_ENABLED;
import static com.android.systemui.util.kotlin.JavaAdapterKt.collectFlow;

@@ -421,6 +422,10 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
            return;
        }

        if (smartspaceRelocateToBottom()) {
            return;
        }

        mSmartspaceView = mSmartspaceController.buildAndConnectView(mView);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                MATCH_PARENT, WRAP_CONTENT);
+7 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static com.android.keyguard.KeyguardClockSwitch.SMALL;
import static com.android.systemui.Flags.keyguardBottomAreaRefactor;
import static com.android.systemui.Flags.migrateClocksToBlueprint;
import static com.android.systemui.Flags.predictiveBackAnimateShade;
import static com.android.systemui.Flags.smartspaceRelocateToBottom;
import static com.android.systemui.classifier.Classifier.BOUNCER_UNLOCK;
import static com.android.systemui.classifier.Classifier.GENERIC;
import static com.android.systemui.classifier.Classifier.QUICK_SETTINGS;
@@ -1428,7 +1429,12 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
            int index = mView.indexOfChild(mKeyguardBottomArea);
            mView.removeView(mKeyguardBottomArea);
            KeyguardBottomAreaView oldBottomArea = mKeyguardBottomArea;
            setKeyguardBottomArea(mKeyguardBottomAreaViewControllerProvider.get().getView());
            KeyguardBottomAreaViewController keyguardBottomAreaViewController =
                    mKeyguardBottomAreaViewControllerProvider.get();
            if (smartspaceRelocateToBottom()) {
                keyguardBottomAreaViewController.init();
            }
            setKeyguardBottomArea(keyguardBottomAreaViewController.getView());
            mKeyguardBottomArea.initFrom(oldBottomArea);
            mView.addView(mKeyguardBottomArea, index);

+41 −2
Original line number Diff line number Diff line
@@ -18,12 +18,23 @@ package com.android.systemui.statusbar.phone

import com.android.systemui.flags.FeatureFlagsClassic
import com.android.systemui.flags.Flags
import com.android.systemui.Flags.smartspaceRelocateToBottom
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import com.android.systemui.res.R
import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController
import com.android.systemui.util.ViewController
import javax.inject.Inject

class KeyguardBottomAreaViewController
    @Inject constructor(view: KeyguardBottomAreaView, featureFlags: FeatureFlagsClassic) :
    ViewController<KeyguardBottomAreaView> (view) {
    @Inject constructor(
            view: KeyguardBottomAreaView,
            private val smartspaceController: LockscreenSmartspaceController,
            featureFlags: FeatureFlagsClassic
) : ViewController<KeyguardBottomAreaView> (view) {

    private var smartspaceView: View? = null

    init {
        view.setIsLockscreenLandscapeEnabled(
@@ -31,6 +42,14 @@ class KeyguardBottomAreaViewController
    }

    override fun onViewAttached() {
        if (!smartspaceRelocateToBottom() || !smartspaceController.isEnabled()) {
            return
        }

        val ambientIndicationArea = mView.findViewById<View>(R.id.ambient_indication_container)
        ambientIndicationArea?.visibility = View.GONE

        addSmartspaceView()
    }

    override fun onViewDetached() {
@@ -40,4 +59,24 @@ class KeyguardBottomAreaViewController
        // TODO: remove this method.
        return mView
    }

    private fun addSmartspaceView() {
        if (!smartspaceRelocateToBottom()) {
            return
        }

        val smartspaceContainer = mView.findViewById<View>(R.id.smartspace_container)
        smartspaceContainer!!.visibility = View.VISIBLE

        smartspaceView = smartspaceController.buildAndConnectView(smartspaceContainer as ViewGroup)
        val lp = LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
        (smartspaceContainer as ViewGroup).addView(smartspaceView, 0, lp)
        val startPadding = context.resources.getDimensionPixelSize(
                R.dimen.below_clock_padding_start)
        val endPadding = context.resources.getDimensionPixelSize(
                R.dimen.below_clock_padding_end)
        smartspaceView?.setPaddingRelative(startPadding, 0, endPadding, 0)
//        mKeyguardUnlockAnimationController.lockscreenSmartspace = smartspaceView
    }
}