aboutsummaryrefslogtreecommitdiffstats
path: root/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2013-09-09 13:19:43 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2013-09-09 13:19:43 +0200
commitaae87b894f72a719a850ec32ad6944bd5c743331 (patch)
treeb5a221fcb529c07b309f5bde0563155df28a472c /libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java
parent5b6880d2e34f4c8a4bfba87b5ce53d3c6727b744 (diff)
downloadopen-keychain-aae87b894f72a719a850ec32ad6944bd5c743331.tar.gz
open-keychain-aae87b894f72a719a850ec32ad6944bd5c743331.tar.bz2
open-keychain-aae87b894f72a719a850ec32ad6944bd5c743331.zip
Update actionbarsherlock from 4.2 to 4.4
Diffstat (limited to 'libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java')
-rw-r--r--libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java150
1 files changed, 10 insertions, 140 deletions
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java
index 4947c41df..b7c6ff318 100644
--- a/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java
@@ -3,10 +3,11 @@ package com.actionbarsherlock.internal.widget;
import android.content.Context;
import android.content.res.TypedArray;
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.View;
-import android.widget.LinearLayout;
import com.actionbarsherlock.internal.nineoldandroids.widget.NineLinearLayout;
@@ -20,14 +21,12 @@ import com.actionbarsherlock.internal.nineoldandroids.widget.NineLinearLayout;
public class IcsLinearLayout extends NineLinearLayout {
private static final int[] R_styleable_LinearLayout = new int[] {
/* 0 */ android.R.attr.divider,
- /* 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_measureWithLargestChild = 1;
- private static final int LinearLayout_showDividers = 2;
- private static final int LinearLayout_dividerPadding = 3;
+ private static final int LinearLayout_showDividers = 1;
+ private static final int LinearLayout_dividerPadding = 2;
/**
* Don't show any dividers.
@@ -53,8 +52,6 @@ public class IcsLinearLayout extends NineLinearLayout {
private int mShowDividers;
private int mDividerPadding;
- private boolean mUseLargestChild;
-
public IcsLinearLayout(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -63,7 +60,6 @@ public class IcsLinearLayout extends NineLinearLayout {
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();
}
@@ -100,6 +96,12 @@ public class IcsLinearLayout extends NineLinearLayout {
if (divider == mDivider) {
return;
}
+
+ //Fix for issue #379
+ if (divider instanceof ColorDrawable && Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
+ divider = new IcsColorDrawable((ColorDrawable) divider);
+ }
+
mDivider = divider;
if (divider != null) {
mDividerWidth = divider.getIntrinsicWidth();
@@ -275,136 +277,4 @@ 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);
- }
}