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

Commit 55fc34c4 authored by Alexandr Shabalin's avatar Alexandr Shabalin Committed by Android (Google) Code Review
Browse files

Merge "Reflow OSw footer buttons when display size is increased" into main

parents a4c06d8a daba318e
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@
            app:layout_constraintHeight_max="@dimen/media_output_dialog_list_max_height"/>
    </androidx.constraintlayout.widget.ConstraintLayout>

    <LinearLayout
    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/dialog_footer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
@@ -139,17 +139,24 @@
            android:text="@string/media_output_dialog_button_stop_casting"
            android:visibility="gone"/>

        <Space
            android:id="@+id/footer_spacer"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="match_parent"/>

        <Button
            android:id="@+id/done"
            style="@style/Widget.Dialog.Button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/inline_done_button"/>
    </LinearLayout>

        <androidx.constraintlayout.helper.widget.Flow
            android:id="@+id/flow_buttons"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            android:orientation="horizontal"
            app:flow_wrapMode="chain"
            app:constraint_referenced_ids="stop,done"
            app:flow_horizontalStyle="spread_inside"
            app:flow_verticalAlign="center" />
    </androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
 No newline at end of file
+24 −9
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import android.widget.TextView;

import androidx.annotation.VisibleForTesting;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.constraintlayout.helper.widget.Flow;
import androidx.core.graphics.drawable.IconCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@@ -100,7 +101,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog
    private LinearLayout mMediaMetadataSectionLayout;
    private Button mDoneButton;
    private ViewGroup mDialogFooter;
    private View mFooterSpacer;
    private Flow mButtonsFlow;
    private Button mStopButton;
    private WallpaperColors mWallpaperColors;
    private boolean mDismissing;
@@ -162,7 +163,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog
        mAudioSharingButton = mDialogView.requireViewById(R.id.audio_sharing);
        mDevicesRecyclerView = mDialogView.requireViewById(R.id.list_result);
        mDialogFooter = mDialogView.requireViewById(R.id.dialog_footer);
        mFooterSpacer = mDialogView.requireViewById(R.id.footer_spacer);
        mButtonsFlow = mDialogView.requireViewById(R.id.flow_buttons);
        mMediaMetadataSectionLayout = mDialogView.requireViewById(R.id.media_metadata_section);
        mDeviceListLayout = mDialogView.requireViewById(R.id.device_list);
        mDoneButton = mDialogView.requireViewById(R.id.done);
@@ -192,13 +193,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog
            // Set non-transparent footer background to change it color on scroll.
            mDialogFooter.setBackground(AppCompatResources.getDrawable(mContext,
                    R.drawable.media_output_dialog_footer_background));
            // Right-align the footer buttons.
            LinearLayout.LayoutParams layoutParams =
                    (LinearLayout.LayoutParams) mFooterSpacer.getLayoutParams();
            layoutParams.width = (int) mContext.getResources().getDimension(
                    R.dimen.media_output_dialog_button_gap);
            mFooterSpacer.setLayoutParams(layoutParams);
            layoutParams.weight = 0;

            // Update font family to Google Sans Flex.
            Typeface buttonTypeface = Typeface.create(GSF_LABEL_LARGE, Typeface.NORMAL);
            mDoneButton.setTypeface(buttonTypeface);
@@ -343,6 +338,26 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog
        mStopButton.setText(getStopButtonText());
        mStopButton.setOnClickListener(v -> onStopButtonClick());

        if (!enableOutputSwitcherRedesign()) {
            if (getStopButtonVisibility() == View.VISIBLE) {
                // If both buttons are visible, spread them to both the ends.
                mButtonsFlow.setHorizontalStyle(Flow.CHAIN_SPREAD_INSIDE);
                mButtonsFlow.setHorizontalBias(0.5f);
            } else {
                // If only one button is visible, align it to the end.
                mButtonsFlow.setHorizontalStyle(Flow.CHAIN_PACKED);
                mButtonsFlow.setHorizontalBias(1.0f);
            }
        } else {
            // If redesign is enabled, buttons stay towards the end.
            mButtonsFlow.setHorizontalStyle(Flow.CHAIN_PACKED);
            mButtonsFlow.setHorizontalBias(1.0f);
            mButtonsFlow.setHorizontalGap(
                    (int)
                            mContext.getResources()
                                    .getDimension(R.dimen.media_output_dialog_button_gap));
        }

        if (!mAdapter.isDragging()) {
            int currentActivePosition = mAdapter.getCurrentActivePosition();
            if (!colorSetUpdated && !deviceSetChanged && currentActivePosition >= 0