From ada31cf4b70b6011931ad05a5d3a6e0356a4cf23 Mon Sep 17 00:00:00 2001 From: David Development Date: Wed, 20 Jan 2016 17:39:22 +0100 Subject: [PATCH] Fix app crash for cached images --- .../NewsDetailImageDialogFragment.java | 57 +++++++++++-------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsDetailImageDialogFragment.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsDetailImageDialogFragment.java index 31a25052..b36e11a5 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsDetailImageDialogFragment.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsDetailImageDialogFragment.java @@ -98,31 +98,38 @@ public class NewsDetailImageDialogFragment extends DialogFragment { //Build the menu switch(mDialogType) { case IMAGE: - mMenuItems.put(getString(R.string.action_img_download), new MenuActionLongClick() { - @Override - public void execute() { - downloadImage(mImageUrl); - } - public void executeLongClick() { changeDownloadDir(); } - }); - mMenuItems.put(getString(R.string.action_img_open), new MenuAction() { - @Override - public void execute() { - openLinkInBrowser(mImageUrl); - } - }); - mMenuItems.put(getString(R.string.action_img_sharelink), new MenuAction() { - @Override - public void execute() { - shareImage(); - } - }); - mMenuItems.put(getString(R.string.action_img_copylink), new MenuAction() { - @Override - public void execute() { - copyToClipboard(mDialogTitle, mImageUrl.toString()); - } - }); + if(mImageUrl.toString().startsWith("http")) { //Only allow download for http[s] images (prevent download of cached images) + mMenuItems.put(getString(R.string.action_img_download), new MenuActionLongClick() { + @Override + public void execute() { + downloadImage(mImageUrl); + } + + public void executeLongClick() { + changeDownloadDir(); + } + }); + mMenuItems.put(getString(R.string.action_img_open), new MenuAction() { + @Override + public void execute() { + openLinkInBrowser(mImageUrl); + } + }); + mMenuItems.put(getString(R.string.action_img_sharelink), new MenuAction() { + @Override + public void execute() { + shareImage(); + } + }); + mMenuItems.put(getString(R.string.action_img_copylink), new MenuAction() { + @Override + public void execute() { + copyToClipboard(mDialogTitle, mImageUrl.toString()); + } + }); + } else { + mDialogTitle = "Cached image"; + } break; case URL: mMenuItems.put(getString(R.string.action_link_open), new MenuAction() {