Change work profile switch to floating button
This is an initial CL to replace the old switch button. This CL only
focusses on introducing the new floating action button:
* Remove the work profile switch
* Add extended floating action button for switching between profiles
* Hide the button in preview mode and when an item is selected
* Hide the button in Album photos view
More specifications will follow soon
Bug: 190727775
Test: manual
Change-Id: I9231a9d13bc5e237feb137ed9c43bd5e933a8e53
Merged-In: I9231a9d13bc5e237feb137ed9c43bd5e933a8e53
(cherry picked from commit 3970fee99898cd4ab20aa8a3bacedf7b833f5c84)
diff --git a/res/drawable/ic_personal_mode.xml b/res/drawable/ic_personal_mode.xml
new file mode 100644
index 0000000..e48a4c8
--- /dev/null
+++ b/res/drawable/ic_personal_mode.xml
@@ -0,0 +1,27 @@
+<!--
+ ~ 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.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="@color/picker_profile_button_text_and_icon_color">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M19.08,4.92C15.16,1.02 8.82,1.03 4.91,4.93C1.03,8.85 1.03,15.17 4.92,19.08C6.8,20.95 9.35,22 12,22c2.65,0 5.2,-1.05 7.08,-2.92C22.97,15.16 22.98,8.83 19.08,4.92zM6.34,17.66L6.34,17.66c0.86,-0.8 3.22,-2.16 5.67,-2.16c2.45,0 4.64,1.24 5.65,2.16C14.53,20.77 9.48,20.77 6.34,17.66zM18.93,16.03c-3.99,-3.36 -9.82,-3.36 -13.82,0c-1.77,-3.07 -1.38,-7.05 1.22,-9.69c3.13,-3.12 8.21,-3.13 11.34,-0.01C20.23,8.91 20.75,12.88 18.93,16.03zM15,8.99c0,1.66 -1.34,3 -3,3c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3C13.66,5.99 15,7.34 15,8.99z"
+ android:fillType="evenOdd"/>
+</vector>
diff --git a/res/drawable/ic_work_outline.xml b/res/drawable/ic_work_outline.xml
new file mode 100644
index 0000000..9aaca27
--- /dev/null
+++ b/res/drawable/ic_work_outline.xml
@@ -0,0 +1,26 @@
+<?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.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="@color/picker_profile_button_text_and_icon_color">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M20,6h-4L16,4c0,-1.11 -0.89,-2 -2,-2h-4c-1.11,0 -2,0.89 -2,2v2L4,6c-1.11,0 -1.99,0.89 -1.99,2L2,19c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,8c0,-1.11 -0.89,-2 -2,-2zM10,4h4v2h-4L10,4zM20,19L4,19L4,8h16v11z"/>
+</vector>
diff --git a/res/layout/activity_photo_picker.xml b/res/layout/activity_photo_picker.xml
index 8807d35..688b4ec 100644
--- a/res/layout/activity_photo_picker.xml
+++ b/res/layout/activity_photo_picker.xml
@@ -35,14 +35,6 @@
app:behavior_hideable="true"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
- <Switch
- android:visibility="gone"
- android:layout_gravity="end|top"
- android:text="Work Profile"
- android:id="@+id/workprofile"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
-
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment_container"
android:layout_width="match_parent"
@@ -70,10 +62,8 @@
android:orientation="horizontal"/>
</androidx.appcompat.widget.Toolbar>
-
</com.google.android.material.appbar.AppBarLayout>
</FrameLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
-
diff --git a/res/layout/fragment_picker_tab.xml b/res/layout/fragment_picker_tab.xml
index 892e853..fbe6a30 100644
--- a/res/layout/fragment_picker_tab.xml
+++ b/res/layout/fragment_picker_tab.xml
@@ -28,6 +28,22 @@
android:drawSelectorOnTop="true"
android:overScrollMode="never"/>
+ <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
+ android:id="@+id/profile_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/picker_profile_button_margin_bottom"
+ android:layout_gravity="bottom|center"
+ android:textAppearance="@style/PickerProfileButton"
+ android:textColor="@color/picker_profile_button_text_and_icon_color"
+ android:text="@string/picker_work_profile"
+ android:visibility="gone"
+ app:backgroundTint="@color/picker_profile_button_background"
+ app:borderWidth="0dp"
+ app:elevation="3dp"
+ app:icon="@drawable/ic_work_outline"
+ />
+
<FrameLayout
android:id="@+id/picker_bottom_bar"
android:layout_width="match_parent"
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index 4d7565a..34c2d34 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -28,5 +28,7 @@
<color name="picker_toolbar_chip_text_color">#E8EAED</color>
<color name="picker_toolbar_title_color">#FFFFFF</color>
<color name="picker_message_text_color">#9AA0A6</color>
+ <color name="picker_profile_button_text_and_icon_color">#A8C7FA</color>
+ <color name="picker_profile_button_background">#1F1F1F</color>
</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index d3def67..bf7b280 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -37,4 +37,8 @@
<color name="preview_default_blue">#8AB4F8</color>
<color name="preview_default_grey">#202124</color>
<color name="preview_default_black">@android:color/black</color>
+
+ <!-- PhotoPicker Preview -->
+ <color name="picker_profile_button_text_and_icon_color">#0B57D0</color>
+ <color name="picker_profile_button_background">#E8F0FE</color>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index c911972..8e6e12f 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -65,4 +65,6 @@
<!-- PhotoPicker Preview text -->
<dimen name="preview_add_text_size">14sp</dimen>
<dimen name="preview_deselect_text_size">16sp</dimen>
+ <!-- PhotoPicker Work Profile -->
+ <dimen name="picker_profile_button_margin_bottom">32dp</dimen>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1b93546..92a6c30 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -106,6 +106,10 @@
<!-- The text of the albums chip on the toolbar for PhotoPicker. [CHAR LIMIT=30] -->
<string name="picker_albums">Albums</string>
+ <!-- The text of the switching work/personal profile in PhotoPicker. [CHAR LIMIT=30] -->
+ <string name="picker_work_profile">Switch to work</string>
+ <string name="picker_personal_profile">Switch to personal</string>
+
<!-- Text shown on the album item in PhotoPicker. [CHAR LIMIT=30] -->
<plurals name="picker_album_item_count">
<item quantity="one"><xliff:g id="count" example="1">^1</xliff:g> item</item>
diff --git a/res/values/styles_text.xml b/res/values/styles_text.xml
index e89a43e..7842c58 100644
--- a/res/values/styles_text.xml
+++ b/res/values/styles_text.xml
@@ -29,4 +29,8 @@
<item name="android:textSize">@dimen/picker_chip_text_size</item>
</style>
+ <style name="PickerProfileButton" parent="@android:style/TextAppearance.Material.Button">
+ <item name="android:textAllCaps">false</item>
+ </style>
+
</resources>