diff --git a/core/java/com/android/internal/view/menu/CascadingMenuPopup.java b/core/java/com/android/internal/view/menu/CascadingMenuPopup.java
index a0f7905771a2e..f08e86082aa99 100644
--- a/core/java/com/android/internal/view/menu/CascadingMenuPopup.java
+++ b/core/java/com/android/internal/view/menu/CascadingMenuPopup.java
@@ -5,12 +5,14 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.StyleRes;
+import android.app.AppGlobals;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Rect;
import android.os.Handler;
import android.os.Parcelable;
import android.os.SystemClock;
+import android.text.TextFlags;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -46,8 +48,6 @@ import java.util.List;
*/
final class CascadingMenuPopup extends MenuPopup implements MenuPresenter, OnKeyListener,
PopupWindow.OnDismissListener {
- private static final int ITEM_LAYOUT = com.android.internal.R.layout.cascading_menu_item_layout;
-
@Retention(RetentionPolicy.SOURCE)
@IntDef({HORIZ_POSITION_LEFT, HORIZ_POSITION_RIGHT})
public @interface HorizPosition {}
@@ -190,6 +190,7 @@ final class CascadingMenuPopup extends MenuPopup implements MenuPresenter, OnKey
private Callback mPresenterCallback;
private ViewTreeObserver mTreeObserver;
private PopupWindow.OnDismissListener mOnDismissListener;
+ private final int mItemLayout;
/** Whether popup menus should disable exit animations when closing. */
private boolean mShouldCloseImmediately;
@@ -215,6 +216,12 @@ final class CascadingMenuPopup extends MenuPopup implements MenuPresenter, OnKey
res.getDimensionPixelSize(com.android.internal.R.dimen.config_prefDialogWidth));
mSubMenuHoverHandler = new Handler();
+
+ mItemLayout = AppGlobals.getIntCoreSetting(
+ TextFlags.KEY_ENABLE_NEW_CONTEXT_MENU,
+ TextFlags.ENABLE_NEW_CONTEXT_MENU_DEFAULT ? 1 : 0) != 0
+ ? com.android.internal.R.layout.cascading_menu_item_layout_material
+ : com.android.internal.R.layout.cascading_menu_item_layout;
}
@Override
@@ -348,7 +355,7 @@ final class CascadingMenuPopup extends MenuPopup implements MenuPresenter, OnKey
*/
private void showMenu(@NonNull MenuBuilder menu) {
final LayoutInflater inflater = LayoutInflater.from(mContext);
- final MenuAdapter adapter = new MenuAdapter(menu, inflater, mOverflowOnly, ITEM_LAYOUT);
+ final MenuAdapter adapter = new MenuAdapter(menu, inflater, mOverflowOnly, mItemLayout);
// Apply "force show icon" setting. There are 3 cases:
// (1) This is the top level menu and icon spacing is forced. Add spacing.
diff --git a/core/java/com/android/internal/view/menu/ListMenuItemView.java b/core/java/com/android/internal/view/menu/ListMenuItemView.java
index 0d2b29b695864..cb1abf13c1096 100644
--- a/core/java/com/android/internal/view/menu/ListMenuItemView.java
+++ b/core/java/com/android/internal/view/menu/ListMenuItemView.java
@@ -16,12 +16,12 @@
package com.android.internal.view.menu;
-import com.android.internal.R;
-
+import android.app.AppGlobals;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.text.TextFlags;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
@@ -61,6 +61,8 @@ public class ListMenuItemView extends LinearLayout
private int mMenuType;
+ private boolean mUseNewContextMenu;
+
private LayoutInflater mInflater;
private boolean mForceShowIcon;
@@ -87,6 +89,10 @@ public class ListMenuItemView extends LinearLayout
a.recycle();
b.recycle();
+
+ mUseNewContextMenu = AppGlobals.getIntCoreSetting(
+ TextFlags.KEY_ENABLE_NEW_CONTEXT_MENU,
+ TextFlags.ENABLE_NEW_CONTEXT_MENU_DEFAULT ? 1 : 0) != 0;
}
public ListMenuItemView(Context context, AttributeSet attrs, int defStyleAttr) {
@@ -283,7 +289,9 @@ public class ListMenuItemView extends LinearLayout
private void insertIconView() {
LayoutInflater inflater = getInflater();
- mIconView = (ImageView) inflater.inflate(com.android.internal.R.layout.list_menu_item_icon,
+ mIconView = (ImageView) inflater.inflate(
+ mUseNewContextMenu ? com.android.internal.R.layout.list_menu_item_fixed_size_icon :
+ com.android.internal.R.layout.list_menu_item_icon,
this, false);
addContentView(mIconView, 0);
}
diff --git a/core/res/res/layout/cascading_menu_item_layout_material.xml b/core/res/res/layout/cascading_menu_item_layout_material.xml
new file mode 100644
index 0000000000000..168ed78d66cad
--- /dev/null
+++ b/core/res/res/layout/cascading_menu_item_layout_material.xml
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core/res/res/layout/list_menu_item_fixed_size_icon.xml b/core/res/res/layout/list_menu_item_fixed_size_icon.xml
new file mode 100644
index 0000000000000..7797682d19677
--- /dev/null
+++ b/core/res/res/layout/list_menu_item_fixed_size_icon.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index b0ff86c71aca7..7906548679437 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1475,6 +1475,7 @@
+
@@ -1524,6 +1525,7 @@
+