add option to jump to the filebrowser home directory
This commit is contained in:
parent
ffb70b40b1
commit
cf75c40c2c
@ -79,6 +79,7 @@ THE SOFTWARE.
|
||||
<string name="remove">Remove</string>
|
||||
<string name="play_or_enqueue">Enqueue if playing; Play if paused</string>
|
||||
<string name="open">Open</string>
|
||||
<string name="go_home">Home directory</string>
|
||||
|
||||
<plurals name="playing">
|
||||
<item quantity="one">1 track playing.</item>
|
||||
|
@ -133,7 +133,7 @@ public class FileSystemAdapter
|
||||
mFolderIcon = activity.getResources().getDrawable(R.drawable.folder);
|
||||
mInflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
if (limiter == null) {
|
||||
limiter = buildLimiter( FileUtils.getFilesystemBrowseStart(activity) );
|
||||
limiter = buildHomeLimiter(activity);
|
||||
}
|
||||
setLimiter(limiter);
|
||||
}
|
||||
@ -252,6 +252,16 @@ public class FileSystemAdapter
|
||||
return new Limiter(MediaUtils.TYPE_FILE, fields, file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the limiter pointing to our home directory
|
||||
*
|
||||
* @param context the context to use
|
||||
* @return A limiter which is configured as 'home' directory
|
||||
*/
|
||||
public static Limiter buildHomeLimiter(Context context) {
|
||||
return buildLimiter(FileUtils.getFilesystemBrowseStart(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Limiter buildLimiter(long id)
|
||||
{
|
||||
|
@ -828,6 +828,7 @@ public class LibraryActivity
|
||||
super.onCreateOptionsMenu(menu);
|
||||
menu.add(0, MENU_PLAYBACK, 0, R.string.playback_view);
|
||||
menu.add(0, MENU_SEARCH, 0, R.string.search).setIcon(R.drawable.ic_menu_search).setVisible(false);
|
||||
menu.add(0, MENU_GO_HOME, 30, R.string.go_home);
|
||||
menu.add(0, MENU_SORT, 30, R.string.sort_by).setIcon(R.drawable.ic_menu_sort_alphabetically);
|
||||
return true;
|
||||
}
|
||||
@ -836,7 +837,9 @@ public class LibraryActivity
|
||||
public boolean onPrepareOptionsMenu(Menu menu)
|
||||
{
|
||||
LibraryAdapter adapter = mCurrentAdapter;
|
||||
menu.findItem(MENU_SORT).setEnabled(adapter != null && adapter.getMediaType() != MediaUtils.TYPE_FILE);
|
||||
boolean isLibraryAdapter = (adapter != null && adapter.getMediaType() != MediaUtils.TYPE_FILE);
|
||||
menu.findItem(MENU_GO_HOME).setVisible(!isLibraryAdapter);
|
||||
menu.findItem(MENU_SORT).setEnabled(isLibraryAdapter);
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@ -846,10 +849,14 @@ public class LibraryActivity
|
||||
switch (item.getItemId()) {
|
||||
case MENU_SEARCH:
|
||||
mBottomBarControls.showSearch(true);
|
||||
return true;
|
||||
break;
|
||||
case MENU_PLAYBACK:
|
||||
openPlaybackActivity();
|
||||
return true;
|
||||
break;
|
||||
case MENU_GO_HOME:
|
||||
mPagerAdapter.setLimiter(FileSystemAdapter.buildHomeLimiter(getApplicationContext()));
|
||||
updateLimiterViews();
|
||||
break;
|
||||
case MENU_SORT: {
|
||||
MediaAdapter adapter = (MediaAdapter)mCurrentAdapter;
|
||||
LinearLayout header = (LinearLayout)getLayoutInflater().inflate(R.layout.sort_dialog, null);
|
||||
@ -877,11 +884,12 @@ public class LibraryActivity
|
||||
dialog.getListView().addHeaderView(header);
|
||||
dialog.setOnDismissListener(this);
|
||||
dialog.show();
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -375,6 +375,7 @@ public abstract class PlaybackActivity extends Activity
|
||||
static final int MENU_EMPTY_QUEUE = 16;
|
||||
static final int MENU_ADD_TO_PLAYLIST = 17;
|
||||
static final int MENU_SHARE = 18;
|
||||
static final int MENU_GO_HOME= 19;
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu)
|
||||
|
Loading…
x
Reference in New Issue
Block a user