Increase touchable area
This commit is contained in:
parent
29010b857e
commit
3ca6be8b04
|
@ -49,11 +49,8 @@ public class DownloadedEpisodesListAdapter extends BaseAdapter {
|
|||
final FeedItem item = getItem(position);
|
||||
holder.bind(item);
|
||||
holder.dragHandle.setVisibility(View.GONE);
|
||||
holder.butSecondary.setImageResource(R.drawable.ic_delete_grey600_24dp);
|
||||
holder.butSecondary.setOnClickListener(v -> {
|
||||
FeedItem item1 = (FeedItem) v.getTag();
|
||||
itemAccess.onFeedItemSecondaryAction(item1);
|
||||
});
|
||||
holder.secondaryActionIcon.setImageResource(R.drawable.ic_delete_grey600_24dp);
|
||||
holder.secondaryActionButton.setOnClickListener(v -> itemAccess.onFeedItemSecondaryAction(item));
|
||||
holder.hideSeparatorIfNecessary();
|
||||
|
||||
return holder.itemView;
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.danoeh.antennapod.adapter.actionbutton;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.AttrRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StringRes;
|
||||
|
@ -53,14 +54,13 @@ public abstract class ItemActionButton {
|
|||
}
|
||||
}
|
||||
|
||||
public void configure(@NonNull ImageButton button, Context context) {
|
||||
TypedArray drawables = context.obtainStyledAttributes(new int[]{getDrawable()});
|
||||
|
||||
public void configure(@NonNull View button, @NonNull ImageView icon, Context context) {
|
||||
button.setVisibility(getVisibility());
|
||||
button.setContentDescription(context.getString(getLabel()));
|
||||
button.setImageDrawable(drawables.getDrawable(0));
|
||||
button.setOnClickListener((view) -> onClick(context));
|
||||
|
||||
TypedArray drawables = context.obtainStyledAttributes(new int[]{getDrawable()});
|
||||
icon.setImageDrawable(drawables.getDrawable(0));
|
||||
drawables.recycle();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,8 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder
|
|||
private final ImageView isVideo;
|
||||
public final ImageView isFavorite;
|
||||
private final ProgressBar progressBar;
|
||||
public final ImageButton butSecondary;
|
||||
public final View secondaryActionButton;
|
||||
public final ImageView secondaryActionIcon;
|
||||
private final CircularProgressBar secondaryActionProgress;
|
||||
private final MainActivity activity;
|
||||
private final TextView separatorIcons;
|
||||
|
@ -72,7 +73,6 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder
|
|||
pubDate = itemView.findViewById(R.id.txtvPubDate);
|
||||
position = itemView.findViewById(R.id.txtvPosition);
|
||||
duration = itemView.findViewById(R.id.txtvDuration);
|
||||
butSecondary = itemView.findViewById(R.id.butSecondaryAction);
|
||||
progressBar = itemView.findViewById(R.id.progressBar);
|
||||
isInQueue = itemView.findViewById(R.id.ivInPlaylist);
|
||||
isVideo = itemView.findViewById(R.id.ivIsVideo);
|
||||
|
@ -81,6 +81,8 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder
|
|||
size = itemView.findViewById(R.id.size);
|
||||
separatorIcons = itemView.findViewById(R.id.separatorIcons);
|
||||
secondaryActionProgress = itemView.findViewById(R.id.secondaryActionProgress);
|
||||
secondaryActionButton = itemView.findViewById(R.id.secondaryActionButton);
|
||||
secondaryActionIcon = itemView.findViewById(R.id.secondaryActionIcon);
|
||||
itemView.setTag(this);
|
||||
}
|
||||
|
||||
|
@ -106,9 +108,8 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder
|
|||
itemView.setAlpha(item.isPlayed() /*&& makePlayedItemsTransparent*/ ? 0.5f : 1.0f);
|
||||
|
||||
ItemActionButton actionButton = ItemActionButton.forItem(item, true);
|
||||
actionButton.configure(butSecondary, activity);
|
||||
butSecondary.setFocusable(false);
|
||||
butSecondary.setTag(item);
|
||||
actionButton.configure(secondaryActionButton, secondaryActionIcon, activity);
|
||||
secondaryActionButton.setFocusable(false);
|
||||
|
||||
if (item.getMedia() != null) {
|
||||
bind(item.getMedia());
|
||||
|
@ -131,7 +132,7 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder
|
|||
if (media.isCurrentlyPlaying()) {
|
||||
container.setBackgroundColor(ThemeUtils.getColorFromAttr(activity, R.attr.currently_playing_background));
|
||||
} else {
|
||||
container.setBackgroundColor(Color.TRANSPARENT);
|
||||
container.setBackgroundResource(ThemeUtils.getDrawableFromAttr(activity, R.attr.selectableItemBackground));
|
||||
}
|
||||
|
||||
if (DownloadRequester.getInstance().isDownloadingFile(media)) {
|
||||
|
@ -146,7 +147,7 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder
|
|||
|
||||
if (media.getDuration() > 0
|
||||
&& (item.getState() == FeedItem.State.PLAYING || item.getState() == FeedItem.State.IN_PROGRESS)) {
|
||||
int progress = (int) (100.0 * media.getPosition() / media.getDuration());
|
||||
int progress = (int) (100.0 * media.getPosition() / media.getDuration());
|
||||
progressBar.setProgress(progress);
|
||||
position.setText(Converter.getDurationStringLong(media.getPosition()));
|
||||
duration.setText(Converter.getDurationStringLong(media.getDuration()));
|
||||
|
|
|
@ -2,20 +2,21 @@
|
|||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginEnd="16dp">
|
||||
android:layout_marginEnd="16dp"
|
||||
android:id="@+id/secondaryActionButton"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false" >
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/butSecondaryAction"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
<ImageView
|
||||
android:id="@+id/secondaryActionIcon"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center"
|
||||
android:focusableInTouchMode="false"
|
||||
tools:ignore="ContentDescription"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
tools:src="@sample/secondaryaction"/>
|
||||
|
||||
<de.danoeh.antennapod.view.CircularProgressBar
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import androidx.annotation.AttrRes;
|
||||
import androidx.annotation.ColorInt;
|
||||
import android.util.TypedValue;
|
||||
import androidx.annotation.DrawableRes;
|
||||
|
||||
public class ThemeUtils {
|
||||
private ThemeUtils() {
|
||||
|
@ -15,4 +16,10 @@ public class ThemeUtils {
|
|||
context.getTheme().resolveAttribute(attr, typedValue, true);
|
||||
return typedValue.data;
|
||||
}
|
||||
|
||||
public static @DrawableRes int getDrawableFromAttr(Context context, @AttrRes int attr) {
|
||||
TypedValue typedValue = new TypedValue();
|
||||
context.getTheme().resolveAttribute(attr, typedValue, true);
|
||||
return typedValue.resourceId;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue