diff options
6 files changed, 38 insertions, 13 deletions
diff --git a/src/com/android/documentsui/AbstractActionHandler.java b/src/com/android/documentsui/AbstractActionHandler.java index 8e1a51301..9b4d50b36 100644 --- a/src/com/android/documentsui/AbstractActionHandler.java +++ b/src/com/android/documentsui/AbstractActionHandler.java @@ -266,7 +266,7 @@ public abstract class AbstractActionHandler<T extends FragmentActivity & CommonA } @Override - public void showInspector(DocumentInfo doc) { + public void showPreview(DocumentInfo doc) { throw new UnsupportedOperationException("Can't open properties."); } diff --git a/src/com/android/documentsui/ActionHandler.java b/src/com/android/documentsui/ActionHandler.java index c66a7e78c..190f5d960 100644 --- a/src/com/android/documentsui/ActionHandler.java +++ b/src/com/android/documentsui/ActionHandler.java @@ -118,7 +118,7 @@ public interface ActionHandler { void showCreateDirectoryDialog(); - void showInspector(DocumentInfo doc); + void showPreview(DocumentInfo doc); @Nullable DocumentInfo renameDocument(String name, DocumentInfo document); diff --git a/src/com/android/documentsui/dirlist/DirectoryFragment.java b/src/com/android/documentsui/dirlist/DirectoryFragment.java index b4b08ce1b..ffa912c51 100644 --- a/src/com/android/documentsui/dirlist/DirectoryFragment.java +++ b/src/com/android/documentsui/dirlist/DirectoryFragment.java @@ -990,7 +990,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On ? mActivity.getCurrentDirectory() : mModel.getDocuments(selection).get(0); - mActions.showInspector(doc); + mActions.showPreview(doc); return true; } else if (id == R.id.dir_menu_cut_to_clipboard) { mActions.cutToClipboard(); diff --git a/src/com/android/documentsui/files/ActionHandler.java b/src/com/android/documentsui/files/ActionHandler.java index 56eef8737..af5ef5bbc 100644 --- a/src/com/android/documentsui/files/ActionHandler.java +++ b/src/com/android/documentsui/files/ActionHandler.java @@ -19,7 +19,7 @@ package com.android.documentsui.files; import static android.content.ContentResolver.wrap; import static com.android.documentsui.base.SharedMinimal.DEBUG; -import static com.android.documentsui.flags.Flags.desktopFileHandling; +import com.android.documentsui.flags.Flags; import android.app.DownloadManager; import android.content.ActivityNotFoundException; @@ -551,7 +551,7 @@ public class ActionHandler<T extends FragmentActivity & AbstractActionHandler.Co return; } - if (desktopFileHandling()) { + if (Flags.desktopFileHandling()) { Intent intent = buildViewIntent(doc); intent.setComponent( new ComponentName("android", "com.android.internal.app.ResolverActivity")); @@ -571,8 +571,7 @@ public class ActionHandler<T extends FragmentActivity & AbstractActionHandler.Co } } - @Override - public void showInspector(DocumentInfo doc) { + private void showInspector(DocumentInfo doc) { Metrics.logUserAction(MetricConsts.USER_ACTION_INSPECTOR); Intent intent = InspectorActivity.createIntent(mActivity, doc.derivedUri, doc.userId); @@ -596,4 +595,17 @@ public class ActionHandler<T extends FragmentActivity & AbstractActionHandler.Co } mActivity.startActivity(intent); } + + private void showPeek() { + Log.d(TAG, "Peek not implemented"); + } + + @Override + public void showPreview(DocumentInfo doc) { + if (Flags.useMaterial3() && Flags.usePeekPreview()) { + showPeek(); + } else { + showInspector(doc); + } + } } diff --git a/src/com/android/documentsui/files/FilesActivity.java b/src/com/android/documentsui/files/FilesActivity.java index cd744476e..4bb7c1ac5 100644 --- a/src/com/android/documentsui/files/FilesActivity.java +++ b/src/com/android/documentsui/files/FilesActivity.java @@ -350,7 +350,7 @@ public class FilesActivity extends BaseActivity implements AbstractActionHandler } else if (id == R.id.option_menu_select_all) { mInjector.actions.selectAllFiles(); } else if (id == R.id.option_menu_inspect) { - mInjector.actions.showInspector(getCurrentDirectory()); + mInjector.actions.showPreview(getCurrentDirectory()); } else { final boolean ok = super.onOptionsItemSelected(item); if (DEBUG && !ok) { diff --git a/tests/unit/com/android/documentsui/files/ActionHandlerTest.java b/tests/unit/com/android/documentsui/files/ActionHandlerTest.java index 4e6cb8f05..2554ea52b 100644 --- a/tests/unit/com/android/documentsui/files/ActionHandlerTest.java +++ b/tests/unit/com/android/documentsui/files/ActionHandlerTest.java @@ -724,8 +724,17 @@ public class ActionHandlerTest { } @Test + @RequiresFlagsEnabled({Flags.FLAG_USE_MATERIAL3, Flags.FLAG_USE_PEEK_PREVIEW}) + public void testShowPeek() throws Exception { + mHandler.showPreview(TestEnv.FILE_GIF); + // The inspector activity is not called. + mActivity.startActivity.assertNotCalled(); + } + + @Test + @RequiresFlagsDisabled({Flags.FLAG_USE_PEEK_PREVIEW}) public void testShowInspector() throws Exception { - mHandler.showInspector(TestEnv.FILE_GIF); + mHandler.showPreview(TestEnv.FILE_GIF); mActivity.startActivity.assertCalled(); Intent intent = mActivity.startActivity.getLastValue(); @@ -737,10 +746,11 @@ public class ActionHandlerTest { } @Test + @RequiresFlagsDisabled({Flags.FLAG_USE_PEEK_PREVIEW}) public void testShowInspector_DebugDisabled() throws Exception { mFeatures.debugSupport = false; - mHandler.showInspector(TestEnv.FILE_GIF); + mHandler.showPreview(TestEnv.FILE_GIF); Intent intent = mActivity.startActivity.getLastValue(); assertHasExtra(intent, Shared.EXTRA_SHOW_DEBUG); @@ -748,11 +758,12 @@ public class ActionHandlerTest { } @Test + @RequiresFlagsDisabled({Flags.FLAG_USE_PEEK_PREVIEW}) public void testShowInspector_DebugEnabled() throws Exception { mFeatures.debugSupport = true; DebugFlags.setDocumentDetailsEnabled(true); - mHandler.showInspector(TestEnv.FILE_GIF); + mHandler.showPreview(TestEnv.FILE_GIF); Intent intent = mActivity.startActivity.getLastValue(); assertHasExtra(intent, Shared.EXTRA_SHOW_DEBUG); @@ -761,6 +772,7 @@ public class ActionHandlerTest { } @Test + @RequiresFlagsDisabled({Flags.FLAG_USE_PEEK_PREVIEW}) public void testShowInspector_OverridesRootDocumentName() throws Exception { mActivity.currentRoot = TestProvidersAccess.PICKLES; mEnv.populateStack(); @@ -772,7 +784,7 @@ public class ActionHandlerTest { DocumentInfo rootDoc = mEnv.state.stack.peek(); rootDoc.displayName = "poodles"; - mHandler.showInspector(rootDoc); + mHandler.showPreview(rootDoc); Intent intent = mActivity.startActivity.getLastValue(); assertEquals( TestProvidersAccess.PICKLES.title, @@ -780,6 +792,7 @@ public class ActionHandlerTest { } @Test + @RequiresFlagsDisabled({Flags.FLAG_USE_PEEK_PREVIEW}) public void testShowInspector_OverridesRootDocumentNameX() throws Exception { mActivity.currentRoot = TestProvidersAccess.PICKLES; mEnv.populateStack(); @@ -792,7 +805,7 @@ public class ActionHandlerTest { DocumentInfo rootDoc = mEnv.state.stack.peek(); rootDoc.displayName = "poodles"; - mHandler.showInspector(rootDoc); + mHandler.showPreview(rootDoc); Intent intent = mActivity.startActivity.getLastValue(); assertFalse(intent.getExtras().containsKey(Intent.EXTRA_TITLE)); } |