Commit b2a22fab authored by yusufo's avatar yusufo Committed by Commit bot

Add a way to have three icon menu item

Add a layout and constants for supporting a menu
item with three icons in it.

BUG=478984

Review URL: https://codereview.chromium.org/1138993011

Cr-Commit-Position: refs/heads/master@{#330649}
parent f8c16009
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:layout_gravity="top|start"
android:orientation="horizontal">
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/button_one"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/listChoiceBackgroundIndicator"
android:scaleType="center" />
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/button_two"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/listChoiceBackgroundIndicator"
android:scaleType="center" />
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/button_three"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/listChoiceBackgroundIndicator"
android:scaleType="center" />
</LinearLayout>
......@@ -42,12 +42,16 @@ class AppMenuAdapter extends BaseAdapter {
/**
* Menu item that has four buttons. Every one of these buttons is displayed as an icon.
*/
private static final int FOUR_BUTTON_MENU_ITEM = 2;
private static final int THREE_BUTTON_MENU_ITEM = 2;
/**
* Menu item that has four buttons. Every one of these buttons is displayed as an icon.
*/
private static final int FOUR_BUTTON_MENU_ITEM = 3;
/**
* The number of view types specified above. If you add a view type you MUST increment this.
*/
private static final int VIEW_TYPE_COUNT = 3;
private static final int VIEW_TYPE_COUNT = 4;
/** MenuItem Animation Constants */
private static final int ENTER_ITEM_DURATION_MS = 350;
......@@ -87,6 +91,8 @@ class AppMenuAdapter extends BaseAdapter {
if (viewCount == 4) {
return FOUR_BUTTON_MENU_ITEM;
} else if (viewCount == 3) {
return THREE_BUTTON_MENU_ITEM;
} else if (viewCount == 2) {
return TITLE_BUTTON_MENU_ITEM;
}
......@@ -145,6 +151,31 @@ class AppMenuAdapter extends BaseAdapter {
convertView.setEnabled(isEnabled);
break;
}
case THREE_BUTTON_MENU_ITEM: {
ThreeButtonMenuItemViewHolder holder = null;
if (convertView == null) {
holder = new ThreeButtonMenuItemViewHolder();
convertView = mInflater.inflate(R.layout.three_button_menu_item, parent, false);
holder.buttons[0] =
(TintedImageButton) convertView.findViewById(R.id.button_one);
holder.buttons[1] =
(TintedImageButton) convertView.findViewById(R.id.button_two);
holder.buttons[2] =
(TintedImageButton) convertView.findViewById(R.id.button_three);
convertView.setTag(holder);
convertView.setTag(R.id.menu_item_enter_anim_id,
buildIconItemEnterAnimator(holder.buttons));
} else {
holder = (ThreeButtonMenuItemViewHolder) convertView.getTag();
}
for (int i = 0; i < 3; i++) {
setupImageButton(holder.buttons[i], item.getSubMenu().getItem(i));
}
convertView.setFocusable(false);
convertView.setEnabled(false);
break;
}
case FOUR_BUTTON_MENU_ITEM: {
FourButtonMenuItemViewHolder holder = null;
if (convertView == null) {
......@@ -315,6 +346,10 @@ class AppMenuAdapter extends BaseAdapter {
public AppMenuItemIcon image;
}
static class ThreeButtonMenuItemViewHolder {
public TintedImageButton[] buttons = new TintedImageButton[3];
}
static class FourButtonMenuItemViewHolder {
public TintedImageButton[] buttons = new TintedImageButton[4];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment