Merge pull request #2626 from ByteHamster/failed-url

Showing URL for failed downloads
This commit is contained in:
Martin Fietz 2018-04-07 17:34:52 +02:00 committed by GitHub
commit c5e99c92b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 0 deletions

View File

@ -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

View File

@ -8,6 +8,7 @@
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingBottom="8dp"
android:descendantFocusability="blocksDescendants"
tools:background="@android:color/darker_gray">
<com.joanzapata.iconify.widget.IconTextView

View File

@ -182,6 +182,8 @@
<string name="download_failed">failed</string>
<string name="download_pending">Download pending</string>
<string name="download_running">Download running</string>
<string name="download_error_details">Details</string>
<string name="download_error_details_message">%1$s \n\nFile URL:\n%2$s</string>
<string name="download_error_device_not_found">Storage Device not found</string>
<string name="download_error_insufficient_space">Insufficient Space</string>
<string name="download_error_file_error">File Error</string>