Loading res/layout/panel_layout.xml +5 −0 Original line number Diff line number Diff line Loading @@ -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" Loading src/com/android/settings/panel/PanelFragment.java +9 −0 Original line number Diff line number Diff line Loading @@ -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<>(); Loading Loading @@ -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. Loading Loading @@ -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()); Loading src/com/android/settings/panel/PanelSlicesAdapter.java +1 −1 Original line number Diff line number Diff line Loading @@ -175,7 +175,7 @@ public class PanelSlicesAdapter @Override public boolean isDividerAllowedBelow() { return true; return mPanelFragment.getPanelViewType() != PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON; } } } tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java +51 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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)); Loading tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java +50 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 */); Loading @@ -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); Loading @@ -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); Loading Loading
res/layout/panel_layout.xml +5 −0 Original line number Diff line number Diff line Loading @@ -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" Loading
src/com/android/settings/panel/PanelFragment.java +9 −0 Original line number Diff line number Diff line Loading @@ -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<>(); Loading Loading @@ -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. Loading Loading @@ -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()); Loading
src/com/android/settings/panel/PanelSlicesAdapter.java +1 −1 Original line number Diff line number Diff line Loading @@ -175,7 +175,7 @@ public class PanelSlicesAdapter @Override public boolean isDividerAllowedBelow() { return true; return mPanelFragment.getPanelViewType() != PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON; } } }
tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java +51 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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)); Loading
tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java +50 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 */); Loading @@ -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); Loading @@ -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); Loading