Optimizations and fixes of rare situations
- popup after orientation change had incorrect allowed bounds for swiping - popup could cause a crash after many quick switches to main player and back - better method of setting fullscreen/non-fullscreen layout using thumbnail view. Also fixed thumbnail height in fullscreen layout - global settings observer didn't work when a user closed a service manually via notification because it checked for service existing - app will now exits from fullscreen mode when the user switches players - playQueuePanel has visibility "gone" by default (not "invisible") because "invisible" can cause problems
This commit is contained in:
parent
c45514b989
commit
fc9b63298c
5 changed files with 22 additions and 21 deletions
|
@ -1040,6 +1040,9 @@ public class VideoDetailFragment
|
||||||
boolean useExternalAudioPlayer = PreferenceManager.getDefaultSharedPreferences(activity)
|
boolean useExternalAudioPlayer = PreferenceManager.getDefaultSharedPreferences(activity)
|
||||||
.getBoolean(activity.getString(R.string.use_external_audio_player_key), false);
|
.getBoolean(activity.getString(R.string.use_external_audio_player_key), false);
|
||||||
|
|
||||||
|
// If a user watched video inside fullscreen mode and than chose another player return to non-fullscreen mode
|
||||||
|
if (player != null && player.isInFullscreen()) player.toggleFullscreen();
|
||||||
|
|
||||||
if (!useExternalAudioPlayer && android.os.Build.VERSION.SDK_INT >= 16) {
|
if (!useExternalAudioPlayer && android.os.Build.VERSION.SDK_INT >= 16) {
|
||||||
openNormalBackgroundPlayer(append);
|
openNormalBackgroundPlayer(append);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1056,6 +1059,9 @@ public class VideoDetailFragment
|
||||||
// See UI changes while remote playQueue changes
|
// See UI changes while remote playQueue changes
|
||||||
if (!bounded) startService(false);
|
if (!bounded) startService(false);
|
||||||
|
|
||||||
|
// If a user watched video inside fullscreen mode and than chose another player return to non-fullscreen mode
|
||||||
|
if (player != null && player.isInFullscreen()) player.toggleFullscreen();
|
||||||
|
|
||||||
PlayQueue queue = setupPlayQueueForIntent(append);
|
PlayQueue queue = setupPlayQueueForIntent(append);
|
||||||
if (append) {
|
if (append) {
|
||||||
NavigationHelper.enqueueOnPopupPlayer(activity, queue, false);
|
NavigationHelper.enqueueOnPopupPlayer(activity, queue, false);
|
||||||
|
@ -1181,17 +1187,7 @@ public class VideoDetailFragment
|
||||||
|
|
||||||
// Check if viewHolder already contains a child
|
// Check if viewHolder already contains a child
|
||||||
if (player.getRootView() != viewHolder) removeVideoPlayerView();
|
if (player.getRootView() != viewHolder) removeVideoPlayerView();
|
||||||
|
setHeightThumbnail();
|
||||||
final int newHeight;
|
|
||||||
if (player.isInFullscreen())
|
|
||||||
newHeight = activity.getWindow().getDecorView().getHeight();
|
|
||||||
else
|
|
||||||
newHeight = FrameLayout.LayoutParams.MATCH_PARENT;
|
|
||||||
|
|
||||||
if (viewHolder.getLayoutParams().height != newHeight) {
|
|
||||||
viewHolder.getLayoutParams().height = newHeight;
|
|
||||||
viewHolder.requestLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prevent from re-adding a view multiple times
|
// Prevent from re-adding a view multiple times
|
||||||
if (player.getRootView().getParent() == null) viewHolder.addView(player.getRootView());
|
if (player.getRootView().getParent() == null) viewHolder.addView(player.getRootView());
|
||||||
|
@ -1242,9 +1238,15 @@ public class VideoDetailFragment
|
||||||
private void setHeightThumbnail() {
|
private void setHeightThumbnail() {
|
||||||
final DisplayMetrics metrics = getResources().getDisplayMetrics();
|
final DisplayMetrics metrics = getResources().getDisplayMetrics();
|
||||||
boolean isPortrait = metrics.heightPixels > metrics.widthPixels;
|
boolean isPortrait = metrics.heightPixels > metrics.widthPixels;
|
||||||
int height = isPortrait
|
|
||||||
|
int height;
|
||||||
|
if (player != null && player.isInFullscreen())
|
||||||
|
height = activity.getWindow().getDecorView().getHeight();
|
||||||
|
else
|
||||||
|
height = isPortrait
|
||||||
? (int) (metrics.widthPixels / (16.0f / 9.0f))
|
? (int) (metrics.widthPixels / (16.0f / 9.0f))
|
||||||
: (int) (metrics.heightPixels / 2f);
|
: (int) (metrics.heightPixels / 2f);;
|
||||||
|
|
||||||
thumbnailImageView.setLayoutParams(
|
thumbnailImageView.setLayoutParams(
|
||||||
new FrameLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, height));
|
new FrameLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, height));
|
||||||
thumbnailImageView.setMinimumHeight(height);
|
thumbnailImageView.setMinimumHeight(height);
|
||||||
|
@ -1334,8 +1336,6 @@ public class VideoDetailFragment
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSettingsChanged() {
|
public void onSettingsChanged() {
|
||||||
if (player == null) return;
|
|
||||||
|
|
||||||
if(!globalScreenOrientationLocked())
|
if(!globalScreenOrientationLocked())
|
||||||
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1329,7 +1329,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
public void updatePopupSize(int width, int height) {
|
public void updatePopupSize(int width, int height) {
|
||||||
if (DEBUG) Log.d(TAG, "updatePopupSize() called with: width = [" + width + "], height = [" + height + "]");
|
if (DEBUG) Log.d(TAG, "updatePopupSize() called with: width = [" + width + "], height = [" + height + "]");
|
||||||
|
|
||||||
if (popupLayoutParams == null || windowManager == null || !popupPlayerSelected() || getRootView().getParent() == null)
|
if (popupLayoutParams == null || windowManager == null || getParentActivity() != null || getRootView().getParent() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
width = (int) (width > maximumWidth ? maximumWidth : width < minimumWidth ? minimumWidth : width);
|
width = (int) (width > maximumWidth ? maximumWidth : width < minimumWidth ? minimumWidth : width);
|
||||||
|
@ -1347,7 +1347,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateWindowFlags(final int flags) {
|
private void updateWindowFlags(final int flags) {
|
||||||
if (popupLayoutParams == null || windowManager == null || !popupPlayerSelected() || getRootView().getParent() == null)
|
if (popupLayoutParams == null || windowManager == null || getParentActivity() != null || getRootView().getParent() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
popupLayoutParams.flags = flags;
|
popupLayoutParams.flags = flags;
|
||||||
|
|
|
@ -299,7 +299,8 @@ public class PlayerGestureListener extends GestureDetector.SimpleOnGestureListen
|
||||||
private boolean onDownInPopup(MotionEvent e) {
|
private boolean onDownInPopup(MotionEvent e) {
|
||||||
// Fix popup position when the user touch it, it may have the wrong one
|
// Fix popup position when the user touch it, it may have the wrong one
|
||||||
// because the soft input is visible (the draggable area is currently resized).
|
// because the soft input is visible (the draggable area is currently resized).
|
||||||
playerImpl.checkPopupPositionBounds(playerImpl.getCloseOverlayView().getWidth(), playerImpl.getCloseOverlayView().getHeight());
|
playerImpl.updateScreenSize();
|
||||||
|
playerImpl.checkPopupPositionBounds();
|
||||||
|
|
||||||
initialPopupX = playerImpl.getPopupLayoutParams().x;
|
initialPopupX = playerImpl.getPopupLayoutParams().x;
|
||||||
initialPopupY = playerImpl.getPopupLayoutParams().y;
|
initialPopupY = playerImpl.getPopupLayoutParams().y;
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:visibility="invisible"
|
android:visibility="gone"
|
||||||
android:background="?attr/queue_background_color"
|
android:background="?attr/queue_background_color"
|
||||||
tools:visibility="visible">
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
android:id="@+id/playQueuePanel"
|
android:id="@+id/playQueuePanel"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:visibility="invisible"
|
android:visibility="gone"
|
||||||
android:background="?attr/queue_background_color"
|
android:background="?attr/queue_background_color"
|
||||||
tools:visibility="visible">
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue