mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
5c140c7ef2
--HG-- rename : mobile/android/base/GeckoMenu.java => mobile/android/base/menu/GeckoMenu.java rename : mobile/android/base/GeckoMenuInflater.java => mobile/android/base/menu/GeckoMenuInflater.java rename : mobile/android/base/GeckoMenuItem.java => mobile/android/base/menu/GeckoMenuItem.java rename : mobile/android/base/GeckoSubMenu.java => mobile/android/base/menu/GeckoSubMenu.java rename : mobile/android/base/MenuItemActionBar.java => mobile/android/base/menu/MenuItemActionBar.java rename : mobile/android/base/MenuItemDefault.java => mobile/android/base/menu/MenuItemDefault.java rename : mobile/android/base/MenuPanel.java => mobile/android/base/menu/MenuPanel.java rename : mobile/android/base/MenuPopup.java => mobile/android/base/menu/MenuPopup.java rename : mobile/android/base/Divider.java => mobile/android/base/widget/Divider.java rename : mobile/android/base/GeckoPopupMenu.java => mobile/android/base/widget/GeckoPopupMenu.java extra : rebase_source : 3b51b8af8318e346fe41b3ab7c18421d67b1359b
49 lines
1.9 KiB
Java
49 lines
1.9 KiB
Java
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
package org.mozilla.gecko.menu;
|
|
|
|
import org.mozilla.gecko.R;
|
|
|
|
import android.content.Context;
|
|
import android.os.Build;
|
|
import android.util.AttributeSet;
|
|
import android.util.DisplayMetrics;
|
|
import android.view.ViewGroup;
|
|
import android.view.accessibility.AccessibilityEvent;
|
|
import android.widget.LinearLayout;
|
|
|
|
/**
|
|
* The outer container for the custom menu. On phones with h/w menu button,
|
|
* this is given to Android which inflates it to the right panel. On phones
|
|
* with s/w menu button, this is added to a MenuPopup.
|
|
*/
|
|
public class MenuPanel extends LinearLayout {
|
|
public MenuPanel(Context context, AttributeSet attrs) {
|
|
super(context, attrs);
|
|
|
|
int width = (int) context.getResources().getDimension(R.dimen.menu_item_row_width);
|
|
setLayoutParams(new ViewGroup.LayoutParams(width, ViewGroup.LayoutParams.WRAP_CONTENT));
|
|
}
|
|
|
|
@Override
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
|
|
// Restrict the height to 75% of the screen-height. heightPixels changes during rotation.
|
|
DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
|
|
int restrictedHeightSpec = MeasureSpec.makeMeasureSpec((int) (0.75 * metrics.heightPixels), MeasureSpec.AT_MOST);
|
|
|
|
super.onMeasure(widthMeasureSpec, restrictedHeightSpec);
|
|
}
|
|
|
|
@Override
|
|
public boolean dispatchPopulateAccessibilityEvent (AccessibilityEvent event) {
|
|
if (Build.VERSION.SDK_INT >= 14) // Build.VERSION_CODES.ICE_CREAM_SANDWICH
|
|
onPopulateAccessibilityEvent(event);
|
|
return true;
|
|
}
|
|
}
|