Add default placeholder when a dream doesn't provide a preview image.
Bug: 213887094
Test: locally on device
Change-Id: Ie4b96eadb0889a5216cda1cfe1cf0cc17a2ad652
diff --git a/res/drawable/dream_default_preview_icon.xml b/res/drawable/dream_default_preview_icon.xml
new file mode 100644
index 0000000..7d247bb
--- /dev/null
+++ b/res/drawable/dream_default_preview_icon.xml
@@ -0,0 +1,24 @@
+<!--
+ ~ Copyright (C) 2022 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path android:fillColor="?android:attr/textColorSecondary"
+ android:pathData="M3,19Q2.175,19 1.588,18.413Q1,17.825 1,17V7Q1,6.175 1.588,5.588Q2.175,5 3,5H13Q13.825,5 14.413,5.588Q15,6.175 15,7V17Q15,17.825 14.413,18.413Q13.825,19 13,19ZM3,17H13Q13,17 13,17Q13,17 13,17V7Q13,7 13,7Q13,7 13,7H3Q3,7 3,7Q3,7 3,7V17Q3,17 3,17Q3,17 3,17ZM17,19V5H19V19ZM21,19V5H23V19ZM4,15H12L9.4,11.5L7.5,14L6.1,12.15ZM3,7Q3,7 3,7Q3,7 3,7V17Q3,17 3,17Q3,17 3,17Q3,17 3,17Q3,17 3,17V7Q3,7 3,7Q3,7 3,7Z"/>
+</vector>
\ No newline at end of file
diff --git a/res/drawable/dream_preview_rounded_bg.xml b/res/drawable/dream_preview_rounded_bg.xml
index be83be5..4da0c7c1 100644
--- a/res/drawable/dream_preview_rounded_bg.xml
+++ b/res/drawable/dream_preview_rounded_bg.xml
@@ -15,6 +15,8 @@
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:shape="rectangle">
+ <solid android:color="?androidprv:attr/colorSurfaceHighlight" />
<corners android:radius="@dimen/dream_item_corner_radius"/>
</shape>
\ No newline at end of file
diff --git a/res/layout/dream_preference_layout.xml b/res/layout/dream_preference_layout.xml
index b1aed73..9528f4d 100644
--- a/res/layout/dream_preference_layout.xml
+++ b/res/layout/dream_preference_layout.xml
@@ -39,6 +39,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
+ <ImageView
+ android:id="@+id/preview_placeholder"
+ android:layout_width="@dimen/dream_preview_placeholder_width"
+ android:layout_height="0dp"
+ android:src="@drawable/dream_default_preview_icon"
+ app:layout_constraintDimensionRatio="1:1"
+ app:layout_constraintTop_toTopOf="@+id/preview"
+ app:layout_constraintBottom_toBottomOf="@+id/preview"
+ app:layout_constraintStart_toStartOf="@+id/preview"
+ app:layout_constraintEnd_toEndOf="@+id/preview"/>
+
<Button
android:id="@+id/customize_button"
style="@style/ActionPrimaryButton"
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 20d6e6a..78dbcce 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -452,6 +452,7 @@
<dimen name="dream_preference_card_padding">16dp</dimen>
<dimen name="dream_preference_margin_bottom">20dp</dimen>
<dimen name="dream_picker_margin_horizontal">48dp</dimen>
+ <dimen name="dream_preview_placeholder_width">52dp</dimen>
<!-- Sims/Data mobile/Calls/SMS select dialog-->
<dimen name="sims_select_margin_bottom">24dp</dimen>
diff --git a/src/com/android/settings/dream/DreamAdapter.java b/src/com/android/settings/dream/DreamAdapter.java
index 246336d..4e16ccb 100644
--- a/src/com/android/settings/dream/DreamAdapter.java
+++ b/src/com/android/settings/dream/DreamAdapter.java
@@ -48,6 +48,7 @@
private final ImageView mIconView;
private final TextView mTitleView;
private final ImageView mPreviewView;
+ private final ImageView mPreviewPlaceholderView;
private final Button mCustomizeButton;
private final Context mContext;
@@ -55,6 +56,7 @@
super(view);
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);
mCustomizeButton = view.findViewById(R.id.customize_button);
@@ -68,11 +70,9 @@
final Drawable previewImage = item.getPreviewImage();
if (previewImage != null) {
- mPreviewView.setVisibility(View.VISIBLE);
mPreviewView.setImageDrawable(previewImage);
mPreviewView.setClipToOutline(true);
- } else {
- mPreviewView.setVisibility(View.GONE);
+ mPreviewPlaceholderView.setVisibility(View.GONE);
}
final Drawable icon = item.isActive()