aboutsummaryrefslogtreecommitdiffstats
path: root/com_actionbarsherlock/src/com/actionbarsherlock/internal
diff options
context:
space:
mode:
authorDominik <dominik@dominikschuermann.de>2012-04-20 12:14:21 +0200
committerDominik <dominik@dominikschuermann.de>2012-06-13 19:28:23 +0300
commitda96aacf55d113c9a91b8e760b3ffef88b11f786 (patch)
treeb7e5a7780af54fdb677a147a40e7218ee5bbc123 /com_actionbarsherlock/src/com/actionbarsherlock/internal
parent784c3156dfaac289ddf5a65567385c3561426401 (diff)
downloadopen-keychain-da96aacf55d113c9a91b8e760b3ffef88b11f786.tar.gz
open-keychain-da96aacf55d113c9a91b8e760b3ffef88b11f786.tar.bz2
open-keychain-da96aacf55d113c9a91b8e760b3ffef88b11f786.zip
ActionBarSherlock 4.0.2
Diffstat (limited to 'com_actionbarsherlock/src/com/actionbarsherlock/internal')
-rw-r--r--com_actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java35
-rw-r--r--com_actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java10
-rw-r--r--com_actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java6
-rw-r--r--com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java2
-rw-r--r--com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/PropertyValuesHolder.java6
-rw-r--r--com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java2
-rw-r--r--com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.java41
-rw-r--r--com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java10
-rw-r--r--com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuView.java4
-rw-r--r--com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.java41
-rw-r--r--com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuMule.java1
-rw-r--r--com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java8
-rw-r--r--com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java4
-rw-r--r--com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java154
-rw-r--r--com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java4
-rw-r--r--com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsSpinner.java4
-rw-r--r--com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java4
17 files changed, 272 insertions, 64 deletions
diff --git a/com_actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java b/com_actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java
index eab4d2153..f080bfe95 100644
--- a/com_actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java
+++ b/com_actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java
@@ -71,6 +71,8 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu
private MenuBuilder mMenu;
/** Map between native options items and sherlock items. */
protected HashMap<android.view.MenuItem, MenuItemImpl> mNativeItemMap;
+ /** Indication of a long-press on the hardware menu key. */
+ private boolean mMenuKeyIsLongPress = false;
/** Parent view of the window decoration (action bar, mode, etc.). */
private ViewGroup mDecor;
@@ -318,6 +320,10 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu
public boolean dispatchPrepareOptionsMenu(android.view.Menu menu) {
if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] android.view.Menu: " + menu);
+ if (mActionMode != null) {
+ return false;
+ }
+
mMenuIsPrepared = false;
if (!preparePanel()) {
return false;
@@ -416,20 +422,27 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu
}
}
- if (keyCode == KeyEvent.KEYCODE_MENU && event.getAction() == KeyEvent.ACTION_UP && isReservingOverflow()) {
- if (mActionMode == null) {
- if (wActionBar.isOverflowMenuShowing()) {
- wActionBar.hideOverflowMenu();
- } else {
- wActionBar.showOverflowMenu();
+ boolean result = false;
+ if (keyCode == KeyEvent.KEYCODE_MENU && isReservingOverflow()) {
+ if (event.getAction() == KeyEvent.ACTION_DOWN && event.isLongPress()) {
+ mMenuKeyIsLongPress = true;
+ } else if (event.getAction() == KeyEvent.ACTION_UP) {
+ if (!mMenuKeyIsLongPress) {
+ if (mActionMode == null) {
+ if (wActionBar.isOverflowMenuShowing()) {
+ wActionBar.hideOverflowMenu();
+ } else {
+ wActionBar.showOverflowMenu();
+ }
+ }
+ result = true;
}
+ mMenuKeyIsLongPress = false;
}
- if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning true");
- return true;
}
- if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning false");
- return false;
+ if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning " + result);
+ return result;
}
@@ -964,7 +977,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu
@Override
public void run() {
//Invalidate if the panel menu hasn't been created before this.
- if (mMenu == null) {
+ if (!mActivity.isFinishing() && mMenu == null) {
dispatchInvalidateOptionsMenu();
}
}
diff --git a/com_actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java b/com_actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java
index 74831a79e..9afca185a 100644
--- a/com_actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java
+++ b/com_actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java
@@ -314,5 +314,15 @@ public class ActionBarSherlockNative extends ActionBarSherlock {
public MenuInflater getMenuInflater() {
return ActionBarSherlockNative.this.getMenuInflater();
}
+
+ @Override
+ public void setTag(Object tag) {
+ mActionMode.setTag(tag);
+ }
+
+ @Override
+ public Object getTag() {
+ return mActionMode.getTag();
+ }
}
}
diff --git a/com_actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java b/com_actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java
index 1fdb9278c..1bd0eaccb 100644
--- a/com_actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java
+++ b/com_actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java
@@ -335,6 +335,12 @@ public class ActionBarWrapper extends ActionBar implements android.app.ActionBar
@Override
public void onTabSelected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft) {
if (mListener != null) {
+
+ if (mFragmentTransaction == null && mActivity instanceof SherlockFragmentActivity) {
+ mFragmentTransaction = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction()
+ .disallowAddToBackStack();
+ }
+
mListener.onTabSelected(this, mFragmentTransaction);
if (mFragmentTransaction != null) {
diff --git a/com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java b/com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java
index 7de2352d4..3231080c4 100644
--- a/com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java
+++ b/com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java
@@ -947,7 +947,7 @@ public final class AnimatorSet extends Animator {
public Node clone() {
try {
Node node = (Node) super.clone();
- node.animation = (Animator) animation.clone();
+ node.animation = animation.clone();
return node;
} catch (CloneNotSupportedException e) {
throw new AssertionError();
diff --git a/com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/PropertyValuesHolder.java b/com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/PropertyValuesHolder.java
index 3a5659506..84f7504ab 100644
--- a/com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/PropertyValuesHolder.java
+++ b/com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/PropertyValuesHolder.java
@@ -256,7 +256,7 @@ public class PropertyValuesHolder implements Cloneable {
else {
PropertyValuesHolder pvh = new PropertyValuesHolder(propertyName);
pvh.mKeyframeSet = keyframeSet;
- pvh.mValueType = ((Keyframe)values[0]).getType();
+ pvh.mValueType = values[0].getType();
return pvh;
}
}
@@ -336,9 +336,9 @@ public class PropertyValuesHolder implements Cloneable {
public void setKeyframes(Keyframe... values) {
int numKeyframes = values.length;
Keyframe keyframes[] = new Keyframe[Math.max(numKeyframes,2)];
- mValueType = ((Keyframe)values[0]).getType();
+ mValueType = values[0].getType();
for (int i = 0; i < numKeyframes; ++i) {
- keyframes[i] = (Keyframe)values[i];
+ keyframes[i] = values[i];
}
mKeyframeSet = new KeyframeSet(keyframes);
}
diff --git a/com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java b/com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java
index 333d49e18..d8a12c688 100644
--- a/com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java
+++ b/com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java
@@ -458,7 +458,7 @@ public class ValueAnimator extends Animator {
mValues = values;
mValuesMap = new HashMap<String, PropertyValuesHolder>(numValues);
for (int i = 0; i < numValues; ++i) {
- PropertyValuesHolder valuesHolder = (PropertyValuesHolder) values[i];
+ PropertyValuesHolder valuesHolder = values[i];
mValuesMap.put(valuesHolder.getPropertyName(), valuesHolder);
}
// New property/values/target should cause re-initialization prior to starting
diff --git a/com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.java b/com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.java
new file mode 100644
index 000000000..129b5aaaa
--- /dev/null
+++ b/com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.java
@@ -0,0 +1,41 @@
+package com.actionbarsherlock.internal.nineoldandroids.widget;
+
+import android.content.Context;
+import android.widget.HorizontalScrollView;
+import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy;
+
+public class NineHorizontalScrollView extends HorizontalScrollView {
+ private final AnimatorProxy mProxy;
+
+ public NineHorizontalScrollView(Context context) {
+ super(context);
+ mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null;
+ }
+
+ @Override
+ public void setVisibility(int visibility) {
+ if (mProxy != null) {
+ if (visibility == GONE) {
+ clearAnimation();
+ } else if (visibility == VISIBLE) {
+ setAnimation(mProxy);
+ }
+ }
+ super.setVisibility(visibility);
+ }
+
+ public float getAlpha() {
+ if (AnimatorProxy.NEEDS_PROXY) {
+ return mProxy.getAlpha();
+ } else {
+ return super.getAlpha();
+ }
+ }
+ public void setAlpha(float alpha) {
+ if (AnimatorProxy.NEEDS_PROXY) {
+ mProxy.setAlpha(alpha);
+ } else {
+ super.setAlpha(alpha);
+ }
+ }
+}
diff --git a/com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java b/com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java
index 020b41d32..6f568c698 100644
--- a/com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java
+++ b/com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java
@@ -130,7 +130,13 @@ public class ActionMenuPresenter extends BaseMenuPresenter
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB);
} else {
- return !ViewConfiguration.get(context).hasPermanentMenuKey();
+ return !HasPermanentMenuKey.get(context);
+ }
+ }
+
+ private static class HasPermanentMenuKey {
+ public static boolean get(Context context) {
+ return ViewConfiguration.get(context).hasPermanentMenuKey();
}
}
@@ -299,7 +305,7 @@ public class ActionMenuPresenter extends BaseMenuPresenter
*/
public boolean showOverflowMenu() {
if (mReserveOverflow && !isOverflowMenuShowing() && mMenu != null && mMenuView != null &&
- mPostedOpenRunnable == null) {
+ mPostedOpenRunnable == null && !mMenu.getNonActionItems().isEmpty()) {
OverflowPopup popup = new OverflowPopup(mContext, mMenu, mOverflowButton, true);
mPostedOpenRunnable = new OpenOverflowRunnable(popup);
// Post this for later; we might still need a layout for the anchor to be right.
diff --git a/com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuView.java b/com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuView.java
index 40ab73c50..e090677a1 100644
--- a/com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuView.java
+++ b/com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuView.java
@@ -417,9 +417,9 @@ public class ActionMenuView extends IcsLinearLayout implements MenuBuilder.ItemI
final int size = v.getMeasuredWidth() + p.leftMargin + p.rightMargin;
//UNUSED nonOverflowWidth += size;
widthRemaining -= size;
- if (hasDividerBeforeChildAt(i)) {
+ //if (hasDividerBeforeChildAt(i)) {
//UNUSED nonOverflowWidth += dividerWidth;
- }
+ //}
nonOverflowCount++;
}
}
diff --git a/com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.java b/com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.java
index d923c4ef8..907a7aa04 100644
--- a/com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.java
+++ b/com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.java
@@ -9,11 +9,12 @@ import com.actionbarsherlock.view.ActionProvider;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.SubMenu;
-public class MenuItemWrapper implements MenuItem, android.view.MenuItem.OnMenuItemClickListener, android.view.MenuItem.OnActionExpandListener {
+public class MenuItemWrapper implements MenuItem, android.view.MenuItem.OnMenuItemClickListener {
private final android.view.MenuItem mNativeItem;
private SubMenu mSubMenu = null;
private OnMenuItemClickListener mMenuItemClickListener = null;
private OnActionExpandListener mActionExpandListener = null;
+ private android.view.MenuItem.OnActionExpandListener mNativeActionExpandListener = null;
public MenuItemWrapper(android.view.MenuItem nativeItem) {
@@ -262,24 +263,30 @@ public class MenuItemWrapper implements MenuItem, android.view.MenuItem.OnMenuIt
@Override
public MenuItem setOnActionExpandListener(OnActionExpandListener listener) {
mActionExpandListener = listener;
- //Register ourselves as the listener to proxy
- mNativeItem.setOnActionExpandListener(this);
- return this;
- }
- @Override
- public boolean onMenuItemActionCollapse(android.view.MenuItem item) {
- if (mActionExpandListener != null) {
- return mActionExpandListener.onMenuItemActionCollapse(this);
+ if (mNativeActionExpandListener == null) {
+ mNativeActionExpandListener = new android.view.MenuItem.OnActionExpandListener() {
+ @Override
+ public boolean onMenuItemActionExpand(android.view.MenuItem menuItem) {
+ if (mActionExpandListener != null) {
+ return mActionExpandListener.onMenuItemActionExpand(MenuItemWrapper.this);
+ }
+ return false;
+ }
+
+ @Override
+ public boolean onMenuItemActionCollapse(android.view.MenuItem menuItem) {
+ if (mActionExpandListener != null) {
+ return mActionExpandListener.onMenuItemActionCollapse(MenuItemWrapper.this);
+ }
+ return false;
+ }
+ };
+
+ //Register our inner-class as the listener to proxy method calls
+ mNativeItem.setOnActionExpandListener(mNativeActionExpandListener);
}
- return false;
- }
- @Override
- public boolean onMenuItemActionExpand(android.view.MenuItem item) {
- if (mActionExpandListener != null) {
- return mActionExpandListener.onMenuItemActionExpand(this);
- }
- return false;
+ return this;
}
}
diff --git a/com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuMule.java b/com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuMule.java
index 183e87a56..b2385b904 100644
--- a/com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuMule.java
+++ b/com_actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuMule.java
@@ -15,6 +15,7 @@ public class MenuMule implements Menu {
private final com.actionbarsherlock.view.Menu mMenu;
+ public boolean mDispatchShow = false;
public MenuMule(com.actionbarsherlock.view.Menu menu) {
mMenu = menu;
diff --git a/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java b/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java
index ae6035892..4636de17f 100644
--- a/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java
+++ b/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java
@@ -132,7 +132,7 @@ public class ActionBarView extends AbsActionBarView {
private SpinnerAdapter mSpinnerAdapter;
private OnNavigationListener mCallback;
- private Runnable mTabSelector;
+ //UNUSED private Runnable mTabSelector;
private ExpandedActionViewMenuPresenter mExpandedMenuPresenter;
View mExpandedActionView;
@@ -250,7 +250,7 @@ public class ActionBarView extends AbsActionBarView {
final int customNavId = a.getResourceId(R.styleable.SherlockActionBar_customNavigationLayout, 0);
if (customNavId != 0) {
- mCustomNavView = (View) inflater.inflate(customNavId, this, false);
+ mCustomNavView = inflater.inflate(customNavId, this, false);
mNavigationMode = ActionBar.NAVIGATION_MODE_STANDARD;
setDisplayOptions(mDisplayOptions | ActionBar.DISPLAY_SHOW_CUSTOM);
}
@@ -383,7 +383,7 @@ public class ActionBarView extends AbsActionBarView {
@Override
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
- removeCallbacks(mTabSelector);
+ //UNUSED removeCallbacks(mTabSelector);
if (mActionMenuPresenter != null) {
mActionMenuPresenter.hideOverflowMenu();
mActionMenuPresenter.hideSubMenus();
@@ -825,7 +825,7 @@ public class ActionBarView extends AbsActionBarView {
this, false);
mTitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_title);
mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_subtitle);
- mTitleUpView = (View) mTitleLayout.findViewById(R.id.abs__up);
+ mTitleUpView = mTitleLayout.findViewById(R.id.abs__up);
mTitleLayout.setOnClickListener(mUpClickListener);
diff --git a/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java b/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java
index 1067b4191..673ec554f 100644
--- a/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java
+++ b/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java
@@ -18,6 +18,10 @@ public class CapitalizingTextView extends TextView {
private boolean mAllCaps;
+ public CapitalizingTextView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
public CapitalizingTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
diff --git a/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java b/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java
index 2edda7264..1b4463a59 100644
--- a/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java
+++ b/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java
@@ -10,7 +10,10 @@ import com.actionbarsherlock.internal.nineoldandroids.widget.NineLinearLayout;
/**
* A simple extension of a regular linear layout that supports the divider API
- * of Android 4.0+.
+ * of Android 4.0+. The dividers are added adjacent to the children by changing
+ * their layout params. If you need to rely on the margins which fall in the
+ * same orientation as the layout you should wrap the child in a simple
+ * {@link android.widget.FrameLayout} so it can receive the margin.
*/
public class IcsLinearLayout extends NineLinearLayout {
private static final int[] LinearLayout = new int[] {
@@ -42,6 +45,7 @@ public class IcsLinearLayout extends NineLinearLayout {
private Drawable mDivider;
private int mDividerWidth;
+ private int mDividerHeight;
private int mShowDividers;
private int mDividerPadding;
@@ -59,6 +63,29 @@ public class IcsLinearLayout extends NineLinearLayout {
}
/**
+ * Set how dividers should be shown between items in this layout
+ *
+ * @param showDividers One or more of {@link #SHOW_DIVIDER_BEGINNING},
+ * {@link #SHOW_DIVIDER_MIDDLE}, or {@link #SHOW_DIVIDER_END},
+ * or {@link #SHOW_DIVIDER_NONE} to show no dividers.
+ */
+ public void setShowDividers(int showDividers) {
+ if (showDividers != mShowDividers) {
+ requestLayout();
+ invalidate(); //XXX This is required if you are toggling a divider off
+ }
+ mShowDividers = showDividers;
+ }
+
+ /**
+ * @return A flag set indicating how dividers should be shown around items.
+ * @see #setShowDividers(int)
+ */
+ public int getShowDividers() {
+ return mShowDividers;
+ }
+
+ /**
* Set a drawable to be used as a divider between items.
* @param divider Drawable that will divide each item.
* @see #setShowDividers(int)
@@ -70,14 +97,40 @@ public class IcsLinearLayout extends NineLinearLayout {
mDivider = divider;
if (divider != null) {
mDividerWidth = divider.getIntrinsicWidth();
+ mDividerHeight = divider.getIntrinsicHeight();
} else {
mDividerWidth = 0;
+ mDividerHeight = 0;
}
setWillNotDraw(divider == null);
requestLayout();
}
/**
+ * Set padding displayed on both ends of dividers.
+ *
+ * @param padding Padding value in pixels that will be applied to each end
+ *
+ * @see #setShowDividers(int)
+ * @see #setDividerDrawable(Drawable)
+ * @see #getDividerPadding()
+ */
+ public void setDividerPadding(int padding) {
+ mDividerPadding = padding;
+ }
+
+ /**
+ * Get the padding size used to inset dividers in pixels
+ *
+ * @see #setShowDividers(int)
+ * @see #setDividerDrawable(Drawable)
+ * @see #setDividerPadding(int)
+ */
+ public int getDividerPadding() {
+ return mDividerPadding;
+ }
+
+ /**
* Get the width of the current divider drawable.
*
* @hide Used internally by framework.
@@ -89,9 +142,27 @@ public class IcsLinearLayout extends NineLinearLayout {
@Override
protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) {
final int index = indexOfChild(child);
+ final int orientation = getOrientation();
+ final LayoutParams params = (LayoutParams) child.getLayoutParams();
if (hasDividerBeforeChildAt(index)) {
- //Account for the divider by pushing everything left
- ((LayoutParams)child.getLayoutParams()).leftMargin = mDividerWidth;
+ if (orientation == VERTICAL) {
+ //Account for the divider by pushing everything up
+ params.topMargin = mDividerHeight;
+ } else {
+ //Account for the divider by pushing everything left
+ params.leftMargin = mDividerWidth;
+ }
+ }
+
+ final int count = getChildCount();
+ if (index == count - 1) {
+ if (hasDividerBeforeChildAt(count)) {
+ if (orientation == VERTICAL) {
+ params.bottomMargin = mDividerHeight;
+ } else {
+ params.rightMargin = mDividerWidth;
+ }
+ }
}
super.measureChildWithMargins(child, parentWidthMeasureSpec, widthUsed, parentHeightMeasureSpec, heightUsed);
}
@@ -99,32 +170,73 @@ public class IcsLinearLayout extends NineLinearLayout {
@Override
protected void onDraw(Canvas canvas) {
if (mDivider != null) {
- final int count = getChildCount();
- for (int i = 0; i < count; i++) {
- final View child = getChildAt(i);
- if (child != null && child.getVisibility() != GONE) {
- if (hasDividerBeforeChildAt(i)) {
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- final int left = child.getLeft() - lp.leftMargin;
- drawVerticalDivider(canvas, left);
- }
+ if (getOrientation() == VERTICAL) {
+ drawDividersVertical(canvas);
+ } else {
+ drawDividersHorizontal(canvas);
+ }
+ }
+ super.onDraw(canvas);
+ }
+
+ void drawDividersVertical(Canvas canvas) {
+ final int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ final View child = getChildAt(i);
+
+ if (child != null && child.getVisibility() != GONE) {
+ if (hasDividerBeforeChildAt(i)) {
+ final LayoutParams lp = (LayoutParams) child.getLayoutParams();
+ final int top = child.getTop() - lp.topMargin/* - mDividerHeight*/;
+ drawHorizontalDivider(canvas, top);
}
}
+ }
+
+ if (hasDividerBeforeChildAt(count)) {
+ final View child = getChildAt(count - 1);
+ int bottom = 0;
+ if (child == null) {
+ bottom = getHeight() - getPaddingBottom() - mDividerHeight;
+ } else {
+ final LayoutParams lp = (LayoutParams) child.getLayoutParams();
+ bottom = child.getBottom()/* + lp.bottomMargin*/;
+ }
+ drawHorizontalDivider(canvas, bottom);
+ }
+ }
- if (hasDividerBeforeChildAt(count)) {
- final View child = getChildAt(count - 1);
- int right = 0;
- if (child == null) {
- right = getWidth() - getPaddingRight() - mDividerWidth;
- } else {
+ void drawDividersHorizontal(Canvas canvas) {
+ final int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ final View child = getChildAt(i);
+
+ if (child != null && child.getVisibility() != GONE) {
+ if (hasDividerBeforeChildAt(i)) {
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- right = child.getRight() + lp.rightMargin;
+ final int left = child.getLeft() - lp.leftMargin/* - mDividerWidth*/;
+ drawVerticalDivider(canvas, left);
}
- drawVerticalDivider(canvas, right);
}
}
- super.onDraw(canvas);
+ if (hasDividerBeforeChildAt(count)) {
+ final View child = getChildAt(count - 1);
+ int right = 0;
+ if (child == null) {
+ right = getWidth() - getPaddingRight() - mDividerWidth;
+ } else {
+ final LayoutParams lp = (LayoutParams) child.getLayoutParams();
+ right = child.getRight()/* + lp.rightMargin*/;
+ }
+ drawVerticalDivider(canvas, right);
+ }
+ }
+
+ void drawHorizontalDivider(Canvas canvas, int top) {
+ mDivider.setBounds(getPaddingLeft() + mDividerPadding, top,
+ getWidth() - getPaddingRight() - mDividerPadding, top + mDividerHeight);
+ mDivider.draw(canvas);
}
void drawVerticalDivider(Canvas canvas, int left) {
diff --git a/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java b/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java
index e06bcb1c4..d13c6cea9 100644
--- a/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java
+++ b/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java
@@ -74,6 +74,10 @@ public class IcsListPopupWindow {
public static final int POSITION_PROMPT_ABOVE = 0;
public static final int POSITION_PROMPT_BELOW = 1;
+ public IcsListPopupWindow(Context context) {
+ this(context, null, R.attr.listPopupWindowStyle);
+ }
+
public IcsListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr) {
mContext = context;
mPopup = new PopupWindow(context, attrs, defStyleAttr);
diff --git a/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsSpinner.java b/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsSpinner.java
index 319c9ab83..038d1e031 100644
--- a/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsSpinner.java
+++ b/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsSpinner.java
@@ -78,6 +78,10 @@ public class IcsSpinner extends IcsAbsSpinner implements OnClickListener {
private Rect mTempRect = new Rect();
+ public IcsSpinner(Context context, AttributeSet attrs) {
+ this(context, attrs, R.attr.actionDropDownStyle);
+ }
+
/**
* Construct a new spinner with the given context's theme, the supplied attribute set,
* and default style.
diff --git a/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java b/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java
index 82b72d8e2..1a532e06c 100644
--- a/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java
+++ b/com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java
@@ -29,7 +29,6 @@ import android.view.ViewParent;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.widget.BaseAdapter;
-import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
@@ -37,12 +36,13 @@ import com.actionbarsherlock.R;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.internal.nineoldandroids.animation.Animator;
import com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator;
+import com.actionbarsherlock.internal.nineoldandroids.widget.NineHorizontalScrollView;
/**
* This widget implements the dynamic action bar tab behavior that can change
* across different configurations or circumstances.
*/
-public class ScrollingTabContainerView extends HorizontalScrollView
+public class ScrollingTabContainerView extends NineHorizontalScrollView
implements IcsAdapterView.OnItemSelectedListener {
//UNUSED private static final String TAG = "ScrollingTabContainerView";
Runnable mTabSelector;