Commit 67155168 authored by Alexandre Perraud's avatar Alexandre Perraud Committed by Ludovic Fauvet

Directory View : back pressed action shows a parent

Signed-off-by: Ludovic Fauvet's avatarLudovic Fauvet <etix@videolan.org>
parent 2e34e4c1
......@@ -285,14 +285,19 @@ public class DirectoryAdapter extends BaseAdapter {
return v;
}
public Boolean browse(int position) {
public boolean browse(int position) {
DirectoryAdapter.Node selectedNode = mCurrentNode.children.get(position);
if(selectedNode.isFile()) return false;
return browse(selectedNode.name);
}
public boolean browse(String directoryName) {
try {
this.mCurrentDir = new URI(LibVLC.getExistingInstance().nativeToURI(this.mCurrentDir + "/" + selectedNode.name)).normalize().getPath();
this.mCurrentDir = new URI(LibVLC.getExistingInstance().nativeToURI(this.mCurrentDir + "/" + directoryName)).normalize().getPath();
this.mCurrentDir = Util.stripTrailingSlash(this.mCurrentDir);
} catch (URISyntaxException e) {
/* blah blah blah blah blah */
e.printStackTrace();
return false;
}
Log.d(TAG, "Browsing to " + this.mCurrentDir);
......@@ -318,6 +323,14 @@ public class DirectoryAdapter extends BaseAdapter {
);
}
public String getmRootDir() {
return mRootDir;
}
public String getmCurrentDir() {
return mCurrentDir;
}
public ArrayList<String> getAllMediaLocations() {
ArrayList<String> a = new ArrayList<String>();
// i = 1 to exclude ".." folder
......
......@@ -144,6 +144,17 @@ public class DirectoryViewFragment extends SherlockListFragment implements ISort
}
}
public boolean isRootDirectory () {
if (mDirectoryAdapter.getmCurrentDir().equals(mDirectoryAdapter.getmRootDir())) {
return true;
}
return false;
};
public void showParentDirectory() {
mDirectoryAdapter.browse("..");
};
private void openMediaFile(int p) {
AudioServiceController audioController = AudioServiceController.getInstance();
String mediaFile = mDirectoryAdapter.getMediaLocation(p);
......
......@@ -358,9 +358,17 @@ public class MainActivity extends SherlockFragmentActivity {
if(mMenu.isBehindShowing()) {
/* Close the menu first */
mMenu.showAbove();
} else {
super.onBackPressed();
return;
}
// If it's the directory view, a "backpressed" action shows a parent.
if (mCurrentFragment.equals("directories")) {
DirectoryViewFragment directoryView = (DirectoryViewFragment) getFragment(mCurrentFragment);
if (!directoryView.isRootDirectory()) {
directoryView.showParentDirectory();
return;
}
}
super.onBackPressed();
}
private Fragment getFragment(String id)
......
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