Hide the icon if didn't have media session or album art
- This CL before, output switcher panel will show default icon if there are no media session or album art. This CL will hide the icon if there are no media session or album art. - Add test case Bug: 161495909 Test: make -j42 RunSettingsRoboTests Change-Id: I5f80158b12f89c8499fb97d0b203ebeffefbc18b
This commit is contained in:
@@ -93,6 +93,7 @@ public class PanelFragment extends Fragment {
|
||||
private String mPanelClosedKey;
|
||||
private LinearLayout mPanelHeader;
|
||||
private ImageView mTitleIcon;
|
||||
private LinearLayout mTitleGroup;
|
||||
private TextView mHeaderTitle;
|
||||
private TextView mHeaderSubtitle;
|
||||
private int mMaxHeight;
|
||||
@@ -191,6 +192,7 @@ public class PanelFragment extends Fragment {
|
||||
mTitleView = mLayoutView.findViewById(R.id.panel_title);
|
||||
mPanelHeader = mLayoutView.findViewById(R.id.panel_header);
|
||||
mTitleIcon = mLayoutView.findViewById(R.id.title_icon);
|
||||
mTitleGroup = mLayoutView.findViewById(R.id.title_group);
|
||||
mHeaderTitle = mLayoutView.findViewById(R.id.header_title);
|
||||
mHeaderSubtitle = mLayoutView.findViewById(R.id.header_subtitle);
|
||||
mFooterDivider = mLayoutView.findViewById(R.id.footer_divider);
|
||||
@@ -228,26 +230,13 @@ public class PanelFragment extends Fragment {
|
||||
|
||||
final IconCompat icon = mPanel.getIcon();
|
||||
final CharSequence title = mPanel.getTitle();
|
||||
if (icon == null) {
|
||||
|
||||
if (icon != null || mPanel.getViewType() == PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON) {
|
||||
enablePanelHeader(icon, title);
|
||||
} else {
|
||||
mTitleView.setVisibility(View.VISIBLE);
|
||||
mPanelHeader.setVisibility(View.GONE);
|
||||
mTitleView.setText(title);
|
||||
} else {
|
||||
mTitleView.setVisibility(View.GONE);
|
||||
mPanelHeader.setVisibility(View.VISIBLE);
|
||||
mPanelHeader.setAccessibilityPaneTitle(title);
|
||||
mTitleIcon.setImageIcon(icon.toIcon(getContext()));
|
||||
mHeaderTitle.setText(title);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
if (mPanel.getViewType() == PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON) {
|
||||
@@ -281,6 +270,29 @@ public class PanelFragment extends Fragment {
|
||||
0 /* value */);
|
||||
}
|
||||
|
||||
private void enablePanelHeader(IconCompat icon, CharSequence title) {
|
||||
mTitleView.setVisibility(View.GONE);
|
||||
mPanelHeader.setVisibility(View.VISIBLE);
|
||||
mPanelHeader.setAccessibilityPaneTitle(title);
|
||||
mHeaderTitle.setText(title);
|
||||
mHeaderSubtitle.setText(mPanel.getSubTitle());
|
||||
if (icon != null) {
|
||||
mTitleGroup.setVisibility(View.VISIBLE);
|
||||
mTitleIcon.setImageIcon(icon.toIcon(getContext()));
|
||||
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));
|
||||
}
|
||||
} else {
|
||||
mTitleGroup.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadAllSlices() {
|
||||
mSliceLiveData.clear();
|
||||
final List<Uri> sliceUris = mPanel.getSlices();
|
||||
@@ -477,7 +489,13 @@ public class PanelFragment extends Fragment {
|
||||
@Override
|
||||
public void onHeaderChanged() {
|
||||
ThreadUtils.postOnMainThread(() -> {
|
||||
mTitleIcon.setImageIcon(mPanel.getIcon().toIcon(getContext()));
|
||||
final IconCompat icon = mPanel.getIcon();
|
||||
if (icon != null) {
|
||||
mTitleIcon.setImageIcon(icon.toIcon(getContext()));
|
||||
mTitleGroup.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mTitleGroup.setVisibility(View.GONE);
|
||||
}
|
||||
mHeaderTitle.setText(mPanel.getTitle());
|
||||
mHeaderSubtitle.setText(mPanel.getSubTitle());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user