diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java index 46148a214..ba4ababf5 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java @@ -47,6 +47,7 @@ import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.storage.DownloadRequestException; import de.danoeh.antennapod.core.storage.DownloadRequester; +import de.danoeh.antennapod.core.util.Converter; import de.danoeh.antennapod.core.util.LongList; import de.danoeh.antennapod.core.util.QueueSorter; import de.danoeh.antennapod.core.util.gui.FeedItemUndoToken; @@ -66,6 +67,7 @@ public class QueueFragment extends Fragment { EventDistributor.DOWNLOAD_QUEUED | EventDistributor.PLAYER_STATUS_UPDATE; + private TextView infoBar; private DragSortListView listView; private QueueListAdapter listAdapter; private TextView txtvEmpty; @@ -363,6 +365,7 @@ public class QueueFragment extends Fragment { ((MainActivity) getActivity()).getSupportActionBar().setTitle(R.string.queue_label); View root = inflater.inflate(R.layout.queue_fragment, container, false); + infoBar = (TextView) root.findViewById(R.id.info_bar); listView = (DragSortListView) root.findViewById(android.R.id.list); txtvEmpty = (TextView) root.findViewById(android.R.id.empty); progLoading = (ProgressBar) root.findViewById(R.id.progLoading); @@ -469,6 +472,20 @@ public class QueueFragment extends Fragment { // we need to refresh the options menu because it sometimes // needs data that may have just been loaded. getActivity().supportInvalidateOptionsMenu(); + + // refresh information bar + String info = queue.size() + getString(R.string.episodes_suffix); + if(queue.size() > 0) { + int duration = 0; + for(FeedItem item : queue) { + if(item.getMedia() != null) { + duration += item.getMedia().getDuration(); + } + } + info += " \u2022 "; + info += Converter.getDurationStringLocalized(getActivity(), duration); + } + infoBar.setText(info); } private DownloadObserver.Callback downloadObserverCallback = new DownloadObserver.Callback() { diff --git a/app/src/main/res/layout/queue_fragment.xml b/app/src/main/res/layout/queue_fragment.xml index 307d95a8d..339369971 100644 --- a/app/src/main/res/layout/queue_fragment.xml +++ b/app/src/main/res/layout/queue_fragment.xml @@ -1,18 +1,33 @@ - + + + + @@ -39,12 +54,13 @@ android:id="@+id/progLoading" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="center" + android:layout_centerInParent="true" android:indeterminateOnly="true" android:visibility="gone" /> - + diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/Converter.java b/core/src/main/java/de/danoeh/antennapod/core/util/Converter.java index a0b514bd6..917f99564 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/Converter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/Converter.java @@ -1,7 +1,10 @@ package de.danoeh.antennapod.core.util; +import android.content.Context; import android.util.Log; +import de.danoeh.antennapod.core.R; + /** Provides methods for converting various units. */ public final class Converter { /** Class shall not be instantiated. */ @@ -99,5 +102,21 @@ public final class Converter { return Integer.valueOf(parts[0]) * 3600 * 1000 + Integer.valueOf(parts[1]) * 1000 * 60; } + + /** Converts milliseconds to a localized string containing hours and minutes */ + public static String getDurationStringLocalized(Context context, int duration) { + int h = duration / HOURS_MIL; + int rest = duration - h * HOURS_MIL; + int m = rest / MINUTES_MIL; + + String result = ""; + if(h > 0) { + String hours = context.getString(R.string.time_unit_hours); + result += h + " " + hours + " "; + } + String minutes = context.getString(R.string.time_unit_minutes); + result += m + " " + minutes; + return result; + } }