Commit 1b4df39e authored by Finnur Thorarinsson's avatar Finnur Thorarinsson Committed by Commit Bot

Photo Picker: A bit of polish for Zoom feature.

Adhere better to UX mocks:
- Make Zoom button appear on first selection (and stay after that).
- Remove selection border on full screen images.

Other changes:
- Evict full-screen cache on leaving full-screen. The cache takes up
quite a bit of space and is not likely to be as useful after
leaving full-screen mode.
- Disable Zoom button while animations are taking place. Avoids
starting animations twice in a row.

Bug: 1029056, 656015
Change-Id: Idb58508c4f0ca691e2247ccd024b88f5d16f0eec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1948894
Commit-Queue: Finnur Thorarinsson <finnur@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721237}
parent 123efb3e
...@@ -231,6 +231,13 @@ public class PickerBitmapView extends SelectableItemView<PickerBitmap> { ...@@ -231,6 +231,13 @@ public class PickerBitmapView extends SelectableItemView<PickerBitmap> {
// TODO(finnur): Look into whether using #updateView can simplify this logic. // TODO(finnur): Look into whether using #updateView can simplify this logic.
boolean selected = mSelectionDelegate.isItemSelected(mBitmapDetails); boolean selected = mSelectionDelegate.isItemSelected(mBitmapDetails);
// Selection border is not in use when in magnifying mode. Selected bitmaps will still have
// a checkmark, indicating selection.
if (mCategoryView.isInMagnifyingMode()) {
selected = false;
}
if (selected == mSelectedState) { if (selected == mSelectedState) {
// No need to change to a state that is already set. // No need to change to a state that is already set.
return; return;
......
...@@ -56,7 +56,8 @@ import java.util.List; ...@@ -56,7 +56,8 @@ import java.util.List;
*/ */
public class PickerCategoryView extends RelativeLayout public class PickerCategoryView extends RelativeLayout
implements FileEnumWorkerTask.FilesEnumeratedCallback, RecyclerView.RecyclerListener, implements FileEnumWorkerTask.FilesEnumeratedCallback, RecyclerView.RecyclerListener,
DecoderServiceHost.ServiceReadyCallback, View.OnClickListener { DecoderServiceHost.ServiceReadyCallback, View.OnClickListener,
SelectionDelegate.SelectionObserver<PickerBitmap> {
// These values are written to logs. New enum values can be added, but existing // These values are written to logs. New enum values can be added, but existing
// enums must never be renumbered or deleted and reused. // enums must never be renumbered or deleted and reused.
private static final int ACTION_CANCEL = 0; private static final int ACTION_CANCEL = 0;
...@@ -189,6 +190,9 @@ public class PickerCategoryView extends RelativeLayout ...@@ -189,6 +190,9 @@ public class PickerCategoryView extends RelativeLayout
// The media controls to show with the video (play/pause, etc). // The media controls to show with the video (play/pause, etc).
private MediaController mMediaController; private MediaController mMediaController;
// The Zoom (floating action) button.
private ImageView mZoom;
/** /**
* @param context The context to use. * @param context The context to use.
* @param multiSelectionAllowed Whether to allow the user to select more than one image. * @param multiSelectionAllowed Whether to allow the user to select more than one image.
...@@ -204,6 +208,9 @@ public class PickerCategoryView extends RelativeLayout ...@@ -204,6 +208,9 @@ public class PickerCategoryView extends RelativeLayout
mDecoderServiceHost.bind(context); mDecoderServiceHost.bind(context);
mSelectionDelegate = new SelectionDelegate<PickerBitmap>(); mSelectionDelegate = new SelectionDelegate<PickerBitmap>();
if (ChromeFeatureList.isEnabled(ChromeFeatureList.PHOTO_PICKER_ZOOM)) {
mSelectionDelegate.addObserver(this);
}
if (!multiSelectionAllowed) mSelectionDelegate.setSingleSelectionMode(); if (!multiSelectionAllowed) mSelectionDelegate.setSingleSelectionMode();
View root = LayoutInflater.from(context).inflate(R.layout.photo_picker_dialog, this); View root = LayoutInflater.from(context).inflate(R.layout.photo_picker_dialog, this);
...@@ -222,12 +229,7 @@ public class PickerCategoryView extends RelativeLayout ...@@ -222,12 +229,7 @@ public class PickerCategoryView extends RelativeLayout
Button doneButton = (Button) toolbar.findViewById(R.id.done); Button doneButton = (Button) toolbar.findViewById(R.id.done);
doneButton.setOnClickListener(this); doneButton.setOnClickListener(this);
mVideoView = findViewById(R.id.video_player); mVideoView = findViewById(R.id.video_player);
mZoom = findViewById(R.id.zoom);
if (ChromeFeatureList.isEnabled(ChromeFeatureList.PHOTO_PICKER_ZOOM)) {
ImageView zoom = findViewById(R.id.zoom);
zoom.setVisibility(View.VISIBLE);
zoom.setOnClickListener(this);
}
calculateGridMetrics(); calculateGridMetrics();
...@@ -387,6 +389,20 @@ public class PickerCategoryView extends RelativeLayout ...@@ -387,6 +389,20 @@ public class PickerCategoryView extends RelativeLayout
} }
} }
// SelectionDelegate.SelectionObserver:
@Override
public void onSelectionStateChange(List<PickerBitmap> selectedItems) {
if (!ChromeFeatureList.isEnabled(ChromeFeatureList.PHOTO_PICKER_ZOOM)) {
return;
}
if (mZoom.getVisibility() != View.VISIBLE) {
mZoom.setVisibility(View.VISIBLE);
mZoom.setOnClickListener(this);
}
}
// OnClickListener: // OnClickListener:
@Override @Override
...@@ -395,7 +411,9 @@ public class PickerCategoryView extends RelativeLayout ...@@ -395,7 +411,9 @@ public class PickerCategoryView extends RelativeLayout
if (id == R.id.done) { if (id == R.id.done) {
notifyPhotosSelected(); notifyPhotosSelected();
} else if (id == R.id.zoom) { } else if (id == R.id.zoom) {
if (!mZoomSwitchingInEffect) {
flipZoomMode(); flipZoomMode();
}
} else if (id == R.id.close) { } else if (id == R.id.close) {
stopVideo(); stopVideo();
} else { } else {
...@@ -424,15 +442,18 @@ public class PickerCategoryView extends RelativeLayout ...@@ -424,15 +442,18 @@ public class PickerCategoryView extends RelativeLayout
mMagnifyingMode = !mMagnifyingMode; mMagnifyingMode = !mMagnifyingMode;
ImageView zoom = findViewById(R.id.zoom);
if (mMagnifyingMode) { if (mMagnifyingMode) {
zoom.setImageResource(R.drawable.zoom_out); mZoom.setImageResource(R.drawable.zoom_out);
} else { } else {
zoom.setImageResource(R.drawable.zoom_in); mZoom.setImageResource(R.drawable.zoom_in);
} }
calculateGridMetrics(); calculateGridMetrics();
if (!mMagnifyingMode) {
getFullScreenBitmaps().evictAll();
}
mZoomSwitchingInEffect = true; mZoomSwitchingInEffect = true;
ChangeBounds transition = new ChangeBounds(); ChangeBounds transition = new ChangeBounds();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment