Commit a741d065 authored by Sébastien Toque's avatar Sébastien Toque
Browse files

Add a setting to change the root folder

parent cb9a40f6
......@@ -2,7 +2,7 @@
<string name="hello">Hello World, VLC!</string>
<string name="filebrowser_sdfail">Impossible de lire la Carte SD. Veuillez vérifier qu\'elle est montée correctement.</string>
<string name="filebrowser_root">&lt;racine&gt;</string>
<string name="filebrowser_root">Racine</string>
<string name="filebrowser_parent">..</string>
<string name="filebrowser_title">Sélection des médias</string>
<string name="preferences">Préférences</string>
......@@ -2,7 +2,7 @@
<string name="hello">Ciao Mondo, vlc!</string>
<string name="filebrowser_sdfail">Impossibile aprire la scheda SD. Si prega di controllare che sia montata correttamente.</string>
<string name="filebrowser_root">&lt;root&gt;</string>
<string name="filebrowser_root">Root</string>
<string name="filebrowser_parent">..</string>
<string name="filebrowser_title">Seleziona media da riprodurre</string>
<string name="preferences">Preferenze</string>
......@@ -3,7 +3,7 @@
<string name="hello">Hello World, vlc!</string>
<string name="app_name" translatable="false">VLC media player</string>
<string name="filebrowser_sdfail">Unable to open SD card. Please check it is mounted correctly.</string>
<string name="filebrowser_root">&lt;root&gt;</string>
<string name="filebrowser_root">Root</string>
<string name="filebrowser_parent">..</string>
<string name="filebrowser_title">Select media to play</string>
<string name="preferences">Preferences</string>
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="">
<PreferenceCategory android:title="@string/mediafiles">
......@@ -5,7 +5,9 @@ import;
import java.util.Stack;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ListView;
......@@ -20,6 +22,7 @@ public class BrowserActivity extends ListActivity {
private BrowserAdapter mAdapter;
private File mCurrentDir;
private Stack<ScrollState> mScollStates = new Stack<ScrollState>();
private String mRoot;
private class ScrollState {
public ScrollState(int index, int top) {
......@@ -38,7 +41,17 @@ public class BrowserActivity extends ListActivity {
mAdapter = new BrowserAdapter(this, R.layout.browser_item);
openDir(new File("/"));
//get the root from the settings
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
mRoot = pref.getString("directories_root", "/");
//Make sure the path is valid, use "/" if it is not
File file = new File(mRoot);
if (!file.exists())
file = new File("/");
mRoot = file.getPath();
private void openDir(File file) {
......@@ -71,7 +84,7 @@ public class BrowserActivity extends ListActivity {
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (mCurrentDir.getPath().equals("/")) {
if (mCurrentDir.getPath().equals(mRoot)) {
return super.onKeyDown(keyCode, event);
} else {
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