diff options
author | Tavis Bohne <tbohne@google.com> | 2016-03-17 21:35:17 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-03-17 21:35:17 +0000 |
commit | 9a3a44d481bab9a375f16cfb3289ec3d9259caea (patch) | |
tree | 97728d92a5378cd502dbe89c75d7a9019f48ace3 | |
parent | 3d3c03ef9db5a163f509d0f77d35e3d2d847bb06 (diff) | |
parent | 2cc3df20c80299a8901c104738d72109b1471668 (diff) | |
download | photoviewer-9a3a44d481bab9a375f16cfb3289ec3d9259caea.tar.gz |
Merge "PhotoViewer sets ContentDescriptions when provided by PagerAdapter" into ub-photoviewer-dorothea am: 8bd440f
am: 2cc3df2
* commit '2cc3df20c80299a8901c104738d72109b1471668':
PhotoViewer sets ContentDescriptions when provided by PagerAdapter
-rw-r--r-- | src/com/android/ex/photo/Intents.java | 15 | ||||
-rw-r--r-- | src/com/android/ex/photo/adapters/PhotoPagerAdapter.java | 6 | ||||
-rw-r--r-- | src/com/android/ex/photo/fragments/PhotoViewFragment.java | 3 |
3 files changed, 24 insertions, 0 deletions
diff --git a/src/com/android/ex/photo/Intents.java b/src/com/android/ex/photo/Intents.java index 104ae28..61e9382 100644 --- a/src/com/android/ex/photo/Intents.java +++ b/src/com/android/ex/photo/Intents.java @@ -37,6 +37,7 @@ public class Intents { public static final String EXTRA_RESOLVED_PHOTO_URI = "resolved_photo_uri"; public static final String EXTRA_PROJECTION = "projection"; public static final String EXTRA_THUMBNAIL_URI = "thumbnail_uri"; + public static final String EXTRA_CONTENT_DESCRIPTION = "content_description"; public static final String EXTRA_MAX_INITIAL_SCALE = "max_scale"; public static final String EXTRA_WATCH_NETWORK = "watch_network"; public static final String EXTRA_ENABLE_TIMER_LIGHTS_OUT = "enable_timer_lights_out"; @@ -116,6 +117,8 @@ public class Intents { private String[] mProjection; /** The URI of a thumbnail of the photo to display */ private String mThumbnailUri; + /** The content Description for the photo to show */ + private String mContentDescription; /** The maximum scale to display images at before */ private Float mMaxInitialScale; /** True if lights out should automatically be invoked on a timer basis */ @@ -206,6 +209,14 @@ public class Intents { } /** + * Sets the content Description for the photo + */ + public PhotoViewIntentBuilder setContentDescription(String contentDescription) { + mContentDescription = contentDescription; + return this; + } + + /** * Sets the maximum scale which an image is initially displayed at */ public PhotoViewIntentBuilder setMaxInitialScale(float maxScale) { @@ -313,6 +324,10 @@ public class Intents { mIntent.putExtra(EXTRA_THUMBNAIL_URI, mThumbnailUri); } + if (mContentDescription != null) { + mIntent.putExtra(EXTRA_CONTENT_DESCRIPTION, mContentDescription); + } + if (mMaxInitialScale != null) { mIntent.putExtra(EXTRA_MAX_INITIAL_SCALE, mMaxInitialScale); } diff --git a/src/com/android/ex/photo/adapters/PhotoPagerAdapter.java b/src/com/android/ex/photo/adapters/PhotoPagerAdapter.java index a09bb63..b7f87f8 100644 --- a/src/com/android/ex/photo/adapters/PhotoPagerAdapter.java +++ b/src/com/android/ex/photo/adapters/PhotoPagerAdapter.java @@ -50,6 +50,7 @@ public class PhotoPagerAdapter extends BaseCursorPagerAdapter { public Fragment getItem(Context context, Cursor cursor, int position) { final String photoUri = getPhotoUri(cursor); final String thumbnailUri = getThumbnailUri(cursor); + final String contentDescription = getPhotoName(cursor); boolean loading = shouldShowLoadingIndicator(cursor); boolean onlyShowSpinner = false; if(photoUri == null && loading) { @@ -62,6 +63,7 @@ public class PhotoPagerAdapter extends BaseCursorPagerAdapter { builder .setResolvedPhotoUri(photoUri) .setThumbnailUri(thumbnailUri) + .setContentDescription(contentDescription) .setDisplayThumbsFullScreen(mDisplayThumbsFullScreen) .setMaxInitialScale(mMaxScale); @@ -109,6 +111,10 @@ public class PhotoPagerAdapter extends BaseCursorPagerAdapter { return getString(cursor, PhotoViewColumns.CONTENT_TYPE); } + public String getPhotoName(Cursor cursor) { + return getString(cursor, PhotoViewColumns.NAME); + } + public boolean shouldShowLoadingIndicator(Cursor cursor) { String value = getString(cursor, PhotoViewColumns.LOADING_INDICATOR); if (value == null) { diff --git a/src/com/android/ex/photo/fragments/PhotoViewFragment.java b/src/com/android/ex/photo/fragments/PhotoViewFragment.java index ab9234d..627d728 100644 --- a/src/com/android/ex/photo/fragments/PhotoViewFragment.java +++ b/src/com/android/ex/photo/fragments/PhotoViewFragment.java @@ -92,6 +92,7 @@ public class PhotoViewFragment extends Fragment implements /** The URL of a photo to display */ protected String mResolvedPhotoUri; protected String mThumbnailUri; + protected String mContentDescription; /** The intent we were launched with */ protected Intent mIntent; protected PhotoViewCallbacks mCallback; @@ -209,6 +210,7 @@ public class PhotoViewFragment extends Fragment implements if (mIntent != null) { mResolvedPhotoUri = mIntent.getStringExtra(Intents.EXTRA_RESOLVED_PHOTO_URI); mThumbnailUri = mIntent.getStringExtra(Intents.EXTRA_THUMBNAIL_URI); + mContentDescription = mIntent.getStringExtra(Intents.EXTRA_CONTENT_DESCRIPTION); mWatchNetworkState = mIntent.getBooleanExtra(Intents.EXTRA_WATCH_NETWORK, false); } } @@ -227,6 +229,7 @@ public class PhotoViewFragment extends Fragment implements mPhotoView.setOnClickListener(this); mPhotoView.setFullScreen(mFullScreen, false); mPhotoView.enableImageTransforms(false); + mPhotoView.setContentDescription(mContentDescription); mPhotoPreviewAndProgress = view.findViewById(R.id.photo_preview); mPhotoPreviewImage = (ImageView) view.findViewById(R.id.photo_preview_image); |