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

Commit 5b103bac authored by Alex Shabalin's avatar Alex Shabalin
Browse files

Update layout for displays with small height.

- Add HorizontalScrollView for the Quick Access Shelf to allow
scrolling when buttons don't fit horizontally.
- For displays with height <= 411dp, hide the metadata section and show
only the application icon to the left of the Quick Access Shelf.

Fix: 431162200
Test: atest MediaOutputDialogFullScreenshotTest
Test: atest MediaOutputDialogLowResScreenshotTest
Test: On a device with font and display size set to max.
Flag: EXEMPT BUGFIX
Change-Id: I039dedd4be85ad01425235cdda0c78c67c09f43d
parent ec8289b6
Loading
Loading
Loading
Loading
+42 −21
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@
                android:layout_height="20dp"
                android:layout_marginBottom="7dp"
                android:gravity="center_vertical"
                android:visibility="gone"
                android:importantForAccessibility="no"/>
            <TextView
                android:id="@+id/header_title"
@@ -74,10 +75,28 @@
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <ImageView
            android:id="@+id/app_source_icon_small_screen_height"
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:visibility="gone"
            android:layout_marginHorizontal="@dimen/media_output_dialog_margin_horizontal"
            android:layout_marginTop="16dp"
            android:layout_marginBottom="16dp"
            android:importantForAccessibility="no"/>

        <HorizontalScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <LinearLayout
                android:id="@+id/quick_access_shelf"
                android:paddingHorizontal="@dimen/media_output_dialog_margin_horizontal"
        android:layout_width="match_parent"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:visibility="gone">

@@ -101,6 +120,8 @@
                    android:text="@string/media_output_dialog_button_connect_device"
                    android:layout_marginBottom="8dp"/>
            </LinearLayout>
        </HorizontalScrollView>
    </LinearLayout>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/device_list"
+23 −12
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog
        implements MediaSwitchingController.Callback, Window.Callback {

    private static final String TAG = "MediaOutputDialog";
    public static final int SMALL_SCREEN_HEIGHT_DP = 400;

    protected final Handler mMainThreadHandler = new Handler(Looper.getMainLooper());
    private final LinearLayoutManager mLayoutManager;
@@ -168,7 +169,14 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog
        mDeviceListLayout = mDialogView.requireViewById(R.id.device_list);
        mDoneButton = mDialogView.requireViewById(R.id.done);
        mStopButton = mDialogView.requireViewById(R.id.stop);
        mAppResourceIcon = mDialogView.requireViewById(R.id.app_source_icon);

        boolean isSmallScreenHeight =
                mContext.getResources().getConfiguration().screenHeightDp <= SMALL_SCREEN_HEIGHT_DP;
        mAppResourceIcon = mDialogView.requireViewById(
                isSmallScreenHeight ? R.id.app_source_icon_small_screen_height
                        : R.id.app_source_icon);
        mAppResourceIcon.setVisibility(View.VISIBLE);
        mMediaMetadataSectionLayout.setVisibility(isSmallScreenHeight ? View.GONE : View.VISIBLE);

        // Init device list
        mLayoutManager.setAutoMeasureEnabled(true);
@@ -187,6 +195,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog
        mDismissing = false;

        if (enableOutputSwitcherRedesign()) {
            // TODO(b/444172986): set these properties in the layout file.
            // Reduce radius of dialog background.
            mDialogView.setBackground(AppCompatResources.getDrawable(mContext,
                    R.drawable.media_output_dialog_background_reduced_radius));
@@ -202,6 +211,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog
                    .setTypeface(Typeface.create(GSF_TITLE_MEDIUM_EMPHASIZED, Typeface.NORMAL));
            mHeaderSubtitle
                    .setTypeface(Typeface.create(GSF_TITLE_SMALL, Typeface.NORMAL));
            if (!isSmallScreenHeight) {
                // Reduce the size of the app icon.
                float appIconSize = mContext.getResources().getDimension(
                        R.dimen.media_output_dialog_app_icon_size);
@@ -213,6 +223,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog
                params.width = (int) appIconSize;
                params.height = (int) appIconSize;
                mAppResourceIcon.setLayoutParams(params);
            }
            // Change footer background color on scroll.
            mDevicesRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
                @Override