Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5bbae10c authored by Steve McKay's avatar Steve McKay
Browse files

Normalize and improve menu fiddling.

Also, don't show copy/paste menu items (though they can still be invoked via keyboard).
Show copy to /move to instead.

Change-Id: I6e7bdf35bf370ea30d4f12a5a200ad38ff0221f4
parent 8359eaaf
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -22,13 +22,6 @@
        android:showAsAction="always|collapseActionView"
        android:actionViewClass="android.widget.SearchView"
        android:imeOptions="actionSearch" />
    <item
        android:id="@+id/menu_create_dir"
        android:title="@string/menu_create_dir"
        android:icon="@drawable/ic_menu_new_folder"
        android:alphabeticShortcut="e"
        android:showAsAction="always"
        android:visible="false" />
    <item
        android:id="@+id/menu_sort"
        android:title="@string/menu_sort"
@@ -62,6 +55,13 @@
        android:alphabeticShortcut="n"
        android:showAsAction="never"
        android:visible="false" />
    <item
        android:id="@+id/menu_create_dir"
        android:title="@string/menu_create_dir"
        android:icon="@drawable/ic_menu_new_folder"
        android:alphabeticShortcut="e"
        android:showAsAction="always"
        android:visible="false" />
    <item
        android:id="@+id/menu_paste_from_clipboard"
        android:title="@string/menu_paste_from_clipboard"
@@ -70,11 +70,11 @@
        android:visible="false" />
    <!-- Copy action is defined in mode_directory.xml -->
    <item
        android:id="@+id/menu_advanced"
        android:id="@+id/menu_file_size"
        android:showAsAction="never"
        android:visible="false" />
    <item
        android:id="@+id/menu_file_size"
        android:id="@+id/menu_advanced"
        android:showAsAction="never"
        android:visible="false" />
    <item
+1 −1
Original line number Diff line number Diff line
@@ -15,5 +15,5 @@
-->

<resources>
    <bool name="productivity_device">false</bool>
    <bool name="productivity_device">true</bool>
</resources>
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@
    <string name="title_save">Save to</string>

    <!-- Menu item that creates a new directory/folder at the current location [CHAR LIMIT=24] -->
    <string name="menu_create_dir">Create folder</string>
    <string name="menu_create_dir">New folder</string>
    <!-- Menu item that switches view to show documents as a large-format grid of thumbnails [CHAR LIMIT=24] -->
    <string name="menu_grid">Grid view</string>
    <!-- Menu item that switches view to show documents as a list [CHAR LIMIT=24] -->
+17 −12
Original line number Diff line number Diff line
@@ -128,10 +128,10 @@ abstract class BaseActivity extends Activity {

    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        boolean shown = super.onPrepareOptionsMenu(menu);
        super.onPrepareOptionsMenu(menu);

        final RootInfo root = getCurrentRoot();
        final DocumentInfo cwd = getCurrentDirectory();
        final boolean inRecents = getCurrentDirectory() == null;

        final MenuItem sort = menu.findItem(R.id.menu_sort);
        final MenuItem sortSize = menu.findItem(R.id.menu_sort_size);
@@ -141,24 +141,28 @@ abstract class BaseActivity extends Activity {
        final MenuItem fileSize = menu.findItem(R.id.menu_file_size);
        final MenuItem settings = menu.findItem(R.id.menu_settings);

        mSearchManager.update(root);
        // I'm thinkin' this isn't necesary here. If it is...'cuz of a bug....
        // then uncomment the linke and let's get a proper bug reference here.
        // mSearchManager.update(root);

        // Search uses backend ranking; no sorting
        sort.setVisible(cwd != null && !mSearchManager.isSearching());
        sort.setVisible(!inRecents && !mSearchManager.isSearching());

        // grid/list is effectively a toggle.
        grid.setVisible(mState.derivedMode != State.MODE_GRID);
        list.setVisible(mState.derivedMode != State.MODE_LIST);

        sortSize.setVisible(mState.showSize); // Only sort by size when visible
        fileSize.setVisible(!mState.forceSize);
        advanced.setVisible(!mState.forceAdvanced);
        settings.setVisible((root.flags & Root.FLAG_HAS_SETTINGS) != 0);

        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);

        sortSize.setVisible(mState.showSize); // Only sort by size when visible
        fileSize.setVisible(!mState.showSize);
        grid.setVisible(mState.derivedMode != State.MODE_GRID);
        list.setVisible(mState.derivedMode != State.MODE_LIST);
        advanced.setVisible(!mState.showAdvanced);
        settings.setVisible((root.flags & Root.FLAG_HAS_SETTINGS) != 0);

        return shown;
        return true;
    }

    State buildDefaultState() {
@@ -277,6 +281,7 @@ abstract class BaseActivity extends Activity {
        return cwd != null
                && cwd.isCreateSupported()
                && !mSearchManager.isSearching()
                && !root.isRecents()
                && !root.isDownloads();
    }

+1 −1
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ public class CopyService extends IntentService {

        int toastMessage = (mode == TRANSFER_MODE_COPY) ? R.plurals.copy_begin
                : R.plurals.move_begin;
        Shared.makeSnackbar(activity,
        Snackbars.makeSnackbar(activity,
                res.getQuantityString(toastMessage, srcDocs.size(), srcDocs.size()),
                Snackbar.LENGTH_SHORT).show();
        activity.startService(copyIntent);
Loading