Add default placeholder when a dream doesn't provide a preview image.
Bug: 213887094 Test: locally on device Change-Id: Ie4b96eadb0889a5216cda1cfe1cf0cc17a2ad652
This commit is contained in:
24
res/drawable/dream_default_preview_icon.xml
Normal file
24
res/drawable/dream_default_preview_icon.xml
Normal file
@@ -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>
|
@@ -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>
|
@@ -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"
|
||||
|
@@ -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>
|
||||
|
@@ -48,6 +48,7 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
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 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
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 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
|
||||
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()
|
||||
|
Reference in New Issue
Block a user