mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-30 13:47:41 +00:00
Fixed previous commit to work on Android API < 19
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@@ -32,7 +33,7 @@
|
||||
<org.kde.kdeconnect.UserInterface.MaxWidthImageButton
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="75dip"
|
||||
android:maxWidth="300dip"
|
||||
app:maxWidth="300dip"
|
||||
android:id="@+id/play_button"
|
||||
android:src="@android:drawable/ic_media_play"
|
||||
android:contentDescription="@string/mpris_play"
|
||||
|
6
src/main/res/values/attrs.xml
Normal file
6
src/main/res/values/attrs.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<declare-styleable name="MaxWidthImageButton">
|
||||
<attr name="maxWidth" format="dimension" />
|
||||
</declare-styleable>
|
||||
</resources>
|
Reference in New Issue
Block a user