Allow to customize OverflowMenu by RRO theme

Define OverflowMenuStyle and let menu not overlap the anchor.
Support to customize OverflowMenu background and selector via RRO.

Test: atest DocumentsUITests
Change-Id: If592318c9181e6901b319ef1a86a0778970ad407
Fix: 117198534
diff --git a/res/drawable/menu_dropdown_panel.xml b/res/drawable/menu_dropdown_panel.xml
new file mode 100644
index 0000000..bde535e
--- /dev/null
+++ b/res/drawable/menu_dropdown_panel.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 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.
+-->
+
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
+    <!-- Panel shadow -->
+    <item>
+        <shape
+            xmlns:android="http://schemas.android.com/apk/res/android"
+            android:shape="rectangle"
+            android:tint="?android:attr/colorBackground">
+            <stroke android:width="2dp" android:color="#3C4043" />
+            <solid android:color="#5F6368" />
+            <corners
+                android:topRightRadius="@dimen/material_round_radius"
+                android:topLeftRadius="@dimen/material_round_radius"
+                android:bottomRightRadius="@dimen/material_round_radius"
+                android:bottomLeftRadius="@dimen/material_round_radius"/>
+        </shape>
+    </item>
+    <!-- Panel surface -->
+    <item android:bottom="2dp">
+        <shape
+            xmlns:android="http://schemas.android.com/apk/res/android"
+            android:shape="rectangle"
+            android:tint="?android:attr/colorBackground">
+            <corners
+                android:topRightRadius="@dimen/material_round_radius"
+                android:topLeftRadius="@dimen/material_round_radius"
+                android:bottomRightRadius="@dimen/material_round_radius"
+                android:bottomLeftRadius="@dimen/material_round_radius"/>
+        </shape>
+    </item>
+</layer-list>
diff --git a/res/values-night/themes.xml b/res/values-night/themes.xml
index 41d66ef..a7c3095 100644
--- a/res/values-night/themes.xml
+++ b/res/values-night/themes.xml
@@ -18,6 +18,7 @@
     <style name="DocumentsTheme" parent="@style/Theme.MaterialComponents.NoActionBar">
 
         <item name="actionModeStyle">@style/ActionModeStyle</item>
+        <item name="actionOverflowMenuStyle">@style/OverflowMenuStyle</item>
         <item name="bottomSheetDialogTheme">@style/BottomSheetDialogStyle</item>
         <item name="snackbarButtonStyle">@style/SnackbarButtonStyle</item>
 
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index b68a464..7e29f3f 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -15,6 +15,9 @@
 -->
 
 <resources>
+    <!-- Material design rounded radius -->
+    <dimen name="material_round_radius">2dp</dimen>
+
     <dimen name="grid_container_padding">4dp</dimen>
     <dimen name="list_container_padding">0dp</dimen>
     <dimen name="icon_size">40dp</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index cdf690b..09b1d17 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -15,6 +15,7 @@
 -->
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android">
+
     <style name="ActionModeStyle" parent="Widget.AppCompat.ActionMode">
         <!-- attr "height" was used by support lib should not in overlay scope -->
         <item name="height">@dimen/action_bar_space_height</item>
@@ -82,6 +83,12 @@
         <item name="android:background">@drawable/bottom_sheet_dialog_background</item>
     </style>
 
+    <style name="OverflowMenuStyle" parent="@style/Widget.AppCompat.PopupMenu.Overflow">
+        <item name="android:popupBackground">@drawable/menu_dropdown_panel</item>
+        <item name="android:dropDownWidth">wrap_content</item>
+        <item name="android:overlapAnchor">false</item>
+    </style>
+
     <style name="SubMenuStyle">
         <item name="android:textColorSecondary">?android:attr/textColorPrimary</item>
     </style>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 388e775..2657195 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -18,6 +18,7 @@
     <style name="DocumentsTheme" parent="@style/Theme.MaterialComponents.Light.NoActionBar">
 
         <item name="actionModeStyle">@style/ActionModeStyle</item>
+        <item name="actionOverflowMenuStyle">@style/OverflowMenuStyle</item>
         <item name="bottomSheetDialogTheme">@style/BottomSheetDialogStyle</item>
         <item name="snackbarButtonStyle">@style/SnackbarButtonStyle</item>