Merge "Throw IllegalArgumentException for getContentResolverForUserId" into sc-mainline-prod
diff --git a/res/color-v31/surface_light.xml b/res/color-v31/surface_light.xml
new file mode 100644
index 0000000..928a6a9
--- /dev/null
+++ b/res/color-v31/surface_light.xml
@@ -0,0 +1,18 @@
+<?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.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:color="@android:color/system_neutral1_500" android:lStar="98" />
+</selector>
diff --git a/res/color/picker_chip_background_color.xml b/res/color/picker_chip_background_color.xml
index ef6b28c..9eb418e 100644
--- a/res/color/picker_chip_background_color.xml
+++ b/res/color/picker_chip_background_color.xml
@@ -16,6 +16,6 @@
   -->
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:state_selected="true" android:color="@color/picker_highlight_color"/>
-    <item android:state_enabled="true" android:color="?android:attr/colorBackground"/>
-</selector>
\ No newline at end of file
+    <item android:state_selected="true" android:color="?attr/pickerSelectedChipBackgroundColor"/>
+    <item android:state_enabled="true" android:color="?attr/pickerChipBackgroundColor"/>
+</selector>
diff --git a/res/color/picker_chip_ripple_color.xml b/res/color/picker_chip_ripple_color.xml
index cc540bd..6264a73 100644
--- a/res/color/picker_chip_ripple_color.xml
+++ b/res/color/picker_chip_ripple_color.xml
@@ -38,4 +38,4 @@
     <item android:state_hovered="true"
           android:alpha="0.04" android:color="?android:textColorSecondary"/>
     <item android:alpha="0.00" android:color="?android:textColorSecondary"/>
-</selector>
\ No newline at end of file
+</selector>
diff --git a/res/color/picker_chip_text_color.xml b/res/color/picker_chip_text_color.xml
index f75c7c8..d9f15a8 100644
--- a/res/color/picker_chip_text_color.xml
+++ b/res/color/picker_chip_text_color.xml
@@ -16,6 +16,6 @@
   -->
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:state_selected="true" android:color="?android:colorAccent"/>
-    <item android:state_enabled="true" android:color="@color/picker_toolbar_chip_text_color"/>
-</selector>
\ No newline at end of file
+    <item android:state_selected="true" android:color="?attr/pickerSelectedChipTextColor"/>
+    <item android:state_enabled="true" android:color="?android:attr/textColorSecondary"/>
+</selector>
diff --git a/res/drawable/ic_arrow_back.xml b/res/drawable/ic_arrow_back.xml
index 1370c3b..85a418a 100644
--- a/res/drawable/ic_arrow_back.xml
+++ b/res/drawable/ic_arrow_back.xml
@@ -19,7 +19,7 @@
         android:height="24dp"
         android:viewportHeight="24"
         android:viewportWidth="24"
-        android:tint="@color/picker_toolbar_icon_color"
+        android:tint="?attr/pickerTextColor"
         android:autoMirrored="true">
     <path
         android:fillColor="@android:color/white"
diff --git a/res/drawable/ic_check_circle_filled.xml b/res/drawable/ic_check_circle_filled.xml
index 5e35ba9..6dbfcf3 100644
--- a/res/drawable/ic_check_circle_filled.xml
+++ b/res/drawable/ic_check_circle_filled.xml
@@ -20,6 +20,6 @@
         android:viewportWidth="24"
         android:viewportHeight="24">
     <path
-        android:fillColor="?android:attr/colorAccent"
+        android:fillColor="?attr/pickerSelectedColor"
         android:pathData="M12,2C6.48,2 2,6.48 2,12c0,5.52 4.48,10 10,10s10,-4.48 10,-10C22,6.48 17.52,2 12,2zM10,17l-4,-4l1.4,-1.4l2.6,2.6l6.6,-6.6L18,9L10,17z"/>
 </vector>
diff --git a/res/drawable/ic_close.xml b/res/drawable/ic_close.xml
index e82bf74..5e5e885 100644
--- a/res/drawable/ic_close.xml
+++ b/res/drawable/ic_close.xml
@@ -19,7 +19,7 @@
         android:height="24dp"
         android:viewportHeight="24"
         android:viewportWidth="24"
-        android:tint="@color/picker_toolbar_icon_color">
+        android:tint="?attr/pickerTextColor">
     <path
         android:fillColor="@android:color/white"
         android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12 19,6.41z"/>
diff --git a/res/drawable/ic_collections.xml b/res/drawable/ic_collections.xml
index ad76643..7ac707d 100644
--- a/res/drawable/ic_collections.xml
+++ b/res/drawable/ic_collections.xml
@@ -19,7 +19,7 @@
         android:height="24dp"
         android:viewportWidth="24"
         android:viewportHeight="24"
-        android:tint="?android:attr/colorAccent">
+        android:tint="?attr/pickerSelectedColor">
     <path
         android:fillColor="@android:color/white"
         android:pathData="M20,4v12L8,16L8,4h12m0,-2L8,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM2,6v14c0,1.1 0.9,2 2,2h14v-2L4,20L4,6L2,6zM15.67,11l-2.5,2.98 -1.67,-2.18L9,15h10l-3.33,-4z"/>
diff --git a/res/drawable/ic_personal_mode.xml b/res/drawable/ic_personal_mode.xml
index cf4562c..0d64a4c 100644
--- a/res/drawable/ic_personal_mode.xml
+++ b/res/drawable/ic_personal_mode.xml
@@ -19,7 +19,7 @@
         android:height="24dp"
         android:viewportWidth="24"
         android:viewportHeight="24"
-        android:tint="@color/picker_profile_button_content_color">
+        android:tint="?attr/pickerProfileButtonTextColor">
     <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"
diff --git a/res/drawable/ic_radio_button_unchecked.xml b/res/drawable/ic_radio_button_unchecked.xml
index 622010e..40a7734 100644
--- a/res/drawable/ic_radio_button_unchecked.xml
+++ b/res/drawable/ic_radio_button_unchecked.xml
@@ -20,6 +20,6 @@
         android:viewportWidth="24"
         android:viewportHeight="24">
     <path
-        android:fillColor="@android:color/white"
+        android:fillColor="@color/picker_unselected_check_color"
         android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z"/>
 </vector>
diff --git a/res/drawable/ic_work_outline.xml b/res/drawable/ic_work_outline.xml
index 71d0e45..12bf61e 100644
--- a/res/drawable/ic_work_outline.xml
+++ b/res/drawable/ic_work_outline.xml
@@ -19,7 +19,7 @@
         android:height="24dp"
         android:viewportWidth="24"
         android:viewportHeight="24"
-        android:tint="@color/picker_profile_button_content_color">
+        android:tint="?attr/pickerProfileButtonTextColor">
     <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"/>
diff --git a/res/layout/activity_photo_picker.xml b/res/layout/activity_photo_picker.xml
index 56a2920..ce0f3e8 100644
--- a/res/layout/activity_photo_picker.xml
+++ b/res/layout/activity_photo_picker.xml
@@ -30,7 +30,7 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:id="@+id/bottom_sheet"
-        android:background="?android:attr/colorBackground"
+        android:background="@color/picker_background_color"
         android:clipToOutline="true"
         app:behavior_hideable="true"
         app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
@@ -39,7 +39,7 @@
             android:id="@+id/drag_bar"
             android:layout_width="match_parent"
             android:layout_height="@dimen/picker_drag_bar_height"
-            android:background="?android:attr/colorBackground">
+            android:background="@color/picker_background_color">
 
             <ImageView
                 android:layout_width="wrap_content"
@@ -69,8 +69,8 @@
                 android:id="@+id/toolbar"
                 android:layout_width="match_parent"
                 android:layout_height="?attr/actionBarSize"
-                android:background="?android:attr/colorBackground"
-                app:titleTextColor="@color/picker_toolbar_title_color">
+                android:background="@color/picker_background_color"
+                app:titleTextColor="?attr/pickerTextColor">
 
                 <LinearLayout
                     android:id="@+id/chip_container"
diff --git a/res/layout/fragment_picker_tab.xml b/res/layout/fragment_picker_tab.xml
index 59cea08..e1590a6 100644
--- a/res/layout/fragment_picker_tab.xml
+++ b/res/layout/fragment_picker_tab.xml
@@ -64,10 +64,10 @@
         android:layout_marginBottom="@dimen/picker_profile_button_margin_bottom"
         android:layout_gravity="bottom|center"
         android:textAppearance="@style/PickerButtonTextAppearance"
-        android:textColor="@color/picker_profile_button_content_color"
+        android:textColor="?attr/pickerProfileButtonTextColor"
         android:text="@string/picker_work_profile"
         android:visibility="gone"
-        app:backgroundTint="@color/picker_profile_button_background_color"
+        app:backgroundTint="?attr/pickerProfileButtonColor"
         app:borderWidth="0dp"
         app:elevation="3dp"
         app:icon="@drawable/ic_work_outline"
@@ -87,13 +87,13 @@
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
             android:layout_marginHorizontal="@dimen/picker_bottom_bar_horizontal_gap"
-            android:layout_gravity="start"
-            android:paddingVertical="@dimen/picker_bottom_bar_vertical_gap"
+            android:layout_gravity="start|center_vertical"
+            android:paddingVertical="@dimen/picker_bottom_bar_buttons_vertical_gap"
             android:drawableLeft="@drawable/ic_collections"
             android:text="@string/picker_view_selected"
             android:textAllCaps="false"
-            android:textColor="?android:attr/colorAccent"
-            app:iconPadding="@dimen/picker_bottom_bar_vertical_gap"
+            android:textColor="?attr/pickerSelectedColor"
+            app:iconPadding="@dimen/picker_viewselected_icon_padding"
             style="@style/MaterialBorderlessButtonStyle"/>
 
         <Button
@@ -102,10 +102,11 @@
             android:layout_height="wrap_content"
             android:layout_marginHorizontal="@dimen/picker_bottom_bar_horizontal_gap"
             android:layout_gravity="end|center_vertical"
-            android:paddingVertical="@dimen/picker_bottom_bar_vertical_gap"
+            android:paddingVertical="@dimen/picker_bottom_bar_buttons_vertical_gap"
             android:text="@string/add"
             android:textAllCaps="false"
-            android:backgroundTint="?android:attr/colorAccent"
+            android:textColor="?attr/pickerHighlightTextColor"
+            android:backgroundTint="?attr/pickerHighlightColor"
             style="@style/MaterialButtonStyle"/>
 
     </FrameLayout>
diff --git a/res/layout/fragment_preview.xml b/res/layout/fragment_preview.xml
index 2d24db2..550c7ca 100644
--- a/res/layout/fragment_preview.xml
+++ b/res/layout/fragment_preview.xml
@@ -15,7 +15,7 @@
   -->
 
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-             android:background="@color/preview_default_black"
+             android:background="@color/preview_background_color"
              android:layout_width="match_parent"
              android:layout_height="match_parent">
 
@@ -56,7 +56,8 @@
             android:layout_width="@dimen/preview_add_or_select_width"
             android:layout_height="wrap_content"
             android:layout_gravity="center"
-            android:backgroundTint="@color/preview_default_blue"
+            android:backgroundTint="@color/preview_highlight_color"
+            android:paddingVertical="@dimen/picker_bottom_bar_buttons_vertical_gap"
             android:text="@string/add"
             android:textAllCaps="false"
             android:textColor="@color/preview_default_grey"
@@ -69,9 +70,10 @@
             android:layout_height="wrap_content"
             android:layout_gravity="start|center_vertical"
             android:paddingStart="@dimen/preview_deselect_padding_start"
+            android:paddingVertical="@dimen/picker_bottom_bar_buttons_vertical_gap"
             android:background="@android:color/transparent"
             android:drawableLeft="@drawable/preview_check"
-            android:drawableTint="@color/preview_default_blue"
+            android:drawableTint="@color/preview_highlight_color"
             android:textAllCaps="false"
             android:text="@string/deselect"
             android:textColor="@color/picker_default_white"
@@ -83,7 +85,8 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_gravity="end|center_vertical"
-            android:backgroundTint="@color/preview_default_blue"
+            android:backgroundTint="@color/preview_highlight_color"
+            android:paddingVertical="@dimen/picker_bottom_bar_buttons_vertical_gap"
             android:text="@string/add"
             android:textAllCaps="false"
             android:textColor="@color/preview_default_grey"
diff --git a/res/layout/item_album_grid.xml b/res/layout/item_album_grid.xml
index e40891e..d90efd7 100644
--- a/res/layout/item_album_grid.xml
+++ b/res/layout/item_album_grid.xml
@@ -28,7 +28,8 @@
         android:elevation="0dp"
         android:duplicateParentState="true"
         app:cardCornerRadius="@dimen/picker_album_grid_radius"
-        app:cardElevation="0dp">
+        app:cardElevation="0dp"
+        app:strokeWidth="0dp">
 
         <com.android.providers.media.photopicker.ui.SquareImageView
             android:id="@+id/icon_thumbnail"
diff --git a/res/layout/item_photo_grid.xml b/res/layout/item_photo_grid.xml
index fed1c8b..f28305c 100644
--- a/res/layout/item_photo_grid.xml
+++ b/res/layout/item_photo_grid.xml
@@ -19,7 +19,6 @@
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:background="@color/picker_highlight_color"
     android:focusable="true">
 
     <com.google.android.material.card.MaterialCardView
@@ -28,7 +27,8 @@
         android:elevation="0dp"
         android:duplicateParentState="true"
         app:cardElevation="0dp"
-        app:cardCornerRadius="0dp">
+        app:cardCornerRadius="0dp"
+        app:strokeWidth="0dp">
 
         <FrameLayout
             android:layout_width="match_parent"
diff --git a/res/layout/picker_chip_tab_header.xml b/res/layout/picker_chip_tab_header.xml
index c2c1dfa..700f5e6 100644
--- a/res/layout/picker_chip_tab_header.xml
+++ b/res/layout/picker_chip_tab_header.xml
@@ -20,6 +20,7 @@
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_gravity="center"
+    android:layout_marginHorizontal="@dimen/picker_chip_horizontal_gap"
     android:textAppearance="@style/PickerChipTextAppearance"
     android:textColor="@color/picker_chip_text_color"
     app:chipBackgroundColor="@color/picker_chip_background_color"
diff --git a/res/values-night-v31/colors.xml b/res/values-night-v31/colors.xml
new file mode 100644
index 0000000..a9e43f7
--- /dev/null
+++ b/res/values-night-v31/colors.xml
@@ -0,0 +1,23 @@
+<?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.
+  -->
+
+<resources>
+
+    <!-- PhotoPicker -->
+    <color name="picker_background_color">@android:color/system_neutral1_800</color>
+
+</resources>
diff --git a/res/values-night-v31/styles.xml b/res/values-night-v31/styles.xml
new file mode 100644
index 0000000..4a34a11
--- /dev/null
+++ b/res/values-night-v31/styles.xml
@@ -0,0 +1,32 @@
+<?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.
+-->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <style name="PickerMaterialTheme" parent="@style/Theme.Material3.DayNight.NoActionBar">
+        <item name="materialAlertDialogTheme">@style/ProfileDialogTheme</item>
+        <item name="pickerChipBackgroundColor">@android:color/system_neutral1_700</item>
+        <item name="pickerHighlightColor">@android:color/system_accent2_100</item>
+        <item name="pickerHighlightTextColor">?android:attr/textColorPrimaryInverse</item>
+        <item name="pickerProfileButtonColor">@android:color/system_accent2_100</item>
+        <item name="pickerProfileButtonTextColor">?android:attr/textColorPrimaryInverse</item>
+        <item name="pickerSelectedChipBackgroundColor">@android:color/system_accent2_100</item>
+        <item name="pickerSelectedChipTextColor">?android:attr/textColorPrimaryInverse</item>
+        <item name="pickerTextColor">?android:attr/textColorSecondary</item>
+        <item name="pickerSelectedColor">@android:color/system_accent1_300</item>
+    </style>
+
+</resources>
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index c675a5d..eb3b0d4 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -20,18 +20,10 @@
     <color name="clear_cache_icon_color">#DADCE0</color>
 
     <!-- PhotoPicker -->
-    <color name="picker_primary_color">#8AB4F8</color>
     <color name="picker_background_color">#202124</color>
-    <color name="picker_highlight_color">#3D8AB4F8</color>
-    <color name="picker_date_header_text_color">@color/picker_default_white</color>
-    <color name="picker_toolbar_icon_color">#E8EAED</color>
-    <color name="picker_toolbar_chip_text_color">#E8EAED</color>
-    <color name="picker_toolbar_title_color">#FFFFFF</color>
     <color name="picker_drag_bar_color">#686868</color>
 
     <!-- PhotoPicker Profile Button -->
-    <color name="picker_profile_button_content_color">#A8C7FA</color>
-    <color name="picker_profile_button_background_color">#1F1F1F</color>
     <color name="picker_profile_disabled_button_content_color">#E3E3E3</color>
     <color name="picker_profile_disabled_button_background_color">#DADADA</color>
 
diff --git a/res/values-night/styles.xml b/res/values-night/styles.xml
index 9b4da23..dd8eacc 100644
--- a/res/values-night/styles.xml
+++ b/res/values-night/styles.xml
@@ -35,4 +35,17 @@
         <item name="android:alertDialogTheme">@style/AlertDialogTheme</item>
     </style>
 
+    <style name="PickerMaterialTheme" parent="@style/Theme.MaterialComponents.DayNight.NoActionBar">
+        <item name="materialAlertDialogTheme">@style/ProfileDialogTheme</item>
+        <item name="pickerChipBackgroundColor">@color/picker_background_color</item>
+        <item name="pickerHighlightColor">?android:attr/colorAccent</item>
+        <item name="pickerHighlightTextColor">#202124</item>
+        <item name="pickerProfileButtonColor">#1F1F1F</item>
+        <item name="pickerProfileButtonTextColor">#A8C7FA</item>
+        <item name="pickerSelectedChipBackgroundColor">#3D8AB4F8</item>
+        <item name="pickerSelectedChipTextColor">#8AB4F8</item>
+        <item name="pickerTextColor">?android:attr/textColorSecondary</item>
+        <item name="pickerSelectedColor">?android:attr/colorAccent</item>
+    </style>
+
 </resources>
diff --git a/res/values-v31/colors.xml b/res/values-v31/colors.xml
new file mode 100644
index 0000000..53fac06
--- /dev/null
+++ b/res/values-v31/colors.xml
@@ -0,0 +1,28 @@
+<?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.
+-->
+
+<resources>
+
+    <!-- PhotoPicker -->
+    <color name="picker_background_color">@color/surface_light</color>
+
+    <!-- PhotoPicker check button -->
+    <color name="picker_unselected_check_color">@android:color/system_neutral1_100</color>
+
+    <!-- PhotoPicker Preview -->
+    <color name="preview_highlight_color">@android:color/system_accent1_100</color>
+
+</resources>
diff --git a/res/values-v31/dimens.xml b/res/values-v31/dimens.xml
new file mode 100644
index 0000000..31ec80c
--- /dev/null
+++ b/res/values-v31/dimens.xml
@@ -0,0 +1,23 @@
+<?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.
+-->
+
+<resources>
+
+    <dimen name="picker_chip_radius">12dp</dimen>
+
+    <dimen name="picker_bottom_bar_size">72dp</dimen>
+
+</resources>
diff --git a/res/values-v31/styles.xml b/res/values-v31/styles.xml
new file mode 100644
index 0000000..0b10d19
--- /dev/null
+++ b/res/values-v31/styles.xml
@@ -0,0 +1,32 @@
+<?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.
+-->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <style name="PickerMaterialTheme" parent="@style/Theme.Material3.DayNight.NoActionBar">
+        <item name="materialAlertDialogTheme">@style/ProfileDialogTheme</item>
+        <item name="pickerChipBackgroundColor">?android:attr/colorBackground</item>
+        <item name="pickerHighlightColor">@android:color/system_accent1_100</item>
+        <item name="pickerHighlightTextColor">?android:attr/textColorPrimary</item>
+        <item name="pickerProfileButtonColor">@android:color/system_accent1_100</item>
+        <item name="pickerProfileButtonTextColor">?android:attr/textColorPrimary</item>
+        <item name="pickerSelectedChipBackgroundColor">@android:color/system_accent1_100</item>
+        <item name="pickerSelectedChipTextColor">?android:attr/textColorPrimary</item>
+        <item name="pickerTextColor">?android:attr/textColorPrimary</item>
+        <item name="pickerSelectedColor">@android:color/system_accent1_600</item>
+    </style>
+
+</resources>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
new file mode 100644
index 0000000..5557364
--- /dev/null
+++ b/res/values/attrs.xml
@@ -0,0 +1,45 @@
+<?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.
+-->
+<resources>
+
+    <!-- The default background color of the chip. -->
+    <attr name="pickerChipBackgroundColor" format="reference|color" />
+
+    <!-- The highlight color of the photo picker. E.g. Add button -->
+    <attr name="pickerHighlightColor" format="reference|color" />
+
+    <!-- The most prominent highlight text color of the photo picker. E.g. Add button -->
+    <attr name="pickerHighlightTextColor" format="reference|color" />
+
+    <!-- The background color of the profile button. -->
+    <attr name="pickerProfileButtonColor" format="reference|color" />
+
+    <!-- The text color of the profile button. -->
+    <attr name="pickerProfileButtonTextColor" format="reference|color" />
+
+    <!-- The selected background color of the chip. -->
+    <attr name="pickerSelectedChipBackgroundColor" format="reference|color" />
+
+    <!-- The selected text color of the chip. -->
+    <attr name="pickerSelectedChipTextColor" format="reference|color" />
+
+    <!-- The most prominent text color of the photo picker.  -->
+    <attr name="pickerTextColor" format="reference|color" />
+
+    <!-- The selected color of the view selected button and check icon -->
+    <attr name="pickerSelectedColor" format="reference|color" />
+
+</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 80772b3..e934274 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -19,34 +19,25 @@
     <color name="clear_cache_icon_color">#5F6368</color>
 
     <!-- PhotoPicker -->
+    <color name="picker_background_color">@android:color/white</color>
     <color name="picker_default_white">@android:color/white</color>
     <color name="picker_drag_bar_color">#DADCE0</color>
 
-    <!-- PhotoPicker photo grid -->
-    <color name="picker_primary_color">#1A73E8</color>
-    <color name="picker_background_color">@android:color/white</color>
-    <color name="picker_highlight_color">#E8F0FE</color>
-    <color name="picker_date_header_text_color">#3C4043</color>
-    <color name="picker_toolbar_icon_color">#3C4043</color>
-    <color name="picker_toolbar_chip_text_color">#5F6368</color>
-    <color name="picker_toolbar_title_color">#3C4043</color>
+    <!-- PhotoPicker check button -->
+    <color name="picker_unselected_check_color">@android:color/white</color>
 
     <!-- PhotoPicker gradient colors -->
-    <color name="picker_item_gradient_color">#42000000</color>
+    <color name="picker_item_gradient_color">#61202124</color> <!-- 38% opacity -->
     <color name="preview_gradient_color_light">@android:color/transparent</color>
     <color name="preview_gradient_color_dark">#80202124</color>
     <color name="preview_scrim_solid_color">#E6000000</color> <!-- 90% opacity black -->
 
     <!-- PhotoPicker Preview -->
-    <color name="preview_default_blue">#8AB4F8</color>
+    <color name="preview_highlight_color">#8AB4F8</color>
     <color name="preview_default_grey">#202124</color>
-    <color name="preview_default_black">@android:color/black</color>
+    <color name="preview_background_color">@android:color/black</color>
 
     <!-- PhotoPicker Profile Button -->
-    <color name="picker_profile_button_content_color">#0B57D0</color>
-    <color name="picker_profile_button_background_color">#E8F0FE</color>
     <color name="picker_profile_disabled_button_content_color">#1F1F1F</color>
     <color name="picker_profile_disabled_button_background_color">#DADADA</color>
-    <color name="picker_profile_dialog_icon_and_button_color">#1A73E8</color>
-    <color name="picker_profile_dialog_text_color">#3C4043</color>
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index ebe5ac0..35268dc 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -27,15 +27,17 @@
 
     <dimen name="picker_bottom_bar_size">56dp</dimen>
     <dimen name="picker_bottom_bar_horizontal_gap">16dp</dimen>
-    <dimen name="picker_bottom_bar_vertical_gap">10dp</dimen>
+    <dimen name="picker_bottom_bar_buttons_vertical_gap">10dp</dimen>
     <dimen name="picker_bottom_bar_elevation">8dp</dimen>
 
+    <dimen name="picker_viewselected_icon_padding">10dp</dimen>
+
     <dimen name="picker_item_check_size">24dp</dimen>
     <dimen name="picker_item_check_margin">6dp</dimen>
     <dimen name="picker_item_badge_margin">4dp</dimen>
     <dimen name="picker_item_badge_text_margin">3dp</dimen>
     <dimen name="picker_item_badge_text_size">10dp</dimen>
-    <dimen name="picker_item_gradient_height">56dp</dimen>
+    <dimen name="picker_item_gradient_height">40dp</dimen>
 
     <dimen name="picker_date_header_height">56dp</dimen>
     <dimen name="picker_date_header_padding">16dp</dimen>
@@ -54,6 +56,7 @@
     <dimen name="picker_chip_text_size">16sp</dimen>
     <dimen name="picker_chip_touch_size">48dp</dimen>
     <dimen name="picker_chip_radius">16dp</dimen>
+    <dimen name="picker_chip_horizontal_gap">4dp</dimen>
 
     <dimen name="picker_drag_bar_height">24dp</dimen>
     <dimen name="picker_drag_margin_top">8dp</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 0a15288..84d8f55 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -35,21 +35,6 @@
         <item name="android:alertDialogTheme">@style/AlertDialogTheme</item>
     </style>
 
-    <style name="CacheClearingAlertDialogTitle"
-           parent="@android:style/TextAppearance.DeviceDefault.DialogWindowTitle">
-        <item name="android:layout_width">match_parent</item>
-        <item name="android:layout_height">wrap_content</item>
-        <item name="android:gravity">center</item>
-        <item name="android:textColor">?android:attr/textColorPrimary</item>
-        <item name="android:textSize">16sp</item>
-        <item name="android:textStyle">bold</item>
-    </style>
-
-    <style name="PermissionAlertDialogTitle"
-           parent="@android:style/TextAppearance.DeviceDefault.DialogWindowTitle">
-        <item name="android:textColor">?android:attr/textColorPrimary</item>
-    </style>
-
     <style name="MaterialBorderlessButtonStyle"
            parent="@style/Widget.MaterialComponents.Button.TextButton">
         <item name="android:textAppearance">@style/PickerButtonTextAppearance</item>
@@ -81,19 +66,15 @@
 
     <style name="MaterialAlertDialogIconStyle"
            parent="@style/MaterialAlertDialog.MaterialComponents.Title.Icon.CenterStacked">
-        <item name="android:tint">@color/picker_profile_dialog_icon_and_button_color</item>
+        <item name="android:tint">?android:attr/colorAccent</item>
         <item name="android:layout_width">@dimen/picker_profile_dialog_icon_width</item>
         <item name="android:layout_height">@dimen/picker_profile_dialog_icon_height</item>
     </style>
 
-    <style name="PickerDefaultTheme" parent="android:style/Theme.DeviceDefault.DayNight">
-        <!-- Color section -->
-        <item name="android:colorAccent">@color/picker_primary_color</item>
-        <item name="android:colorBackground">@color/picker_background_color</item>
-
+    <style name="PickerDefaultTheme" parent="@android:style/Theme.DeviceDefault.DayNight">
         <!-- System | Widget section -->
         <item name="android:backgroundDimEnabled">true</item>
-        <item name="android:navigationBarColor">?android:attr/colorBackground</item>
+        <item name="android:navigationBarColor">@color/picker_background_color</item>
         <item name="android:statusBarColor">@android:color/transparent</item>
         <item name="android:windowBackground">@android:color/transparent</item>
         <item name="android:windowIsTranslucent">true</item>
@@ -102,6 +83,15 @@
 
     <style name="PickerMaterialTheme" parent="@style/Theme.MaterialComponents.DayNight.NoActionBar">
         <item name="materialAlertDialogTheme">@style/ProfileDialogTheme</item>
+        <item name="pickerChipBackgroundColor">@color/picker_background_color</item>
+        <item name="pickerHighlightColor">?android:attr/colorAccent</item>
+        <item name="pickerHighlightTextColor">@android:color/white</item>
+        <item name="pickerProfileButtonColor">#E8F0FE</item>
+        <item name="pickerProfileButtonTextColor">#0B57D0</item>
+        <item name="pickerSelectedChipBackgroundColor">#E8F0FE</item>
+        <item name="pickerSelectedChipTextColor">#185ABC</item>
+        <item name="pickerTextColor">?android:attr/textColorPrimary</item>
+        <item name="pickerSelectedColor">?android:attr/colorAccent</item>
     </style>
 
 </resources>
diff --git a/res/values/styles_text.xml b/res/values/styles_text.xml
index 55a71b8..cd06a65 100644
--- a/res/values/styles_text.xml
+++ b/res/values/styles_text.xml
@@ -16,9 +16,24 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android">
 
+    <style name="CacheClearingAlertDialogTitle"
+           parent="@android:style/TextAppearance.DeviceDefault.DialogWindowTitle">
+        <item name="android:layout_width">match_parent</item>
+        <item name="android:layout_height">wrap_content</item>
+        <item name="android:gravity">center</item>
+        <item name="android:textColor">?android:attr/textColorPrimary</item>
+        <item name="android:textSize">16sp</item>
+        <item name="android:textStyle">bold</item>
+    </style>
+
+    <style name="PermissionAlertDialogTitle"
+           parent="@android:style/TextAppearance.DeviceDefault.DialogWindowTitle">
+        <item name="android:textColor">?android:attr/textColorPrimary</item>
+    </style>
+
     <style name="PickerHeaderTextAppearance"
            parent="@android:style/TextAppearance.DeviceDefault.WindowTitle">
-        <item name="android:textColor">@color/picker_date_header_text_color</item>
+        <item name="android:textColor">?attr/pickerTextColor</item>
         <item name="android:textSize">16sp</item>
     </style>
 
@@ -33,13 +48,13 @@
     <style name="PickerProfileDialogTitle"
            parent="@android:style/TextAppearance.DeviceDefault.DialogWindowTitle">
         <item name="android:textAllCaps">false</item>
-        <item name="android:textColor">@color/picker_profile_dialog_text_color</item>
+        <item name="android:textColor">?attr/pickerTextColor</item>
         <item name="android:textSize">@dimen/picker_profile_dialog_title_text_size</item>
     </style>
 
     <style name="PickerProfileDialogBody" parent="@android:style/TextAppearance.Material.Body2">
         <item name="android:textAllCaps">false</item>
-        <item name="android:textColor">@color/picker_profile_dialog_text_color</item>
+        <item name="android:textColor">?attr/pickerTextColor</item>
     </style>
 
 </resources>
diff --git a/src/com/android/providers/media/DatabaseHelper.java b/src/com/android/providers/media/DatabaseHelper.java
index 2aa206a..96277cc 100644
--- a/src/com/android/providers/media/DatabaseHelper.java
+++ b/src/com/android/providers/media/DatabaseHelper.java
@@ -159,33 +159,34 @@
     private static Object sMigrationLockExternal = new Object();
 
     public interface OnSchemaChangeListener {
-        public void onSchemaChange(@NonNull String volumeName, int versionFrom, int versionTo,
+        void onSchemaChange(@NonNull String volumeName, int versionFrom, int versionTo,
                 long itemCount, long durationMillis, String databaseUuid);
     }
 
     public interface OnFilesChangeListener {
-        public void onInsert(@NonNull DatabaseHelper helper, @NonNull String volumeName, long id,
+        void onInsert(@NonNull DatabaseHelper helper, @NonNull String volumeName, long id,
                 int mediaType, boolean isDownload, boolean isPending);
 
-        public void onUpdate(@NonNull DatabaseHelper helper, @NonNull String volumeName,
+        void onUpdate(@NonNull DatabaseHelper helper, @NonNull String volumeName,
                 long oldId, int oldMediaType, boolean oldIsDownload,
                 long newId, int newMediaType, boolean newIsDownload,
                 boolean oldIsTrashed, boolean newIsTrashed,
                 boolean oldIsPending, boolean newIsPending,
                 boolean oldIsFavorite, boolean newIsFavorite,
+                int oldSpecialFormat, int newSpecialFormat,
                 String oldOwnerPackage, String newOwnerPackage, String oldPath);
 
-        public void onDelete(@NonNull DatabaseHelper helper, @NonNull String volumeName, long id,
+        void onDelete(@NonNull DatabaseHelper helper, @NonNull String volumeName, long id,
                 int mediaType, boolean isDownload, String ownerPackage, String path);
     }
 
     public interface OnLegacyMigrationListener {
-        public void onStarted(ContentProviderClient client, String volumeName);
+        void onStarted(ContentProviderClient client, String volumeName);
 
-        public void onProgress(ContentProviderClient client, String volumeName,
+        void onProgress(ContentProviderClient client, String volumeName,
                 long progress, long total);
 
-        public void onFinished(ContentProviderClient client, String volumeName);
+        void onFinished(ContentProviderClient client, String volumeName);
     }
 
     public DatabaseHelper(Context context, String name,
@@ -320,7 +321,7 @@
         db.setCustomScalarFunction("_UPDATE", (arg) -> {
             if (arg != null && mFilesListener != null
                     && !mSchemaLock.isWriteLockedByCurrentThread()) {
-                final String[] split = arg.split(":", 16);
+                final String[] split = arg.split(":", 18);
                 final String volumeName = split[0];
                 final long oldId = Long.parseLong(split[1]);
                 final int oldMediaType = Integer.parseInt(split[2]);
@@ -334,17 +335,19 @@
                 final boolean newIsPending = Integer.parseInt(split[10]) != 0;
                 final boolean oldIsFavorite = Integer.parseInt(split[11]) != 0;
                 final boolean newIsFavorite = Integer.parseInt(split[12]) != 0;
-                final String oldOwnerPackage = split[13];
-                final String newOwnerPackage = split[14];
-                final String oldPath = split[15];
+                final int oldSpecialFormat = Integer.parseInt(split[13]);
+                final int newSpecialFormat = Integer.parseInt(split[14]);
+                final String oldOwnerPackage = split[15];
+                final String newOwnerPackage = split[16];
+                final String oldPath = split[17];
 
                 Trace.beginSection("_UPDATE");
                 try {
                     mFilesListener.onUpdate(DatabaseHelper.this, volumeName, oldId,
                             oldMediaType, oldIsDownload, newId, newMediaType, newIsDownload,
                             oldIsTrashed, newIsTrashed, oldIsPending, newIsPending,
-                            oldIsFavorite, newIsFavorite, oldOwnerPackage, newOwnerPackage,
-                            oldPath);
+                            oldIsFavorite, newIsFavorite, oldSpecialFormat, newSpecialFormat,
+                            oldOwnerPackage, newOwnerPackage, oldPath);
                 } finally {
                     Trace.endSection();
                 }
@@ -1374,6 +1377,8 @@
                         + "||':'||old.is_trashed||':'||new.is_trashed"
                         + "||':'||old.is_pending||':'||new.is_pending"
                         + "||':'||old.is_favorite||':'||new.is_favorite"
+                        + "||':'||ifnull(old._special_format,0)"
+                        + "||':'||ifnull(new._special_format,0)"
                         + "||':'||ifnull(old.owner_package_name,'null')"
                         + "||':'||ifnull(new.owner_package_name,'null')||':'||old._data";
         final String deleteArg =
@@ -1718,7 +1723,7 @@
     static final int VERSION_S = 1209;
     // Leave some gaps in database version tagging to allow S schema changes
     // to go independent of T schema changes.
-    static final int VERSION_T = 1305;
+    static final int VERSION_T = 1306;
     public static final int VERSION_LATEST = VERSION_T;
 
     /**
@@ -1908,6 +1913,9 @@
             if (fromVersion < 1305) {
                 // Empty version bump to ensure views are recreated
             }
+            if (fromVersion < 1306) {
+                // Empty version bump to ensure views are recreated
+            }
 
             // If this is the legacy database, it's not worth recomputing data
             // values locally, since they'll be recomputed after the migration
diff --git a/src/com/android/providers/media/MediaProvider.java b/src/com/android/providers/media/MediaProvider.java
index 21d25d7..125c4f2 100644
--- a/src/com/android/providers/media/MediaProvider.java
+++ b/src/com/android/providers/media/MediaProvider.java
@@ -707,6 +707,7 @@
                 boolean oldIsTrashed, boolean newIsTrashed,
                 boolean oldIsPending, boolean newIsPending,
                 boolean oldIsFavorite, boolean newIsFavorite,
+                int oldSpecialFormat, int newSpecialFormat,
                 String oldOwnerPackage, String newOwnerPackage, String oldPath) {
             final boolean isDownload = oldIsDownload || newIsDownload;
             final Uri fileUri = MediaStore.Files.getContentUri(volumeName, oldId);
@@ -722,7 +723,7 @@
 
                 if (mExternalDbFacade.onFileUpdated(oldId, oldMediaType, newMediaType, oldIsTrashed,
                                 newIsTrashed, oldIsPending, newIsPending, oldIsFavorite,
-                                newIsFavorite)) {
+                                newIsFavorite, oldSpecialFormat, newSpecialFormat)) {
                     mPickerSyncController.notifyMediaEvent();
                 }
             });
diff --git a/src/com/android/providers/media/photopicker/PhotoPickerActivity.java b/src/com/android/providers/media/photopicker/PhotoPickerActivity.java
index 61907fd..996ff48 100644
--- a/src/com/android/providers/media/photopicker/PhotoPickerActivity.java
+++ b/src/com/android/providers/media/photopicker/PhotoPickerActivity.java
@@ -42,6 +42,7 @@
 import android.view.WindowInsetsController;
 import android.view.WindowManager;
 
+import androidx.annotation.ColorInt;
 import androidx.annotation.NonNull;
 import androidx.annotation.VisibleForTesting;
 import androidx.appcompat.app.AppCompatActivity;
@@ -100,6 +101,12 @@
     @TabChipType
     private int mSelectedTabChipType;
 
+    @ColorInt
+    private int mDefaultBackgroundColor;
+
+    @ColorInt
+    private int mToolBarIconColor;
+
     private int mToolbarHeight = 0;
     private int mDragBarHeight = 0;
 
@@ -122,12 +129,14 @@
         setSupportActionBar(mToolbar);
         getSupportActionBar().setDisplayHomeAsUpEnabled(true);
 
-        final int[] attrs = new int[] {R.attr.actionBarSize};
+        final int[] attrs = new int[]{R.attr.actionBarSize, R.attr.pickerTextColor};
         final TypedArray ta = obtainStyledAttributes(attrs);
         // Save toolbar height so that we can use it as padding for FragmentContainerView
-        mToolbarHeight = ta.getDimensionPixelSize(0, -1);
+        mToolbarHeight = ta.getDimensionPixelSize(/* index */ 0, /* defValue */ -1);
+        mToolBarIconColor = ta.getColor(/* index */ 1,/* defValue */ -1);
         ta.recycle();
 
+        mDefaultBackgroundColor = getColor(R.color.picker_background_color);
         mPickerViewModel = createViewModel();
         mSelection = mPickerViewModel.getSelection();
 
@@ -457,7 +466,7 @@
                 toolbarColor = new ColorDrawable(getColor(R.color.preview_scrim_solid_color));
             }
         } else {
-            toolbarColor = new ColorDrawable(getColor(R.color.picker_background_color));
+            toolbarColor = new ColorDrawable(mDefaultBackgroundColor);
         }
         getSupportActionBar().setBackgroundDrawable(toolbarColor);
 
@@ -468,7 +477,7 @@
         } else {
             icon = getDrawable(R.drawable.ic_arrow_back);
             // Preview mode has dark background, hence icons will be WHITE in color
-            icon.setTint(isPreview ? Color.WHITE : getColor(R.color.picker_toolbar_icon_color));
+            icon.setTint(isPreview ? Color.WHITE : mToolBarIconColor);
         }
         getSupportActionBar().setHomeAsUpIndicator(icon);
 
@@ -487,11 +496,11 @@
      */
     private void updateStatusBarAndNavigationBar(@NonNull LayoutModeUtils.Mode mode) {
         final boolean isPreview = mode.isPreview;
-        final int navigationBarColor = isPreview ? getColor(R.color.preview_default_black) :
-                getColor(R.color.picker_background_color);
+        final int navigationBarColor = isPreview ? getColor(R.color.preview_background_color) :
+                mDefaultBackgroundColor;
         getWindow().setNavigationBarColor(navigationBarColor);
 
-        final int statusBarColor = isPreview ? getColor(R.color.preview_default_black) :
+        final int statusBarColor = isPreview ? getColor(R.color.preview_background_color) :
                 getColor(android.R.color.transparent);
         getWindow().setStatusBarColor(statusBarColor);
 
diff --git a/src/com/android/providers/media/photopicker/data/ExternalDbFacade.java b/src/com/android/providers/media/photopicker/data/ExternalDbFacade.java
index 6eebedf..3eb3c4d 100644
--- a/src/com/android/providers/media/photopicker/data/ExternalDbFacade.java
+++ b/src/com/android/providers/media/photopicker/data/ExternalDbFacade.java
@@ -150,7 +150,8 @@
      */
     public boolean onFileUpdated(long oldId, int oldMediaType, int newMediaType,
             boolean oldIsTrashed, boolean newIsTrashed, boolean oldIsPending,
-            boolean newIsPending, boolean oldIsFavorite, boolean newIsFavorite) {
+            boolean newIsPending, boolean oldIsFavorite, boolean newIsFavorite,
+            int oldSpecialFormat, int newSpecialFormat) {
         if (!mDatabaseHelper.isExternal()) {
             return false;
         }
@@ -175,7 +176,7 @@
         }
 
         if (newIsVisibleMedia) {
-            return oldIsFavorite != newIsFavorite;
+            return (oldIsFavorite != newIsFavorite) || (oldSpecialFormat != newSpecialFormat);
         }
 
 
diff --git a/src/com/android/providers/media/photopicker/ui/TabFragment.java b/src/com/android/providers/media/photopicker/ui/TabFragment.java
index 0b49ace..6efda0b 100644
--- a/src/com/android/providers/media/photopicker/ui/TabFragment.java
+++ b/src/com/android/providers/media/photopicker/ui/TabFragment.java
@@ -16,6 +16,8 @@
 package com.android.providers.media.photopicker.ui;
 
 import android.content.Context;
+import android.content.res.ColorStateList;
+import android.content.res.TypedArray;
 import android.os.Bundle;
 import android.text.TextUtils;
 import android.view.LayoutInflater;
@@ -24,9 +26,9 @@
 import android.widget.Button;
 import android.widget.TextView;
 
+import androidx.annotation.ColorInt;
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
-import androidx.appcompat.content.res.AppCompatResources;
 import androidx.fragment.app.Fragment;
 import androidx.lifecycle.ViewModelProvider;
 import androidx.recyclerview.widget.RecyclerView;
@@ -59,6 +61,18 @@
     private View mEmptyView;
     private TextView mEmptyTextView;
 
+    @ColorInt
+    private int mButtonIconAndTextColor;
+
+    @ColorInt
+    private int mButtonBackgroundColor;
+
+    @ColorInt
+    private int mButtonDisabledIconAndTextColor;
+
+    @ColorInt
+    private int mButtonDisabledBackgroundColor;
+
     @Override
     @NonNull
     public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
@@ -80,6 +94,18 @@
         mEmptyView = view.findViewById(android.R.id.empty);
         mEmptyTextView = mEmptyView.findViewById(R.id.empty_text_view);
 
+        mButtonDisabledIconAndTextColor = getContext().getColor(
+                R.color.picker_profile_disabled_button_content_color);
+        mButtonDisabledBackgroundColor = getContext().getColor(
+                R.color.picker_profile_disabled_button_background_color);
+
+        final int[] attrs =
+                new int[]{R.attr.pickerProfileButtonColor, R.attr.pickerProfileButtonTextColor};
+        final TypedArray ta = getContext().obtainStyledAttributes(attrs);
+        mButtonBackgroundColor = ta.getColor(/* index */ 0, /* defValue */ -1);
+        mButtonIconAndTextColor = ta.getColor(/* index */ 1, /* defValue */ -1);
+        ta.recycle();
+
         mProfileButton = view.findViewById(R.id.profile_button);
         mUserIdManager = mPickerViewModel.getUserIdManager();
 
@@ -219,20 +245,14 @@
     }
 
     private void updateProfileButtonColor(boolean isDisabled) {
-        final int textAndIconResId;
-        final int backgroundTintResId;
-        if (isDisabled) {
-            textAndIconResId = R.color.picker_profile_disabled_button_content_color;
-            backgroundTintResId = R.color.picker_profile_disabled_button_background_color;
-        } else {
-            textAndIconResId = R.color.picker_profile_button_content_color;
-            backgroundTintResId = R.color.picker_profile_button_background_color;
-        }
-        mProfileButton.setTextColor(AppCompatResources.getColorStateList(getContext(),
-                textAndIconResId));
-        mProfileButton.setIconTintResource(textAndIconResId);
-        mProfileButton.setBackgroundTintList(AppCompatResources.getColorStateList(getContext(),
-                backgroundTintResId));
+        final int textAndIconColor =
+                isDisabled ? mButtonDisabledIconAndTextColor : mButtonIconAndTextColor;
+        final int backgroundTintColor =
+                isDisabled ? mButtonDisabledBackgroundColor : mButtonBackgroundColor;
+
+        mProfileButton.setTextColor(ColorStateList.valueOf(textAndIconColor));
+        mProfileButton.setIconTint(ColorStateList.valueOf(textAndIconColor));
+        mProfileButton.setBackgroundTintList(ColorStateList.valueOf(backgroundTintColor));
     }
 
     protected int getBottomGapForRecyclerView(int bottomBarSize) {
diff --git a/tests/src/com/android/providers/media/photopicker/data/ExternalDbFacadeTest.java b/tests/src/com/android/providers/media/photopicker/data/ExternalDbFacadeTest.java
index 12f95e8..84a905d 100644
--- a/tests/src/com/android/providers/media/photopicker/data/ExternalDbFacadeTest.java
+++ b/tests/src/com/android/providers/media/photopicker/data/ExternalDbFacadeTest.java
@@ -16,6 +16,9 @@
 
 package com.android.providers.media.photopicker.data;
 
+import static android.provider.MediaStore.Files.FileColumns._SPECIAL_FORMAT_NONE;
+import static android.provider.MediaStore.Files.FileColumns._SPECIAL_FORMAT_GIF;
+
 import static com.android.providers.media.photopicker.data.ExternalDbFacade.COLUMN_OLD_ID;
 import static com.android.providers.media.photopicker.data.ExternalDbFacade.TABLE_DELETED_MEDIA;
 import static com.android.providers.media.photopicker.data.ExternalDbFacade.TABLE_FILES;
@@ -158,7 +161,9 @@
                             FileColumns.MEDIA_TYPE_NONE, FileColumns.MEDIA_TYPE_NONE,
                             /* oldIsTrashed */ false, /* newIsTrashed */ false,
                             /* oldIsPending */ false, /* newIsPending */ false,
-                            /* oldIsFavorite */ false, /* newIsFavorite */ false)).isFalse();
+                            /* oldIsFavorite */ false, /* newIsFavorite */ false,
+                            /* oldSpecialFormat */ _SPECIAL_FORMAT_NONE,
+                            /* newSpecialFormat */ _SPECIAL_FORMAT_NONE)).isFalse();
             assertDeletedMediaEmpty(facade);
 
             // Media -> non-media: added to deleted_media
@@ -166,7 +171,9 @@
                             FileColumns.MEDIA_TYPE_IMAGE, FileColumns.MEDIA_TYPE_NONE,
                             /* oldIsTrashed */ false, /* newIsTrashed */ false,
                             /* oldIsPending */ false, /* newIsPending */ false,
-                            /* oldIsFavorite */ false, /* newIsFavorite */ false)).isTrue();
+                            /* oldIsFavorite */ false, /* newIsFavorite */ false,
+                            /* oldSpecialFormat */ _SPECIAL_FORMAT_NONE,
+                            /* newSpecialFormat */ _SPECIAL_FORMAT_NONE)).isTrue();
             assertDeletedMedia(facade, ID1);
 
             // Non-media -> non-media: no-op
@@ -174,7 +181,9 @@
                             FileColumns.MEDIA_TYPE_NONE, FileColumns.MEDIA_TYPE_NONE,
                             /* oldIsTrashed */ false, /* newIsTrashed */ false,
                             /* oldIsPending */ false, /* newIsPending */ false,
-                            /* oldIsFavorite */ false, /* newIsFavorite */ false)).isFalse();
+                            /* oldIsFavorite */ false, /* newIsFavorite */ false,
+                            /* oldSpecialFormat */ _SPECIAL_FORMAT_NONE,
+                            /* newSpecialFormat */ _SPECIAL_FORMAT_NONE)).isFalse();
             assertDeletedMedia(facade, ID1);
 
             // Non-media -> media: remove from deleted_media
@@ -182,7 +191,9 @@
                             FileColumns.MEDIA_TYPE_NONE, FileColumns.MEDIA_TYPE_IMAGE,
                             /* oldIsTrashed */ false, /* newIsTrashed */ false,
                             /* oldIsPending */ false, /* newIsPending */ false,
-                            /* oldIsFavorite */ false, /* newIsFavorite */ false)).isTrue();
+                            /* oldIsFavorite */ false, /* newIsFavorite */ false,
+                            /* oldSpecialFormat */ _SPECIAL_FORMAT_NONE,
+                            /* newSpecialFormat */ _SPECIAL_FORMAT_NONE)).isTrue();
             assertDeletedMediaEmpty(facade);
 
             // Non-media -> media: no-op
@@ -190,7 +201,9 @@
                             FileColumns.MEDIA_TYPE_NONE, FileColumns.MEDIA_TYPE_NONE,
                             /* oldIsTrashed */ false, /* newIsTrashed */ false,
                             /* oldIsPending */ false, /* newIsPending */ false,
-                            /* oldIsFavorite */ false, /* newIsFavorite */ false)).isFalse();
+                            /* oldIsFavorite */ false, /* newIsFavorite */ false,
+                            /* oldSpecialFormat */ _SPECIAL_FORMAT_NONE,
+                            /* newSpecialFormat */ _SPECIAL_FORMAT_NONE)).isFalse();
             assertDeletedMediaEmpty(facade);
         }
     }
@@ -205,7 +218,9 @@
                             FileColumns.MEDIA_TYPE_IMAGE, FileColumns.MEDIA_TYPE_IMAGE,
                             /* oldIsTrashed */ true, /* newIsTrashed */ false,
                             /* oldIsPending */ false, /* newIsPending */ false,
-                            /* oldIsFavorite */ false, /* newIsFavorite */ false)).isTrue();
+                            /* oldIsFavorite */ false, /* newIsFavorite */ false,
+                            /* oldSpecialFormat */ _SPECIAL_FORMAT_NONE,
+                            /* newSpecialFormat */ _SPECIAL_FORMAT_NONE)).isTrue();
             assertDeletedMediaEmpty(facade);
 
             // Was not trashed but is now trashed
@@ -213,7 +228,9 @@
                             FileColumns.MEDIA_TYPE_IMAGE, FileColumns.MEDIA_TYPE_IMAGE,
                             /* oldIsTrashed */ false, /* newIsTrashed */ true,
                             /* oldIsPending */ false, /* newIsPending */ false,
-                            /* oldIsFavorite */ false, /* newIsFavorite */ false)).isTrue();
+                            /* oldIsFavorite */ false, /* newIsFavorite */ false,
+                            /* oldSpecialFormat */ _SPECIAL_FORMAT_NONE,
+                            /* newSpecialFormat */ _SPECIAL_FORMAT_NONE)).isTrue();
             assertDeletedMedia(facade, ID1);
 
             // Was trashed but is now neither trashed nor pending
@@ -221,7 +238,9 @@
                             FileColumns.MEDIA_TYPE_IMAGE, FileColumns.MEDIA_TYPE_IMAGE,
                             /* oldIsTrashed */ true, /* newIsTrashed */ false,
                             /* oldIsPending */ false, /* newIsPending */ false,
-                            /* oldIsFavorite */ false, /* newIsFavorite */ false)).isTrue();
+                            /* oldIsFavorite */ false, /* newIsFavorite */ false,
+                            /* oldSpecialFormat */ _SPECIAL_FORMAT_NONE,
+                            /* newSpecialFormat */ _SPECIAL_FORMAT_NONE)).isTrue();
             assertDeletedMediaEmpty(facade);
         }
     }
@@ -236,7 +255,9 @@
                             FileColumns.MEDIA_TYPE_IMAGE, FileColumns.MEDIA_TYPE_IMAGE,
                             /* oldIsTrashed */ false, /* newIsTrashed */ false,
                             /* oldIsPending */ true, /* newIsPending */ false,
-                            /* oldIsFavorite */ false, /* newIsFavorite */ false)).isTrue();
+                            /* oldIsFavorite */ false, /* newIsFavorite */ false,
+                            /* oldSpecialFormat */ _SPECIAL_FORMAT_NONE,
+                            /* newSpecialFormat */ _SPECIAL_FORMAT_NONE)).isTrue();
             assertDeletedMediaEmpty(facade);
 
             // Was not pending but is now pending
@@ -244,7 +265,9 @@
                             FileColumns.MEDIA_TYPE_IMAGE, FileColumns.MEDIA_TYPE_IMAGE,
                             /* oldIsTrashed */ false, /* newIsTrashed */ false,
                             /* oldIsPending */ false, /* newIsPending */ true,
-                            /* oldIsFavorite */ false, /* newIsFavorite */ false)).isTrue();
+                            /* oldIsFavorite */ false, /* newIsFavorite */ false,
+                            /* oldSpecialFormat */ _SPECIAL_FORMAT_NONE,
+                            /* newSpecialFormat */ _SPECIAL_FORMAT_NONE)).isTrue();
             assertDeletedMedia(facade, ID1);
 
             // Was pending but is now neither trashed nor pending
@@ -252,7 +275,9 @@
                             FileColumns.MEDIA_TYPE_IMAGE, FileColumns.MEDIA_TYPE_IMAGE,
                             /* oldIsTrashed */ false, /* newIsTrashed */ false,
                             /* oldIsPending */ true, /* newIsPending */ false,
-                            /* oldIsFavorite */ false, /* newIsFavorite */ false)).isTrue();
+                            /* oldIsFavorite */ false, /* newIsFavorite */ false,
+                            /* oldSpecialFormat */ _SPECIAL_FORMAT_NONE,
+                            /* newSpecialFormat */ _SPECIAL_FORMAT_NONE)).isTrue();
             assertDeletedMediaEmpty(facade);
         }
     }
@@ -267,14 +292,18 @@
                             FileColumns.MEDIA_TYPE_IMAGE, FileColumns.MEDIA_TYPE_IMAGE,
                             /* oldIsTrashed */ false, /* newIsTrashed */ false,
                             /* oldIsPending */ false, /* newIsPending */ false,
-                            /* oldIsFavorite */ true, /* newIsFavorite */ false)).isTrue();
+                            /* oldIsFavorite */ true, /* newIsFavorite */ false,
+                            /* oldSpecialFormat */ _SPECIAL_FORMAT_NONE,
+                            /* newSpecialFormat */ _SPECIAL_FORMAT_NONE)).isTrue();
 
             // Was not favorite but is now favorited
             assertThat(facade.onFileUpdated(ID1,
                             FileColumns.MEDIA_TYPE_IMAGE, FileColumns.MEDIA_TYPE_IMAGE,
                             /* oldIsTrashed */ false, /* newIsTrashed */ false,
                             /* oldIsPending */ false, /* newIsPending */ false,
-                            /* oldIsFavorite */ false, /* newIsFavorite */ true)).isTrue();
+                            /* oldIsFavorite */ false, /* newIsFavorite */ true,
+                            /* oldSpecialFormat */ _SPECIAL_FORMAT_NONE,
+                            /* newSpecialFormat */ _SPECIAL_FORMAT_NONE)).isTrue();
         }
     }
 
@@ -288,14 +317,68 @@
                             FileColumns.MEDIA_TYPE_IMAGE, FileColumns.MEDIA_TYPE_IMAGE,
                             /* oldIsTrashed */ true, /* newIsTrashed */ true,
                             /* oldIsPending */ false, /* newIsPending */ false,
-                            /* oldIsFavorite */ true, /* newIsFavorite */ false)).isFalse();
+                            /* oldIsFavorite */ true, /* newIsFavorite */ false,
+                            /* oldSpecialFormat */ _SPECIAL_FORMAT_NONE,
+                            /* newSpecialFormat */ _SPECIAL_FORMAT_NONE)).isFalse();
 
             // Was not favorite but is now favorited
             assertThat(facade.onFileUpdated(ID1,
                             FileColumns.MEDIA_TYPE_IMAGE, FileColumns.MEDIA_TYPE_IMAGE,
                             /* oldIsTrashed */ false, /* newIsTrashed */ false,
                             /* oldIsPending */ true, /* newIsPending */ true,
-                            /* oldIsFavorite */ false, /* newIsFavorite */ true)).isFalse();
+                            /* oldIsFavorite */ false, /* newIsFavorite */ true,
+                            /* oldSpecialFormat */ _SPECIAL_FORMAT_NONE,
+                            /* newSpecialFormat */ _SPECIAL_FORMAT_NONE)).isFalse();
+        }
+    }
+
+    @Test
+    public void testOnUpdate_visibleSpecialFormat() throws Exception {
+        try (DatabaseHelper helper = new TestDatabaseHelper(sIsolatedContext)) {
+            ExternalDbFacade facade = new ExternalDbFacade(sIsolatedContext, helper);
+
+            // Was _SPECIAL_FORMAT_NONE but is now _SPECIAL_FORMAT_GIF
+            assertThat(facade.onFileUpdated(ID1,
+                    FileColumns.MEDIA_TYPE_IMAGE, FileColumns.MEDIA_TYPE_IMAGE,
+                    /* oldIsTrashed */ false, /* newIsTrashed */ false,
+                    /* oldIsPending */ false, /* newIsPending */ false,
+                    /* oldIsFavorite */ false, /* newIsFavorite */ false,
+                    /* oldSpecialFormat */ _SPECIAL_FORMAT_NONE,
+                    /* newSpecialFormat */ _SPECIAL_FORMAT_GIF)).isTrue();
+
+            // Was _SPECIAL_FORMAT_GIF but is now _SPECIAL_FORMAT_NONE
+            assertThat(facade.onFileUpdated(ID1,
+                    FileColumns.MEDIA_TYPE_IMAGE, FileColumns.MEDIA_TYPE_IMAGE,
+                    /* oldIsTrashed */ false, /* newIsTrashed */ false,
+                    /* oldIsPending */ false, /* newIsPending */ false,
+                    /* oldIsFavorite */ false, /* newIsFavorite */ false,
+                    /* oldSpecialFormat */ _SPECIAL_FORMAT_GIF,
+                    /* newSpecialFormat */ _SPECIAL_FORMAT_NONE)).isTrue();
+        }
+    }
+
+    @Test
+    public void testOnUpdate_hiddenSpecialFormat() throws Exception {
+        try (DatabaseHelper helper = new TestDatabaseHelper(sIsolatedContext)) {
+            ExternalDbFacade facade = new ExternalDbFacade(sIsolatedContext, helper);
+
+            // Was _SPECIAL_FORMAT_NONE but is now _SPECIAL_FORMAT_GIF
+            assertThat(facade.onFileUpdated(ID1,
+                    FileColumns.MEDIA_TYPE_IMAGE, FileColumns.MEDIA_TYPE_IMAGE,
+                    /* oldIsTrashed */ true, /* newIsTrashed */ true,
+                    /* oldIsPending */ false, /* newIsPending */ false,
+                    /* oldIsFavorite */ false, /* newIsFavorite */ false,
+                    /* oldSpecialFormat */ _SPECIAL_FORMAT_NONE,
+                    /* newSpecialFormat */ _SPECIAL_FORMAT_GIF)).isFalse();
+
+            // Was _SPECIAL_FORMAT_NONE but is now _SPECIAL_FORMAT_GIF
+            assertThat(facade.onFileUpdated(ID1,
+                    FileColumns.MEDIA_TYPE_IMAGE, FileColumns.MEDIA_TYPE_IMAGE,
+                    /* oldIsTrashed */ false, /* newIsTrashed */ false,
+                    /* oldIsPending */ true, /* newIsPending */ true,
+                    /* oldIsFavorite */ false, /* newIsFavorite */ false,
+                    /* oldSpecialFormat */ _SPECIAL_FORMAT_GIF,
+                    /* newSpecialFormat */ _SPECIAL_FORMAT_NONE)).isFalse();
         }
     }