From 9fec495f534403dac483b129d9bf4d925733056e Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Tue, 21 Jul 2020 15:38:34 +0200 Subject: [PATCH 1/2] Open download log when pressing download error icon --- .../danoeh/antennapod/fragment/FeedItemlistFragment.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java index 5ae2b9ce5..0646d1273 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java @@ -3,6 +3,7 @@ package de.danoeh.antennapod.fragment; import android.content.Context; import android.content.DialogInterface; import android.content.res.Configuration; +import android.content.Intent; import android.graphics.LightingColorFilter; import android.os.Bundle; import android.util.Log; @@ -490,6 +491,14 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem ((MainActivity) getActivity()).loadChildFragment(fragment, TransitionEffect.SLIDE); } }); + txtvFailure.setOnClickListener(v -> { + Intent intent = new Intent(getContext(), MainActivity.class); + intent.putExtra(MainActivity.EXTRA_FRAGMENT_TAG, DownloadsFragment.TAG); + Bundle args = new Bundle(); + args.putInt(DownloadsFragment.ARG_SELECTED_TAB, DownloadsFragment.POS_LOG); + intent.putExtra(MainActivity.EXTRA_FRAGMENT_ARGS, args); + startActivity(intent); + }); headerCreated = true; } From 319c3c8d236085bdcb7cea760f3f651c43cb8b20 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Tue, 21 Jul 2020 15:42:36 +0200 Subject: [PATCH 2/2] Offer to copy download error to clipboard --- .../antennapod/fragment/DownloadLogFragment.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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 5b2813ec5..1d36345ca 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java @@ -1,11 +1,13 @@ package de.danoeh.antennapod.fragment; import android.app.Dialog; +import android.content.ClipData; +import android.content.ClipboardManager; +import android.content.Context; import android.content.res.TypedArray; import android.os.Bundle; import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.ListFragment; -import androidx.core.view.MenuItemCompat; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; @@ -17,7 +19,9 @@ import android.widget.TextView; import java.util.ArrayList; import java.util.List; +import com.google.android.material.snackbar.Snackbar; import de.danoeh.antennapod.R; +import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.adapter.DownloadLogAdapter; import de.danoeh.antennapod.core.event.DownloadLogEvent; import de.danoeh.antennapod.core.feed.Feed; @@ -119,10 +123,17 @@ public class DownloadLogFragment extends ListFragment { message = status.getReasonDetailed(); } + String messageFull = getString(R.string.download_error_details_message, message, url); 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.setMessage(messageFull); builder.setPositiveButton(android.R.string.ok, null); + builder.setNeutralButton(R.string.copy_to_clipboard, (dialog, which) -> { + ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE); + ClipData clip = ClipData.newPlainText(getString(R.string.download_error_details), messageFull); + clipboard.setPrimaryClip(clip); + ((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.copied_to_clipboard, Snackbar.LENGTH_SHORT); + }); Dialog dialog = builder.show(); ((TextView) dialog.findViewById(android.R.id.message)).setTextIsSelectable(true); }