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

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

Merge "Change copy/move destination to Downloads when home directory is hidden." into nyc-dev

parents b22e51ec 64ae1f4e
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -438,6 +438,17 @@ public abstract class BaseActivity extends Activity
        return mState;
    }

    /*
     * Get the default directory to be presented after starting the activity.
     * Method can be overridden if the change of the behavior of the the child activity is needed.
     */
    public Uri getDefaultRoot() {
        return Shared.isHomeRootHidden(this)
                ? DocumentsContract.buildRootUri("com.android.providers.downloads.documents",
                        "downloads")
                : DocumentsContract.buildHomeUri();
    }

    void setDisplayFileSize(boolean display) {
        LocalPreferences.setDisplayFileSize(this, display);
        mState.showSize = display;
+1 −3
Original line number Diff line number Diff line
@@ -108,9 +108,7 @@ public class DocumentsActivity extends BaseActivity {
            // we restore the stack as last used from that app.
            if (mState.action == ACTION_PICK_COPY_DESTINATION) {
                if (DEBUG) Log.d(TAG, "Launching directly into Home directory.");
                Uri homeUri = DocumentsContract.buildHomeUri();
                new LoadRootTask(this, homeUri).executeOnExecutor(
                        ProviderExecutor.forAuthority(homeUri.getAuthority()));
                loadRoot(getDefaultRoot());
            } else {
                if (DEBUG) Log.d(TAG, "Attempting to load last used stack for calling package.");
                new LoadLastUsedStackTask(this).execute();
+1 −3
Original line number Diff line number Diff line
@@ -109,9 +109,7 @@ public class FilesActivity extends BaseActivity {
            loadRoot(uri);
        } else {
            if (DEBUG) Log.d(TAG, "All other means skipped. Launching into default directory.");
            Uri defaultUri = DocumentsContract.buildRootUri(
                    "com.android.providers.downloads.documents", "downloads");
            loadRoot(defaultUri);
            loadRoot(getDefaultRoot());
        }

        final @DialogType int dialogType = intent.getIntExtra(
+2 −16
Original line number Diff line number Diff line
@@ -318,9 +318,9 @@ public class RootsFragment extends Fragment {
            for (final RootInfo root : roots) {
                final RootItem item = new RootItem(root);

                if (root.isHome() && isHomeRootHidden(context)) {
                if (root.isHome() && Shared.isHomeRootHidden(context)) {
                    continue;
                } else if (root.isAdvanced() && areAdvancedRootsHidden(context)) {
                } else if (root.isAdvanced() && Shared.areAdvancedRootsHidden(context)) {
                    continue;
                } else if (root.isLibrary()) {
                    if (DEBUG) Log.d(TAG, "Adding " + root + " as library.");
@@ -372,20 +372,6 @@ public class RootsFragment extends Fragment {
            }
        }

        /*
         * Indicates if the home directory should be hidden in the roots list.
         */
        private boolean isHomeRootHidden(Context context) {
            return context.getResources().getBoolean(R.bool.home_root_hidden);
        }

        /*
         * Indicates if the advanced roots should be hidden.
         */
        private boolean areAdvancedRootsHidden(Context context) {
            return context.getResources().getBoolean(R.bool.advanced_roots_hidden);
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            final Item item = getItem(position);
+14 −0
Original line number Diff line number Diff line
@@ -169,4 +169,18 @@ public final class Shared {
        }
    }

    /*
     * Indicates if the home directory should be hidden in the roots list.
     */
    public static boolean isHomeRootHidden(Context context) {
        return context.getResources().getBoolean(R.bool.home_root_hidden);
    }

    /*
     * Indicates if the advanced roots should be hidden.
     */
    public static boolean areAdvancedRootsHidden(Context context) {
        return context.getResources().getBoolean(R.bool.advanced_roots_hidden);
    }

}