Loading res/layout/document_inspector_fragment.xml +7 −1 Original line number Diff line number Diff line Loading @@ -37,6 +37,12 @@ android:layout_width="match_parent" android:layout_height="wrap_content"/> <com.android.documentsui.inspector.TableView android:id="@+id/inspector_metadata_view" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"/> <com.android.documentsui.inspector.actions.ActionView android:paddingTop="10dp" android:id="@+id/inspector_show_in_provider_view" Loading res/values/colors.xml +1 −0 Original line number Diff line number Diff line Loading @@ -73,5 +73,6 @@ <color name="scroll_track">#fff0f0f0</color> <color name="inspector_value">#ff939393</color> <color name="inspector_link">#6633b5e5</color> <color name="inspector_section_title">#ff939393</color> </resources> res/values/strings.xml +19 −1 Original line number Diff line number Diff line Loading @@ -183,7 +183,7 @@ <!-- Toast shown when some of the selected documents failed to be deleted [CHAR LIMIT=48] --> <string name="toast_failed_delete">Unable to delete some documents</string> <!-- Toast shown when a files document info fails to load--> <!--File properties dialog error shown when information about a file could not be loaded--> <string name="file_inspector_load_error">Properties could not be loaded</string> <!-- Title of dialog when prompting user to select an app to share documents with [CHAR LIMIT=32] --> Loading Loading @@ -390,4 +390,22 @@ <!-- Title of inspector's debug info section. [CHAR LIMIT=48] --> <string name="inspector_debug_section">Debug info (dev only)</string> <!-- Title of inspector's metadata info section. Note that this is probably camera EXIF data. --> <string name="inspector_metadata_section">Metadata</string> <!--The height and width of a photo. Note that this is probably camera EXIF data.--> <string name="metadata_dimensions">Dimensions</string> <!--The location of where a photo was taken. (i.e. latitude, longitude) Note that this is probably camera EXIF data.--> <string name="metadata_location">Location</string> <!--The elevation the photo was taken. Note that this is probably camera EXIF data.--> <string name="metadata_altitude">Altitude</string> <!--The company that made the camera the photo was taken on. Note that this is probably camera EXIF data.--> <string name="metadata_make">Make</string> <!--The camera model that the photo was taken on. Note that this is probably camera EXIF data.--> <string name="metadata_model">Model</string> <!--The value of a photos aperture. Note that this is probably camera EXIF data.--> <string name="metadata_aperture">Aperture</string> <!--The value of a photos shutter speed. Note that this is probably camera EXIF data.--> <string name="metadata_shutter_speed">Shutter speed</string> </resources> src/com/android/documentsui/inspector/DebugView.java +1 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ public class DebugView extends TableView implements Consumer<DocumentInfo> { @Override public void accept(DocumentInfo info) { setTitle(this, R.string.inspector_debug_section); setTitle(R.string.inspector_debug_section); put("Content uri", info.derivedUri); put("Document id", info.documentId); Loading src/com/android/documentsui/inspector/InspectorController.java +141 −28 Original line number Diff line number Diff line Loading @@ -18,12 +18,15 @@ package com.android.documentsui.inspector; import static android.provider.DocumentsContract.Document.FLAG_SUPPORTS_SETTINGS; import static com.android.internal.util.Preconditions.checkArgument; import android.annotation.StringRes; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; import android.media.ExifInterface; import android.net.Uri; import android.os.Bundle; import android.provider.DocumentsContract; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; Loading @@ -49,6 +52,7 @@ public final class InspectorController { private final Loader mLoader; private final Consumer<DocumentInfo> mHeader; private final DetailsDisplay mDetails; private final TableDisplay mMetadata; private final ActionDisplay mShowProvider; private final ActionDisplay mAppDefaults; private final Consumer<DocumentInfo> mDebugView; Loading @@ -65,9 +69,9 @@ public final class InspectorController { @VisibleForTesting public InspectorController(Context context, Loader loader, PackageManager pm, ProvidersAccess providers, boolean showDebug, Consumer<DocumentInfo> header, DetailsDisplay details, ActionDisplay showProvider, ActionDisplay appDefaults, Consumer<DocumentInfo> debugView, Lookup<String, Executor> executors, Runnable showSnackbar) { DetailsDisplay details, TableDisplay metadata, ActionDisplay showProvider, ActionDisplay appDefaults, Consumer<DocumentInfo> debugView, Lookup<String, Executor> executors, Runnable showSnackbar) { checkArgument(context != null); checkArgument(loader != null); Loading @@ -75,6 +79,7 @@ public final class InspectorController { checkArgument(providers != null); checkArgument(header != null); checkArgument(details != null); checkArgument(metadata != null); checkArgument(showProvider != null); checkArgument(appDefaults != null); checkArgument(debugView != null); Loading @@ -88,6 +93,7 @@ public final class InspectorController { mProviders = providers; mHeader = header; mDetails = details; mMetadata = metadata; mShowProvider = showProvider; mAppDefaults = appDefaults; mDebugView = debugView; Loading @@ -104,6 +110,7 @@ public final class InspectorController { showDebug, (HeaderView) layout.findViewById(R.id.inspector_header_view), (DetailsView) layout.findViewById(R.id.inspector_details_view), (TableView) layout.findViewById(R.id.inspector_metadata_view), (ActionDisplay) layout.findViewById(R.id.inspector_show_in_provider_view), (ActionDisplay) layout.findViewById(R.id.inspector_app_defaults_view), (DebugView) layout.findViewById(R.id.inspector_debug_view), Loading Loading @@ -165,13 +172,74 @@ public final class InspectorController { }); } } if (mShowDebug) { mDebugView.accept(docInfo); } } } /** * Updates a files metadata to the view. * @param docName - the name of the doc. needed for launching a geo intent. * @param args - bundle of metadata. */ @VisibleForTesting public void updateMetadata(String docName, Bundle args) { mMetadata.setTitle(R.string.inspector_metadata_section); if (args.containsKey(ExifInterface.TAG_IMAGE_WIDTH) && args.containsKey(ExifInterface.TAG_IMAGE_LENGTH)) { int width = args.getInt(ExifInterface.TAG_IMAGE_WIDTH); int height = args.getInt(ExifInterface.TAG_IMAGE_LENGTH); mMetadata.put(R.string.metadata_dimensions, String.valueOf(width) + " x " + String.valueOf(height)); } if (args.containsKey(ExifInterface.TAG_GPS_LATITUDE) && args.containsKey(ExifInterface.TAG_GPS_LONGITUDE) ) { double latitude = args.getDouble(ExifInterface.TAG_GPS_LATITUDE); double longitude = args.getDouble(ExifInterface.TAG_GPS_LONGITUDE); Intent intent = createGeoIntent(latitude, longitude, docName); if (hasHandler(intent)) { mMetadata.put(R.string.metadata_location, String.valueOf(latitude) + ", " + String.valueOf(longitude), view -> startActivity(intent) ); } else { mMetadata.put(R.string.metadata_location, String.valueOf(latitude) + ", " + String.valueOf(longitude)); } } if (args.containsKey(ExifInterface.TAG_GPS_ALTITUDE)) { double altitude = args.getDouble(ExifInterface.TAG_GPS_ALTITUDE); mMetadata.put(R.string.metadata_altitude, String.valueOf(altitude)); } if (args.containsKey(ExifInterface.TAG_MAKE)) { String make = args.getString(ExifInterface.TAG_MAKE); mMetadata.put(R.string.metadata_make, make); } if (args.containsKey(ExifInterface.TAG_MODEL)) { String model = args.getString(ExifInterface.TAG_MODEL); mMetadata.put(R.string.metadata_model, model); } if (args.containsKey(ExifInterface.TAG_APERTURE)) { String aperture = String.valueOf(args.get(ExifInterface.TAG_APERTURE)); mMetadata.put(R.string.metadata_aperture, aperture); } if (args.containsKey(ExifInterface.TAG_SHUTTER_SPEED_VALUE)) { String shutterSpeed = String.valueOf(args.get(ExifInterface.TAG_SHUTTER_SPEED_VALUE)); mMetadata.put(R.string.metadata_shutter_speed, shutterSpeed); } } /** * Displays a directory's information to the view. * Loading @@ -181,6 +249,30 @@ public final class InspectorController { mDetails.setChildrenCount(count); } private void startActivity(Intent intent) { assert hasHandler(intent); mContext.startActivity(intent); } /** * checks that we can handle a geo-intent. */ private boolean hasHandler(Intent intent) { return mPackageManager.resolveActivity(intent, 0) != null; } /** * Creates a geo-intent for opening a location in maps. * * @see https://developer.android.com/guide/components/intents-common.html#Maps */ private static Intent createGeoIntent(double latitude, double longitude, @Nullable String label) { String data = "geo:0,0?q=" + latitude + " " + longitude + "(" + Uri.encode(label) + ")"; Uri uri = Uri.parse(data); return new Intent(Intent.ACTION_VIEW, uri); } /** * Shows the selected document in it's content provider. * Loading Loading @@ -272,4 +364,25 @@ public final class InspectorController { void setChildrenCount(int count); } /** * Displays a table of image metadata. */ public interface TableDisplay { /** * Sets the title of the data. */ void setTitle(@StringRes int title); /** * Adds a row in the table. */ void put(@StringRes int keyId, String value); /** * Adds a row in the table and makes it clickable. */ void put(@StringRes int keyId, String value, OnClickListener callback); } } No newline at end of file Loading
res/layout/document_inspector_fragment.xml +7 −1 Original line number Diff line number Diff line Loading @@ -37,6 +37,12 @@ android:layout_width="match_parent" android:layout_height="wrap_content"/> <com.android.documentsui.inspector.TableView android:id="@+id/inspector_metadata_view" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"/> <com.android.documentsui.inspector.actions.ActionView android:paddingTop="10dp" android:id="@+id/inspector_show_in_provider_view" Loading
res/values/colors.xml +1 −0 Original line number Diff line number Diff line Loading @@ -73,5 +73,6 @@ <color name="scroll_track">#fff0f0f0</color> <color name="inspector_value">#ff939393</color> <color name="inspector_link">#6633b5e5</color> <color name="inspector_section_title">#ff939393</color> </resources>
res/values/strings.xml +19 −1 Original line number Diff line number Diff line Loading @@ -183,7 +183,7 @@ <!-- Toast shown when some of the selected documents failed to be deleted [CHAR LIMIT=48] --> <string name="toast_failed_delete">Unable to delete some documents</string> <!-- Toast shown when a files document info fails to load--> <!--File properties dialog error shown when information about a file could not be loaded--> <string name="file_inspector_load_error">Properties could not be loaded</string> <!-- Title of dialog when prompting user to select an app to share documents with [CHAR LIMIT=32] --> Loading Loading @@ -390,4 +390,22 @@ <!-- Title of inspector's debug info section. [CHAR LIMIT=48] --> <string name="inspector_debug_section">Debug info (dev only)</string> <!-- Title of inspector's metadata info section. Note that this is probably camera EXIF data. --> <string name="inspector_metadata_section">Metadata</string> <!--The height and width of a photo. Note that this is probably camera EXIF data.--> <string name="metadata_dimensions">Dimensions</string> <!--The location of where a photo was taken. (i.e. latitude, longitude) Note that this is probably camera EXIF data.--> <string name="metadata_location">Location</string> <!--The elevation the photo was taken. Note that this is probably camera EXIF data.--> <string name="metadata_altitude">Altitude</string> <!--The company that made the camera the photo was taken on. Note that this is probably camera EXIF data.--> <string name="metadata_make">Make</string> <!--The camera model that the photo was taken on. Note that this is probably camera EXIF data.--> <string name="metadata_model">Model</string> <!--The value of a photos aperture. Note that this is probably camera EXIF data.--> <string name="metadata_aperture">Aperture</string> <!--The value of a photos shutter speed. Note that this is probably camera EXIF data.--> <string name="metadata_shutter_speed">Shutter speed</string> </resources>
src/com/android/documentsui/inspector/DebugView.java +1 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ public class DebugView extends TableView implements Consumer<DocumentInfo> { @Override public void accept(DocumentInfo info) { setTitle(this, R.string.inspector_debug_section); setTitle(R.string.inspector_debug_section); put("Content uri", info.derivedUri); put("Document id", info.documentId); Loading
src/com/android/documentsui/inspector/InspectorController.java +141 −28 Original line number Diff line number Diff line Loading @@ -18,12 +18,15 @@ package com.android.documentsui.inspector; import static android.provider.DocumentsContract.Document.FLAG_SUPPORTS_SETTINGS; import static com.android.internal.util.Preconditions.checkArgument; import android.annotation.StringRes; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; import android.media.ExifInterface; import android.net.Uri; import android.os.Bundle; import android.provider.DocumentsContract; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; Loading @@ -49,6 +52,7 @@ public final class InspectorController { private final Loader mLoader; private final Consumer<DocumentInfo> mHeader; private final DetailsDisplay mDetails; private final TableDisplay mMetadata; private final ActionDisplay mShowProvider; private final ActionDisplay mAppDefaults; private final Consumer<DocumentInfo> mDebugView; Loading @@ -65,9 +69,9 @@ public final class InspectorController { @VisibleForTesting public InspectorController(Context context, Loader loader, PackageManager pm, ProvidersAccess providers, boolean showDebug, Consumer<DocumentInfo> header, DetailsDisplay details, ActionDisplay showProvider, ActionDisplay appDefaults, Consumer<DocumentInfo> debugView, Lookup<String, Executor> executors, Runnable showSnackbar) { DetailsDisplay details, TableDisplay metadata, ActionDisplay showProvider, ActionDisplay appDefaults, Consumer<DocumentInfo> debugView, Lookup<String, Executor> executors, Runnable showSnackbar) { checkArgument(context != null); checkArgument(loader != null); Loading @@ -75,6 +79,7 @@ public final class InspectorController { checkArgument(providers != null); checkArgument(header != null); checkArgument(details != null); checkArgument(metadata != null); checkArgument(showProvider != null); checkArgument(appDefaults != null); checkArgument(debugView != null); Loading @@ -88,6 +93,7 @@ public final class InspectorController { mProviders = providers; mHeader = header; mDetails = details; mMetadata = metadata; mShowProvider = showProvider; mAppDefaults = appDefaults; mDebugView = debugView; Loading @@ -104,6 +110,7 @@ public final class InspectorController { showDebug, (HeaderView) layout.findViewById(R.id.inspector_header_view), (DetailsView) layout.findViewById(R.id.inspector_details_view), (TableView) layout.findViewById(R.id.inspector_metadata_view), (ActionDisplay) layout.findViewById(R.id.inspector_show_in_provider_view), (ActionDisplay) layout.findViewById(R.id.inspector_app_defaults_view), (DebugView) layout.findViewById(R.id.inspector_debug_view), Loading Loading @@ -165,13 +172,74 @@ public final class InspectorController { }); } } if (mShowDebug) { mDebugView.accept(docInfo); } } } /** * Updates a files metadata to the view. * @param docName - the name of the doc. needed for launching a geo intent. * @param args - bundle of metadata. */ @VisibleForTesting public void updateMetadata(String docName, Bundle args) { mMetadata.setTitle(R.string.inspector_metadata_section); if (args.containsKey(ExifInterface.TAG_IMAGE_WIDTH) && args.containsKey(ExifInterface.TAG_IMAGE_LENGTH)) { int width = args.getInt(ExifInterface.TAG_IMAGE_WIDTH); int height = args.getInt(ExifInterface.TAG_IMAGE_LENGTH); mMetadata.put(R.string.metadata_dimensions, String.valueOf(width) + " x " + String.valueOf(height)); } if (args.containsKey(ExifInterface.TAG_GPS_LATITUDE) && args.containsKey(ExifInterface.TAG_GPS_LONGITUDE) ) { double latitude = args.getDouble(ExifInterface.TAG_GPS_LATITUDE); double longitude = args.getDouble(ExifInterface.TAG_GPS_LONGITUDE); Intent intent = createGeoIntent(latitude, longitude, docName); if (hasHandler(intent)) { mMetadata.put(R.string.metadata_location, String.valueOf(latitude) + ", " + String.valueOf(longitude), view -> startActivity(intent) ); } else { mMetadata.put(R.string.metadata_location, String.valueOf(latitude) + ", " + String.valueOf(longitude)); } } if (args.containsKey(ExifInterface.TAG_GPS_ALTITUDE)) { double altitude = args.getDouble(ExifInterface.TAG_GPS_ALTITUDE); mMetadata.put(R.string.metadata_altitude, String.valueOf(altitude)); } if (args.containsKey(ExifInterface.TAG_MAKE)) { String make = args.getString(ExifInterface.TAG_MAKE); mMetadata.put(R.string.metadata_make, make); } if (args.containsKey(ExifInterface.TAG_MODEL)) { String model = args.getString(ExifInterface.TAG_MODEL); mMetadata.put(R.string.metadata_model, model); } if (args.containsKey(ExifInterface.TAG_APERTURE)) { String aperture = String.valueOf(args.get(ExifInterface.TAG_APERTURE)); mMetadata.put(R.string.metadata_aperture, aperture); } if (args.containsKey(ExifInterface.TAG_SHUTTER_SPEED_VALUE)) { String shutterSpeed = String.valueOf(args.get(ExifInterface.TAG_SHUTTER_SPEED_VALUE)); mMetadata.put(R.string.metadata_shutter_speed, shutterSpeed); } } /** * Displays a directory's information to the view. * Loading @@ -181,6 +249,30 @@ public final class InspectorController { mDetails.setChildrenCount(count); } private void startActivity(Intent intent) { assert hasHandler(intent); mContext.startActivity(intent); } /** * checks that we can handle a geo-intent. */ private boolean hasHandler(Intent intent) { return mPackageManager.resolveActivity(intent, 0) != null; } /** * Creates a geo-intent for opening a location in maps. * * @see https://developer.android.com/guide/components/intents-common.html#Maps */ private static Intent createGeoIntent(double latitude, double longitude, @Nullable String label) { String data = "geo:0,0?q=" + latitude + " " + longitude + "(" + Uri.encode(label) + ")"; Uri uri = Uri.parse(data); return new Intent(Intent.ACTION_VIEW, uri); } /** * Shows the selected document in it's content provider. * Loading Loading @@ -272,4 +364,25 @@ public final class InspectorController { void setChildrenCount(int count); } /** * Displays a table of image metadata. */ public interface TableDisplay { /** * Sets the title of the data. */ void setTitle(@StringRes int title); /** * Adds a row in the table. */ void put(@StringRes int keyId, String value); /** * Adds a row in the table and makes it clickable. */ void put(@StringRes int keyId, String value, OnClickListener callback); } } No newline at end of file