aboutsummaryrefslogtreecommitdiffstats
path: root/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2012-12-12 13:58:22 +0100
committerDominik Schürmann <dominik@dominikschuermann.de>2012-12-12 13:58:22 +0100
commite3fea30abe9f9f16dbfa5e989e7058842b085b7e (patch)
tree06c5bdcb4e8d18d315115a8a0fc414a1d0d64ccc /APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget
parenta4ea3e65a7feb9175e206b4aa93662bf51457072 (diff)
downloadopen-keychain-e3fea30abe9f9f16dbfa5e989e7058842b085b7e.tar.gz
open-keychain-e3fea30abe9f9f16dbfa5e989e7058842b085b7e.tar.bz2
open-keychain-e3fea30abe9f9f16dbfa5e989e7058842b085b7e.zip
Update ActionBarSherlock
Diffstat (limited to 'APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget')
-rw-r--r--APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java13
-rw-r--r--APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java10
-rw-r--r--APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/CollapsibleActionViewWrapper.java30
-rw-r--r--APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsColorDrawable.java41
-rw-r--r--APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java154
-rw-r--r--APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java1
6 files changed, 239 insertions, 10 deletions
diff --git a/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java b/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java
index 5e5aa2867..1d9c68b37 100644
--- a/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java
+++ b/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java
@@ -18,8 +18,11 @@ package com.actionbarsherlock.internal.widget;
import android.content.Context;
import android.content.res.TypedArray;
+import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
+import android.os.Build;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
@@ -60,6 +63,16 @@ public class ActionBarContainer extends NineFrameLayout {
mStackedBackground = a.getDrawable(
R.styleable.SherlockActionBar_backgroundStacked);
+ //Fix for issue #379
+ if (mStackedBackground instanceof ColorDrawable && Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
+ Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
+ Canvas c = new Canvas(bitmap);
+ mStackedBackground.draw(c);
+ int color = bitmap.getPixel(0, 0);
+ bitmap.recycle();
+ mStackedBackground = new IcsColorDrawable(color);
+ }
+
if (getId() == R.id.abs__split_action_bar) {
mIsSplit = true;
mSplitBackground = a.getDrawable(
diff --git a/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java b/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java
index 673ec554f..cae8b8aed 100644
--- a/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java
+++ b/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java
@@ -1,12 +1,13 @@
package com.actionbarsherlock.internal.widget;
-import java.util.Locale;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.TextView;
+import java.util.Locale;
+
public class CapitalizingTextView extends TextView {
private static final boolean SANS_ICE_CREAM = Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH;
private static final boolean IS_GINGERBREAD = Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD;
@@ -33,7 +34,12 @@ public class CapitalizingTextView extends TextView {
public void setTextCompat(CharSequence text) {
if (SANS_ICE_CREAM && mAllCaps && text != null) {
if (IS_GINGERBREAD) {
- setText(text.toString().toUpperCase(Locale.ROOT));
+ try {
+ setText(text.toString().toUpperCase(Locale.ROOT));
+ } catch (NoSuchFieldError e) {
+ //Some manufacturer broke Locale.ROOT. See #572.
+ setText(text.toString().toUpperCase());
+ }
} else {
setText(text.toString().toUpperCase());
}
diff --git a/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/CollapsibleActionViewWrapper.java b/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/CollapsibleActionViewWrapper.java
new file mode 100644
index 000000000..14f092c81
--- /dev/null
+++ b/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/CollapsibleActionViewWrapper.java
@@ -0,0 +1,30 @@
+package com.actionbarsherlock.internal.widget;
+
+import android.view.View;
+import android.widget.FrameLayout;
+import com.actionbarsherlock.view.CollapsibleActionView;
+
+/**
+ * Wraps an ABS collapsible action view in a native container that delegates the calls.
+ */
+public class CollapsibleActionViewWrapper extends FrameLayout implements android.view.CollapsibleActionView {
+ private final CollapsibleActionView child;
+
+ public CollapsibleActionViewWrapper(View child) {
+ super(child.getContext());
+ this.child = (CollapsibleActionView) child;
+ addView(child);
+ }
+
+ @Override public void onActionViewExpanded() {
+ child.onActionViewExpanded();
+ }
+
+ @Override public void onActionViewCollapsed() {
+ child.onActionViewCollapsed();
+ }
+
+ public View unwrap() {
+ return getChildAt(0);
+ }
+}
diff --git a/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsColorDrawable.java b/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsColorDrawable.java
new file mode 100644
index 000000000..a78b3f71b
--- /dev/null
+++ b/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsColorDrawable.java
@@ -0,0 +1,41 @@
+package com.actionbarsherlock.internal.widget;
+
+import android.graphics.Canvas;
+import android.graphics.ColorFilter;
+import android.graphics.Paint;
+import android.graphics.drawable.Drawable;
+
+/**
+ * A version of {@link android.graphics.drawable.ColorDrawable} that respects bounds.
+ */
+public class IcsColorDrawable extends Drawable {
+ private int color;
+ private final Paint paint = new Paint();
+
+ public IcsColorDrawable(int color) {
+ this.color = color;
+ }
+
+ @Override public void draw(Canvas canvas) {
+ if ((color >>> 24) != 0) {
+ paint.setColor(color);
+ canvas.drawRect(getBounds(), paint);
+ }
+ }
+
+ @Override
+ public void setAlpha(int alpha) {
+ if (alpha != (color >>> 24)) {
+ color = (color & 0x00FFFFFF) & (alpha << 24);
+ invalidateSelf();
+ }
+ }
+
+ @Override public void setColorFilter(ColorFilter colorFilter) {
+ //Ignored
+ }
+
+ @Override public int getOpacity() {
+ return color >>> 24;
+ }
+}
diff --git a/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java b/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java
index 1b4463a59..4947c41df 100644
--- a/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java
+++ b/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java
@@ -6,6 +6,8 @@ import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
+import android.widget.LinearLayout;
+
import com.actionbarsherlock.internal.nineoldandroids.widget.NineLinearLayout;
/**
@@ -16,14 +18,16 @@ import com.actionbarsherlock.internal.nineoldandroids.widget.NineLinearLayout;
* {@link android.widget.FrameLayout} so it can receive the margin.
*/
public class IcsLinearLayout extends NineLinearLayout {
- private static final int[] LinearLayout = new int[] {
+ private static final int[] R_styleable_LinearLayout = new int[] {
/* 0 */ android.R.attr.divider,
- /* 1 */ android.R.attr.showDividers,
- /* 2 */ android.R.attr.dividerPadding,
+ /* 1 */ android.R.attr.measureWithLargestChild,
+ /* 2 */ android.R.attr.showDividers,
+ /* 3 */ android.R.attr.dividerPadding,
};
private static final int LinearLayout_divider = 0;
- private static final int LinearLayout_showDividers = 1;
- private static final int LinearLayout_dividerPadding = 2;
+ private static final int LinearLayout_measureWithLargestChild = 1;
+ private static final int LinearLayout_showDividers = 2;
+ private static final int LinearLayout_dividerPadding = 3;
/**
* Don't show any dividers.
@@ -49,15 +53,17 @@ public class IcsLinearLayout extends NineLinearLayout {
private int mShowDividers;
private int mDividerPadding;
+ private boolean mUseLargestChild;
public IcsLinearLayout(Context context, AttributeSet attrs) {
super(context, attrs);
- TypedArray a = context.obtainStyledAttributes(attrs, /*com.android.internal.R.styleable.*/LinearLayout);
+ TypedArray a = context.obtainStyledAttributes(attrs, /*com.android.internal.R.styleable.*/R_styleable_LinearLayout);
setDividerDrawable(a.getDrawable(/*com.android.internal.R.styleable.*/LinearLayout_divider));
mShowDividers = a.getInt(/*com.android.internal.R.styleable.*/LinearLayout_showDividers, SHOW_DIVIDER_NONE);
mDividerPadding = a.getDimensionPixelSize(/*com.android.internal.R.styleable.*/LinearLayout_dividerPadding, 0);
+ mUseLargestChild = a.getBoolean(/*com.android.internal.R.styleable.*/LinearLayout_measureWithLargestChild, false);
a.recycle();
}
@@ -199,7 +205,7 @@ public class IcsLinearLayout extends NineLinearLayout {
if (child == null) {
bottom = getHeight() - getPaddingBottom() - mDividerHeight;
} else {
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
+ //final LayoutParams lp = (LayoutParams) child.getLayoutParams();
bottom = child.getBottom()/* + lp.bottomMargin*/;
}
drawHorizontalDivider(canvas, bottom);
@@ -226,7 +232,7 @@ public class IcsLinearLayout extends NineLinearLayout {
if (child == null) {
right = getWidth() - getPaddingRight() - mDividerWidth;
} else {
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
+ //final LayoutParams lp = (LayoutParams) child.getLayoutParams();
right = child.getRight()/* + lp.rightMargin*/;
}
drawVerticalDivider(canvas, right);
@@ -269,4 +275,136 @@ public class IcsLinearLayout extends NineLinearLayout {
}
return false;
}
+
+ /**
+ * When true, all children with a weight will be considered having
+ * the minimum size of the largest child. If false, all children are
+ * measured normally.
+ *
+ * @return True to measure children with a weight using the minimum
+ * size of the largest child, false otherwise.
+ *
+ * @attr ref android.R.styleable#LinearLayout_measureWithLargestChild
+ */
+ public boolean isMeasureWithLargestChildEnabled() {
+ return mUseLargestChild;
+ }
+
+ /**
+ * When set to true, all children with a weight will be considered having
+ * the minimum size of the largest child. If false, all children are
+ * measured normally.
+ *
+ * Disabled by default.
+ *
+ * @param enabled True to measure children with a weight using the
+ * minimum size of the largest child, false otherwise.
+ *
+ * @attr ref android.R.styleable#LinearLayout_measureWithLargestChild
+ */
+ public void setMeasureWithLargestChildEnabled(boolean enabled) {
+ mUseLargestChild = enabled;
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+ if (mUseLargestChild) {
+ final int orientation = getOrientation();
+ switch (orientation) {
+ case HORIZONTAL:
+ useLargestChildHorizontal();
+ break;
+
+ case VERTICAL:
+ useLargestChildVertical();
+ break;
+ }
+ }
+ }
+
+ private void useLargestChildHorizontal() {
+ final int childCount = getChildCount();
+
+ // Find largest child width
+ int largestChildWidth = 0;
+ for (int i = 0; i < childCount; i++) {
+ final View child = getChildAt(i);
+ largestChildWidth = Math.max(child.getMeasuredWidth(), largestChildWidth);
+ }
+
+ int totalWidth = 0;
+ // Re-measure childs
+ for (int i = 0; i < childCount; i++) {
+ final View child = getChildAt(i);
+
+ if (child == null || child.getVisibility() == View.GONE) {
+ continue;
+ }
+
+ final LinearLayout.LayoutParams lp =
+ (LinearLayout.LayoutParams) child.getLayoutParams();
+
+ float childExtra = lp.weight;
+ if (childExtra > 0) {
+ child.measure(
+ MeasureSpec.makeMeasureSpec(largestChildWidth,
+ MeasureSpec.EXACTLY),
+ MeasureSpec.makeMeasureSpec(child.getMeasuredHeight(),
+ MeasureSpec.EXACTLY));
+ totalWidth += largestChildWidth;
+
+ } else {
+ totalWidth += child.getMeasuredWidth();
+ }
+
+ totalWidth += lp.leftMargin + lp.rightMargin;
+ }
+
+ totalWidth += getPaddingLeft() + getPaddingRight();
+ setMeasuredDimension(totalWidth, getMeasuredHeight());
+ }
+
+ private void useLargestChildVertical() {
+ final int childCount = getChildCount();
+
+ // Find largest child width
+ int largestChildHeight = 0;
+ for (int i = 0; i < childCount; i++) {
+ final View child = getChildAt(i);
+ largestChildHeight = Math.max(child.getMeasuredHeight(), largestChildHeight);
+ }
+
+ int totalHeight = 0;
+ // Re-measure childs
+ for (int i = 0; i < childCount; i++) {
+ final View child = getChildAt(i);
+
+ if (child == null || child.getVisibility() == View.GONE) {
+ continue;
+ }
+
+ final LinearLayout.LayoutParams lp =
+ (LinearLayout.LayoutParams) child.getLayoutParams();
+
+ float childExtra = lp.weight;
+ if (childExtra > 0) {
+ child.measure(
+ MeasureSpec.makeMeasureSpec(child.getMeasuredWidth(),
+ MeasureSpec.EXACTLY),
+ MeasureSpec.makeMeasureSpec(largestChildHeight,
+ MeasureSpec.EXACTLY));
+ totalHeight += largestChildHeight;
+
+ } else {
+ totalHeight += child.getMeasuredHeight();
+ }
+
+ totalHeight += lp.leftMargin + lp.rightMargin;
+ }
+
+ totalHeight += getPaddingLeft() + getPaddingRight();
+ setMeasuredDimension(getMeasuredWidth(), totalHeight);
+ }
}
diff --git a/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java b/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java
index 1a532e06c..48fb5d8b4 100644
--- a/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java
+++ b/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java
@@ -188,6 +188,7 @@ public class ScrollingTabContainerView extends NineHorizontalScrollView
private IcsLinearLayout createTabLayout() {
final IcsLinearLayout tabLayout = (IcsLinearLayout) LayoutInflater.from(getContext())
.inflate(R.layout.abs__action_bar_tab_bar_view, null);
+ tabLayout.setMeasureWithLargestChildEnabled(true);
tabLayout.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT));
return tabLayout;