summaryrefslogtreecommitdiffstats
path: root/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java
diff options
context:
space:
mode:
authorSteve McKay <smckay@google.com>2015-04-30 16:12:59 -0700
committerSteve McKay <smckay@google.com>2015-05-04 16:21:09 +0000
commit69aee097a3853490c9c7afb191af4f047ab1d164 (patch)
tree83feb8f2f270e369b93c0f3fc371e0d11abadc08 /packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java
parent340b198ccbd1a05e67d586c345139617d4b84ce0 (diff)
downloadframeworks_base-69aee097a3853490c9c7afb191af4f047ab1d164.zip
frameworks_base-69aee097a3853490c9c7afb191af4f047ab1d164.tar.gz
frameworks_base-69aee097a3853490c9c7afb191af4f047ab1d164.tar.bz2
Ensure sort menu is shown as needed.
This also hoists common code for options menu setup into BaseActivity. Change-Id: Ie87b8188a6c142b2312c92dc0d0bd550f0b1e59f
Diffstat (limited to 'packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java')
-rw-r--r--packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java b/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java
index e0f10fa..cb21131 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java
@@ -101,6 +101,41 @@ abstract class BaseActivity extends Activity {
return showMenu;
}
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ boolean shown = super.onPrepareOptionsMenu(menu);
+
+ final RootInfo root = getCurrentRoot();
+ final DocumentInfo cwd = getCurrentDirectory();
+
+ final MenuItem sort = menu.findItem(R.id.menu_sort);
+ final MenuItem sortSize = menu.findItem(R.id.menu_sort_size);
+ final MenuItem grid = menu.findItem(R.id.menu_grid);
+ final MenuItem list = menu.findItem(R.id.menu_list);
+
+ final MenuItem advanced = menu.findItem(R.id.menu_advanced);
+ final MenuItem fileSize = menu.findItem(R.id.menu_file_size);
+
+ mSearchManager.update(root);
+
+ // Search uses backend ranking; no sorting
+ sort.setVisible(cwd != null && !mSearchManager.isSearching());
+
+ State state = getDisplayState();
+ grid.setVisible(state.derivedMode != State.MODE_GRID);
+ list.setVisible(state.derivedMode != State.MODE_LIST);
+
+ // Only sort by size when visible
+ sortSize.setVisible(state.showSize);
+
+ advanced.setTitle(LocalPreferences.getDisplayAdvancedDevices(this)
+ ? R.string.menu_advanced_hide : R.string.menu_advanced_show);
+ fileSize.setTitle(LocalPreferences.getDisplayFileSize(this)
+ ? R.string.menu_file_size_hide : R.string.menu_file_size_show);
+
+ return shown;
+ }
+
void onStackRestored(boolean restored, boolean external) {}
void onRootPicked(RootInfo root) {