Add bold effect to the selected button of wallpaper preview
- Also cleanup the wallpaper preview home/lockscreen button
- Mock: https://docs.google.com/presentation/d/15JadcGi5k1_0znUN_XdFpU7UxeXwxjK3Y7LxvhW5ETM/edit?ts=5eb5f9a8#slide=id.g7cc7612850_7_19
- Video: https://drive.google.com/file/d/1RmwwBov-KodRw65B48cBaBrJekZ6LmUr/view?usp=sharing
Test: Manually
Fixes: 158267263
Change-Id: I22ed252100d9a250953c59f3c3c38e253a558f42
diff --git a/res/color/full_preview_tab_text_color.xml b/res/color/full_preview_tab_text_color.xml
new file mode 100644
index 0000000..eecbccd
--- /dev/null
+++ b/res/color/full_preview_tab_text_color.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item
+ android:state_selected="false"
+ android:color="?android:attr/textColorSecondary"/>
+ <item
+ android:state_selected="true"
+ android:color="?android:colorAccent" />
+</selector>
\ No newline at end of file
diff --git a/res/layout/fragment_image_preview_v2.xml b/res/layout/fragment_image_preview_v2.xml
index 42c5b5e..55c5eba 100644
--- a/res/layout/fragment_image_preview_v2.xml
+++ b/res/layout/fragment_image_preview_v2.xml
@@ -103,35 +103,7 @@
</com.android.wallpaper.picker.TouchForwardingLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
- <LinearLayout
- android:id="@+id/tabs_container"
- android:layout_width="match_parent"
- android:layout_height="@dimen/full_preview_page_tab_height"
- android:background="@color/fullscreen_preview_background"
- android:orientation="horizontal">
- <TextView
- android:id="@+id/home"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:background="?android:attr/selectableItemBackgroundBorderless"
- android:paddingVertical="@dimen/full_preview_page_tab_padding_top"
- android:gravity="center"
- android:text="@string/home_screen_message"
- android:textColor="@color/bottom_action_button_color_tint"/>
-
- <TextView
- android:id="@+id/lock"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:background="?android:attr/selectableItemBackgroundBorderless"
- android:paddingVertical="@dimen/full_preview_page_tab_padding_top"
- android:gravity="center"
- android:text="@string/lock_screen_message"
- android:textColor="@color/bottom_action_button_color_tint"/>
-
- </LinearLayout>
+ <include layout="@layout/full_preview_tabs" />
</LinearLayout>
</FrameLayout>
diff --git a/res/layout/fragment_live_preview_v2.xml b/res/layout/fragment_live_preview_v2.xml
index b78b951..21c72ae 100644
--- a/res/layout/fragment_live_preview_v2.xml
+++ b/res/layout/fragment_live_preview_v2.xml
@@ -57,36 +57,7 @@
</com.android.wallpaper.picker.TouchForwardingLayout>
</FrameLayout>
- <LinearLayout
- android:id="@+id/tabs_container"
- android:layout_width="match_parent"
- android:layout_height="@dimen/full_preview_page_tab_height"
- android:background="@color/fullscreen_preview_background"
- android:orientation="horizontal">
-
- <TextView
- android:id="@+id/home"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:background="?android:attr/selectableItemBackgroundBorderless"
- android:gravity="center"
- android:paddingTop="@dimen/full_preview_page_tab_padding_top"
- android:paddingBottom="@dimen/full_preview_page_tab_padding_bottom"
- android:text="@string/home_screen_message"
- android:textColor="@color/bottom_action_button_color_tint"/>
- <TextView
- android:id="@+id/lock"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:background="?android:attr/selectableItemBackgroundBorderless"
- android:gravity="center"
- android:paddingTop="@dimen/full_preview_page_tab_padding_top"
- android:paddingBottom="@dimen/full_preview_page_tab_padding_bottom"
- android:text="@string/lock_screen_message"
- android:textColor="@color/bottom_action_button_color_tint"/>
- </LinearLayout>
+ <include layout="@layout/full_preview_tabs" />
</LinearLayout>
<FrameLayout
diff --git a/res/layout/full_preview_tabs.xml b/res/layout/full_preview_tabs.xml
new file mode 100644
index 0000000..0bc59f5
--- /dev/null
+++ b/res/layout/full_preview_tabs.xml
@@ -0,0 +1,45 @@
+<?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:id="@+id/tabs_container"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/full_preview_page_tab_height"
+ android:background="@color/fullscreen_preview_background"
+ android:orientation="horizontal">
+
+ <com.android.wallpaper.widget.SelectedBoldTextView
+ android:id="@+id/home"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:background="?android:attr/selectableItemBackgroundBorderless"
+ android:gravity="center"
+ android:paddingVertical="@dimen/full_preview_page_tab_padding_top"
+ android:text="@string/home_screen_message"
+ style="@style/SubtitleTextAppearance" />
+
+ <com.android.wallpaper.widget.SelectedBoldTextView
+ android:id="@+id/lock"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:background="?android:attr/selectableItemBackgroundBorderless"
+ android:gravity="center"
+ android:paddingVertical="@dimen/full_preview_page_tab_padding_top"
+ android:text="@string/lock_screen_message"
+ style="@style/SubtitleTextAppearance" />
+</LinearLayout>
diff --git a/src/com/android/wallpaper/widget/SelectedBoldTextView.java b/src/com/android/wallpaper/widget/SelectedBoldTextView.java
new file mode 100644
index 0000000..790734c
--- /dev/null
+++ b/src/com/android/wallpaper/widget/SelectedBoldTextView.java
@@ -0,0 +1,40 @@
+/*
+ * 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.wallpaper.widget;
+
+import android.content.Context;
+import android.graphics.Typeface;
+import android.util.AttributeSet;
+
+import androidx.annotation.Nullable;
+import androidx.appcompat.widget.AppCompatTextView;
+
+import com.android.wallpaper.R;
+
+/** A TextView that would update the text style to bold when selected. */
+public class SelectedBoldTextView extends AppCompatTextView {
+
+ public SelectedBoldTextView(Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ setTextColor(context.getColorStateList(R.color.full_preview_tab_text_color));
+ }
+
+ @Override
+ public void setSelected(boolean selected) {
+ super.setSelected(selected);
+ setTypeface(selected ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
+ }
+}