OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.appmenu; | 5 package org.chromium.chrome.browser.appmenu; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.content.res.Resources; | 8 import android.content.res.Resources; |
9 import android.graphics.Rect; | 9 import android.graphics.Rect; |
10 import android.view.KeyEvent; | 10 import android.view.KeyEvent; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 List<MenuItem> menuItems = new ArrayList<MenuItem>(); | 111 List<MenuItem> menuItems = new ArrayList<MenuItem>(); |
112 for (int i = 0; i < numItems; ++i) { | 112 for (int i = 0; i < numItems; ++i) { |
113 MenuItem item = mMenu.getItem(i); | 113 MenuItem item = mMenu.getItem(i); |
114 if (item.isVisible()) { | 114 if (item.isVisible()) { |
115 menuItems.add(item); | 115 menuItems.add(item); |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 // A List adapter for visible items in the Menu. The first row is added
as a header to the | 119 // A List adapter for visible items in the Menu. The first row is added
as a header to the |
120 // list view. | 120 // list view. |
121 mAdapter = new AppMenuAdapter(this, menuItems, LayoutInflater.from(conte
xt)); | 121 mAdapter = new AppMenuAdapter( |
| 122 this, menuItems, LayoutInflater.from(context), !mIsByHardwareBut
ton); |
122 mPopup.setAdapter(mAdapter); | 123 mPopup.setAdapter(mAdapter); |
123 | 124 |
124 setMenuHeight(menuItems.size(), visibleDisplayFrame); | 125 setMenuHeight(menuItems.size(), visibleDisplayFrame); |
125 setPopupOffset(mPopup, mCurrentScreenRotation, visibleDisplayFrame); | 126 setPopupOffset(mPopup, mCurrentScreenRotation, visibleDisplayFrame); |
126 mPopup.setOnItemClickListener(this); | 127 mPopup.setOnItemClickListener(this); |
127 mPopup.show(); | 128 mPopup.show(); |
128 mPopup.getListView().setItemsCanFocus(true); | 129 mPopup.getListView().setItemsCanFocus(true); |
129 mPopup.getListView().setOnKeyListener(this); | 130 mPopup.getListView().setOnKeyListener(this); |
130 | 131 |
131 mHandler.onMenuVisibilityChanged(true); | 132 mHandler.onMenuVisibilityChanged(true); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 padding.top + padding.bottom); | 259 padding.top + padding.bottom); |
259 } else { | 260 } else { |
260 mPopup.setHeight(spaceForFullItems - mItemRowHeight + spaceForPa
rtialItem + | 261 mPopup.setHeight(spaceForFullItems - mItemRowHeight + spaceForPa
rtialItem + |
261 padding.top + padding.bottom); | 262 padding.top + padding.bottom); |
262 } | 263 } |
263 } else { | 264 } else { |
264 mPopup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); | 265 mPopup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); |
265 } | 266 } |
266 } | 267 } |
267 } | 268 } |
OLD | NEW |