Loading src/com/android/documentsui/files/ActionHandler.java +6 −7 Original line number Diff line number Diff line Loading @@ -701,19 +701,18 @@ public class ActionHandler<T extends FragmentActivity & Addons> extends Abstract // treatment, thusly the "isDownloads" check. // Launch MANAGE_DOCUMENTS only for the root level files, so it's not called for // files in archives. Also, if the activity is already browsing a ZIP from downloads, // then skip MANAGE_DOCUMENTS. // files in archives or in child folders. Also, if the activity is already browsing // a ZIP from downloads, then skip MANAGE_DOCUMENTS. if (Intent.ACTION_VIEW.equals(mActivity.getIntent().getAction()) && mState.stack.size() > 1) { // viewing the contents of an archive. return false; } // management is only supported in downloads. if (mActivity.getCurrentRoot().isDownloads()) { // and only and only on APKs or partial files. return MimeTypes.isApkType(doc.mimeType) || doc.isPartial(); // management is only supported in Downloads root or downloaded files show in Recent root. if (Providers.AUTHORITY_DOWNLOADS.equals(doc.authority)) { // only on APKs or partial files. return MimeTypes.isApkType(doc.mimeType) || doc.isPartial(); } return false; Loading tests/unit/com/android/documentsui/files/ActionHandlerTest.java +19 −7 Original line number Diff line number Diff line Loading @@ -331,6 +331,7 @@ public class ActionHandlerTest { @Test public void testDocumentPicked_Downloads_ManagesApks() throws Exception { mActivity.currentRoot = TestProvidersAccess.DOWNLOADS; TestEnv.FILE_APK.authority = TestProvidersAccess.DOWNLOADS.authority; mHandler.openDocument(TestEnv.FILE_APK, ActionHandler.VIEW_TYPE_PREVIEW, ActionHandler.VIEW_TYPE_REGULAR); Loading @@ -338,23 +339,34 @@ public class ActionHandlerTest { } @Test public void testDocumentPicked_Home_SendsActionViewForApks() throws Exception { mActivity.currentRoot = TestProvidersAccess.HOME; public void testDocumentPicked_Downloads_ManagesPartialFiles() throws Exception { mActivity.currentRoot = TestProvidersAccess.DOWNLOADS; TestEnv.FILE_PARTIAL.authority = TestProvidersAccess.DOWNLOADS.authority; mHandler.openDocument(TestEnv.FILE_APK, ActionHandler.VIEW_TYPE_PREVIEW, mHandler.openDocument(TestEnv.FILE_PARTIAL, ActionHandler.VIEW_TYPE_PREVIEW, ActionHandler.VIEW_TYPE_REGULAR); mActivity.assertActivityStarted(Intent.ACTION_VIEW); mActivity.assertActivityStarted(DocumentsContract.ACTION_MANAGE_DOCUMENT); } @Test public void testDocumentPicked_Downloads_ManagesPartialFiles() throws Exception { mActivity.currentRoot = TestProvidersAccess.DOWNLOADS; public void testDocumentPicked_Recent_ManagesApks() throws Exception { mActivity.currentRoot = TestProvidersAccess.RECENTS; TestEnv.FILE_APK.authority = TestProvidersAccess.DOWNLOADS.authority; mHandler.openDocument(TestEnv.FILE_PARTIAL, ActionHandler.VIEW_TYPE_PREVIEW, mHandler.openDocument(TestEnv.FILE_APK, ActionHandler.VIEW_TYPE_PREVIEW, ActionHandler.VIEW_TYPE_REGULAR); mActivity.assertActivityStarted(DocumentsContract.ACTION_MANAGE_DOCUMENT); } @Test public void testDocumentPicked_Home_SendsActionViewForApks() throws Exception { mActivity.currentRoot = TestProvidersAccess.HOME; mHandler.openDocument(TestEnv.FILE_APK, ActionHandler.VIEW_TYPE_PREVIEW, ActionHandler.VIEW_TYPE_REGULAR); mActivity.assertActivityStarted(Intent.ACTION_VIEW); } @Test public void testDocumentPicked_OpensArchives() throws Exception { mActivity.currentRoot = TestProvidersAccess.HOME; Loading Loading
src/com/android/documentsui/files/ActionHandler.java +6 −7 Original line number Diff line number Diff line Loading @@ -701,19 +701,18 @@ public class ActionHandler<T extends FragmentActivity & Addons> extends Abstract // treatment, thusly the "isDownloads" check. // Launch MANAGE_DOCUMENTS only for the root level files, so it's not called for // files in archives. Also, if the activity is already browsing a ZIP from downloads, // then skip MANAGE_DOCUMENTS. // files in archives or in child folders. Also, if the activity is already browsing // a ZIP from downloads, then skip MANAGE_DOCUMENTS. if (Intent.ACTION_VIEW.equals(mActivity.getIntent().getAction()) && mState.stack.size() > 1) { // viewing the contents of an archive. return false; } // management is only supported in downloads. if (mActivity.getCurrentRoot().isDownloads()) { // and only and only on APKs or partial files. return MimeTypes.isApkType(doc.mimeType) || doc.isPartial(); // management is only supported in Downloads root or downloaded files show in Recent root. if (Providers.AUTHORITY_DOWNLOADS.equals(doc.authority)) { // only on APKs or partial files. return MimeTypes.isApkType(doc.mimeType) || doc.isPartial(); } return false; Loading
tests/unit/com/android/documentsui/files/ActionHandlerTest.java +19 −7 Original line number Diff line number Diff line Loading @@ -331,6 +331,7 @@ public class ActionHandlerTest { @Test public void testDocumentPicked_Downloads_ManagesApks() throws Exception { mActivity.currentRoot = TestProvidersAccess.DOWNLOADS; TestEnv.FILE_APK.authority = TestProvidersAccess.DOWNLOADS.authority; mHandler.openDocument(TestEnv.FILE_APK, ActionHandler.VIEW_TYPE_PREVIEW, ActionHandler.VIEW_TYPE_REGULAR); Loading @@ -338,23 +339,34 @@ public class ActionHandlerTest { } @Test public void testDocumentPicked_Home_SendsActionViewForApks() throws Exception { mActivity.currentRoot = TestProvidersAccess.HOME; public void testDocumentPicked_Downloads_ManagesPartialFiles() throws Exception { mActivity.currentRoot = TestProvidersAccess.DOWNLOADS; TestEnv.FILE_PARTIAL.authority = TestProvidersAccess.DOWNLOADS.authority; mHandler.openDocument(TestEnv.FILE_APK, ActionHandler.VIEW_TYPE_PREVIEW, mHandler.openDocument(TestEnv.FILE_PARTIAL, ActionHandler.VIEW_TYPE_PREVIEW, ActionHandler.VIEW_TYPE_REGULAR); mActivity.assertActivityStarted(Intent.ACTION_VIEW); mActivity.assertActivityStarted(DocumentsContract.ACTION_MANAGE_DOCUMENT); } @Test public void testDocumentPicked_Downloads_ManagesPartialFiles() throws Exception { mActivity.currentRoot = TestProvidersAccess.DOWNLOADS; public void testDocumentPicked_Recent_ManagesApks() throws Exception { mActivity.currentRoot = TestProvidersAccess.RECENTS; TestEnv.FILE_APK.authority = TestProvidersAccess.DOWNLOADS.authority; mHandler.openDocument(TestEnv.FILE_PARTIAL, ActionHandler.VIEW_TYPE_PREVIEW, mHandler.openDocument(TestEnv.FILE_APK, ActionHandler.VIEW_TYPE_PREVIEW, ActionHandler.VIEW_TYPE_REGULAR); mActivity.assertActivityStarted(DocumentsContract.ACTION_MANAGE_DOCUMENT); } @Test public void testDocumentPicked_Home_SendsActionViewForApks() throws Exception { mActivity.currentRoot = TestProvidersAccess.HOME; mHandler.openDocument(TestEnv.FILE_APK, ActionHandler.VIEW_TYPE_PREVIEW, ActionHandler.VIEW_TYPE_REGULAR); mActivity.assertActivityStarted(Intent.ACTION_VIEW); } @Test public void testDocumentPicked_OpensArchives() throws Exception { mActivity.currentRoot = TestProvidersAccess.HOME; Loading