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:
@@ -64,36 +64,38 @@
|
|||||||
app:layout_constraintStart_toStartOf="@+id/preview"
|
app:layout_constraintStart_toStartOf="@+id/preview"
|
||||||
app:layout_constraintEnd_toEndOf="@+id/preview"/>
|
app:layout_constraintEnd_toEndOf="@+id/preview"/>
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/icon"
|
|
||||||
android:layout_width="@dimen/dream_item_icon_size"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_marginTop="@dimen/dream_item_title_margin_top"
|
|
||||||
android:layout_marginStart="@dimen/dream_item_icon_margin_start"
|
|
||||||
android:layout_marginBottom="@dimen/dream_item_title_margin_bottom"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:importantForAccessibility="no"
|
|
||||||
app:layout_constraintDimensionRatio="1:1"
|
|
||||||
app:layout_constraintHorizontal_chainStyle="packed"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/preview"
|
|
||||||
app_layout_constraintEnd_toStartOf="@+id/title_text"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title_text"
|
android:id="@+id/title_text"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/dream_item_title_margin_top"
|
android:layout_marginTop="@dimen/dream_item_title_margin_top"
|
||||||
android:layout_marginStart="@dimen/dream_item_title_margin_start"
|
android:layout_marginHorizontal="@dimen/dream_item_title_margin_horizontal"
|
||||||
android:layout_marginBottom="@dimen/dream_item_title_margin_bottom"
|
android:layout_marginBottom="@dimen/dream_item_title_margin_bottom"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:textSize="16sp"
|
android:textSize="@dimen/dream_item_title_text_size"
|
||||||
android:textColor="@color/dream_card_text_color_state_list"
|
android:textColor="@color/dream_card_text_color_state_list"
|
||||||
|
android:drawablePadding="@dimen/dream_item_icon_padding"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/preview"
|
app:layout_constraintTop_toBottomOf="@+id/preview"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@+id/icon"/>
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/summary_text"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/summary_text"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="@dimen/dream_item_title_margin_horizontal"
|
||||||
|
android:layout_marginBottom="@dimen/dream_item_title_margin_bottom"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:textSize="@dimen/dream_item_summary_text_size"
|
||||||
|
android:textColor="@color/dream_card_text_color_state_list"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/title_text"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
@@ -445,10 +445,12 @@
|
|||||||
<dimen name="dream_item_corner_radius">28dp</dimen>
|
<dimen name="dream_item_corner_radius">28dp</dimen>
|
||||||
<dimen name="dream_item_content_padding">8dp</dimen>
|
<dimen name="dream_item_content_padding">8dp</dimen>
|
||||||
<dimen name="dream_item_icon_size">20dp</dimen>
|
<dimen name="dream_item_icon_size">20dp</dimen>
|
||||||
<dimen name="dream_item_title_margin_top">18dp</dimen>
|
<dimen name="dream_item_summary_text_size">14sp</dimen>
|
||||||
|
<dimen name="dream_item_title_margin_top">16dp</dimen>
|
||||||
<dimen name="dream_item_title_margin_bottom">8dp</dimen>
|
<dimen name="dream_item_title_margin_bottom">8dp</dimen>
|
||||||
<dimen name="dream_item_title_margin_start">18dp</dimen>
|
<dimen name="dream_item_title_text_size">16sp</dimen>
|
||||||
<dimen name="dream_item_icon_margin_start">10dp</dimen>
|
<dimen name="dream_item_icon_padding">18dp</dimen>
|
||||||
|
<dimen name="dream_item_title_margin_horizontal">8dp</dimen>
|
||||||
<dimen name="dream_preference_card_padding">16dp</dimen>
|
<dimen name="dream_preference_card_padding">16dp</dimen>
|
||||||
<dimen name="dream_preference_margin_bottom">20dp</dimen>
|
<dimen name="dream_preference_margin_bottom">20dp</dimen>
|
||||||
<dimen name="dream_picker_margin_horizontal">48dp</dimen>
|
<dimen name="dream_picker_margin_horizontal">48dp</dimen>
|
||||||
|
@@ -19,6 +19,7 @@ package com.android.settings.dream;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.VectorDrawable;
|
import android.graphics.drawable.VectorDrawable;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -45,8 +46,8 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
* View holder for each {@link IDreamItem}.
|
* View holder for each {@link IDreamItem}.
|
||||||
*/
|
*/
|
||||||
private class DreamViewHolder extends RecyclerView.ViewHolder {
|
private class DreamViewHolder extends RecyclerView.ViewHolder {
|
||||||
private final ImageView mIconView;
|
|
||||||
private final TextView mTitleView;
|
private final TextView mTitleView;
|
||||||
|
private final TextView mSummaryView;
|
||||||
private final ImageView mPreviewView;
|
private final ImageView mPreviewView;
|
||||||
private final ImageView mPreviewPlaceholderView;
|
private final ImageView mPreviewPlaceholderView;
|
||||||
private final Button mCustomizeButton;
|
private final Button mCustomizeButton;
|
||||||
@@ -57,8 +58,8 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
mContext = context;
|
mContext = context;
|
||||||
mPreviewView = view.findViewById(R.id.preview);
|
mPreviewView = view.findViewById(R.id.preview);
|
||||||
mPreviewPlaceholderView = view.findViewById(R.id.preview_placeholder);
|
mPreviewPlaceholderView = view.findViewById(R.id.preview_placeholder);
|
||||||
mIconView = view.findViewById(R.id.icon);
|
|
||||||
mTitleView = view.findViewById(R.id.title_text);
|
mTitleView = view.findViewById(R.id.title_text);
|
||||||
|
mSummaryView = view.findViewById(R.id.summary_text);
|
||||||
mCustomizeButton = view.findViewById(R.id.customize_button);
|
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) {
|
public void bindView(IDreamItem item, int position) {
|
||||||
mTitleView.setText(item.getTitle());
|
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();
|
final Drawable previewImage = item.getPreviewImage();
|
||||||
if (previewImage != null) {
|
if (previewImage != null) {
|
||||||
mPreviewView.setImageDrawable(previewImage);
|
mPreviewView.setImageDrawable(previewImage);
|
||||||
@@ -82,7 +91,10 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
icon.setTint(Utils.getColorAttrDefaultColor(mContext,
|
icon.setTint(Utils.getColorAttrDefaultColor(mContext,
|
||||||
com.android.internal.R.attr.colorAccentPrimaryVariant));
|
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()) {
|
if (item.isActive()) {
|
||||||
mLastSelectedPos = position;
|
mLastSelectedPos = position;
|
||||||
|
@@ -111,6 +111,11 @@ public class DreamPickerController extends BasePreferenceController {
|
|||||||
return mDreamInfo.caption;
|
return mDreamInfo.caption;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharSequence getSummary() {
|
||||||
|
return mDreamInfo.description;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Drawable getIcon() {
|
public Drawable getIcon() {
|
||||||
return mDreamInfo.icon;
|
return mDreamInfo.icon;
|
||||||
|
@@ -18,23 +18,52 @@ package com.android.settings.dream;
|
|||||||
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface representing a dream item to be displayed.
|
* Interface representing a dream item to be displayed.
|
||||||
*/
|
*/
|
||||||
public interface IDreamItem {
|
public interface IDreamItem {
|
||||||
|
/**
|
||||||
|
* Gets the title of this dream.
|
||||||
|
*/
|
||||||
CharSequence getTitle();
|
CharSequence getTitle();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the summary of this dream, or null if the dream doesn't provide one.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
CharSequence getSummary();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the icon for the dream.
|
||||||
|
*/
|
||||||
Drawable getIcon();
|
Drawable getIcon();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback which can be implemented to handle clicks on this dream.
|
||||||
|
*/
|
||||||
void onItemClicked();
|
void onItemClicked();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback which can be implemented to handle the customization of this dream.
|
||||||
|
*/
|
||||||
default void onCustomizeClicked() {
|
default void onCustomizeClicked() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the preview image of this dream.
|
||||||
|
*/
|
||||||
Drawable getPreviewImage();
|
Drawable getPreviewImage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not this dream is currently active.
|
||||||
|
*/
|
||||||
boolean isActive();
|
boolean isActive();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether to allow customization of this dream or not.
|
||||||
|
*/
|
||||||
default boolean allowCustomization() {
|
default boolean allowCustomization() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user