From 03bcfecb882ade67906a471f5b9805ec20e5256e Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Sat, 4 Oct 2014 21:07:57 -0700 Subject: [PATCH] Fixed previous commit to work on Android API < 19 --- .../UserInterface/MaxWidthImageButton.java | 12 +++++++++--- src/main/res/layout/mpris_control.xml | 3 ++- src/main/res/values/attrs.xml | 6 ++++++ 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 src/main/res/values/attrs.xml diff --git a/src/main/java/org/kde/kdeconnect/UserInterface/MaxWidthImageButton.java b/src/main/java/org/kde/kdeconnect/UserInterface/MaxWidthImageButton.java index 203d5852..8a070879 100644 --- a/src/main/java/org/kde/kdeconnect/UserInterface/MaxWidthImageButton.java +++ b/src/main/java/org/kde/kdeconnect/UserInterface/MaxWidthImageButton.java @@ -6,8 +6,12 @@ import android.util.AttributeSet; import android.widget.ImageButton; import android.widget.LinearLayout; +import org.kde.kdeconnect_tp.R; + public class MaxWidthImageButton extends ImageButton { + int mMaxWidth = Integer.MAX_VALUE; + public MaxWidthImageButton(Context context) { super(context); @@ -15,14 +19,16 @@ public class MaxWidthImageButton extends ImageButton { public MaxWidthImageButton(Context context, AttributeSet attrs) { super(context, attrs); + + TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.MaxWidthImageButton); + mMaxWidth = a.getDimensionPixelSize(R.styleable.MaxWidthImageButton_maxWidth, Integer.MAX_VALUE); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int maxWidth = getMaxWidth(); super.onMeasure(widthMeasureSpec, heightMeasureSpec); - if(getMeasuredWidth() > maxWidth){ - setMeasuredDimension(maxWidth, getMeasuredHeight()); + if(getMeasuredWidth() > mMaxWidth){ + setMeasuredDimension(mMaxWidth, getMeasuredHeight()); } } } diff --git a/src/main/res/layout/mpris_control.xml b/src/main/res/layout/mpris_control.xml index 19c46438..3c36f3ea 100644 --- a/src/main/res/layout/mpris_control.xml +++ b/src/main/res/layout/mpris_control.xml @@ -1,6 +1,7 @@ + + + + + \ No newline at end of file