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"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
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_height="match_parent">
android:layout_height="wrap_content">
<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/imgvInPlaylist"
android:contentDescription="@string/in_queue_label"
android:layout_width="@dimen/enc_icons_size"
android:layout_height="@dimen/enc_icons_size"
android:layout_alignParentRight="true"
android:src="?attr/stat_playlist"/>
<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_margin="8dp"
android:background="@color/status_playing"
android:gravity="center"
android:padding="2dp"
android:src="@drawable/av_play_dark"/>
<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/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/txtvDuration"
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"
android:textColor="?android:attr/textColorTertiary"
android:textSize="@dimen/text_size_micro"/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<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"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@drawable/vertical_divider"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"/>
<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">
<ImageButton
android:id="@+id/butSecondaryAction"
android:focusable="false"
android:clickable="false"
android:focusableInTouchMode="false"
android:layout_width="@dimen/listview_secondary_button_width"
android:layout_height="match_parent"
android:background="?attr/borderless_button"
tools:ignore="ContentDescription"/>
<RelativeLayout
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>
</LinearLayout>

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_onlinefeedview">110dp</dimen>
<dimen name="thumbnail_length_navlist">42dp</dimen>
<dimen name="listview_secondary_button_width">48dp</dimen>
</resources>

View File

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