[Android] Allow subtitles download for remote videos
Geoffrey Métais
git at videolan.org
Fri May 20 16:30:59 CEST 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri May 20 16:30:14 2016 +0200| [b9f214c917481056b0c7341c65a278bac7ca8771] | committer: Geoffrey Métais
Allow subtitles download for remote videos
> https://code.videolan.org/videolan/vlc-android/commit/b9f214c917481056b0c7341c65a278bac7ca8771
---
.../org/videolan/vlc/gui/browser/BaseBrowserFragment.java | 2 +-
.../src/org/videolan/vlc/util/SubtitlesDownloader.java | 15 +++++----------
2 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
index 3cd0005..3ab5019 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -452,7 +452,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
menu.findItem(R.id.directory_view_info).setVisible(type == MediaWrapper.TYPE_VIDEO || type == MediaWrapper.TYPE_AUDIO);
menu.findItem(R.id.directory_view_play_audio).setVisible(type != MediaWrapper.TYPE_AUDIO);
menu.findItem(R.id.directory_view_add_playlist).setVisible(type == MediaWrapper.TYPE_AUDIO);
- menu.findItem(R.id.directory_subtitles_download).setVisible(type == MediaWrapper.TYPE_VIDEO && canWrite);
+ menu.findItem(R.id.directory_subtitles_download).setVisible(type == MediaWrapper.TYPE_VIDEO);
}
}
diff --git a/vlc-android/src/org/videolan/vlc/util/SubtitlesDownloader.java b/vlc-android/src/org/videolan/vlc/util/SubtitlesDownloader.java
index c4c8caf..694b0ec 100644
--- a/vlc-android/src/org/videolan/vlc/util/SubtitlesDownloader.java
+++ b/vlc-android/src/org/videolan/vlc/util/SubtitlesDownloader.java
@@ -297,17 +297,12 @@ public class SubtitlesDownloader {
if (mToken == null || path == null)
return;
- final File parent = new File(path).getParentFile();
- boolean canWrite = !path.startsWith("smb://") && !path.startsWith("http://") && parent != null && parent.canWrite();
- String fileUrl;
+ boolean canWrite = FileUtils.canWrite(path);
StringBuilder sb = new StringBuilder();
- if (canWrite){
- fileUrl = path;
- sb.append(fileUrl.substring(0,fileUrl.lastIndexOf('.')+1)).append(language).append('.').append(subFormat);
- } else{
- fileUrl = name;
- sb.append(VLCApplication.getAppContext().getFilesDir().getPath()).append('/').append(fileUrl).append('.').append(language).append('.').append(subFormat);
- }
+ if (canWrite)
+ sb.append(path.substring(0,path.lastIndexOf('.')+1)).append(language).append('.').append(subFormat);
+ else
+ sb.append(FileUtils.SUBTITLES_DIRECTORY.getPath()).append('/').append(name).append('.').append(language).append('.').append(subFormat);
String srtURl = sb.toString();
FileOutputStream f = null;
InputStream in = null;
More information about the Android
mailing list