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

Commit 85a91449 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[flexiglass] Fix multiple smartspace view issue." into main

parents add49626 28baed28
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -222,4 +222,10 @@

    <!-- Communal mode -->
    <item type="id" name="communal_widget_wrapper" />

    <!--
    Used to tag views programmatically added to the smartspace area so they can be more easily
    removed later.
    -->
    <item type="id" name="tag_smartspace_view" />
</resources>
+11 −2
Original line number Diff line number Diff line
@@ -293,7 +293,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
            int viewIndex = mStatusArea.indexOfChild(ksv);
            ksv.setVisibility(View.GONE);

            mSmartspaceController.removeViewsFromParent(mStatusArea);
            removeViewsFromStatusArea();
            addSmartspaceView();
            // TODO(b/261757708): add content observer for the Settings toggle and add/remove
            //  weather according to the Settings.
@@ -325,7 +325,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS

    void onLocaleListChanged() {
        if (mSmartspaceController.isEnabled()) {
            mSmartspaceController.removeViewsFromParent(mStatusArea);
            removeViewsFromStatusArea();
            addSmartspaceView();
            if (mSmartspaceController.isDateWeatherDecoupled()) {
                mDateWeatherView.removeView(mWeatherView);
@@ -620,4 +620,13 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
        return ((mCurrentClockSize == LARGE) ? clock.getLargeClock() : clock.getSmallClock())
                .getConfig().getHasCustomWeatherDataDisplay();
    }

    private void removeViewsFromStatusArea() {
        for  (int i = mStatusArea.getChildCount() - 1; i >= 0; i--) {
            final View childView = mStatusArea.getChildAt(i);
            if (childView.getTag(R.id.tag_smartspace_view) != null) {
                mStatusArea.removeViewAt(i);
            }
        }
    }
}
+5 −7
Original line number Diff line number Diff line
@@ -388,7 +388,10 @@ constructor(
        })
        ssView.setFalsingManager(falsingManager)
        ssView.setKeyguardBypassEnabled(bypassController.bypassEnabled)
        return (ssView as View).apply { addOnAttachStateChangeListener(stateChangeListener) }
        return (ssView as View).apply {
            setTag(R.id.tag_smartspace_view, Any())
            addOnAttachStateChangeListener(stateChangeListener)
        }
    }

    private fun connectSession() {
@@ -451,12 +454,6 @@ constructor(
        session?.requestSmartspaceUpdate()
    }

    fun removeViewsFromParent(viewGroup: ViewGroup) {
        smartspaceViews.toList().forEach {
            viewGroup.removeView(it as View)
        }
    }

    /**
     * Disconnects the smartspace view from the smartspace service and cleans up any resources.
     */
@@ -597,3 +594,4 @@ constructor(
        }
    }
}
+4 −7
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import static com.android.systemui.flags.Flags.LOCKSCREEN_WALLPAPER_DREAM_ENABLE

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -136,6 +135,10 @@ public class KeyguardClockSwitchControllerBaseTest extends SysuiTestCase {
    public void setup() {
        MockitoAnnotations.initMocks(this);

        mFakeDateView.setTag(R.id.tag_smartspace_view, new Object());
        mFakeWeatherView.setTag(R.id.tag_smartspace_view, new Object());
        mFakeSmartspaceView.setTag(R.id.tag_smartspace_view, new Object());

        when(mView.findViewById(R.id.left_aligned_notification_icon_container))
                .thenReturn(mNotificationIcons);
        when(mNotificationIcons.getLayoutParams()).thenReturn(
@@ -158,12 +161,6 @@ public class KeyguardClockSwitchControllerBaseTest extends SysuiTestCase {
        when(mSmartspaceController.buildAndConnectDateView(any())).thenReturn(mFakeDateView);
        when(mSmartspaceController.buildAndConnectWeatherView(any())).thenReturn(mFakeWeatherView);
        when(mSmartspaceController.buildAndConnectView(any())).thenReturn(mFakeSmartspaceView);
        doAnswer(invocation -> {
            removeView(mFakeDateView);
            removeView(mFakeWeatherView);
            removeView(mFakeSmartspaceView);
            return null;
        }).when(mSmartspaceController).removeViewsFromParent(any());
        mExecutor = new FakeExecutor(new FakeSystemClock());
        mFakeFeatureFlags = new FakeFeatureFlags();
        mFakeFeatureFlags.set(FACE_AUTH_REFACTOR, false);