Merge SP1A.210624.001
Change-Id: Id0caa49265e8ced5397387c723c39e9b4daf0c8a
diff --git a/res/drawable/fullscreen_button_background.xml b/res/drawable/fullscreen_button_background.xml
index e3a0052..87a3e1e 100644
--- a/res/drawable/fullscreen_button_background.xml
+++ b/res/drawable/fullscreen_button_background.xml
@@ -15,6 +15,12 @@
limitations under the License.
-->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:color="?android:colorControlHighlight">
- <item android:drawable="@drawable/pill_tabs_indicator_background" />
+ <item>
+ <shape android:shape="rectangle">
+ <solid android:color="?androidprv:attr/colorAccentPrimary" />
+ <corners android:radius="@dimen/separated_tabs_corner_radius" />
+ </shape>
+ </item>
</ripple>
\ No newline at end of file
diff --git a/res/drawable/pill_tabs_indicator_background.xml b/res/drawable/pill_tabs_indicator_background.xml
deleted file mode 100644
index da6ac95..0000000
--- a/res/drawable/pill_tabs_indicator_background.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2021 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.
--->
-<shape android:shape="rectangle"
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
- <solid android:color="?androidprv:attr/colorAccentPrimary" />
- <corners android:radius="@dimen/pill_tabs_corner_radius" />
-</shape>
\ No newline at end of file
diff --git a/res/drawable/pill_tabs_background.xml b/res/drawable/separated_tabs_background.xml
similarity index 61%
copy from res/drawable/pill_tabs_background.xml
copy to res/drawable/separated_tabs_background.xml
index 189d6bb..546c568 100644
--- a/res/drawable/pill_tabs_background.xml
+++ b/res/drawable/separated_tabs_background.xml
@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,9 +13,12 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<shape android:shape="rectangle"
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
- <solid android:color="?androidprv:attr/colorSurface" />
- <corners android:radius="@dimen/pill_tabs_corner_radius" />
-</shape>
\ No newline at end of file
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
+ android:insetLeft="@dimen/separated_tabs_inset_horizontal"
+ android:insetRight="@dimen/separated_tabs_inset_horizontal">
+ <shape android:shape="rectangle">
+ <solid android:color="?androidprv:attr/colorSurface" />
+ <corners android:radius="@dimen/separated_tabs_corner_radius" />
+ </shape>
+</inset>
diff --git a/res/drawable/pill_tabs_background.xml b/res/drawable/separated_tabs_indicator_background.xml
similarity index 64%
copy from res/drawable/pill_tabs_background.xml
copy to res/drawable/separated_tabs_indicator_background.xml
index 189d6bb..942810a 100644
--- a/res/drawable/pill_tabs_background.xml
+++ b/res/drawable/separated_tabs_indicator_background.xml
@@ -14,9 +14,12 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<shape android:shape="rectangle"
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
- <solid android:color="?androidprv:attr/colorSurface" />
- <corners android:radius="@dimen/pill_tabs_corner_radius" />
-</shape>
\ No newline at end of file
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
+ android:insetLeft="@dimen/separated_tabs_inset_horizontal"
+ android:insetRight="@dimen/separated_tabs_inset_horizontal">
+ <shape android:shape="rectangle">
+ <solid android:color="?androidprv:attr/colorAccentPrimary" />
+ <corners android:radius="@dimen/separated_tabs_corner_radius" />
+ </shape>
+</inset>
diff --git a/res/drawable/pill_tabs_background.xml b/res/font/clock.xml
similarity index 64%
rename from res/drawable/pill_tabs_background.xml
rename to res/font/clock.xml
index 189d6bb..8ef49bd 100644
--- a/res/drawable/pill_tabs_background.xml
+++ b/res/font/clock.xml
@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,9 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<shape android:shape="rectangle"
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
- <solid android:color="?androidprv:attr/colorSurface" />
- <corners android:radius="@dimen/pill_tabs_corner_radius" />
-</shape>
\ No newline at end of file
+<font-family xmlns:android="http://schemas.android.com/apk/res/android">
+ <font android:typeface="monospace"/>
+</font-family>
\ No newline at end of file
diff --git a/res/layout/bottom_actions_layout.xml b/res/layout/bottom_actions_layout.xml
index 91e8f1d..9102086 100644
--- a/res/layout/bottom_actions_layout.xml
+++ b/res/layout/bottom_actions_layout.xml
@@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
+<!-- Updates layout's color and background in {@code BottomActionBar} -->
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
@@ -31,7 +32,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/bottom_sheet_margin"
- android:background="@drawable/bottom_sheet_background"
android:theme="@style/WallpaperPicker.BottomPaneStyle"
android:clickable="true"
app:behavior_peekHeight="0dp"
@@ -45,7 +45,6 @@
android:layout_height="@dimen/bottom_actions_height"
android:paddingTop="@dimen/bottom_actions_top_padding"
android:paddingBottom="@dimen/bottom_actions_bottom_padding"
- android:background="?android:colorBackground"
android:theme="@style/BottomActionItemStyle"
android:layout_alignParentBottom="true"
android:layoutDirection="locale">
@@ -162,8 +161,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:background="@drawable/btn_transparent_background"
- android:textColor="?android:attr/colorAccent"
android:text="@string/bottom_action_bar_apply"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
diff --git a/res/layout/fragment_image_preview_v2.xml b/res/layout/fragment_image_preview.xml
similarity index 92%
rename from res/layout/fragment_image_preview_v2.xml
rename to res/layout/fragment_image_preview.xml
index ead02b9..46b4b88 100644
--- a/res/layout/fragment_image_preview_v2.xml
+++ b/res/layout/fragment_image_preview.xml
@@ -22,13 +22,13 @@
android:background="?android:colorBackground">
<FrameLayout
- android:id="@+id/pill_tabs_container"
+ android:id="@+id/separated_tabs_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="@dimen/bottom_actions_height"
- android:paddingHorizontal="@dimen/pill_tabs_horizontal_margin">
- <include layout="@layout/pill_tabs" />
+ android:paddingHorizontal="@dimen/separated_tabs_horizontal_margin">
+ <include layout="@layout/separated_tabs" />
</FrameLayout>
<FrameLayout
@@ -36,7 +36,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?android:attr/actionBarSize"
- android:layout_marginBottom="@dimen/bottom_actions_plus_pill_tabs">
+ android:layout_marginBottom="@dimen/bottom_actions_plus_separated_tabs">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/container"
@@ -74,7 +74,7 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_marginBottom="@dimen/fullscreen_preview_button_margin"
- android:paddingHorizontal="@dimen/pill_tabs_horizontal_margin">
+ android:paddingHorizontal="@dimen/fullscreen_preview_buttons_horizontal_margin">
<include layout="@layout/fullscreen_buttons" />
</FrameLayout>
diff --git a/res/layout/fragment_live_preview_v2.xml b/res/layout/fragment_live_preview.xml
similarity index 92%
rename from res/layout/fragment_live_preview_v2.xml
rename to res/layout/fragment_live_preview.xml
index 81c49f4..dc8273c 100644
--- a/res/layout/fragment_live_preview_v2.xml
+++ b/res/layout/fragment_live_preview.xml
@@ -22,13 +22,13 @@
android:background="?android:colorBackground">
<FrameLayout
- android:id="@+id/pill_tabs_container"
+ android:id="@+id/separated_tabs_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="@dimen/bottom_actions_height"
- android:paddingHorizontal="@dimen/pill_tabs_horizontal_margin">
- <include layout="@layout/pill_tabs" />
+ android:paddingHorizontal="@dimen/separated_tabs_horizontal_margin">
+ <include layout="@layout/separated_tabs" />
</FrameLayout>
<FrameLayout
@@ -36,7 +36,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?android:attr/actionBarSize"
- android:layout_marginBottom="@dimen/bottom_actions_plus_pill_tabs">
+ android:layout_marginBottom="@dimen/bottom_actions_plus_separated_tabs">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/live_wallpaper_preview"
@@ -78,7 +78,7 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_marginBottom="@dimen/fullscreen_preview_button_margin"
- android:paddingHorizontal="@dimen/pill_tabs_horizontal_margin">
+ android:paddingHorizontal="@dimen/fullscreen_preview_buttons_horizontal_margin">
<include layout="@layout/fullscreen_buttons" />
</FrameLayout>
diff --git a/res/layout/fullscreen_buttons.xml b/res/layout/fullscreen_buttons.xml
index 63668e7..e6a0387 100644
--- a/res/layout/fullscreen_buttons.xml
+++ b/res/layout/fullscreen_buttons.xml
@@ -17,7 +17,7 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
- android:layout_height="@dimen/pill_tabs_height"
+ android:layout_height="@dimen/separated_tabs_height"
android:layout_width="match_parent"
android:orientation="horizontal"
android:weightSum="2">
@@ -33,7 +33,7 @@
android:gravity="center"
android:text="@string/hide_ui_preview_text"
android:textAlignment="center"
- android:textAppearance="@style/PillTabsTextAppearance"
+ android:textAppearance="@style/SeparatedTabsTextAppearance"
android:textColor="?androidprv:attr/textColorOnAccent"
android:visibility="visible">
</Button>
@@ -49,7 +49,7 @@
android:gravity="center"
android:text="@string/set_wallpaper_button_text"
android:textAlignment="center"
- android:textAppearance="@style/PillTabsTextAppearance"
+ android:textAppearance="@style/SeparatedTabsTextAppearance"
android:textColor="?androidprv:attr/textColorOnAccent"
android:visibility="visible">
</Button>
diff --git a/res/layout/lock_screen_preview.xml b/res/layout/lock_screen_preview.xml
index 5a01099..8c90877 100644
--- a/res/layout/lock_screen_preview.xml
+++ b/res/layout/lock_screen_preview.xml
@@ -16,6 +16,7 @@
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/lock_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -34,19 +35,28 @@
android:textSize="@dimen/lock_screen_preview_date_text_size"
android:lineHeight="@dimen/lock_screen_preview_date_line_height" />
- <TextView
- android:id="@+id/lock_time"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:gravity="center_horizontal"
- android:fontFamily="@*android:string/config_headlineFontFamily"
- android:textColor="?androidprv:attr/colorAccentPrimary"
- android:textSize="@dimen/lock_screen_preview_time_text_size"
- android:lineHeight="@dimen/lock_screen_preview_time_line_height"
- android:elegantTextHeight="false"
- android:lineSpacingMultiplier="0.7"
- android:letterSpacing="-0.04"
- android:includeFontPadding="false" />
-
-</FrameLayout>
+ <!-- Not going to depend on dp but ratio to keep clock always at the same position. -->
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <!-- Must specify android.widget.TextView to make android:fontVariationSettings work. -->
+ <android.widget.TextView
+ android:id="@+id/lock_time"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:gravity="center_horizontal"
+ android:fontFamily="@font/clock"
+ android:textColor="?androidprv:attr/colorAccentPrimary"
+ android:typeface="monospace"
+ android:textSize="@dimen/lock_screen_preview_time_text_size"
+ android:lineSpacingMultiplier="0.7"
+ android:elegantTextHeight="false"
+ android:fontVariationSettings="'wght' 300"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintVertical_bias="0.57"/>
+ </androidx.constraintlayout.widget.ConstraintLayout>
+</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/pill_tabs.xml b/res/layout/pill_tabs.xml
deleted file mode 100644
index a4d01db..0000000
--- a/res/layout/pill_tabs.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2021 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.
--->
-<com.google.android.material.tabs.TabLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
- android:id="@+id/pill_tabs"
- android:layout_width="match_parent"
- android:layout_height="@dimen/pill_tabs_height"
- android:background="@drawable/pill_tabs_background"
- app:tabRippleColor="?android:colorControlHighlight"
- app:tabUnboundedRipple="true"
- app:tabGravity="fill"
- app:tabIndicator="@drawable/pill_tabs_indicator_background"
- app:tabIndicatorColor="?androidprv:attr/colorAccentPrimary"
- app:tabIndicatorFullWidth="true"
- app:tabIndicatorGravity="stretch"
- app:tabTextColor="@color/tab_text_color"
- app:tabSelectedTextColor="?androidprv:attr/textColorOnAccent"
- app:tabTextAppearance="@style/PillTabsTextAppearance" />
diff --git a/res/layout/separated_tabs.xml b/res/layout/separated_tabs.xml
new file mode 100644
index 0000000..1445101
--- /dev/null
+++ b/res/layout/separated_tabs.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2021 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.
+-->
+<com.google.android.material.tabs.TabLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/separated_tabs"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/separated_tabs_height"
+ app:tabBackground="@drawable/separated_tabs_background"
+ app:tabRippleColor="?android:colorControlHighlight"
+ app:tabIndicatorAnimationDuration="0"
+ app:tabIndicator="@drawable/separated_tabs_indicator_background"
+ app:tabIndicatorColor="?androidprv:attr/colorAccentPrimary"
+ app:tabIndicatorFullWidth="true"
+ app:tabIndicatorGravity="stretch"
+ app:tabGravity="fill"
+ app:tabTextColor="@color/tab_text_color"
+ app:tabSelectedTextColor="?android:textColorPrimary"
+ app:tabTextAppearance="@style/SeparatedTabsTextAppearance" />
diff --git a/res/layout/wallpaper_section_view.xml b/res/layout/wallpaper_section_view.xml
index e963b3a..54fd6d8 100644
--- a/res/layout/wallpaper_section_view.xml
+++ b/res/layout/wallpaper_section_view.xml
@@ -68,6 +68,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginVertical="@dimen/wallpaper_picker_entry_margin_vertical"
+ android:paddingHorizontal="@dimen/wallpaper_picker_entry_horizontal_padding"
android:background="@drawable/btn_transparent_background"
android:textColor="?android:attr/colorAccent"
android:drawablePadding="@dimen/wallpaper_picker_entry_drawable_padding"
diff --git a/res/values-h700dp/dimens.xml b/res/values-h700dp/dimens.xml
new file mode 100644
index 0000000..b4daf92
--- /dev/null
+++ b/res/values-h700dp/dimens.xml
@@ -0,0 +1,20 @@
+<!--
+ ~ Copyright (C) 2021 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
+ -->
+
+<resources>
+ <!-- Lock screen clock maximum font size (dp is intentional, to prevent any further scaling) -->
+ <dimen name="lock_screen_preview_time_text_size">170dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/res/values-h800dp/dimens.xml b/res/values-h800dp/dimens.xml
new file mode 100644
index 0000000..92ddfbf
--- /dev/null
+++ b/res/values-h800dp/dimens.xml
@@ -0,0 +1,20 @@
+<!--
+ ~ Copyright (C) 2021 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
+ -->
+
+<resources>
+ <!-- Lock screen clock maximum font size (dp is intentional, to prevent any further scaling) -->
+ <dimen name="lock_screen_preview_time_text_size">200dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index a1c3150..1b773ba 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -159,8 +159,8 @@
<dimen name="bottom_action_button_radius">100dp</dimen>
<!-- Whenever updating this file, ensure that
- bottom_actions_plus_pill_tabs == bottom_actions_height + pill_tabs_height -->
- <dimen name="bottom_actions_plus_pill_tabs">144dp</dimen>
+ bottom_actions_plus_separated_tabs == bottom_actions_height + separated_tabs_height -->
+ <dimen name="bottom_actions_plus_separated_tabs">144dp</dimen>
<dimen name="bottom_sheet_margin">24dp</dimen>
<dimen name="wallpaper_info_pane_padding">24dp</dimen>
@@ -173,23 +173,25 @@
<dimen name="option_title_font_text_size">14sp</dimen>
<dimen name="option_title_line_height">20dp</dimen>
- <!-- Dimensions for the pill tabs. -->
- <dimen name="pill_tabs_height">56dp</dimen>
- <dimen name="pill_tabs_corner_radius">50dp</dimen>
- <dimen name="pill_tabs_horizontal_margin">24dp</dimen>
+ <!-- Dimensions for the separated tabs. -->
+ <dimen name="separated_tabs_height">56dp</dimen>
+ <dimen name="separated_tabs_corner_radius">12dp</dimen>
+ <dimen name="separated_tabs_inset_horizontal">4dp</dimen>
+ <!-- Default page horizontal margin (24dp) - separated tabs inset horizontal (4dp) -->
+ <dimen name="separated_tabs_horizontal_margin">20dp</dimen>
<!-- Whenever updating this file, ensure that
- fullscreen_preview_button_margin == - pill_tabs_height -->
+ fullscreen_preview_button_margin == - separated_tabs_height -->
<dimen name="fullscreen_preview_button_margin">-60dp</dimen>
<dimen name="fullscreen_preview_button_margin_between">15dp</dimen>
<dimen name="fullscreen_preview_button_margin_bottom">28dp</dimen>
+ <dimen name="fullscreen_preview_buttons_horizontal_margin">24dp</dimen>
<!-- The size of lock screen widget on the full screen. -->
<dimen name="smartspace_preview_key_ambient_shadow_blur">1.5dp</dimen>
<dimen name="lock_screen_preview_date_text_size">20dp</dimen>
<dimen name="lock_screen_preview_date_line_height">24dp</dimen>
- <dimen name="lock_screen_preview_time_text_size">200dp</dimen>
- <dimen name="lock_screen_preview_time_line_height">168dp</dimen>
+ <dimen name="lock_screen_preview_time_text_size">150dp</dimen>
<!-- Common dimensions for option sections -->
<dimen name="section_container_vertical_margin">24dp</dimen>
@@ -201,5 +203,6 @@
<!-- For the wallpaper section -->
<dimen name="wallpaper_preview_margin_top">24dp</dimen>
<dimen name="wallpaper_picker_entry_drawable_padding">8dp</dimen>
+ <dimen name="wallpaper_picker_entry_horizontal_padding">16dp</dimen>
<dimen name="wallpaper_picker_entry_margin_vertical">18dp</dimen>
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 729b4ce..051ca4b 100755
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -99,7 +99,7 @@
<style name="SubtitleTextAppearance" parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Subtitle"/>
- <style name="PillTabsTextAppearance" parent="TitleTextAppearance">
+ <style name="SeparatedTabsTextAppearance" parent="TitleTextAppearance">
<item name="android:textStyle" />
<item name="textAllCaps">false</item>
<item name="android:textSize">14sp</item>
@@ -121,12 +121,7 @@
</style>
<!-- Preview attribution pane styles -->
- <style name="WallpaperPicker.BottomPaneStyle" parent="@android:style/Theme.DeviceDefault.Settings">
- <item name="tabTextAppearance">@style/WallpaperPicker.Preview.TextAppearance.NoAllCaps</item>
- <item name="tabIndicatorColor">?android:attr/textColorPrimary</item>
- <item name="tabGravity">fill</item>
- <item name="tabMaxWidth">0dp</item>
- </style>
+ <style name="WallpaperPicker.BottomPaneStyle" parent="@android:style/Theme.DeviceDefault.Settings"/>
<!-- Preview customization pane styles -->
<style name="WallpaperPicker.CustomizationPaneStyle" parent="@android:style/Theme.DeviceDefault.Settings">
@@ -182,8 +177,6 @@
<!-- Bottom action item -->
<style name="BottomActionItemStyle">
- <item name="android:tint">@color/bottom_action_button_color_tint</item>
- <item name="android:background">@drawable/bottom_action_button_background</item>
<item name="android:paddingHorizontal">@dimen/bottom_action_button_padding_horizontal</item>
</style>
diff --git a/src/com/android/wallpaper/module/DailyLoggingAlarmScheduler.java b/src/com/android/wallpaper/module/DailyLoggingAlarmScheduler.java
index e3d7b06..dd3a013 100755
--- a/src/com/android/wallpaper/module/DailyLoggingAlarmScheduler.java
+++ b/src/com/android/wallpaper/module/DailyLoggingAlarmScheduler.java
@@ -15,6 +15,8 @@
*/
package com.android.wallpaper.module;
+import static android.app.PendingIntent.FLAG_IMMUTABLE;
+
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
@@ -30,7 +32,6 @@
public class DailyLoggingAlarmScheduler {
private static final int UNUSED_REQUEST_CODE = 0;
- private static final int UNUSED_REQUEST_FLAGS = 0;
/**
* Sets a new alarm to fire approximately 24 hours after the last one, or immediately if it has
@@ -79,7 +80,7 @@
private static PendingIntent createAlarmReceiverPendingIntent(Context appContext) {
Intent intent = new Intent(appContext, DailyLoggingAlarmReceiver.class);
return PendingIntent.getBroadcast(
- appContext, UNUSED_REQUEST_CODE, intent, UNUSED_REQUEST_FLAGS);
+ appContext, UNUSED_REQUEST_CODE, intent, FLAG_IMMUTABLE);
}
}
diff --git a/src/com/android/wallpaper/picker/CustomizationPickerFragment.java b/src/com/android/wallpaper/picker/CustomizationPickerFragment.java
index 75f1b46..9710f0f 100644
--- a/src/com/android/wallpaper/picker/CustomizationPickerFragment.java
+++ b/src/com/android/wallpaper/picker/CustomizationPickerFragment.java
@@ -52,6 +52,7 @@
// Note that the section views will be displayed by the list ordering.
private final List<CustomizationSectionController<?>> mSectionControllers = new ArrayList<>();
private NestedScrollView mNestedScrollView;
+ @Nullable private Bundle mBackStackSavedInstanceState;
/** Initiates CustomizationPickerFragment instance. */
public static CustomizationPickerFragment newInstance(CharSequence title) {
@@ -62,7 +63,7 @@
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
+ @Nullable Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.collapsing_toolbar_base_layout,
container, /* attachToRoot= */ false);
setContentView(view, R.layout.fragment_customization_picker);
@@ -79,6 +80,11 @@
});
mNestedScrollView = view.findViewById(R.id.scroll_container);
+ if (mBackStackSavedInstanceState != null) {
+ savedInstanceState = mBackStackSavedInstanceState;
+ mBackStackSavedInstanceState = null;
+ }
+
initSections(savedInstanceState);
mSectionControllers.forEach(controller ->
sectionContainer.addView(controller.createView(getContext())));
@@ -103,10 +109,7 @@
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
- if (mNestedScrollView != null) {
- savedInstanceState.putInt(SCROLL_POSITION_Y, mNestedScrollView.getScrollY());
- }
- mSectionControllers.forEach(c -> c.onSaveInstanceState(savedInstanceState));
+ onSaveInstanceStateInternal(savedInstanceState);
super.onSaveInstanceState(savedInstanceState);
}
@@ -126,6 +129,13 @@
@Override
public void onDestroyView() {
+ // When add to back stack, #onDestroyView would be called, but #onDestroy wouldn't. So
+ // storing the state in variable to restore when back to foreground. If it's not a back
+ // stack case (i,e, config change), the variable would not be retained, see
+ // https://developer.android.com/guide/fragments/saving-state.
+ mBackStackSavedInstanceState = new Bundle();
+ onSaveInstanceStateInternal(mBackStackSavedInstanceState);
+
mSectionControllers.forEach(CustomizationSectionController::release);
mSectionControllers.clear();
super.onDestroyView();
@@ -142,6 +152,14 @@
fragmentManager.executePendingTransactions();
}
+ /** Saves state of the fragment. */
+ private void onSaveInstanceStateInternal(Bundle savedInstanceState) {
+ if (mNestedScrollView != null) {
+ savedInstanceState.putInt(SCROLL_POSITION_Y, mNestedScrollView.getScrollY());
+ }
+ mSectionControllers.forEach(c -> c.onSaveInstanceState(savedInstanceState));
+ }
+
private void initSections(@Nullable Bundle savedInstanceState) {
// Release and clear if any.
mSectionControllers.forEach(CustomizationSectionController::release);
diff --git a/src/com/android/wallpaper/picker/ImagePreviewFragment.java b/src/com/android/wallpaper/picker/ImagePreviewFragment.java
index feb3699..0ceaa3d 100755
--- a/src/com/android/wallpaper/picker/ImagePreviewFragment.java
+++ b/src/com/android/wallpaper/picker/ImagePreviewFragment.java
@@ -31,7 +31,9 @@
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.graphics.Color;
+import android.graphics.ColorSpace;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
@@ -77,6 +79,7 @@
import com.davemorrissey.labs.subscaleview.ImageSource;
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
+import java.io.ByteArrayOutputStream;
import java.util.Locale;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
@@ -120,7 +123,7 @@
@Override
protected int getLayoutResId() {
- return R.layout.fragment_image_preview_v2;
+ return R.layout.fragment_image_preview;
}
@Override
@@ -155,7 +158,7 @@
mLockScreenPreviewer.setDateViewVisibility(!mFullScreenAnimation.isFullScreen());
mFullScreenAnimation.setFullScreenStatusListener(
isFullScreen -> mLockScreenPreviewer.setDateViewVisibility(!isFullScreen));
- setUpTabs(view.findViewById(R.id.pill_tabs));
+ setUpTabs(view.findViewById(R.id.separated_tabs));
view.measure(makeMeasureSpec(mScreenSize.x, EXACTLY),
makeMeasureSpec(mScreenSize.y, EXACTLY));
@@ -230,21 +233,22 @@
mBottomActionBar.setActionClickListener(APPLY, this::onSetWallpaperClicked);
- View pillTabsContainer = getView().findViewById(R.id.pill_tabs_container);
+ View separatedTabsContainer = getView().findViewById(R.id.separated_tabs_container);
// Update target view's accessibility param since it will be blocked by the bottom sheet
// when expanded.
mBottomActionBar.setAccessibilityCallback(new AccessibilityCallback() {
@Override
public void onBottomSheetCollapsed() {
mContainer.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
- pillTabsContainer.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
+ separatedTabsContainer.setImportantForAccessibility(
+ IMPORTANT_FOR_ACCESSIBILITY_YES);
}
@Override
public void onBottomSheetExpanded() {
mContainer.setImportantForAccessibility(
IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
- pillTabsContainer.setImportantForAccessibility(
+ separatedTabsContainer.setImportantForAccessibility(
IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
}
@@ -347,6 +351,15 @@
@Override
public void onBitmapCropped(Bitmap croppedBitmap) {
boolean shouldRecycle = false;
+ ByteArrayOutputStream tmpOut = new ByteArrayOutputStream();
+ if (croppedBitmap.compress(Bitmap.CompressFormat.PNG, 100, tmpOut)) {
+ byte[] outByteArray = tmpOut.toByteArray();
+ BitmapFactory.Options options = new BitmapFactory.Options();
+ options.inPreferredColorSpace = ColorSpace.get(ColorSpace.Named.SRGB);
+ Bitmap decodedPng = BitmapFactory.decodeByteArray(outByteArray, 0,
+ outByteArray.length);
+ croppedBitmap = decodedPng;
+ }
if (croppedBitmap.getConfig() == Bitmap.Config.HARDWARE) {
croppedBitmap = croppedBitmap.copy(Bitmap.Config.ARGB_8888, false);
shouldRecycle = true;
@@ -571,8 +584,7 @@
mWallpaperSurface.setBackgroundColor(placeHolderColor);
mWallpaperAsset.loadLowResDrawable(activity, mLowResImageView, placeHolderColor,
- new WallpaperPreviewBitmapTransformation(
- activity.getApplicationContext(), isRtl()));
+ mPreviewBitmapTransformation);
wallpaperPreviewContainer.measure(
makeMeasureSpec(width, EXACTLY),
diff --git a/src/com/android/wallpaper/picker/LivePreviewFragment.java b/src/com/android/wallpaper/picker/LivePreviewFragment.java
index de98d7e..8b8ed44 100644
--- a/src/com/android/wallpaper/picker/LivePreviewFragment.java
+++ b/src/com/android/wallpaper/picker/LivePreviewFragment.java
@@ -117,7 +117,6 @@
private ViewGroup mPreviewContainer;
private TouchForwardingLayout mTouchForwardingLayout;
private SurfaceView mWallpaperSurface;
- private WallpaperPreviewBitmapTransformation mPreviewBitmapTransformation;
private Future<Integer> mPlaceholderColorFuture;
@Override
@@ -132,8 +131,6 @@
mDeleteIntent.setPackage(info.getPackageName());
mDeleteIntent.putExtra(EXTRA_LIVE_WALLPAPER_INFO, info);
}
- mPreviewBitmapTransformation = new WallpaperPreviewBitmapTransformation(
- requireContext().getApplicationContext(), isRtl());
String settingsActivity = getSettingsActivity(info);
if (settingsActivity != null) {
mSettingsIntent = new Intent();
@@ -203,7 +200,7 @@
mWallpaperSurfaceCallback = new WallpaperSurfaceCallback(getContext(),
mHomePreviewCard, mWallpaperSurface, mPlaceholderColorFuture, null);
- setUpTabs(view.findViewById(R.id.pill_tabs));
+ setUpTabs(view.findViewById(R.id.separated_tabs));
view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
@@ -234,9 +231,7 @@
@Override
protected void updateScreenPreview(boolean isHomeSelected) {
mWorkspaceSurface.setVisibility(isHomeSelected ? View.VISIBLE : View.INVISIBLE);
- if (!isHomeSelected) {
- mWorkspaceSurfaceCallback.cleanUp();
- }
+
mLockPreviewContainer.setVisibility(isHomeSelected ? View.INVISIBLE : View.VISIBLE);
mFullScreenAnimation.setIsHomeSelected(isHomeSelected);
@@ -360,21 +355,22 @@
mBottomActionBar.setActionClickListener(APPLY, unused -> onSetWallpaperClicked(null));
mBottomActionBar.attachViewToBottomSheetAndBindAction(mWallpaperInfoView, INFORMATION);
- View pillTabsContainer = getView().findViewById(R.id.pill_tabs_container);
+ View separatedTabsContainer = getView().findViewById(R.id.separated_tabs_container);
// Update target view's accessibility param since it will be blocked by the bottom sheet
// when expanded.
mBottomActionBar.setAccessibilityCallback(new AccessibilityCallback() {
@Override
public void onBottomSheetCollapsed() {
mPreviewContainer.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
- pillTabsContainer.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
+ separatedTabsContainer.setImportantForAccessibility(
+ IMPORTANT_FOR_ACCESSIBILITY_YES);
}
@Override
public void onBottomSheetExpanded() {
mPreviewContainer.setImportantForAccessibility(
IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
- pillTabsContainer.setImportantForAccessibility(
+ separatedTabsContainer.setImportantForAccessibility(
IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
}
});
@@ -397,8 +393,7 @@
}
}
- final String deleteAction = getDeleteAction(mWallpaper.getWallpaperComponent());
- if (TextUtils.isEmpty(deleteAction)) {
+ if (TextUtils.isEmpty(getDeleteAction(mWallpaper.getWallpaperComponent()))) {
mBottomActionBar.hideActions(DELETE);
} else {
mBottomActionBar.setActionClickListener(DELETE, listener ->
@@ -457,7 +452,7 @@
@Override
protected int getLayoutResId() {
- return R.layout.fragment_live_preview_v2;
+ return R.layout.fragment_live_preview;
}
@Override
diff --git a/src/com/android/wallpaper/picker/PreviewFragment.java b/src/com/android/wallpaper/picker/PreviewFragment.java
index 1249a61..a94e1f6 100755
--- a/src/com/android/wallpaper/picker/PreviewFragment.java
+++ b/src/com/android/wallpaper/picker/PreviewFragment.java
@@ -132,6 +132,7 @@
protected boolean mTestingModeEnabled;
protected WallpaperInfo mWallpaper;
+ protected WallpaperPreviewBitmapTransformation mPreviewBitmapTransformation;
protected WallpaperSetter mWallpaperSetter;
protected UserEventLogger mUserEventLogger;
protected BottomActionBar mBottomActionBar;
@@ -139,6 +140,10 @@
protected Intent mExploreIntent;
protected CharSequence mActionLabel;
+ // For full screen animations.
+ protected View mRootView;
+ protected FullScreenAnimation mFullScreenAnimation;
+
/**
* Staged error dialog fragments that were unable to be shown when the hosting activity didn't
* allow committing fragment transactions.
@@ -146,10 +151,6 @@
private SetWallpaperErrorDialogFragment mStagedSetWallpaperErrorDialogFragment;
private LoadWallpaperErrorDialogFragment mStagedLoadWallpaperErrorDialogFragment;
- // For full screen animations.
- protected View mRootView;
- protected FullScreenAnimation mFullScreenAnimation;
-
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -158,6 +159,8 @@
mUserEventLogger = injector.getUserEventLogger(appContext);
mWallpaper = getArguments().getParcelable(ARG_WALLPAPER);
+ mPreviewBitmapTransformation = new WallpaperPreviewBitmapTransformation(
+ appContext, isRtl());
//noinspection ResourceType
mPreviewMode = getArguments().getInt(ARG_PREVIEW_MODE);
@@ -204,7 +207,6 @@
protected void onBottomActionBarReady(BottomActionBar bottomActionBar) {
super.onBottomActionBarReady(bottomActionBar);
mBottomActionBar = bottomActionBar;
- // TODO: Extract the common code here.
setBottomActionBarAndFullScreenActions();
}
diff --git a/src/com/android/wallpaper/picker/WorkspaceSurfaceHolderCallback.java b/src/com/android/wallpaper/picker/WorkspaceSurfaceHolderCallback.java
index c469820..2661923 100644
--- a/src/com/android/wallpaper/picker/WorkspaceSurfaceHolderCallback.java
+++ b/src/com/android/wallpaper/picker/WorkspaceSurfaceHolderCallback.java
@@ -164,6 +164,12 @@
protected void requestPreview(SurfaceView workspaceSurface,
PreviewUtils.WorkspacePreviewCallback callback) {
+ if (workspaceSurface.getDisplay() == null) {
+ Log.w(TAG,
+ "No display ID, avoiding asking for workspace preview, lest WallpaperPicker "
+ + "crash");
+ return;
+ }
Bundle request = SurfaceViewUtils.createSurfaceViewRequest(workspaceSurface);
if (mWallpaperColors != null) {
request.putParcelable(KEY_WALLPAPER_COLORS, mWallpaperColors);
diff --git a/src/com/android/wallpaper/util/FullScreenAnimation.java b/src/com/android/wallpaper/util/FullScreenAnimation.java
index b3dd69e..0a97f72 100644
--- a/src/com/android/wallpaper/util/FullScreenAnimation.java
+++ b/src/com/android/wallpaper/util/FullScreenAnimation.java
@@ -61,7 +61,7 @@
private int mWorkspaceWidth;
private int mWorkspaceHeight;
private float mBottomActionBarTranslation;
- private float mPillButtonsTranslation;
+ private float mFullScreenButtonsTranslation;
private int mStatusBarHeight;
private int mNavigationBarHeight;
private FullScreenStatusListener mFullScreenStatusListener;
@@ -144,15 +144,16 @@
return dimension;
}
- private void setViewMargins(int viewId, float marginTop, float marginBottom, boolean pillTabs) {
+ private void setViewMargins(int viewId, float marginTop, float marginBottom,
+ boolean separatedTabs) {
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
- pillTabs ? FrameLayout.LayoutParams.WRAP_CONTENT
+ separatedTabs ? FrameLayout.LayoutParams.WRAP_CONTENT
: FrameLayout.LayoutParams.MATCH_PARENT);
layoutParams.setMargins(0, Math.round(marginTop), 0, Math.round(marginBottom));
- if (pillTabs) {
+ if (separatedTabs) {
layoutParams.gravity = Gravity.BOTTOM;
}
@@ -191,13 +192,13 @@
getStatusBarHeight() + getAttributeDimension(R.attr.actionBarSize),
getNavigationBarHeight()
+ mView.getResources().getDimension(R.dimen.bottom_actions_height)
- + mView.getResources().getDimension(R.dimen.pill_tabs_height),
+ + mView.getResources().getDimension(R.dimen.separated_tabs_height),
false);
setViewMargins(R.id.bottom_action_bar_container,
0,
getNavigationBarHeight(),
false);
- setViewMargins(R.id.pill_tabs_container,
+ setViewMargins(R.id.separated_tabs_container,
0,
getNavigationBarHeight()
+ mView.getResources().getDimension(R.dimen.bottom_actions_height),
@@ -278,7 +279,7 @@
0,
Math.round(mWorkspaceHeight * HIDE_ICONS_TOP_RATIO),
mWorkspaceWidth,
- mWorkspaceHeight + Math.round(mPillButtonsTranslation / mScale)));
+ mWorkspaceHeight + Math.round(mFullScreenButtonsTranslation / mScale)));
mView.findViewById(R.id.lock_screen_preview_container).setVisibility(View.VISIBLE);
} else {
int half = mWorkspaceHeight / 2;
@@ -378,12 +379,12 @@
mBottomActionBarTranslation = getNavigationBarHeight()
+ mView.getResources().getDimension(R.dimen.bottom_actions_height)
- + mView.getResources().getDimension(R.dimen.pill_tabs_height);
+ + mView.getResources().getDimension(R.dimen.separated_tabs_height);
- mPillButtonsTranslation = -(getNavigationBarHeight()
+ mFullScreenButtonsTranslation = -(getNavigationBarHeight()
+ mView.getResources().getDimension(
R.dimen.fullscreen_preview_button_margin_bottom)
- + mView.getResources().getDimension(R.dimen.pill_tabs_height));
+ + mView.getResources().getDimension(R.dimen.separated_tabs_height));
mScaleIsSet = true;
}
@@ -404,8 +405,8 @@
// Animation to hide some of the home screen icons.
float fromTop = toFullScreen ? 0f : HIDE_ICONS_TOP_RATIO;
float toTop = toFullScreen ? HIDE_ICONS_TOP_RATIO : 0f;
- float fromBottom = toFullScreen ? 0 : mPillButtonsTranslation / mScale;
- float toBottom = toFullScreen ? mPillButtonsTranslation / mScale : 0;
+ float fromBottom = toFullScreen ? 0 : mFullScreenButtonsTranslation / mScale;
+ float toBottom = toFullScreen ? mFullScreenButtonsTranslation / mScale : 0;
ValueAnimator animationHide = ValueAnimator.ofFloat(0f, 1f);
animationHide.addUpdateListener(animation -> {
@@ -423,7 +424,7 @@
float scale = toFullScreen ? mScale : 1f;
float offsetY = toFullScreen ? mOffsetY : 0f;
float bottomActionBarTranslation = toFullScreen ? mBottomActionBarTranslation : 0;
- float pillButtonsTranslation = toFullScreen ? mPillButtonsTranslation : 0;
+ float fullScreenButtonsTranslation = toFullScreen ? mFullScreenButtonsTranslation : 0;
View frameLayout = mView.findViewById(R.id.screen_preview_layout);
AnimatorSet animatorSet = new AnimatorSet();
@@ -433,10 +434,10 @@
ObjectAnimator.ofFloat(frameLayout, "translationY", offsetY),
ObjectAnimator.ofFloat(mView.findViewById(R.id.bottom_actionbar),
"translationY", bottomActionBarTranslation),
- ObjectAnimator.ofFloat(mView.findViewById(R.id.pill_tabs_container),
+ ObjectAnimator.ofFloat(mView.findViewById(R.id.separated_tabs_container),
"translationY", bottomActionBarTranslation),
ObjectAnimator.ofFloat(mView.findViewById(R.id.fullscreen_buttons_container),
- "translationY", pillButtonsTranslation),
+ "translationY", fullScreenButtonsTranslation),
animationRounding,
animationHide
);
diff --git a/src/com/android/wallpaper/util/WallpaperConnection.java b/src/com/android/wallpaper/util/WallpaperConnection.java
index 36bd49d..06b4619 100644
--- a/src/com/android/wallpaper/util/WallpaperConnection.java
+++ b/src/com/android/wallpaper/util/WallpaperConnection.java
@@ -68,7 +68,7 @@
private final SurfaceView mContainerView;
private final SurfaceView mSecondContainerView;
private IWallpaperService mService;
- private IWallpaperEngine mEngine;
+ @Nullable private IWallpaperEngine mEngine;
private boolean mConnected;
private boolean mIsVisible;
private boolean mIsEngineVisible;
@@ -216,6 +216,7 @@
/**
* Returns the engine handled by this WallpaperConnection
*/
+ @Nullable
public IWallpaperEngine getEngine() {
return mEngine;
}
@@ -309,6 +310,10 @@
}
private void mirrorAndReparent(SurfaceView parentSurface) {
+ if (mEngine == null) {
+ Log.i(TAG, "Engine is null, was the service disconnected?");
+ return;
+ }
try {
SurfaceControl parentSC = parentSurface.getSurfaceControl();
SurfaceControl wallpaperMirrorSC = mEngine.mirrorSurfaceControl();
diff --git a/src/com/android/wallpaper/widget/BottomActionBar.java b/src/com/android/wallpaper/widget/BottomActionBar.java
index fda4c8b..8c0169b 100644
--- a/src/com/android/wallpaper/widget/BottomActionBar.java
+++ b/src/com/android/wallpaper/widget/BottomActionBar.java
@@ -24,12 +24,16 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.Button;
import android.widget.FrameLayout;
+import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.core.widget.ImageViewCompat;
import com.android.wallpaper.R;
+import com.android.wallpaper.util.ResourceUtils;
import com.android.wallpaper.util.SizeCalculator;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
@@ -127,6 +131,7 @@
mBottomSheetView = findViewById(R.id.action_bottom_sheet);
SizeCalculator.adjustBackgroundCornerRadius(mBottomSheetView);
+ setColor(context);
mBottomSheetBehavior = (QueueStateBottomSheetBehavior<ViewGroup>) BottomSheetBehavior.from(
mBottomSheetView);
@@ -460,6 +465,26 @@
mSelectedAction = null;
}
+ /** Dynamic update color with {@code Context}. */
+ public void setColor(Context context) {
+ mBottomSheetView.setBackground(context.getDrawable(R.drawable.bottom_sheet_background));
+
+ ViewGroup actionTabs = findViewById(R.id.action_tabs);
+ actionTabs.setBackgroundColor(
+ ResourceUtils.getColorAttr(context, android.R.attr.colorBackground));
+ for (int i = 0; i < actionTabs.getChildCount(); i++) {
+ View v = actionTabs.getChildAt(i);
+ if (v instanceof ImageView) {
+ v.setBackground(context.getDrawable(R.drawable.bottom_action_button_background));
+ ImageViewCompat.setImageTintList((ImageView) v,
+ context.getColorStateList(R.color.bottom_action_button_color_tint));
+ }
+ }
+ Button applyButton = findViewById(R.id.action_apply_text_button);
+ applyButton.setBackground(context.getDrawable(R.drawable.btn_transparent_background));
+ applyButton.setTextColor(ResourceUtils.getColorAttr(context, android.R.attr.colorAccent));
+ }
+
private void updateSelectedState(BottomAction bottomAction, boolean selected) {
View bottomActionView = mActionMap.get(bottomAction);
if (bottomActionView.isSelected() == selected) {
diff --git a/src/com/android/wallpaper/widget/LockScreenPreviewer.java b/src/com/android/wallpaper/widget/LockScreenPreviewer.java
index 0c0d078..282a899 100644
--- a/src/com/android/wallpaper/widget/LockScreenPreviewer.java
+++ b/src/com/android/wallpaper/widget/LockScreenPreviewer.java
@@ -21,12 +21,8 @@
import android.app.WallpaperColors;
import android.content.Context;
import android.content.res.Configuration;
-import android.graphics.Canvas;
-import android.graphics.Paint;
import android.graphics.Point;
-import android.text.SpannableString;
import android.text.format.DateFormat;
-import android.text.style.ReplacementSpan;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
@@ -35,7 +31,6 @@
import android.widget.TextView;
import androidx.annotation.MainThread;
-import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
@@ -183,55 +178,6 @@
private void updateDateTime() {
Calendar calendar = Calendar.getInstance(TimeZone.getDefault());
mLockDate.setText(DateFormat.format(mDatePattern, calendar));
- SpannableString timeWithMonospaceText = new SpannableString(
- TimeUtils.getDoubleLineFormattedTime(mContext, calendar));
- timeWithMonospaceText.setSpan(new MonospaceSpan(), /* start= */ 0,
- timeWithMonospaceText.length(), /* flag= */ 0);
- mLockTime.setText(timeWithMonospaceText);
- }
-
- /** Make text monospace without overriding the text fontFamily. */
- private static class MonospaceSpan extends ReplacementSpan {
-
- @Override
- public int getSize(@NonNull Paint paint, @NonNull CharSequence text, int start, int end,
- @Nullable Paint.FontMetricsInt fontMetricsInt) {
- if (fontMetricsInt != null) {
- paint.getFontMetricsInt(fontMetricsInt);
- }
- int count = end - start;
- if (text.charAt(start) == '\n') {
- count--;
- }
- if (text.charAt(end - 1) == '\n') {
- count--;
- }
- return getMaxCharWidth(paint, text, /* start= */ 0, text.length())
- * Math.max(count, 0);
- }
-
- @Override
- public void draw(@NonNull Canvas canvas, @NonNull CharSequence text, int start, int end,
- float x, int top, int y, int bottom, @NonNull Paint paint) {
- float[] widths = new float[end - start];
- paint.getTextWidths(text, start, end, widths);
- int maxCharWidth = getMaxCharWidth(paint, text, /* start= */ 0, text.length());
- for (int i = 0; i < end - start; ++i) {
- canvas.drawText(text, start + i, start + i + 1,
- x + maxCharWidth * i + (maxCharWidth - widths[i]) / 2, y, paint);
- }
- }
-
- private int getMaxCharWidth(Paint paint, CharSequence text, int start, int end) {
- float[] widths = new float[end - start];
- paint.getTextWidths(text, start, end, widths);
- float max = 0;
- for (float w : widths) {
- if (max < w) {
- max = w;
- }
- }
- return Math.round(max);
- }
+ mLockTime.setText(TimeUtils.getDoubleLineFormattedTime(mLockTime.getContext(), calendar));
}
}