Add an exported flag in manifest am: a8409b8d22 am: a66d3ffcbf am: 30e793ae09
Change-Id: I581c71710ebba4c972f914b6c3523aac7f5bc7ff
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 70aa303..95a24b6 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -35,6 +35,10 @@
<activity android:name="com.android.customization.picker.theme.CustomThemeActivity"
android:resizeableActivity="false"
android:theme="@style/CustomizationTheme.NoActionBar"/>
+
+ <activity android:name="com.android.customization.picker.ViewOnlyFullPreviewActivity"
+ android:resizeableActivity="false"
+ android:theme="@style/CustomizationTheme.NoActionBar"/>
</application>
</manifest>
diff --git a/res/drawable/ic_check_circle_filled_24px.xml b/res/drawable/ic_check_circle_filled_24px.xml
index cacf1d8..01d2091 100644
--- a/res/drawable/ic_check_circle_filled_24px.xml
+++ b/res/drawable/ic_check_circle_filled_24px.xml
@@ -19,7 +19,7 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
- android:fillColor="@color/selected_check_background_color"
+ android:fillColor="@color/accent_color"
android:pathData="M12,2C6.5,2 2,6.5 2,12s4.5,10 10,10s10,-4.5 10,-10S17.5,2 12,2zM10,17l-4,-4l1.4,-1.4l2.6,2.6l6.6,-6.6L18,9L10,17z"/>
<path
android:pathData="m8.0085,14.9866 l-1.9939,-1.994 0.6892,-0.6889 0.6892,-0.6889 1.2925,1.2926c0.7109,0.711 1.3035,1.2926 1.3169,1.2926 0.0134,0 1.5034,-1.4789 3.3111,-3.2865l3.2866,-3.2865 0.689,0.689 0.689,0.689 -3.9878,3.9878 -3.9878,3.9878z"
diff --git a/res/layout-land/fragment_grid_picker.xml b/res/layout-land/fragment_grid_picker.xml
index 77330a8..6c2d8c5 100644
--- a/res/layout-land/fragment_grid_picker.xml
+++ b/res/layout-land/fragment_grid_picker.xml
@@ -39,34 +39,18 @@
android:background="@color/secondary_color"
app:card_style="screen_aspect_ratio"/>
- <LinearLayout
+ <FrameLayout
android:id="@+id/options_section"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
- android:paddingVertical="10dp"
- android:orientation="vertical">
+ android:paddingVertical="10dp">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/options_container"
android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"/>
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingHorizontal="10dp">
- <Button
- android:id="@+id/apply_button"
- style="@style/ActionPrimaryButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentEnd="true"
- android:text="@string/apply_btn"/>
- </RelativeLayout>
-
- </LinearLayout>
+ android:layout_height="match_parent"/>
+ </FrameLayout>
</LinearLayout>
<androidx.core.widget.ContentLoadingProgressBar
android:id="@+id/loading_indicator"
diff --git a/res/layout-land/fragment_theme_picker.xml b/res/layout-land/fragment_theme_picker.xml
index f2083f3..dc30232 100644
--- a/res/layout-land/fragment_theme_picker.xml
+++ b/res/layout-land/fragment_theme_picker.xml
@@ -55,30 +55,14 @@
android:layout_height="0dp"
android:layout_weight="1"/>
- <RelativeLayout
- android:layout_width="match_parent"
+ <Button
+ android:id="@+id/apply_button"
+ style="@style/ActionPrimaryButton"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:background="@null"
- android:paddingHorizontal="10dp">
- <CheckBox
- android:id="@+id/use_my_wallpaper"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentStart="true"
- android:layout_centerVertical="true"
- android:layout_toStartOf="@+id/apply_button"
- android:ellipsize="end"
- android:paddingLeft="4dp"
- android:minHeight="@dimen/min_taptarget_height"
- android:text="@string/keep_my_wallpaper"/>
- <Button
- android:id="@+id/apply_button"
- style="@style/ActionPrimaryButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentEnd="true"
- android:text="@string/apply_theme_btn"/>
- </RelativeLayout>
+ android:layout_gravity="end"
+ android:paddingHorizontal="10dp"
+ android:text="@string/apply_theme_btn"/>
</LinearLayout>
</LinearLayout>
diff --git a/res/layout/activity_full_preview.xml b/res/layout/activity_full_preview.xml
new file mode 100644
index 0000000..b1e0584
--- /dev/null
+++ b/res/layout/activity_full_preview.xml
@@ -0,0 +1,28 @@
+<?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.
+-->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <FrameLayout
+ android:id="@+id/preview_fragment_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginBottom="@dimen/bottom_navbar_height" />
+
+ <include layout="@layout/bottom_action_bar" />
+</FrameLayout>
diff --git a/res/layout/fragment_clock_scalable_picker.xml b/res/layout/fragment_clock_scalable_picker.xml
deleted file mode 100644
index db31dc5..0000000
--- a/res/layout/fragment_clock_scalable_picker.xml
+++ /dev/null
@@ -1,119 +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.coordinatorlayout.widget.CoordinatorLayout
- 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:background="?android:colorPrimary"
- android:orientation="vertical">
-
- <include layout="@layout/section_header" />
-
- <FrameLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- app:layout_behavior="@string/scalable_container_behavior">
-
- <com.android.wallpaper.widget.PreviewPager
- android:id="@+id/clock_preview_pager"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="@color/preview_pager_background" />
- </FrameLayout>
-
- <FrameLayout
- android:id="@+id/scalable_content_container"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/content_container_maximum_height"
- app:behavior_peekHeight="@dimen/content_container_minimum_height"
- app:layout_behavior="@string/bottom_sheet_behavior">
-
- <androidx.constraintlayout.widget.ConstraintLayout
- android:id="@+id/content_section"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <androidx.recyclerview.widget.RecyclerView
- android:id="@+id/options_container"
- android:layout_width="match_parent"
- android:layout_height="@dimen/options_container_height"
- android:layout_gravity="center_horizontal"
- android:layout_marginTop="10dp"
- app:layout_constraintBottom_toTopOf="@id/placeholder"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintVertical_bias="1.0" />
-
- <Space
- android:id="@+id/placeholder"
- android:layout_width="match_parent"
- android:layout_height="@dimen/min_taptarget_height"
- app:layout_constraintBottom_toTopOf="@id/apply_button"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintHeight_min="@dimen/min_taptarget_height"
- app:layout_constraintHorizontal_bias="0.0"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@id/options_container"
- app:layout_constraintVertical_bias="1.0" />
-
- <Button
- android:id="@+id/apply_button"
- style="@style/ActionPrimaryButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="end"
- android:layout_marginVertical="10dp"
- android:layout_marginEnd="10dp"
- android:layout_weight="1"
- android:text="@string/apply_theme_btn"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent" />
- </androidx.constraintlayout.widget.ConstraintLayout>
- </FrameLayout>
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <androidx.core.widget.ContentLoadingProgressBar
- android:id="@+id/loading_indicator"
- style="@android:style/Widget.DeviceDefault.ProgressBar"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal|top"
- android:layout_marginTop="200dp"
- android:indeterminate="true" />
-
- <FrameLayout
- android:id="@+id/error_section"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:visibility="gone">
-
- <TextView
- android:id="@+id/error_message"
- style="@style/TitleTextAppearance"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:gravity="center"
- android:text="@string/something_went_wrong" />
- </FrameLayout>
- </FrameLayout>
-</androidx.coordinatorlayout.widget.CoordinatorLayout>
diff --git a/res/layout/fragment_grid_full_preview.xml b/res/layout/fragment_grid_full_preview.xml
new file mode 100644
index 0000000..1c01743
--- /dev/null
+++ b/res/layout/fragment_grid_full_preview.xml
@@ -0,0 +1,58 @@
+<?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:orientation="vertical">
+
+ <include layout="@layout/section_header"/>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:background="@color/fullscreen_preview_background">
+
+ <androidx.cardview.widget.CardView
+ style="@style/FullContentPreviewCard"
+ android:id="@+id/grid_full_preview_card"
+ android:layout_marginTop="24dp"
+ android:layout_marginBottom="32dp"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center">
+
+ <ImageView
+ android:id="@+id/grid_full_preview_image"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/primary_color"/>
+
+ <SurfaceView
+ android:id="@+id/grid_full_preview_option_surface"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
+
+ <SurfaceView
+ android:id="@+id/grid_full_preview_wallpaper_surface"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ </androidx.cardview.widget.CardView>
+ </FrameLayout>
+</LinearLayout>
diff --git a/res/layout/fragment_grid_picker.xml b/res/layout/fragment_grid_picker.xml
index f664568..5bf96e1 100644
--- a/res/layout/fragment_grid_picker.xml
+++ b/res/layout/fragment_grid_picker.xml
@@ -39,49 +39,39 @@
android:background="@color/preview_pager_background"
app:card_style="screen_aspect_ratio"
app:layout_constrainedHeight="true"
- app:layout_constraintBottom_toTopOf="@id/options_container"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toTopOf="@id/options_title"
+ app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_max="@dimen/preview_pager_max_height"
app:layout_constraintHeight_min="@dimen/preview_pager_min_height"
app:layout_constraintVertical_bias="0.0"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="spread_inside"/>
+ <TextView
+ android:id="@+id/options_title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:paddingVertical="18dp"
+ android:lineHeight="24dp"
+ android:singleLine="true"
+ android:text="@string/grid_options_title"
+ android:textAppearance="@style/TitleTextAppearance"
+ app:layout_constraintTop_toBottomOf="@id/grid_preview_pager"
+ app:layout_constraintBottom_toTopOf="@id/options_container"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"/>
+
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/options_container"
android:layout_width="match_parent"
android:layout_height="@dimen/options_container_height"
android:layout_gravity="center_horizontal"
- android:layout_marginTop="10dp"
- app:layout_constraintBottom_toTopOf="@id/placeholder"
+ app:layout_constraintTop_toBottomOf="@+id/options_title"
+ app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/grid_preview_pager"
app:layout_constraintVertical_bias="1.0"/>
-
- <Space
- android:id="@+id/placeholder"
- android:layout_width="match_parent"
- android:layout_height="@dimen/min_taptarget_height"
- app:layout_constraintBottom_toTopOf="@id/apply_button"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@id/options_container"
- app:layout_constraintVertical_bias="1.0"/>
-
- <Button
- android:id="@+id/apply_button"
- style="@style/ActionPrimaryButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="end"
- android:layout_marginEnd="10dp"
- android:layout_marginVertical="10dp"
- android:layout_weight="1"
- android:text="@string/apply_theme_btn"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent"/>
-
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.core.widget.ContentLoadingProgressBar
diff --git a/res/layout/fragment_grid_scalable_picker.xml b/res/layout/fragment_grid_scalable_picker.xml
deleted file mode 100644
index de44923..0000000
--- a/res/layout/fragment_grid_scalable_picker.xml
+++ /dev/null
@@ -1,118 +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.coordinatorlayout.widget.CoordinatorLayout
- 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:background="?android:colorPrimary"
- android:orientation="vertical">
-
- <include layout="@layout/section_header" />
-
- <FrameLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- app:layout_behavior="@string/scalable_container_behavior">
-
- <com.android.wallpaper.widget.PreviewPager
- android:id="@+id/grid_preview_pager"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="@color/preview_pager_background"
- app:card_style="screen_aspect_ratio" />
- </FrameLayout>
-
- <FrameLayout
- android:id="@+id/scalable_content_container"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/content_container_maximum_height"
- app:behavior_peekHeight="@dimen/content_container_minimum_height"
- app:layout_behavior="@string/bottom_sheet_behavior">
-
- <androidx.constraintlayout.widget.ConstraintLayout
- android:id="@+id/content_section"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <androidx.recyclerview.widget.RecyclerView
- android:id="@+id/options_container"
- android:layout_width="match_parent"
- android:layout_height="@dimen/options_container_height"
- android:layout_gravity="center_horizontal"
- android:layout_marginTop="10dp"
- app:layout_constraintBottom_toTopOf="@id/placeholder"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintVertical_bias="1.0" />
-
- <Space
- android:id="@+id/placeholder"
- android:layout_width="match_parent"
- android:layout_height="@dimen/min_taptarget_height"
- app:layout_constraintBottom_toTopOf="@id/apply_button"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@id/options_container"
- app:layout_constraintVertical_bias="1.0" />
-
- <Button
- android:id="@+id/apply_button"
- style="@style/ActionPrimaryButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="end"
- android:layout_marginVertical="10dp"
- android:layout_marginEnd="10dp"
- android:layout_weight="1"
- android:text="@string/apply_theme_btn"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent" />
-
- </androidx.constraintlayout.widget.ConstraintLayout>
- </FrameLayout>
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <androidx.core.widget.ContentLoadingProgressBar
- android:id="@+id/loading_indicator"
- style="@android:style/Widget.DeviceDefault.ProgressBar"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal|top"
- android:layout_marginTop="200dp"
- android:indeterminate="true" />
-
- <FrameLayout
- android:id="@+id/error_section"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:visibility="gone">
-
- <TextView
- android:id="@+id/error_message"
- style="@style/TitleTextAppearance"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:gravity="center"
- android:text="@string/something_went_wrong" />
- </FrameLayout>
- </FrameLayout>
-</androidx.coordinatorlayout.widget.CoordinatorLayout>
diff --git a/res/layout/fragment_theme_picker.xml b/res/layout/fragment_theme_picker.xml
index 1de5a3c..d15d93f 100644
--- a/res/layout/fragment_theme_picker.xml
+++ b/res/layout/fragment_theme_picker.xml
@@ -53,29 +53,11 @@
android:layout_gravity="bottom|center_horizontal"
android:layout_marginTop="10dp"
android:layout_weight="1"
- app:layout_constraintBottom_toTopOf="@id/use_my_wallpaper"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/theme_preview_pager"
app:layout_constraintVertical_bias="1.0"/>
- <CheckBox
- android:id="@+id/use_my_wallpaper"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/min_taptarget_height"
- android:layout_marginStart="10dp"
- android:ellipsize="end"
- android:gravity="start|center_vertical"
- android:paddingLeft="4dp"
- android:text="@string/keep_my_wallpaper"
- app:layout_constraintBottom_toTopOf="@id/apply_button"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintHeight_min="@dimen/min_taptarget_height"
- app:layout_constraintHorizontal_bias="0.0"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@id/options_container"
- app:layout_constraintVertical_bias="1.0"/>
-
<Button
android:id="@+id/apply_button"
style="@style/ActionPrimaryButton"
diff --git a/res/layout/fragment_theme_scalable_picker.xml b/res/layout/fragment_theme_scalable_picker.xml
deleted file mode 100644
index e03df3e..0000000
--- a/res/layout/fragment_theme_scalable_picker.xml
+++ /dev/null
@@ -1,124 +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.coordinatorlayout.widget.CoordinatorLayout
- 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:background="?android:colorPrimary"
- android:orientation="vertical">
-
- <include layout="@layout/section_header" />
-
- <FrameLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- app:layout_behavior="@string/scalable_container_behavior">
-
- <com.android.wallpaper.widget.PreviewPager
- android:id="@+id/theme_preview_pager"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="@color/preview_pager_background" />
- </FrameLayout>
-
- <FrameLayout
- android:id="@+id/scalable_content_container"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/content_container_maximum_height"
- app:behavior_peekHeight="@dimen/content_container_minimum_height"
- app:layout_behavior="@string/bottom_sheet_behavior">
-
- <androidx.constraintlayout.widget.ConstraintLayout
- android:id="@+id/content_section"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <androidx.recyclerview.widget.RecyclerView
- android:id="@+id/options_container"
- android:layout_width="match_parent"
- android:layout_height="@dimen/options_container_height"
- android:layout_gravity="bottom|center_horizontal"
- android:layout_marginTop="10dp"
- android:layout_weight="1"
- app:layout_constraintBottom_toTopOf="@id/use_my_wallpaper"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintVertical_bias="1.0" />
-
- <CheckBox
- android:id="@+id/use_my_wallpaper"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/min_taptarget_height"
- android:layout_marginStart="10dp"
- android:ellipsize="end"
- android:gravity="start|center_vertical"
- android:paddingLeft="4dp"
- android:text="@string/keep_my_wallpaper"
- app:layout_constraintBottom_toTopOf="@id/apply_button"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintHeight_min="@dimen/min_taptarget_height"
- app:layout_constraintHorizontal_bias="0.0"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@id/options_container"
- app:layout_constraintVertical_bias="1.0" />
-
- <Button
- android:id="@+id/apply_button"
- style="@style/ActionPrimaryButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="end"
- android:layout_marginEnd="10dp"
- android:layout_marginBottom="10dp"
- android:text="@string/apply_theme_btn"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent" />
- </androidx.constraintlayout.widget.ConstraintLayout>
- </FrameLayout>
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <androidx.core.widget.ContentLoadingProgressBar
- android:id="@+id/loading_indicator"
- style="@android:style/Widget.DeviceDefault.ProgressBar"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal|top"
- android:layout_marginTop="200dp"
- android:indeterminate="true" />
-
- <FrameLayout
- android:id="@+id/error_section"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:visibility="gone">
-
- <TextView
- android:id="@+id/error_message"
- style="@style/TitleTextAppearance"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:gravity="center"
- android:text="@string/something_went_wrong" />
- </FrameLayout>
- </FrameLayout>
-</androidx.coordinatorlayout.widget.CoordinatorLayout>
diff --git a/res/layout/preview_card_wallpaper_content.xml b/res/layout/preview_card_wallpaper_content.xml
deleted file mode 100644
index 0b43c2f..0000000
--- a/res/layout/preview_card_wallpaper_content.xml
+++ /dev/null
@@ -1,31 +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.
--->
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:id="@+id/preview_static_image"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- tools:showIn="@layout/theme_preview_card">
- <TextView
- style="@style/CardTitleTextAppearance"
- android:id="@+id/wallpaper_description"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_horizontal|bottom"/>
-</FrameLayout>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 49daee4..3c78967 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -21,15 +21,15 @@
<dimen name="tip_dot_size">8dp</dimen>
<dimen name="tip_dot_line_width">2dp</dimen>
- <dimen name="check_size">20dp</dimen>
- <dimen name="check_offset">-4dp</dimen>
+ <dimen name="check_size">16dp</dimen>
+ <dimen name="check_offset">4dp</dimen>
<dimen name="component_preview_page_bottom_margin">16dp</dimen>
<!-- Dimensions for the customization option tiles -->
- <dimen name="options_container_height">104dp</dimen>
+ <dimen name="options_container_height">120dp</dimen>
<dimen name="options_container_width">0dp</dimen>
- <dimen name="option_tile_width">72dp</dimen>
+ <dimen name="option_tile_width">88dp</dimen>
<dimen name="theme_option_icon_sample_height">18dp</dimen>
<dimen name="theme_option_icon_sample_width">18dp</dimen>
<dimen name="theme_option_shape_sample_height">16dp</dimen>
@@ -38,8 +38,8 @@
<dimen name="theme_option_font_sample_width">52dp</dimen>
<dimen name="theme_option_sample_padding">5dp</dimen>
<!-- Note, using dp instead of sp as this is just the "+" symbol, not text -->
- <dimen name="option_tile_padding_vertical">12dp</dimen>
- <dimen name="option_tile_padding_horizontal">10dp</dimen>
+ <dimen name="option_tile_padding_vertical">16dp</dimen>
+ <dimen name="option_tile_padding_horizontal">16dp</dimen>
<dimen name="option_bottom_margin">8dp</dimen>
<!-- Note, using dp instead of sp as this text is more like a "snapshot" of the font -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c940efd..c0aef7a 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -67,7 +67,7 @@
<!-- Plus sign used to indicate that the user can add a custom theme -->
- <!-- Name for the Android Theme that comes preset with the device [CHAR LIMIT=10]-->
+ <!-- Name for the Android Theme (Style/Wallpaper/Grid/Clock...) that comes preset with the device [CHAR LIMIT=10]-->
<string name="default_theme_title">Default</string>
<!-- Title of a page that shows the user the preview of a font selection [CHAR_LIMIT=20] -->
@@ -92,14 +92,20 @@
<!-- Body text for previewing a font [CHAR LIMIT=160] -->
<string name="font_card_body">Add your favorite fonts to every screen</string>
+ <!--Title for grid options [CHAR LIMIT=NONE] -->
+ <string name="grid_options_title">Choose a grid size</string>
+
<!--Title for a grid option, describing the number of columns and rows, eg: 4x4 [CHAR LIMIT=10] -->
<string name="grid_title_pattern"><xliff:g name="num_cols" example="1">%1$d</xliff:g>x<xliff:g name="num_rows" example="1">%2$d</xliff:g></string>
<!-- Message shown when a theme has been applied successfully in the system [CHAR LIMIT=NONE] -->
- <string name="applied_theme_msg">Style applied</string>
+ <string name="applied_theme_msg">Style set successfully</string>
<!-- Message shown when a clock has been applied successfully in the system [CHAR LIMIT=NONE] -->
- <string name="applied_clock_msg">Clock applied</string>
+ <string name="applied_clock_msg">Clock set successfully</string>
+
+ <!-- Message shown when a grid has been applied successfully in the system [CHAR LIMIT=NONE] -->
+ <string name="applied_grid_msg">Grid set successfully</string>
<!-- Message shown when a theme couldn't be applied in the system because of an error
[CHAR LIMIT=NONE] -->
diff --git a/robolectric_tests/src/com/android/customization/model/theme/ThemeManagerTest.java b/robolectric_tests/src/com/android/customization/model/theme/ThemeManagerTest.java
index 6f1f95e..cfb8a33 100644
--- a/robolectric_tests/src/com/android/customization/model/theme/ThemeManagerTest.java
+++ b/robolectric_tests/src/com/android/customization/model/theme/ThemeManagerTest.java
@@ -40,12 +40,11 @@
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
-import com.android.customization.model.CustomizationManager.OptionsFetchedListener;
import com.android.customization.model.CustomizationManager.Callback;
+import com.android.customization.model.CustomizationManager.OptionsFetchedListener;
import com.android.customization.model.theme.custom.CustomTheme;
import com.android.customization.module.ThemesUserEventLogger;
import com.android.customization.testutils.OverlayManagerMocks;
-import com.android.wallpaper.module.WallpaperSetter;
import org.json.JSONObject;
import org.junit.After;
@@ -61,7 +60,6 @@
public class ThemeManagerTest {
@Mock OverlayManagerCompat mMockOm;
- @Mock WallpaperSetter mMockWallpaperSetter;
@Mock ThemesUserEventLogger mThemesUserEventLogger;
@Mock ThemeBundleProvider mThemeBundleProvider;
private OverlayManagerMocks mMockOmHelper;
@@ -75,7 +73,7 @@
mActivity = spy(activity);
mMockOmHelper = new OverlayManagerMocks();
mMockOmHelper.setUpMock(mMockOm);
- mThemeManager = new ThemeManager(mThemeBundleProvider, activity, mMockWallpaperSetter,
+ mThemeManager = new ThemeManager(mThemeBundleProvider, activity,
mMockOm, mThemesUserEventLogger);
}
diff --git a/src/com/android/customization/model/grid/GridOption.java b/src/com/android/customization/model/grid/GridOption.java
index e3b90f4..2f32ce1 100644
--- a/src/com/android/customization/model/grid/GridOption.java
+++ b/src/com/android/customization/model/grid/GridOption.java
@@ -18,6 +18,8 @@
import android.content.Context;
import android.graphics.PorterDuff.Mode;
import android.net.Uri;
+import android.os.Parcel;
+import android.os.Parcelable;
import android.view.View;
import android.widget.ImageView;
@@ -29,10 +31,23 @@
/**
* Represents a grid layout option available in the current launcher.
*/
-public class GridOption implements CustomizationOption<GridOption> {
+// TODO(chihhangchuang): Consider moving Parcelable into CustomizationOption.
+public class GridOption implements CustomizationOption<GridOption>, Parcelable {
+ public static final Creator<GridOption> CREATOR = new Creator<GridOption>() {
+ @Override
+ public GridOption createFromParcel(Parcel in) {
+ return new GridOption(in);
+ }
+
+ @Override
+ public GridOption[] newArray(int size) {
+ return new GridOption[size];
+ }
+ };
private final String mTitle;
private final boolean mIsCurrent;
+ private final String mIconShapePath;
private final GridTileDrawable mTileDrawable;
public final String name;
public final int rows;
@@ -44,7 +59,8 @@
Uri previewImageUri, int previewPagesCount, String iconShapePath) {
mTitle = title;
mIsCurrent = isCurrent;
- mTileDrawable = new GridTileDrawable(rows, cols, iconShapePath);
+ mIconShapePath = iconShapePath;
+ mTileDrawable = new GridTileDrawable(rows, cols, mIconShapePath);
this.name = name;
this.rows = rows;
this.cols = cols;
@@ -52,6 +68,18 @@
this.previewPagesCount = previewPagesCount;
}
+ protected GridOption(Parcel in) {
+ mTitle = in.readString();
+ mIsCurrent = in.readByte() != 0;
+ mIconShapePath = in.readString();
+ name = in.readString();
+ rows = in.readInt();
+ cols = in.readInt();
+ previewImageUri = in.readParcelable(Uri.class.getClassLoader());
+ previewPagesCount = in.readInt();
+ mTileDrawable = new GridTileDrawable(rows, cols, mIconShapePath);
+ }
+
@Override
public String getTitle() {
return mTitle;
@@ -76,4 +104,21 @@
public int getLayoutResId() {
return R.layout.grid_option;
}
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel parcel, int i) {
+ parcel.writeString(mTitle);
+ parcel.writeByte((byte) (mIsCurrent ? 1 : 0));
+ parcel.writeString(mIconShapePath);
+ parcel.writeString(name);
+ parcel.writeInt(rows);
+ parcel.writeInt(cols);
+ parcel.writeParcelable(previewImageUri, i);
+ parcel.writeInt(previewPagesCount);
+ }
}
diff --git a/src/com/android/customization/model/grid/GridOptionsManager.java b/src/com/android/customization/model/grid/GridOptionsManager.java
index a334f5e..84f5373 100644
--- a/src/com/android/customization/model/grid/GridOptionsManager.java
+++ b/src/com/android/customization/model/grid/GridOptionsManager.java
@@ -58,7 +58,7 @@
@Override
public void fetchOptions(OptionsFetchedListener<GridOption> callback, boolean reload) {
- new FetchTask(mProvider, callback).execute();
+ new FetchTask(mProvider, callback, reload).execute();
}
/** See if using surface view to render grid options */
@@ -67,23 +67,25 @@
}
/** Call through content provider API to render preview */
- public void renderPreview(Bundle bundle, String gridName) {
- mProvider.renderPreview(gridName, bundle);
+ public Bundle renderPreview(Bundle bundle, String gridName) {
+ return mProvider.renderPreview(gridName, bundle);
}
private static class FetchTask extends AsyncTask<Void, Void, Pair<List<GridOption>, String>> {
private final LauncherGridOptionsProvider mProvider;
@Nullable private final OptionsFetchedListener<GridOption> mCallback;
+ private final boolean mReload;
private FetchTask(@NonNull LauncherGridOptionsProvider provider,
- @Nullable OptionsFetchedListener<GridOption> callback) {
+ @Nullable OptionsFetchedListener<GridOption> callback, boolean reload) {
mCallback = callback;
mProvider = provider;
+ mReload = reload;
}
@Override
protected Pair<List<GridOption>, String> doInBackground(Void[] params) {
- return mProvider.fetch(false);
+ return mProvider.fetch(mReload);
}
@Override
diff --git a/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java b/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java
index 7d1d5cd..6a47f95 100644
--- a/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java
+++ b/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java
@@ -29,7 +29,6 @@
import androidx.annotation.WorkerThread;
import com.android.customization.model.ResourceConstants;
-import com.android.systemui.shared.system.SurfaceViewRequestUtils;
import com.android.wallpaper.R;
import com.android.wallpaper.util.PreviewUtils;
@@ -53,6 +52,9 @@
private static final String COL_PREVIEW_COUNT = "preview_count";
private static final String COL_IS_DEFAULT = "is_default";
+ // Normal gird size name
+ private static final String GRID_NAME_NORMAL = "normal";
+
private static final String METADATA_KEY_PREVIEW_VERSION = "preview_version";
private final Context mContext;
@@ -100,7 +102,9 @@
int cols = c.getInt(c.getColumnIndex(COL_COLS));
int previewCount = c.getInt(c.getColumnIndex(COL_PREVIEW_COUNT));
boolean isSet = Boolean.valueOf(c.getString(c.getColumnIndex(COL_IS_DEFAULT)));
- String title = mContext.getString(R.string.grid_title_pattern, cols, rows);
+ String title = GRID_NAME_NORMAL.equals(name)
+ ? mContext.getString(R.string.default_theme_title)
+ : mContext.getString(R.string.grid_title_pattern, cols, rows);
mOptions.add(new GridOption(title, name, isSet, rows, cols,
mPreviewUtils.getUri(PREVIEW), previewCount, iconPath));
}
@@ -116,11 +120,11 @@
* Request rendering of home screen preview via Launcher to Wallpaper using SurfaceView
* @param name the grid option name
* @param bundle surface view request bundle generated from
- * {@link SurfaceViewRequestUtils#createSurfaceBundle(SurfaceView)}.
+ * {@link com.android.wallpaper.util.SurfaceViewUtils#createSurfaceViewRequest(SurfaceView)}.
*/
- void renderPreview(String name, Bundle bundle) {
+ Bundle renderPreview(String name, Bundle bundle) {
bundle.putString("name", name);
- mPreviewUtils.renderPreview(bundle);
+ return mPreviewUtils.renderPreview(bundle);
}
int applyGrid(String name) {
diff --git a/src/com/android/customization/model/theme/DefaultThemeProvider.java b/src/com/android/customization/model/theme/DefaultThemeProvider.java
index ce12d35..7c99f9c 100644
--- a/src/com/android/customization/model/theme/DefaultThemeProvider.java
+++ b/src/com/android/customization/model/theme/DefaultThemeProvider.java
@@ -15,8 +15,6 @@
*/
package com.android.customization.model.theme;
-import static android.content.res.Resources.ID_NULL;
-
import static com.android.customization.model.ResourceConstants.ANDROID_PACKAGE;
import static com.android.customization.model.ResourceConstants.ICONS_FOR_PREVIEW;
import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_COLOR;
@@ -29,14 +27,9 @@
import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_SHAPE;
import static com.android.customization.model.ResourceConstants.SYSUI_PACKAGE;
-import android.content.ComponentName;
import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.pm.ResolveInfo;
import android.content.res.Resources.NotFoundException;
-import android.service.wallpaper.WallpaperService;
import android.text.TextUtils;
import android.util.Log;
@@ -49,7 +42,6 @@
import com.android.customization.module.CustomizationPreferences;
import com.android.wallpaper.R;
import com.android.wallpaper.asset.ResourceAsset;
-import com.android.wallpaper.model.LiveWallpaperInfo;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.apps.wallpaper.asset.ThemeBundleThumbAsset;
@@ -57,9 +49,7 @@
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
-import org.xmlpull.v1.XmlPullParserException;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -83,12 +73,6 @@
private static final String ICON_THEMEPICKER_PREFIX = "theme_overlay_icon_themepicker_";
private static final String ICON_SETTINGS_PREFIX = "theme_overlay_icon_settings_";
private static final String ICON_SYSUI_PREFIX = "theme_overlay_icon_sysui_";
- private static final String WALLPAPER_PREFIX = "theme_wallpaper_";
- private static final String WALLPAPER_TITLE_PREFIX = "theme_wallpaper_title_";
- private static final String WALLPAPER_ATTRIBUTION_PREFIX = "theme_wallpaper_attribution_";
- private static final String WALLPAPER_THUMB_PREFIX = "theme_wallpaper_thumbnail_";
- private static final String WALLPAPER_ACTION_PREFIX = "theme_wallpaper_action_";
- private static final String WALLPAPER_OPTIONS_PREFIX = "theme_wallpaper_options_";
private static final String DEFAULT_THEME_NAME= "default";
private static final String THEME_TITLE_FIELD = "_theme_title";
@@ -172,8 +156,6 @@
mOverlayProvider.addNoPreviewIconOverlay(builder, iconSettingsOverlayPackage);
- addWallpaper(themeName, builder);
-
mThemes.add(builder.build(mContext));
} catch (NameNotFoundException | NotFoundException e) {
Log.w(TAG, String.format("Couldn't load part of theme %s, will skip it", themeName),
@@ -184,70 +166,6 @@
addCustomThemes();
}
- private void addWallpaper(String themeName, Builder builder) {
- try {
- String wallpaperResName = WALLPAPER_PREFIX + themeName;
- int wallpaperResId = mStubApkResources.getIdentifier(wallpaperResName,
- "drawable", mStubPackageName);
- // Check in case the theme has a separate thumbnail for the wallpaper
- String wallpaperThumbnailResName = WALLPAPER_THUMB_PREFIX + themeName;
- int wallpaperThumbnailResId = mStubApkResources.getIdentifier(wallpaperThumbnailResName,
- "drawable", mStubPackageName);
- if (wallpaperResId != ID_NULL) {
- builder.setWallpaperInfo(mStubPackageName, wallpaperResName,
- themeName, wallpaperResId,
- mStubApkResources.getIdentifier(WALLPAPER_TITLE_PREFIX + themeName,
- "string", mStubPackageName),
- mStubApkResources.getIdentifier(
- WALLPAPER_ATTRIBUTION_PREFIX + themeName, "string",
- mStubPackageName),
- mStubApkResources.getIdentifier(WALLPAPER_ACTION_PREFIX + themeName,
- "string", mStubPackageName))
- .setWallpaperAsset(wallpaperThumbnailResId != ID_NULL ?
- getThumbAsset(WALLPAPER_THUMB_PREFIX, themeName)
- : getDrawableResourceAsset(WALLPAPER_PREFIX, themeName));
- } else {
- // Try to see if it's a live wallpaper reference
- wallpaperResId = mStubApkResources.getIdentifier(wallpaperResName,
- "string", mStubPackageName);
- if (wallpaperResId != ID_NULL) {
- String wpComponent = mStubApkResources.getString(wallpaperResId);
-
- int wallpaperOptionsResId = mStubApkResources.getIdentifier(
- WALLPAPER_OPTIONS_PREFIX + themeName, "string", mStubPackageName);
- String wallpaperOptions = wallpaperOptionsResId != ID_NULL
- ? mStubApkResources.getString(wallpaperOptionsResId) : null;
-
- String[] componentParts = wpComponent.split("/");
- Intent liveWpIntent = new Intent(WallpaperService.SERVICE_INTERFACE);
- liveWpIntent.setComponent(
- new ComponentName(componentParts[0], componentParts[1]));
-
- Context appContext = mContext.getApplicationContext();
- PackageManager pm = appContext.getPackageManager();
- ResolveInfo resolveInfo =
- pm.resolveService(liveWpIntent, PackageManager.GET_META_DATA);
- if (resolveInfo != null) {
- android.app.WallpaperInfo wallpaperInfo;
- try {
- wallpaperInfo = new android.app.WallpaperInfo(appContext, resolveInfo);
- LiveWallpaperInfo liveInfo = new LiveWallpaperInfo(wallpaperInfo);
- builder.setLiveWallpaperInfo(liveInfo).setWallpaperAsset(
- wallpaperThumbnailResId != ID_NULL ?
- getThumbAsset(WALLPAPER_THUMB_PREFIX, themeName)
- : liveInfo.getThumbAsset(mContext))
- .setWallpaperOptions(wallpaperOptions);
- } catch (XmlPullParserException | IOException e) {
- Log.w(TAG, "Skipping wallpaper " + resolveInfo.serviceInfo, e);
- }
- }
- }
- }
- } catch (NotFoundException e) {
- // Nothing to do here, if there's no wallpaper we'll just omit wallpaper
- }
- }
-
/**
* Default theme requires different treatment: if there are overlay packages specified in the
* stub apk, we'll use those, otherwise we'll get the System default values. But we cannot skip
@@ -318,8 +236,6 @@
mOverlayProvider.addSystemDefaultIcons(builder, SYSUI_PACKAGE, ICONS_FOR_PREVIEW);
}
- addWallpaper(DEFAULT_THEME_NAME, builder);
-
mThemes.add(builder.build(mContext));
}
diff --git a/src/com/android/customization/model/theme/ThemeBundle.java b/src/com/android/customization/model/theme/ThemeBundle.java
index e83e852..14b2dcd 100644
--- a/src/com/android/customization/model/theme/ThemeBundle.java
+++ b/src/com/android/customization/model/theme/ThemeBundle.java
@@ -31,7 +31,6 @@
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.PathShape;
-import android.icu.text.SimpleDateFormat;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
@@ -40,9 +39,7 @@
import androidx.annotation.ColorInt;
import androidx.annotation.Dimension;
-import androidx.annotation.DrawableRes;
import androidx.annotation.Nullable;
-import androidx.annotation.StringRes;
import androidx.core.graphics.PathParser;
import com.android.customization.model.CustomizationManager;
@@ -51,7 +48,6 @@
import com.android.wallpaper.R;
import com.android.wallpaper.asset.Asset;
import com.android.wallpaper.asset.BitmapCachingAsset;
-import com.android.wallpaper.model.LiveWallpaperInfo;
import com.android.wallpaper.model.WallpaperInfo;
import org.json.JSONException;
@@ -59,12 +55,10 @@
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
import java.util.Set;
@@ -83,20 +77,15 @@
private final PreviewInfo mPreviewInfo;
private final boolean mIsDefault;
protected final Map<String, String> mPackagesByCategory;
- @Nullable private final WallpaperInfo mWallpaperInfo;
- @Nullable private final String mWallpaperOptions;
private WallpaperInfo mOverrideWallpaper;
private Asset mOverrideWallpaperAsset;
private CharSequence mContentDescription;
protected ThemeBundle(String title, Map<String, String> overlayPackages,
- boolean isDefault, @Nullable WallpaperInfo wallpaperInfo,
- @Nullable String wallpaperOptions, PreviewInfo previewInfo) {
+ boolean isDefault, PreviewInfo previewInfo) {
mTitle = title;
mIsDefault = isDefault;
mPreviewInfo = previewInfo;
- mWallpaperInfo = wallpaperInfo;
- mWallpaperOptions = wallpaperOptions;
mPackagesByCategory = Collections.unmodifiableMap(overlayPackages);
}
@@ -169,16 +158,6 @@
mOverrideWallpaperAsset = null;
}
- public boolean shouldUseThemeWallpaper() {
- return mOverrideWallpaper == null && mWallpaperInfo != null;
- }
-
- public Asset getWallpaperPreviewAsset(Context context) {
- return mOverrideWallpaper != null ?
- getOverrideWallpaperAsset(context) :
- getPreviewInfo().wallpaperAsset;
- }
-
private Asset getOverrideWallpaperAsset(Context context) {
if (mOverrideWallpaperAsset == null) {
mOverrideWallpaperAsset = new BitmapCachingAsset(context,
@@ -187,15 +166,6 @@
return mOverrideWallpaperAsset;
}
- public WallpaperInfo getWallpaperInfo() {
- return mWallpaperInfo;
- }
-
- @Nullable
- public String getWallpaperOptions() {
- return mWallpaperOptions;
- }
-
boolean isDefault() {
return mIsDefault;
}
@@ -280,14 +250,13 @@
@ColorInt public final int colorAccentDark;
public final List<Drawable> icons;
public final Drawable shapeDrawable;
- @Nullable public final Asset wallpaperAsset;
public final List<Drawable> shapeAppIcons;
@Dimension public final int bottomSheeetCornerRadius;
private PreviewInfo(Context context, Typeface bodyFontFamily, Typeface headlineFontFamily,
int colorAccentLight, int colorAccentDark, List<Drawable> icons,
Drawable shapeDrawable, @Dimension int cornerRadius,
- @Nullable Asset wallpaperAsset, List<Drawable> shapeAppIcons) {
+ List<Drawable> shapeAppIcons) {
this.bodyFontFamily = bodyFontFamily;
this.headlineFontFamily = headlineFontFamily;
this.colorAccentLight = colorAccentLight;
@@ -295,8 +264,6 @@
this.icons = icons;
this.shapeDrawable = shapeDrawable;
this.bottomSheeetCornerRadius = cornerRadius;
- this.wallpaperAsset = wallpaperAsset == null
- ? null : new BitmapCachingAsset(context, wallpaperAsset);
this.shapeAppIcons = shapeAppIcons;
}
@@ -323,15 +290,11 @@
private Path mShapePath;
private boolean mIsDefault;
@Dimension private int mCornerRadius;
- private Asset mWallpaperAsset;
- private WallpaperInfo mWallpaperInfo;
- private String mWallpaperOptions;
protected Map<String, String> mPackages = new HashMap<>();
private List<Drawable> mAppIcons = new ArrayList<>();
public ThemeBundle build(Context context) {
- return new ThemeBundle(mTitle, mPackages, mIsDefault, mWallpaperInfo, mWallpaperOptions,
- createPreviewInfo(context));
+ return new ThemeBundle(mTitle, mPackages, mIsDefault, createPreviewInfo(context));
}
public PreviewInfo createPreviewInfo(Context context) {
@@ -359,8 +322,7 @@
}
}
return new PreviewInfo(context, mBodyFontFamily, mHeadlineFontFamily, mColorAccentLight,
- mColorAccentDark, mIcons, shapeDrawable, mCornerRadius,
- mWallpaperAsset, shapeIcons);
+ mColorAccentDark, mIcons, shapeDrawable, mCornerRadius, shapeIcons);
}
public Map<String, String> getPackages() {
@@ -416,30 +378,6 @@
return this;
}
- public Builder setWallpaperInfo(String wallpaperPackageName, String wallpaperResName,
- String themeId, @DrawableRes int wallpaperResId, @StringRes int titleResId,
- @StringRes int attributionResId, @StringRes int actionUrlResId) {
- mWallpaperInfo = new ThemeBundledWallpaperInfo(wallpaperPackageName, wallpaperResName,
- themeId, wallpaperResId, titleResId, attributionResId, actionUrlResId);
- return this;
- }
-
- public Builder setLiveWallpaperInfo(LiveWallpaperInfo info) {
- mWallpaperInfo = info;
- return this;
- }
-
-
- public Builder setWallpaperAsset(Asset wallpaperAsset) {
- mWallpaperAsset = wallpaperAsset;
- return this;
- }
-
- public Builder setWallpaperOptions(String wallpaperOptions) {
- mWallpaperOptions = wallpaperOptions;
- return this;
- }
-
public Builder asDefault() {
mIsDefault = true;
return this;
diff --git a/src/com/android/customization/model/theme/ThemeManager.java b/src/com/android/customization/model/theme/ThemeManager.java
index 79b45fd..533fbd0 100644
--- a/src/com/android/customization/model/theme/ThemeManager.java
+++ b/src/com/android/customization/model/theme/ThemeManager.java
@@ -24,7 +24,6 @@
import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_ICON_THEMEPICKER;
import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_SHAPE;
-import android.graphics.Point;
import android.provider.Settings;
import android.text.TextUtils;
@@ -35,13 +34,6 @@
import com.android.customization.model.ResourceConstants;
import com.android.customization.model.theme.custom.CustomTheme;
import com.android.customization.module.ThemesUserEventLogger;
-import com.android.wallpaper.R;
-import com.android.wallpaper.asset.Asset;
-import com.android.wallpaper.model.LiveWallpaperInfo;
-import com.android.wallpaper.model.WallpaperInfo;
-import com.android.wallpaper.module.WallpaperPersister.SetWallpaperCallback;
-import com.android.wallpaper.module.WallpaperSetter;
-import com.android.wallpaper.util.WallpaperCropUtils;
import org.json.JSONObject;
@@ -61,25 +53,22 @@
THEME_CATEGORIES.add(OVERLAY_CATEGORY_ICON_SYSUI);
THEME_CATEGORIES.add(OVERLAY_CATEGORY_ICON_LAUNCHER);
THEME_CATEGORIES.add(OVERLAY_CATEGORY_ICON_THEMEPICKER);
- };
-
+ }
private final ThemeBundleProvider mProvider;
private final OverlayManagerCompat mOverlayManagerCompat;
- private final WallpaperSetter mWallpaperSetter;
protected final FragmentActivity mActivity;
private final ThemesUserEventLogger mEventLogger;
private Map<String, String> mCurrentOverlays;
public ThemeManager(ThemeBundleProvider provider, FragmentActivity activity,
- WallpaperSetter wallpaperSetter, OverlayManagerCompat overlayManagerCompat,
+ OverlayManagerCompat overlayManagerCompat,
ThemesUserEventLogger logger) {
mProvider = provider;
mActivity = activity;
mOverlayManagerCompat = overlayManagerCompat;
- mWallpaperSetter = wallpaperSetter;
mEventLogger = logger;
}
@@ -90,67 +79,7 @@
@Override
public void apply(ThemeBundle theme, Callback callback) {
- // Set wallpaper
- if (theme.shouldUseThemeWallpaper()) {
- mWallpaperSetter.requestDestination(mActivity, mActivity.getSupportFragmentManager(),
- R.string.set_theme_wallpaper_dialog_message,
- destination -> applyWallpaper(
- theme,
- destination,
- createSetWallpaperCallback(theme, callback)),
- theme.getWallpaperInfo() instanceof LiveWallpaperInfo);
-
- } else {
- applyOverlays(theme, callback);
- }
- }
-
- private SetWallpaperCallback createSetWallpaperCallback(ThemeBundle theme, Callback callback) {
- return new SetWallpaperCallback() {
- @Override
- public void onSuccess(WallpaperInfo wallpaperInfo) {
- applyWallpaperOptions(theme);
- applyOverlays(theme, callback);
- }
-
- @Override
- public void onError(@Nullable Throwable throwable) {
- callback.onError(throwable);
- }
- };
- }
-
- protected void applyWallpaperOptions(ThemeBundle theme) {
- //Do nothing.
- }
-
- private void applyWallpaper(ThemeBundle theme, int destination,
- SetWallpaperCallback callback) {
- Point defaultCropSurfaceSize = WallpaperCropUtils.getDefaultCropSurfaceSize(
- mActivity.getResources(),
- mActivity.getWindowManager().getDefaultDisplay());
- Asset wallpaperAsset = theme.getWallpaperInfo().getAsset(mActivity);
- if (wallpaperAsset != null) {
- wallpaperAsset.decodeRawDimensions(mActivity,
- dimensions -> {
- float scale = 1f;
- // Calculate scale to fit the screen height
- if (dimensions != null && dimensions.y > 0) {
- scale = (float) defaultCropSurfaceSize.y / dimensions.y;
- }
- mWallpaperSetter.setCurrentWallpaper(mActivity,
- theme.getWallpaperInfo(),
- wallpaperAsset,
- destination,
- scale, null, callback);
- });
- } else {
- mWallpaperSetter.setCurrentWallpaper(mActivity,
- theme.getWallpaperInfo(),
- null,
- destination,
- 1f, null, callback);
- }
+ applyOverlays(theme, callback);
}
private void applyOverlays(ThemeBundle theme, Callback callback) {
diff --git a/src/com/android/customization/model/theme/custom/CustomTheme.java b/src/com/android/customization/model/theme/custom/CustomTheme.java
index 8a7ca05..9c14f01 100644
--- a/src/com/android/customization/model/theme/custom/CustomTheme.java
+++ b/src/com/android/customization/model/theme/custom/CustomTheme.java
@@ -41,7 +41,7 @@
public CustomTheme(@NonNull String id, String title, Map<String, String> overlayPackages,
@Nullable PreviewInfo previewInfo) {
- super(title, overlayPackages, false, null, null, previewInfo);
+ super(title, overlayPackages, false, previewInfo);
mId = id;
}
@@ -76,11 +76,6 @@
}
@Override
- public boolean shouldUseThemeWallpaper() {
- return false;
- }
-
- @Override
public boolean isActive(CustomizationManager<ThemeBundle> manager) {
return isDefined() && super.isActive(manager);
}
diff --git a/src/com/android/customization/module/CustomizationInjector.java b/src/com/android/customization/module/CustomizationInjector.java
index d25f925..85853de 100644
--- a/src/com/android/customization/module/CustomizationInjector.java
+++ b/src/com/android/customization/module/CustomizationInjector.java
@@ -23,13 +23,11 @@
import com.android.customization.model.theme.ThemeBundleProvider;
import com.android.customization.model.theme.ThemeManager;
import com.android.wallpaper.module.Injector;
-import com.android.wallpaper.module.WallpaperSetter;
public interface CustomizationInjector extends Injector {
CustomizationPreferences getCustomizationPreferences(Context context);
ThemeManager getThemeManager(ThemeBundleProvider provider, FragmentActivity activity,
- WallpaperSetter wallpaperSetter, OverlayManagerCompat overlayManagerCompat,
- ThemesUserEventLogger logger);
+ OverlayManagerCompat overlayManagerCompat, ThemesUserEventLogger logger);
}
diff --git a/src/com/android/customization/module/DefaultCustomizationInjector.java b/src/com/android/customization/module/DefaultCustomizationInjector.java
index a0d435b..7358d8f 100644
--- a/src/com/android/customization/module/DefaultCustomizationInjector.java
+++ b/src/com/android/customization/module/DefaultCustomizationInjector.java
@@ -30,7 +30,6 @@
import com.android.wallpaper.module.LoggingOptInStatusProvider;
import com.android.wallpaper.module.WallpaperPreferences;
import com.android.wallpaper.module.WallpaperRotationRefresher;
-import com.android.wallpaper.module.WallpaperSetter;
import com.android.wallpaper.monitor.PerformanceMonitor;
import com.android.wallpaper.picker.PreviewFragment;
@@ -50,7 +49,6 @@
return mPrefs;
}
-
@Override
public CustomizationPreferences getCustomizationPreferences(Context context) {
return (CustomizationPreferences) getPreferences(context);
@@ -115,9 +113,8 @@
@Override
public ThemeManager getThemeManager(ThemeBundleProvider provider, FragmentActivity activity,
- WallpaperSetter wallpaperSetter, OverlayManagerCompat overlayManagerCompat,
- ThemesUserEventLogger logger) {
- return new ThemeManager(provider, activity, wallpaperSetter, overlayManagerCompat, logger);
+ OverlayManagerCompat overlayManagerCompat, ThemesUserEventLogger logger) {
+ return new ThemeManager(provider, activity, overlayManagerCompat, logger);
}
}
diff --git a/src/com/android/customization/picker/BasePreviewAdapter.java b/src/com/android/customization/picker/BasePreviewAdapter.java
index dab923a..c3ddc1d 100644
--- a/src/com/android/customization/picker/BasePreviewAdapter.java
+++ b/src/com/android/customization/picker/BasePreviewAdapter.java
@@ -17,6 +17,7 @@
import static androidx.core.view.ViewCompat.LAYOUT_DIRECTION_RTL;
+import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
@@ -29,6 +30,7 @@
import androidx.viewpager.widget.PagerAdapter;
import com.android.customization.picker.BasePreviewAdapter.PreviewPage;
+import com.android.wallpaper.util.SizeCalculator;
import com.android.wallpaper.widget.PreviewPager;
import java.util.ArrayList;
@@ -103,11 +105,24 @@
protected final String title;
protected CardView card;
- protected PreviewPage(String title) {
+ private Activity mActivity;
+
+ protected PreviewPage(String title, Activity activity) {
this.title = title;
+ mActivity = activity;
}
public void setCard(CardView card) {
+ card.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) {
+ card.setRadius(SizeCalculator.getPreviewCornerRadius(
+ mActivity, card.getMeasuredWidth()));
+ card.removeOnLayoutChangeListener(this);
+ }
+ });
this.card = card;
}
diff --git a/src/com/android/customization/picker/CustomizationPickerActivity.java b/src/com/android/customization/picker/CustomizationPickerActivity.java
index 86a0bf6..ac456be 100644
--- a/src/com/android/customization/picker/CustomizationPickerActivity.java
+++ b/src/com/android/customization/picker/CustomizationPickerActivity.java
@@ -25,6 +25,7 @@
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.View;
import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
@@ -65,7 +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.WallpaperSetter;
+import com.android.wallpaper.picker.BottomActionBarFragment;
import com.android.wallpaper.picker.CategoryFragment;
import com.android.wallpaper.picker.CategoryFragment.CategoryFragmentHost;
import com.android.wallpaper.picker.MyPhotosStarter;
@@ -73,6 +74,8 @@
import com.android.wallpaper.picker.TopLevelPickerActivity;
import com.android.wallpaper.picker.WallpaperPickerDelegate;
import com.android.wallpaper.picker.WallpapersUiContainer;
+import com.android.wallpaper.widget.BottomActionBar;
+import com.android.wallpaper.widget.BottomActionBar.BottomActionBarHost;
import com.google.android.material.bottomnavigation.BottomNavigationView;
@@ -84,7 +87,8 @@
* Fragments providing customization options.
*/
public class CustomizationPickerActivity extends FragmentActivity implements WallpapersUiContainer,
- CategoryFragmentHost, ThemeFragmentHost, GridFragmentHost, ClockFragmentHost {
+ CategoryFragmentHost, ThemeFragmentHost, GridFragmentHost, ClockFragmentHost,
+ BottomActionBarHost {
private static final String TAG = "CustomizationPickerActivity";
@VisibleForTesting static final String WALLPAPER_FLAVOR_EXTRA =
@@ -98,7 +102,7 @@
private static final Map<Integer, CustomizationSection> mSections = new HashMap<>();
private CategoryFragment mWallpaperCategoryFragment;
- private WallpaperSetter mWallpaperSetter;
+ private BottomActionBar mBottomActionBar;
private boolean mWallpaperCategoryInitialized;
@@ -116,25 +120,35 @@
if (!supportsCustomization()) {
Log.w(TAG, "Themes not supported, reverting to Wallpaper Picker");
skipToWallpaperPicker();
- } else {
- setContentView(R.layout.activity_customization_picker_main);
- setUpBottomNavView();
-
- FragmentManager fm = getSupportFragmentManager();
- Fragment fragment = fm.findFragmentById(R.id.fragment_container);
-
- if (fragment == null) {
- // App launch specific logic: log the "app launched" event and set up daily logging.
- mUserEventLogger.logAppLaunched();
- DailyLoggingAlarmScheduler.setAlarm(getApplicationContext());
-
- // Navigate to the Wallpaper tab if we started directly from launcher, otherwise
- // start at the Styles tab
- navigateToSection(
- WALLPAPER_FOCUS.equals(getIntent().getStringExtra(WALLPAPER_FLAVOR_EXTRA))
- ? R.id.nav_wallpaper : R.id.nav_theme);
- }
+ return;
}
+
+ setContentView(R.layout.activity_customization_picker_main);
+ setUpBottomNavView();
+
+ FragmentManager fm = getSupportFragmentManager();
+ Fragment fragment = fm.findFragmentById(R.id.fragment_container);
+
+ if (fragment == null) {
+ // App launch specific logic: log the "app launched" event and set up daily logging.
+ mUserEventLogger.logAppLaunched();
+ DailyLoggingAlarmScheduler.setAlarm(getApplicationContext());
+
+ // Navigate to the Wallpaper tab if we started directly from launcher, otherwise
+ // start at the Styles tab
+ navigateToSection(
+ WALLPAPER_FOCUS.equals(getIntent().getStringExtra(WALLPAPER_FLAVOR_EXTRA))
+ ? R.id.nav_wallpaper : R.id.nav_theme);
+ }
+
+ mBottomActionBar = findViewById(R.id.bottom_actionbar);
+ mBottomActionBar.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
+ // Only update the visibility of mBottomNav when mBottomActionBar visibility changes.
+ // Since the listener will be triggered by mBottomActionBar and its child views.
+ if (mBottomActionBar.getVisibility() == mBottomNav.getVisibility()) {
+ mBottomNav.setVisibility(mBottomActionBar.isVisible() ? View.GONE : View.VISIBLE);
+ }
+ });
}
@Override
@@ -194,14 +208,11 @@
}
//Theme
CustomizationInjector injector = (CustomizationInjector) InjectorProvider.getInjector();
- mWallpaperSetter = new WallpaperSetter(injector.getWallpaperPersister(this),
- injector.getPreferences(this), mUserEventLogger, false);
ThemesUserEventLogger eventLogger = (ThemesUserEventLogger) injector.getUserEventLogger(
this);
ThemeManager themeManager = injector.getThemeManager(
new DefaultThemeProvider(this, injector.getCustomizationPreferences(this)),
- this,
- mWallpaperSetter, new OverlayManagerCompat(this), eventLogger);
+ this, new OverlayManagerCompat(this), eventLogger);
if (themeManager.isAvailable()) {
mSections.put(R.id.nav_theme, new ThemeSection(R.id.nav_theme, themeManager));
} else {
@@ -292,9 +303,17 @@
@Override
public void onBackPressed() {
+ Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
+ if (fragment instanceof BottomActionBarFragment
+ && ((BottomActionBarFragment) fragment).onBackPressed()) {
+ return;
+ }
+
+ // For wallpaper tab, since it had child fragment.
if (mWallpaperCategoryFragment != null && mWallpaperCategoryFragment.popChildFragment()) {
return;
}
+
if (getSupportFragmentManager().popBackStackImmediate()) {
return;
}
@@ -391,14 +410,6 @@
}
@Override
- protected void onDestroy() {
- super.onDestroy();
- if (mWallpaperSetter != null) {
- mWallpaperSetter.cleanUp();
- }
- }
-
- @Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (mDelegate.handleActivityResult(requestCode, resultCode, data)) {
@@ -412,6 +423,11 @@
finish();
}
+ @Override
+ public BottomActionBar getBottomActionBar() {
+ return mBottomActionBar;
+ }
+
/**
* Represents a section of the Picker (eg "ThemeBundle", "Clock", etc).
* There should be a concrete subclass per available section, providing the corresponding
diff --git a/src/com/android/customization/picker/ViewOnlyFullPreviewActivity.java b/src/com/android/customization/picker/ViewOnlyFullPreviewActivity.java
new file mode 100644
index 0000000..19324da
--- /dev/null
+++ b/src/com/android/customization/picker/ViewOnlyFullPreviewActivity.java
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ */
+package com.android.customization.picker;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+
+import androidx.annotation.IntDef;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentActivity;
+
+import com.android.customization.picker.grid.GridFullPreviewFragment;
+import com.android.wallpaper.R;
+import com.android.wallpaper.widget.BottomActionBar;
+import com.android.wallpaper.widget.BottomActionBar.BottomActionBarHost;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/** Activity for full preview. */
+public class ViewOnlyFullPreviewActivity extends FragmentActivity implements BottomActionBarHost {
+
+ private static final String EXTRA_PREVIEW_SECTION = "preview_section";
+ private static final String EXTRA_PREVIEW_BUNDLE = "preview_bundle";
+
+ public static final int SECTION_STYLE = 0;
+ public static final int SECTION_GRID = 1;
+ public static final int SECTION_CLOCK = 2;
+
+ @IntDef({SECTION_STYLE, SECTION_GRID, SECTION_CLOCK})
+ @Retention(RetentionPolicy.SOURCE)
+ private @interface Section {}
+
+ /** Returns a new Intent with the provided data in the extra. */
+ public static Intent newIntent(Context packageContext, @Section int section, Bundle bundle) {
+ Intent intent = new Intent(packageContext, ViewOnlyFullPreviewActivity.class);
+ intent.putExtra(EXTRA_PREVIEW_SECTION, section);
+ intent.putExtra(EXTRA_PREVIEW_BUNDLE, bundle);
+ return intent;
+ }
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_full_preview);
+
+ final Intent intent = getIntent();
+ @Section final int section = intent.getIntExtra(EXTRA_PREVIEW_SECTION, 0);
+ final Bundle bundle = intent.getBundleExtra(EXTRA_PREVIEW_BUNDLE);
+ if (section == SECTION_GRID) {
+ showFragment(
+ GridFullPreviewFragment.newInstance(getString(R.string.grid_title), bundle));
+ }
+ }
+
+ @Override
+ public BottomActionBar getBottomActionBar() {
+ return findViewById(R.id.bottom_actionbar);
+ }
+
+ private void showFragment(Fragment fragment) {
+ getSupportFragmentManager()
+ .beginTransaction()
+ .replace(R.id.preview_fragment_container, fragment)
+ .commitNow();
+ }
+}
diff --git a/src/com/android/customization/picker/clock/ClockFragment.java b/src/com/android/customization/picker/clock/ClockFragment.java
index 48b4c0d..bc02ae3 100644
--- a/src/com/android/customization/picker/clock/ClockFragment.java
+++ b/src/com/android/customization/picker/clock/ClockFragment.java
@@ -15,8 +15,7 @@
*/
package com.android.customization.picker.clock;
-import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
-
+import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
@@ -43,7 +42,7 @@
import com.android.wallpaper.R;
import com.android.wallpaper.asset.Asset;
import com.android.wallpaper.module.InjectorProvider;
-import com.android.wallpaper.picker.ToolbarFragment;
+import com.android.wallpaper.picker.AppbarFragment;
import com.android.wallpaper.widget.PreviewPager;
import java.util.List;
@@ -51,7 +50,7 @@
/**
* Fragment that contains the main UI for selecting and applying a Clockface.
*/
-public class ClockFragment extends ToolbarFragment {
+public class ClockFragment extends AppbarFragment {
private static final String TAG = "ClockFragment";
@@ -64,7 +63,7 @@
public static ClockFragment newInstance(CharSequence title) {
ClockFragment fragment = new ClockFragment();
- fragment.setArguments(ToolbarFragment.createArguments(title));
+ fragment.setArguments(AppbarFragment.createArguments(title));
return fragment;
}
@@ -90,20 +89,8 @@
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
- View view;
- if (ADD_SCALABLE_HEADER) {
- // TODO(b/147780560): Once the temporary flag (ADD_SCALABLE_HEADER) is removed,
- // we should have a layout with the same name for portrait and landscape.
- int orientation = getResources().getConfiguration().orientation;
- view = inflater.inflate(
- orientation == ORIENTATION_LANDSCAPE
- ? R.layout.fragment_clock_picker
- : R.layout.fragment_clock_scalable_picker,
- container, /* attachToRoot */ false);
- } else {
- view = inflater.inflate(
- R.layout.fragment_clock_picker, container, /* attachToRoot */ false);
- }
+ View view = inflater.inflate(
+ R.layout.fragment_clock_picker, container, /* attachToRoot */ false);
setUpToolbar(view);
mContent = view.findViewById(R.id.content_section);
mPreviewPager = view.findViewById(R.id.clock_preview_pager);
@@ -134,7 +121,7 @@
}
private void createAdapter() {
- mPreviewPager.setAdapter(new ClockPreviewAdapter(getContext(), mSelectedOption));
+ mPreviewPager.setAdapter(new ClockPreviewAdapter(getActivity(), mSelectedOption));
}
private void setUpOptions() {
@@ -188,8 +175,8 @@
private final Asset mPreviewAsset;
- public ClockfacePreviewPage(String title, Asset previewAsset) {
- super(title);
+ public ClockfacePreviewPage(String title, Activity activity, Asset previewAsset) {
+ super(title, activity);
mPreviewAsset = previewAsset;
}
@@ -213,9 +200,10 @@
* we don't want to just scroll)
*/
private static class ClockPreviewAdapter extends BasePreviewAdapter<ClockfacePreviewPage> {
- ClockPreviewAdapter(Context context, Clockface clockface) {
- super(context, R.layout.clock_preview_card);
- addPage(new ClockfacePreviewPage(clockface.getTitle(), clockface.getPreviewAsset()));
+ ClockPreviewAdapter(Activity activity, Clockface clockface) {
+ super(activity, R.layout.clock_preview_card);
+ addPage(new ClockfacePreviewPage(
+ clockface.getTitle(), activity , clockface.getPreviewAsset()));
}
}
}
diff --git a/src/com/android/customization/picker/grid/GridFragment.java b/src/com/android/customization/picker/grid/GridFragment.java
index 7a01f26..c9af437 100644
--- a/src/com/android/customization/picker/grid/GridFragment.java
+++ b/src/com/android/customization/picker/grid/GridFragment.java
@@ -15,23 +15,34 @@
*/
package com.android.customization.picker.grid;
-import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
+import static android.app.Activity.RESULT_OK;
+
+import static com.android.customization.picker.ViewOnlyFullPreviewActivity.SECTION_GRID;
+import static com.android.customization.picker.grid.GridFullPreviewFragment.EXTRA_GRID_OPTION;
+import static com.android.customization.picker.grid.GridFullPreviewFragment.EXTRA_GRID_USES_SURFACE_VIEW;
+import static com.android.customization.picker.grid.GridFullPreviewFragment.EXTRA_WALLPAPER_INFO;
+import static com.android.wallpaper.widget.BottomActionBar.BottomAction.APPLY;
import android.app.Activity;
import android.content.Context;
+import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.Bundle;
+import android.os.Message;
+import android.os.RemoteException;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
+import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnLayoutChangeListener;
import android.view.ViewGroup;
import android.widget.ImageView;
+import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -46,15 +57,17 @@
import com.android.customization.module.ThemesUserEventLogger;
import com.android.customization.picker.BasePreviewAdapter;
import com.android.customization.picker.BasePreviewAdapter.PreviewPage;
+import com.android.customization.picker.ViewOnlyFullPreviewActivity;
import com.android.customization.widget.OptionSelectorController;
-import com.android.systemui.shared.system.SurfaceViewRequestUtils;
import com.android.wallpaper.R;
import com.android.wallpaper.asset.Asset;
import com.android.wallpaper.asset.ContentUriAsset;
import com.android.wallpaper.model.WallpaperInfo;
import com.android.wallpaper.module.CurrentWallpaperInfoFactory;
import com.android.wallpaper.module.InjectorProvider;
-import com.android.wallpaper.picker.ToolbarFragment;
+import com.android.wallpaper.picker.AppbarFragment;
+import com.android.wallpaper.util.SurfaceViewUtils;
+import com.android.wallpaper.widget.BottomActionBar;
import com.android.wallpaper.widget.PreviewPager;
import com.bumptech.glide.Glide;
@@ -65,9 +78,11 @@
/**
* Fragment that contains the UI for selecting and applying a GridOption.
*/
-public class GridFragment extends ToolbarFragment {
+public class GridFragment extends AppbarFragment {
- private static final int PREVIEW_FADE_DURATION_MS = 100;
+ static final int PREVIEW_FADE_DURATION_MS = 100;
+
+ private static final int FULL_PREVIEW_REQUEST_CODE = 1000;
private static final String TAG = "GridFragment";
@@ -80,7 +95,7 @@
public static GridFragment newInstance(CharSequence title) {
GridFragment fragment = new GridFragment();
- fragment.setArguments(ToolbarFragment.createArguments(title));
+ fragment.setArguments(AppbarFragment.createArguments(title));
return fragment;
}
@@ -98,7 +113,43 @@
private ContentLoadingProgressBar mLoading;
private View mContent;
private View mError;
+ private BottomActionBar mBottomActionBar;
private ThemesUserEventLogger mEventLogger;
+ private boolean mReloadOptionsAfterApplying;
+
+ private final Callback mApplyGridCallback = new Callback() {
+ @Override
+ public void onSuccess() {
+ mGridManager.fetchOptions(new OptionsFetchedListener<GridOption>() {
+ @Override
+ public void onOptionsLoaded(List<GridOption> options) {
+ mOptionsController.resetOptions(options);
+ mSelectedOption = getSelectedOption(options);
+ mReloadOptionsAfterApplying = true;
+ // It will trigger OptionSelectedListener#onOptionSelected.
+ mOptionsController.setSelectedOption(mSelectedOption);
+ Toast.makeText(getContext(), R.string.applied_grid_msg, Toast.LENGTH_SHORT)
+ .show();
+ // Since we disabled it when clicked apply button.
+ mBottomActionBar.enableActions();
+ mBottomActionBar.hide();
+ }
+
+ @Override
+ public void onError(@Nullable Throwable throwable) {
+ if (throwable != null) {
+ Log.e(TAG, "Error loading grid options", throwable);
+ }
+ showError();
+ }
+ }, true);
+ }
+
+ @Override
+ public void onError(@Nullable Throwable throwable) {
+ //TODO(chihhangchuang): handle
+ }
+ };
@Override
public void onAttach(Context context) {
@@ -112,20 +163,8 @@
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
- View view;
- if (ADD_SCALABLE_HEADER) {
- // TODO(b/147780560): Once the temporary flag (ADD_SCALABLE_HEADER) is removed,
- // we should have a layout with the same name for portrait and landscape.
- int orientation = getResources().getConfiguration().orientation;
- view = inflater.inflate(
- orientation == ORIENTATION_LANDSCAPE
- ? R.layout.fragment_grid_picker
- : R.layout.fragment_grid_scalable_picker,
- container, /* attachToRoot */ false);
- } else {
- view = inflater.inflate(
- R.layout.fragment_grid_picker, container, /* attachToRoot */ false);
- }
+ View view = inflater.inflate(
+ R.layout.fragment_grid_picker, container, /* attachToRoot */ false);
setUpToolbar(view);
mContent = view.findViewById(R.id.content_section);
mPreviewPager = view.findViewById(R.id.grid_preview_pager);
@@ -139,20 +178,7 @@
// Clear memory cache whenever grid fragment view is being loaded.
Glide.get(getContext()).clearMemory();
setUpOptions();
- view.findViewById(R.id.apply_button).setOnClickListener(v -> {
- mGridManager.apply(mSelectedOption, new Callback() {
- @Override
- public void onSuccess() {
- getActivity().finish();
- }
- @Override
- public void onError(@Nullable Throwable throwable) {
- //TODO(santie): handle
- }
- });
-
- });
CurrentWallpaperInfoFactory factory = InjectorProvider.getInjector()
.getCurrentWallpaperFactory(getContext().getApplicationContext());
@@ -175,6 +201,27 @@
return view;
}
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (requestCode == FULL_PREVIEW_REQUEST_CODE && resultCode == RESULT_OK) {
+ applyGridOption(data.getParcelableExtra(EXTRA_GRID_OPTION));
+ }
+ }
+
+
+ @Override
+ protected void onBottomActionBarReady(BottomActionBar bottomActionBar) {
+ mBottomActionBar = bottomActionBar;
+ mBottomActionBar.showActionsOnly(APPLY);
+ mBottomActionBar.setActionClickListener(APPLY, unused -> applyGridOption(mSelectedOption));
+ }
+
+ private void applyGridOption(GridOption gridOption) {
+ mBottomActionBar.disableActions();
+ mGridManager.apply(gridOption, mApplyGridCallback);
+ }
+
private void loadWallpaperBackground() {
if (mHomeWallpaper != null && mCardHeight > 0 && mCardWidth > 0) {
mHomeWallpaper.getThumbAsset(getContext()).decodeBitmap(mCardWidth,
@@ -205,19 +252,16 @@
mOptionsController.addListener(selected -> {
mSelectedOption = (GridOption) selected;
+ if (mReloadOptionsAfterApplying) {
+ mReloadOptionsAfterApplying = false;
+ return;
+ }
+ mBottomActionBar.show();
mEventLogger.logGridSelected(mSelectedOption);
createAdapter();
});
mOptionsController.initOptions(mGridManager);
- for (GridOption option : options) {
- if (option.isActive(mGridManager)) {
- mSelectedOption = option;
- }
- }
- // For development only, as there should always be a grid set.
- if (mSelectedOption == null) {
- mSelectedOption = options.get(0);
- }
+ mSelectedOption = getSelectedOption(options);
createAdapter();
}
@@ -231,6 +275,14 @@
}, false);
}
+ private GridOption getSelectedOption(List<GridOption> options) {
+ return options.stream()
+ .filter(option -> option.isActive(mGridManager))
+ .findAny()
+ // For development only, as there should always be a grid set.
+ .orElse(options.get(0));
+ }
+
private void hideError() {
mContent.setVisibility(View.VISIBLE);
mError.setVisibility(View.GONE);
@@ -242,6 +294,15 @@
mError.setVisibility(View.VISIBLE);
}
+ private void showFullPreview() {
+ Bundle bundle = new Bundle();
+ bundle.putParcelable(EXTRA_WALLPAPER_INFO, mHomeWallpaper);
+ bundle.putParcelable(EXTRA_GRID_OPTION, mSelectedOption);
+ bundle.putBoolean(EXTRA_GRID_USES_SURFACE_VIEW, mGridManager.usesSurfaceView());
+ Intent intent = ViewOnlyFullPreviewActivity.newIntent(getContext(), SECTION_GRID, bundle);
+ startActivityForResult(intent, FULL_PREVIEW_REQUEST_CODE);
+ }
+
private class GridPreviewPage extends PreviewPage {
private final int mPageId;
private final Asset mPreviewAsset;
@@ -254,9 +315,46 @@
private ImageView mPreview;
private SurfaceView mPreviewSurface;
+ private final SurfaceHolder.Callback mSurfaceCallback = new SurfaceHolder.Callback() {
+
+ private Surface mLastSurface;
+ private Message mCallback;
+
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+ if (mLastSurface != holder.getSurface()) {
+ mLastSurface = holder.getSurface();
+ Bundle result = mGridManager.renderPreview(
+ SurfaceViewUtils.createSurfaceViewRequest(mPreviewSurface), mName);
+ if (result != null) {
+ mPreviewSurface.setChildSurfacePackage(
+ SurfaceViewUtils.getSurfacePackage(result));
+ mCallback = SurfaceViewUtils.getCallback(result);
+ }
+ }
+ }
+
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int width,
+ int height) {}
+
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ if (mCallback != null) {
+ try {
+ mCallback.replyTo.send(mCallback);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ } finally {
+ mCallback = null;
+ }
+ }
+ }
+ };
+
private GridPreviewPage(Activity activity, int id, Uri previewUri, String name, int rows,
int cols) {
- super(null);
+ super(null, activity);
mPageId = id;
mPreviewAsset = new ContentUriAsset(activity, previewUri,
RequestOptions.fitCenterTransform());
@@ -271,6 +369,8 @@
super.setCard(card);
mPreview = card.findViewById(R.id.grid_preview_image);
mPreviewSurface = card.findViewById(R.id.grid_preview_surface);
+ // PreviewSurface is the top of its window(card view), due to #setZOrderOnTop(true).
+ mPreviewSurface.setOnClickListener(view -> showFullPreview());
}
public void bindPreviewContent() {
@@ -281,21 +381,7 @@
mPreviewSurface.setVisibility(usesSurfaceViewForPreview ? View.VISIBLE : View.GONE);
if (usesSurfaceViewForPreview) {
mPreviewSurface.setZOrderOnTop(true);
- mPreviewSurface.getHolder().addCallback(new SurfaceHolder.Callback() {
- @Override
- public void surfaceCreated(SurfaceHolder holder) {
- Bundle bundle = SurfaceViewRequestUtils.createSurfaceBundle(
- mPreviewSurface);
- mGridManager.renderPreview(bundle, mName);
- }
-
- @Override
- public void surfaceChanged(SurfaceHolder holder, int format, int width,
- int height) {}
-
- @Override
- public void surfaceDestroyed(SurfaceHolder holder) {}
- });
+ mPreviewSurface.getHolder().addCallback(mSurfaceCallback);
} else {
mPreviewAsset.loadDrawableWithTransition(mActivity,
mPreview /* imageView */,
diff --git a/src/com/android/customization/picker/grid/GridFullPreviewFragment.java b/src/com/android/customization/picker/grid/GridFullPreviewFragment.java
new file mode 100644
index 0000000..29d74de
--- /dev/null
+++ b/src/com/android/customization/picker/grid/GridFullPreviewFragment.java
@@ -0,0 +1,360 @@
+/*
+ * 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.
+ */
+package com.android.customization.picker.grid;
+
+import static android.app.Activity.RESULT_OK;
+import static android.view.View.MeasureSpec.EXACTLY;
+import static android.view.View.MeasureSpec.makeMeasureSpec;
+
+import static com.android.customization.picker.grid.GridFragment.PREVIEW_FADE_DURATION_MS;
+import static com.android.wallpaper.widget.BottomActionBar.BottomAction.APPLY;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.graphics.Rect;
+import android.graphics.RectF;
+import android.os.Bundle;
+import android.os.Message;
+import android.os.RemoteException;
+import android.service.wallpaper.WallpaperService;
+import android.util.DisplayMetrics;
+import android.view.LayoutInflater;
+import android.view.Surface;
+import android.view.SurfaceControlViewHost;
+import android.view.SurfaceHolder;
+import android.view.SurfaceView;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.cardview.widget.CardView;
+import androidx.core.content.ContextCompat;
+
+import com.android.customization.model.grid.GridOption;
+import com.android.customization.model.grid.GridOptionsManager;
+import com.android.customization.model.grid.LauncherGridOptionsProvider;
+import com.android.customization.module.CustomizationInjector;
+import com.android.customization.module.ThemesUserEventLogger;
+import com.android.wallpaper.R;
+import com.android.wallpaper.asset.Asset;
+import com.android.wallpaper.asset.ContentUriAsset;
+import com.android.wallpaper.model.LiveWallpaperInfo;
+import com.android.wallpaper.model.WallpaperInfo;
+import com.android.wallpaper.module.InjectorProvider;
+import com.android.wallpaper.picker.AppbarFragment;
+import com.android.wallpaper.util.SizeCalculator;
+import com.android.wallpaper.util.SurfaceViewUtils;
+import com.android.wallpaper.util.WallpaperConnection;
+import com.android.wallpaper.widget.BottomActionBar;
+import com.android.wallpaper.widget.LiveTileOverlay;
+
+import com.bumptech.glide.request.RequestOptions;
+
+/** A Fragment for grid full preview page. */
+public class GridFullPreviewFragment extends AppbarFragment {
+
+ static final String EXTRA_WALLPAPER_INFO = "wallpaper_info";
+ static final String EXTRA_GRID_OPTION = "grid_option";
+ static final String EXTRA_GRID_USES_SURFACE_VIEW = "uses_surface_view";
+
+ private final Rect mPreviewLocalRect = new Rect();
+ private final Rect mPreviewGlobalRect = new Rect();
+ private final int[] mLivePreviewLocation = new int[2];
+
+ private GridOptionsManager mGridManager;
+ private WallpaperInfo mWallpaper;
+ private GridOption mGridOption;
+ private boolean mUsesSurfaceView;
+
+ private CardView mCardView;
+ private ImageView mHomePreview;
+ private SurfaceView mGridOptionSurface;
+ private SurfaceView mWallpaperSurface;
+ private WallpaperConnection mWallpaperConnection;
+
+ // Home workspace surface is behind the app window, and so must the home image wallpaper like
+ // the live wallpaper. This view is rendered on mWallpaperSurface for home image wallpaper.
+ private ImageView mHomeImageWallpaper;
+
+ /**
+ * Returns a new {@link GridFullPreviewFragment} with the provided title and bundle arguments
+ * set.
+ */
+ public static GridFullPreviewFragment newInstance(CharSequence title, Bundle intentBundle) {
+ GridFullPreviewFragment fragment = new GridFullPreviewFragment();
+ Bundle bundle = new Bundle();
+ bundle.putAll(AppbarFragment.createArguments(title));
+ bundle.putAll(intentBundle);
+ fragment.setArguments(bundle);
+ return fragment;
+ }
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mWallpaper = getArguments().getParcelable(EXTRA_WALLPAPER_INFO);
+ mGridOption = getArguments().getParcelable(EXTRA_GRID_OPTION);
+ mUsesSurfaceView = getArguments().getBoolean(EXTRA_GRID_USES_SURFACE_VIEW);
+
+ CustomizationInjector injector = (CustomizationInjector) InjectorProvider.getInjector();
+ ThemesUserEventLogger eventLogger = (ThemesUserEventLogger) injector.getUserEventLogger(
+ getContext());
+
+ mGridManager = new GridOptionsManager(new LauncherGridOptionsProvider(getContext(),
+ getString(R.string.grid_control_metadata_name)),
+ eventLogger);
+ }
+
+ @Nullable
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
+ @Nullable Bundle savedInstanceState) {
+ View view = inflater.inflate(
+ R.layout.fragment_grid_full_preview, container, /* attachToRoot */ false);
+ setUpToolbar(view);
+
+ mCardView = view.findViewById(R.id.grid_full_preview_card);
+ mHomePreview = view.findViewById(R.id.grid_full_preview_image);
+ mGridOptionSurface = view.findViewById(R.id.grid_full_preview_option_surface);
+ mWallpaperSurface = view.findViewById(R.id.grid_full_preview_wallpaper_surface);
+ mGridOptionSurface.setVisibility(View.GONE);
+
+ final DisplayMetrics dm = getResources().getDisplayMetrics();
+ float screenAspectRatio = (float) dm.heightPixels / dm.widthPixels;
+
+ 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) {
+ int cardWidth = (int) (mCardView.getMeasuredHeight() / screenAspectRatio);
+ ViewGroup.LayoutParams layoutParams = mCardView.getLayoutParams();
+ layoutParams.width = cardWidth;
+ mCardView.setLayoutParams(layoutParams);
+ mCardView.setRadius(SizeCalculator.getPreviewCornerRadius(
+ getActivity(), mCardView.getMeasuredWidth()));
+ view.removeOnLayoutChangeListener(this);
+ }
+ });
+ return view;
+ }
+
+ @Override
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ updateWallpaperSurface();
+ updateWorkspaceSurface();
+ }
+
+ @Override
+ protected void onBottomActionBarReady(BottomActionBar bottomActionBar) {
+ bottomActionBar.bindBackButtonToSystemBackKey(getActivity());
+ bottomActionBar.showActionsOnly(APPLY);
+ bottomActionBar.setActionClickListener(APPLY, v -> finishActivityWithResultOk());
+ bottomActionBar.show();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ if (mWallpaperConnection != null) {
+ mWallpaperConnection.setVisibility(true);
+ }
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ if (mWallpaperConnection != null) {
+ mWallpaperConnection.setVisibility(false);
+ }
+ }
+
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
+ LiveTileOverlay.INSTANCE.detach(mHomePreview.getOverlay());
+ if (mWallpaperConnection != null) {
+ mWallpaperConnection.disconnect();
+ mWallpaperConnection = null;
+ }
+ }
+
+ private void finishActivityWithResultOk() {
+ Activity activity = requireActivity();
+ activity.overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
+ Intent intent = new Intent();
+ intent.putExtra(EXTRA_GRID_OPTION, mGridOption);
+ activity.setResult(RESULT_OK, intent);
+ activity.finish();
+ }
+
+ private void updateWallpaperSurface() {
+ mWallpaperSurface.setZOrderMediaOverlay(false);
+ mWallpaperSurface.getHolder().addCallback(mWallpaperSurfaceCallback);
+ }
+
+ private void updateWorkspaceSurface() {
+ if (mUsesSurfaceView) {
+ mGridOptionSurface.setZOrderOnTop(true);
+ mGridOptionSurface.getHolder().addCallback(mGridOptionSurfaceCallback);
+ mGridOptionSurface.setVisibility(View.VISIBLE);
+ } else {
+ final Asset previewAsset = new ContentUriAsset(
+ getContext(),
+ mGridOption.previewImageUri,
+ RequestOptions.fitCenterTransform());
+ previewAsset.loadDrawableWithTransition(getContext(),
+ mHomePreview /* imageView */,
+ PREVIEW_FADE_DURATION_MS /* duration */,
+ null /* drawableLoadedListener */,
+ getResources().getColor(android.R.color.transparent,
+ null) /* placeHolderColorJ */);
+ }
+ }
+
+ private void setUpWallpaperPreview() {
+ if (mWallpaper != null && mHomeImageWallpaper != null) {
+ boolean renderInImageWallpaperSurface = !(mWallpaper instanceof LiveWallpaperInfo);
+ mWallpaper.getThumbAsset(getContext())
+ .loadPreviewImage(getActivity(),
+ renderInImageWallpaperSurface ? mHomeImageWallpaper : mHomePreview,
+ getResources().getColor(R.color.secondary_color));
+ LiveTileOverlay.INSTANCE.detach(mHomePreview.getOverlay());
+ if (mWallpaper instanceof LiveWallpaperInfo) {
+ mWallpaper.getThumbAsset(getContext().getApplicationContext())
+ .loadPreviewImage(
+ getActivity(),
+ mHomeImageWallpaper,
+ getContext().getColor(R.color.secondary_color));
+ setUpLiveWallpaperPreview(mWallpaper);
+ } else {
+ if (mWallpaperConnection != null) {
+ mWallpaperConnection.disconnect();
+ mWallpaperConnection = null;
+ }
+ }
+ }
+ }
+
+ private void setUpLiveWallpaperPreview(WallpaperInfo homeWallpaper) {
+ Activity activity = getActivity();
+ if (activity == null) {
+ return;
+ }
+
+ if (mWallpaperConnection != null) {
+ mWallpaperConnection.disconnect();
+ }
+
+ mHomePreview.getLocationOnScreen(mLivePreviewLocation);
+ mPreviewGlobalRect.set(0, 0, mHomePreview.getMeasuredWidth(),
+ mHomePreview.getMeasuredHeight());
+ mPreviewLocalRect.set(mPreviewGlobalRect);
+ mPreviewGlobalRect.offset(mLivePreviewLocation[0], mLivePreviewLocation[1]);
+
+ mWallpaperConnection = new WallpaperConnection(
+ getWallpaperIntent(homeWallpaper.getWallpaperComponent()), activity,
+ new WallpaperConnection.WallpaperConnectionListener() {
+ @Override
+ public void onEngineShown() {}
+ }, mPreviewGlobalRect);
+
+ LiveTileOverlay.INSTANCE.update(new RectF(mPreviewLocalRect), mCardView.getRadius());
+
+ mWallpaperConnection.setVisibility(true);
+ mHomePreview.post(() -> {
+ if (!mWallpaperConnection.connect()) {
+ mWallpaperConnection = null;
+ LiveTileOverlay.INSTANCE.detach(mHomePreview.getOverlay());
+ }
+ });
+ }
+
+ private Intent getWallpaperIntent(android.app.WallpaperInfo info) {
+ return new Intent(WallpaperService.SERVICE_INTERFACE)
+ .setClassName(info.getPackageName(), info.getServiceName());
+ }
+
+ private final SurfaceHolder.Callback mGridOptionSurfaceCallback = new SurfaceHolder.Callback() {
+
+ private Surface mLastSurface;
+ private Message mCallback;
+
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+ if (mLastSurface != holder.getSurface()) {
+ mLastSurface = holder.getSurface();
+ Bundle result = mGridManager.renderPreview(
+ SurfaceViewUtils.createSurfaceViewRequest(mGridOptionSurface),
+ mGridOption.name);
+ if (result != null) {
+ mGridOptionSurface.setChildSurfacePackage(
+ SurfaceViewUtils.getSurfacePackage(result));
+ mCallback = SurfaceViewUtils.getCallback(result);
+ }
+ }
+ }
+
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {}
+
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ if (mCallback != null) {
+ try {
+ mCallback.replyTo.send(mCallback);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ } finally {
+ mCallback = null;
+ }
+ }
+ }
+ };
+
+ private final SurfaceHolder.Callback mWallpaperSurfaceCallback = new SurfaceHolder.Callback() {
+
+ private Surface mLastSurface;
+
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+ if (mLastSurface != holder.getSurface()) {
+ mLastSurface = holder.getSurface();
+ mHomeImageWallpaper = new ImageView(getContext());
+ mHomeImageWallpaper.setBackgroundColor(
+ ContextCompat.getColor(getContext(), R.color.primary_color));
+ mHomeImageWallpaper.measure(makeMeasureSpec(mHomePreview.getWidth(), EXACTLY),
+ makeMeasureSpec(mHomePreview.getHeight(), EXACTLY));
+ mHomeImageWallpaper.layout(0, 0, mHomePreview.getWidth(), mHomePreview.getHeight());
+
+ SurfaceControlViewHost host = new SurfaceControlViewHost(getContext(),
+ getContext().getDisplay(), mWallpaperSurface.getHostToken());
+ host.setView(mHomeImageWallpaper, mHomeImageWallpaper.getWidth(),
+ mHomeImageWallpaper.getHeight());
+ mWallpaperSurface.setChildSurfacePackage(host.getSurfacePackage());
+ }
+ setUpWallpaperPreview();
+ }
+
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {}
+
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {}
+ };
+}
diff --git a/src/com/android/customization/picker/theme/CustomThemeActivity.java b/src/com/android/customization/picker/theme/CustomThemeActivity.java
index fe537ba..6173b3d 100644
--- a/src/com/android/customization/picker/theme/CustomThemeActivity.java
+++ b/src/com/android/customization/picker/theme/CustomThemeActivity.java
@@ -53,7 +53,6 @@
import com.android.customization.picker.theme.CustomThemeStepFragment.CustomThemeComponentStepHost;
import com.android.wallpaper.R;
import com.android.wallpaper.module.InjectorProvider;
-import com.android.wallpaper.module.WallpaperSetter;
import org.json.JSONException;
@@ -106,8 +105,6 @@
mThemeManager = injector.getThemeManager(
new DefaultThemeProvider(this, injector.getCustomizationPreferences(this)),
this,
- new WallpaperSetter(injector.getWallpaperPersister(this),
- injector.getPreferences(this), mUserEventLogger, false),
new OverlayManagerCompat(this),
mUserEventLogger);
mThemeManager.fetchOptions(null, false);
diff --git a/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java b/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java
index f6471f0..b2217aa 100644
--- a/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java
+++ b/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java
@@ -15,27 +15,20 @@
*/
package com.android.customization.picker.theme;
-import android.app.AlertDialog;
-import android.content.Context;
-import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.LayoutInflater;
-import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.StringRes;
import androidx.recyclerview.widget.RecyclerView;
-import com.android.customization.model.theme.custom.CustomThemeManager;
import com.android.customization.model.theme.custom.ThemeComponentOption;
import com.android.customization.model.theme.custom.ThemeComponentOptionProvider;
import com.android.customization.widget.OptionSelectorController;
import com.android.wallpaper.R;
-import com.android.wallpaper.picker.ToolbarFragment;
+import com.android.wallpaper.picker.AppbarFragment;
public class CustomThemeComponentFragment extends CustomThemeStepFragment {
private static final String ARG_USE_GRID_LAYOUT = "CustomThemeComponentFragment.use_grid";;
@@ -48,7 +41,7 @@
public static CustomThemeComponentFragment newInstance(CharSequence toolbarTitle, int position,
int titleResId, boolean allowGridLayout) {
CustomThemeComponentFragment fragment = new CustomThemeComponentFragment();
- Bundle arguments = ToolbarFragment.createArguments(toolbarTitle);
+ Bundle arguments = AppbarFragment.createArguments(toolbarTitle);
arguments.putInt(ARG_KEY_POSITION, position);
arguments.putInt(ARG_KEY_TITLE_RES_ID, titleResId);
arguments.putBoolean(ARG_USE_GRID_LAYOUT, allowGridLayout);
diff --git a/src/com/android/customization/picker/theme/CustomThemeNameFragment.java b/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
index e21fc80..45e4324 100644
--- a/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
+++ b/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
@@ -42,14 +42,14 @@
import com.android.wallpaper.asset.BitmapCachingAsset;
import com.android.wallpaper.module.CurrentWallpaperInfoFactory;
import com.android.wallpaper.module.InjectorProvider;
-import com.android.wallpaper.picker.ToolbarFragment;
+import com.android.wallpaper.picker.AppbarFragment;
public class CustomThemeNameFragment extends CustomThemeStepFragment {
public static CustomThemeNameFragment newInstance(CharSequence toolbarTitle, int position,
int titleResId) {
CustomThemeNameFragment fragment = new CustomThemeNameFragment();
- Bundle arguments = ToolbarFragment.createArguments(toolbarTitle);
+ Bundle arguments = AppbarFragment.createArguments(toolbarTitle);
arguments.putInt(ARG_KEY_POSITION, position);
arguments.putInt(ARG_KEY_TITLE_RES_ID, titleResId);
fragment.setArguments(arguments);
@@ -104,7 +104,6 @@
mNameEditor = view.findViewById(R.id.custom_theme_name);
mNameEditor.setText(mCustomThemeManager.getOriginalTheme().getTitle());
bindCover(view.findViewById(R.id.component_preview_content));
-
return view;
}
@@ -132,7 +131,7 @@
private void bindCover(CardView card) {
Context context = getContext();
PreviewInfo previewInfo = mCustomThemeManager.buildCustomThemePreviewInfo(context);
- mCoverPage = new ThemeCoverPage(context, getThemeName(),
+ mCoverPage = new ThemeCoverPage(getActivity(), getThemeName(),
previewInfo.resolveAccentColor(getResources()), previewInfo.icons,
previewInfo.headlineFontFamily, previewInfo.bottomSheeetCornerRadius,
previewInfo.shapeDrawable, previewInfo.shapeAppIcons, null,
diff --git a/src/com/android/customization/picker/theme/CustomThemeStepFragment.java b/src/com/android/customization/picker/theme/CustomThemeStepFragment.java
index ebf55e3..b05ebc4 100644
--- a/src/com/android/customization/picker/theme/CustomThemeStepFragment.java
+++ b/src/com/android/customization/picker/theme/CustomThemeStepFragment.java
@@ -18,9 +18,9 @@
import com.android.customization.model.theme.custom.ThemeComponentOption;
import com.android.customization.model.theme.custom.ThemeComponentOptionProvider;
import com.android.wallpaper.R;
-import com.android.wallpaper.picker.ToolbarFragment;
+import com.android.wallpaper.picker.AppbarFragment;
-abstract class CustomThemeStepFragment extends ToolbarFragment {
+abstract class CustomThemeStepFragment extends AppbarFragment {
protected static final String ARG_KEY_POSITION = "CustomThemeStepFragment.position";
protected static final String ARG_KEY_TITLE_RES_ID = "CustomThemeStepFragment.title_res";
protected CustomThemeComponentStepHost mHost;
diff --git a/src/com/android/customization/picker/theme/ThemeFragment.java b/src/com/android/customization/picker/theme/ThemeFragment.java
index b5c68e5..e04d8d2 100644
--- a/src/com/android/customization/picker/theme/ThemeFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFragment.java
@@ -15,8 +15,6 @@
*/
package com.android.customization.picker.theme;
-import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
-
import android.app.Activity;
import android.app.WallpaperColors;
import android.content.Context;
@@ -35,7 +33,6 @@
import android.view.View.OnClickListener;
import android.view.View.OnLayoutChangeListener;
import android.view.ViewGroup;
-import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.SeekBar;
@@ -63,10 +60,11 @@
import com.android.wallpaper.R;
import com.android.wallpaper.asset.Asset;
import com.android.wallpaper.asset.Asset.CenterCropBitmapTask;
+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.ToolbarFragment;
+import com.android.wallpaper.picker.AppbarFragment;
import com.android.wallpaper.widget.PreviewPager;
import java.util.List;
@@ -74,7 +72,7 @@
/**
* Fragment that contains the main UI for selecting and applying a ThemeBundle.
*/
-public class ThemeFragment extends ToolbarFragment {
+public class ThemeFragment extends AppbarFragment {
private static final String TAG = "ThemeFragment";
private static final String KEY_SELECTED_THEME = "ThemeFragment.SelectedThemeBundle";
@@ -87,12 +85,11 @@
}
public static ThemeFragment newInstance(CharSequence title) {
ThemeFragment fragment = new ThemeFragment();
- fragment.setArguments(ToolbarFragment.createArguments(title));
+ fragment.setArguments(AppbarFragment.createArguments(title));
return fragment;
}
private RecyclerView mOptionsContainer;
- private CheckBox mUseMyWallpaperButton;
private OptionSelectorController<ThemeBundle> mOptionsController;
private ThemeManager mThemeManager;
private ThemesUserEventLogger mEventLogger;
@@ -102,8 +99,9 @@
private ContentLoadingProgressBar mLoading;
private View mContent;
private View mError;
- private boolean mUseMyWallpaper;
+ private boolean mUseMyWallpaper = true;
private WallpaperInfo mCurrentHomeWallpaper;
+ private Asset mCurrentWallpaperThumbAsset;
private CurrentWallpaperInfoFactory mCurrentWallpaperFactory;
private TimeTicker mTicker;
@@ -119,20 +117,8 @@
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
- View view;
- if (ADD_SCALABLE_HEADER) {
- // TODO(b/147780560): Once the temporary flag (ADD_SCALABLE_HEADER) is removed,
- // we should have a layout with the same name for portrait and landscape.
- int orientation = getResources().getConfiguration().orientation;
- view = inflater.inflate(
- orientation == ORIENTATION_LANDSCAPE
- ? R.layout.fragment_theme_picker
- : R.layout.fragment_theme_scalable_picker,
- container, /* attachToRoot */ false);
- } else {
- view = inflater.inflate(
- R.layout.fragment_theme_picker, container, /* attachToRoot */ false);
- }
+ View view = inflater.inflate(
+ R.layout.fragment_theme_picker, container, /* attachToRoot */ false);
setUpToolbar(view);
mContent = view.findViewById(R.id.content_section);
@@ -145,8 +131,6 @@
view.findViewById(R.id.apply_button).setOnClickListener(v -> {
applyTheme();
});
- mUseMyWallpaperButton = view.findViewById(R.id.use_my_wallpaper);
- mUseMyWallpaperButton.setOnCheckedChangeListener(this::onUseMyWallpaperCheckChanged);
setUpOptions(savedInstanceState);
return view;
@@ -220,32 +204,23 @@
super.onActivityResult(requestCode, resultCode, data);
}
- private void onUseMyWallpaperCheckChanged(CompoundButton checkbox, boolean checked) {
- mUseMyWallpaper = checked;
- reloadWallpaper();
- }
-
private void reloadWallpaper() {
mCurrentWallpaperFactory.createCurrentWallpaperInfos(
(homeWallpaper, lockWallpaper, presentationMode) -> {
mCurrentHomeWallpaper = homeWallpaper;
- if (mSelectedTheme != null) {
- if (mUseMyWallpaper || (mSelectedTheme instanceof CustomTheme)) {
- mSelectedTheme.setOverrideThemeWallpaper(homeWallpaper);
- } else {
- mSelectedTheme.setOverrideThemeWallpaper(null);
- }
- if (mAdapter != null) {
- mAdapter.rebindWallpaperIfAvailable();
- }
+ mCurrentWallpaperThumbAsset = new BitmapCachingAsset(getContext(),
+ mCurrentHomeWallpaper.getThumbAsset(getContext()));
+ if (mSelectedTheme != null && mAdapter != null) {
+ mAdapter.setWallpaperAsset(mCurrentWallpaperThumbAsset);
+ mAdapter.rebindWallpaperIfAvailable();
}
}, false);
}
private void createAdapter(List<ThemeBundle> options) {
mAdapter = new ThemePreviewAdapter(getActivity(), mSelectedTheme,
- mSelectedTheme instanceof CustomTheme ? this::onEditClicked : null,
- new PreloadWallpapersLayoutListener(options));
+ mCurrentWallpaperThumbAsset,
+ mSelectedTheme instanceof CustomTheme ? this::onEditClicked : null);
mPreviewPager.setAdapter(mAdapter);
}
@@ -255,11 +230,6 @@
}
}
- private void updateButtonsVisibility() {
- mUseMyWallpaperButton.setVisibility(mSelectedTheme instanceof CustomTheme
- ? View.INVISIBLE : View.VISIBLE);
- }
-
private void hideError() {
mContent.setVisibility(View.VISIBLE);
mError.setVisibility(View.GONE);
@@ -292,7 +262,6 @@
mEventLogger.logThemeSelected(mSelectedTheme,
selected instanceof CustomTheme);
createAdapter(options);
- updateButtonsVisibility();
}
});
mOptionsController.initOptions(mThemeManager);
@@ -384,11 +353,12 @@
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;
- ThemePreviewAdapter(Activity activity, ThemeBundle theme,
- @Nullable OnClickListener editClickListener,
- @Nullable OnLayoutChangeListener coverCardLayoutListener) {
+ ThemePreviewAdapter(Activity activity, ThemeBundle theme, @Nullable Asset wallpaperAsset,
+ @Nullable OnClickListener editClickListener) {
super(activity, R.layout.theme_preview_card);
+ mWallpaperAsset = wallpaperAsset;
final Resources res = activity.getResources();
final PreviewInfo previewInfo = theme.getPreviewInfo();
@@ -397,14 +367,14 @@
: null;
WallpaperPreviewLayoutListener wallpaperListener = new WallpaperPreviewLayoutListener(
- theme, previewInfo, coverScrim, true);
+ () -> mWallpaperAsset, previewInfo, coverScrim, true);
addPage(new ThemeCoverPage(activity, theme.getTitle(),
previewInfo.resolveAccentColor(res), previewInfo.icons,
previewInfo.headlineFontFamily, previewInfo.bottomSheeetCornerRadius,
previewInfo.shapeDrawable, previewInfo.shapeAppIcons, editClickListener,
mColorButtonIds, mColorTileIds, mColorTileIconIds, mShapeIconIds,
- wallpaperListener, coverCardLayoutListener));
+ wallpaperListener));
addPage(new ThemePreviewPage(activity, R.string.preview_name_font, R.drawable.ic_font,
R.layout.preview_card_font_content,
previewInfo.resolveAccentColor(res)) {
@@ -501,31 +471,6 @@
}
});
}
- if (previewInfo.wallpaperAsset != null) {
- addPage(new ThemePreviewPage(activity, R.string.preview_name_wallpaper,
- R.drawable.ic_nav_wallpaper, R.layout.preview_card_wallpaper_content,
- previewInfo.resolveAccentColor(res)) {
-
- private final WallpaperPreviewLayoutListener mListener =
- new WallpaperPreviewLayoutListener(theme, previewInfo, null, false);
-
- @Override
- protected boolean containsWallpaper() {
- return true;
- }
-
- @Override
- protected void bindBody(boolean forceRebind) {
- if (card == null) {
- return;
- }
- card.addOnLayoutChangeListener(mListener);
- if (forceRebind) {
- card.requestLayout();
- }
- }
- });
- }
}
public void rebindWallpaperIfAvailable() {
@@ -544,15 +489,23 @@
}
}
+ public void setWallpaperAsset(Asset wallpaperAsset) {
+ mWallpaperAsset = wallpaperAsset;
+ }
+
private static class WallpaperPreviewLayoutListener implements OnLayoutChangeListener {
- private final ThemeBundle mTheme;
+ interface WallpaperPreviewAssetProvider {
+ Asset getAsset();
+ }
+ private final WallpaperPreviewAssetProvider mWallpaperPreviewAssetProvider;
private final PreviewInfo mPreviewInfo;
private final Drawable mScrim;
private final boolean mIsTranslucent;
- public WallpaperPreviewLayoutListener(ThemeBundle theme, PreviewInfo previewInfo,
- Drawable scrim, boolean translucent) {
- mTheme = theme;
+ WallpaperPreviewLayoutListener(
+ WallpaperPreviewAssetProvider wallpaperPreviewAssetProvider,
+ PreviewInfo previewInfo, Drawable scrim, boolean translucent) {
+ mWallpaperPreviewAssetProvider = wallpaperPreviewAssetProvider;
mPreviewInfo = previewInfo;
mScrim = scrim;
mIsTranslucent = translucent;
@@ -564,8 +517,7 @@
int targetWidth = right - left;
int targetHeight = bottom - top;
if (targetWidth > 0 && targetHeight > 0) {
- Asset wallpaperPreviewAsset = mTheme.getWallpaperPreviewAsset(
- view.getContext());
+ Asset wallpaperPreviewAsset = mWallpaperPreviewAssetProvider.getAsset();
if (wallpaperPreviewAsset != null) {
wallpaperPreviewAsset.decodeBitmap(
targetWidth, targetHeight,
@@ -611,41 +563,4 @@
}
}
}
-
- /**
- * Runs only once after the card size is known, and requests decoding wallpaper bitmaps
- * for all the options, to warm-up the bitmap cache.
- */
- private static class PreloadWallpapersLayoutListener implements OnLayoutChangeListener {
- private static boolean alreadyRunOnce;
- private final List<ThemeBundle> mOptions;
-
- public PreloadWallpapersLayoutListener(List<ThemeBundle> options) {
- mOptions = options;
- }
-
- @Override
- public void onLayoutChange(View view, int left, int top, int right,
- int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
- if (alreadyRunOnce) {
- view.removeOnLayoutChangeListener(this);
- return;
- }
- int targetWidth = right - left;
- int targetHeight = bottom - top;
- if (targetWidth > 0 && targetHeight > 0) {
- for (ThemeBundle theme : mOptions) {
- if (theme instanceof CustomTheme && !((CustomTheme) theme).isDefined()) {
- continue;
- }
- Asset wallpaperAsset = theme.getWallpaperPreviewAsset(view.getContext());
- if (wallpaperAsset != null) {
- wallpaperAsset.decodeBitmap(targetWidth, targetHeight, bitmap -> {});
- }
- }
- view.removeOnLayoutChangeListener(this);
- alreadyRunOnce = true;
- }
- }
- }
}
diff --git a/src/com/android/customization/picker/theme/ThemePreviewPage.java b/src/com/android/customization/picker/theme/ThemePreviewPage.java
index c3af91c..b8152d9 100644
--- a/src/com/android/customization/picker/theme/ThemePreviewPage.java
+++ b/src/com/android/customization/picker/theme/ThemePreviewPage.java
@@ -1,6 +1,6 @@
package com.android.customization.picker.theme;
-import android.content.Context;
+import android.app.Activity;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Typeface;
@@ -45,21 +45,20 @@
final int accentColor;
protected final LayoutInflater inflater;
- public ThemePreviewPage(Context context, @StringRes int titleResId,
- @DrawableRes int iconSrc, @LayoutRes int contentLayoutRes,
- @ColorInt int accentColor) {
- super(null);
+ 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 = context.getResources().getDrawable(iconSrc, context.getTheme());
- int size = context.getResources().getDimensionPixelSize(R.dimen.card_header_icon_size);
+ 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(context);
+ this.inflater = LayoutInflater.from(activity);
}
@Override
@@ -106,15 +105,17 @@
private final int mCornerRadius;
private final ColorStateList mTintList;
- public ThemeCoverPage(Context context, String title, int accentColor, List<Drawable> icons,
+ 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(context, 0, 0, R.layout.preview_card_cover_content, accentColor);
- mRes = context.getResources();
+ super(activity, 0, 0, R.layout.preview_card_cover_content,
+ accentColor);
+ mRes = activity.getResources();
mTitle = title;
mHeadlineFont = headlineFont;
mIcons = icons;
@@ -179,7 +180,6 @@
}
// Shape preview icons:
-
for (int i = 0; i < 3 && i < mShapeAppIcons.size(); i++) {
ImageView iconView = card.findViewById(mShapeIconIds[i]);
iconView.setBackground(mShapeAppIcons.get(i));
diff --git a/tests/src/com/android/customization/testing/TestCustomizationInjector.java b/tests/src/com/android/customization/testing/TestCustomizationInjector.java
index 10b5934..dbbdb74 100644
--- a/tests/src/com/android/customization/testing/TestCustomizationInjector.java
+++ b/tests/src/com/android/customization/testing/TestCustomizationInjector.java
@@ -13,7 +13,6 @@
import com.android.wallpaper.module.DrawableLayerResolver;
import com.android.wallpaper.module.PackageStatusNotifier;
import com.android.wallpaper.module.UserEventLogger;
-import com.android.wallpaper.module.WallpaperSetter;
import com.android.wallpaper.testing.TestInjector;
/**
@@ -38,12 +37,10 @@
public ThemeManager getThemeManager(
ThemeBundleProvider provider,
FragmentActivity activity,
- WallpaperSetter wallpaperSetter,
OverlayManagerCompat overlayManagerCompat,
ThemesUserEventLogger logger) {
if (mThemeManager == null) {
- mThemeManager = new TestThemeManager(provider, activity, wallpaperSetter,
- overlayManagerCompat, logger);
+ mThemeManager = new TestThemeManager(provider, activity, overlayManagerCompat, logger);
}
return mThemeManager;
}
diff --git a/tests/src/com/android/customization/testing/TestThemeManager.java b/tests/src/com/android/customization/testing/TestThemeManager.java
index cc8567f..c4d25fb 100644
--- a/tests/src/com/android/customization/testing/TestThemeManager.java
+++ b/tests/src/com/android/customization/testing/TestThemeManager.java
@@ -6,7 +6,6 @@
import com.android.customization.model.theme.ThemeBundleProvider;
import com.android.customization.model.theme.ThemeManager;
import com.android.customization.module.ThemesUserEventLogger;
-import com.android.wallpaper.module.WallpaperSetter;
/**
* Test implementation of {@link ThemeManager}.
@@ -18,10 +17,9 @@
public TestThemeManager(
ThemeBundleProvider provider,
FragmentActivity activity,
- WallpaperSetter wallpaperSetter,
OverlayManagerCompat overlayManagerCompat,
ThemesUserEventLogger logger) {
- super(provider, activity, wallpaperSetter, overlayManagerCompat, logger);
+ super(provider, activity, overlayManagerCompat, logger);
}
@Override