Added secondary button to new episodes list

This commit is contained in:
daniel oeh 2014-04-03 12:29:07 +02:00
parent c37b67172e
commit 5b74a4cc39
5 changed files with 165 additions and 124 deletions

View File

@ -1,114 +1,130 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginRight="16dp">
<ImageView
android:id="@+id/imgvImage"
android:contentDescription="@string/cover_label"
android:layout_width="@dimen/thumbnail_length_itemlist"
android:layout_height="@dimen/thumbnail_length_itemlist"
android:layout_alignParentLeft="true"
android:scaleType="centerCrop"/>
<ImageView
android:id="@+id/statusPlaying"
android:contentDescription="@string/status_playing_label"
android:layout_width="@dimen/status_indicator_width"
android:layout_height="18dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:layout_marginLeft="8dp"
android:background="@color/status_playing"
android:gravity="center"
android:padding="2dp"
android:src="@drawable/av_play_dark"/>
<TextView
android:id="@+id/txtvPublished"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/imgvImage"
android:layout_toLeftOf="@id/statusPlaying"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:attr/textColorTertiary"
android:textSize="@dimen/text_size_micro"/>
<TextView
android:id="@+id/txtvTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="@id/txtvPublished"
android:layout_marginLeft="8dp"
android:layout_marginRight="4dp"
android:layout_marginTop="2dp"
android:layout_toRightOf="@id/imgvImage"
android:layout_toLeftOf="@id/statusPlaying"
android:ellipsize="end"
android:lines="2"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/text_size_small"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/imgvImage"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/bottom_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="wrap_content">
<ImageView <ImageView
android:id="@+id/imgvImage" android:id="@id/imgvInPlaylist"
android:contentDescription="@string/cover_label" android:contentDescription="@string/in_queue_label"
android:layout_width="@dimen/thumbnail_length_itemlist" android:layout_width="@dimen/enc_icons_size"
android:layout_height="@dimen/thumbnail_length_itemlist" android:layout_height="@dimen/enc_icons_size"
android:layout_alignParentLeft="true" android:layout_alignParentRight="true"
android:scaleType="centerCrop"/> android:src="?attr/stat_playlist"/>
<ImageView <ProgressBar
android:id="@+id/statusPlaying" android:id="@+id/pbar_download_progress"
android:contentDescription="@string/status_playing_label" style="?android:attr/progressBarStyleHorizontal"
android:layout_width="@dimen/status_indicator_width" android:max="100"
android:layout_height="18dp" android:layout_width="0dp"
android:layout_alignParentRight="true" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_toLeftOf="@id/imgvInPlaylist"
android:layout_margin="8dp" android:layout_marginLeft="8dp"
android:background="@color/status_playing" android:layout_marginRight="8dp"
android:gravity="center" android:layout_alignParentLeft="true"/>
android:padding="2dp"
android:src="@drawable/av_play_dark"/>
<TextView <TextView
android:id="@+id/txtvPublished" android:id="@+id/txtvDuration"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="8dp" android:layout_toLeftOf="@id/imgvInPlaylist"
android:layout_marginRight="8dp" android:layout_marginLeft="8dp"
android:layout_alignParentTop="true" android:layout_marginRight="8dp"
android:layout_toRightOf="@id/imgvImage" android:layout_alignParentLeft="true"
android:layout_toLeftOf="@id/statusPlaying" android:textColor="?android:attr/textColorTertiary"
android:ellipsize="end" android:textSize="@dimen/text_size_micro"/>
android:maxLines="1" </RelativeLayout>
android:textColor="?android:attr/textColorTertiary" </LinearLayout>
android:textSize="@dimen/text_size_micro"/> </RelativeLayout>
<TextView <View
android:id="@+id/txtvTitle" android:layout_width="1dp"
android:layout_width="0dp" android:layout_height="match_parent"
android:layout_height="wrap_content" android:background="@drawable/vertical_divider"
android:layout_below="@id/txtvPublished" android:layout_marginTop="8dp"
android:layout_marginLeft="8dp" android:layout_marginBottom="8dp"/>
android:layout_marginRight="4dp"
android:layout_marginTop="2dp"
android:layout_toRightOf="@id/imgvImage"
android:layout_toLeftOf="@id/statusPlaying"
android:ellipsize="end"
android:lines="2"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/text_size_small"/>
<LinearLayout <ImageButton
android:layout_width="0dp" android:id="@+id/butSecondaryAction"
android:layout_height="wrap_content" android:focusable="false"
android:layout_alignParentBottom="true" android:clickable="false"
android:layout_alignParentRight="true" android:focusableInTouchMode="false"
android:layout_toRightOf="@id/imgvImage" android:layout_width="@dimen/listview_secondary_button_width"
android:orientation="vertical"> android:layout_height="match_parent"
android:background="?attr/borderless_button"
tools:ignore="ContentDescription"/>
<RelativeLayout </LinearLayout>
android:id="@+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imgvDownloadStatus"
android:layout_width="@dimen/enc_icons_size"
android:layout_height="@dimen/enc_icons_size"
android:layout_alignParentRight="true"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
tools:ignore="ContentDescription"/>
<ImageView
android:id="@id/imgvInPlaylist"
android:contentDescription="@string/in_queue_label"
android:layout_width="@dimen/enc_icons_size"
android:layout_height="@dimen/enc_icons_size"
android:layout_toLeftOf="@+id/imgvDownloadStatus"
android:src="?attr/stat_playlist"/>
<ProgressBar
android:id="@+id/pbar_download_progress"
style="?android:attr/progressBarStyleHorizontal"
android:max="100"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/imgvInPlaylist"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_alignParentLeft="true"/>
<TextView
android:id="@+id/txtvDuration"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/imgvDownloadStatus"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_alignParentLeft="true"
android:textColor="?android:attr/textColorTertiary"
android:textSize="@dimen/text_size_micro"/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="selection_background_color_dark">#484B4D</color>
<color name="selection_background_color_light">#E3E3E3</color>
</resources>

View File

@ -15,4 +15,5 @@
<dimen name="thumbnail_length_itemlist">80dp</dimen> <dimen name="thumbnail_length_itemlist">80dp</dimen>
<dimen name="thumbnail_length_onlinefeedview">110dp</dimen> <dimen name="thumbnail_length_onlinefeedview">110dp</dimen>
<dimen name="thumbnail_length_navlist">42dp</dimen> <dimen name="thumbnail_length_navlist">42dp</dimen>
<dimen name="listview_secondary_button_width">48dp</dimen>
</resources> </resources>

View File

@ -6,10 +6,7 @@ import android.text.format.DateUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.BaseAdapter; import android.widget.*;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.asynctask.ImageLoader; import de.danoeh.antennapod.asynctask.ImageLoader;
import de.danoeh.antennapod.feed.FeedItem; import de.danoeh.antennapod.feed.FeedItem;
@ -35,8 +32,8 @@ public class NewEpisodesListAdapter extends BaseAdapter {
this.context = context; this.context = context;
this.itemAccess = itemAccess; this.itemAccess = itemAccess;
drawables = context.obtainStyledAttributes(new int[]{ drawables = context.obtainStyledAttributes(new int[]{
R.attr.navigation_accept, R.attr.navigation_refresh, R.attr.av_download}); R.attr.av_play, R.attr.navigation_cancel, R.attr.av_download});
labels = new int[]{R.string.status_downloaded_label, R.string.status_downloading_label, R.string.status_not_downloaded_label}; labels = new int[]{R.string.play_label, R.string.cancel_download_label, R.string.download_label};
} }
@Override @Override
@ -113,8 +110,8 @@ public class NewEpisodesListAdapter extends BaseAdapter {
holder.title = (TextView) convertView.findViewById(R.id.txtvTitle); holder.title = (TextView) convertView.findViewById(R.id.txtvTitle);
holder.pubDate = (TextView) convertView holder.pubDate = (TextView) convertView
.findViewById(R.id.txtvPublished); .findViewById(R.id.txtvPublished);
holder.downloadStatus = (ImageView) convertView holder.butSecondary = (ImageButton) convertView
.findViewById(R.id.imgvDownloadStatus); .findViewById(R.id.butSecondaryAction);
holder.queueStatus = (ImageView) convertView holder.queueStatus = (ImageView) convertView
.findViewById(R.id.imgvInPlaylist); .findViewById(R.id.imgvInPlaylist);
holder.statusPlaying = (ImageView) convertView holder.statusPlaying = (ImageView) convertView
@ -159,27 +156,27 @@ public class NewEpisodesListAdapter extends BaseAdapter {
if (!media.isDownloaded()) { if (!media.isDownloaded()) {
if (isDownloadingMedia) { if (isDownloadingMedia) {
// item is being downloaded // item is being downloaded
holder.downloadStatus.setVisibility(View.VISIBLE); holder.butSecondary.setVisibility(View.VISIBLE);
holder.downloadStatus.setImageDrawable(drawables holder.butSecondary.setImageDrawable(drawables
.getDrawable(1)); .getDrawable(1));
holder.downloadStatus.setContentDescription(context.getString(labels[1])); holder.butSecondary.setContentDescription(context.getString(labels[1]));
holder.downloadProgress.setProgress(itemAccess.getItemDownloadProgressPercent(item)); holder.downloadProgress.setProgress(itemAccess.getItemDownloadProgressPercent(item));
} else { } else {
// item is not downloaded and not being downloaded // item is not downloaded and not being downloaded
holder.downloadStatus.setVisibility(View.VISIBLE); holder.butSecondary.setVisibility(View.VISIBLE);
holder.downloadStatus.setImageDrawable(drawables.getDrawable(2)); holder.butSecondary.setImageDrawable(drawables.getDrawable(2));
holder.downloadStatus.setContentDescription(context.getString(labels[2])); holder.butSecondary.setContentDescription(context.getString(labels[2]));
} }
} else { } else {
// item is not being downloaded // item is not being downloaded
holder.downloadStatus.setVisibility(View.VISIBLE); holder.butSecondary.setVisibility(View.VISIBLE);
holder.downloadStatus holder.butSecondary
.setImageDrawable(drawables.getDrawable(0)); .setImageDrawable(drawables.getDrawable(0));
holder.downloadStatus.setContentDescription(context.getString(labels[0])); holder.butSecondary.setContentDescription(context.getString(labels[0]));
} }
} else { } else {
holder.downloadStatus.setVisibility(View.INVISIBLE); holder.butSecondary.setVisibility(View.INVISIBLE);
} }
if (itemAccess.isInQueue(item)) { if (itemAccess.isInQueue(item)) {
@ -188,6 +185,12 @@ public class NewEpisodesListAdapter extends BaseAdapter {
holder.queueStatus.setVisibility(View.INVISIBLE); holder.queueStatus.setVisibility(View.INVISIBLE);
} }
holder.butSecondary.setFocusable(false);
holder.butSecondary.setTag(item);
holder.butSecondary.setOnClickListener(secondaryActionListener);
ImageLoader.getInstance().loadThumbnailBitmap( ImageLoader.getInstance().loadThumbnailBitmap(
item, item,
holder.imageView, holder.imageView,
@ -197,16 +200,24 @@ public class NewEpisodesListAdapter extends BaseAdapter {
return convertView; return convertView;
} }
private View.OnClickListener secondaryActionListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
FeedItem item = (FeedItem) v.getTag();
itemAccess.onFeedItemSecondaryAction(item);
}
};
static class Holder { static class Holder {
TextView title; TextView title;
TextView pubDate; TextView pubDate;
ImageView downloadStatus;
ImageView queueStatus; ImageView queueStatus;
ImageView imageView; ImageView imageView;
ImageView statusPlaying; ImageView statusPlaying;
ProgressBar downloadProgress; ProgressBar downloadProgress;
TextView txtvDuration; TextView txtvDuration;
ImageButton butSecondary;
} }
public interface ItemAccess { public interface ItemAccess {
@ -221,5 +232,7 @@ public class NewEpisodesListAdapter extends BaseAdapter {
int getItemDownloadProgressPercent(FeedItem item); int getItemDownloadProgressPercent(FeedItem item);
boolean isInQueue(FeedItem item); boolean isInQueue(FeedItem item);
void onFeedItemSecondaryAction(FeedItem item);
} }
} }

View File

@ -6,6 +6,7 @@ import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -193,6 +194,11 @@ public class NewEpisodesFragment extends Fragment {
} }
} }
@Override
public void onFeedItemSecondaryAction(FeedItem item) {
Log.i(TAG, item.getTitle());
}
}; };