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

Commit 7e43bf15 authored by Tony Huang's avatar Tony Huang
Browse files

Remove show internal storage menu item

Remove it and always show internal storage on drawer.
For global search, let it search all providers but exclude storage
providers to avoid duplicate content.

Bug: 142034844
Test: manual
Test: atest DocumentsUIGoogleTests
Change-Id: I6faff4d9a295df762710033b292fdb8610701e17
parent 2fe45775
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -66,10 +66,6 @@
            android:alphabeticShortcut="a"
            android:visible="false"
            app:showAsAction="never"/>
        <item
            android:id="@+id/option_menu_advanced"
            android:visible="false"
            app:showAsAction="never"/>
        <item
            android:id="@+id/option_menu_settings"
            android:title="@string/menu_settings"
+0 −41
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.documentsui;

import static com.android.documentsui.base.Shared.EXTRA_BENCHMARK;
import static com.android.documentsui.base.SharedMinimal.DEBUG;
import static com.android.documentsui.base.State.ACTION_OPEN_TREE;
import static com.android.documentsui.base.State.MODE_GRID;

import android.content.Intent;
@@ -65,7 +64,6 @@ import com.android.documentsui.dirlist.DirectoryFragment;
import com.android.documentsui.prefs.LocalPreferences;
import com.android.documentsui.prefs.Preferences;
import com.android.documentsui.prefs.PreferencesMonitor;
import com.android.documentsui.prefs.ScopedPreferences;
import com.android.documentsui.queries.CommandInterceptor;
import com.android.documentsui.queries.SearchChipData;
import com.android.documentsui.queries.SearchFragment;
@@ -281,11 +279,6 @@ public abstract class BaseActivity
        // just limits the scope of what we expect to come flowing
        // through here until we know we want more and fancier options.
        assert(Preferences.shouldBackup(pref));

        switch (pref) {
            case ScopedPreferences.INCLUDE_DEVICE_ROOT:
                updateDisplayAdvancedDevices(mInjector.prefs.getShowDeviceRoot());
        }
    }

    @Override
@@ -360,14 +353,6 @@ public abstract class BaseActivity

        includeState(state);

        // always show device root in tree mode
        final boolean mustShowDeviceRoot =
                state.action == ACTION_OPEN_TREE || Shared.mustShowDeviceRoot(intent);
        state.showAdvanced = mustShowDeviceRoot || mInjector.prefs.getShowDeviceRoot();

        // Only show the toggle if advanced isn't forced enabled.
        state.showDeviceStorageOption = !mustShowDeviceRoot;

        if (DEBUG) {
            Log.d(mTag, "Created new state object: " + state);
        }
@@ -460,10 +445,6 @@ public abstract class BaseActivity
                // SearchViewManager listens for this directly.
                return false;

            case R.id.option_menu_advanced:
                onDisplayAdvancedDevices();
                return true;

            case R.id.option_menu_select_all:
                getInjector().actions.selectAllFiles();
                return true;
@@ -601,28 +582,6 @@ public abstract class BaseActivity
        return mState;
    }

    /**
     * Set internal storage visible based on explicit user action.
     */
    private void onDisplayAdvancedDevices() {
        boolean display = !mState.showAdvanced;
        Metrics.logUserAction(display
                ? MetricConsts.USER_ACTION_SHOW_ADVANCED : MetricConsts.USER_ACTION_HIDE_ADVANCED);

        mInjector.prefs.setShowDeviceRoot(display);
        updateDisplayAdvancedDevices(display);
    }

    private void updateDisplayAdvancedDevices(boolean display) {
        mState.showAdvanced = display;
        @Nullable RootsFragment fragment = RootsFragment.get(getSupportFragmentManager());
        if (fragment != null) {
            // This also takes care of updating launcher shortcuts (which are roots :)
            fragment.onDisplayStateChanged();
        }
        invalidateOptionsMenu();
    }

    /**
     * Set mode based on explicit user action.
     */
+3 −7
Original line number Diff line number Diff line
@@ -69,13 +69,9 @@ public class GlobalSearchLoader extends MultiRootDocumentsLoader {
            return true;
        }

        // If the value of showAdvanced is true,
        // don't query media roots and downloads root to avoid showing
        // duplicated files.
        if (mState.showAdvanced && (root.isLibrary() || root.isDownloads())) {
            return true;
        }
        return false;
        // To prevent duplicate files on search result, ignore storage root because its almost
        // files include in media root.
        return root.isStorage();
    }

    @Override
+0 −7
Original line number Diff line number Diff line
@@ -92,7 +92,6 @@ public abstract class MenuManager {
        updateSettings(mOptionMenu.findItem(R.id.option_menu_settings));
        updateSelectAll(mOptionMenu.findItem(R.id.option_menu_select_all));
        updateNewWindow(mOptionMenu.findItem(R.id.option_menu_new_window));
        updateAdvanced(mOptionMenu.findItem(R.id.option_menu_advanced));
        updateDebug(mOptionMenu.findItem(R.id.option_menu_debug));
        updateInspect(mOptionMenu.findItem(R.id.option_menu_inspect));
        updateSort(mOptionMenu.findItem(R.id.option_menu_sort));
@@ -258,12 +257,6 @@ public abstract class MenuManager {
        list.setVisible(mState.derivedMode != State.MODE_LIST);
    }

    protected void updateAdvanced(MenuItem advanced) {
        advanced.setVisible(mState.showDeviceStorageOption);
        advanced.setTitle(mState.showDeviceStorageOption && mState.showAdvanced
                ? R.string.menu_advanced_hide : R.string.menu_advanced_show);
    }

    protected void updateSort(MenuItem sort) {
        sort.setVisible(true);
    }
+3 −5
Original line number Diff line number Diff line
@@ -15,14 +15,14 @@
 */
package com.android.documentsui;

import androidx.annotation.DrawableRes;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
import android.graphics.drawable.Icon;

import com.android.documentsui.R;
import androidx.annotation.DrawableRes;

import com.android.documentsui.base.Providers;
import com.android.documentsui.base.RootInfo;
import com.android.documentsui.base.Shared;
@@ -93,9 +93,7 @@ public final class ShortcutsUpdater {
            // } else
            if (root.isAdvanced() && root.authority.equals(Providers.AUTHORITY_STORAGE)) {
                // internal storage
                if (mPrefs.getShowDeviceRoot()) {
                devices.add(0, createShortcut(root, R.drawable.ic_advanced_shortcut));
                }
            } else if (root.isAdvanced()) {
                // probably just bugreports provider
                devices.add(0, createShortcut(root, R.drawable.ic_folder_shortcut));
Loading