Rename FeedMedia methods to no longer have underscores (#7017)
This commit is contained in:
parent
f20ce1fc69
commit
f6b45e7162
|
@ -67,7 +67,7 @@ public class HttpDownloaderTest {
|
||||||
if (deleteExisting) {
|
if (deleteExisting) {
|
||||||
Log.d(TAG, "Deleting file: " + file.delete());
|
Log.d(TAG, "Deleting file: " + file.delete());
|
||||||
}
|
}
|
||||||
feedfile.setFile_url(fileUrl);
|
feedfile.setLocalFileUrl(fileUrl);
|
||||||
return feedfile;
|
return feedfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class HttpDownloaderTest {
|
||||||
private Downloader download(String url, String title, boolean expectedResult, boolean deleteExisting,
|
private Downloader download(String url, String title, boolean expectedResult, boolean deleteExisting,
|
||||||
String username, String password) {
|
String username, String password) {
|
||||||
Feed feedFile = setupFeedFile(url, title, deleteExisting);
|
Feed feedFile = setupFeedFile(url, title, deleteExisting);
|
||||||
DownloadRequest request = new DownloadRequest(feedFile.getFile_url(), url, title, 0, Feed.FEEDFILETYPE_FEED,
|
DownloadRequest request = new DownloadRequest(feedFile.getLocalFileUrl(), url, title, 0, Feed.FEEDFILETYPE_FEED,
|
||||||
username, password, null, false);
|
username, password, null, false);
|
||||||
Downloader downloader = new HttpDownloader(request);
|
Downloader downloader = new HttpDownloader(request);
|
||||||
downloader.call();
|
downloader.call();
|
||||||
|
@ -86,7 +86,7 @@ public class HttpDownloaderTest {
|
||||||
assertNotNull(status);
|
assertNotNull(status);
|
||||||
assertEquals(expectedResult, status.isSuccessful());
|
assertEquals(expectedResult, status.isSuccessful());
|
||||||
// the file should not exist if the download has failed and deleteExisting was true
|
// the file should not exist if the download has failed and deleteExisting was true
|
||||||
assertTrue(!deleteExisting || new File(feedFile.getFile_url()).exists() == expectedResult);
|
assertTrue(!deleteExisting || new File(feedFile.getLocalFileUrl()).exists() == expectedResult);
|
||||||
return downloader;
|
return downloader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,8 +114,8 @@ public class HttpDownloaderTest {
|
||||||
public void testCancel() {
|
public void testCancel() {
|
||||||
final String url = httpServer.getBaseUrl() + "/delay/3";
|
final String url = httpServer.getBaseUrl() + "/delay/3";
|
||||||
Feed feedFile = setupFeedFile(url, "delay", true);
|
Feed feedFile = setupFeedFile(url, "delay", true);
|
||||||
final Downloader downloader = new HttpDownloader(new DownloadRequest(feedFile.getFile_url(), url, "delay", 0,
|
final Downloader downloader = new HttpDownloader(new DownloadRequest(feedFile.getLocalFileUrl(),
|
||||||
Feed.FEEDFILETYPE_FEED, null, null, null, false));
|
url, "delay", 0, Feed.FEEDFILETYPE_FEED, null, null, null, false));
|
||||||
Thread t = new Thread() {
|
Thread t = new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class MainActivityTest {
|
||||||
openNavDrawer();
|
openNavDrawer();
|
||||||
onView(withText(R.string.add_feed_label)).perform(click());
|
onView(withText(R.string.add_feed_label)).perform(click());
|
||||||
onView(withId(R.id.addViaUrlButton)).perform(scrollTo(), click());
|
onView(withId(R.id.addViaUrlButton)).perform(scrollTo(), click());
|
||||||
onView(withId(R.id.urlEditText)).perform(replaceText(feed.getDownload_url()));
|
onView(withId(R.id.urlEditText)).perform(replaceText(feed.getDownloadUrl()));
|
||||||
onView(withText(R.string.confirm_label)).perform(scrollTo(), click());
|
onView(withText(R.string.confirm_label)).perform(scrollTo(), click());
|
||||||
|
|
||||||
// subscribe podcast
|
// subscribe podcast
|
||||||
|
|
|
@ -138,7 +138,7 @@ public class UITestUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
feed.setItems(items);
|
feed.setItems(items);
|
||||||
feed.setDownload_url(hostFeed(feed));
|
feed.setDownloadUrl(hostFeed(feed));
|
||||||
hostedFeeds.add(feed);
|
hostedFeeds.add(feed);
|
||||||
}
|
}
|
||||||
feedDataHosted = true;
|
feedDataHosted = true;
|
||||||
|
@ -174,8 +174,8 @@ public class UITestUtils {
|
||||||
for (FeedItem item : feed.getItems()) {
|
for (FeedItem item : feed.getItems()) {
|
||||||
if (item.hasMedia()) {
|
if (item.hasMedia()) {
|
||||||
FeedMedia media = item.getMedia();
|
FeedMedia media = item.getMedia();
|
||||||
int fileId = Integer.parseInt(StringUtils.substringAfter(media.getDownload_url(), "files/"));
|
int fileId = Integer.parseInt(StringUtils.substringAfter(media.getDownloadUrl(), "files/"));
|
||||||
media.setFile_url(server.accessFile(fileId).getAbsolutePath());
|
media.setLocalFileUrl(server.accessFile(fileId).getAbsolutePath());
|
||||||
media.setDownloaded(true);
|
media.setDownloaded(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,10 +45,10 @@ public class UITestUtilsTest {
|
||||||
assertFalse(feeds.isEmpty());
|
assertFalse(feeds.isEmpty());
|
||||||
|
|
||||||
for (Feed feed : feeds) {
|
for (Feed feed : feeds) {
|
||||||
testUrlReachable(feed.getDownload_url());
|
testUrlReachable(feed.getDownloadUrl());
|
||||||
for (FeedItem item : feed.getItems()) {
|
for (FeedItem item : feed.getItems()) {
|
||||||
if (item.hasMedia()) {
|
if (item.hasMedia()) {
|
||||||
testUrlReachable(item.getMedia().getDownload_url());
|
testUrlReachable(item.getMedia().getDownloadUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,8 +77,8 @@ public class UITestUtilsTest {
|
||||||
assertTrue(item.getMedia().getId() != 0);
|
assertTrue(item.getMedia().getId() != 0);
|
||||||
if (downloadEpisodes) {
|
if (downloadEpisodes) {
|
||||||
assertTrue(item.getMedia().isDownloaded());
|
assertTrue(item.getMedia().isDownloaded());
|
||||||
assertNotNull(item.getMedia().getFile_url());
|
assertNotNull(item.getMedia().getLocalFileUrl());
|
||||||
File file = new File(item.getMedia().getFile_url());
|
File file = new File(item.getMedia().getLocalFileUrl());
|
||||||
assertTrue(file.exists());
|
assertTrue(file.exists());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,9 +110,9 @@ public class Rss2Generator implements FeedGenerator {
|
||||||
}
|
}
|
||||||
if (item.getMedia() != null) {
|
if (item.getMedia() != null) {
|
||||||
xml.startTag(null, "enclosure");
|
xml.startTag(null, "enclosure");
|
||||||
xml.attribute(null, "url", item.getMedia().getDownload_url());
|
xml.attribute(null, "url", item.getMedia().getDownloadUrl());
|
||||||
xml.attribute(null, "length", String.valueOf(item.getMedia().getSize()));
|
xml.attribute(null, "length", String.valueOf(item.getMedia().getSize()));
|
||||||
xml.attribute(null, "type", item.getMedia().getMime_type());
|
xml.attribute(null, "type", item.getMedia().getMimeType());
|
||||||
xml.endTag(null, "enclosure");
|
xml.endTag(null, "enclosure");
|
||||||
}
|
}
|
||||||
if (fundingList != null) {
|
if (fundingList != null) {
|
||||||
|
|
|
@ -382,7 +382,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
||||||
private FeedHandlerResult doParseFeed(String destination) throws Exception {
|
private FeedHandlerResult doParseFeed(String destination) throws Exception {
|
||||||
FeedHandler handler = new FeedHandler();
|
FeedHandler handler = new FeedHandler();
|
||||||
Feed feed = new Feed(selectedDownloadUrl, null);
|
Feed feed = new Feed(selectedDownloadUrl, null);
|
||||||
feed.setFile_url(destination);
|
feed.setLocalFileUrl(destination);
|
||||||
File destinationFile = new File(destination);
|
File destinationFile = new File(destination);
|
||||||
try {
|
try {
|
||||||
return handler.parseFeed(feed);
|
return handler.parseFeed(feed);
|
||||||
|
@ -485,7 +485,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
||||||
final List<String> alternateUrlsList = new ArrayList<>();
|
final List<String> alternateUrlsList = new ArrayList<>();
|
||||||
final List<String> alternateUrlsTitleList = new ArrayList<>();
|
final List<String> alternateUrlsTitleList = new ArrayList<>();
|
||||||
|
|
||||||
alternateUrlsList.add(feed.getDownload_url());
|
alternateUrlsList.add(feed.getDownloadUrl());
|
||||||
alternateUrlsTitleList.add(feed.getTitle());
|
alternateUrlsTitleList.add(feed.getTitle());
|
||||||
|
|
||||||
|
|
||||||
|
@ -577,7 +577,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
for (Feed f : feeds) {
|
for (Feed f : feeds) {
|
||||||
if (f.getDownload_url().equals(selectedDownloadUrl)) {
|
if (f.getDownloadUrl().equals(selectedDownloadUrl)) {
|
||||||
return f.getId();
|
return f.getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -553,7 +553,7 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
||||||
menu.findItem(R.id.visit_website_item).setVisible(hasWebsiteLink);
|
menu.findItem(R.id.visit_website_item).setVisible(hasWebsiteLink);
|
||||||
|
|
||||||
boolean isItemAndHasLink = isFeedMedia && ShareUtils.hasLinkToShare(((FeedMedia) media).getItem());
|
boolean isItemAndHasLink = isFeedMedia && ShareUtils.hasLinkToShare(((FeedMedia) media).getItem());
|
||||||
boolean isItemHasDownloadLink = isFeedMedia && ((FeedMedia) media).getDownload_url() != null;
|
boolean isItemHasDownloadLink = isFeedMedia && ((FeedMedia) media).getDownloadUrl() != null;
|
||||||
menu.findItem(R.id.share_item).setVisible(hasWebsiteLink || isItemAndHasLink || isItemHasDownloadLink);
|
menu.findItem(R.id.share_item).setVisible(hasWebsiteLink || isItemAndHasLink || isItemHasDownloadLink);
|
||||||
|
|
||||||
menu.findItem(R.id.add_to_favorites_item).setVisible(false);
|
menu.findItem(R.id.add_to_favorites_item).setVisible(false);
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class DownloadActionButton extends ItemActionButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldNotDownload(@NonNull FeedMedia media) {
|
private boolean shouldNotDownload(@NonNull FeedMedia media) {
|
||||||
boolean isDownloading = DownloadServiceInterface.get().isDownloadingEpisode(media.getDownload_url());
|
boolean isDownloading = DownloadServiceInterface.get().isDownloadingEpisode(media.getDownloadUrl());
|
||||||
return isDownloading || media.isDownloaded();
|
return isDownloading || media.isDownloaded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public abstract class ItemActionButton {
|
||||||
return new MarkAsPlayedActionButton(item);
|
return new MarkAsPlayedActionButton(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean isDownloadingMedia = DownloadServiceInterface.get().isDownloadingEpisode(media.getDownload_url());
|
final boolean isDownloadingMedia = DownloadServiceInterface.get().isDownloadingEpisode(media.getDownloadUrl());
|
||||||
if (PlaybackStatus.isCurrentlyPlaying(media)) {
|
if (PlaybackStatus.isCurrentlyPlaying(media)) {
|
||||||
return new PauseActionButton(item);
|
return new PauseActionButton(item);
|
||||||
} else if (item.getFeed().isLocalFeed()) {
|
} else if (item.getFeed().isLocalFeed()) {
|
||||||
|
|
|
@ -26,12 +26,12 @@ public class DownloadLogDetailsDialog extends MaterialAlertDialogBuilder {
|
||||||
if (status.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
|
if (status.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
|
||||||
FeedMedia media = DBReader.getFeedMedia(status.getFeedfileId());
|
FeedMedia media = DBReader.getFeedMedia(status.getFeedfileId());
|
||||||
if (media != null) {
|
if (media != null) {
|
||||||
url = media.getDownload_url();
|
url = media.getDownloadUrl();
|
||||||
}
|
}
|
||||||
} else if (status.getFeedfileType() == Feed.FEEDFILETYPE_FEED) {
|
} else if (status.getFeedfileType() == Feed.FEEDFILETYPE_FEED) {
|
||||||
Feed feed = DBReader.getFeed(status.getFeedfileId());
|
Feed feed = DBReader.getFeed(status.getFeedfileId());
|
||||||
if (feed != null) {
|
if (feed != null) {
|
||||||
url = feed.getDownload_url();
|
url = feed.getDownloadUrl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ public abstract class EditUrlSettingsDialog {
|
||||||
|
|
||||||
final EditTextDialogBinding binding = EditTextDialogBinding.inflate(LayoutInflater.from(activity));
|
final EditTextDialogBinding binding = EditTextDialogBinding.inflate(LayoutInflater.from(activity));
|
||||||
|
|
||||||
binding.urlEditText.setText(feed.getDownload_url());
|
binding.urlEditText.setText(feed.getDownloadUrl());
|
||||||
|
|
||||||
new MaterialAlertDialogBuilder(activity)
|
new MaterialAlertDialogBuilder(activity)
|
||||||
.setView(binding.getRoot())
|
.setView(binding.getRoot())
|
||||||
|
@ -47,7 +47,7 @@ public abstract class EditUrlSettingsDialog {
|
||||||
private void onConfirmed(String original, String updated) {
|
private void onConfirmed(String original, String updated) {
|
||||||
try {
|
try {
|
||||||
DBWriter.updateFeedDownloadURL(original, updated).get();
|
DBWriter.updateFeedDownloadURL(original, updated).get();
|
||||||
feed.setDownload_url(updated);
|
feed.setDownloadUrl(updated);
|
||||||
FeedUpdateManager.runOnce(activityRef.get(), feed);
|
FeedUpdateManager.runOnce(activityRef.get(), feed);
|
||||||
} catch (ExecutionException | InterruptedException e) {
|
} catch (ExecutionException | InterruptedException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
@ -61,7 +61,7 @@ public abstract class EditUrlSettingsDialog {
|
||||||
.setTitle(R.string.edit_url_menu)
|
.setTitle(R.string.edit_url_menu)
|
||||||
.setMessage(R.string.edit_url_confirmation_msg)
|
.setMessage(R.string.edit_url_confirmation_msg)
|
||||||
.setPositiveButton(android.R.string.ok, (d, input) -> {
|
.setPositiveButton(android.R.string.ok, (d, input) -> {
|
||||||
onConfirmed(feed.getDownload_url(), url);
|
onConfirmed(feed.getDownloadUrl(), url);
|
||||||
setUrl(url);
|
setUrl(url);
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.cancel_label, null)
|
.setNegativeButton(R.string.cancel_label, null)
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class ShareDialog extends BottomSheetDialogFragment {
|
||||||
boolean downloaded = hasMedia && item.getMedia().isDownloaded();
|
boolean downloaded = hasMedia && item.getMedia().isDownloaded();
|
||||||
viewBinding.shareMediaFileRadio.setVisibility(downloaded ? View.VISIBLE : View.GONE);
|
viewBinding.shareMediaFileRadio.setVisibility(downloaded ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
boolean hasDownloadUrl = hasMedia && item.getMedia().getDownload_url() != null;
|
boolean hasDownloadUrl = hasMedia && item.getMedia().getDownloadUrl() != null;
|
||||||
if (!hasDownloadUrl) {
|
if (!hasDownloadUrl) {
|
||||||
viewBinding.shareMediaReceiverRadio.setVisibility(View.GONE);
|
viewBinding.shareMediaReceiverRadio.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,8 +92,8 @@ public class FeedInfoFragment extends Fragment implements MaterialToolbar.OnMenu
|
||||||
private final View.OnClickListener copyUrlToClipboard = new View.OnClickListener() {
|
private final View.OnClickListener copyUrlToClipboard = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (feed != null && feed.getDownload_url() != null) {
|
if (feed != null && feed.getDownloadUrl() != null) {
|
||||||
String url = feed.getDownload_url();
|
String url = feed.getDownloadUrl();
|
||||||
ClipData clipData = ClipData.newPlainText(url, url);
|
ClipData clipData = ClipData.newPlainText(url, url);
|
||||||
android.content.ClipboardManager cm = (android.content.ClipboardManager) getContext()
|
android.content.ClipboardManager cm = (android.content.ClipboardManager) getContext()
|
||||||
.getSystemService(Context.CLIPBOARD_SERVICE);
|
.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
|
@ -198,7 +198,7 @@ public class FeedInfoFragment extends Fragment implements MaterialToolbar.OnMenu
|
||||||
private void showFeed() {
|
private void showFeed() {
|
||||||
Log.d(TAG, "Language is " + feed.getLanguage());
|
Log.d(TAG, "Language is " + feed.getLanguage());
|
||||||
Log.d(TAG, "Author is " + feed.getAuthor());
|
Log.d(TAG, "Author is " + feed.getAuthor());
|
||||||
Log.d(TAG, "URL is " + feed.getDownload_url());
|
Log.d(TAG, "URL is " + feed.getDownloadUrl());
|
||||||
Glide.with(this)
|
Glide.with(this)
|
||||||
.load(feed.getImageUrl())
|
.load(feed.getImageUrl())
|
||||||
.apply(new RequestOptions()
|
.apply(new RequestOptions()
|
||||||
|
@ -227,7 +227,7 @@ public class FeedInfoFragment extends Fragment implements MaterialToolbar.OnMenu
|
||||||
txtvAuthorHeader.setText(feed.getAuthor());
|
txtvAuthorHeader.setText(feed.getAuthor());
|
||||||
}
|
}
|
||||||
|
|
||||||
txtvUrl.setText(feed.getDownload_url());
|
txtvUrl.setText(feed.getDownloadUrl());
|
||||||
txtvUrl.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.ic_paperclip, 0);
|
txtvUrl.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.ic_paperclip, 0);
|
||||||
|
|
||||||
if (feed.getPaymentLinks() == null || feed.getPaymentLinks().size() == 0) {
|
if (feed.getPaymentLinks() == null || feed.getPaymentLinks().size() == 0) {
|
||||||
|
@ -309,8 +309,8 @@ public class FeedInfoFragment extends Fragment implements MaterialToolbar.OnMenu
|
||||||
new EditUrlSettingsDialog(getActivity(), feed) {
|
new EditUrlSettingsDialog(getActivity(), feed) {
|
||||||
@Override
|
@Override
|
||||||
protected void setUrl(String url) {
|
protected void setUrl(String url) {
|
||||||
feed.setDownload_url(url);
|
feed.setDownloadUrl(url);
|
||||||
txtvUrl.setText(feed.getDownload_url());
|
txtvUrl.setText(feed.getDownloadUrl());
|
||||||
txtvUrl.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.ic_paperclip, 0);
|
txtvUrl.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.ic_paperclip, 0);
|
||||||
}
|
}
|
||||||
}.show();
|
}.show();
|
||||||
|
@ -339,7 +339,7 @@ public class FeedInfoFragment extends Fragment implements MaterialToolbar.OnMenu
|
||||||
if (documentFile == null) {
|
if (documentFile == null) {
|
||||||
throw new IllegalArgumentException("Unable to retrieve document tree");
|
throw new IllegalArgumentException("Unable to retrieve document tree");
|
||||||
}
|
}
|
||||||
feed.setDownload_url(Feed.PREFIX_LOCAL_FOLDER + uri.toString());
|
feed.setDownloadUrl(Feed.PREFIX_LOCAL_FOLDER + uri.toString());
|
||||||
DBTasks.updateFeed(getContext(), feed, true);
|
DBTasks.updateFeed(getContext(), feed, true);
|
||||||
})
|
})
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
|
|
|
@ -276,7 +276,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
|
||||||
FeedUpdateManager.runOnceOrAsk(getContext(), feed);
|
FeedUpdateManager.runOnceOrAsk(getContext(), feed);
|
||||||
} else if (item.getItemId() == R.id.refresh_complete_item) {
|
} else if (item.getItemId() == R.id.refresh_complete_item) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
feed.setNextPageLink(feed.getDownload_url());
|
feed.setNextPageLink(feed.getDownloadUrl());
|
||||||
feed.setPageNr(0);
|
feed.setPageNr(0);
|
||||||
try {
|
try {
|
||||||
DBWriter.resetPagedFeedPage(feed).get();
|
DBWriter.resetPagedFeedPage(feed).get();
|
||||||
|
|
|
@ -304,12 +304,12 @@ public class ItemFragment extends Fragment {
|
||||||
private void updateButtons() {
|
private void updateButtons() {
|
||||||
progbarDownload.setVisibility(View.GONE);
|
progbarDownload.setVisibility(View.GONE);
|
||||||
if (item.hasMedia()) {
|
if (item.hasMedia()) {
|
||||||
if (DownloadServiceInterface.get().isDownloadingEpisode(item.getMedia().getDownload_url())) {
|
if (DownloadServiceInterface.get().isDownloadingEpisode(item.getMedia().getDownloadUrl())) {
|
||||||
progbarDownload.setVisibility(View.VISIBLE);
|
progbarDownload.setVisibility(View.VISIBLE);
|
||||||
progbarDownload.setPercentage(0.01f * Math.max(1,
|
progbarDownload.setPercentage(0.01f * Math.max(1,
|
||||||
DownloadServiceInterface.get().getProgress(item.getMedia().getDownload_url())), item);
|
DownloadServiceInterface.get().getProgress(item.getMedia().getDownloadUrl())), item);
|
||||||
progbarDownload.setIndeterminate(
|
progbarDownload.setIndeterminate(
|
||||||
DownloadServiceInterface.get().isEpisodeQueued(item.getMedia().getDownload_url()));
|
DownloadServiceInterface.get().isEpisodeQueued(item.getMedia().getDownloadUrl()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ public class ItemFragment extends Fragment {
|
||||||
} else {
|
} else {
|
||||||
actionButton1 = new StreamActionButton(item);
|
actionButton1 = new StreamActionButton(item);
|
||||||
}
|
}
|
||||||
if (DownloadServiceInterface.get().isDownloadingEpisode(media.getDownload_url())) {
|
if (DownloadServiceInterface.get().isDownloadingEpisode(media.getDownloadUrl())) {
|
||||||
actionButton2 = new CancelDownloadActionButton(item);
|
actionButton2 = new CancelDownloadActionButton(item);
|
||||||
} else if (!media.isDownloaded()) {
|
} else if (!media.isDownloaded()) {
|
||||||
actionButton2 = new DownloadActionButton(item);
|
actionButton2 = new DownloadActionButton(item);
|
||||||
|
@ -383,7 +383,7 @@ public class ItemFragment extends Fragment {
|
||||||
if (item == null || item.getMedia() == null) {
|
if (item == null || item.getMedia() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!event.getUrls().contains(item.getMedia().getDownload_url())) {
|
if (!event.getUrls().contains(item.getMedia().getDownloadUrl())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (itemsLoaded && getActivity() != null) {
|
if (itemsLoaded && getActivity() != null) {
|
||||||
|
|
|
@ -148,11 +148,11 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder {
|
||||||
itemView.setBackgroundResource(ThemeUtils.getDrawableFromAttr(activity, R.attr.selectableItemBackground));
|
itemView.setBackgroundResource(ThemeUtils.getDrawableFromAttr(activity, R.attr.selectableItemBackground));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DownloadServiceInterface.get().isDownloadingEpisode(media.getDownload_url())) {
|
if (DownloadServiceInterface.get().isDownloadingEpisode(media.getDownloadUrl())) {
|
||||||
float percent = 0.01f * DownloadServiceInterface.get().getProgress(media.getDownload_url());
|
float percent = 0.01f * DownloadServiceInterface.get().getProgress(media.getDownloadUrl());
|
||||||
secondaryActionProgress.setPercentage(Math.max(percent, 0.01f), item);
|
secondaryActionProgress.setPercentage(Math.max(percent, 0.01f), item);
|
||||||
secondaryActionProgress.setIndeterminate(
|
secondaryActionProgress.setIndeterminate(
|
||||||
DownloadServiceInterface.get().isEpisodeQueued(media.getDownload_url()));
|
DownloadServiceInterface.get().isEpisodeQueued(media.getDownloadUrl()));
|
||||||
} else if (media.isDownloaded()) {
|
} else if (media.isDownloaded()) {
|
||||||
secondaryActionProgress.setPercentage(1, item); // Do not animate 100% -> 0%
|
secondaryActionProgress.setPercentage(1, item); // Do not animate 100% -> 0%
|
||||||
secondaryActionProgress.setIndeterminate(false);
|
secondaryActionProgress.setIndeterminate(false);
|
||||||
|
|
|
@ -85,11 +85,11 @@ public class HorizontalItemViewHolder extends RecyclerView.ViewHolder {
|
||||||
setProgressBar(false, 0);
|
setProgressBar(false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DownloadServiceInterface.get().isDownloadingEpisode(media.getDownload_url())) {
|
if (DownloadServiceInterface.get().isDownloadingEpisode(media.getDownloadUrl())) {
|
||||||
float percent = 0.01f * DownloadServiceInterface.get().getProgress(media.getDownload_url());
|
float percent = 0.01f * DownloadServiceInterface.get().getProgress(media.getDownloadUrl());
|
||||||
circularProgressBar.setPercentage(Math.max(percent, 0.01f), item);
|
circularProgressBar.setPercentage(Math.max(percent, 0.01f), item);
|
||||||
circularProgressBar.setIndeterminate(
|
circularProgressBar.setIndeterminate(
|
||||||
DownloadServiceInterface.get().isEpisodeQueued(media.getDownload_url()));
|
DownloadServiceInterface.get().isEpisodeQueued(media.getDownloadUrl()));
|
||||||
} else if (media.isDownloaded()) {
|
} else if (media.isDownloaded()) {
|
||||||
circularProgressBar.setPercentage(1, item); // Do not animate 100% -> 0%
|
circularProgressBar.setPercentage(1, item); // Do not animate 100% -> 0%
|
||||||
circularProgressBar.setIndeterminate(false);
|
circularProgressBar.setIndeterminate(false);
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class LocalFeedUpdater {
|
||||||
public static void updateFeed(Feed feed, Context context,
|
public static void updateFeed(Feed feed, Context context,
|
||||||
@Nullable UpdaterProgressListener updaterProgressListener) {
|
@Nullable UpdaterProgressListener updaterProgressListener) {
|
||||||
try {
|
try {
|
||||||
String uriString = feed.getDownload_url().replace(Feed.PREFIX_LOCAL_FOLDER, "");
|
String uriString = feed.getDownloadUrl().replace(Feed.PREFIX_LOCAL_FOLDER, "");
|
||||||
DocumentFile documentFolder = DocumentFile.fromTreeUri(context, Uri.parse(uriString));
|
DocumentFile documentFolder = DocumentFile.fromTreeUri(context, Uri.parse(uriString));
|
||||||
if (documentFolder == null) {
|
if (documentFolder == null) {
|
||||||
throw new IOException("Unable to retrieve document tree. "
|
throw new IOException("Unable to retrieve document tree. "
|
||||||
|
@ -178,7 +178,7 @@ public class LocalFeedUpdater {
|
||||||
|
|
||||||
for (FeedItem existingItem : feed.getItems()) {
|
for (FeedItem existingItem : feed.getItems()) {
|
||||||
if (existingItem.getMedia() != null
|
if (existingItem.getMedia() != null
|
||||||
&& existingItem.getMedia().getDownload_url().equals(file.getUri().toString())
|
&& existingItem.getMedia().getDownloadUrl().equals(file.getUri().toString())
|
||||||
&& file.getLength() == existingItem.getMedia().getSize()) {
|
&& file.getLength() == existingItem.getMedia().getSize()) {
|
||||||
// We found an old file that we already scanned. Re-use metadata.
|
// We found an old file that we already scanned. Re-use metadata.
|
||||||
item.updateFromOther(existingItem);
|
item.updateFromOther(existingItem);
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class DownloadRequestCreator {
|
||||||
if (dest.exists()) {
|
if (dest.exists()) {
|
||||||
dest.delete();
|
dest.delete();
|
||||||
}
|
}
|
||||||
Log.d(TAG, "Requesting download of url " + feed.getDownload_url());
|
Log.d(TAG, "Requesting download of url " + feed.getDownloadUrl());
|
||||||
|
|
||||||
String username = (feed.getPreferences() != null) ? feed.getPreferences().getUsername() : null;
|
String username = (feed.getPreferences() != null) ? feed.getPreferences().getUsername() : null;
|
||||||
String password = (feed.getPreferences() != null) ? feed.getPreferences().getPassword() : null;
|
String password = (feed.getPreferences() != null) ? feed.getPreferences().getPassword() : null;
|
||||||
|
@ -36,10 +36,10 @@ public class DownloadRequestCreator {
|
||||||
|
|
||||||
public static DownloadRequestBuilder create(FeedMedia media) {
|
public static DownloadRequestBuilder create(FeedMedia media) {
|
||||||
final boolean partiallyDownloadedFileExists =
|
final boolean partiallyDownloadedFileExists =
|
||||||
media.getFile_url() != null && new File(media.getFile_url()).exists();
|
media.getLocalFileUrl() != null && new File(media.getLocalFileUrl()).exists();
|
||||||
File dest;
|
File dest;
|
||||||
if (partiallyDownloadedFileExists) {
|
if (partiallyDownloadedFileExists) {
|
||||||
dest = new File(media.getFile_url());
|
dest = new File(media.getLocalFileUrl());
|
||||||
} else {
|
} else {
|
||||||
dest = new File(getMediafilePath(media), getMediafilename(media));
|
dest = new File(getMediafilePath(media), getMediafilename(media));
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class DownloadRequestCreator {
|
||||||
if (dest.exists() && !partiallyDownloadedFileExists) {
|
if (dest.exists() && !partiallyDownloadedFileExists) {
|
||||||
dest = findUnusedFile(dest);
|
dest = findUnusedFile(dest);
|
||||||
}
|
}
|
||||||
Log.d(TAG, "Requesting download of url " + media.getDownload_url());
|
Log.d(TAG, "Requesting download of url " + media.getDownloadUrl());
|
||||||
|
|
||||||
String username = (media.getItem().getFeed().getPreferences() != null)
|
String username = (media.getItem().getFeed().getPreferences() != null)
|
||||||
? media.getItem().getFeed().getPreferences().getUsername() : null;
|
? media.getItem().getFeed().getPreferences().getUsername() : null;
|
||||||
|
@ -83,7 +83,7 @@ public class DownloadRequestCreator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getFeedfileName(Feed feed) {
|
private static String getFeedfileName(Feed feed) {
|
||||||
String filename = feed.getDownload_url();
|
String filename = feed.getDownloadUrl();
|
||||||
if (feed.getTitle() != null && !feed.getTitle().isEmpty()) {
|
if (feed.getTitle() != null && !feed.getTitle().isEmpty()) {
|
||||||
filename = feed.getTitle();
|
filename = feed.getTitle();
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public class DownloadRequestCreator {
|
||||||
titleBaseFilename = FileNameGenerator.generateFileName(title);
|
titleBaseFilename = FileNameGenerator.generateFileName(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
String urlBaseFilename = URLUtil.guessFileName(media.getDownload_url(), null, media.getMime_type());
|
String urlBaseFilename = URLUtil.guessFileName(media.getDownloadUrl(), null, media.getMimeType());
|
||||||
|
|
||||||
String baseFilename;
|
String baseFilename;
|
||||||
if (!titleBaseFilename.equals("")) {
|
if (!titleBaseFilename.equals("")) {
|
||||||
|
|
|
@ -30,14 +30,14 @@ public class DownloadServiceInterfaceImpl extends DownloadServiceInterface {
|
||||||
} else {
|
} else {
|
||||||
workRequest.setConstraints(getConstraints());
|
workRequest.setConstraints(getConstraints());
|
||||||
}
|
}
|
||||||
WorkManager.getInstance(context).enqueueUniqueWork(item.getMedia().getDownload_url(),
|
WorkManager.getInstance(context).enqueueUniqueWork(item.getMedia().getDownloadUrl(),
|
||||||
ExistingWorkPolicy.KEEP, workRequest.build());
|
ExistingWorkPolicy.KEEP, workRequest.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void download(Context context, FeedItem item) {
|
public void download(Context context, FeedItem item) {
|
||||||
OneTimeWorkRequest.Builder workRequest = getRequest(context, item);
|
OneTimeWorkRequest.Builder workRequest = getRequest(context, item);
|
||||||
workRequest.setConstraints(getConstraints());
|
workRequest.setConstraints(getConstraints());
|
||||||
WorkManager.getInstance(context).enqueueUniqueWork(item.getMedia().getDownload_url(),
|
WorkManager.getInstance(context).enqueueUniqueWork(item.getMedia().getDownloadUrl(),
|
||||||
ExistingWorkPolicy.KEEP, workRequest.build());
|
ExistingWorkPolicy.KEEP, workRequest.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class DownloadServiceInterfaceImpl extends DownloadServiceInterface {
|
||||||
OneTimeWorkRequest.Builder workRequest = new OneTimeWorkRequest.Builder(EpisodeDownloadWorker.class)
|
OneTimeWorkRequest.Builder workRequest = new OneTimeWorkRequest.Builder(EpisodeDownloadWorker.class)
|
||||||
.setInitialDelay(0L, TimeUnit.MILLISECONDS)
|
.setInitialDelay(0L, TimeUnit.MILLISECONDS)
|
||||||
.addTag(DownloadServiceInterface.WORK_TAG)
|
.addTag(DownloadServiceInterface.WORK_TAG)
|
||||||
.addTag(DownloadServiceInterface.WORK_TAG_EPISODE_URL + item.getMedia().getDownload_url());
|
.addTag(DownloadServiceInterface.WORK_TAG_EPISODE_URL + item.getMedia().getDownloadUrl());
|
||||||
if (!item.isTagged(FeedItem.TAG_QUEUE) && UserPreferences.enqueueDownloadedEpisodes()) {
|
if (!item.isTagged(FeedItem.TAG_QUEUE) && UserPreferences.enqueueDownloadedEpisodes()) {
|
||||||
DBWriter.addQueueItem(context, false, item.getId());
|
DBWriter.addQueueItem(context, false, item.getId());
|
||||||
workRequest.addTag(DownloadServiceInterface.WORK_DATA_WAS_QUEUED);
|
workRequest.addTag(DownloadServiceInterface.WORK_DATA_WAS_QUEUED);
|
||||||
|
@ -68,7 +68,7 @@ public class DownloadServiceInterfaceImpl extends DownloadServiceInterface {
|
||||||
public void cancel(Context context, FeedMedia media) {
|
public void cancel(Context context, FeedMedia media) {
|
||||||
// This needs to be done here, not in the worker. Reason: The worker might or might not be running.
|
// This needs to be done here, not in the worker. Reason: The worker might or might not be running.
|
||||||
DBWriter.deleteFeedMediaOfItem(context, media.getId()); // Remove partially downloaded file
|
DBWriter.deleteFeedMediaOfItem(context, media.getId()); // Remove partially downloaded file
|
||||||
String tag = WORK_TAG_EPISODE_URL + media.getDownload_url();
|
String tag = WORK_TAG_EPISODE_URL + media.getDownloadUrl();
|
||||||
Future<List<WorkInfo>> future = WorkManager.getInstance(context).getWorkInfosByTag(tag);
|
Future<List<WorkInfo>> future = WorkManager.getInstance(context).getWorkInfosByTag(tag);
|
||||||
Observable.fromFuture(future)
|
Observable.fromFuture(future)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
|
|
|
@ -116,7 +116,7 @@ public class EpisodeDownloadWorker extends Worker {
|
||||||
nm.cancel(R.id.notification_downloading);
|
nm.cancel(R.id.notification_downloading);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.d(TAG, "Worker for " + media.getDownload_url() + " returned.");
|
Log.d(TAG, "Worker for " + media.getDownloadUrl() + " returned.");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ public class EpisodeDownloadWorker extends Worker {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dest.exists()) {
|
if (dest.exists()) {
|
||||||
media.setFile_url(request.getDestination());
|
media.setLocalFileUrl(request.getDestination());
|
||||||
try {
|
try {
|
||||||
DBWriter.setFeedMedia(media).get();
|
DBWriter.setFeedMedia(media).get();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class FeedParserTask implements Callable<FeedHandlerResult> {
|
||||||
@Override
|
@Override
|
||||||
public FeedHandlerResult call() {
|
public FeedHandlerResult call() {
|
||||||
Feed feed = new Feed(request.getSource(), request.getLastModified());
|
Feed feed = new Feed(request.getSource(), request.getLastModified());
|
||||||
feed.setFile_url(request.getDestination());
|
feed.setLocalFileUrl(request.getDestination());
|
||||||
feed.setId(request.getFeedfileId());
|
feed.setId(request.getFeedfileId());
|
||||||
feed.setDownloaded(true);
|
feed.setDownloaded(true);
|
||||||
feed.setPreferences(new FeedPreferences(0, true, FeedPreferences.AutoDeleteAction.GLOBAL,
|
feed.setPreferences(new FeedPreferences(0, true, FeedPreferences.AutoDeleteAction.GLOBAL,
|
||||||
|
@ -57,7 +57,7 @@ public class FeedParserTask implements Callable<FeedHandlerResult> {
|
||||||
Log.d(TAG, feed.getTitle() + " parsed");
|
Log.d(TAG, feed.getTitle() + " parsed");
|
||||||
checkFeedData(feed);
|
checkFeedData(feed);
|
||||||
if (TextUtils.isEmpty(feed.getImageUrl())) {
|
if (TextUtils.isEmpty(feed.getImageUrl())) {
|
||||||
feed.setImageUrl(Feed.PREFIX_GENERATIVE_COVER + feed.getDownload_url());
|
feed.setImageUrl(Feed.PREFIX_GENERATIVE_COVER + feed.getDownloadUrl());
|
||||||
}
|
}
|
||||||
} catch (SAXException | IOException | ParserConfigurationException e) {
|
} catch (SAXException | IOException | ParserConfigurationException e) {
|
||||||
successful = false;
|
successful = false;
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class MediaDownloadedHandler implements Runnable {
|
||||||
// media.setDownloaded modifies played state
|
// media.setDownloaded modifies played state
|
||||||
boolean broadcastUnreadStateUpdate = media.getItem() != null && media.getItem().isNew();
|
boolean broadcastUnreadStateUpdate = media.getItem() != null && media.getItem().isNew();
|
||||||
media.setDownloaded(true);
|
media.setDownloaded(true);
|
||||||
media.setFile_url(request.getDestination());
|
media.setLocalFileUrl(request.getDestination());
|
||||||
media.setSize(new File(request.getDestination()).length());
|
media.setSize(new File(request.getDestination()).length());
|
||||||
media.checkEmbeddedPicture(); // enforce check
|
media.checkEmbeddedPicture(); // enforce check
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ public class MediaDownloadedHandler implements Runnable {
|
||||||
// Get duration
|
// Get duration
|
||||||
String durationStr = null;
|
String durationStr = null;
|
||||||
try (MediaMetadataRetrieverCompat mmr = new MediaMetadataRetrieverCompat()) {
|
try (MediaMetadataRetrieverCompat mmr = new MediaMetadataRetrieverCompat()) {
|
||||||
mmr.setDataSource(media.getFile_url());
|
mmr.setDataSource(media.getLocalFileUrl());
|
||||||
durationStr = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
|
durationStr = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
|
||||||
media.setDuration(Integer.parseInt(durationStr));
|
media.setDuration(Integer.parseInt(durationStr));
|
||||||
Log.d(TAG, "Duration of file is " + media.getDuration());
|
Log.d(TAG, "Duration of file is " + media.getDuration());
|
||||||
|
|
|
@ -175,10 +175,10 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
|
||||||
} else {
|
} else {
|
||||||
mediaPlayer.setDataSource(media.getStreamUrl());
|
mediaPlayer.setDataSource(media.getStreamUrl());
|
||||||
}
|
}
|
||||||
} else if (media.getLocalMediaUrl() != null && new File(media.getLocalMediaUrl()).canRead()) {
|
} else if (media.getLocalFileUrl() != null && new File(media.getLocalFileUrl()).canRead()) {
|
||||||
mediaPlayer.setDataSource(media.getLocalMediaUrl());
|
mediaPlayer.setDataSource(media.getLocalFileUrl());
|
||||||
} else {
|
} else {
|
||||||
throw new IOException("Unable to read local file " + media.getLocalMediaUrl());
|
throw new IOException("Unable to read local file " + media.getLocalFileUrl());
|
||||||
}
|
}
|
||||||
UiModeManager uiModeManager = (UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);
|
UiModeManager uiModeManager = (UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);
|
||||||
if (uiModeManager.getCurrentModeType() != Configuration.UI_MODE_TYPE_CAR) {
|
if (uiModeManager.getCurrentModeType() != Configuration.UI_MODE_TYPE_CAR) {
|
||||||
|
|
|
@ -98,7 +98,7 @@ public final class DBTasks {
|
||||||
public static void notifyMissingFeedMediaFile(final Context context, final FeedMedia media) {
|
public static void notifyMissingFeedMediaFile(final Context context, final FeedMedia media) {
|
||||||
Log.i(TAG, "The feedmanager was notified about a missing episode. It will update its database now.");
|
Log.i(TAG, "The feedmanager was notified about a missing episode. It will update its database now.");
|
||||||
media.setDownloaded(false);
|
media.setDownloaded(false);
|
||||||
media.setFile_url(null);
|
media.setLocalFileUrl(null);
|
||||||
DBWriter.setFeedMedia(media);
|
DBWriter.setFeedMedia(media);
|
||||||
EventBus.getDefault().post(FeedItemEvent.updated(media.getItem()));
|
EventBus.getDefault().post(FeedItemEvent.updated(media.getItem()));
|
||||||
EventBus.getDefault().post(new MessageEvent(context.getString(R.string.error_file_not_found)));
|
EventBus.getDefault().post(new MessageEvent(context.getString(R.string.error_file_not_found)));
|
||||||
|
@ -369,7 +369,7 @@ public final class DBTasks {
|
||||||
private static String duplicateEpisodeDetails(FeedItem item) {
|
private static String duplicateEpisodeDetails(FeedItem item) {
|
||||||
return "Title: " + item.getTitle()
|
return "Title: " + item.getTitle()
|
||||||
+ "\nID: " + item.getItemIdentifier()
|
+ "\nID: " + item.getItemIdentifier()
|
||||||
+ ((item.getMedia() == null) ? "" : "\nURL: " + item.getMedia().getDownload_url());
|
+ ((item.getMedia() == null) ? "" : "\nURL: " + item.getMedia().getDownloadUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -116,25 +116,25 @@ public class DBWriter {
|
||||||
Log.i(TAG, String.format(Locale.US, "Requested to delete FeedMedia [id=%d, title=%s, downloaded=%s",
|
Log.i(TAG, String.format(Locale.US, "Requested to delete FeedMedia [id=%d, title=%s, downloaded=%s",
|
||||||
media.getId(), media.getEpisodeTitle(), media.isDownloaded()));
|
media.getId(), media.getEpisodeTitle(), media.isDownloaded()));
|
||||||
boolean localDelete = false;
|
boolean localDelete = false;
|
||||||
if (media.getFile_url() != null && media.getFile_url().startsWith("content://")) {
|
if (media.getLocalFileUrl() != null && media.getLocalFileUrl().startsWith("content://")) {
|
||||||
// Local feed
|
// Local feed
|
||||||
DocumentFile documentFile = DocumentFile.fromSingleUri(context, Uri.parse(media.getFile_url()));
|
DocumentFile documentFile = DocumentFile.fromSingleUri(context, Uri.parse(media.getLocalFileUrl()));
|
||||||
if (documentFile == null || !documentFile.exists() || !documentFile.delete()) {
|
if (documentFile == null || !documentFile.exists() || !documentFile.delete()) {
|
||||||
EventBus.getDefault().post(new MessageEvent(context.getString(R.string.delete_local_failed)));
|
EventBus.getDefault().post(new MessageEvent(context.getString(R.string.delete_local_failed)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
media.setFile_url(null);
|
media.setLocalFileUrl(null);
|
||||||
localDelete = true;
|
localDelete = true;
|
||||||
} else if (media.getFile_url() != null) {
|
} else if (media.getLocalFileUrl() != null) {
|
||||||
// delete downloaded media file
|
// delete downloaded media file
|
||||||
File mediaFile = new File(media.getFile_url());
|
File mediaFile = new File(media.getLocalFileUrl());
|
||||||
if (mediaFile.exists() && !mediaFile.delete()) {
|
if (mediaFile.exists() && !mediaFile.delete()) {
|
||||||
MessageEvent evt = new MessageEvent(context.getString(R.string.delete_failed));
|
MessageEvent evt = new MessageEvent(context.getString(R.string.delete_failed));
|
||||||
EventBus.getDefault().post(evt);
|
EventBus.getDefault().post(evt);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
media.setDownloaded(false);
|
media.setDownloaded(false);
|
||||||
media.setFile_url(null);
|
media.setLocalFileUrl(null);
|
||||||
media.setHasEmbeddedPicture(false);
|
media.setHasEmbeddedPicture(false);
|
||||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||||
adapter.open();
|
adapter.open();
|
||||||
|
@ -192,7 +192,7 @@ public class DBWriter {
|
||||||
adapter.close();
|
adapter.close();
|
||||||
|
|
||||||
if (!feed.isLocalFeed()) {
|
if (!feed.isLocalFeed()) {
|
||||||
SynchronizationQueueSink.enqueueFeedRemovedIfSynchronizationIsActive(context, feed.getDownload_url());
|
SynchronizationQueueSink.enqueueFeedRemovedIfSynchronizationIsActive(context, feed.getDownloadUrl());
|
||||||
}
|
}
|
||||||
EventBus.getDefault().post(new FeedListUpdateEvent(feed));
|
EventBus.getDefault().post(new FeedListUpdateEvent(feed));
|
||||||
});
|
});
|
||||||
|
@ -802,7 +802,7 @@ public class DBWriter {
|
||||||
|
|
||||||
for (Feed feed : feeds) {
|
for (Feed feed : feeds) {
|
||||||
if (!feed.isLocalFeed()) {
|
if (!feed.isLocalFeed()) {
|
||||||
SynchronizationQueueSink.enqueueFeedAddedIfSynchronizationIsActive(context, feed.getDownload_url());
|
SynchronizationQueueSink.enqueueFeedAddedIfSynchronizationIsActive(context, feed.getDownloadUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,8 +53,8 @@ public class FeedItemDuplicateGuesser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean mimeTypeLooksSimilar(FeedMedia media1, FeedMedia media2) {
|
private static boolean mimeTypeLooksSimilar(FeedMedia media1, FeedMedia media2) {
|
||||||
String mimeType1 = media1.getMime_type();
|
String mimeType1 = media1.getMimeType();
|
||||||
String mimeType2 = media2.getMime_type();
|
String mimeType2 = media2.getMimeType();
|
||||||
if (mimeType1 == null || mimeType2 == null) {
|
if (mimeType1 == null || mimeType2 == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ class ItemEnqueuePositionCalculator {
|
||||||
}
|
}
|
||||||
return curItem != null
|
return curItem != null
|
||||||
&& curItem.getMedia() != null
|
&& curItem.getMedia() != null
|
||||||
&& DownloadServiceInterface.get().isDownloadingEpisode(curItem.getMedia().getDownload_url());
|
&& DownloadServiceInterface.get().isDownloadingEpisode(curItem.getMedia().getDownloadUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getCurrentlyPlayingPosition(@NonNull List<FeedItem> curQueue,
|
private static int getCurrentlyPlayingPosition(@NonNull List<FeedItem> curQueue,
|
||||||
|
|
|
@ -125,10 +125,10 @@ public class ChapterUtils {
|
||||||
|
|
||||||
private static CountingInputStream openStream(Playable playable, Context context) throws IOException {
|
private static CountingInputStream openStream(Playable playable, Context context) throws IOException {
|
||||||
if (playable.localFileAvailable()) {
|
if (playable.localFileAvailable()) {
|
||||||
if (playable.getLocalMediaUrl() == null) {
|
if (playable.getLocalFileUrl() == null) {
|
||||||
throw new IOException("No local url");
|
throw new IOException("No local url");
|
||||||
}
|
}
|
||||||
File source = new File(playable.getLocalMediaUrl());
|
File source = new File(playable.getLocalFileUrl());
|
||||||
if (!source.exists()) {
|
if (!source.exists()) {
|
||||||
throw new IOException("Local file does not exist");
|
throw new IOException("Local file does not exist");
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class FeedItemUtil {
|
||||||
public static int indexOfItemWithDownloadUrl(List<FeedItem> items, String downloadUrl) {
|
public static int indexOfItemWithDownloadUrl(List<FeedItem> items, String downloadUrl) {
|
||||||
for (int i = 0; i < items.size(); i++) {
|
for (int i = 0; i < items.size(); i++) {
|
||||||
FeedItem item = items.get(i);
|
FeedItem item = items.get(i);
|
||||||
if (item != null && item.getMedia() != null && item.getMedia().getDownload_url().equals(downloadUrl)) {
|
if (item != null && item.getMedia() != null && item.getMedia().getDownloadUrl().equals(downloadUrl)) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class ShareUtils {
|
||||||
String text = feed.getTitle()
|
String text = feed.getTitle()
|
||||||
+ "\n\n"
|
+ "\n\n"
|
||||||
+ "https://antennapod.org/deeplink/subscribe/?url="
|
+ "https://antennapod.org/deeplink/subscribe/?url="
|
||||||
+ URLEncoder.encode(feed.getDownload_url())
|
+ URLEncoder.encode(feed.getDownloadUrl())
|
||||||
+ "&title="
|
+ "&title="
|
||||||
+ URLEncoder.encode(feed.getTitle());
|
+ URLEncoder.encode(feed.getTitle());
|
||||||
shareLink(context, text);
|
shareLink(context, text);
|
||||||
|
@ -49,7 +49,7 @@ public class ShareUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void shareMediaDownloadLink(Context context, FeedMedia media) {
|
public static void shareMediaDownloadLink(Context context, FeedMedia media) {
|
||||||
shareLink(context, media.getDownload_url());
|
shareLink(context, media.getDownloadUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void shareFeedItemLinkWithDownloadLink(Context context, FeedItem item, boolean withPosition) {
|
public static void shareFeedItemLinkWithDownloadLink(Context context, FeedItem item, boolean withPosition) {
|
||||||
|
@ -66,9 +66,9 @@ public class ShareUtils {
|
||||||
text += FeedItemUtil.getLinkWithFallback(item);
|
text += FeedItemUtil.getLinkWithFallback(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getMedia() != null && item.getMedia().getDownload_url() != null) {
|
if (item.getMedia() != null && item.getMedia().getDownloadUrl() != null) {
|
||||||
text += "\n\n" + context.getResources().getString(R.string.share_dialog_media_file_label) + ": ";
|
text += "\n\n" + context.getResources().getString(R.string.share_dialog_media_file_label) + ": ";
|
||||||
text += item.getMedia().getDownload_url();
|
text += item.getMedia().getDownloadUrl();
|
||||||
if (withPosition) {
|
if (withPosition) {
|
||||||
text += "#t=" + pos / 1000;
|
text += "#t=" + pos / 1000;
|
||||||
}
|
}
|
||||||
|
@ -78,10 +78,10 @@ public class ShareUtils {
|
||||||
|
|
||||||
public static void shareFeedItemFile(Context context, FeedMedia media) {
|
public static void shareFeedItemFile(Context context, FeedMedia media) {
|
||||||
Uri fileUri = FileProvider.getUriForFile(context, context.getString(R.string.provider_authority),
|
Uri fileUri = FileProvider.getUriForFile(context, context.getString(R.string.provider_authority),
|
||||||
new File(media.getLocalMediaUrl()));
|
new File(media.getLocalFileUrl()));
|
||||||
|
|
||||||
new ShareCompat.IntentBuilder(context)
|
new ShareCompat.IntentBuilder(context)
|
||||||
.setType(media.getMime_type())
|
.setType(media.getMimeType())
|
||||||
.addStream(fileUri)
|
.addStream(fileUri)
|
||||||
.setChooserTitle(R.string.share_file_label)
|
.setChooserTitle(R.string.share_file_label)
|
||||||
.startChooser();
|
.startChooser();
|
||||||
|
|
|
@ -28,14 +28,14 @@ public abstract class MediaSizeLoader {
|
||||||
}
|
}
|
||||||
long size = Integer.MIN_VALUE;
|
long size = Integer.MIN_VALUE;
|
||||||
if (media.isDownloaded()) {
|
if (media.isDownloaded()) {
|
||||||
File mediaFile = new File(media.getLocalMediaUrl());
|
File mediaFile = new File(media.getLocalFileUrl());
|
||||||
if (mediaFile.exists()) {
|
if (mediaFile.exists()) {
|
||||||
size = mediaFile.length();
|
size = mediaFile.length();
|
||||||
}
|
}
|
||||||
} else if (!media.checkedOnSizeButUnknown()) {
|
} else if (!media.checkedOnSizeButUnknown()) {
|
||||||
// only query the network if we haven't already checked
|
// only query the network if we haven't already checked
|
||||||
|
|
||||||
String url = media.getDownload_url();
|
String url = media.getDownloadUrl();
|
||||||
if (TextUtils.isEmpty(url)) {
|
if (TextUtils.isEmpty(url)) {
|
||||||
emitter.onSuccess(0L);
|
emitter.onSuccess(0L);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class LocalFeedUpdaterTest {
|
||||||
// verify new feed in database
|
// verify new feed in database
|
||||||
verifySingleFeedInDatabaseAndItemCount(2);
|
verifySingleFeedInDatabaseAndItemCount(2);
|
||||||
Feed feedAfter = verifySingleFeedInDatabase();
|
Feed feedAfter = verifySingleFeedInDatabase();
|
||||||
assertEquals(FEED_URL, feedAfter.getDownload_url());
|
assertEquals(FEED_URL, feedAfter.getDownloadUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -211,7 +211,7 @@ public class DbCleanupTests {
|
||||||
FeedMedia m = feeds.get(0).getItems().get(0).getMedia();
|
FeedMedia m = feeds.get(0).getItems().get(0).getMedia();
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
m.setDownloaded(true);
|
m.setDownloaded(true);
|
||||||
m.setFile_url("file");
|
m.setLocalFileUrl("file");
|
||||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||||
adapter.open();
|
adapter.open();
|
||||||
adapter.setMedia(m);
|
adapter.setMedia(m);
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class DbReaderTest {
|
||||||
assertNotNull(urls);
|
assertNotNull(urls);
|
||||||
assertEquals(feeds.size(), urls.size());
|
assertEquals(feeds.size(), urls.size());
|
||||||
for (int i = 0; i < urls.size(); i++) {
|
for (int i = 0; i < urls.size(); i++) {
|
||||||
assertEquals(urls.get(i), feeds.get(i).getDownload_url());
|
assertEquals(urls.get(i), feeds.get(i).getDownloadUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ public class DbReaderTest {
|
||||||
if (!downloaded.contains(items.get(i))) {
|
if (!downloaded.contains(items.get(i))) {
|
||||||
FeedItem item = items.get(i);
|
FeedItem item = items.get(i);
|
||||||
item.getMedia().setDownloaded(true);
|
item.getMedia().setDownloaded(true);
|
||||||
item.getMedia().setFile_url("file" + i);
|
item.getMedia().setLocalFileUrl("file" + i);
|
||||||
downloaded.add(item);
|
downloaded.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ public class DbReaderTest {
|
||||||
for (FeedItem item : downloadedSaved) {
|
for (FeedItem item : downloadedSaved) {
|
||||||
assertNotNull(item.getMedia());
|
assertNotNull(item.getMedia());
|
||||||
assertTrue(item.getMedia().isDownloaded());
|
assertTrue(item.getMedia().isDownloaded());
|
||||||
assertNotNull(item.getMedia().getDownload_url());
|
assertNotNull(item.getMedia().getDownloadUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ public class DbReaderTest {
|
||||||
List<Feed> feeds = saveFeedlist(1, 1, true);
|
List<Feed> feeds = saveFeedlist(1, 1, true);
|
||||||
FeedItem item1 = feeds.get(0).getItems().get(0);
|
FeedItem item1 = feeds.get(0).getItems().get(0);
|
||||||
FeedItem feedItemByEpisodeUrl = DBReader.getFeedItemByGuidOrEpisodeUrl(null,
|
FeedItem feedItemByEpisodeUrl = DBReader.getFeedItemByGuidOrEpisodeUrl(null,
|
||||||
item1.getMedia().getDownload_url());
|
item1.getMedia().getDownloadUrl());
|
||||||
assertEquals(item1.getItemIdentifier(), feedItemByEpisodeUrl.getItemIdentifier());
|
assertEquals(item1.getItemIdentifier(), feedItemByEpisodeUrl.getItemIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,7 +444,7 @@ public class DbReaderTest {
|
||||||
FeedItem item1 = feeds.get(0).getItems().get(0);
|
FeedItem item1 = feeds.get(0).getItems().get(0);
|
||||||
|
|
||||||
FeedItem feedItemByGuid = DBReader.getFeedItemByGuidOrEpisodeUrl(item1.getItemIdentifier(),
|
FeedItem feedItemByGuid = DBReader.getFeedItemByGuidOrEpisodeUrl(item1.getItemIdentifier(),
|
||||||
item1.getMedia().getDownload_url());
|
item1.getMedia().getDownloadUrl());
|
||||||
assertEquals(item1.getItemIdentifier(), feedItemByGuid.getItemIdentifier());
|
assertEquals(item1.getItemIdentifier(), feedItemByGuid.getItemIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ public class DbWriterTest {
|
||||||
assertNotNull(media);
|
assertNotNull(media);
|
||||||
assertFalse(dest.exists());
|
assertFalse(dest.exists());
|
||||||
assertFalse(media.isDownloaded());
|
assertFalse(media.isDownloaded());
|
||||||
assertNull(media.getFile_url());
|
assertNull(media.getLocalFileUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -197,7 +197,7 @@ public class DbWriterTest {
|
||||||
assertNotNull(media);
|
assertNotNull(media);
|
||||||
assertFalse(dest.exists());
|
assertFalse(dest.exists());
|
||||||
assertFalse(media.isDownloaded());
|
assertFalse(media.isDownloaded());
|
||||||
assertNull(media.getFile_url());
|
assertNull(media.getLocalFileUrl());
|
||||||
Awaitility.await().timeout(2, TimeUnit.SECONDS).until(() -> DBReader.getQueue().isEmpty());
|
Awaitility.await().timeout(2, TimeUnit.SECONDS).until(() -> DBReader.getQueue().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,8 +53,8 @@ public class FeedCursorMapperTest {
|
||||||
assertEquals("feed author", feed.getAuthor());
|
assertEquals("feed author", feed.getAuthor());
|
||||||
assertEquals("feed language", feed.getLanguage());
|
assertEquals("feed language", feed.getLanguage());
|
||||||
assertEquals("feed image url", feed.getImageUrl());
|
assertEquals("feed image url", feed.getImageUrl());
|
||||||
assertEquals("feed file url", feed.getFile_url());
|
assertEquals("feed file url", feed.getLocalFileUrl());
|
||||||
assertEquals("feed download url", feed.getDownload_url());
|
assertEquals("feed download url", feed.getDownloadUrl());
|
||||||
assertTrue(feed.isDownloaded());
|
assertTrue(feed.isDownloaded());
|
||||||
assertEquals("feed last update", feed.getLastModified());
|
assertEquals("feed last update", feed.getLastModified());
|
||||||
assertEquals("feed type", feed.getType());
|
assertEquals("feed type", feed.getType());
|
||||||
|
|
|
@ -133,7 +133,7 @@ public class Feed {
|
||||||
if (filter != null) {
|
if (filter != null) {
|
||||||
this.itemfilter = new FeedItemFilter(filter);
|
this.itemfilter = new FeedItemFilter(filter);
|
||||||
} else {
|
} else {
|
||||||
this.itemfilter = new FeedItemFilter(new String[0]);
|
this.itemfilter = new FeedItemFilter();
|
||||||
}
|
}
|
||||||
setSortOrder(sortOrder);
|
setSortOrder(sortOrder);
|
||||||
this.lastUpdateFailed = lastUpdateFailed;
|
this.lastUpdateFailed = lastUpdateFailed;
|
||||||
|
@ -455,22 +455,22 @@ public class Feed {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFile_url() {
|
public String getLocalFileUrl() {
|
||||||
return localFileUrl;
|
return localFileUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFile_url(String fileUrl) {
|
public void setLocalFileUrl(String fileUrl) {
|
||||||
this.localFileUrl = fileUrl;
|
this.localFileUrl = fileUrl;
|
||||||
if (fileUrl == null) {
|
if (fileUrl == null) {
|
||||||
downloaded = false;
|
downloaded = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDownload_url() {
|
public String getDownloadUrl() {
|
||||||
return downloadUrl;
|
return downloadUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDownload_url(String downloadUrl) {
|
public void setDownloadUrl(String downloadUrl) {
|
||||||
this.downloadUrl = downloadUrl;
|
this.downloadUrl = downloadUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,12 +511,6 @@ public class Feed {
|
||||||
return itemfilter;
|
return itemfilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItemFilter(String[] properties) {
|
|
||||||
if (properties != null) {
|
|
||||||
this.itemfilter = new FeedItemFilter(properties);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public SortOrder getSortOrder() {
|
public SortOrder getSortOrder() {
|
||||||
return sortOrder;
|
return sortOrder;
|
||||||
|
|
|
@ -182,8 +182,8 @@ public class FeedItem implements Serializable {
|
||||||
return itemIdentifier;
|
return itemIdentifier;
|
||||||
} else if (title != null && !title.isEmpty()) {
|
} else if (title != null && !title.isEmpty()) {
|
||||||
return title;
|
return title;
|
||||||
} else if (hasMedia() && media.getDownload_url() != null) {
|
} else if (hasMedia() && media.getDownloadUrl() != null) {
|
||||||
return media.getDownload_url();
|
return media.getDownloadUrl();
|
||||||
} else {
|
} else {
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,7 @@ public class FeedItem implements Serializable {
|
||||||
if (imageUrl != null) {
|
if (imageUrl != null) {
|
||||||
return imageUrl;
|
return imageUrl;
|
||||||
} else if (media != null && media.hasEmbeddedPicture()) {
|
} else if (media != null && media.hasEmbeddedPicture()) {
|
||||||
return FeedMedia.FILENAME_PREFIX_EMBEDDED_COVER + media.getLocalMediaUrl();
|
return FeedMedia.FILENAME_PREFIX_EMBEDDED_COVER + media.getLocalFileUrl();
|
||||||
} else if (feed != null) {
|
} else if (feed != null) {
|
||||||
return feed.getImageUrl();
|
return feed.getImageUrl();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -239,7 +239,7 @@ public class FeedMedia implements Playable {
|
||||||
return (CHECKED_ON_SIZE_BUT_UNKNOWN == this.size);
|
return (CHECKED_ON_SIZE_BUT_UNKNOWN == this.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMime_type() {
|
public String getMimeType() {
|
||||||
return mimeType;
|
return mimeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ public class FeedMedia implements Playable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLocalMediaUrl() {
|
public String getLocalFileUrl() {
|
||||||
return localFileUrl;
|
return localFileUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,6 +364,10 @@ public class FeedMedia implements Playable {
|
||||||
return downloadUrl;
|
return downloadUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDownloadUrl() {
|
||||||
|
return downloadUrl;
|
||||||
|
}
|
||||||
|
|
||||||
public int getStartPosition() {
|
public int getStartPosition() {
|
||||||
return startPosition;
|
return startPosition;
|
||||||
}
|
}
|
||||||
|
@ -402,18 +406,10 @@ public class FeedMedia implements Playable {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFile_url() {
|
|
||||||
return localFileUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDownloaded() {
|
public boolean isDownloaded() {
|
||||||
return downloaded;
|
return downloaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDownload_url() {
|
|
||||||
return downloadUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getItemId() {
|
public long getItemId() {
|
||||||
return itemID;
|
return itemID;
|
||||||
}
|
}
|
||||||
|
@ -470,7 +466,7 @@ public class FeedMedia implements Playable {
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
return item.getImageLocation();
|
return item.getImageLocation();
|
||||||
} else if (hasEmbeddedPicture()) {
|
} else if (hasEmbeddedPicture()) {
|
||||||
return FILENAME_PREFIX_EMBEDDED_COVER + getLocalMediaUrl();
|
return FILENAME_PREFIX_EMBEDDED_COVER + getLocalFileUrl();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -487,9 +483,9 @@ public class FeedMedia implements Playable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFile_url(String file_url) {
|
public void setLocalFileUrl(String fileUrl) {
|
||||||
this.localFileUrl = file_url;
|
this.localFileUrl = fileUrl;
|
||||||
if (file_url == null) {
|
if (fileUrl == null) {
|
||||||
downloaded = false;
|
downloaded = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -500,7 +496,7 @@ public class FeedMedia implements Playable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try (MediaMetadataRetrieverCompat mmr = new MediaMetadataRetrieverCompat()) {
|
try (MediaMetadataRetrieverCompat mmr = new MediaMetadataRetrieverCompat()) {
|
||||||
mmr.setDataSource(getLocalMediaUrl());
|
mmr.setDataSource(getLocalFileUrl());
|
||||||
byte[] image = mmr.getEmbeddedPicture();
|
byte[] image = mmr.getEmbeddedPicture();
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
hasEmbeddedPicture = Boolean.TRUE;
|
hasEmbeddedPicture = Boolean.TRUE;
|
||||||
|
|
|
@ -88,7 +88,7 @@ public interface Playable extends Parcelable, Serializable {
|
||||||
* Returns an url to a local file that can be played or null if this file
|
* Returns an url to a local file that can be played or null if this file
|
||||||
* does not exist.
|
* does not exist.
|
||||||
*/
|
*/
|
||||||
String getLocalMediaUrl();
|
String getLocalFileUrl();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an url to a file that can be streamed by the player or null if
|
* Returns an url to a file that can be streamed by the player or null if
|
||||||
|
|
|
@ -62,9 +62,9 @@ public class RemoteMedia implements Playable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public RemoteMedia(FeedItem item) {
|
public RemoteMedia(FeedItem item) {
|
||||||
this.downloadUrl = item.getMedia().getDownload_url();
|
this.downloadUrl = item.getMedia().getDownloadUrl();
|
||||||
this.itemIdentifier = item.getItemIdentifier();
|
this.itemIdentifier = item.getItemIdentifier();
|
||||||
this.feedUrl = item.getFeed().getDownload_url();
|
this.feedUrl = item.getFeed().getDownloadUrl();
|
||||||
this.feedTitle = item.getFeed().getTitle();
|
this.feedTitle = item.getFeed().getTitle();
|
||||||
this.episodeTitle = item.getTitle();
|
this.episodeTitle = item.getTitle();
|
||||||
this.episodeLink = item.getLink();
|
this.episodeLink = item.getLink();
|
||||||
|
@ -75,7 +75,7 @@ public class RemoteMedia implements Playable {
|
||||||
this.imageUrl = item.getFeed().getImageUrl();
|
this.imageUrl = item.getFeed().getImageUrl();
|
||||||
}
|
}
|
||||||
this.feedLink = item.getFeed().getLink();
|
this.feedLink = item.getFeed().getLink();
|
||||||
this.mimeType = item.getMedia().getMime_type();
|
this.mimeType = item.getMedia().getMimeType();
|
||||||
this.pubDate = item.getPubDate();
|
this.pubDate = item.getPubDate();
|
||||||
this.notes = item.getDescription();
|
this.notes = item.getDescription();
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ public class RemoteMedia implements Playable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLocalMediaUrl() {
|
public String getLocalFileUrl() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ public class RemoteMedia implements Playable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Feed feed = fi.getFeed();
|
Feed feed = fi.getFeed();
|
||||||
return feed != null && TextUtils.equals(feedUrl, feed.getDownload_url());
|
return feed != null && TextUtils.equals(feedUrl, feed.getDownloadUrl());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class DownloadRequestBuilder {
|
||||||
|
|
||||||
public DownloadRequestBuilder(@NonNull String destination, @NonNull FeedMedia media) {
|
public DownloadRequestBuilder(@NonNull String destination, @NonNull FeedMedia media) {
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
this.source = UrlChecker.prepareUrl(media.getDownload_url());
|
this.source = UrlChecker.prepareUrl(media.getDownloadUrl());
|
||||||
this.title = media.getHumanReadableIdentifier();
|
this.title = media.getHumanReadableIdentifier();
|
||||||
this.feedfileId = media.getId();
|
this.feedfileId = media.getId();
|
||||||
this.feedfileType = FeedMedia.FEEDFILETYPE_FEEDMEDIA;
|
this.feedfileType = FeedMedia.FEEDFILETYPE_FEEDMEDIA;
|
||||||
|
@ -29,7 +29,7 @@ public class DownloadRequestBuilder {
|
||||||
|
|
||||||
public DownloadRequestBuilder(@NonNull String destination, @NonNull Feed feed) {
|
public DownloadRequestBuilder(@NonNull String destination, @NonNull Feed feed) {
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
this.source = feed.isLocalFeed() ? feed.getDownload_url() : UrlChecker.prepareUrl(feed.getDownload_url());
|
this.source = feed.isLocalFeed() ? feed.getDownloadUrl() : UrlChecker.prepareUrl(feed.getDownloadUrl());
|
||||||
this.title = feed.getHumanReadableIdentifier();
|
this.title = feed.getHumanReadableIdentifier();
|
||||||
this.feedfileId = feed.getId();
|
this.feedfileId = feed.getId();
|
||||||
this.feedfileType = Feed.FEEDFILETYPE_FEED;
|
this.feedfileType = Feed.FEEDFILETYPE_FEED;
|
||||||
|
|
|
@ -239,7 +239,7 @@ public class EpisodeAction {
|
||||||
private String guid;
|
private String guid;
|
||||||
|
|
||||||
public Builder(FeedItem item, Action action) {
|
public Builder(FeedItem item, Action action) {
|
||||||
this(item.getFeed().getDownload_url(), item.getMedia().getDownload_url(), action);
|
this(item.getFeed().getDownloadUrl(), item.getMedia().getDownloadUrl(), action);
|
||||||
this.guid(item.getItemIdentifier());
|
this.guid(item.getItemIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class FeedHandler {
|
||||||
SAXParserFactory factory = SAXParserFactory.newInstance();
|
SAXParserFactory factory = SAXParserFactory.newInstance();
|
||||||
factory.setNamespaceAware(true);
|
factory.setNamespaceAware(true);
|
||||||
SAXParser saxParser = factory.newSAXParser();
|
SAXParser saxParser = factory.newSAXParser();
|
||||||
File file = new File(feed.getFile_url());
|
File file = new File(feed.getLocalFileUrl());
|
||||||
Reader inputStreamReader = new XmlStreamReader(file);
|
Reader inputStreamReader = new XmlStreamReader(file);
|
||||||
InputSource inputSource = new InputSource(inputStreamReader);
|
InputSource inputSource = new InputSource(inputStreamReader);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class TypeGetter {
|
||||||
|
|
||||||
public Type getType(Feed feed) throws UnsupportedFeedtypeException {
|
public Type getType(Feed feed) throws UnsupportedFeedtypeException {
|
||||||
XmlPullParserFactory factory;
|
XmlPullParserFactory factory;
|
||||||
if (feed.getFile_url() != null) {
|
if (feed.getLocalFileUrl() != null) {
|
||||||
Reader reader = null;
|
Reader reader = null;
|
||||||
try {
|
try {
|
||||||
factory = XmlPullParserFactory.newInstance();
|
factory = XmlPullParserFactory.newInstance();
|
||||||
|
@ -86,7 +86,7 @@ public class TypeGetter {
|
||||||
// XML document might actually be a HTML document -> try to parse as HTML
|
// XML document might actually be a HTML document -> try to parse as HTML
|
||||||
String rootElement = null;
|
String rootElement = null;
|
||||||
try {
|
try {
|
||||||
Jsoup.parse(new File(feed.getFile_url()));
|
Jsoup.parse(new File(feed.getLocalFileUrl()));
|
||||||
rootElement = "html";
|
rootElement = "html";
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
|
@ -112,7 +112,7 @@ public class TypeGetter {
|
||||||
private Reader createReader(Feed feed) {
|
private Reader createReader(Feed feed) {
|
||||||
Reader reader;
|
Reader reader;
|
||||||
try {
|
try {
|
||||||
reader = new XmlStreamReader(new File(feed.getFile_url()));
|
reader = new XmlStreamReader(new File(feed.getLocalFileUrl()));
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -47,9 +47,9 @@ public class AtomParserTest {
|
||||||
assertTrue(item.hasMedia());
|
assertTrue(item.hasMedia());
|
||||||
FeedMedia media = item.getMedia();
|
FeedMedia media = item.getMedia();
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
assertEquals("http://example.com/media-" + i, media.getDownload_url());
|
assertEquals("http://example.com/media-" + i, media.getDownloadUrl());
|
||||||
assertEquals(1024 * 1024, media.getSize());
|
assertEquals(1024 * 1024, media.getSize());
|
||||||
assertEquals("audio/mp3", media.getMime_type());
|
assertEquals("audio/mp3", media.getMimeType());
|
||||||
// chapters
|
// chapters
|
||||||
assertNull(item.getChapters());
|
assertNull(item.getChapters());
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public abstract class FeedParserTestHelper {
|
||||||
static Feed runFeedParser(@NonNull File feedFile) throws Exception {
|
static Feed runFeedParser(@NonNull File feedFile) throws Exception {
|
||||||
FeedHandler handler = new FeedHandler();
|
FeedHandler handler = new FeedHandler();
|
||||||
Feed parsedFeed = new Feed("http://example.com/feed", null);
|
Feed parsedFeed = new Feed("http://example.com/feed", null);
|
||||||
parsedFeed.setFile_url(feedFile.getAbsolutePath());
|
parsedFeed.setLocalFileUrl(feedFile.getAbsolutePath());
|
||||||
parsedFeed.setDownloaded(true);
|
parsedFeed.setDownloaded(true);
|
||||||
handler.parseFeed(parsedFeed);
|
handler.parseFeed(parsedFeed);
|
||||||
return parsedFeed;
|
return parsedFeed;
|
||||||
|
|
|
@ -48,9 +48,9 @@ public class RssParserTest {
|
||||||
assertTrue(item.hasMedia());
|
assertTrue(item.hasMedia());
|
||||||
FeedMedia media = item.getMedia();
|
FeedMedia media = item.getMedia();
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
assertEquals("http://example.com/media-" + i, media.getDownload_url());
|
assertEquals("http://example.com/media-" + i, media.getDownloadUrl());
|
||||||
assertEquals(1024 * 1024, media.getSize());
|
assertEquals(1024 * 1024, media.getSize());
|
||||||
assertEquals("audio/mp3", media.getMime_type());
|
assertEquals("audio/mp3", media.getMimeType());
|
||||||
// chapters
|
// chapters
|
||||||
assertNull(item.getChapters());
|
assertNull(item.getChapters());
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ public class RssParserTest {
|
||||||
FeedItem feedItem = feed.getItems().get(0);
|
FeedItem feedItem = feed.getItems().get(0);
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
assertEquals(MediaType.VIDEO, feedItem.getMedia().getMediaType());
|
assertEquals(MediaType.VIDEO, feedItem.getMedia().getMediaType());
|
||||||
assertEquals("https://www.example.com/file.mp4", feedItem.getMedia().getDownload_url());
|
assertEquals("https://www.example.com/file.mp4", feedItem.getMedia().getDownloadUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -132,7 +132,7 @@ public class CastUtils {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Feed feed = fi.getFeed();
|
Feed feed = fi.getFeed();
|
||||||
return feed != null && TextUtils.equals(metadata.getString(KEY_FEED_URL), feed.getDownload_url());
|
return feed != null && TextUtils.equals(metadata.getString(KEY_FEED_URL), feed.getDownloadUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -97,8 +97,8 @@ public class MediaInfoCreator {
|
||||||
if (!TextUtils.isEmpty(feed.getAuthor())) {
|
if (!TextUtils.isEmpty(feed.getAuthor())) {
|
||||||
metadata.putString(MediaMetadata.KEY_ARTIST, feed.getAuthor());
|
metadata.putString(MediaMetadata.KEY_ARTIST, feed.getAuthor());
|
||||||
}
|
}
|
||||||
if (!TextUtils.isEmpty(feed.getDownload_url())) {
|
if (!TextUtils.isEmpty(feed.getDownloadUrl())) {
|
||||||
metadata.putString(CastUtils.KEY_FEED_URL, feed.getDownload_url());
|
metadata.putString(CastUtils.KEY_FEED_URL, feed.getDownloadUrl());
|
||||||
}
|
}
|
||||||
if (!TextUtils.isEmpty(feed.getLink())) {
|
if (!TextUtils.isEmpty(feed.getLink())) {
|
||||||
metadata.putString(CastUtils.KEY_FEED_WEBSITE, feed.getLink());
|
metadata.putString(CastUtils.KEY_FEED_WEBSITE, feed.getLink());
|
||||||
|
@ -124,7 +124,7 @@ public class MediaInfoCreator {
|
||||||
metadata.putString(CastUtils.KEY_STREAM_URL, media.getStreamUrl());
|
metadata.putString(CastUtils.KEY_STREAM_URL, media.getStreamUrl());
|
||||||
|
|
||||||
MediaInfo.Builder builder = new MediaInfo.Builder(media.getStreamUrl())
|
MediaInfo.Builder builder = new MediaInfo.Builder(media.getStreamUrl())
|
||||||
.setContentType(media.getMime_type())
|
.setContentType(media.getMimeType())
|
||||||
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
|
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
|
||||||
.setMetadata(metadata);
|
.setMetadata(metadata);
|
||||||
if (media.getDuration() > 0) {
|
if (media.getDuration() > 0) {
|
||||||
|
|
|
@ -416,8 +416,8 @@ public class PodDBAdapter {
|
||||||
values.put(KEY_LANGUAGE, feed.getLanguage());
|
values.put(KEY_LANGUAGE, feed.getLanguage());
|
||||||
values.put(KEY_IMAGE_URL, feed.getImageUrl());
|
values.put(KEY_IMAGE_URL, feed.getImageUrl());
|
||||||
|
|
||||||
values.put(KEY_FILE_URL, feed.getFile_url());
|
values.put(KEY_FILE_URL, feed.getLocalFileUrl());
|
||||||
values.put(KEY_DOWNLOAD_URL, feed.getDownload_url());
|
values.put(KEY_DOWNLOAD_URL, feed.getDownloadUrl());
|
||||||
values.put(KEY_DOWNLOADED, feed.isDownloaded());
|
values.put(KEY_DOWNLOADED, feed.isDownloaded());
|
||||||
values.put(KEY_LASTUPDATE, feed.getLastModified());
|
values.put(KEY_LASTUPDATE, feed.getLastModified());
|
||||||
values.put(KEY_TYPE, feed.getType());
|
values.put(KEY_TYPE, feed.getType());
|
||||||
|
@ -493,10 +493,10 @@ public class PodDBAdapter {
|
||||||
values.put(KEY_DURATION, media.getDuration());
|
values.put(KEY_DURATION, media.getDuration());
|
||||||
values.put(KEY_POSITION, media.getPosition());
|
values.put(KEY_POSITION, media.getPosition());
|
||||||
values.put(KEY_SIZE, media.getSize());
|
values.put(KEY_SIZE, media.getSize());
|
||||||
values.put(KEY_MIME_TYPE, media.getMime_type());
|
values.put(KEY_MIME_TYPE, media.getMimeType());
|
||||||
values.put(KEY_DOWNLOAD_URL, media.getDownload_url());
|
values.put(KEY_DOWNLOAD_URL, media.getDownloadUrl());
|
||||||
values.put(KEY_DOWNLOADED, media.isDownloaded());
|
values.put(KEY_DOWNLOADED, media.isDownloaded());
|
||||||
values.put(KEY_FILE_URL, media.getFile_url());
|
values.put(KEY_FILE_URL, media.getLocalFileUrl());
|
||||||
values.put(KEY_HAS_EMBEDDED_PICTURE, media.hasEmbeddedPicture());
|
values.put(KEY_HAS_EMBEDDED_PICTURE, media.hasEmbeddedPicture());
|
||||||
values.put(KEY_LAST_PLAYED_TIME, media.getLastPlayedTime());
|
values.put(KEY_LAST_PLAYED_TIME, media.getLastPlayedTime());
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class FavoritesWriter {
|
||||||
.replace("{FEED_IMG}", feed.getImageUrl())
|
.replace("{FEED_IMG}", feed.getImageUrl())
|
||||||
.replace("{FEED_TITLE}", feed.getTitle())
|
.replace("{FEED_TITLE}", feed.getTitle())
|
||||||
.replace("{FEED_LINK}", feed.getLink())
|
.replace("{FEED_LINK}", feed.getLink())
|
||||||
.replace("{FEED_WEBSITE}", feed.getDownload_url());
|
.replace("{FEED_WEBSITE}", feed.getDownloadUrl());
|
||||||
|
|
||||||
writer.append(feedInfo);
|
writer.append(feedInfo);
|
||||||
}
|
}
|
||||||
|
@ -99,8 +99,8 @@ public class FavoritesWriter {
|
||||||
} else {
|
} else {
|
||||||
favItem = favItem.replace("{FAV_WEBSITE}", "");
|
favItem = favItem.replace("{FAV_WEBSITE}", "");
|
||||||
}
|
}
|
||||||
if (item.getMedia() != null && item.getMedia().getDownload_url() != null) {
|
if (item.getMedia() != null && item.getMedia().getDownloadUrl() != null) {
|
||||||
favItem = favItem.replace("{FAV_MEDIA}", item.getMedia().getDownload_url());
|
favItem = favItem.replace("{FAV_MEDIA}", item.getMedia().getDownloadUrl());
|
||||||
} else {
|
} else {
|
||||||
favItem = favItem.replace("{FAV_MEDIA}", "");
|
favItem = favItem.replace("{FAV_MEDIA}", "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class HtmlWriter {
|
||||||
writer.append(" <span><a href=\"");
|
writer.append(" <span><a href=\"");
|
||||||
writer.append(feed.getLink());
|
writer.append(feed.getLink());
|
||||||
writer.append("\">Website</a> • <a href=\"");
|
writer.append("\">Website</a> • <a href=\"");
|
||||||
writer.append(feed.getDownload_url());
|
writer.append(feed.getDownloadUrl());
|
||||||
writer.append("\">Feed</a></span></p></div></li>\n");
|
writer.append("\">Feed</a></span></p></div></li>\n");
|
||||||
}
|
}
|
||||||
writer.append(templateParts[1]);
|
writer.append(templateParts[1]);
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class OpmlWriter {
|
||||||
if (feed.getType() != null) {
|
if (feed.getType() != null) {
|
||||||
xs.attribute(null, OpmlSymbols.TYPE, feed.getType());
|
xs.attribute(null, OpmlSymbols.TYPE, feed.getType());
|
||||||
}
|
}
|
||||||
xs.attribute(null, OpmlSymbols.XMLURL, feed.getDownload_url());
|
xs.attribute(null, OpmlSymbols.XMLURL, feed.getDownloadUrl());
|
||||||
if (feed.getLink() != null) {
|
if (feed.getLink() != null) {
|
||||||
xs.attribute(null, OpmlSymbols.HTMLURL, feed.getLink());
|
xs.attribute(null, OpmlSymbols.HTMLURL, feed.getLink());
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ public final class ChapterImageModelLoader implements ModelLoader<EmbeddedChapte
|
||||||
Uri uri = Uri.parse(image.getMedia().getStreamUrl());
|
Uri uri = Uri.parse(image.getMedia().getStreamUrl());
|
||||||
stream = new BufferedInputStream(context.getContentResolver().openInputStream(uri));
|
stream = new BufferedInputStream(context.getContentResolver().openInputStream(uri));
|
||||||
} else {
|
} else {
|
||||||
File localFile = new File(image.getMedia().getLocalMediaUrl());
|
File localFile = new File(image.getMedia().getLocalFileUrl());
|
||||||
stream = new BufferedInputStream(new FileInputStream(localFile));
|
stream = new BufferedInputStream(new FileInputStream(localFile));
|
||||||
}
|
}
|
||||||
IOUtils.skip(stream, image.getPosition());
|
IOUtils.skip(stream, image.getPosition());
|
||||||
|
|
Loading…
Reference in New Issue