Add dream descriptions to dream settings UI.
The dream descriptions will now be shown underneath the title, if the dream has provided one. We also cleaned up the icon view, instead merging it with the title view to ensure proper alignment between the icon and title. Bug: 221078654 Test: locally on device Test: atest DreamPickerControllerTest Change-Id: I00fd69c294f1a5fbcbc5392eba342f2896f6d9ed
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.settings.dream;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.VectorDrawable;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -45,8 +46,8 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
* View holder for each {@link IDreamItem}.
|
||||
*/
|
||||
private class DreamViewHolder extends RecyclerView.ViewHolder {
|
||||
private final ImageView mIconView;
|
||||
private final TextView mTitleView;
|
||||
private final TextView mSummaryView;
|
||||
private final ImageView mPreviewView;
|
||||
private final ImageView mPreviewPlaceholderView;
|
||||
private final Button mCustomizeButton;
|
||||
@@ -57,8 +58,8 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
mContext = context;
|
||||
mPreviewView = view.findViewById(R.id.preview);
|
||||
mPreviewPlaceholderView = view.findViewById(R.id.preview_placeholder);
|
||||
mIconView = view.findViewById(R.id.icon);
|
||||
mTitleView = view.findViewById(R.id.title_text);
|
||||
mSummaryView = view.findViewById(R.id.summary_text);
|
||||
mCustomizeButton = view.findViewById(R.id.customize_button);
|
||||
}
|
||||
|
||||
@@ -68,6 +69,14 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
public void bindView(IDreamItem item, int position) {
|
||||
mTitleView.setText(item.getTitle());
|
||||
|
||||
final CharSequence summary = item.getSummary();
|
||||
if (TextUtils.isEmpty(summary)) {
|
||||
mSummaryView.setVisibility(View.GONE);
|
||||
} else {
|
||||
mSummaryView.setText(summary);
|
||||
mSummaryView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
final Drawable previewImage = item.getPreviewImage();
|
||||
if (previewImage != null) {
|
||||
mPreviewView.setImageDrawable(previewImage);
|
||||
@@ -82,7 +91,10 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
icon.setTint(Utils.getColorAttrDefaultColor(mContext,
|
||||
com.android.internal.R.attr.colorAccentPrimaryVariant));
|
||||
}
|
||||
mIconView.setImageDrawable(icon);
|
||||
final int iconSize = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.dream_item_icon_size);
|
||||
icon.setBounds(0, 0, iconSize, iconSize);
|
||||
mTitleView.setCompoundDrawablesRelative(icon, null, null, null);
|
||||
|
||||
if (item.isActive()) {
|
||||
mLastSelectedPos = position;
|
||||
|
Reference in New Issue
Block a user