Commit 41dc902b authored by Geoffrey Métais's avatar Geoffrey Métais

Pass subs path in extra and fix subspicker adapter

parent 240ae27e
......@@ -23,8 +23,6 @@
package org.videolan.vlc.gui.browser;
import android.view.View;
import org.videolan.medialibrary.media.MediaLibraryItem;
import org.videolan.medialibrary.media.MediaWrapper;
......@@ -56,12 +54,4 @@ public class FilePickerAdapter extends BaseBrowserAdapter {
private boolean filter(MediaWrapper mediaWrapper) {
return mediaWrapper.getType() == MediaWrapper.TYPE_DIR || mediaWrapper.getType() == MediaWrapper.TYPE_SUBTITLE;
}
protected void openMediaFromView(MediaViewHolder holder, View v) {
final MediaWrapper media = (MediaWrapper) getItem(holder.getAdapterPosition());
if (media.getType() == MediaWrapper.TYPE_DIR)
fragment.browse(media, holder.getAdapterPosition(), true);
else
((FilePickerFragment)fragment).pickFile(media);
}
}
......@@ -32,8 +32,9 @@ import android.text.TextUtils;
import android.view.View;
import org.videolan.libvlc.util.MediaBrowser;
import org.videolan.vlc.R;
import org.videolan.medialibrary.media.MediaLibraryItem;
import org.videolan.medialibrary.media.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.FileUtils;
import org.videolan.vlc.util.Strings;
......@@ -41,6 +42,8 @@ import org.videolan.vlc.util.VLCInstance;
public class FilePickerFragment extends FileBrowserFragment {
public static final String EXTRA_MRL = "sub_mrl";
private static String[] rootDirectories = AndroidDevices.getMediaDirectories();
@Override
......@@ -77,8 +80,18 @@ public class FilePickerFragment extends FileBrowserFragment {
getActivity().setTitle(getTitle());
}
public void onClick(View v, int position, MediaLibraryItem item) {
final MediaWrapper media = (MediaWrapper) item;
if (media.getType() == MediaWrapper.TYPE_DIR)
browse(media, position, true);
else
pickFile(media);
}
void pickFile(MediaWrapper mw){
getActivity().setResult(Activity.RESULT_OK, new Intent(Intent.ACTION_PICK, mw.getUri()));
Intent i = new Intent(Intent.ACTION_PICK);
i.putExtra(EXTRA_MRL, mw.getLocation());
getActivity().setResult(Activity.RESULT_OK, i);
getActivity().finish();
}
......
......@@ -112,6 +112,7 @@ import org.videolan.vlc.gui.MainActivity;
import org.videolan.vlc.gui.PlaybackServiceActivity;
import org.videolan.vlc.gui.audio.PlaylistAdapter;
import org.videolan.vlc.gui.browser.FilePickerActivity;
import org.videolan.vlc.gui.browser.FilePickerFragment;
import org.videolan.vlc.gui.dialogs.AdvOptionsDialog;
import org.videolan.vlc.gui.helpers.OnRepeatListener;
import org.videolan.vlc.gui.helpers.SwipeDragItemTouchHelperCallback;
......@@ -945,17 +946,16 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
if(data == null) return;
if(data.getData() == null)
Log.d(TAG, "Subtitle selection dialog was cancelled");
else {
mService.addSubtitleTrack(data.getData(), true);
if(data.hasExtra(FilePickerFragment.EXTRA_MRL)) {
mService.addSubtitleTrack(Uri.parse(data.getStringExtra(FilePickerFragment.EXTRA_MRL)), true);
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
MediaDatabase.getInstance().saveSlave(mService.getCurrentMediaLocation(), Media.Slave.Type.Subtitle, 2, data.getDataString());
MediaDatabase.getInstance().saveSlave(mService.getCurrentMediaLocation(), Media.Slave.Type.Subtitle, 2, data.getStringExtra(FilePickerFragment.EXTRA_MRL));
}
});
}
} else
Log.d(TAG, "Subtitle selection dialog was cancelled");
}
public static void start(Context context, Uri uri) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment