Commit c1dab961 authored by Finnur Thorarinsson's avatar Finnur Thorarinsson Committed by Commit Bot

[Android] Photo Picker: Handle orientation better in video player.

Bug: 895776, 656015
Change-Id: Ide9f2e54ea68f6f93d62bd7d2beaabb9bb7954c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2015100
Commit-Queue: Finnur Thorarinsson <finnur@chromium.org>
Auto-Submit: Finnur Thorarinsson <finnur@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734423}
parent 7186bcef
......@@ -35,6 +35,7 @@ import android.widget.VideoView;
import androidx.annotation.VisibleForTesting;
import org.chromium.base.DiscardableReferencePool.DiscardableReference;
import org.chromium.base.ThreadUtils;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.task.AsyncTask;
import org.chromium.base.task.PostTask;
......@@ -319,6 +320,13 @@ public class PickerCategoryView extends RelativeLayout
mPickerAdapter.notifyDataSetChanged();
mRecyclerView.requestLayout();
}
if (mVideoControls.getVisibility() != View.GONE) {
// When configuration changes, the video overlay controls need to be synced to the new
// video size. Post a task, so that size adjustments happen after layout of the video
// controls has completed.
ThreadUtils.postOnUiThread(() -> { syncOverlayControlsSize(); });
}
}
/**
......@@ -352,11 +360,7 @@ public class PickerCategoryView extends RelativeLayout
startVideoPlayback();
mMediaPlayer.setOnVideoSizeChangedListener(
(MediaPlayer player, int width, int height) -> {
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
mVideoView.getMeasuredWidth(), mVideoView.getMeasuredHeight());
mVideoControls.setLayoutParams(params);
});
(MediaPlayer player, int width, int height) -> { syncOverlayControlsSize(); });
if (sProgressCallback != null) {
mMediaPlayer.setOnInfoListener((MediaPlayer player, int what, int extra) -> {
......@@ -910,6 +914,12 @@ public class PickerCategoryView extends RelativeLayout
}
}
private void syncOverlayControlsSize() {
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
mVideoView.getMeasuredWidth(), mVideoView.getMeasuredHeight());
mVideoControls.setLayoutParams(params);
}
private void toggleMute() {
mAudioOn = !mAudioOn;
if (mAudioOn) {
......
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