Fixed other square images
This commit is contained in:
parent
0485102797
commit
fe632a4f9f
|
@ -1,13 +1,16 @@
|
||||||
package de.danoeh.antennapod.view;
|
package de.danoeh.antennapod.view;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
import androidx.appcompat.widget.AppCompatImageView;
|
import androidx.appcompat.widget.AppCompatImageView;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import de.danoeh.antennapod.core.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* From http://stackoverflow.com/a/19449488/6839
|
* From http://stackoverflow.com/a/19449488/6839
|
||||||
*/
|
*/
|
||||||
public class SquareImageView extends AppCompatImageView {
|
public class SquareImageView extends AppCompatImageView {
|
||||||
|
private boolean useMinimum = false;
|
||||||
|
|
||||||
public SquareImageView(Context context) {
|
public SquareImageView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
@ -15,17 +18,29 @@ public class SquareImageView extends AppCompatImageView {
|
||||||
|
|
||||||
public SquareImageView(Context context, AttributeSet attrs) {
|
public SquareImageView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
loadAttrs(context, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SquareImageView(Context context, AttributeSet attrs, int defStyle) {
|
public SquareImageView(Context context, AttributeSet attrs, int defStyle) {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
|
loadAttrs(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadAttrs(Context context, AttributeSet attrs) {
|
||||||
|
TypedArray a = context.getTheme().obtainStyledAttributes(attrs,
|
||||||
|
new int[]{R.styleable.SquareImageView_useMinimum}, 0, 0);
|
||||||
|
useMinimum = a.getBoolean(0, false);
|
||||||
|
a.recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
|
|
||||||
int size = Math.min(getMeasuredWidth(), getMeasuredHeight());
|
int size = getMeasuredWidth();
|
||||||
|
if (useMinimum) {
|
||||||
|
size = Math.min(getMeasuredWidth(), getMeasuredHeight());
|
||||||
|
}
|
||||||
setMeasuredDimension(size, size);
|
setMeasuredDimension(size, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
xmlns:squareImageView="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
|
@ -18,7 +19,8 @@
|
||||||
android:layout_marginRight="32dp"
|
android:layout_marginRight="32dp"
|
||||||
android:transitionName="coverTransition"
|
android:transitionName="coverTransition"
|
||||||
tools:src="@android:drawable/sym_def_app_icon"
|
tools:src="@android:drawable/sym_def_app_icon"
|
||||||
android:foreground="?attr/selectableItemBackgroundBorderless"/>
|
android:foreground="?attr/selectableItemBackgroundBorderless"
|
||||||
|
squareImageView:useMinimum="true" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/txtvPodcastTitle"
|
android:id="@+id/txtvPodcastTitle"
|
||||||
|
|
|
@ -117,7 +117,7 @@
|
||||||
android:layout_marginRight="16dp"
|
android:layout_marginRight="16dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
android:contentDescription="@string/pause_label"
|
android:contentDescription="@string/pause_label"
|
||||||
android:src="?attr/av_play"
|
android:src="?attr/av_play"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
|
@ -132,7 +132,7 @@
|
||||||
android:layout_toStartOf="@id/butPlay"
|
android:layout_toStartOf="@id/butPlay"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_marginLeft="16dp"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
android:contentDescription="@string/rewind_label"
|
android:contentDescription="@string/rewind_label"
|
||||||
android:src="?attr/av_rew_big"
|
android:src="?attr/av_rew_big"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
|
@ -161,7 +161,7 @@
|
||||||
android:layout_height="@dimen/audioplayer_playercontrols_length"
|
android:layout_height="@dimen/audioplayer_playercontrols_length"
|
||||||
android:layout_toLeftOf="@id/butRev"
|
android:layout_toLeftOf="@id/butRev"
|
||||||
android:layout_toStartOf="@id/butRev"
|
android:layout_toStartOf="@id/butRev"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
android:contentDescription="@string/set_playback_speed_label"
|
android:contentDescription="@string/set_playback_speed_label"
|
||||||
android:src="?attr/av_speed"
|
android:src="?attr/av_speed"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
|
@ -191,7 +191,7 @@
|
||||||
android:layout_height="@dimen/audioplayer_playercontrols_length"
|
android:layout_height="@dimen/audioplayer_playercontrols_length"
|
||||||
android:layout_toLeftOf="@id/butRev"
|
android:layout_toLeftOf="@id/butRev"
|
||||||
android:layout_toStartOf="@id/butRev"
|
android:layout_toStartOf="@id/butRev"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
android:contentDescription="@string/cast_disconnect_label"
|
android:contentDescription="@string/cast_disconnect_label"
|
||||||
android:src="?attr/ic_cast_disconnect"
|
android:src="?attr/ic_cast_disconnect"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
|
@ -208,7 +208,7 @@
|
||||||
android:layout_toEndOf="@id/butPlay"
|
android:layout_toEndOf="@id/butPlay"
|
||||||
android:layout_marginRight="16dp"
|
android:layout_marginRight="16dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
android:contentDescription="@string/fast_forward_label"
|
android:contentDescription="@string/fast_forward_label"
|
||||||
android:src="?attr/av_ff_big"
|
android:src="?attr/av_ff_big"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
|
@ -237,7 +237,7 @@
|
||||||
android:layout_height="@dimen/audioplayer_playercontrols_length"
|
android:layout_height="@dimen/audioplayer_playercontrols_length"
|
||||||
android:layout_toRightOf="@id/butFF"
|
android:layout_toRightOf="@id/butFF"
|
||||||
android:layout_toEndOf="@id/butFF"
|
android:layout_toEndOf="@id/butFF"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
android:src="?attr/av_skip_big"
|
android:src="?attr/av_skip_big"
|
||||||
android:contentDescription="@string/skip_episode_label"
|
android:contentDescription="@string/skip_episode_label"
|
||||||
|
|
|
@ -77,4 +77,8 @@
|
||||||
<attr name="about_screen_card_border" format="color"/>
|
<attr name="about_screen_card_border" format="color"/>
|
||||||
<attr name="about_screen_font_color" format="color"/>
|
<attr name="about_screen_font_color" format="color"/>
|
||||||
<attr name="batch_edit_fab_icon" format="reference"/>
|
<attr name="batch_edit_fab_icon" format="reference"/>
|
||||||
|
|
||||||
|
<declare-styleable name="SquareImageView">
|
||||||
|
<attr name="useMinimum" format="boolean" />
|
||||||
|
</declare-styleable>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue