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

Commit dbf09882 authored by Ben Lin's avatar Ben Lin
Browse files

Move defaultRootUri authority and rootId to resources.

Change-Id: I2bd443d86fa3567fe4eb2ddf4cef575be3e4852e
parent 551a2a1d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@
         layouts we reduce this to an input-box adjacent to menu actions. -->
    <bool name="full_bar_search_view">true</bool>

    <string name="default_root_uri" translatable="false">content://com.android.providers.downloads.documents/root/downloads</string>

    <!--
        New features must be added behind a boolean flag prefixed w/ "feature_".
        Please add them in alphabetical order. Same goes for accessor
+7 −4
Original line number Diff line number Diff line
@@ -216,10 +216,13 @@ public final class Shared {
     * Method can be overridden if the change of the behavior of the the child activity is needed.
     */
    public static Uri getDefaultRootUri(Activity activity) {
        return shouldShowDocumentsRoot(activity)
                ? DocumentsContract.buildHomeUri()
                : DocumentsContract.buildRootUri(
                        Providers.AUTHORITY_DOWNLOADS, Providers.ROOT_ID_DOWNLOADS);
        Uri defaultUri = Uri.parse(activity.getResources().getString(R.string.default_root_uri));

        if (!DocumentsContract.isRootUri(activity, defaultUri)) {
            throw new RuntimeException("Default Root URI is not a valid root URI.");
        }

        return defaultUri;
    }

    public static boolean isHardwareKeyboardAvailable(Context context) {
+5 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ public abstract class TestResources extends Resources {
        // this little hack....QuickViewIntentBuilder will check for this value
        // and ignore
        res.setQuickViewerPackage(QuickViewIntentBuilder.IGNORE_DEBUG_PROP);
        res.setDefaultDocumentsUri(TestProvidersAccess.DOWNLOADS.getUri().toString());
        return res;
    }

@@ -66,6 +67,10 @@ public abstract class TestResources extends Resources {
        strings.put(R.string.trusted_quick_viewer_package, packageName);
    }

    public void setDefaultDocumentsUri(String uri) {
        strings.put(R.string.default_root_uri, uri);
    }

    public void setProductivityDeviceEnabled(boolean enabled) {
        bools.put(R.bool.show_documents_root, enabled);
    }
+1 −0
Original line number Diff line number Diff line
@@ -368,6 +368,7 @@ public class ActionHandlerTest {
    @Test
    public void testInitLocation_DocumentsRootEnabled() throws Exception {
        mActivity.resources.bools.put(R.bool.show_documents_root, true);
        mActivity.resources.strings.put(R.string.default_root_uri, TestProvidersAccess.HOME.getUri().toString());

        mHandler.initLocation(mActivity.getIntent());
        assertRootPicked(TestProvidersAccess.HOME.getUri());
+1 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ public class ActionHandlerTest {
    @Test
    public void testInitLocation_CopyDestination_DocumentsRootEnabled() throws Exception {
        mActivity.resources.bools.put(R.bool.show_documents_root, true);
        mActivity.resources.strings.put(R.string.default_root_uri, TestProvidersAccess.HOME.getUri().toString());

        Intent intent = mActivity.getIntent();
        intent.setAction(Shared.ACTION_PICK_COPY_DESTINATION);