summaryrefslogtreecommitdiffstats
path: root/src/com/android/contacts/widget
diff options
context:
space:
mode:
authorDmitri Plotnikov <dplotnikov@google.com>2010-11-29 18:50:14 -0800
committerDmitri Plotnikov <dplotnikov@google.com>2010-11-29 18:50:14 -0800
commitbb0788a8a052cb3baf8fdc20fcf97d77b94e12ab (patch)
tree946b45dff60109b9c8e5d6a236c8628fdd60e016 /src/com/android/contacts/widget
parent8e89d1e7f9af9cde91b737881496b0fd4314fea2 (diff)
downloadpackages_apps_Contacts-bb0788a8a052cb3baf8fdc20fcf97d77b94e12ab.tar.gz
packages_apps_Contacts-bb0788a8a052cb3baf8fdc20fcf97d77b94e12ab.tar.bz2
packages_apps_Contacts-bb0788a8a052cb3baf8fdc20fcf97d77b94e12ab.zip
Adding support for interpolated padding.
Change-Id: Ib7733abdebb2125ae28f4f5deb532f6faf93d0b9
Diffstat (limited to 'src/com/android/contacts/widget')
-rw-r--r--src/com/android/contacts/widget/InterpolatingLayout.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/com/android/contacts/widget/InterpolatingLayout.java b/src/com/android/contacts/widget/InterpolatingLayout.java
index 5900bf11b..fb0c371c4 100644
--- a/src/com/android/contacts/widget/InterpolatingLayout.java
+++ b/src/com/android/contacts/widget/InterpolatingLayout.java
@@ -58,17 +58,25 @@ public class InterpolatingLayout extends ViewGroup {
public int narrowParentWidth;
public int narrowWidth;
public int narrowLeftMargin;
+ public int narrowLeftPadding;
public int narrowRightMargin;
+ public int narrowRightPadding;
public int wideParentWidth;
public int wideWidth;
public int wideLeftMargin;
+ public int wideLeftPadding;
public int wideRightMargin;
+ public int wideRightPadding;
private float widthMultiplier;
private int widthConstant;
private float leftMarginMultiplier;
private int leftMarginConstant;
+ private float leftPaddingMultiplier;
+ private int leftPaddingConstant;
private float rightMarginMultiplier;
private int rightMarginConstant;
+ private float rightPaddingMultiplier;
+ private int rightPaddingConstant;
public LayoutParams(Context c, AttributeSet attrs) {
super(c, attrs);
@@ -80,16 +88,24 @@ public class InterpolatingLayout extends ViewGroup {
R.styleable.InterpolatingLayout_Layout_layout_narrowWidth, -1);
narrowLeftMargin = a.getDimensionPixelSize(
R.styleable.InterpolatingLayout_Layout_layout_narrowLeftMargin, -1);
+ narrowLeftPadding = a.getDimensionPixelSize(
+ R.styleable.InterpolatingLayout_Layout_layout_narrowLeftPadding, -1);
narrowRightMargin = a.getDimensionPixelSize(
R.styleable.InterpolatingLayout_Layout_layout_narrowRightMargin, -1);
+ narrowRightPadding = a.getDimensionPixelSize(
+ R.styleable.InterpolatingLayout_Layout_layout_narrowRightPadding, -1);
wideParentWidth = a.getDimensionPixelSize(
R.styleable.InterpolatingLayout_Layout_layout_wideParentWidth, -1);
wideWidth = a.getDimensionPixelSize(
R.styleable.InterpolatingLayout_Layout_layout_wideWidth, -1);
wideLeftMargin = a.getDimensionPixelSize(
R.styleable.InterpolatingLayout_Layout_layout_wideLeftMargin, -1);
+ wideLeftPadding = a.getDimensionPixelSize(
+ R.styleable.InterpolatingLayout_Layout_layout_wideLeftPadding, -1);
wideRightMargin = a.getDimensionPixelSize(
R.styleable.InterpolatingLayout_Layout_layout_wideRightMargin, -1);
+ wideRightPadding = a.getDimensionPixelSize(
+ R.styleable.InterpolatingLayout_Layout_layout_wideRightPadding, -1);
a.recycle();
@@ -106,12 +122,26 @@ public class InterpolatingLayout extends ViewGroup {
* leftMarginMultiplier);
}
+ if (narrowLeftPadding != -1) {
+ leftPaddingMultiplier = (float) (wideLeftPadding - narrowLeftPadding)
+ / (wideParentWidth - narrowParentWidth);
+ leftPaddingConstant = (int) (narrowLeftPadding - narrowParentWidth
+ * leftPaddingMultiplier);
+ }
+
if (narrowRightMargin != -1) {
rightMarginMultiplier = (float) (wideRightMargin - narrowRightMargin)
/ (wideParentWidth - narrowParentWidth);
rightMarginConstant = (int) (narrowRightMargin - narrowParentWidth
* rightMarginMultiplier);
}
+
+ if (narrowRightPadding != -1) {
+ rightPaddingMultiplier = (float) (wideRightPadding - narrowRightPadding)
+ / (wideParentWidth - narrowParentWidth);
+ rightPaddingConstant = (int) (narrowRightPadding - narrowParentWidth
+ * rightPaddingMultiplier);
+ }
}
public LayoutParams(int width, int height) {
@@ -140,6 +170,11 @@ public class InterpolatingLayout extends ViewGroup {
}
}
+ public int resolveLeftPadding(int parentSize) {
+ int w = (int) (parentSize * leftPaddingMultiplier) + leftPaddingConstant;
+ return w < 0 ? 0 : w;
+ }
+
public int resolveRightMargin(int parentSize) {
if (narrowRightMargin == -1) {
return rightMargin;
@@ -148,6 +183,11 @@ public class InterpolatingLayout extends ViewGroup {
return w < 0 ? 0 : w;
}
}
+
+ public int resolveRightPadding(int parentSize) {
+ int w = (int) (parentSize * rightPaddingMultiplier) + rightPaddingConstant;
+ return w < 0 ? 0 : w;
+ }
}
@Override
@@ -248,6 +288,15 @@ public class InterpolatingLayout extends ViewGroup {
gravity = Gravity.LEFT | Gravity.TOP;
}
+ if (params.narrowLeftPadding != -1 || params.narrowRightPadding != -1) {
+ int leftPadding = params.narrowLeftPadding == -1 ? child.getPaddingLeft()
+ : params.resolveLeftPadding(width);
+ int rightPadding = params.narrowRightPadding == -1 ? child.getPaddingRight()
+ : params.resolveRightPadding(width);
+ child.setPadding(
+ leftPadding, child.getPaddingTop(), rightPadding, child.getPaddingBottom());
+ }
+
int leftMargin = params.resolveLeftMargin(width);
int rightMargin = params.resolveRightMargin(width);