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

Commit 30ad01e5 authored by Aga Wronska's avatar Aga Wronska Committed by Android (Google) Code Review
Browse files

Merge "Add menu option to show/hide internal storage." into nyc-dev

parents 66de1373 ceb990ea
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -85,6 +85,10 @@
            android:id="@+id/menu_file_size"
            android:showAsAction="never"
            android:visible="false" />
        <item
            android:id="@+id/menu_advanced"
            android:showAsAction="never"
            android:visible="false" />
        <item
            android:id="@+id/menu_settings"
            android:title="@string/menu_settings"
+3 −2
Original line number Diff line number Diff line
@@ -24,8 +24,9 @@
    <!-- Indicates if the home directory should be hidden in the roots list, that is presented
         in the drawer/left side panel ) -->
    <bool name="home_root_hidden">true</bool>
    <!-- Indicates if the advanced roots like internal storage should be hidden in the roots list) -->
    <bool name="advanced_roots_hidden">true</bool>
    <!-- Indicates if the advanced roots like internal storage should be shown in the roots list.
         When enabled there is no menu option to toggle internal storage visibility. -->
    <bool name="advanced_roots_shown">false</bool>
    <!-- Indicates if search view is taking the whole toolbar space -->
    <bool name="full_bar_search_view">true</bool>
</resources>
+33 −9
Original line number Diff line number Diff line
@@ -18,6 +18,11 @@ package com.android.documentsui;

import static com.android.documentsui.Shared.DEBUG;
import static com.android.documentsui.Shared.EXTRA_BENCHMARK;
import static com.android.documentsui.State.ACTION_CREATE;
import static com.android.documentsui.State.ACTION_OPEN;
import static com.android.documentsui.State.ACTION_OPEN_TREE;
import static com.android.documentsui.State.ACTION_GET_CONTENT;
import static com.android.documentsui.State.ACTION_PICK_COPY_DESTINATION;
import static com.android.documentsui.State.MODE_GRID;

import android.app.Activity;
@@ -165,6 +170,7 @@ public abstract class BaseActivity extends Activity
        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);

        // Search uses backend ranking; no sorting, recents doesn't support sort.
@@ -176,6 +182,9 @@ public abstract class BaseActivity extends Activity
        grid.setVisible(mState.derivedMode != State.MODE_GRID);
        list.setVisible(mState.derivedMode != State.MODE_LIST);

        advanced.setVisible(mState.showAdvancedOption);
        advanced.setTitle(mState.showAdvancedOption && mState.showAdvanced
                ? 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);

@@ -195,25 +204,30 @@ public abstract class BaseActivity extends Activity
            return state;
        }

        State state = createSharedState();
        includeState(state);
        if (DEBUG) Log.d(mTag, "Created new state object: " + state);
        return state;
    }

    private State createSharedState() {
        State state = new State();

        final Intent intent = getIntent();

        state.localOnly = intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false);

        state.forceSize = intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_FILESIZE, false);
        state.showSize = state.forceSize || LocalPreferences.getDisplayFileSize(this);

        state.initAcceptMimes(intent);
        state.excludedAuthorities = getExcludedAuthorities();

        includeState(state);

        // Advanced roots are shown by deafult without menu option if forced by config or intent.
        state.showAdvanced = getResources().getBoolean(R.bool.advanced_roots_shown)
                || intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false);
        // Menu option is shown for whitelisted intents if advanced roots are not shown by default.
        state.showAdvancedOption = !state.showAdvanced &&
                (state.action == ACTION_OPEN ||
                        state.action == ACTION_CREATE ||
                        state.action == ACTION_OPEN_TREE ||
                        state.action == ACTION_GET_CONTENT);

        if (DEBUG) Log.d(mTag, "Created new state object: " + state);

        return state;
    }

@@ -287,6 +301,10 @@ public abstract class BaseActivity extends Activity
                }
                return true;

            case R.id.menu_advanced:
                setDisplayAdvancedDevices(!mState.showAdvanced);
                return true;

            case R.id.menu_file_size:
                setDisplayFileSize(!LocalPreferences.getDisplayFileSize(this));
                return true;
@@ -454,6 +472,12 @@ public abstract class BaseActivity extends Activity
                : DocumentsContract.buildHomeUri();
            }

    void setDisplayAdvancedDevices(boolean display) {
        mState.showAdvanced = display;
        RootsFragment.get(getFragmentManager()).onDisplayStateChanged();
        invalidateOptionsMenu();
    }

    void setDisplayFileSize(boolean display) {
        LocalPreferences.setDisplayFileSize(this, display);
        mState.showSize = display;
+5 −0
Original line number Diff line number Diff line
@@ -477,6 +477,11 @@ public class RootsCache {
                continue;
            }

            if (!state.showAdvanced && root.isAdvanced()) {
                if (DEBUG) Log.d(TAG, "Excluding root because: unwanted advanced device.");
                continue;
            }

            if (state.localOnly && !root.isLocalOnly()) {
                if (DEBUG) Log.d(TAG, "Excluding root because: unwanted non-local device.");
                continue;
+0 −3
Original line number Diff line number Diff line
@@ -321,9 +321,6 @@ public class RootsFragment extends Fragment {

                if (root.isHome() && Shared.isHomeRootHidden(context)) {
                    continue;
                } else if (root.isAdvanced()
                        && Shared.areAdvancedRootsHidden(context, state)) {
                    continue;
                } else if (root.isLibrary()) {
                    if (DEBUG) Log.d(TAG, "Adding " + root + " as library.");
                    libraries.add(item);
Loading