From e41bc7bd61ba568adec4ff82c636cbbee7556022 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Thu, 5 Apr 2018 18:25:14 +0200 Subject: [PATCH] Showing URL for failed downloads Closes #1082 --- .../fragment/DownloadLogFragment.java | 27 +++++++++++++++++++ app/src/main/res/layout/downloadlog_item.xml | 2 ++ core/src/main/res/values/strings.xml | 2 ++ 3 files changed, 31 insertions(+) diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java index 9a4c9e030..ae9c60f65 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java @@ -1,5 +1,7 @@ package de.danoeh.antennapod.fragment; +import android.app.AlertDialog; +import android.app.Dialog; import android.content.res.TypedArray; import android.os.Bundle; import android.support.v4.app.ListFragment; @@ -13,9 +15,11 @@ import android.widget.ListView; import java.util.List; +import android.widget.TextView; import de.danoeh.antennapod.R; import de.danoeh.antennapod.adapter.DownloadLogAdapter; import de.danoeh.antennapod.core.feed.EventDistributor; +import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.service.download.DownloadStatus; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBWriter; @@ -82,6 +86,29 @@ public class DownloadLogFragment extends ListFragment { getActivity().supportInvalidateOptionsMenu(); } + @Override + public void onListItemClick(ListView l, View v, int position, long id) { + super.onListItemClick(l, v, position, id); + + DownloadStatus status = adapter.getItem(position); + String url = "unknown"; + String message = getString(R.string.download_successful); + FeedMedia media = DBReader.getFeedMedia(status.getFeedfileId()); + if (media != null) { + url = media.getDownload_url(); + } + if (!status.isSuccessful()) { + message = status.getReasonDetailed(); + } + + AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + builder.setTitle(R.string.download_error_details); + builder.setMessage(getString(R.string.download_error_details_message, message, url)); + builder.setPositiveButton(android.R.string.ok, null); + Dialog dialog = builder.show(); + ((TextView) dialog.findViewById(android.R.id.message)).setTextIsSelectable(true); + } + private final DownloadLogAdapter.ItemAccess itemAccess = new DownloadLogAdapter.ItemAccess() { @Override diff --git a/app/src/main/res/layout/downloadlog_item.xml b/app/src/main/res/layout/downloadlog_item.xml index 27b179f4e..b69fdf20d 100644 --- a/app/src/main/res/layout/downloadlog_item.xml +++ b/app/src/main/res/layout/downloadlog_item.xml @@ -8,6 +8,8 @@ android:paddingLeft="16dp" android:paddingRight="16dp" android:paddingBottom="8dp" + android:background="?attr/selectableItemBackground" + android:descendantFocusability="blocksDescendants" tools:background="@android:color/darker_gray"> failed Download pending Download running + Details + %1$s \n\nFile URL:\n%2$s Storage Device not found Insufficient Space File Error