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

Commit 67d6ff2c authored by Tomasz Mikolajewski's avatar Tomasz Mikolajewski Committed by Android (Google) Code Review
Browse files

Merge "Disable searching in archives." into arc-apps

parents db05d140 9e047855
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -155,8 +155,6 @@ public abstract class BaseActivity
             */
            @Override
            public void onSearchChanged(@Nullable String query) {
                // We should not get here if root is not searchable
                assert (canSearchRoot());
                reloadSearch(query);
            }

@@ -229,7 +227,7 @@ public abstract class BaseActivity
    @CallSuper
    public boolean onPrepareOptionsMenu(Menu menu) {
        super.onPrepareOptionsMenu(menu);
        mSearchManager.showMenu(canSearchRoot());
        mSearchManager.showMenu(mState.stack);
        return true;
    }

@@ -431,11 +429,6 @@ public abstract class BaseActivity
        return authorities;
    }

    boolean canSearchRoot() {
        final RootInfo root = getCurrentRoot();
        return (root.flags & Root.FLAG_SUPPORTS_SEARCH) != 0;
    }

    public static BaseActivity get(Fragment fragment) {
        return (BaseActivity) fragment.getActivity();
    }
+1 −1
Original line number Diff line number Diff line
@@ -136,7 +136,7 @@ final class RootsMonitor<T extends Activity & CommonAddons> {

            // Clear entire backstack and start in new root.
            mState.stack.changeRoot(defaultRoot);
            mSearchMgr.update(defaultRoot);
            mSearchMgr.update(mState.stack);

            if (defaultRoot.isRecents()) {
                mOwner.refreshCurrentRootAndDirectory(AnimationView.ANIM_NONE);
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ public final class MenuManager extends com.android.documentsui.MenuManager {
        if (picking()) {
            // May already be hidden because the root
            // doesn't support search.
            mSearchManager.showMenu(false);
            mSearchManager.showMenu(null);
        }
    }

+23 −7
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ import android.widget.SearchView.OnQueryTextListener;

import com.android.documentsui.DocumentsToolbar;
import com.android.documentsui.R;
import com.android.documentsui.base.DocumentInfo;
import com.android.documentsui.base.DocumentStack;
import com.android.documentsui.base.RootInfo;
import com.android.documentsui.base.Shared;

@@ -103,9 +105,9 @@ public class SearchViewManager implements
    }

    /**
     * @param root Info about the current directory.
     * @param stack New stack.
     */
    public void update(RootInfo root) {
    public void update(DocumentStack stack) {
        if (mMenuItem == null) {
            if (DEBUG) Log.d(TAG, "update called before Search MenuItem installed.");
            return;
@@ -129,21 +131,35 @@ public class SearchViewManager implements
            }
        }

        showMenu(root != null
                && ((root.flags & Root.FLAG_SUPPORTS_SEARCH) != 0));
        showMenu(stack);
    }

    public void showMenu(@Nullable DocumentStack stack) {
        final DocumentInfo cwd = stack.peek();

        boolean supportsSearch = true;

        // Searching in archives is not enabled, as archives are backed by
        // a different provider than the root provider.
        if (cwd != null && cwd.isInArchive()) {
            supportsSearch = false;
        }

        final RootInfo root = stack != null ? stack.getRoot() : null;
        if (root == null || (root.flags & Root.FLAG_SUPPORTS_SEARCH) == 0) {
            supportsSearch = false;
        }

    public void showMenu(boolean visible) {
        if (mMenuItem == null) {
            if (DEBUG) Log.d(TAG, "showMenu called before Search MenuItem installed.");
            return;
        }

        if (!visible) {
        if (!supportsSearch) {
            mCurrentSearch = null;
        }

        mMenuItem.setVisible(visible);
        mMenuItem.setVisible(supportsSearch);
    }

    /**
+2 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.documentsui.testing;

import com.android.documentsui.base.DocumentStack;
import com.android.documentsui.queries.DebugCommandProcessor;
import com.android.documentsui.queries.SearchViewManager;

@@ -52,7 +53,7 @@ public class TestSearchViewManager extends SearchViewManager {
    }

    @Override
    public void showMenu(boolean visible) {
    public void showMenu(DocumentStack stack) {
        mShowMenuCalled = true;
    }