[Android] BrowserActivity: verify against adding invalid directories

Edward Wang git at videolan.org
Thu Aug 21 16:59:02 CEST 2014


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Thu Aug 21 10:58:14 2014 -0400| [17005dc84b7b8362a238b62449c1387b8c9468c0] | committer: Edward Wang

BrowserActivity: verify against adding invalid directories

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=17005dc84b7b8362a238b62449c1387b8c9468c0
---

 vlc-android/res/values/strings.xml                        |    1 +
 vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java |   10 +++++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index cd02aab..7ac8601 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -86,6 +86,7 @@
     <string name="mediafiles">Media files</string>
     <string name="notavailable">not available</string>
     <string name="nosubdirectory">No subdirectories.</string>
+    <string name="directorynotfound">The directory path \'%1$s\' was not found.</string>
     <string name="nohistory">You have no playback history yet.</string>
     <string name="validation">Are you sure?</string>
 
diff --git a/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java b/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java
index 8a33357..018ec33 100644
--- a/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java
@@ -51,6 +51,7 @@ import android.view.View;
 import android.widget.AdapterView.AdapterContextMenuInfo;
 import android.widget.EditText;
 import android.widget.ListView;
+import android.widget.Toast;
 
 public class BrowserActivity extends ListActivity {
     public final static String TAG = "VLC/BrowserActivity";
@@ -192,7 +193,14 @@ public class BrowserActivity extends ListActivity {
             b.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialog, int which) {
-                    CustomDirectories.addCustomDirectory(input.getText().toString());
+                    String path = input.getText().toString().trim();
+                    File f = new File(path);
+                    if(!f.exists() || !f.isDirectory()) {
+                        Toast.makeText(BrowserActivity.this, getString(R.string.directorynotfound, path), Toast.LENGTH_SHORT).show();
+                        return;
+                    }
+
+                    CustomDirectories.addCustomDirectory(f.getAbsolutePath());
                     refresh();
                 }
             });



More information about the Android mailing list