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

Commit 02e311e5 authored by tim peng's avatar tim peng Committed by Android (Google) Code Review
Browse files

Merge "Add a separate line at the bottom of list area in output switcher" into rvc-dev

parents cab1329f aeabfc30
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -86,6 +86,11 @@
        <!-- Note: There is a landscape version of panel_slice_list which supports scrolling. -->
        <include layout="@layout/panel_slice_list"/>

        <include
            android:id="@+id/footer_divider"
            layout="@layout/horizontal_divider"
            android:visibility="gone"/>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
+9 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ public class PanelFragment extends Fragment {
    private TextView mHeaderTitle;
    private TextView mHeaderSubtitle;
    private int mMaxHeight;
    private View mFooterDivider;

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

@@ -187,6 +188,7 @@ public class PanelFragment extends Fragment {
        mTitleIcon = mLayoutView.findViewById(R.id.title_icon);
        mHeaderTitle = mLayoutView.findViewById(R.id.header_title);
        mHeaderSubtitle = mLayoutView.findViewById(R.id.header_subtitle);
        mFooterDivider = mLayoutView.findViewById(R.id.footer_divider);

        // Make the panel layout gone here, to avoid janky animation when updating from old panel.
        // We will make it visible once the panel is ready to load.
@@ -241,6 +243,13 @@ public class PanelFragment extends Fragment {
                mTitleIcon.setLayoutParams(new LinearLayout.LayoutParams(size, size));
            }
        }

        if (mPanel.getViewType() == PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON) {
            mFooterDivider.setVisibility(View.VISIBLE);
        } else {
            mFooterDivider.setVisibility(View.GONE);
        }

        mSeeMoreButton.setOnClickListener(getSeeMoreListener());
        mDoneButton.setOnClickListener(getCloseListener());

+1 −1
Original line number Diff line number Diff line
@@ -175,7 +175,7 @@ public class PanelSlicesAdapter

        @Override
        public boolean isDividerAllowedBelow() {
            return true;
            return mPanelFragment.getPanelViewType() != PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON;
        }
    }
}
+51 −0
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@

package com.android.settings.panel;

import static com.android.settings.panel.PanelContent.VIEW_TYPE_SLIDER;
import static com.android.settings.panel.PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON;

import static com.google.common.truth.Truth.assertThat;

import static org.mockito.ArgumentMatchers.any;
@@ -209,6 +212,54 @@ public class PanelFragmentTest {
        assertThat(titleView.getVisibility()).isEqualTo(View.VISIBLE);
    }

    @Test
    public void sliderLargeIconPanelType_displayFooterDivider() {
        mFakePanelContent.setViewType(VIEW_TYPE_SLIDER_LARGE_ICON);
        final ActivityController<FakeSettingsPanelActivity> activityController =
                Robolectric.buildActivity(FakeSettingsPanelActivity.class);
        activityController.setup();
        final PanelFragment panelFragment = (PanelFragment)
                Objects.requireNonNull(activityController
                        .get()
                        .getSupportFragmentManager()
                        .findFragmentById(R.id.main_content));
        final View footerDivider = panelFragment.mLayoutView.findViewById(R.id.footer_divider);
        // Check visibility
        assertThat(footerDivider.getVisibility()).isEqualTo(View.VISIBLE);
    }

    @Test
    public void sliderPanelType_notDisplayFooterDivider() {
        mFakePanelContent.setViewType(VIEW_TYPE_SLIDER);
        final ActivityController<FakeSettingsPanelActivity> activityController =
                Robolectric.buildActivity(FakeSettingsPanelActivity.class);
        activityController.setup();
        final PanelFragment panelFragment = (PanelFragment)
                Objects.requireNonNull(activityController
                        .get()
                        .getSupportFragmentManager()
                        .findFragmentById(R.id.main_content));
        final View footerDivider = panelFragment.mLayoutView.findViewById(R.id.footer_divider);
        // Check visibility
        assertThat(footerDivider.getVisibility()).isEqualTo(View.GONE);
    }

    @Test
    public void defaultPanelType_notDisplayFooterDivider() {
        mFakePanelContent.setViewType(0 /* viewType */);
        final ActivityController<FakeSettingsPanelActivity> activityController =
                Robolectric.buildActivity(FakeSettingsPanelActivity.class);
        activityController.setup();
        final PanelFragment panelFragment = (PanelFragment)
                Objects.requireNonNull(activityController
                        .get()
                        .getSupportFragmentManager()
                        .findFragmentById(R.id.main_content));
        final View footerDivider = panelFragment.mLayoutView.findViewById(R.id.footer_divider);
        // Check visibility
        assertThat(footerDivider.getVisibility()).isEqualTo(View.GONE);
    }

    @Test
    public void onHeaderChanged_updateHeader_verifyTitle() {
        mFakePanelContent.setIcon(IconCompat.createWithResource(mContext, R.drawable.ic_android));
+50 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static com.android.settings.panel.PanelSlicesAdapter.MAX_NUM_OF_SLICES;
import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_GROUP_SLICE_URI;
import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_INDICATOR_SLICE_URI;
import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_SLICE_URI;
import static com.android.settings.slices.CustomSliceRegistry.VOLUME_MEDIA_URI;

import static com.google.common.truth.Truth.assertThat;

@@ -143,8 +144,25 @@ public class PanelSlicesAdapterTest {
    }

    @Test
    public void outputSwitcherSlice_shouldAddFirstItemPadding() {
    public void sliderLargeIconPanel_shouldNotAllowDividerBelow() {
        addTestLiveData(MEDIA_OUTPUT_SLICE_URI);
        mFakePanelContent.setViewType(PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON);

        final PanelSlicesAdapter adapter =
                new PanelSlicesAdapter(mPanelFragment, mData, 0 /* metrics category */);
        final int position = 0;
        final ViewGroup view = new FrameLayout(mContext);
        final SliceRowViewHolder viewHolder =
                adapter.onCreateViewHolder(view, PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON);
        adapter.onBindViewHolder(viewHolder, position);

        assertThat(viewHolder.isDividerAllowedBelow()).isFalse();
    }

    @Test
    public void sliderPanelType_shouldAllowDividerBelow() {
        addTestLiveData(VOLUME_MEDIA_URI);
        mFakePanelContent.setViewType(PanelContent.VIEW_TYPE_SLIDER);

        final PanelSlicesAdapter adapter =
                new PanelSlicesAdapter(mPanelFragment, mData, 0 /* metrics category */);
@@ -152,6 +170,36 @@ public class PanelSlicesAdapterTest {
        final ViewGroup view = new FrameLayout(mContext);
        final SliceRowViewHolder viewHolder =
                adapter.onCreateViewHolder(view, PanelContent.VIEW_TYPE_SLIDER);
        adapter.onBindViewHolder(viewHolder, position);

        assertThat(viewHolder.isDividerAllowedBelow()).isTrue();
    }

    @Test
    public void defaultPanelType_shouldAllowDividerBelow() {
        addTestLiveData(VOLUME_MEDIA_URI);
        mFakePanelContent.setViewType(0 /* viewType */);

        final PanelSlicesAdapter adapter =
                new PanelSlicesAdapter(mPanelFragment, mData, 0 /* metrics category */);
        final int position = 0;
        final ViewGroup view = new FrameLayout(mContext);
        final SliceRowViewHolder viewHolder = adapter.onCreateViewHolder(view, 0/* viewType */);
        adapter.onBindViewHolder(viewHolder, position);

        assertThat(viewHolder.isDividerAllowedBelow()).isTrue();
    }

    @Test
    public void outputSwitcherSlice_shouldAddFirstItemPadding() {
        addTestLiveData(MEDIA_OUTPUT_SLICE_URI);

        final PanelSlicesAdapter adapter =
                new PanelSlicesAdapter(mPanelFragment, mData, 0 /* metrics category */);
        final int position = 0;
        final ViewGroup view = new FrameLayout(mContext);
        final SliceRowViewHolder viewHolder =
                adapter.onCreateViewHolder(view, PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON);

        adapter.onBindViewHolder(viewHolder, position);

@@ -169,7 +217,7 @@ public class PanelSlicesAdapterTest {
        final int position = 0;
        final ViewGroup view = new FrameLayout(mContext);
        final SliceRowViewHolder viewHolder =
                adapter.onCreateViewHolder(view, PanelContent.VIEW_TYPE_SLIDER);
                adapter.onCreateViewHolder(view, PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON);

        adapter.onBindViewHolder(viewHolder, position);