Merge "Fix WallpaperPicker styles to work properly" into ub-launcher3-qt-r1-dev
am: 2493213b98
Change-Id: If96337be7406efe6d3ea9790bcecd2038bae5572
diff --git a/res/layout/activity_single_fragment_with_toolbar.xml b/res/layout/activity_single_fragment_with_toolbar.xml
index fb4c9e6..c856197 100755
--- a/res/layout/activity_single_fragment_with_toolbar.xml
+++ b/res/layout/activity_single_fragment_with_toolbar.xml
@@ -14,20 +14,20 @@
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">
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content">
+ android:layout_height="wrap_content"
+ android:elevation="8dp">
<androidx.appcompat.widget.Toolbar
+ style="@style/Widget.AppCompat.Toolbar"
android:id="@+id/toolbar"
- style="@style/RegularToolbarStyle"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="top" />
+ android:layout_height="wrap_content"/>
</com.google.android.material.appbar.AppBarLayout>
diff --git a/res/layout/dialog_start_rotation.xml b/res/layout/dialog_start_rotation.xml
index e58fcfe..3775100 100755
--- a/res/layout/dialog_start_rotation.xml
+++ b/res/layout/dialog_start_rotation.xml
@@ -14,10 +14,10 @@
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:auto="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:orientation="vertical">
+ android:orientation="vertical"
+ android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">
<TextView
android:id="@+id/start_rotation_dialog_subhead"
@@ -41,7 +41,7 @@
android:layout_marginStart="@dimen/start_rotation_dialog_checkbox_area_margin_left"
android:orientation="horizontal">
- <androidx.appcompat.widget.AppCompatCheckBox
+ <CheckBox
android:id="@+id/start_rotation_wifi_only_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -50,8 +50,7 @@
android:layout_marginRight="@dimen/start_rotation_dialog_checkbox_margin_right"
android:minHeight="@dimen/start_rotation_dialog_checkbox_min_height"
android:text="@string/start_rotation_dialog_wifi_only_option_message"
- android:textSize="@dimen/abc_text_size_body_1_material"
- auto:buttonTint="@color/accent_color" />
+ android:textSize="@dimen/abc_text_size_body_1_material"/>
</LinearLayout>
diff --git a/res/values-notnight-v26/picker_colors.xml b/res/values-notnight-v26/picker_colors.xml
index a21500f..0cadb67 100755
--- a/res/values-notnight-v26/picker_colors.xml
+++ b/res/values-notnight-v26/picker_colors.xml
@@ -52,4 +52,5 @@
<color name="individual_picker_background_color">@color/material_white_100</color>
<color name="toolbar_icon_color">@color/text_color_dark</color>
+ <color name="toolbar_color">@color/material_white_100</color>
</resources>
diff --git a/res/values-notnight-v26/styles.xml b/res/values-notnight-v26/styles.xml
index bce1cd1..8472800 100755
--- a/res/values-notnight-v26/styles.xml
+++ b/res/values-notnight-v26/styles.xml
@@ -16,14 +16,25 @@
<resources xmlns:tools="http://schemas.android.com/tools" tools:targetApi="23">
<style name="WallpaperTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
+ <item name="colorPrimary">?android:colorPrimary</item>
<item name="colorControlActivated">?attr/colorPrimary</item>
<item name="colorControlNormal">@color/accent_color</item>
<item name="android:statusBarColor">@color/status_bar_color</item>
<item name="android:windowLightStatusBar">true</item>
- </style>
- <style name="RegularToolbarStyle" parent="@android:style/Widget.DeviceDefault.Light.ActionBar.Solid">
- <item name="android:background">@color/toolbar_color</item>
- <item name="android:theme">@style/WallpaperTheme</item>
+ <item name="actionBarSize">?android:attr/actionBarSize</item>
+ <item name="homeAsUpIndicator">@drawable/material_ic_arrow_back_black_24</item>
+
+ <item name="selectableItemBackground">?android:attr/selectableItemBackground</item>
+ <item name="dialogPreferredPadding">24dp</item>
+ <item name="colorControlHighlight">@color/ripple_material_dark</item>
+ <item name="windowActionBar">false</item>
+ <item name="windowNoTitle">true</item>
+ <item name="toolbarNavigationButtonStyle">@style/Widget.AppCompat.Toolbar.Button.Navigation</item>
+
+ <item name="android:windowActionBar">false</item>
+ <item name="android:windowNoTitle">true</item>
+ <item name="android:fitsSystemWindows">false</item>
+ <item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
</resources>
diff --git a/res/values-notnight-v27/styles.xml b/res/values-notnight-v27/styles.xml
index 4de0e9f..89c602b 100755
--- a/res/values-notnight-v27/styles.xml
+++ b/res/values-notnight-v27/styles.xml
@@ -15,15 +15,31 @@
-->
<resources xmlns:tools="http://schemas.android.com/tools" tools:targetApi="27">
- <style name="WallpaperTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
+ <style name="WallpaperTheme" parent="@android:style/Theme.DeviceDefault.Settings">
+ <item name="colorPrimary">?android:colorPrimary</item>
<item name="colorControlActivated">?attr/colorPrimary</item>
<item name="colorControlNormal">?android:attr/colorPrimary</item>
<item name="android:statusBarColor">?attr/colorPrimary</item>
<item name="android:windowLightStatusBar">true</item>
- <item name="android:navigationBarColor">#ffffffff</item>
- <item name="android:navigationBarDividerColor">#1f000000</item>
+ <item name="android:navigationBarColor">?android:colorPrimaryDark</item>
+ <item name="android:navigationBarDividerColor">@android:color/transparent</item>
<item name="android:windowLightNavigationBar">true</item>
+
+ <item name="actionBarSize">?android:attr/actionBarSize</item>
+ <item name="homeAsUpIndicator">@drawable/material_ic_arrow_back_black_24</item>
+
+ <item name="selectableItemBackground">?android:attr/selectableItemBackground</item>
+ <item name="dialogPreferredPadding">24dp</item>
+ <item name="colorControlHighlight">@color/ripple_material_dark</item>
+ <item name="windowActionBar">false</item>
+ <item name="windowNoTitle">true</item>
+ <item name="toolbarNavigationButtonStyle">@style/Widget.AppCompat.Toolbar.Button.Navigation</item>
+
+ <item name="android:windowActionBar">false</item>
+ <item name="android:windowNoTitle">true</item>
+ <item name="android:fitsSystemWindows">false</item>
+ <item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
<style name="LightDialogTheme" parent="@android:style/Theme.DeviceDefault.Light.Dialog.NoActionBar">
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 9610dd3..5c16375 100755
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -32,5 +32,5 @@
<color name="accent_color">@color/material_googblue500</color>
<color name="status_bar_color">@color/material_black_100</color>
- <color name="toolbar_color">@color/material_white_100</color>
+ <color name="toolbar_color">#000000</color>
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 511f0fb..d565b74 100755
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -15,12 +15,28 @@
-->
<resources xmlns:tools="http://schemas.android.com/tools" tools:targetApi="23">
- <style name="WallpaperTheme" parent="@style/Theme.AppCompat.NoActionBar">
+ <style name="WallpaperTheme" parent="@android:style/Theme.DeviceDefault.Settings">
+ <item name="colorPrimary">?android:colorPrimary</item>
<item name="colorControlActivated">?attr/colorPrimary</item>
<item name="android:statusBarColor">?attr/colorPrimary</item>
<item name="android:navigationBarColor">@color/translucent_black</item>
<item name="android:navigationBarDividerColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar">false</item>
+
+ <item name="actionBarSize">?android:attr/actionBarSize</item>
+ <item name="homeAsUpIndicator">@drawable/material_ic_arrow_back_black_24</item>
+
+ <item name="selectableItemBackground">?android:attr/selectableItemBackground</item>
+ <item name="dialogPreferredPadding">24dp</item>
+ <item name="colorControlHighlight">@color/ripple_material_dark</item>
+ <item name="windowActionBar">false</item>
+ <item name="windowNoTitle">true</item>
+ <item name="toolbarNavigationButtonStyle">@style/Widget.AppCompat.Toolbar.Button.Navigation</item>
+
+ <item name="android:windowActionBar">false</item>
+ <item name="android:windowNoTitle">true</item>
+ <item name="android:fitsSystemWindows">false</item>
+ <item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
<style name="WallpaperTheme.Preview" parent="@style/Theme.AppCompat.NoActionBar">
@@ -125,4 +141,10 @@
<style name="PreviewCheckboxDeviceTheme" parent="@android:style/Theme.DeviceDefault">
<item name="android:colorControlActivated">@*android:color/accent_device_default_light</item>
</style>
+
+ <style name="RegularToolbarStyle" parent="@android:style/Widget.DeviceDefault.Light.ActionBar.Solid">
+ <item name="android:background">@color/toolbar_color</item>
+ <item name="android:elevation">0dp</item>
+ <item name="android:theme">@style/WallpaperTheme</item>
+ </style>
</resources>
diff --git a/src/com/android/wallpaper/picker/StartRotationDialogFragment.java b/src/com/android/wallpaper/picker/StartRotationDialogFragment.java
index 5f39690..d5fd017 100755
--- a/src/com/android/wallpaper/picker/StartRotationDialogFragment.java
+++ b/src/com/android/wallpaper/picker/StartRotationDialogFragment.java
@@ -15,9 +15,11 @@
*/
package com.android.wallpaper.picker;
+import static com.android.wallpaper.model.WallpaperRotationInitializer.NETWORK_PREFERENCE_CELLULAR_OK;
+import static com.android.wallpaper.model.WallpaperRotationInitializer.NETWORK_PREFERENCE_WIFI_ONLY;
+
+import android.app.AlertDialog;
import android.app.Dialog;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater;
@@ -25,15 +27,15 @@
import android.widget.CheckBox;
import android.widget.TextView;
-import com.android.wallpaper.R;
-import com.android.wallpaper.model.WallpaperRotationInitializer;
-import com.android.wallpaper.module.InjectorProvider;
-
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.appcompat.app.AlertDialog;
+
+import androidx.appcompat.view.ContextThemeWrapper;
import androidx.fragment.app.DialogFragment;
+import com.android.wallpaper.R;
+import com.android.wallpaper.module.InjectorProvider;
+
/**
* Dialog which allows user to start a wallpaper rotation or cancel, as well as providing an option
* whether to rotate wallpapers on wifi-only connections or not.
@@ -76,10 +78,10 @@
LayoutInflater inflater = getActivity().getLayoutInflater();
View dialogView = inflater.inflate(R.layout.dialog_start_rotation, null);
- TextView bodyText = (TextView) dialogView.findViewById(R.id.start_rotation_dialog_subhead);
+ TextView bodyText = dialogView.findViewById(R.id.start_rotation_dialog_subhead);
bodyText.setText(Html.fromHtml(getResources().getString(getBodyTextResourceId())));
- final CheckBox wifiOnlyCheckBox = (CheckBox) dialogView.findViewById(
+ final CheckBox wifiOnlyCheckBox = dialogView.findViewById(
R.id.start_rotation_wifi_only_checkbox);
boolean hasTelephony = InjectorProvider.getInjector().getSystemFeatureChecker()
@@ -88,12 +90,8 @@
// Only show the "WiFi only" checkbox if the device supports a cellular data connection.
if (hasTelephony) {
wifiOnlyCheckBox.setChecked(mIsWifiOnlyChecked);
- wifiOnlyCheckBox.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mIsWifiOnlyChecked = wifiOnlyCheckBox.isChecked();
- }
- });
+ wifiOnlyCheckBox.setOnClickListener(
+ v -> mIsWifiOnlyChecked = wifiOnlyCheckBox.isChecked());
} else {
wifiOnlyCheckBox.setVisibility(View.GONE);
}
@@ -102,15 +100,12 @@
.setView(dialogView)
.setNegativeButton(android.R.string.cancel, null /* listener */)
.setPositiveButton(getPositiveButtonTextResourceId(),
- new OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- RotationStarter callback = (RotationStarter) getTargetFragment();
- callback.startRotation(
- mIsWifiOnlyChecked
- ? WallpaperRotationInitializer.NETWORK_PREFERENCE_WIFI_ONLY
- : WallpaperRotationInitializer.NETWORK_PREFERENCE_CELLULAR_OK);
- }
+ (dialog, which) -> {
+ RotationStarter callback = (RotationStarter) getTargetFragment();
+ callback.startRotation(
+ mIsWifiOnlyChecked
+ ? NETWORK_PREFERENCE_WIFI_ONLY
+ : NETWORK_PREFERENCE_CELLULAR_OK);
})
.create();
}
diff --git a/src/com/android/wallpaper/picker/individual/IndividualPickerActivity.java b/src/com/android/wallpaper/picker/individual/IndividualPickerActivity.java
index 9b1c53b..25b15b8 100755
--- a/src/com/android/wallpaper/picker/individual/IndividualPickerActivity.java
+++ b/src/com/android/wallpaper/picker/individual/IndividualPickerActivity.java
@@ -107,25 +107,7 @@
getSupportActionBar().setTitle(mCategory.getTitle());
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- // Use updated fancy arrow icon for O+.
- if (BuildCompat.isAtLeastO()) {
- Drawable navigationIcon = ContextCompat.getDrawable(
- this, R.drawable.material_ic_arrow_back_black_24);
-
- // This Drawable's state is shared across the app, so make a copy of it before applying a
- // color tint as not to affect other clients elsewhere in the app.
- navigationIcon = navigationIcon.getConstantState().newDrawable().mutate();
- navigationIcon.setColorFilter(
- ContextCompat.getColor(this, R.color.toolbar_icon_color), Mode.SRC_IN);
-
- // Need to explicitly check against 19 rather than using BuildCompat in order to avoid a
- // NoSuchMethodError here in UI tests running on pre-API 19 emulators.
- if (VERSION.SDK_INT >= 19) {
- navigationIcon.setAutoMirrored(true);
- }
-
- toolbar.setNavigationIcon(navigationIcon);
- }
+ toolbar.getNavigationIcon().setTint(getColor(R.color.toolbar_icon_color));
getWindow().getDecorView().setSystemUiVisibility(
getWindow().getDecorView().getSystemUiVisibility() |