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

Commit bdd31f45 authored by tim peng's avatar tim peng Committed by Automerger Merge Worker
Browse files

Merge "Refine layout for output switcher panel" into rvc-dev am: 7874c0fd

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/11596546

Change-Id: I107a836766ab9aef4f2e8cc5fc953c35f414f5f0
parents 42a72503 7874c0fd
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -30,21 +30,20 @@
        <LinearLayout
            android:id="@+id/panel_header"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_height="94dp"
            android:gravity="start|center_vertical"
            android:orientation="horizontal"
            android:visibility="gone">

            <LinearLayout
                android:layout_width="36dp"
                android:layout_height="36dp"
                android:gravity="center_vertical|center_horizontal"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_marginStart="16dp">
                <ImageView
                    android:id="@+id/title_icon"
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"/>
                    android:layout_width="@dimen/output_switcher_panel_icon_size"
                    android:layout_height="@dimen/output_switcher_panel_icon_size"/>
            </LinearLayout>

            <LinearLayout
@@ -52,10 +51,7 @@
                android:layout_height="wrap_content"
                android:layout_marginStart="16dp"
                android:layout_marginEnd="16dp"
                android:gravity="center_vertical"
                android:orientation="vertical"
                android:paddingBottom="9dp"
                android:paddingTop="9dp">
                android:orientation="vertical">
                <TextView
                    android:id="@+id/header_title"
                    android:layout_width="wrap_content"
+3 −1
Original line number Diff line number Diff line
@@ -422,7 +422,9 @@
    <dimen name="list_preferred_item_padding">16dp</dimen>

    <!-- Output switcher panel related dimensions -->
    <dimen name="output_switcher_slice_padding_top">12dp</dimen>
    <dimen name="output_switcher_slice_padding_top">11dp</dimen>
    <dimen name="output_switcher_slice_max_height">506dp</dimen>
    <dimen name="output_switcher_panel_icon_size">52dp</dimen>

    <!-- Text padding for EmptyTextSettings -->
    <dimen name="empty_text_padding">24dp</dimen>
+5 −4
Original line number Diff line number Diff line
@@ -564,16 +564,17 @@
    </style>

    <style name="SliceRow.Slider">
        <!-- 10dp start padding for the start icon -->
        <item name="titleItemStartPadding">10dp</item>
        <!-- 4dp start padding for the start icon -->
        <item name="titleItemStartPadding">4dp</item>

        <!-- Padding between content and the start icon is 0dp -->
        <item name="contentStartPadding">0dp</item>
        <item name="contentEndPadding">36dp</item>

        <!-- 0dp start padding for the end item -->
        <item name="endItemStartPadding">0dp</item>
        <!-- 24dp end padding for the end item -->
        <item name="endItemEndPadding">24dp</item>
        <!-- 8dp end padding for the end item -->
        <item name="endItemEndPadding">8dp</item>

        <!-- Align text with slider -->
        <item name="titleStartPadding">11dp</item>
+28 −0
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ public class PanelFragment extends Fragment {
    private ImageView mTitleIcon;
    private TextView mHeaderTitle;
    private TextView mHeaderSubtitle;
    private int mMaxHeight;

    private final Map<Uri, LiveData<Slice>> mSliceLiveData = new LinkedHashMap<>();

@@ -105,6 +106,18 @@ public class PanelFragment extends Fragment {
        return false;
    };

    private final ViewTreeObserver.OnGlobalLayoutListener mPanelLayoutListener =
            new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    if (mLayoutView.getHeight() > mMaxHeight) {
                        final ViewGroup.LayoutParams params = mLayoutView.getLayoutParams();
                        params.height = mMaxHeight;
                        mLayoutView.setLayoutParams(params);
                    }
                }
            };

    private final ViewTreeObserver.OnGlobalLayoutListener mOnGlobalLayoutListener =
            new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
@@ -123,6 +136,9 @@ public class PanelFragment extends Fragment {
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
            @Nullable Bundle savedInstanceState) {
        mLayoutView = inflater.inflate(R.layout.panel_layout, container, false);
        mLayoutView.getViewTreeObserver()
                .addOnGlobalLayoutListener(mPanelLayoutListener);
        mMaxHeight = getResources().getDimensionPixelSize(R.dimen.output_switcher_slice_max_height);
        createPanelContent();
        return mLayoutView;
    }
@@ -159,6 +175,9 @@ public class PanelFragment extends Fragment {
        if (mLayoutView == null) {
            activity.finish();
        }
        final ViewGroup.LayoutParams params = mLayoutView.getLayoutParams();
        params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        mLayoutView.setLayoutParams(params);

        mPanelSlices = mLayoutView.findViewById(R.id.panel_parent_layout);
        mSeeMoreButton = mLayoutView.findViewById(R.id.see_more);
@@ -214,6 +233,12 @@ public class PanelFragment extends Fragment {
            mHeaderSubtitle.setText(mPanel.getSubTitle());
            if (mPanel.getHeaderIconIntent() != null) {
                mTitleIcon.setOnClickListener(getHeaderIconListener());
                mTitleIcon.setLayoutParams(new LinearLayout.LayoutParams(
                        ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
            } else {
                final int size = getResources().getDimensionPixelSize(
                        R.dimen.output_switcher_panel_icon_size);
                mTitleIcon.setLayoutParams(new LinearLayout.LayoutParams(size, size));
            }
        }
        mSeeMoreButton.setOnClickListener(getSeeMoreListener());
@@ -378,6 +403,9 @@ public class PanelFragment extends Fragment {
            mPanelClosedKey = PanelClosedKeys.KEY_OTHERS;
        }

        if (mLayoutView != null) {
            mLayoutView.getViewTreeObserver().removeOnGlobalLayoutListener(mPanelLayoutListener);
        }
        mMetricsProvider.action(
                0 /* attribution */,
                SettingsEnums.PAGE_HIDE,