summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorByteHamster <info@bytehamster.com>2020-02-06 22:51:58 +0100
committerByteHamster <info@bytehamster.com>2020-02-06 22:51:58 +0100
commit7ec9b00e8b080df831adeafdccf3633a26de1836 (patch)
tree35bd7389e0d33d5e300eebb980a654c6985f4120 /app/src
parent24a51062e0c59b5ef2acea42d7536209254a37a1 (diff)
downloadAntennaPod-7ec9b00e8b080df831adeafdccf3633a26de1836.zip
Updated running downloads list
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/adapter/DownloadlistAdapter.java73
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/RunningDownloadsFragment.java7
-rw-r--r--app/src/main/res/layout/downloadlist_item.xml109
3 files changed, 69 insertions, 120 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadlistAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadlistAdapter.java
index b0ee87b7e..fd9b76b9c 100644
--- a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadlistAdapter.java
+++ b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadlistAdapter.java
@@ -5,23 +5,25 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
-import android.widget.ImageButton;
-import android.widget.ProgressBar;
+import android.widget.ImageView;
import android.widget.TextView;
import de.danoeh.antennapod.R;
+import de.danoeh.antennapod.core.feed.Feed;
+import de.danoeh.antennapod.core.feed.FeedMedia;
import de.danoeh.antennapod.core.service.download.DownloadRequest;
import de.danoeh.antennapod.core.service.download.DownloadStatus;
import de.danoeh.antennapod.core.service.download.Downloader;
import de.danoeh.antennapod.core.util.Converter;
+import de.danoeh.antennapod.core.util.ThemeUtils;
+import de.danoeh.antennapod.view.CircularProgressBar;
public class DownloadlistAdapter extends BaseAdapter {
private final ItemAccess itemAccess;
private final Context context;
- public DownloadlistAdapter(Context context,
- ItemAccess itemAccess) {
+ public DownloadlistAdapter(Context context, ItemAccess itemAccess) {
super();
this.context = context;
this.itemAccess = itemAccess;
@@ -47,47 +49,44 @@ public class DownloadlistAdapter extends BaseAdapter {
Holder holder;
Downloader downloader = getItem(position);
DownloadRequest request = downloader.getDownloadRequest();
- // Inflate layout
if (convertView == null) {
holder = new Holder();
- LayoutInflater inflater = (LayoutInflater) context
- .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.downloadlist_item, parent, false);
holder.title = convertView.findViewById(R.id.txtvTitle);
- holder.downloaded = convertView
- .findViewById(R.id.txtvDownloaded);
- holder.percent = convertView
- .findViewById(R.id.txtvPercent);
- holder.progbar = convertView
- .findViewById(R.id.progProgress);
- holder.butSecondary = convertView
- .findViewById(R.id.butSecondaryAction);
-
+ holder.status = convertView.findViewById(R.id.txtvStatus);
+ holder.secondaryActionButton = convertView.findViewById(R.id.secondaryActionButton);
+ holder.secondaryActionIcon = convertView.findViewById(R.id.secondaryActionIcon);
+ holder.secondaryActionProgress = convertView.findViewById(R.id.secondaryActionProgress);
convertView.setTag(holder);
} else {
holder = (Holder) convertView.getTag();
}
holder.title.setText(request.getTitle());
-
- holder.progbar.setIndeterminate(request.getSoFar() <= 0);
-
- String strDownloaded = Converter.byteToString(request.getSoFar());
- if (request.getSize() != DownloadStatus.SIZE_UNKNOWN) {
- strDownloaded += " / " + Converter.byteToString(request.getSize());
- holder.percent.setText(request.getProgressPercent() + "%");
- holder.progbar.setProgress(request.getProgressPercent());
- holder.percent.setVisibility(View.VISIBLE);
+ holder.secondaryActionIcon.setImageResource(ThemeUtils.getDrawableFromAttr(context, R.attr.navigation_cancel));
+ holder.secondaryActionButton.setTag(downloader);
+ holder.secondaryActionButton.setOnClickListener(butSecondaryListener);
+ holder.secondaryActionProgress.setPercentage(0, request);
+
+ String status = "";
+ if (request.getFeedfileType() == Feed.FEEDFILETYPE_FEED) {
+ status += context.getString(R.string.download_type_feed);
+ } else if (request.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
+ status += context.getString(R.string.download_type_media);
+ }
+ status += " · ";
+ if (request.getSoFar() <= 0) {
+ status += context.getString(R.string.download_queued);
} else {
- holder.progbar.setProgress(0);
- holder.percent.setVisibility(View.INVISIBLE);
+ status += Converter.byteToString(request.getSoFar());
+ if (request.getSize() != DownloadStatus.SIZE_UNKNOWN) {
+ status += " / " + Converter.byteToString(request.getSize());
+ holder.secondaryActionProgress.setPercentage(
+ 0.01f * Math.max(1, request.getProgressPercent()), request);
+ }
}
-
- holder.downloaded.setText(strDownloaded);
-
- holder.butSecondary.setFocusable(false);
- holder.butSecondary.setTag(downloader);
- holder.butSecondary.setOnClickListener(butSecondaryListener);
+ holder.status.setText(status);
return convertView;
}
@@ -102,10 +101,10 @@ public class DownloadlistAdapter extends BaseAdapter {
static class Holder {
TextView title;
- TextView downloaded;
- TextView percent;
- ProgressBar progbar;
- ImageButton butSecondary;
+ TextView status;
+ View secondaryActionButton;
+ ImageView secondaryActionIcon;
+ CircularProgressBar secondaryActionProgress;
}
public interface ItemAccess {
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/RunningDownloadsFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/RunningDownloadsFragment.java
index 7e8823c27..1bfbd2d78 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/RunningDownloadsFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/RunningDownloadsFragment.java
@@ -104,11 +104,12 @@ public class RunningDownloadsFragment extends ListFragment {
DownloadRequest downloadRequest = downloader.getDownloadRequest();
DownloadRequester.getInstance().cancelDownload(getActivity(), downloadRequest.getSource());
- if(downloadRequest.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA &&
- UserPreferences.isEnableAutodownload()) {
+ if (downloadRequest.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA
+ && UserPreferences.isEnableAutodownload()) {
FeedMedia media = DBReader.getFeedMedia(downloadRequest.getFeedfileId());
DBWriter.setFeedItemAutoDownload(media.getItem(), false);
- Toast.makeText(getActivity(), R.string.download_canceled_autodownload_enabled_msg, Toast.LENGTH_SHORT).show();
+ Toast.makeText(getActivity(), R.string.download_canceled_autodownload_enabled_msg,
+ Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getActivity(), R.string.download_canceled_msg, Toast.LENGTH_SHORT).show();
}
diff --git a/app/src/main/res/layout/downloadlist_item.xml b/app/src/main/res/layout/downloadlist_item.xml
index 668ec817a..7a4c2fede 100644
--- a/app/src/main/res/layout/downloadlist_item.xml
+++ b/app/src/main/res/layout/downloadlist_item.xml
@@ -1,90 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- tools:background="@android:color/darker_gray">
-
- <LinearLayout
- android:layout_width="0dp"
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/container"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_weight="1"
- android:orientation="vertical">
+ android:orientation="horizontal"
+ android:gravity="center_vertical"
+ android:baselineAligned="false"
+ android:descendantFocusability="blocksDescendants">
- <TextView
- android:id="@+id/txtvTitle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="@dimen/listitem_threeline_horizontalpadding"
- android:layout_marginStart="@dimen/listitem_threeline_horizontalpadding"
- android:layout_marginTop="@dimen/listitem_threeline_verticalpadding"
- android:ellipsize="end"
- android:lines="1"
- android:textColor="?android:attr/textColorPrimary"
- android:textSize="16sp"
- tools:text="Download item title"
- tools:background="@android:color/holo_green_dark" />
-
- <ProgressBar
- android:id="@+id/progProgress"
- style="?android:attr/progressBarStyleHorizontal"
- android:layout_width="match_parent"
- android:layout_height="16dp"
- android:layout_marginBottom="4dp"
- android:layout_marginLeft="@dimen/listitem_threeline_horizontalpadding"
- android:layout_marginRight="@dimen/listitem_threeline_horizontalpadding"
- android:layout_marginTop="4dp"
- tools:background="@android:color/holo_blue_light" />
-
- <RelativeLayout
- android:layout_width="match_parent"
+ <LinearLayout
+ android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/listitem_threeline_verticalpadding"
- android:layout_marginLeft="@dimen/listitem_threeline_horizontalpadding"
- android:layout_marginRight="@dimen/listitem_threeline_horizontalpadding">
-
- <TextView
- android:id="@+id/txtvDownloaded"
- android:layout_width="wrap_content"
+ android:layout_marginRight="@dimen/listitem_threeline_textrightpadding"
+ android:layout_marginEnd="@dimen/listitem_threeline_textrightpadding"
+ android:layout_marginTop="@dimen/listitem_threeline_verticalpadding"
+ android:layout_marginLeft="16dp"
+ android:layout_marginStart="16dp"
+ android:layout_weight="1"
+ android:orientation="vertical">
+ <TextView
+ android:id="@+id/txtvTitle"
+ style="@style/AntennaPod.TextView.ListItemPrimaryTitle"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true"
- android:ellipsize="end"
- android:lines="1"
- android:textColor="?android:attr/textColorPrimary"
- android:textSize="@dimen/text_size_small"
- tools:text="21 MB / 42 MB"
- tools:background="@android:color/holo_green_dark" />
-
- <TextView
- android:id="@+id/txtvPercent"
+ tools:text="@sample/episodes.json/data/title"
+ android:ellipsize="end"/>
+ <TextView
+ android:id="@+id/txtvStatus"
+ style="@style/AntennaPod.TextView.ListItemSecondaryTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:layout_alignParentEnd="true"
- android:ellipsize="end"
- android:lines="1"
- android:textColor="?android:attr/textColorPrimary"
- android:textSize="@dimen/text_size_small"
- tools:text="50%"
- tools:background="@android:color/holo_green_dark" />
- </RelativeLayout>
-
+ tools:text="Media file · 10MB / 20MB"/>
</LinearLayout>
-
- <include layout="@layout/vertical_list_divider"/>
-
- <ImageButton
- android:id="@+id/butSecondaryAction"
- android:layout_width="@dimen/listview_secondary_button_width"
- android:layout_height="match_parent"
- android:background="?attr/selectableItemBackground"
- android:clickable="false"
- android:contentDescription="@string/cancel_download_label"
- android:focusable="false"
- android:focusableInTouchMode="false"
- android:src="?attr/navigation_cancel"
- tools:src="@drawable/ic_cancel_white_24dp"
- tools:background="@android:color/holo_green_dark" />
+ <include layout="@layout/secondary_action"/>
</LinearLayout>