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

Commit 6049a0f9 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Clean-up QS footer actions initialization

This CL cleans up the trivial removal of the View implementation of the
QS footer actions that was made in http://ag/27576275.

Bug: 293569320
Test: atest QSImplTest
Test: Manual, verified that the QS footer actions display correctly and
 that b/299104543 was not happening.
Flag: NONE code cleanup
Change-Id: I76349d8616774bc2a89be6cb19e1cd619d596ab2
parent da5f2ff6
Loading
Loading
Loading
Loading
+0 −29
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
** Copyright 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.
-->

<!-- Action buttons for footer in QS/QQS, containing settings button, power off button etc -->
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="@dimen/footer_actions_height"
    android:elevation="@dimen/qs_panel_elevation"
    android:paddingTop="@dimen/qs_footer_actions_top_padding"
    android:paddingBottom="@dimen/qs_footer_actions_bottom_padding"
    android:background="@drawable/qs_footer_actions_background"
    android:gravity="center_vertical|end"
    android:layout_gravity="bottom"
/>
 No newline at end of file
+2 −3
Original line number Diff line number Diff line
@@ -47,13 +47,12 @@

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

    <include
        layout="@layout/footer_actions"
    <androidx.compose.ui.platform.ComposeView
        android:id="@+id/qs_footer_actions"
        android:layout_height="@dimen/footer_actions_height"
        android:layout_width="match_parent"
        android:layout_gravity="bottom"
        />
        android:elevation="@dimen/qs_panel_elevation" />

    <include
        android:id="@+id/qs_customize"
+0 −3
Original line number Diff line number Diff line
@@ -259,9 +259,6 @@
    <!-- ID of the Scene Container root Composable view -->
    <item type='id' name="scene_container_root_composable" />

    <!-- Tag set on the Compose implementation of the QS footer actions. -->
    <item type="id" name="tag_compose_qs_footer_actions" />

    <!--
    Ids for the device entry icon.
        device_entry_icon_view: parent view of both device_entry_icon and device_entry_icon_bg
+1 −1
Original line number Diff line number Diff line
@@ -307,7 +307,7 @@ public class QSContainerImpl extends FrameLayout implements Dumpable {
            } else {
                // Set the horizontal paddings unless the view is the Compose implementation of the
                // footer actions.
                if (view.getTag(R.id.tag_compose_qs_footer_actions) == null) {
                if (view.getId() != R.id.qs_footer_actions) {
                    view.setPaddingRelative(
                            mContentHorizontalPadding,
                            view.getPaddingTop(),
+4 −29
Original line number Diff line number Diff line
@@ -34,11 +34,11 @@ import android.util.IndentingPrintWriter;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import androidx.annotation.FloatRange;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.compose.ui.platform.ComposeView;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleRegistry;
@@ -167,7 +167,7 @@ public class QSImpl implements QS, CommandQueue.Callbacks, StatusBarStateControl

    private View mRootView;
    @Nullable
    private View mFooterActionsView;
    private ComposeView mFooterActionsView;

    @Inject
    public QSImpl(RemoteInputQuickSettingsDisabler remoteInputQsDisabler,
@@ -285,34 +285,9 @@ public class QSImpl implements QS, CommandQueue.Callbacks, StatusBarStateControl
    }

    private void bindFooterActionsView(View root) {
        LinearLayout footerActionsView = root.findViewById(R.id.qs_footer_actions);

        // Compose is available, so let's use the Compose implementation of the footer actions.
        View composeView = QSUtils.createFooterActionsView(root.getContext(),
        mFooterActionsView = root.findViewById(R.id.qs_footer_actions);
        QSUtils.setFooterActionsViewContent(mFooterActionsView,
                mQSFooterActionsViewModel, mListeningAndVisibilityLifecycleOwner);
        mFooterActionsView = composeView;

        // The id R.id.qs_footer_actions is used by QSContainerImpl to set the horizontal margin
        // to all views except for qs_footer_actions, so we set it to the Compose view.
        composeView.setId(R.id.qs_footer_actions);

        // Set this tag so that QSContainerImpl does not add horizontal paddings to this Compose
        // implementation of the footer actions. They will be set in Compose instead so that the
        // background fills the full screen width.
        composeView.setTag(R.id.tag_compose_qs_footer_actions, true);

        // Set the same elevation as the View implementation, otherwise the footer actions will be
        // drawn below the scroll view with QS grid and clicks won't get through on small devices
        // where there isn't enough vertical space to show all the tiles and the footer actions.
        composeView.setElevation(
                composeView.getContext().getResources().getDimension(R.dimen.qs_panel_elevation));

        // Replace the View by the Compose provided one.
        ViewGroup parent = (ViewGroup) footerActionsView.getParent();
        ViewGroup.LayoutParams layoutParams = footerActionsView.getLayoutParams();
        int index = parent.indexOfChild(footerActionsView);
        parent.removeViewAt(index);
        parent.addView(composeView, index, layoutParams);
    }

    @Override
Loading