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

Commit 81f7a397 authored by Ben Lin's avatar Ben Lin
Browse files

Introduce QsFrameTranslateController.

This allows different device configurations, such as
Desktop devices, to move the QS around by providing their own
calculation and logic.

Bug: None
Test: m -j32
Change-Id: Ibe28d4bc0b741367fb63b230e34b2ca34ab075bc
parent b7ce2794
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import com.android.systemui.shared.system.smartspace.SmartspaceTransitionControl
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.QsFrameTranslateModule;
import com.android.systemui.statusbar.notification.NotifPipelineFlags;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.collection.NotifPipeline;
@@ -112,6 +113,7 @@ import dagger.Provides;
            LogModule.class,
            PeopleHubModule.class,
            PluginModule.class,
            QsFrameTranslateModule.class,
            ScreenshotModule.class,
            SensorModule.class,
            SettingsModule.class,
+48 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.
 */

package com.android.systemui.statusbar;

import android.view.View;

import com.android.systemui.plugins.qs.QS;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.phone.StatusBar;

/**
 * Calculates and moves the QS frame vertically.
 */
public abstract class QsFrameTranslateController {

    protected StatusBar mStatusBar;

    public QsFrameTranslateController(StatusBar statusBar) {
        mStatusBar = statusBar;
    }

    /**
     * Calculate and translate the QS Frame on the Y-axis.
     */
    public abstract void translateQsFrame(View qsFrame, QS qs, float overExpansion,
            float qsTranslationForFullShadeTransition);

    /**
     * Calculate the top padding for notifications panel. This could be the supplied
     * @param expansionHeight or recalculate it for a different value.
     */
    public abstract float getNotificationsTopPadding(float expansionHeight,
            NotificationStackScrollLayoutController controller);
}
+50 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.
 */

package com.android.systemui.statusbar;

import android.view.View;

import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.plugins.qs.QS;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.phone.StatusBar;

import javax.inject.Inject;

/**
 * Default implementation of QS Translation. This by default does not do much.
 */
@SysUISingleton
public class QsFrameTranslateImpl extends QsFrameTranslateController {

    @Inject
    public QsFrameTranslateImpl(StatusBar statusBar) {
        super(statusBar);
    }

    @Override
    public void translateQsFrame(View qsFrame, QS qs, float overExpansion,
            float qsTranslationForFullShadeTransition) {
    }

    @Override
    public float getNotificationsTopPadding(float expansionHeight,
            NotificationStackScrollLayoutController controller) {

        return expansionHeight;
    }
}
+30 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.
 */

package com.android.systemui.statusbar;

import com.android.systemui.dagger.SysUISingleton;

import dagger.Binds;
import dagger.Module;

@Module
public interface QsFrameTranslateModule {

    @Binds
    @SysUISingleton
    QsFrameTranslateController bindQsFrameTranslateController(QsFrameTranslateImpl impl);
}
+9 −6
Original line number Diff line number Diff line
@@ -157,6 +157,7 @@ import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.NotificationShadeDepthController;
import com.android.systemui.statusbar.NotificationShelfController;
import com.android.systemui.statusbar.PulseExpansionHandler;
import com.android.systemui.statusbar.QsFrameTranslateController;
import com.android.systemui.statusbar.RemoteInputController;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
@@ -339,6 +340,7 @@ public class NotificationPanelViewController extends PanelViewController {
    private KeyguardStatusBarViewController mKeyguardStatusBarViewController;
    @VisibleForTesting QS mQs;
    private FrameLayout mQsFrame;
    private QsFrameTranslateController mQsFrameTranslateController;
    @Nullable
    private CommunalHostViewController mCommunalViewController;
    private KeyguardStatusViewController mKeyguardStatusViewController;
@@ -775,7 +777,8 @@ public class NotificationPanelViewController extends PanelViewController {
            NotificationRemoteInputManager remoteInputManager,
            Optional<SysUIUnfoldComponent> unfoldComponent,
            ControlsComponent controlsComponent,
            InteractionJankMonitor interactionJankMonitor) {
            InteractionJankMonitor interactionJankMonitor,
            QsFrameTranslateController qsFrameTranslateController) {
        super(view,
                falsingManager,
                dozeLog,
@@ -900,7 +903,6 @@ public class NotificationPanelViewController extends PanelViewController {

        mMaxKeyguardNotifications = resources.getInteger(R.integer.keyguard_max_notification_count);
        mKeyguardUnfoldTransition = unfoldComponent.map(c -> c.getKeyguardUnfoldTransition());

        mCommunalSourceCallback = () -> {
            mUiExecutor.execute(() -> setCommunalSource(null /*source*/));
        };
@@ -908,7 +910,7 @@ public class NotificationPanelViewController extends PanelViewController {
        mCommunalSourceMonitorCallback = (source) -> {
            mUiExecutor.execute(() -> setCommunalSource(source));
        };

        mQsFrameTranslateController = qsFrameTranslateController;
        updateUserSwitcherFlags();
        onFinishInflate();
    }
@@ -2667,7 +2669,8 @@ public class NotificationPanelViewController extends PanelViewController {
                    (float) (mQsMaxExpansionHeight),
                    computeQsExpansionFraction());
        } else {
            return mQsExpansionHeight;
            return mQsFrameTranslateController.getNotificationsTopPadding(mQsExpansionHeight,
                    mNotificationStackScrollLayoutController);
        }
    }

@@ -3251,8 +3254,8 @@ public class NotificationPanelViewController extends PanelViewController {
    }

    private void updateQsFrameTranslation() {
        float translation = mOverExpansion / 2.0f + mQsTranslationForFullShadeTransition;
        mQsFrame.setTranslationY(translation);
        mQsFrameTranslateController.translateQsFrame(mQsFrame, mQs, mOverExpansion,
                mQsTranslationForFullShadeTransition);
    }

    @Override
Loading