Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 849d1be1 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix wrongly applied material theme for StandardMenuPopup" into main

parents d588b98d 50a9619b
Loading
Loading
Loading
Loading
+1 −11
Original line number Original line Diff line number Diff line
@@ -16,12 +16,10 @@


package com.android.internal.view.menu;
package com.android.internal.view.menu;


import android.app.AppGlobals;
import android.content.Context;
import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.text.TextFlags;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View;
@@ -61,8 +59,6 @@ public class ListMenuItemView extends LinearLayout


    private int mMenuType;
    private int mMenuType;


    private boolean mUseNewContextMenu;

    private LayoutInflater mInflater;
    private LayoutInflater mInflater;


    private boolean mForceShowIcon;
    private boolean mForceShowIcon;
@@ -89,10 +85,6 @@ public class ListMenuItemView extends LinearLayout


        a.recycle();
        a.recycle();
        b.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) {
    public ListMenuItemView(Context context, AttributeSet attrs, int defStyleAttr) {
@@ -289,9 +281,7 @@ public class ListMenuItemView extends LinearLayout


    private void insertIconView() {
    private void insertIconView() {
        LayoutInflater inflater = getInflater();
        LayoutInflater inflater = getInflater();
        mIconView = (ImageView) inflater.inflate(
        mIconView = (ImageView) inflater.inflate(com.android.internal.R.layout.list_menu_item_icon,
                mUseNewContextMenu ? com.android.internal.R.layout.list_menu_item_fixed_size_icon :
                        com.android.internal.R.layout.list_menu_item_icon,
                this, false);
                this, false);
        addContentView(mIconView, 0);
        addContentView(mIconView, 0);
    }
    }
+14 −4
Original line number Original line Diff line number Diff line
@@ -16,24 +16,26 @@


package com.android.internal.view.menu;
package com.android.internal.view.menu;


import android.app.AppGlobals;
import android.content.Context;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.Resources;
import android.os.Parcelable;
import android.os.Parcelable;
import android.text.TextFlags;
import android.view.Gravity;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View;
import android.view.View.OnAttachStateChangeListener;
import android.view.View.OnAttachStateChangeListener;
import android.view.View.OnKeyListener;
import android.view.View.OnKeyListener;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.FrameLayout;
import android.widget.FrameLayout;
import android.widget.ListView;
import android.widget.ListView;
import android.widget.MenuPopupWindow;
import android.widget.MenuPopupWindow;
import android.widget.PopupWindow;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.PopupWindow.OnDismissListener;
import android.widget.PopupWindow.OnDismissListener;
import android.widget.TextView;


import java.util.Objects;
import java.util.Objects;


@@ -44,6 +46,8 @@ import java.util.Objects;
final class StandardMenuPopup extends MenuPopup implements OnDismissListener, OnItemClickListener,
final class StandardMenuPopup extends MenuPopup implements OnDismissListener, OnItemClickListener,
        MenuPresenter, OnKeyListener {
        MenuPresenter, OnKeyListener {
    private static final int ITEM_LAYOUT = com.android.internal.R.layout.popup_menu_item_layout;
    private static final int ITEM_LAYOUT = com.android.internal.R.layout.popup_menu_item_layout;
    private static final int ITEM_LAYOUT_MATERIAL =
            com.android.internal.R.layout.popup_menu_item_layout_material;


    private final Context mContext;
    private final Context mContext;


@@ -53,6 +57,7 @@ final class StandardMenuPopup extends MenuPopup implements OnDismissListener, On
    private final int mPopupMaxWidth;
    private final int mPopupMaxWidth;
    private final int mPopupStyleAttr;
    private final int mPopupStyleAttr;
    private final int mPopupStyleRes;
    private final int mPopupStyleRes;

    // The popup window is final in order to couple its lifecycle to the lifecycle of the
    // The popup window is final in order to couple its lifecycle to the lifecycle of the
    // StandardMenuPopup.
    // StandardMenuPopup.
    private final MenuPopupWindow mPopup;
    private final MenuPopupWindow mPopup;
@@ -114,10 +119,15 @@ final class StandardMenuPopup extends MenuPopup implements OnDismissListener, On
    public StandardMenuPopup(Context context, MenuBuilder menu, View anchorView, int popupStyleAttr,
    public StandardMenuPopup(Context context, MenuBuilder menu, View anchorView, int popupStyleAttr,
            int popupStyleRes, boolean overflowOnly) {
            int popupStyleRes, boolean overflowOnly) {
        mContext = Objects.requireNonNull(context);
        mContext = Objects.requireNonNull(context);
        boolean useNewContextMenu = AppGlobals.getIntCoreSetting(
                TextFlags.KEY_ENABLE_NEW_CONTEXT_MENU,
                TextFlags.ENABLE_NEW_CONTEXT_MENU_DEFAULT ? 1 : 0) != 0;

        mMenu = menu;
        mMenu = menu;
        mOverflowOnly = overflowOnly;
        mOverflowOnly = overflowOnly;
        final LayoutInflater inflater = LayoutInflater.from(context);
        final LayoutInflater inflater = LayoutInflater.from(context);
        mAdapter = new MenuAdapter(menu, inflater, mOverflowOnly, ITEM_LAYOUT);
        mAdapter = new MenuAdapter(menu, inflater, mOverflowOnly,
                useNewContextMenu ? ITEM_LAYOUT_MATERIAL : ITEM_LAYOUT);
        mPopupStyleAttr = popupStyleAttr;
        mPopupStyleAttr = popupStyleAttr;
        mPopupStyleRes = popupStyleRes;
        mPopupStyleRes = popupStyleRes;


+1 −1
Original line number Original line Diff line number Diff line
@@ -20,7 +20,7 @@
    android:layout_height="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:layout_gravity="center_vertical"
    android:layout_marginStart="8dip"
    android:layout_marginStart="8dip"
    android:layout_marginEnd="-8dip"
    android:layout_marginEnd="8dip"
    android:layout_marginTop="8dip"
    android:layout_marginTop="8dip"
    android:layout_marginBottom="8dip"
    android:layout_marginBottom="8dip"
    android:scaleType="centerInside"
    android:scaleType="centerInside"
+91 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2024 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.

     Forked from the popup_menu_item_layout.xml for material support. When you edit this file, you
     may also need to update that file.
-->

<com.android.internal.view.menu.ListMenuItemView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minWidth="196dip"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/group_divider"
        android:layout_width="match_parent"
        android:layout_height="1dip"
        android:layout_marginTop="4dip"
        android:layout_marginBottom="4dip"
        android:background="@drawable/list_divider_material" />

    <LinearLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="?attr/dropdownListPreferredItemHeight"
        android:paddingEnd="16dip"
        android:duplicateParentState="true" >

        <!-- Icon will be inserted here. -->

        <!-- The title and summary have some gap between them,
        and this 'group' should be centered vertically. -->
        <RelativeLayout
            android:layout_width="0dip"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:duplicateParentState="true">

            <TextView
                android:id="@+id/title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_alignParentStart="true"
                android:textAppearance="?attr/textAppearanceLargePopupMenu"
                android:singleLine="true"
                android:duplicateParentState="true"
                android:ellipsize="marquee"
                android:fadingEdge="horizontal"
                android:textAlignment="viewStart" />

            <TextView
                android:id="@+id/shortcut"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/title"
                android:layout_alignParentStart="true"
                android:textAppearance="?attr/textAppearanceSmallPopupMenu"
                android:singleLine="true"
                android:duplicateParentState="true"
                android:textAlignment="viewStart" />

        </RelativeLayout>

        <ImageView
            android:id="@+id/submenuarrow"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginStart="8dp"
            android:scaleType="center"
            android:visibility="gone" />

        <!-- Checkbox, and/or radio button will be inserted here. -->

    </LinearLayout>

</com.android.internal.view.menu.ListMenuItemView>
+1 −0
Original line number Original line Diff line number Diff line
@@ -1527,6 +1527,7 @@
  <java-symbol type="layout" name="number_picker" />
  <java-symbol type="layout" name="number_picker" />
  <java-symbol type="layout" name="permissions_package_list_item" />
  <java-symbol type="layout" name="permissions_package_list_item" />
  <java-symbol type="layout" name="popup_menu_item_layout" />
  <java-symbol type="layout" name="popup_menu_item_layout" />
  <java-symbol type="layout" name="popup_menu_item_layout_material" />
  <java-symbol type="layout" name="popup_menu_header_item_layout" />
  <java-symbol type="layout" name="popup_menu_header_item_layout" />
  <java-symbol type="layout" name="remote_views_adapter_default_loading_view" />
  <java-symbol type="layout" name="remote_views_adapter_default_loading_view" />
  <java-symbol type="layout" name="search_bar" />
  <java-symbol type="layout" name="search_bar" />