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

Commit 8de16326 authored by Zemiao Zhu's avatar Zemiao Zhu Committed by Android (Google) Code Review
Browse files

Merge changes from topic "hidden-files" into rvc-dev

* changes:
  Add menu item for show hidden files.
  Add a localPreference for showHiddenFiles and use it in DirectoryLoader.
parents 68392ec4 bc616ee4
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -76,6 +76,11 @@
           android:title="@string/menu_inspect"
           android:visible="false"
           app:showAsAction="never"/>
        <item
            android:id="@+id/option_menu_show_hidden_files"
            android:title="@string/menu_show_hidden_files"
            android:visible="false"
            app:showAsAction="never"/>
        <item
            android:id="@+id/option_menu_launcher"
            android:visible="false"
+3 −0
Original line number Diff line number Diff line
@@ -29,6 +29,9 @@
    <!-- Indicates if showing as search bar design -->
    <bool name="show_search_bar">false</bool>

    <!-- Indicates if showing hidden files by default -->
    <bool name="show_hidden_files_by_default">false</bool>

    <string name="default_root_uri" translatable="false">content://com.android.providers.downloads.documents/root/downloads</string>
    <!-- The value is used in sorting process on Drawer menu. If the root's package name
     start with it, the item will have higher order than others.-->
+4 −0
Original line number Diff line number Diff line
@@ -75,6 +75,10 @@
    <string name="menu_rename">Rename</string>
    <!-- Menu item that displays properties about the selected document [CHAR LIMIT=28] -->
    <string name="menu_inspect">Get info</string>
    <!-- Menu item that shows hidden files [CHAR LIMIT=28] -->
    <string name="menu_show_hidden_files">Show hidden files</string>
    <!-- Menu item that hides hidden files [CHAR LIMIT=28] -->
    <string name="menu_hide_hidden_files">Don\u2019t show hidden files</string>
    <!-- Menu item that renames the selected document [CHAR LIMIT=28] -->
    <string name="menu_view_in_owner">View in <xliff:g id="source" example="Google Drive">%1$s</xliff:g></string>

+27 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static com.android.documentsui.base.Shared.EXTRA_BENCHMARK;
import static com.android.documentsui.base.SharedMinimal.DEBUG;
import static com.android.documentsui.base.State.MODE_GRID;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
@@ -403,6 +404,11 @@ public abstract class BaseActivity
        state.localOnly = intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false);
        state.excludedAuthorities = getExcludedAuthorities();
        state.restrictScopeStorage = Shared.shouldRestrictStorageAccessFramework(this);
        state.showHiddenFiles = LocalPreferences.getShowHiddenFiles(
                getApplicationContext(),
                getApplicationContext()
                        .getResources()
                        .getBoolean(R.bool.show_hidden_files_by_default));

        includeState(state);

@@ -524,6 +530,10 @@ public abstract class BaseActivity
                getInjector().actions.switchLauncherIcon();
                return true;

            case R.id.option_menu_show_hidden_files:
                onClickedShowHiddenFiles();
                return true;

            case R.id.sub_menu_grid:
                setViewMode(State.MODE_GRID);
                return true;
@@ -655,6 +665,23 @@ public abstract class BaseActivity
        return mState;
    }

    /**
     * Updates hidden files visibility based on user action.
     */
    private void onClickedShowHiddenFiles() {
        boolean showHiddenFiles = !mState.showHiddenFiles;
        Context context = getApplicationContext();

        Metrics.logUserAction(showHiddenFiles
                ? MetricConsts.USER_ACTION_SHOW_HIDDEN_FILES
                : MetricConsts.USER_ACTION_HIDE_HIDDEN_FILES);
        LocalPreferences.setShowHiddenFiles(context, showHiddenFiles);
        mState.showHiddenFiles = showHiddenFiles;

        // Calls this to trigger either MultiRootDocumentsLoader or DirectoryLoader reloading.
        mInjector.actions.loadDocumentsForCurrentStack();
    }

    /**
     * Set mode based on explicit user action.
     */
+3 −0
Original line number Diff line number Diff line
@@ -178,6 +178,9 @@ public class DirectoryLoader extends AsyncTaskLoader<DirectoryResult> {
            }
            cursor.registerContentObserver(mObserver);

            // Filter hidden files.
            cursor = new FilteringCursorWrapper(cursor, mState.showHiddenFiles);

            if (mSearchMode && !mFeatures.isFoldersInSearchResultsEnabled()) {
                // There is no findDocumentPath API. Enable filtering on folders in search mode.
                cursor = new FilteringCursorWrapper(cursor, null, SEARCH_REJECT_MIMES);
Loading