diff options
| author | 2023-04-26 21:31:11 -0700 | |
|---|---|---|
| committer | 2023-04-27 11:32:39 -0700 | |
| commit | 0bd94de6891a259cfabce5c5ccbac588de950642 (patch) | |
| tree | a4d0ef17f78fa170dc624f718751855fc64493b4 /java/src/com | |
| parent | 5a603c19da597f81507e9245bb17bda455c7578b (diff) | |
Preview UI: specify metadata columns, change metada reading order
Specify columns passed to ContentResolver#query.
Read ContentResolver#getStreamTypes before ContentResolver#query because
if the former returns, among others, an image mime types we can avoid
reading the latter.
Bug: 279674836
Test: unit tests, manual testing wiht Drive and a Photos prototype.
Change-Id: Ide31f5c9aae21c9e0ce93bec9a8d829851532f4a
Diffstat (limited to 'java/src/com')
| -rw-r--r-- | java/src/com/android/intentresolver/contentpreview/ChooserContentPreviewUi.java | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/java/src/com/android/intentresolver/contentpreview/ChooserContentPreviewUi.java b/java/src/com/android/intentresolver/contentpreview/ChooserContentPreviewUi.java index 69d8c49f..8173d542 100644 --- a/java/src/com/android/intentresolver/contentpreview/ChooserContentPreviewUi.java +++ b/java/src/com/android/intentresolver/contentpreview/ChooserContentPreviewUi.java @@ -37,6 +37,7 @@ import android.view.LayoutInflater; import android.view.ViewGroup; import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; import com.android.intentresolver.widget.ActionRow; import com.android.intentresolver.widget.ImagePreviewView.TransitionElementStatusCallback; @@ -52,6 +53,18 @@ import java.util.function.Consumer; * A content preview façade. */ public final class ChooserContentPreviewUi { + + /** + * A set of metadata columns we read for a content URI (see [readFileMetadata] method). + */ + @VisibleForTesting + static final String[] METADATA_COLUMNS = new String[] { + DocumentsContract.Document.COLUMN_FLAGS, + MediaMetadata.METADATA_KEY_DISPLAY_ICON_URI, + OpenableColumns.DISPLAY_NAME, + Downloads.Impl.COLUMN_TITLE + }; + /** * Delegate to build the default system action buttons to display in the preview layout, if/when * they're determined to be appropriate for the particular preview we display. @@ -209,9 +222,9 @@ public final class ChooserContentPreviewUi { if (typeClassifier.isImageType(mimeType)) { return builder.withPreviewUri(uri).build(); } - readFileMetadata(resolver, uri, builder); + readOtherFileTypes(resolver, uri, typeClassifier, builder); if (builder.getPreviewUri() == null) { - readOtherFileTypes(resolver, uri, typeClassifier, builder); + readFileMetadata(resolver, uri, builder); } return builder.build(); } @@ -329,7 +342,7 @@ public final class ChooserContentPreviewUi { } catch (SecurityException e) { logProviderPermissionWarning(uri, "mime type"); } catch (Throwable t) { - Log.e(ContentPreviewUi.TAG, "Failed to read content type, uri: " + uri, t); + Log.e(ContentPreviewUi.TAG, "Failed to read content type, uri: " + uri, t); } return null; } @@ -337,7 +350,7 @@ public final class ChooserContentPreviewUi { @Nullable private static Cursor query(ContentInterface resolver, Uri uri) { try { - return resolver.query(uri, null, null, null); + return resolver.query(uri, METADATA_COLUMNS, null, null); } catch (SecurityException e) { logProviderPermissionWarning(uri, "metadata"); } catch (Throwable t) { |