diff options
Diffstat (limited to 'com_actionbarsherlock/src/com/actionbarsherlock/internal/widget')
6 files changed, 151 insertions, 27 deletions
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; |
