Merging from ub-launcher3-master @ build 6538369 am: 741fbf67bc
Change-Id: I7b9e593329dac26ad51af448e96d6f8ed9d04761
diff --git a/res/layout-land/fragment_custom_theme_name.xml b/res/layout-land/fragment_custom_theme_name.xml
index 3c85f35..53cf513 100644
--- a/res/layout-land/fragment_custom_theme_name.xml
+++ b/res/layout-land/fragment_custom_theme_name.xml
@@ -31,15 +31,11 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
- android:background="@color/secondary_color">
- <include
- android:id="@+id/component_preview_content"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_marginHorizontal="@dimen/preview_page_horizontal_margin"
- android:layout_marginTop="@dimen/preview_page_top_margin"
- android:layout_marginBottom="@dimen/component_preview_page_bottom_margin"
- layout="@layout/theme_preview_card"/>
+ android:paddingTop="@dimen/preview_content_padding_top"
+ android:paddingBottom="@dimen/preview_content_padding_bottom"
+ android:clipToPadding="false"
+ android:background="@color/fullscreen_preview_background">
+ <include layout="@layout/theme_preview_card"/>
</FrameLayout>
<LinearLayout
android:id="@+id/options_section"
diff --git a/res/layout-land/fragment_theme_picker.xml b/res/layout-land/fragment_theme_picker.xml
index 915fb47..fe660cf 100644
--- a/res/layout-land/fragment_theme_picker.xml
+++ b/res/layout-land/fragment_theme_picker.xml
@@ -38,12 +38,12 @@
<FrameLayout
android:id="@+id/preview_card_container"
android:layout_width="match_parent"
- android:layout_height="@dimen/preview_content_height"
+ android:layout_height="wrap_content"
android:paddingTop="@dimen/preview_content_padding_top"
android:paddingBottom="@dimen/preview_content_padding_bottom"
android:clipToPadding="false"
android:background="@color/fullscreen_preview_background">
- <include layout="@layout/theme_preview_card_v2"/>
+ <include layout="@layout/theme_preview_card"/>
</FrameLayout>
</FrameLayout>
diff --git a/res/layout/fragment_custom_theme_name.xml b/res/layout/fragment_custom_theme_name.xml
index 0a18aab..27a8f19 100644
--- a/res/layout/fragment_custom_theme_name.xml
+++ b/res/layout/fragment_custom_theme_name.xml
@@ -31,7 +31,10 @@
android:id="@+id/component_preview_container"
android:layout_width="match_parent"
android:layout_height="0dp"
- android:background="@color/secondary_color"
+ android:paddingTop="@dimen/preview_content_padding_top"
+ android:paddingBottom="@dimen/preview_content_padding_bottom"
+ android:clipToPadding="false"
+ android:background="@color/fullscreen_preview_background"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toTopOf="@+id/guideline"
app:layout_constraintEnd_toEndOf="parent"
@@ -40,15 +43,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0">
-
- <include
- android:id="@+id/component_preview_content"
- layout="@layout/theme_preview_card"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_marginHorizontal="@dimen/preview_page_horizontal_margin"
- android:layout_marginTop="@dimen/preview_page_top_margin"
- android:layout_marginBottom="@dimen/indicator_container_height"/>
+ <include layout="@layout/theme_preview_card"/>
</FrameLayout>
<androidx.constraintlayout.widget.Guideline
diff --git a/res/layout/fragment_grid_picker.xml b/res/layout/fragment_grid_picker.xml
index af70e0c..7f35689 100644
--- a/res/layout/fragment_grid_picker.xml
+++ b/res/layout/fragment_grid_picker.xml
@@ -16,6 +16,7 @@
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@@ -26,19 +27,27 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
- <LinearLayout
+ <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/content_section"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+ android:layout_height="match_parent">
<FrameLayout
+ android:id="@+id/preview_card_container"
android:layout_width="match_parent"
- android:layout_height="@dimen/preview_content_height"
+ android:layout_height="0dp"
android:paddingTop="@dimen/preview_content_padding_top"
android:paddingBottom="@dimen/preview_content_padding_bottom"
+ android:background="@color/fullscreen_preview_background"
android:clipToPadding="false"
- android:background="@color/fullscreen_preview_background">
+ app:layout_constrainedHeight="true"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toTopOf="@id/options_title"
+ app:layout_constraintHeight_max="@dimen/preview_pager_max_height"
+ app:layout_constraintVertical_bias="0.0"
+ app:layout_constraintHeight_percent="@dimen/preview_pager_maximum_height_ratio">
<include layout="@layout/grid_preview_card"/>
</FrameLayout>
@@ -51,14 +60,22 @@
android:lineHeight="24dp"
android:singleLine="true"
android:text="@string/grid_options_title"
- android:textAppearance="@style/TitleTextAppearance"/>
+ android:textAppearance="@style/TitleTextAppearance"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/preview_card_container"
+ app:layout_constraintBottom_toTopOf="@id/options_container" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/options_container"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal"/>
- </LinearLayout>
+ android:layout_height="0dp"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/options_title"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintVertical_bias="1.0" />
+ </androidx.constraintlayout.widget.ConstraintLayout>
<androidx.core.widget.ContentLoadingProgressBar
android:id="@+id/loading_indicator"
diff --git a/res/layout/fragment_theme_full_preview.xml b/res/layout/fragment_theme_full_preview.xml
index 7573c5b..008a795 100644
--- a/res/layout/fragment_theme_full_preview.xml
+++ b/res/layout/fragment_theme_full_preview.xml
@@ -31,6 +31,6 @@
android:clipToPadding="false"
android:background="@color/fullscreen_preview_background">
- <include layout="@layout/theme_preview_card_v2"/>
+ <include layout="@layout/theme_preview_card"/>
</FrameLayout>
</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/fragment_theme_picker.xml b/res/layout/fragment_theme_picker.xml
index 704114f..a773207 100644
--- a/res/layout/fragment_theme_picker.xml
+++ b/res/layout/fragment_theme_picker.xml
@@ -14,8 +14,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@@ -26,21 +26,27 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
- <LinearLayout
+ <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/content_section"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
+ android:layout_height="match_parent">
<FrameLayout
android:id="@+id/preview_card_container"
android:layout_width="match_parent"
- android:layout_height="@dimen/preview_content_height"
+ android:layout_height="0dp"
android:paddingTop="@dimen/preview_content_padding_top"
android:paddingBottom="@dimen/preview_content_padding_bottom"
+ android:background="@color/fullscreen_preview_background"
android:clipToPadding="false"
- android:background="@color/fullscreen_preview_background">
- <include layout="@layout/theme_preview_card_v2"/>
+ app:layout_constrainedHeight="true"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toTopOf="@id/options_container"
+ app:layout_constraintHeight_max="@dimen/preview_pager_max_height"
+ app:layout_constraintVertical_bias="0.0"
+ app:layout_constraintHeight_percent="@dimen/preview_pager_maximum_height_ratio">
+ <include layout="@layout/theme_preview_card"/>
</FrameLayout>
<androidx.recyclerview.widget.RecyclerView
@@ -49,8 +55,12 @@
android:layout_height="0dp"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginTop="10dp"
- android:layout_weight="1"/>
- </LinearLayout>
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/preview_card_container"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintVertical_bias="1.0"/>
+ </androidx.constraintlayout.widget.ConstraintLayout>
<androidx.core.widget.ContentLoadingProgressBar
android:id="@+id/loading_indicator"
diff --git a/res/layout/preview_card_cover_content.xml b/res/layout/preview_card_cover_content.xml
deleted file mode 100644
index 3ab13a4..0000000
--- a/res/layout/preview_card_cover_content.xml
+++ /dev/null
@@ -1,117 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2019 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.
--->
-<RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:layout_marginHorizontal="@dimen/preview_theme_cover_content_extra_margin"
- android:gravity="center_horizontal"
- android:clipChildren="false"
- tools:showIn="@layout/theme_preview_card">
- <FrameLayout
- android:layout_width="@dimen/preview_theme_icon_size"
- android:layout_height="@dimen/preview_theme_icon_size"
- android:layout_marginLeft="6dp"
- android:layout_alignParentLeft="true"
- android:layout_alignParentTop="true">
- <ImageView
- android:layout_width="@dimen/preview_theme_icon_size"
- android:layout_height="@dimen/preview_theme_icon_size"
- android:id="@+id/preview_color_qs_0_bg"/>
- <ImageView
- android:layout_width="@dimen/preview_theme_tile_size"
- android:layout_height="@dimen/preview_theme_tile_size"
- android:id="@+id/preview_color_qs_0_icon"
- android:tint="@color/tile_enabled_icon_color"
- android:layout_gravity="center"/>
- </FrameLayout>
- <FrameLayout
- android:layout_width="@dimen/preview_theme_icon_size"
- android:layout_height="@dimen/preview_theme_icon_size"
- android:layout_alignParentTop="true"
- android:layout_centerHorizontal="true"
- android:layout_gravity="center_horizontal">
- <ImageView
- android:layout_width="@dimen/preview_theme_icon_size"
- android:layout_height="@dimen/preview_theme_icon_size"
- android:layout_gravity="center"
- android:id="@+id/preview_color_qs_1_bg"/>
- <ImageView
- android:layout_width="@dimen/preview_theme_tile_size"
- android:layout_height="@dimen/preview_theme_tile_size"
- android:id="@+id/preview_color_qs_1_icon"
- android:tint="@color/tile_enabled_icon_color"
- android:layout_gravity="center"/>
- </FrameLayout>
- <FrameLayout
- android:layout_width="@dimen/preview_theme_icon_size"
- android:layout_height="@dimen/preview_theme_icon_size"
- android:layout_marginRight="6dp"
- android:layout_alignParentRight="true"
- android:layout_alignParentTop="true">
- <ImageView
- android:layout_width="@dimen/preview_theme_icon_size"
- android:layout_height="@dimen/preview_theme_icon_size"
- android:id="@+id/preview_color_qs_2_bg"/>
- <ImageView
- android:layout_width="@dimen/preview_theme_tile_size"
- android:layout_height="@dimen/preview_theme_tile_size"
- android:id="@+id/preview_color_qs_2_icon"
- android:tint="@color/tile_enabled_icon_color"
- android:layout_gravity="center"/>
- </FrameLayout>
-
- <ImageView
- android:id="@+id/shape_preview_icon_0"
- android:layout_width="@dimen/preview_theme_shape_size"
- android:layout_height="@dimen/preview_theme_shape_size"
- android:layout_marginVertical="4dp"
- android:layout_alignParentLeft="true"
- android:layout_centerVertical="true"
- android:elevation="4dp"/>
- <FrameLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerVertical="true"
- android:layout_centerHorizontal="true">
- <ImageView
- android:id="@+id/shape_preview_icon_1"
- android:layout_width="@dimen/preview_theme_shape_size"
- android:layout_height="@dimen/preview_theme_shape_size"
- android:layout_gravity="center_horizontal"
- android:layout_marginVertical="4dp"
- android:elevation="4dp"/>
- </FrameLayout>
- <ImageView
- android:id="@+id/shape_preview_icon_2"
- android:layout_width="@dimen/preview_theme_shape_size"
- android:layout_height="@dimen/preview_theme_shape_size"
- android:layout_marginVertical="4dp"
- android:layout_marginRight="2dp"
- android:layout_alignParentRight="true"
- android:layout_centerVertical="true"
- android:elevation="4dp"/>
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true">
- <include layout="@layout/theme_cover_qsb"/>
- </FrameLayout>
-</RelativeLayout>
\ No newline at end of file
diff --git a/res/layout/theme_preview_app_icon_shape.xml b/res/layout/theme_preview_app_icon_shape.xml
index c6f4cd9..fe95f90 100644
--- a/res/layout/theme_preview_app_icon_shape.xml
+++ b/res/layout/theme_preview_app_icon_shape.xml
@@ -14,27 +14,38 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.constraintlayout.widget.ConstraintLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingHorizontal="@dimen/preview_theme_app_icon_shape_padding_horizontal"
+ android:layout_height="match_parent"
android:orientation="vertical">
- <LinearLayout
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:id="@+id/app_row_0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingTop="@dimen/preview_theme_app_icon_shape_padding_top"
- android:orientation="horizontal">
+ android:orientation="horizontal"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toTopOf="@id/app_row_1">
<LinearLayout
- android:layout_width="wrap_content"
+ android:id="@+id/app_item_0"
+ android:layout_width="@dimen/preview_theme_app_icon_size"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
- android:orientation="vertical">
+ android:orientation="vertical"
+ android:clipChildren="false"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toStartOf="@id/app_item_1"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent">
<ImageView
android:id="@+id/shape_preview_icon_0"
- android:layout_width="@dimen/preview_theme_shape_size"
- android:layout_height="@dimen/preview_theme_shape_size"
+ android:layout_width="@dimen/preview_theme_app_icon_size"
+ android:layout_height="@dimen/preview_theme_app_icon_size"
android:elevation="4dp"/>
<TextView
android:id="@+id/shape_preview_icon_app_name_0"
@@ -42,23 +53,25 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/preview_theme_app_icon_shape_text_margin_top"
android:textSize="@dimen/preview_theme_app_icon_shape_text_size"
- android:lineHeight="20dp"/>
+ android:lineHeight="20dp"
+ android:singleLine="true"/>
</LinearLayout>
- <Space
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"/>
-
<LinearLayout
- android:layout_width="wrap_content"
+ android:id="@+id/app_item_1"
+ android:layout_width="@dimen/preview_theme_app_icon_size"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
- android:orientation="vertical">
+ android:orientation="vertical"
+ android:clipChildren="false"
+ app:layout_constraintStart_toEndOf="@id/app_item_0"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent">
<ImageView
android:id="@+id/shape_preview_icon_1"
- android:layout_width="@dimen/preview_theme_shape_size"
- android:layout_height="@dimen/preview_theme_shape_size"
+ android:layout_width="@dimen/preview_theme_app_icon_size"
+ android:layout_height="@dimen/preview_theme_app_icon_size"
android:elevation="4dp"/>
<TextView
android:id="@+id/shape_preview_icon_app_name_1"
@@ -66,25 +79,36 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/preview_theme_app_icon_shape_text_margin_top"
android:textSize="@dimen/preview_theme_app_icon_shape_text_size"
- android:lineHeight="20dp"/>
+ android:lineHeight="20dp"
+ android:singleLine="true"/>
</LinearLayout>
- </LinearLayout>
+ </androidx.constraintlayout.widget.ConstraintLayout>
- <LinearLayout
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:id="@+id/app_row_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingTop="@dimen/preview_theme_app_icon_shape_padding_top"
- android:orientation="horizontal">
+ android:orientation="horizontal"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/app_row_0"
+ app:layout_constraintBottom_toBottomOf="parent">
<LinearLayout
- android:layout_width="wrap_content"
+ android:id="@+id/app_item_2"
+ android:layout_width="@dimen/preview_theme_app_icon_size"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
- android:orientation="vertical">
+ android:orientation="vertical"
+ android:clipChildren="false"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toStartOf="@id/app_item_3"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent">
<ImageView
android:id="@+id/shape_preview_icon_2"
- android:layout_width="@dimen/preview_theme_shape_size"
- android:layout_height="@dimen/preview_theme_shape_size"
+ android:layout_width="@dimen/preview_theme_app_icon_size"
+ android:layout_height="@dimen/preview_theme_app_icon_size"
android:elevation="4dp"/>
<TextView
android:id="@+id/shape_preview_icon_app_name_2"
@@ -92,23 +116,25 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/preview_theme_app_icon_shape_text_margin_top"
android:textSize="@dimen/preview_theme_app_icon_shape_text_size"
- android:lineHeight="20dp"/>
+ android:lineHeight="20dp"
+ android:singleLine="true"/>
</LinearLayout>
- <Space
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"/>
-
<LinearLayout
- android:layout_width="wrap_content"
+ android:id="@+id/app_item_3"
+ android:layout_width="@dimen/preview_theme_app_icon_size"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
- android:orientation="vertical">
+ android:orientation="vertical"
+ android:clipChildren="false"
+ app:layout_constraintStart_toEndOf="@id/app_item_2"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent">
<ImageView
android:id="@+id/shape_preview_icon_3"
- android:layout_width="@dimen/preview_theme_shape_size"
- android:layout_height="@dimen/preview_theme_shape_size"
+ android:layout_width="@dimen/preview_theme_app_icon_size"
+ android:layout_height="@dimen/preview_theme_app_icon_size"
android:elevation="4dp"/>
<TextView
android:id="@+id/shape_preview_icon_app_name_3"
@@ -116,7 +142,8 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/preview_theme_app_icon_shape_text_margin_top"
android:textSize="@dimen/preview_theme_app_icon_shape_text_size"
- android:lineHeight="20dp"/>
+ android:lineHeight="20dp"
+ android:singleLine="true"/>
</LinearLayout>
- </LinearLayout>
-</LinearLayout>
+ </androidx.constraintlayout.widget.ConstraintLayout>
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/res/layout/theme_preview_card.xml b/res/layout/theme_preview_card.xml
index f80e846..74d1e68 100644
--- a/res/layout/theme_preview_card.xml
+++ b/res/layout/theme_preview_card.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2019 The Android Open Source Project
+ Copyright (C) 2020 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.
@@ -16,12 +16,24 @@
-->
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- style="@style/PreviewCard"
+ style="@style/FullContentPreviewCard"
android:layout_width="match_parent"
android:layout_height="match_parent"
- app:contentPadding="0dp">
+ android:layout_gravity="center">
- <include layout="@layout/theme_component_preview"/>
+ <ImageView
+ android:id="@+id/wallpaper_preview_image"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/primary_color" />
+
+ <SurfaceView
+ android:id="@+id/wallpaper_preview_surface"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ <FrameLayout
+ android:id="@+id/theme_preview_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
</androidx.cardview.widget.CardView>
\ No newline at end of file
diff --git a/res/layout/theme_preview_card_v2.xml b/res/layout/theme_preview_card_v2.xml
deleted file mode 100644
index 74d1e68..0000000
--- a/res/layout/theme_preview_card_v2.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2020 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.
--->
-<androidx.cardview.widget.CardView
- xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/FullContentPreviewCard"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center">
-
- <ImageView
- android:id="@+id/wallpaper_preview_image"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@color/primary_color" />
-
- <SurfaceView
- android:id="@+id/wallpaper_preview_surface"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
- <FrameLayout
- android:id="@+id/theme_preview_container"
- android:layout_width="match_parent"
- android:layout_height="match_parent"/>
-</androidx.cardview.widget.CardView>
\ No newline at end of file
diff --git a/res/layout/theme_preview_color_icons.xml b/res/layout/theme_preview_color_icons.xml
index 7a068ee..ccfb300 100644
--- a/res/layout/theme_preview_color_icons.xml
+++ b/res/layout/theme_preview_color_icons.xml
@@ -16,15 +16,18 @@
-->
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/color_icons_section"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="match_parent"
android:background="@color/primary_color">
- <LinearLayout
+ <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="match_parent"
android:paddingHorizontal="@dimen/preview_theme_color_icons_padding_horizontal"
+ android:paddingTop="@dimen/preview_theme_color_icons_padding_top"
+ android:paddingBottom="@dimen/preview_theme_color_icons_padding_bottom"
android:orientation="vertical">
<!-- Title -->
@@ -32,18 +35,27 @@
android:id="@+id/color_icons_section_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/preview_theme_color_icons_title_margin_top"
- android:layout_marginBottom="@dimen/preview_theme_color_icons_title_margin_bottom"
android:text="@string/theme_preview_icons_section_title"
android:textSize="@dimen/preview_theme_color_icons_title_text_size"
android:lineHeight="16dp"
- android:gravity="center"/>
+ android:gravity="center"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toTopOf="@id/qs_icons"
+ app:layout_constraintVertical_bias="0.0"
+ app:layout_constraintVertical_chainStyle="spread_inside" />
<!-- QS icons -->
<LinearLayout
+ android:id="@+id/qs_icons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="horizontal">
+ android:orientation="horizontal"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/color_icons_section_title"
+ app:layout_constraintBottom_toTopOf="@id/button_icons">
<FrameLayout
android:layout_width="@dimen/preview_theme_color_icons_icon_size"
android:layout_height="@dimen/preview_theme_color_icons_icon_size">
@@ -117,11 +129,14 @@
<!-- Icons of CheckBox/RadioButton/Switch. -->
<LinearLayout
+ android:id="@+id/button_icons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/preview_theme_color_icons_buttons_margin_top"
- android:layout_marginBottom="@dimen/preview_theme_color_icons_buttons_margin_bottom"
- android:orientation="horizontal">
+ android:orientation="horizontal"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/qs_icons"
+ app:layout_constraintBottom_toBottomOf="parent">
<FrameLayout
android:layout_width="@dimen/preview_theme_icon_size"
android:layout_height="@dimen/preview_theme_icon_size">
@@ -165,5 +180,5 @@
</FrameLayout>
</LinearLayout>
- </LinearLayout>
+ </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
diff --git a/res/layout/theme_preview_content.xml b/res/layout/theme_preview_content.xml
new file mode 100644
index 0000000..4b29617
--- /dev/null
+++ b/res/layout/theme_preview_content.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2020 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.
+-->
+<androidx.constraintlayout.widget.ConstraintLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingTop="@dimen/preview_theme_content_padding_top"
+ android:paddingBottom="@dimen/preview_theme_content_padding_bottom"
+ android:clipToPadding="false"
+ android:clipChildren="false">
+
+ <FrameLayout
+ android:id="@+id/topbar_container"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginHorizontal="@dimen/preview_theme_topbar_container_margin_horizontal"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toTopOf="@id/smart_space_date"
+ app:layout_constraintVertical_bias="0.0"
+ app:layout_constraintVertical_chainStyle="spread_inside">
+ <include layout="@layout/theme_preview_topbar" />
+ </FrameLayout>
+
+ <TextView
+ android:id="@+id/smart_space_date"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:textSize="@dimen/preview_theme_smart_space_date_size"
+ android:singleLine="true"
+ android:gravity="center|bottom"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/topbar_container"
+ app:layout_constraintBottom_toTopOf="@id/app_icon_shape_container"
+ app:layout_constraintHeight_percent="0.1" />
+
+ <FrameLayout
+ android:id="@+id/app_icon_shape_container"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/smart_space_date"
+ app:layout_constraintBottom_toTopOf="@id/color_icons_container"
+ app:layout_constraintHeight_percent="0.49">
+ <include layout="@layout/theme_preview_app_icon_shape" />
+ </FrameLayout>
+
+ <FrameLayout
+ android:id="@+id/color_icons_container"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_marginHorizontal="@dimen/preview_theme_color_icons_container_margin_horizontal"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/app_icon_shape_container"
+ app:layout_constraintBottom_toTopOf="@id/theme_qsb_container"
+ app:layout_constraintHeight_percent="0.275">
+ <include layout="@layout/theme_preview_color_icons" />
+ </FrameLayout>
+
+ <FrameLayout
+ android:id="@+id/theme_qsb_container"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_marginHorizontal="@dimen/preview_theme_qsb_container_margin_horizontal"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/color_icons_container"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintHeight_percent="0.1">
+ <include layout="@layout/theme_cover_qsb" />
+ </FrameLayout>
+
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/res/layout/theme_preview_content_v2.xml b/res/layout/theme_preview_content_v2.xml
deleted file mode 100644
index ea5db19..0000000
--- a/res/layout/theme_preview_content_v2.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2020 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.
--->
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingTop="@dimen/preview_theme_content_padding_top"
- android:paddingHorizontal="@dimen/preview_theme_content_padding"
- android:paddingBottom="@dimen/preview_theme_content_padding"
- android:orientation="vertical">
-
- <include layout="@layout/theme_preview_topbar" />
-
- <TextView
- android:id="@+id/smart_space_date"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="@dimen/preview_theme_smart_space_date_size"
- android:lineHeight="24dp"
- android:gravity="center"
- android:layout_marginTop="@dimen/preview_theme_smart_space_margin_top"/>
-
- <include layout="@layout/theme_preview_app_icon_shape" />
-
- <include layout="@layout/theme_preview_color_icons"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/preview_theme_color_icons_margin_top"/>
-
- <Space
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"/>
-
- <include layout="@layout/theme_cover_qsb" />
-</LinearLayout>
\ No newline at end of file
diff --git a/res/values-h740dp/dimens.xml b/res/values-h740dp/dimens.xml
index a752b6b..250262f 100644
--- a/res/values-h740dp/dimens.xml
+++ b/res/values-h740dp/dimens.xml
@@ -21,7 +21,6 @@
<dimen name="preview_theme_icon_size">40dp</dimen>
<dimen name="preview_theme_tile_size">20dp</dimen>
<dimen name="preview_theme_shape_size">52dp</dimen>
- <dimen name="preview_theme_cover_content_extra_margin">8dp</dimen>
<dimen name="preview_theme_content_min_height">152dp</dimen>
diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml
index bd37bae..134bfa7 100644
--- a/res/values-land/dimens.xml
+++ b/res/values-land/dimens.xml
@@ -29,9 +29,7 @@
<dimen name="preview_theme_icon_size">26dp</dimen>
<dimen name="preview_theme_tile_size">14dp</dimen>
<dimen name="preview_theme_shape_size">30dp</dimen>
- <dimen name="preview_theme_cover_content_extra_margin">0dp</dimen>
<dimen name="preview_theme_content_bottom">8dp</dimen>
- <dimen name="preview_theme_cover_content_bottom">36dp</dimen>
<dimen name="font_preview_divider_gap">12dp</dimen>
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index c6b2a3f..feaf26f 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -24,6 +24,8 @@
<color name="switch_track_tint">#171717</color>
<color name="switch_thumb_tint">#bdbdbd</color>
+ <color name="theme_preview_workspace_shadow_color">@android:color/transparent</color>
+
<color name="tile_enabled_icon_color">#2d2d2d</color>
<color name="tile_disabled_icon_color">@color/light_grey</color>
<color name="tile_disabled_background_color">#353535</color>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 437e4ea..d4ad0e1 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -31,6 +31,7 @@
<color name="clockface_preview_background">@android:color/black</color>
<color name="theme_preview_icon_color">@color/google_grey700</color>
+ <color name="theme_preview_workspace_shadow_color">#B0000000</color>
<color name="text_color_dark">#2d2d2d</color>
<color name="text_color_light">@color/material_white_text</color>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index ec21329..461b39e 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -68,31 +68,28 @@
<dimen name="preview_theme_shape_size">36dp</dimen>
<dimen name="preview_theme_cover_topbar_clock_size">12sp</dimen>
<dimen name="preview_theme_cover_topbar_icon_size">16dp</dimen>
- <dimen name="preview_theme_cover_content_extra_margin">16dp</dimen>
<dimen name="preview_theme_content_bottom">@dimen/min_taptarget_height</dimen>
- <dimen name="preview_theme_cover_content_bottom">@dimen/preview_theme_content_bottom</dimen>
<!-- For the new preview of theme picker. -->
- <dimen name="preview_theme_content_padding_top">12dp</dimen>
- <dimen name="preview_theme_content_padding">@dimen/preview_card_padding</dimen>
- <dimen name="preview_theme_smart_space_margin_top">48dp</dimen>
+ <dimen name="preview_theme_content_padding_top">16dp</dimen>
+ <dimen name="preview_theme_content_padding_bottom">24dp</dimen>
+ <dimen name="preview_theme_topbar_container_margin_horizontal">16dp</dimen>
+ <dimen name="preview_theme_color_icons_container_margin_horizontal">10dp</dimen>
+ <dimen name="preview_theme_qsb_container_margin_horizontal">14dp</dimen>
<dimen name="preview_theme_smart_space_date_size">16sp</dimen>
- <dimen name="preview_theme_app_icon_shape_padding_horizontal">36dp</dimen>
- <dimen name="preview_theme_app_icon_shape_padding_top">28dp</dimen>
+ <dimen name="preview_theme_app_icon_size">64dp</dimen>
<dimen name="preview_theme_app_icon_shape_text_margin_top">8dp</dimen>
- <dimen name="preview_theme_app_icon_shape_text_size">16sp</dimen>
- <dimen name="preview_theme_color_icons_margin_top">40dp</dimen>
+ <dimen name="preview_theme_app_icon_shape_text_size">14sp</dimen>
+ <dimen name="preview_theme_color_icons_padding_top">12dp</dimen>
+ <dimen name="preview_theme_color_icons_padding_bottom">20dp</dimen>
<dimen name="preview_theme_color_icons_padding_horizontal">18dp</dimen>
<dimen name="preview_theme_color_icons_title_text_size">12sp</dimen>
- <dimen name="preview_theme_color_icons_title_margin_top">12dp</dimen>
- <dimen name="preview_theme_color_icons_title_margin_bottom">20dp</dimen>
<dimen name="preview_theme_color_icons_icon_size">@dimen/preview_theme_icon_size</dimen>
<dimen name="preview_theme_color_icons_tile_size">@dimen/preview_theme_tile_size</dimen>
- <dimen name="preview_theme_color_icons_buttons_margin_top">32dp</dimen>
- <dimen name="preview_theme_color_icons_buttons_margin_bottom">28dp</dimen>
+ <dimen name="preview_theme_smartspace_key_ambient_shadow_blur">1.5dp</dimen>
+ <dimen name="preview_theme_app_name_key_ambient_shadow_blur">2.5dp</dimen>
<!-- For the customization previews on the picker. -->
- <dimen name="preview_content_height">@dimen/preview_pager_height</dimen>
<dimen name="preview_content_padding_top">@dimen/preview_page_top_margin</dimen>
<dimen name="preview_content_padding_bottom">@dimen/indicator_container_height</dimen>
diff --git a/src/com/android/customization/model/theme/DefaultThemeProvider.java b/src/com/android/customization/model/theme/DefaultThemeProvider.java
index 60eb66d..dc93770 100644
--- a/src/com/android/customization/model/theme/DefaultThemeProvider.java
+++ b/src/com/android/customization/model/theme/DefaultThemeProvider.java
@@ -31,6 +31,7 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources.NotFoundException;
+import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.Log;
@@ -39,6 +40,7 @@
import com.android.customization.model.CustomizationManager.OptionsFetchedListener;
import com.android.customization.model.ResourcesApkProvider;
import com.android.customization.model.theme.ThemeBundle.Builder;
+import com.android.customization.model.theme.ThemeBundle.PreviewInfo.ShapeAppIcon;
import com.android.customization.model.theme.custom.CustomTheme;
import com.android.customization.module.CustomizationPreferences;
import com.android.wallpaper.R;
@@ -209,20 +211,26 @@
Log.d(TAG, "Didn't find shape overlay for default theme, will use system default");
mOverlayProvider.addSystemDefaultShape(builder);
}
+
+ List<ShapeAppIcon> icons = new ArrayList<>();
for (String packageName : mOverlayProvider.getShapePreviewIconPackages()) {
+ Drawable icon = null;
+ CharSequence name = null;
try {
- builder.addShapePreviewIcon(
- mContext.getPackageManager().getApplicationIcon(packageName));
- // Add the shape icon app name.
+ icon = mContext.getPackageManager().getApplicationIcon(packageName);
ApplicationInfo appInfo = mContext.getPackageManager()
.getApplicationInfo(packageName, /* flag= */ 0);
- builder.addShapePreviewIconName(
- String.valueOf(mContext.getPackageManager().getApplicationLabel(appInfo)));
+ name = mContext.getPackageManager().getApplicationLabel(appInfo);
} catch (NameNotFoundException e) {
Log.d(TAG, "Couldn't find app " + packageName + ", won't use it for icon shape"
+ "preview");
+ } finally {
+ if (icon != null && !TextUtils.isEmpty(name)) {
+ icons.add(new ShapeAppIcon(icon, name));
+ }
}
}
+ builder.setShapePreviewIcons(icons);
try {
String iconAndroidOverlayPackage = getOverlayPackage(ICON_ANDROID_PREFIX,
diff --git a/src/com/android/customization/model/theme/OverlayThemeExtractor.java b/src/com/android/customization/model/theme/OverlayThemeExtractor.java
index f1698f6..816176e 100644
--- a/src/com/android/customization/model/theme/OverlayThemeExtractor.java
+++ b/src/com/android/customization/model/theme/OverlayThemeExtractor.java
@@ -23,9 +23,12 @@
import com.android.customization.model.ResourceConstants;
import com.android.customization.model.theme.ThemeBundle.Builder;
+import com.android.customization.model.theme.ThemeBundle.PreviewInfo.ShapeAppIcon;
import com.android.wallpaper.R;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
@@ -98,21 +101,26 @@
}
private void addShapePreviewIcons(Builder builder) {
+ List<ShapeAppIcon> icons = new ArrayList<>();
for (String packageName : mShapePreviewIconPackages) {
+ Drawable icon = null;
+ CharSequence name = null;
try {
- builder.addShapePreviewIcon(
- mContext.getPackageManager().getApplicationIcon(
- packageName));
+ icon = mContext.getPackageManager().getApplicationIcon(packageName);
// Add the shape icon app name.
ApplicationInfo appInfo = mContext.getPackageManager()
.getApplicationInfo(packageName, /* flag= */ 0);
- builder.addShapePreviewIconName(
- String.valueOf(mContext.getPackageManager().getApplicationLabel(appInfo)));
+ name = mContext.getPackageManager().getApplicationLabel(appInfo);
} catch (NameNotFoundException e) {
Log.d(TAG, "Couldn't find app " + packageName
+ ", won't use it for icon shape preview");
+ } finally {
+ if (icon != null && !TextUtils.isEmpty(name)) {
+ icons.add(new ShapeAppIcon(icon, name));
+ }
}
}
+ builder.setShapePreviewIcons(icons);
}
void addNoPreviewIconOverlay(Builder builder, String overlayPackage) {
diff --git a/src/com/android/customization/model/theme/ThemeBundle.java b/src/com/android/customization/model/theme/ThemeBundle.java
index 9928c76..8cb2865 100644
--- a/src/com/android/customization/model/theme/ThemeBundle.java
+++ b/src/com/android/customization/model/theme/ThemeBundle.java
@@ -44,6 +44,7 @@
import com.android.customization.model.CustomizationManager;
import com.android.customization.model.CustomizationOption;
+import com.android.customization.model.theme.ThemeBundle.PreviewInfo.ShapeAppIcon;
import com.android.customization.widget.DynamicAdaptiveIconDrawable;
import com.android.wallpaper.R;
import com.android.wallpaper.asset.Asset;
@@ -250,14 +251,34 @@
@ColorInt public final int colorAccentDark;
public final List<Drawable> icons;
public final Drawable shapeDrawable;
- public final List<Drawable> shapeAppIcons;
- public final List<String> shapeAppIconNames;
+ public final List<ShapeAppIcon> shapeAppIcons;
@Dimension public final int bottomSheeetCornerRadius;
+ /** A class to represent an App icon and its name. */
+ public static class ShapeAppIcon {
+ private Drawable mIconDrawable;
+ private CharSequence mAppName;
+
+ public ShapeAppIcon(Drawable icon, CharSequence appName) {
+ mIconDrawable = icon;
+ mAppName = appName;
+ }
+
+ /** Returns the app icon drawable. */
+ public Drawable getDrawable() {
+ return mIconDrawable;
+ }
+
+ /** Returns the app name. */
+ public CharSequence getAppName() {
+ return mAppName;
+ }
+ }
+
private PreviewInfo(Context context, Typeface bodyFontFamily, Typeface headlineFontFamily,
int colorAccentLight, int colorAccentDark, List<Drawable> icons,
Drawable shapeDrawable, @Dimension int cornerRadius,
- List<Drawable> shapeAppIcons, List<String> shapeAppIconNames) {
+ List<ShapeAppIcon> shapeAppIcons) {
this.bodyFontFamily = bodyFontFamily;
this.headlineFontFamily = headlineFontFamily;
this.colorAccentLight = colorAccentLight;
@@ -266,7 +287,6 @@
this.shapeDrawable = shapeDrawable;
this.bottomSheeetCornerRadius = cornerRadius;
this.shapeAppIcons = shapeAppIcons;
- this.shapeAppIconNames = shapeAppIconNames;
}
/**
@@ -293,8 +313,7 @@
private boolean mIsDefault;
@Dimension private int mCornerRadius;
protected Map<String, String> mPackages = new HashMap<>();
- private List<Drawable> mAppIcons = new ArrayList<>();
- private List<String> mAppIconNames = new ArrayList<>();
+ private List<ShapeAppIcon> mAppIcons = new ArrayList<>();
public ThemeBundle build(Context context) {
return new ThemeBundle(mTitle, mPackages, mIsDefault, createPreviewInfo(context));
@@ -302,7 +321,7 @@
public PreviewInfo createPreviewInfo(Context context) {
ShapeDrawable shapeDrawable = null;
- List<Drawable> shapeIcons = new ArrayList<>();
+ List<ShapeAppIcon> shapeIcons = new ArrayList<>();
Path path = mShapePath;
if (!TextUtils.isEmpty(mPathString)) {
path = PathParser.createPathFromPathData(mPathString);
@@ -312,12 +331,15 @@
shapeDrawable = new ShapeDrawable(shape);
shapeDrawable.setIntrinsicHeight((int) PATH_SIZE);
shapeDrawable.setIntrinsicWidth((int) PATH_SIZE);
- for (Drawable icon : mAppIcons) {
- if (icon instanceof AdaptiveIconDrawable) {
- AdaptiveIconDrawable adaptiveIcon = (AdaptiveIconDrawable) icon;
- shapeIcons.add(new DynamicAdaptiveIconDrawable(adaptiveIcon.getBackground(),
- adaptiveIcon.getForeground(), path));
- } else if (icon instanceof DynamicAdaptiveIconDrawable) {
+ for (ShapeAppIcon icon : mAppIcons) {
+ Drawable drawable = icon.getDrawable();
+ if (drawable instanceof AdaptiveIconDrawable) {
+ AdaptiveIconDrawable adaptiveIcon = (AdaptiveIconDrawable) drawable;
+ shapeIcons.add(new ShapeAppIcon(
+ new DynamicAdaptiveIconDrawable(adaptiveIcon.getBackground(),
+ adaptiveIcon.getForeground(), path),
+ icon.getAppName()));
+ } else if (drawable instanceof DynamicAdaptiveIconDrawable) {
shapeIcons.add(icon);
}
// TODO: add iconloader library's legacy treatment helper methods for
@@ -325,8 +347,7 @@
}
}
return new PreviewInfo(context, mBodyFontFamily, mHeadlineFontFamily, mColorAccentLight,
- mColorAccentDark, mIcons, shapeDrawable, mCornerRadius, shapeIcons,
- mAppIconNames);
+ mColorAccentDark, mIcons, shapeDrawable, mCornerRadius, shapeIcons);
}
public Map<String, String> getPackages() {
@@ -387,13 +408,9 @@
return this;
}
- public Builder addShapePreviewIcon(Drawable appIcon) {
- mAppIcons.add(appIcon);
- return this;
- }
-
- public Builder addShapePreviewIconName(String appIconName) {
- mAppIconNames.add(appIconName);
+ public Builder setShapePreviewIcons(List<ShapeAppIcon> appIcons) {
+ mAppIcons.clear();
+ mAppIcons.addAll(appIcons);
return this;
}
diff --git a/src/com/android/customization/model/theme/custom/ShapeOptionsProvider.java b/src/com/android/customization/model/theme/custom/ShapeOptionsProvider.java
index 2206ff4..f93b892 100644
--- a/src/com/android/customization/model/theme/custom/ShapeOptionsProvider.java
+++ b/src/com/android/customization/model/theme/custom/ShapeOptionsProvider.java
@@ -22,6 +22,7 @@
import static com.android.customization.model.ResourceConstants.PATH_SIZE;
import android.content.Context;
+import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
@@ -39,6 +40,7 @@
import com.android.customization.model.ResourceConstants;
import com.android.customization.model.theme.OverlayManagerCompat;
+import com.android.customization.model.theme.ThemeBundle.PreviewInfo.ShapeAppIcon;
import com.android.customization.model.theme.custom.ThemeComponentOption.ShapeOption;
import com.android.customization.widget.DynamicAdaptiveIconDrawable;
import com.android.wallpaper.R;
@@ -71,11 +73,11 @@
try {
Path path = loadPath(mContext.getPackageManager()
.getResourcesForApplication(overlayPackage), overlayPackage);
- ShapeDrawable shapeDrawable = createShapeDrawable(path);
PackageManager pm = mContext.getPackageManager();
String label = pm.getApplicationInfo(overlayPackage, 0).loadLabel(pm).toString();
mOptions.add(new ShapeOption(overlayPackage, label, path,
- loadCornerRadius(overlayPackage), shapeDrawable, getShapedIcons(path)));
+ loadCornerRadius(overlayPackage), createShapeDrawable(path),
+ getShapedAppIcons(path)));
} catch (NameNotFoundException | NotFoundException e) {
Log.w(TAG, String.format("Couldn't load shape overlay %s, will skip it",
overlayPackage), e);
@@ -86,12 +88,11 @@
private void addDefault() {
Resources system = Resources.getSystem();
Path path = loadPath(system, ANDROID_PACKAGE);
- ShapeDrawable shapeDrawable = createShapeDrawable(path);
mOptions.add(new ShapeOption(null, mContext.getString(R.string.default_theme_title), path,
system.getDimensionPixelOffset(
- system.getIdentifier(ResourceConstants.CONFIG_CORNERRADIUS,
- "dimen", ResourceConstants.ANDROID_PACKAGE)),
- shapeDrawable, getShapedIcons(path)));
+ system.getIdentifier(ResourceConstants.CONFIG_CORNERRADIUS,
+ "dimen", ResourceConstants.ANDROID_PACKAGE)),
+ createShapeDrawable(path), getShapedAppIcons(path)));
}
private ShapeDrawable createShapeDrawable(Path path) {
@@ -102,22 +103,32 @@
return shapeDrawable;
}
- private List<Drawable> getShapedIcons(Path path) {
- List<Drawable> icons = new ArrayList<>();
+ private List<ShapeAppIcon> getShapedAppIcons(Path path) {
+ List<ShapeAppIcon> shapedAppIcons = new ArrayList<>();
for (String packageName : mShapePreviewIconPackages) {
+ Drawable icon = null;
+ CharSequence name = null;
try {
Drawable appIcon = mContext.getPackageManager().getApplicationIcon(packageName);
if (appIcon instanceof AdaptiveIconDrawable) {
AdaptiveIconDrawable adaptiveIcon = (AdaptiveIconDrawable) appIcon;
- icons.add(new DynamicAdaptiveIconDrawable(adaptiveIcon.getBackground(),
- adaptiveIcon.getForeground(), path));
+ icon = new DynamicAdaptiveIconDrawable(adaptiveIcon.getBackground(),
+ adaptiveIcon.getForeground(), path);
+
+ ApplicationInfo appInfo = mContext.getPackageManager()
+ .getApplicationInfo(packageName, /* flag= */ 0);
+ name = mContext.getPackageManager().getApplicationLabel(appInfo);
}
} catch (NameNotFoundException e) {
Log.d(TAG, "Couldn't find app " + packageName
+ ", won't use it for icon shape preview");
+ } finally {
+ if (icon != null && !TextUtils.isEmpty(name)) {
+ shapedAppIcons.add(new ShapeAppIcon(icon, name));
+ }
}
}
- return icons;
+ return shapedAppIcons;
}
private Path loadPath(Resources overlayRes, String packageName) {
diff --git a/src/com/android/customization/model/theme/custom/ThemeComponentOption.java b/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
index 6583433..b3d9d15 100644
--- a/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
+++ b/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
@@ -55,6 +55,7 @@
import com.android.customization.model.CustomizationManager;
import com.android.customization.model.CustomizationOption;
import com.android.customization.model.ResourceConstants;
+import com.android.customization.model.theme.ThemeBundle.PreviewInfo.ShapeAppIcon;
import com.android.customization.model.theme.custom.CustomTheme.Builder;
import com.android.wallpaper.R;
@@ -416,7 +417,7 @@
public static class ShapeOption extends ThemeComponentOption {
private final LayerDrawable mShape;
- private final List<Drawable> mAppIcons;
+ private final List<ShapeAppIcon> mAppIcons;
private final String mLabel;
private final Path mPath;
private final int mCornerRadius;
@@ -427,7 +428,7 @@
ShapeOption(String packageName, String label, Path path,
@Dimension int cornerRadius, Drawable shapeDrawable,
- List<Drawable> appIcons) {
+ List<ShapeAppIcon> appIcons) {
addOverlayPackage(OVERLAY_CATEGORY_SHAPE, packageName);
mLabel = label;
mAppIcons = appIcons;
@@ -489,16 +490,15 @@
}
for (int i = 0; i < mShapeIconIds.length && i < mAppIcons.size(); i++) {
ImageView iconView = cardBody.findViewById(mShapeIconIds[i]);
- iconView.setBackground(mAppIcons.get(i));
+ iconView.setBackground(mAppIcons.get(i).getDrawable());
}
}
@Override
public Builder buildStep(Builder builder) {
- builder.setShapePath(mPath).setBottomSheetCornerRadius(mCornerRadius);
- for (Drawable appIcon : mAppIcons) {
- builder.addShapePreviewIcon(appIcon);
- }
+ builder.setShapePath(mPath)
+ .setBottomSheetCornerRadius(mCornerRadius)
+ .setShapePreviewIcons(mAppIcons);
return super.buildStep(builder);
}
}
diff --git a/src/com/android/customization/picker/CustomizationPickerActivity.java b/src/com/android/customization/picker/CustomizationPickerActivity.java
index ac456be..11bcbdf 100644
--- a/src/com/android/customization/picker/CustomizationPickerActivity.java
+++ b/src/com/android/customization/picker/CustomizationPickerActivity.java
@@ -66,6 +66,7 @@
import com.android.wallpaper.module.Injector;
import com.android.wallpaper.module.InjectorProvider;
import com.android.wallpaper.module.UserEventLogger;
+import com.android.wallpaper.module.WallpaperPreferences;
import com.android.wallpaper.picker.BottomActionBarFragment;
import com.android.wallpaper.picker.CategoryFragment;
import com.android.wallpaper.picker.CategoryFragment.CategoryFragmentHost;
@@ -132,6 +133,8 @@
if (fragment == null) {
// App launch specific logic: log the "app launched" event and set up daily logging.
mUserEventLogger.logAppLaunched();
+ WallpaperPreferences preferences = injector.getPreferences(this);
+ preferences.incrementAppLaunched();
DailyLoggingAlarmScheduler.setAlarm(getApplicationContext());
// Navigate to the Wallpaper tab if we started directly from launcher, otherwise
diff --git a/src/com/android/customization/picker/theme/CustomThemeActivity.java b/src/com/android/customization/picker/theme/CustomThemeActivity.java
index 6173b3d..a5ce222 100644
--- a/src/com/android/customization/picker/theme/CustomThemeActivity.java
+++ b/src/com/android/customization/picker/theme/CustomThemeActivity.java
@@ -64,6 +64,7 @@
public static final String EXTRA_THEME_ID = "CustomThemeActivity.ThemeId";
public static final String EXTRA_THEME_TITLE = "CustomThemeActivity.ThemeTitle";
public static final String EXTRA_THEME_PACKAGES = "CustomThemeActivity.ThemePackages";
+ public static final String CREATE_NEW_THEME = "CustomThemeActivity.NewTheme";
public static final int REQUEST_CODE_CUSTOM_THEME = 1;
public static final int RESULT_THEME_DELETED = 10;
public static final int RESULT_THEME_APPLIED = 20;
@@ -78,6 +79,7 @@
private ThemeManager mThemeManager;
private TextView mNextButton;
private TextView mPreviousButton;
+ private boolean mIsDefinedTheme = true;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -89,6 +91,7 @@
&& intent.hasExtra(EXTRA_THEME_TITLE) && intent.hasExtra(EXTRA_THEME_ID)) {
ThemeBundleProvider themeProvider =
new DefaultThemeProvider(this, injector.getCustomizationPreferences(this));
+ mIsDefinedTheme = intent.getBooleanExtra(CREATE_NEW_THEME, true);
try {
CustomTheme.Builder themeBuilder = themeProvider.parseCustomTheme(
intent.getStringExtra(EXTRA_THEME_PACKAGES));
@@ -220,7 +223,8 @@
mThemeManager.apply(themeToApply, new Callback() {
@Override
public void onSuccess() {
- Toast.makeText(CustomThemeActivity.this, R.string.applied_theme_msg,
+ overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
+ Toast.makeText(getApplicationContext(), R.string.applied_theme_msg,
Toast.LENGTH_LONG).show();
setResult(RESULT_THEME_APPLIED);
finish();
@@ -383,7 +387,8 @@
return CustomThemeNameFragment.newInstance(
title,
position,
- titleResId);
+ titleResId,
+ mIsDefinedTheme);
}
}
}
diff --git a/src/com/android/customization/picker/theme/CustomThemeNameFragment.java b/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
index 8075ffa..3411542 100644
--- a/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
+++ b/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
@@ -15,84 +15,62 @@
*/
package com.android.customization.picker.theme;
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
+import static com.android.customization.picker.ViewOnlyFullPreviewActivity.SECTION_STYLE;
+import static com.android.customization.picker.theme.ThemeFullPreviewFragment.EXTRA_THEME_OPTION;
+import static com.android.customization.picker.theme.ThemeFullPreviewFragment.EXTRA_THEME_OPTION_TITLE;
+import static com.android.customization.picker.theme.ThemeFullPreviewFragment.EXTRA_WALLPAPER_INFO;
+
+import android.content.Intent;
import android.os.Bundle;
-import android.text.Editable;
-import android.text.TextWatcher;
+import android.text.TextUtils;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.View.OnLayoutChangeListener;
import android.view.ViewGroup;
import android.widget.EditText;
-import android.widget.TextView;
+import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.cardview.widget.CardView;
import com.android.customization.model.theme.ThemeBundle.PreviewInfo;
-import com.android.customization.picker.theme.ThemePreviewPage.ThemeCoverPage;
+import com.android.customization.model.theme.custom.CustomTheme;
+import com.android.customization.module.CustomizationInjector;
+import com.android.customization.module.CustomizationPreferences;
+import com.android.customization.picker.ViewOnlyFullPreviewActivity;
+import com.android.customization.picker.WallpaperPreviewer;
import com.android.wallpaper.R;
-import com.android.wallpaper.asset.Asset;
-import com.android.wallpaper.asset.BitmapCachingAsset;
+import com.android.wallpaper.model.WallpaperInfo;
import com.android.wallpaper.module.CurrentWallpaperInfoFactory;
import com.android.wallpaper.module.InjectorProvider;
import com.android.wallpaper.picker.AppbarFragment;
-import com.android.wallpaper.util.TimeTicker;
+import com.android.wallpaper.widget.WallpaperColorsLoader;
+import org.json.JSONArray;
+import org.json.JSONException;
+
+/** Fragment of naming a custom theme. */
public class CustomThemeNameFragment extends CustomThemeStepFragment {
+ private static final String TAG = "CustomThemeNameFragment";
+ private static final String ARG_IS_DEFINED_THEME = "CustomThemeNameFragment.new_theme";
+
public static CustomThemeNameFragment newInstance(CharSequence toolbarTitle, int position,
- int titleResId) {
+ int titleResId, boolean mIsDefinedTheme) {
CustomThemeNameFragment fragment = new CustomThemeNameFragment();
Bundle arguments = AppbarFragment.createArguments(toolbarTitle);
arguments.putInt(ARG_KEY_POSITION, position);
arguments.putInt(ARG_KEY_TITLE_RES_ID, titleResId);
+ arguments.putBoolean(ARG_IS_DEFINED_THEME, mIsDefinedTheme);
fragment.setArguments(arguments);
return fragment;
}
-
- private int[] mColorButtonIds = {
- R.id.preview_check_selected, R.id.preview_radio_selected, R.id.preview_toggle_selected
- };
- private int[] mColorTileIds = {
- R.id.preview_color_qs_0_bg, R.id.preview_color_qs_1_bg, R.id.preview_color_qs_2_bg
- };
- private int[][] mColorTileIconIds = {
- new int[]{ R.id.preview_color_qs_0_icon, 0},
- new int[]{ R.id.preview_color_qs_1_icon, 1},
- new int[] { R.id.preview_color_qs_2_icon, 3}
- };
-
- private int[] mShapeIconIds = {
- R.id.shape_preview_icon_0, R.id.shape_preview_icon_1, R.id.shape_preview_icon_2,
- R.id.shape_preview_icon_3, R.id.shape_preview_icon_4, R.id.shape_preview_icon_5
- };
-
- private Asset mWallpaperAsset;
- private ThemeCoverPage mCoverPage;
- private TimeTicker mTicker;
private EditText mNameEditor;
-
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- CurrentWallpaperInfoFactory currentWallpaperFactory = InjectorProvider.getInjector()
- .getCurrentWallpaperFactory(getActivity().getApplicationContext());
- currentWallpaperFactory.createCurrentWallpaperInfos(
- (homeWallpaper, lockWallpaper, presentationMode) -> {
- mWallpaperAsset = new BitmapCachingAsset(getContext(),
- homeWallpaper.getThumbAsset(getContext()));
- if (mCoverPage != null) {
- mCoverPage.bindBody(true);
- }
- }, false);
- }
+ private ImageView mWallpaperImage;
+ private WallpaperInfo mCurrentHomeWallpaper;
+ private ThemeOptionPreviewer mThemeOptionPreviewer;
+ private CustomizationPreferences mCustomizationPreferences;
@Nullable
@Override
@@ -101,92 +79,82 @@
View view = super.onCreateView(inflater, container, savedInstanceState);
mTitle = view.findViewById(R.id.component_options_title);
mTitle.setText(mTitleResId);
+ CurrentWallpaperInfoFactory currentWallpaperFactory = InjectorProvider.getInjector()
+ .getCurrentWallpaperFactory(getActivity().getApplicationContext());
+ CustomizationInjector injector = (CustomizationInjector) InjectorProvider.getInjector();
+ mCustomizationPreferences = injector.getCustomizationPreferences(getContext());
+
+ // Set wallpaper background.
+ mWallpaperImage = view.findViewById(R.id.wallpaper_preview_image);
+ final WallpaperPreviewer wallpaperPreviewer = new WallpaperPreviewer(
+ getLifecycle(),
+ getActivity(),
+ mWallpaperImage,
+ view.findViewById(R.id.wallpaper_preview_surface));
+ currentWallpaperFactory.createCurrentWallpaperInfos(
+ (homeWallpaper, lockWallpaper, presentationMode) -> {
+ mCurrentHomeWallpaper = homeWallpaper;
+ wallpaperPreviewer.setWallpaper(homeWallpaper);
+ updateThemePreviewColorPerWallpaper();
+ }, false);
+
+ // Set theme option.
+ ViewGroup previewContainer = view.findViewById(R.id.theme_preview_container);
+ previewContainer.setOnClickListener(v -> showFullPreview());
+ mThemeOptionPreviewer = new ThemeOptionPreviewer(getLifecycle(), getContext(),
+ previewContainer);
+ PreviewInfo previewInfo = mCustomThemeManager.buildCustomThemePreviewInfo(getContext());
+ mThemeOptionPreviewer.setPreviewInfo(previewInfo);
+
+ // Set theme default name.
mNameEditor = view.findViewById(R.id.custom_theme_name);
- mNameEditor.setText(mCustomThemeManager.getOriginalTheme().getTitle());
- bindCover(view.findViewById(R.id.component_preview_content));
+ mNameEditor.setText(
+ getCustomThemeDefaultName(getArguments().getBoolean(ARG_IS_DEFINED_THEME, true)));
+
+ view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View v, int left, int top, int right, int bottom,
+ int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ wallpaperPreviewer.updatePreviewCardRadius();
+ updateThemePreviewColorPerWallpaper();
+ view.removeOnLayoutChangeListener(this);
+ }
+ });
return view;
}
- @Override
- public void onResume() {
- super.onResume();
- mTicker = TimeTicker.registerNewReceiver(getContext(), this::updateTime);
- updateTime();
- }
-
- private void updateTime() {
- if (mCoverPage != null) {
- mCoverPage.updateTime();
+ private void updateThemePreviewColorPerWallpaper() {
+ if (mCurrentHomeWallpaper != null && mWallpaperImage.getMeasuredWidth() > 0
+ && mWallpaperImage.getMeasuredHeight() > 0) {
+ WallpaperColorsLoader.getWallpaperColors(
+ getContext(),
+ mCurrentHomeWallpaper.getThumbAsset(getContext()),
+ mWallpaperImage.getMeasuredWidth(),
+ mWallpaperImage.getMeasuredHeight(),
+ mThemeOptionPreviewer::updateColorForLauncherWidgets);
}
}
- @Override
- public void onPause() {
- super.onPause();
- if (getContext() != null) {
- getContext().unregisterReceiver(mTicker);
- }
- }
-
- private void bindCover(CardView card) {
- Context context = getContext();
- PreviewInfo previewInfo = mCustomThemeManager.buildCustomThemePreviewInfo(context);
- mCoverPage = new ThemeCoverPage(getActivity(), getThemeName(),
- previewInfo.resolveAccentColor(getResources()), previewInfo.icons,
- previewInfo.headlineFontFamily, previewInfo.bottomSheeetCornerRadius,
- previewInfo.shapeDrawable, previewInfo.shapeAppIcons, null,
- mColorButtonIds, mColorTileIds, mColorTileIconIds, mShapeIconIds,
- new WallpaperLayoutListener());
- mCoverPage.setCard(card);
- mCoverPage.bindPreviewContent();
- mNameEditor.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
-
- }
-
- @Override
- public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
- ((TextView)card.findViewById(R.id.theme_preview_card_header)).setText(charSequence);
- }
-
- @Override
- public void afterTextChanged(Editable editable) {
-
- }
- });
- }
-
- private class WallpaperLayoutListener implements OnLayoutChangeListener {
-
- @Override
- public void onLayoutChange(View view, int left, int top, int right,
- int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
- int targetWidth = right - left;
- int targetHeight = bottom - top;
- if (targetWidth > 0 && targetHeight > 0) {
- if (mWallpaperAsset != null) {
- mWallpaperAsset.decodeBitmap(
- targetWidth, targetHeight,
- bitmap -> setWallpaperBitmap(view, bitmap));
+ private String getCustomThemeDefaultName(boolean mIsDefinedTheme) {
+ if (mIsDefinedTheme) {
+ // For new custom theme. use custom themes amount plus 1 as default naming.
+ String serializedThemes = mCustomizationPreferences.getSerializedCustomThemes();
+ int customThemesCount = 0;
+ if (!TextUtils.isEmpty(serializedThemes)) {
+ try {
+ JSONArray customThemes = new JSONArray(serializedThemes);
+ customThemesCount = customThemes.length();
+ } catch (JSONException e) {
+ Log.w(TAG, "Couldn't read stored custom theme");
}
- view.removeOnLayoutChangeListener(this);
}
+ return getContext().getString(
+ R.string.custom_theme_title, customThemesCount + 1);
+ } else {
+ // For existing custom theme, keep its name as default naming.
+ return mCustomThemeManager.getOriginalTheme().getTitle();
}
- private void setWallpaperBitmap(View view, Bitmap bitmap) {
- Resources res = view.getContext().getResources();
- Drawable background = new BitmapDrawable(res, bitmap);
- background.setAlpha(ThemeCoverPage.COVER_PAGE_WALLPAPER_ALPHA);
-
- view.findViewById(R.id.theme_preview_card_background).setBackground(background);
- }
- }
-
- @Override
- public void onDestroyView() {
- super.onDestroyView();
- mCoverPage = null;
}
@Override
@@ -197,4 +165,15 @@
public String getThemeName() {
return mNameEditor.getText().toString();
}
+
+ private void showFullPreview() {
+ CustomTheme themeToFullPreview = mCustomThemeManager.buildPartialCustomTheme(
+ getContext(), /* id= */ "", getThemeName());
+ Bundle bundle = new Bundle();
+ bundle.putParcelable(EXTRA_WALLPAPER_INFO, mCurrentHomeWallpaper);
+ bundle.putString(EXTRA_THEME_OPTION, themeToFullPreview.getSerializedPackages());
+ bundle.putString(EXTRA_THEME_OPTION_TITLE, themeToFullPreview.getTitle());
+ Intent intent = ViewOnlyFullPreviewActivity.newIntent(getContext(), SECTION_STYLE, bundle);
+ startActivity(intent);
+ }
}
diff --git a/src/com/android/customization/picker/theme/ThemeFragment.java b/src/com/android/customization/picker/theme/ThemeFragment.java
index 3da41c6..1f4917e 100644
--- a/src/com/android/customization/picker/theme/ThemeFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFragment.java
@@ -18,6 +18,7 @@
import static android.app.Activity.RESULT_OK;
import static com.android.customization.picker.ViewOnlyFullPreviewActivity.SECTION_STYLE;
+import static com.android.customization.picker.theme.ThemeFullPreviewFragment.EXTRA_CAN_APPLY_FROM_FULL_PREVIEW;
import static com.android.customization.picker.theme.ThemeFullPreviewFragment.EXTRA_THEME_OPTION;
import static com.android.customization.picker.theme.ThemeFullPreviewFragment.EXTRA_THEME_OPTION_TITLE;
import static com.android.customization.picker.theme.ThemeFullPreviewFragment.EXTRA_WALLPAPER_INFO;
@@ -179,6 +180,7 @@
if (mCurrentHomeWallpaper != null && mWallpaperImage.getMeasuredWidth() > 0
&& mWallpaperImage.getMeasuredHeight() > 0) {
WallpaperColorsLoader.getWallpaperColors(
+ getContext(),
mCurrentHomeWallpaper.getThumbAsset(getContext()),
mWallpaperImage.getMeasuredWidth(),
mWallpaperImage.getMeasuredHeight(),
@@ -224,7 +226,7 @@
mSelectedTheme = null;
reloadOptions();
} else if (resultCode == CustomThemeActivity.RESULT_THEME_APPLIED) {
- getActivity().finish();
+ reloadOptions();
} else {
if (mSelectedTheme != null) {
mOptionsController.setSelectedOption(mSelectedTheme);
@@ -361,6 +363,7 @@
intent.putExtra(CustomThemeActivity.EXTRA_THEME_ID, themeToEdit.getId());
intent.putExtra(CustomThemeActivity.EXTRA_THEME_PACKAGES,
themeToEdit.getSerializedPackages());
+ intent.putExtra(CustomThemeActivity.CREATE_NEW_THEME, !themeToEdit.isDefined());
startActivityForResult(intent, CustomThemeActivity.REQUEST_CODE_CUSTOM_THEME);
}
@@ -369,6 +372,7 @@
bundle.putParcelable(EXTRA_WALLPAPER_INFO, mCurrentHomeWallpaper);
bundle.putString(EXTRA_THEME_OPTION, mSelectedTheme.getSerializedPackages());
bundle.putString(EXTRA_THEME_OPTION_TITLE, mSelectedTheme.getTitle());
+ bundle.putBoolean(EXTRA_CAN_APPLY_FROM_FULL_PREVIEW, true);
Intent intent = ViewOnlyFullPreviewActivity.newIntent(getContext(), SECTION_STYLE, bundle);
startActivityForResult(intent, FULL_PREVIEW_REQUEST_CODE);
}
diff --git a/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java b/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java
index 3b6923c..253720e 100644
--- a/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java
@@ -56,9 +56,11 @@
public static final String EXTRA_THEME_OPTION_TITLE = "theme_option_title";
protected static final String EXTRA_THEME_OPTION = "theme_option";
protected static final String EXTRA_WALLPAPER_INFO = "wallpaper_info";
+ protected static final String EXTRA_CAN_APPLY_FROM_FULL_PREVIEW = "can_apply";
private WallpaperInfo mWallpaper;
private ThemeBundle mThemeBundle;
+ private boolean mCanApplyFromFullPreview;
/**
* Returns a new {@link ThemeFullPreviewFragment} with the provided title and bundle arguments
@@ -77,6 +79,7 @@
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mWallpaper = getArguments().getParcelable(EXTRA_WALLPAPER_INFO);
+ mCanApplyFromFullPreview = getArguments().getBoolean(EXTRA_CAN_APPLY_FROM_FULL_PREVIEW);
CustomizationInjector injector = (CustomizationInjector) InjectorProvider.getInjector();
ThemeBundleProvider themeProvider = new DefaultThemeProvider(
getContext(), injector.getCustomizationPreferences(getContext()));
@@ -122,10 +125,12 @@
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
wallpaperPreviewer.updatePreviewCardRadius();
+ // Let's use half size of full preview card to reduce memory and loading time.
WallpaperColorsLoader.getWallpaperColors(
+ getContext(),
mWallpaper.getThumbAsset(getContext()),
- wallpaperImageView.getMeasuredWidth(),
- wallpaperImageView.getMeasuredHeight(),
+ wallpaperImageView.getMeasuredWidth() / 2,
+ wallpaperImageView.getMeasuredHeight() / 2,
themeOptionPreviewer::updateColorForLauncherWidgets);
view.removeOnLayoutChangeListener(this);
}
@@ -135,8 +140,12 @@
@Override
protected void onBottomActionBarReady(BottomActionBar bottomActionBar) {
- bottomActionBar.showActionsOnly(INFORMATION, APPLY);
- bottomActionBar.setActionClickListener(APPLY, v -> finishActivityWithResultOk());
+ if (mCanApplyFromFullPreview) {
+ bottomActionBar.showActionsOnly(INFORMATION, APPLY);
+ bottomActionBar.setActionClickListener(APPLY, v -> finishActivityWithResultOk());
+ } else {
+ bottomActionBar.showActionsOnly(INFORMATION);
+ }
ThemeInfoView themeInfoView = (ThemeInfoView) LayoutInflater.from(getContext()).inflate(
R.layout.theme_info_view, /* root= */ null);
themeInfoView.populateThemeInfo(mThemeBundle);
diff --git a/src/com/android/customization/picker/theme/ThemeOptionPreviewer.java b/src/com/android/customization/picker/theme/ThemeOptionPreviewer.java
index 6096762..afeb6ff 100644
--- a/src/com/android/customization/picker/theme/ThemeOptionPreviewer.java
+++ b/src/com/android/customization/picker/theme/ThemeOptionPreviewer.java
@@ -25,11 +25,13 @@
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
+import android.text.format.DateFormat;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.animation.AnimationUtils;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.Switch;
@@ -43,18 +45,21 @@
import com.android.customization.model.theme.ThemeBundle;
import com.android.customization.model.theme.ThemeBundle.PreviewInfo;
+import com.android.customization.model.theme.ThemeBundle.PreviewInfo.ShapeAppIcon;
import com.android.wallpaper.R;
import com.android.wallpaper.util.ScreenSizeCalculator;
-import com.android.wallpaper.util.TimeTicker;
+import com.android.wallpaper.util.TimeUtils;
+import com.android.wallpaper.util.TimeUtils.TimeTicker;
-import java.text.DateFormat;
-import java.text.FieldPosition;
import java.util.Calendar;
import java.util.List;
+import java.util.Locale;
import java.util.TimeZone;
/** A class to load the {@link ThemeBundle} preview to the view. */
class ThemeOptionPreviewer implements LifecycleObserver {
+ private static final String DATE_FORMAT = "EEEE, MMM d";
+
// Maps which icon from ResourceConstants#ICONS_FOR_PREVIEW.
private static final int ICON_WIFI = 0;
private static final int ICON_BLUETOOTH = 1;
@@ -95,16 +100,22 @@
private final Context mContext;
private View mContentView;
- private TextView mClock;
+ private TextView mStatusBarClock;
+ private TextView mSmartSpaceDate;
private TimeTicker mTicker;
+ private boolean mHasPreviewInfoSet;
+ private boolean mHasWallpaperColorSet;
+
ThemeOptionPreviewer(Lifecycle lifecycle, Context context, ViewGroup previewContainer) {
lifecycle.addObserver(this);
mContext = context;
mContentView = LayoutInflater.from(context).inflate(
- R.layout.theme_preview_content_v2, /* root= */ null);
- mClock = mContentView.findViewById(R.id.theme_preview_clock);
+ R.layout.theme_preview_content, /* root= */ null);
+ mContentView.setVisibility(View.INVISIBLE);
+ mStatusBarClock = mContentView.findViewById(R.id.theme_preview_clock);
+ mSmartSpaceDate = mContentView.findViewById(R.id.smart_space_date);
updateTime();
final float screenAspectRatio =
ScreenSizeCalculator.getInstance().getScreenAspectRatio(mContext);
@@ -150,11 +161,12 @@
setHeadlineFont(previewInfo.headlineFontFamily);
setTopBarIcons(previewInfo.icons);
setAppIconShape(previewInfo.shapeAppIcons);
- setAppIconName(previewInfo.shapeAppIconNames);
setColorAndIconsSection(previewInfo.icons, previewInfo.shapeDrawable,
previewInfo.resolveAccentColor(mContext.getResources()));
setColorAndIconsBoxRadius(previewInfo.bottomSheeetCornerRadius);
setQsbRadius(previewInfo.bottomSheeetCornerRadius);
+ mHasPreviewInfoSet = true;
+ showPreviewIfHasAllConfigSet();
}
/**
@@ -167,7 +179,7 @@
? R.color.text_color_light
: R.color.text_color_dark);
// Update the top status bar clock text color.
- mClock.setTextColor(color);
+ mStatusBarClock.setTextColor(color);
// Update the top status bar icon color.
ViewGroup iconsContainer = mContentView.findViewById(R.id.theme_preview_top_bar_icons);
for (int i = 0; i < iconsContainer.getChildCount(); i++) {
@@ -180,6 +192,9 @@
for (int id : mShapeIconAppNameIds) {
((TextView) mContentView.findViewById(id)).setTextColor(color);
}
+
+ mHasWallpaperColorSet = true;
+ showPreviewIfHasAllConfigSet();
}
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
@@ -197,20 +212,40 @@
}
}
- private void setHeadlineFont(Typeface headlineFont) {
- // Update font of status bar clock.
- mClock.setTypeface(headlineFont);
+ private void showPreviewIfHasAllConfigSet() {
+ if (mHasPreviewInfoSet && mHasWallpaperColorSet
+ && mContentView.getVisibility() != View.VISIBLE) {
+ mContentView.setAlpha(0f);
+ mContentView.setVisibility(View.VISIBLE);
+ mContentView.animate().alpha(1f)
+ .setStartDelay(50)
+ .setDuration(200)
+ .setInterpolator(AnimationUtils.loadInterpolator(mContext,
+ android.R.interpolator.fast_out_linear_in))
+ .start();
+ }
+ }
- // Update font of the smart space date.
- TextView date = mContentView.findViewById(R.id.smart_space_date);
- date.setTypeface(headlineFont);
- // TODO(chihhangchuang): Use real date.
- date.setText("Friday, Nov 12");
+ private void setHeadlineFont(Typeface headlineFont) {
+ mStatusBarClock.setTypeface(headlineFont);
+ mSmartSpaceDate.setTypeface(headlineFont);
+ mSmartSpaceDate.setShadowLayer(
+ mContext.getResources().getDimension(
+ R.dimen.preview_theme_smartspace_key_ambient_shadow_blur),
+ /* dx = */ 0,
+ /* dy = */ 0,
+ mContext.getColor(R.color.theme_preview_workspace_shadow_color));
// Update font of app names.
for (int id : mShapeIconAppNameIds) {
TextView appName = mContentView.findViewById(id);
appName.setTypeface(headlineFont);
+ appName.setShadowLayer(
+ mContext.getResources().getDimension(
+ R.dimen.preview_theme_app_name_key_ambient_shadow_blur),
+ /* dx = */ 0,
+ /* dy = */ 0,
+ mContext.getColor(R.color.theme_preview_workspace_shadow_color));
}
// Update font of color/icons section title.
@@ -232,17 +267,16 @@
}
}
- private void setAppIconShape(List<Drawable> appIcons) {
- for (int i = 0; i < mShapeAppIconIds.length && i < appIcons.size(); i++) {
+ private void setAppIconShape(List<ShapeAppIcon> appIcons) {
+ for (int i = 0; i < mShapeAppIconIds.length && i < mShapeIconAppNameIds.length
+ && i < appIcons.size(); i++) {
+ ShapeAppIcon icon = appIcons.get(i);
+ // Set app icon.
ImageView iconView = mContentView.findViewById(mShapeAppIconIds[i]);
- iconView.setBackground(appIcons.get(i));
- }
- }
-
- private void setAppIconName(List<String> appIconNames) {
- for (int i = 0; i < mShapeIconAppNameIds.length && i < appIconNames.size(); i++) {
+ iconView.setBackground(icon.getDrawable());
+ // Set app name.
TextView appName = mContentView.findViewById(mShapeIconAppNameIds[i]);
- appName.setText(appIconNames.get(i));
+ appName.setText(icon.getAppName());
}
}
@@ -292,20 +326,15 @@
}
private void updateTime() {
- if (mClock != null) {
- mClock.setText(getFormattedTime());
+ Calendar calendar = Calendar.getInstance(TimeZone.getDefault());
+ if (mStatusBarClock != null) {
+ mStatusBarClock.setText(TimeUtils.getFormattedTime(mContext, calendar));
}
- }
-
- private String getFormattedTime() {
- DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
- StringBuffer time = new StringBuffer();
- FieldPosition amPmPosition = new FieldPosition(DateFormat.Field.AM_PM);
- df.format(Calendar.getInstance(TimeZone.getDefault()).getTime(), time, amPmPosition);
- if (amPmPosition.getBeginIndex() > 0) {
- time.delete(amPmPosition.getBeginIndex(), amPmPosition.getEndIndex());
+ if (mSmartSpaceDate != null) {
+ String datePattern =
+ DateFormat.getBestDateTimePattern(Locale.getDefault(), DATE_FORMAT);
+ mSmartSpaceDate.setText(DateFormat.format(datePattern, calendar));
}
- return time.toString();
}
private boolean useRoundedQSB(int cornerRadius) {
diff --git a/src/com/android/customization/picker/theme/ThemePreviewPage.java b/src/com/android/customization/picker/theme/ThemePreviewPage.java
deleted file mode 100644
index b8152d9..0000000
--- a/src/com/android/customization/picker/theme/ThemePreviewPage.java
+++ /dev/null
@@ -1,276 +0,0 @@
-package com.android.customization.picker.theme;
-
-import android.app.Activity;
-import android.content.res.ColorStateList;
-import android.content.res.Resources;
-import android.graphics.Typeface;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.GradientDrawable;
-import android.icu.text.DateFormat;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.View.OnLayoutChangeListener;
-import android.view.ViewGroup;
-import android.widget.CompoundButton;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import androidx.annotation.ColorInt;
-import androidx.annotation.DrawableRes;
-import androidx.annotation.LayoutRes;
-import androidx.annotation.StringRes;
-import androidx.constraintlayout.widget.Guideline;
-
-import com.android.customization.picker.BasePreviewAdapter.PreviewPage;
-import com.android.wallpaper.R;
-
-import java.text.FieldPosition;
-import java.util.Calendar;
-import java.util.List;
-import java.util.TimeZone;
-
-abstract class ThemePreviewPage extends PreviewPage {
-
- public interface TimeContainer {
- void updateTime();
- }
-
- @StringRes
- final int nameResId;
- final Drawable icon;
- @LayoutRes
- final int contentLayoutRes;
- @ColorInt
- final int accentColor;
- protected final LayoutInflater inflater;
-
- public ThemePreviewPage(Activity activity, @StringRes int titleResId,
- @DrawableRes int iconSrc, @LayoutRes int contentLayoutRes, @ColorInt int accentColor) {
- super(null, activity);
- this.nameResId = titleResId;
- if (iconSrc != Resources.ID_NULL) {
- this.icon = activity.getResources().getDrawable(iconSrc, activity.getTheme());
- int size = activity.getResources().getDimensionPixelSize(R.dimen.card_header_icon_size);
- icon.setBounds(0, 0, size, size);
- } else {
- this.icon = null;
- }
- this.contentLayoutRes = contentLayoutRes;
- this.accentColor = accentColor;
- this.inflater = LayoutInflater.from(activity);
- }
-
- @Override
- public void bindPreviewContent() {
- TextView header = card.findViewById(R.id.theme_preview_card_header);
- header.setText(nameResId);
- header.setCompoundDrawables(null, icon, null, null);
- header.setCompoundDrawableTintList(ColorStateList.valueOf(accentColor));
- card.findViewById(R.id.theme_preview_top_bar).setVisibility(View.GONE);
- card.findViewById(R.id.edit_label).setVisibility(View.GONE);
-
- ViewGroup body = card.findViewById(R.id.theme_preview_card_body_container);
- inflater.inflate(contentLayoutRes, body, true);
- bindBody(false);
- }
-
- protected boolean containsWallpaper() {
- return false;
- }
-
- protected abstract void bindBody(boolean forceRebind);
-
- static class ThemeCoverPage extends ThemePreviewPage implements TimeContainer {
-
- public static final int COVER_PAGE_WALLPAPER_ALPHA = 0x66;
- /**
- * Maps which icon from ResourceConstants#ICONS_FOR_PREVIEW to use for each icon in the
- * top bar (fake "status bar") of the cover page.
- */
- private static final int [] sTopBarIconToPreviewIcon = new int [] { 0, 6, 7 };
-
- private final Typeface mHeadlineFont;
- private final List<Drawable> mIcons;
- private final List<Drawable> mShapeAppIcons;
- private Drawable mShapeDrawable;
- private final int[] mColorButtonIds;
- private final int[] mColorTileIds;
- private final int[][] mColorTileIconIds;
- private final int[] mShapeIconIds;
- private final Resources mRes;
- private String mTitle;
- private OnClickListener mEditClickListener;
- private final OnLayoutChangeListener[] mListeners;
- private final int mCornerRadius;
- private final ColorStateList mTintList;
-
- public ThemeCoverPage(Activity activity, String title, int accentColor,
- List<Drawable> icons,
- Typeface headlineFont, int cornerRadius,
- Drawable shapeDrawable,
- List<Drawable> shapeAppIcons,
- OnClickListener editClickListener,
- int[] colorButtonIds, int[] colorTileIds, int[][] colorTileIconIds,
- int[] shapeIconIds, OnLayoutChangeListener... wallpaperListeners) {
- super(activity, 0, 0, R.layout.preview_card_cover_content,
- accentColor);
- mRes = activity.getResources();
- mTitle = title;
- mHeadlineFont = headlineFont;
- mIcons = icons;
- mCornerRadius = cornerRadius;
- mShapeDrawable = shapeDrawable;
- mShapeAppIcons = shapeAppIcons;
- mEditClickListener = editClickListener;
- mColorButtonIds = colorButtonIds;
- mColorTileIds = colorTileIds;
- mColorTileIconIds = colorTileIconIds;
- mShapeIconIds = shapeIconIds;
- mListeners = wallpaperListeners;
- // Color QS icons:
- int controlGreyColor = mRes.getColor(R.color.control_grey, null);
- mTintList = new ColorStateList(
- new int[][]{
- new int[]{android.R.attr.state_selected},
- new int[]{android.R.attr.state_checked},
- new int[]{-android.R.attr.state_enabled},
- },
- new int[] {
- accentColor,
- accentColor,
- controlGreyColor
- }
- );
- }
-
- @Override
- protected void bindBody(boolean forceRebind) {
- if (card == null) {
- return;
- }
- if (mListeners != null) {
- for (OnLayoutChangeListener listener : mListeners) {
- if (listener != null) {
- card.addOnLayoutChangeListener(listener);
- }
- }
- }
-
- if (forceRebind) {
- card.requestLayout();
- }
-
- for (int i = 0; i < mColorButtonIds.length; i++) {
- CompoundButton button = card.findViewById(mColorButtonIds[i]);
- if (button != null) {
- button.setButtonTintList(mTintList);
- }
- }
- for (int i = 0; i < 3 && i < mIcons.size(); i++) {
- Drawable icon = mIcons.get(mColorTileIconIds[i][1]).getConstantState()
- .newDrawable().mutate();
- Drawable bgShape = mShapeDrawable.getConstantState().newDrawable();
- bgShape.setTint(accentColor);
-
- ImageView bg = card.findViewById(mColorTileIds[i]);
- bg.setImageDrawable(bgShape);
- ImageView fg = card.findViewById(mColorTileIconIds[i][0]);
- fg.setImageDrawable(icon);
- }
-
- // Shape preview icons:
- for (int i = 0; i < 3 && i < mShapeAppIcons.size(); i++) {
- ImageView iconView = card.findViewById(mShapeIconIds[i]);
- iconView.setBackground(mShapeAppIcons.get(i));
- }
- }
-
- @Override
- public void bindPreviewContent() {
- TextView header = card.findViewById(R.id.theme_preview_card_header);
- header.setText(mTitle);
- header.setTextAppearance(R.style.CoverTitleTextAppearance);
- header.setTypeface(mHeadlineFont);
-
- card.findViewById(R.id.theme_preview_top_bar).setVisibility(View.VISIBLE);
- TextView clock = card.findViewById(R.id.theme_preview_clock);
- clock.setText(getFormattedTime());
- clock.setTypeface(mHeadlineFont);
-
- ViewGroup iconsContainer = card.findViewById(R.id.theme_preview_top_bar_icons);
-
- for (int i = 0; i < iconsContainer.getChildCount(); i++) {
- int iconIndex = sTopBarIconToPreviewIcon[i];
- if (iconIndex < mIcons.size()) {
- ((ImageView) iconsContainer.getChildAt(i))
- .setImageDrawable(mIcons.get(iconIndex).getConstantState()
- .newDrawable().mutate());
- } else {
- iconsContainer.getChildAt(i).setVisibility(View.GONE);
- }
- }
-
- ViewGroup body = card.findViewById(R.id.theme_preview_card_body_container);
-
- inflater.inflate(contentLayoutRes, body, true);
-
- bindBody(false);
-
- TextView editLabel = card.findViewById(R.id.edit_label);
- editLabel.setOnClickListener(mEditClickListener);
- card.setOnClickListener(mEditClickListener);
- card.setClickable(mEditClickListener != null);
-
- editLabel.setVisibility(mEditClickListener != null
- ? View.VISIBLE : View.INVISIBLE);
-
- View qsb = card.findViewById(R.id.theme_qsb);
- if (qsb != null && qsb.getVisibility() == View.VISIBLE) {
- if (qsb.getBackground() instanceof GradientDrawable) {
- GradientDrawable bg = (GradientDrawable) qsb.getBackground();
- float cornerRadius = useRoundedQSB(mCornerRadius)
- ? (float)qsb.getLayoutParams().height / 2 : mCornerRadius;
- bg.setCornerRadii(new float[]{
- cornerRadius, cornerRadius, cornerRadius, cornerRadius,
- cornerRadius, cornerRadius, cornerRadius, cornerRadius});
- }
- }
-
- Guideline guideline = card.findViewById(R.id.guideline);
- if (guideline != null) {
- guideline.setGuidelineEnd(card.getResources().getDimensionPixelOffset(
- R.dimen.preview_theme_cover_content_bottom));
- }
- }
-
- @Override
- public void updateTime() {
- if (card != null) {
- ((TextView) card.findViewById(R.id.theme_preview_clock)).setText(
- getFormattedTime());
- }
- }
-
- private boolean useRoundedQSB(int cornerRadius) {
- return cornerRadius >=
- card.getResources().getDimensionPixelSize(R.dimen.roundCornerThreshold);
- }
-
- private String getFormattedTime() {
- DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
- StringBuffer time = new StringBuffer();
- FieldPosition amPmPosition = new FieldPosition(DateFormat.Field.AM_PM);
- df.format(Calendar.getInstance(TimeZone.getDefault()).getTime(), time, amPmPosition);
- if (amPmPosition.getBeginIndex() > 0) {
- time.delete(amPmPosition.getBeginIndex(), amPmPosition.getEndIndex());
- }
- return time.toString();
- }
-
- @Override
- protected boolean containsWallpaper() {
- return true;
- }
- }
-}
diff --git a/src/com/android/customization/widget/ThemeInfoView.java b/src/com/android/customization/widget/ThemeInfoView.java
index 5b05484..a733a40 100644
--- a/src/com/android/customization/widget/ThemeInfoView.java
+++ b/src/com/android/customization/widget/ThemeInfoView.java
@@ -72,7 +72,7 @@
if (previewInfo.shapeAppIcons.get(SHAPE_PREVIEW_INDEX) != null) {
mAppPreviewImageView.setBackground(
- previewInfo.shapeAppIcons.get(SHAPE_PREVIEW_INDEX));
+ previewInfo.shapeAppIcons.get(SHAPE_PREVIEW_INDEX).getDrawable());
}
if (previewInfo.shapeDrawable != null) {