Loading src/com/android/documentsui/files/ActionHandler.java +18 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.content.ContentResolver.wrap; import static com.android.documentsui.base.SharedMinimal.DEBUG; import android.app.DownloadManager; import android.content.ActivityNotFoundException; import android.content.ClipData; import android.content.ContentProviderClient; Loading Loading @@ -57,6 +58,7 @@ import com.android.documentsui.base.DocumentStack; import com.android.documentsui.base.Features; import com.android.documentsui.base.Lookup; import com.android.documentsui.base.MimeTypes; import com.android.documentsui.base.Providers; import com.android.documentsui.base.RootInfo; import com.android.documentsui.base.Shared; import com.android.documentsui.base.State; Loading Loading @@ -429,6 +431,11 @@ public class ActionHandler<T extends FragmentActivity & Addons> extends Abstract return; } if (launchToDownloads(intent)) { if (DEBUG) Log.d(TAG, "Launched to a downloads."); return; } if (DEBUG) Log.d(TAG, "Launching directly into Home directory."); launchToDefaultLocation(); } Loading Loading @@ -500,6 +507,17 @@ public class ActionHandler<T extends FragmentActivity & Addons> extends Abstract return false; } private boolean launchToDownloads(Intent intent) { if (DownloadManager.ACTION_VIEW_DOWNLOADS.equals(intent.getAction())) { Uri uri = DocumentsContract.buildRootUri(Providers.AUTHORITY_DOWNLOADS, Providers.ROOT_ID_DOWNLOADS); loadRoot(uri); return true; } return false; } @Override public void showChooserForDoc(DocumentInfo doc) { assert(!doc.isDirectory()); Loading tests/unit/com/android/documentsui/files/ActionHandlerTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import android.app.Activity; import android.app.DownloadManager; import android.app.PendingIntent; import android.content.ClipData; import android.content.Intent; Loading Loading @@ -501,6 +502,15 @@ public class ActionHandlerTest { mActivity.refreshCurrentRootAndDirectory.assertCalled(); } @Test public void testInitLocation_LaunchToDownloads() throws Exception { Intent intent = mActivity.getIntent(); intent.setAction(DownloadManager.ACTION_VIEW_DOWNLOADS); mHandler.initLocation(intent); assertRootPicked(TestProvidersAccess.DOWNLOADS.getUri()); } @Test public void testDragAndDrop_OnReadOnlyRoot() throws Exception { RootInfo root = new RootInfo(); // root by default has no SUPPORT_CREATE flag Loading Loading
src/com/android/documentsui/files/ActionHandler.java +18 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.content.ContentResolver.wrap; import static com.android.documentsui.base.SharedMinimal.DEBUG; import android.app.DownloadManager; import android.content.ActivityNotFoundException; import android.content.ClipData; import android.content.ContentProviderClient; Loading Loading @@ -57,6 +58,7 @@ import com.android.documentsui.base.DocumentStack; import com.android.documentsui.base.Features; import com.android.documentsui.base.Lookup; import com.android.documentsui.base.MimeTypes; import com.android.documentsui.base.Providers; import com.android.documentsui.base.RootInfo; import com.android.documentsui.base.Shared; import com.android.documentsui.base.State; Loading Loading @@ -429,6 +431,11 @@ public class ActionHandler<T extends FragmentActivity & Addons> extends Abstract return; } if (launchToDownloads(intent)) { if (DEBUG) Log.d(TAG, "Launched to a downloads."); return; } if (DEBUG) Log.d(TAG, "Launching directly into Home directory."); launchToDefaultLocation(); } Loading Loading @@ -500,6 +507,17 @@ public class ActionHandler<T extends FragmentActivity & Addons> extends Abstract return false; } private boolean launchToDownloads(Intent intent) { if (DownloadManager.ACTION_VIEW_DOWNLOADS.equals(intent.getAction())) { Uri uri = DocumentsContract.buildRootUri(Providers.AUTHORITY_DOWNLOADS, Providers.ROOT_ID_DOWNLOADS); loadRoot(uri); return true; } return false; } @Override public void showChooserForDoc(DocumentInfo doc) { assert(!doc.isDirectory()); Loading
tests/unit/com/android/documentsui/files/ActionHandlerTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import android.app.Activity; import android.app.DownloadManager; import android.app.PendingIntent; import android.content.ClipData; import android.content.Intent; Loading Loading @@ -501,6 +502,15 @@ public class ActionHandlerTest { mActivity.refreshCurrentRootAndDirectory.assertCalled(); } @Test public void testInitLocation_LaunchToDownloads() throws Exception { Intent intent = mActivity.getIntent(); intent.setAction(DownloadManager.ACTION_VIEW_DOWNLOADS); mHandler.initLocation(intent); assertRootPicked(TestProvidersAccess.DOWNLOADS.getUri()); } @Test public void testDragAndDrop_OnReadOnlyRoot() throws Exception { RootInfo root = new RootInfo(); // root by default has no SUPPORT_CREATE flag Loading