Skip to content
This repository has been archived by the owner on Jun 5, 2018. It is now read-only.

Commit

Permalink
Fix #655
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Shatunov committed Nov 2, 2013
1 parent 6ee21a2 commit 090edf4
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 33 deletions.
18 changes: 18 additions & 0 deletions issues/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
</intent-filter>
</activity>

<activity
android:name=".i511.MainActivity"
android:label="Issue #511">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="org.holoeverywhere.category.ISSUE_LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".i569.MainActivity"
android:label="Issue #569">
Expand Down Expand Up @@ -101,6 +110,15 @@
</intent-filter>
</activity>

<activity
android:name=".i655.MainActivity"
android:label="Issue #655">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="org.holoeverywhere.category.ISSUE_LAUNCHER" />
</intent-filter>
</activity>

<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCE7ryckjuvXRIW5H0mZr2S7b1x9OReInM" />
Expand Down
26 changes: 26 additions & 0 deletions issues/res/menu/i655_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:holo="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_collapsed"
android:title="collapsed"
holo:showAsAction="always|collapseActionView">
<menu>
<item
android:id="@+id/menu1"
android:showAsAction="always"
android:title="menu1"
holo:showAsAction="always" />
<item
android:id="@+id/menu2"
android:showAsAction="always"
android:title="menu2"
holo:showAsAction="always" />
<item
android:id="@+id/menu3"
android:showAsAction="always"
android:title="menu3"
holo:showAsAction="always" />
</menu>
</item>
</menu>
15 changes: 15 additions & 0 deletions issues/src/org/holoeverywhere/issues/i655/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.holoeverywhere.issues.i655;

import android.view.Menu;

import org.holoeverywhere.app.Activity;
import org.holoeverywhere.issues.R;


public class MainActivity extends Activity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.i655_menu, menu);
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@
package android.support.v7.internal.view.menu;

import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Parcel;
import android.os.Parcelable;
import org.holoeverywhere.R;
import android.support.v7.internal.view.ActionBarPolicy;
import android.support.v4.view.ActionProvider;
import android.support.v7.internal.view.ActionBarPolicy;
import android.support.v7.internal.view.menu.ActionMenuView.ActionMenuChildView;
import android.util.SparseBooleanArray;
import android.view.MenuItem;
Expand All @@ -34,6 +32,8 @@
import android.view.ViewGroup;
import android.widget.ImageButton;

import org.holoeverywhere.R;

import java.util.ArrayList;

/**
Expand All @@ -45,7 +45,10 @@ public class ActionMenuPresenter extends BaseMenuPresenter
implements ActionProvider.SubUiVisibilityListener {

private static final String TAG = "ActionMenuPresenter";

final PopupPresenterCallback mPopupPresenterCallback = new PopupPresenterCallback();
// Group IDs that have been added as actions - used temporarily, allocated here for reuse.
private final SparseBooleanArray mActionButtonGroups = new SparseBooleanArray();
int mOpenSubMenuId;
private View mOverflowButton;
private boolean mReserveOverflow;
private boolean mReserveOverflowSet;
Expand All @@ -56,22 +59,12 @@ public class ActionMenuPresenter extends BaseMenuPresenter
private boolean mStrictWidthLimit;
private boolean mWidthLimitSet;
private boolean mExpandedActionViewsExclusive;

private int mMinCellSize;

// Group IDs that have been added as actions - used temporarily, allocated here for reuse.
private final SparseBooleanArray mActionButtonGroups = new SparseBooleanArray();

private View mScrapActionButtonView;

private OverflowPopup mOverflowPopup;
private ActionButtonSubmenu mActionButtonPopup;

private OpenOverflowRunnable mPostedOpenRunnable;

final PopupPresenterCallback mPopupPresenterCallback = new PopupPresenterCallback();
int mOpenSubMenuId;

public ActionMenuPresenter(Context context) {
super(context, R.layout.abc_action_menu_layout, R.layout.abc_action_menu_item_layout);
}
Expand Down Expand Up @@ -263,8 +256,9 @@ public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
}

mOpenSubMenuId = subMenu.getItem().getItemId();
mActionButtonPopup = new ActionButtonSubmenu(subMenu);
mActionButtonPopup.show(null);
mActionButtonPopup = new ActionButtonSubmenu(mContext, subMenu);
mActionButtonPopup.setAnchorView(anchor);
mActionButtonPopup.show();
super.onSubMenuSelected(subMenu);
return true;
}
Expand Down Expand Up @@ -538,6 +532,16 @@ public void onSubUiVisibilityChanged(boolean isVisible) {

private static class SavedState implements Parcelable {

public static final Parcelable.Creator<SavedState> CREATOR
= new Parcelable.Creator<SavedState>() {
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
}

public SavedState[] newArray(int size) {
return new SavedState[size];
}
};
public int openSubMenuId;

SavedState() {
Expand All @@ -556,17 +560,6 @@ public int describeContents() {
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(openSubMenuId);
}

public static final Parcelable.Creator<SavedState> CREATOR
= new Parcelable.Creator<SavedState>() {
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
}

public SavedState[] newArray(int size) {
return new SavedState[size];
}
};
}

private class OverflowMenuButton extends ImageButton implements ActionMenuChildView {
Expand Down Expand Up @@ -603,7 +596,7 @@ public boolean needsDividerAfter() {
private class OverflowPopup extends MenuPopupHelper {

public OverflowPopup(Context context, MenuBuilder menu, View anchorView,
boolean overflowOnly) {
boolean overflowOnly) {
super(context, menu, anchorView, overflowOnly);
setCallback(mPopupPresenterCallback);
}
Expand All @@ -616,16 +609,36 @@ public void onDismiss() {
}
}

private class ActionButtonSubmenu extends MenuDialogHelper {
private class ActionButtonSubmenu extends MenuPopupHelper {
private SubMenuBuilder mSubMenu;

public ActionButtonSubmenu(Context context, SubMenuBuilder subMenu) {
super(context, subMenu);
mSubMenu = subMenu;

MenuItemImpl item = (MenuItemImpl) subMenu.getItem();
if (!item.isActionButton()) {
// Give a reasonable anchor to nested submenus.
setAnchorView(mOverflowButton == null ? (View) mMenuView : mOverflowButton);
}

public ActionButtonSubmenu(SubMenuBuilder subMenu) {
super(subMenu);
setCallback(mPopupPresenterCallback);

boolean preserveIconSpacing = false;
final int count = subMenu.size();
for (int i = 0; i < count; i++) {
MenuItem childItem = subMenu.getItem(i);
if (childItem.isVisible() && childItem.getIcon() != null) {
preserveIconSpacing = true;
break;
}
}
setForceShowIcon(preserveIconSpacing);
}

@Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
public void onDismiss() {
super.onDismiss();
mActionButtonPopup = null;
mOpenSubMenuId = 0;
}
Expand Down

0 comments on commit 090edf4

Please sign in to comment.