Refine layout for output switcher panel

1. only make the output switcher tall enough to show 6.5 devices
2. enlarge album art to 52*52 and keep same size on group panel
3. reduce panel header top padding
4. enlarge slice first item top padding
5. update slider bar right padding
6. update panel height
7. align slice title item left with panel title icon
8. enlarge slice end item right padding

Bug: 156045699
Test: manual test
Change-Id: I51321d98ef483665689b7e258d6071df76382759
This commit is contained in:
Tim Peng
2020-05-27 13:29:55 +08:00
parent 05103c79d1
commit 9bdeef43fd
4 changed files with 42 additions and 15 deletions

View File

@@ -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,