[Android] Fix browsing to root in subtitles picker
Geoffrey Métais
git at videolan.org
Fri Nov 17 18:25:23 CET 2017
vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Nov 17 16:18:26 2017 +0100| [caf77bad309ce9492e03791a3d08e90c8922eeda] | committer: Geoffrey Métais
Fix browsing to root in subtitles picker
Close #420
(cherry picked from commit 23e94289cff477fda9584435d6415431bae6ed75)
> https://code.videolan.org/videolan/vlc-android/commit/caf77bad309ce9492e03791a3d08e90c8922eeda
---
.../vlc/gui/browser/FileBrowserFragment.java | 21 +++++++++++++++++----
.../vlc/gui/browser/FilePickerActivity.java | 5 ++---
.../vlc/gui/browser/FilePickerFragment.java | 2 +-
3 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java
index 59f4464cc..0c1d9265f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java
@@ -28,6 +28,7 @@ import android.content.DialogInterface;
import android.net.Uri;
import android.os.Environment;
import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.AppCompatEditText;
import android.text.InputType;
@@ -85,30 +86,42 @@ public class FileBrowserFragment extends BaseBrowserFragment {
@Override
protected void browseRoot() {
+ mMrl = null;
+ final FragmentActivity activity = getActivity();
+ if (activity == null) return;
+ activity.setTitle(R.string.directories);
+ final String internalmemoryTitle = getString(R.string.internal_memory);
+ final String browserStorage = getString(R.string.browser_storages);
+ final String quickAccess = getString(R.string.browser_quick_access);
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
final String storages[] = AndroidDevices.getMediaDirectories();
MediaWrapper directory;
final ArrayList<MediaLibraryItem> devices = new ArrayList<>(storages.length);
- devices.add(new DummyItem(getString(R.string.browser_storages)));
+ final boolean isFilePicker = FileBrowserFragment.this instanceof FilePickerFragment;
+ if (!isFilePicker) {
+ devices.add(new DummyItem(browserStorage));
+ }
for (String mediaDirLocation : storages) {
if (!(new File(mediaDirLocation).exists()))
continue;
directory = new MediaWrapper(AndroidUtil.PathToUri(mediaDirLocation));
directory.setType(MediaWrapper.TYPE_DIR);
if (TextUtils.equals(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY, mediaDirLocation))
- directory.setDisplayTitle(VLCApplication.getAppResources().getString(R.string.internal_memory));
+ directory.setDisplayTitle(internalmemoryTitle);
devices.add(directory);
}
// Set folders shortcuts
- devices.add(new DummyItem(getString(R.string.browser_quick_access)));
+ if (!isFilePicker) {
+ devices.add(new DummyItem(quickAccess));
+ }
if (AndroidDevices.MediaFolders.EXTERNAL_PUBLIC_MOVIES_DIRECTORY_FILE.exists()) {
final MediaWrapper movies = new MediaWrapper(AndroidDevices.MediaFolders.EXTERNAL_PUBLIC_MOVIES_DIRECTORY_URI);
movies.setType(MediaWrapper.TYPE_DIR);
devices.add(movies);
}
- if (!(FileBrowserFragment.this instanceof FilePickerFragment)) {
+ if (!isFilePicker) {
if (AndroidDevices.MediaFolders.EXTERNAL_PUBLIC_MUSIC_DIRECTORY_FILE.exists()) {
final MediaWrapper music = new MediaWrapper(AndroidDevices.MediaFolders.EXTERNAL_PUBLIC_MUSIC_DIRECTORY_URI);
music.setType(MediaWrapper.TYPE_DIR);
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerActivity.java b/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerActivity.java
index 9c8e40c02..7f0180995 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerActivity.java
@@ -37,14 +37,14 @@ public class FilePickerActivity extends AppCompatActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.file_picker_activity);
- FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
+ final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.fragment_placeholder, new FilePickerFragment(), "picker");
ft.commit();
}
@Override
public void onBackPressed() {
- FilePickerFragment fpf = ((FilePickerFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_placeholder));
+ final FilePickerFragment fpf = ((FilePickerFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_placeholder));
if (fpf.isRootDirectory())
finish();
else if (getSupportFragmentManager().getBackStackEntryCount() > 0)
@@ -55,6 +55,5 @@ public class FilePickerActivity extends AppCompatActivity {
public void onHomeClick(View v) {
((FilePickerFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_placeholder)).browseRoot();
- setTitle(R.string.directories);
}
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.java
index f9bdddc51..6c51d7859 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.java
@@ -110,7 +110,7 @@ public class FilePickerFragment extends FileBrowserFragment {
mRoot = true;
mAdapter.clear();
browseRoot();
- } else {
+ } else if (mMrl != null) {
MediaWrapper mw = new MediaWrapper(Uri.parse(FileUtils.getParent(mMrl)));
browse(mw, 0, false);
}
More information about the Android
mailing list