mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-05-29 04:50:19 +02:00
minimized player fixes
This commit is contained in:
parent
68eb0cc8f2
commit
13516087f2
@ -178,7 +178,7 @@ abstract class ContentFeedView<TFragment> : FeedView<TFragment, IPlatformContent
|
|||||||
): StaggeredGridLayoutManager {
|
): StaggeredGridLayoutManager {
|
||||||
val glmResults =
|
val glmResults =
|
||||||
StaggeredGridLayoutManager(
|
StaggeredGridLayoutManager(
|
||||||
if (resources.configuration.screenWidthDp >= resources.getDimension(R.dimen.landscape_threshold)) 2 else 1,
|
(resources.configuration.screenWidthDp / resources.getDimension(R.dimen.landscape_threshold)).toInt() + 1,
|
||||||
StaggeredGridLayoutManager.VERTICAL
|
StaggeredGridLayoutManager.VERTICAL
|
||||||
);
|
);
|
||||||
return glmResults
|
return glmResults
|
||||||
|
@ -180,14 +180,13 @@ abstract class FeedView<TFragment, TResult, TConverted, TPager, TViewHolder> : L
|
|||||||
if (firstVisibleItemPosition != RecyclerView.NO_POSITION) {
|
if (firstVisibleItemPosition != RecyclerView.NO_POSITION) {
|
||||||
val firstVisibleView = layoutManager.findViewByPosition(firstVisibleItemPosition)
|
val firstVisibleView = layoutManager.findViewByPosition(firstVisibleItemPosition)
|
||||||
val itemHeight = firstVisibleView?.height ?: 0
|
val itemHeight = firstVisibleView?.height ?: 0
|
||||||
val occupiedSpace = recyclerData.results.size * itemHeight
|
val occupiedSpace = recyclerData.results.size / recyclerData.layoutManager.spanCount * itemHeight
|
||||||
val recyclerViewHeight = _recyclerResults.height
|
val recyclerViewHeight = _recyclerResults.height
|
||||||
Logger.i(TAG, "ensureEnoughContentVisible loadNextPage occupiedSpace=$occupiedSpace recyclerViewHeight=$recyclerViewHeight")
|
Logger.i(TAG, "ensureEnoughContentVisible loadNextPage occupiedSpace=$occupiedSpace recyclerViewHeight=$recyclerViewHeight")
|
||||||
occupiedSpace >= recyclerViewHeight
|
occupiedSpace >= recyclerViewHeight
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Logger.i(TAG, "ensureEnoughContentVisible loadNextPage canScroll=$canScroll _automaticNextPageCounter=$_automaticNextPageCounter")
|
Logger.i(TAG, "ensureEnoughContentVisible loadNextPage canScroll=$canScroll _automaticNextPageCounter=$_automaticNextPageCounter")
|
||||||
if (!canScroll || filteredResults.isEmpty()) {
|
if (!canScroll || filteredResults.isEmpty()) {
|
||||||
@ -228,11 +227,7 @@ abstract class FeedView<TFragment, TResult, TConverted, TPager, TViewHolder> : L
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSpanCount() {
|
private fun updateSpanCount() {
|
||||||
if (resources.configuration.screenWidthDp >= resources.getDimension(R.dimen.landscape_threshold) && recyclerData.layoutManager.spanCount != 2) {
|
recyclerData.layoutManager.spanCount = (resources.configuration.screenWidthDp / resources.getDimension(R.dimen.landscape_threshold)).toInt() + 1
|
||||||
recyclerData.layoutManager.spanCount = 2
|
|
||||||
} else if (resources.configuration.screenWidthDp < resources.getDimension(R.dimen.landscape_threshold) && recyclerData.layoutManager.spanCount != 1) {
|
|
||||||
recyclerData.layoutManager.spanCount = 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration?) {
|
override fun onConfigurationChanged(newConfig: Configuration?) {
|
||||||
|
@ -4,6 +4,7 @@ import android.app.PictureInPictureParams
|
|||||||
import android.app.RemoteAction
|
import android.app.RemoteAction
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.res.Configuration
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
@ -164,6 +165,7 @@ import kotlinx.coroutines.withContext
|
|||||||
import userpackage.Protocol
|
import userpackage.Protocol
|
||||||
import java.time.OffsetDateTime
|
import java.time.OffsetDateTime
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
import kotlin.math.max
|
||||||
import kotlin.math.roundToLong
|
import kotlin.math.roundToLong
|
||||||
|
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
@ -2650,13 +2652,29 @@ class VideoDetailView : ConstraintLayout {
|
|||||||
if(_minimize_controls.isClickable != clickable)
|
if(_minimize_controls.isClickable != clickable)
|
||||||
_minimize_controls.isClickable = clickable;
|
_minimize_controls.isClickable = clickable;
|
||||||
}
|
}
|
||||||
fun setVideoMinimize(value : Float) {
|
|
||||||
val padRight = (resources.displayMetrics.widthPixels * 0.70 * value).toInt();
|
override fun onConfigurationChanged(newConfig: Configuration?) {
|
||||||
_player.setPadding(0, _player.paddingTop, padRight, 0);
|
super.onConfigurationChanged(newConfig)
|
||||||
_cast.setPadding(0, _cast.paddingTop, padRight, 0);
|
|
||||||
|
setVideoMinimize(_minimizeProgress)
|
||||||
}
|
}
|
||||||
fun setTopPadding(value : Float) {
|
|
||||||
_player.setPadding(0, value.toInt(), _player.paddingRight, 0);
|
fun setVideoMinimize(value: Float) {
|
||||||
|
val totalPaddingNeeded = value * max(
|
||||||
|
(resources.displayMetrics.widthPixels - resources.getDimension(R.dimen.minimized_player_max_width)).toInt(),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
val outerPadding = (totalPaddingNeeded / 2).toInt()
|
||||||
|
val padRight =
|
||||||
|
((resources.displayMetrics.widthPixels - totalPaddingNeeded) * 0.70 * value).toInt()
|
||||||
|
|
||||||
|
rootView.setPadding(outerPadding, 0, outerPadding, 0)
|
||||||
|
_player.setPadding(0, _player.paddingTop, padRight, 0)
|
||||||
|
_cast.setPadding(0, _cast.paddingTop, padRight, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setTopPadding(value: Float) {
|
||||||
|
_player.setPadding(_player.paddingLeft, value.toInt(), _player.paddingRight, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Tasks
|
//Tasks
|
||||||
|
@ -718,58 +718,72 @@ class FutoVideoPlayer : FutoVideoPlayerBase {
|
|||||||
|
|
||||||
//Sizing
|
//Sizing
|
||||||
@OptIn(UnstableApi::class)
|
@OptIn(UnstableApi::class)
|
||||||
fun fitHeight(videoSize : VideoSize? = null){
|
fun fitHeight(videoSize: VideoSize? = null) {
|
||||||
Logger.i(TAG, "Video Fit Height");
|
Logger.i(TAG, "Video Fit Height");
|
||||||
if(_originalBottomMargin != 0) {
|
if (_originalBottomMargin != 0) {
|
||||||
val layoutParams = _videoView.layoutParams as ConstraintLayout.LayoutParams;
|
val layoutParams = _videoView.layoutParams as ConstraintLayout.LayoutParams;
|
||||||
layoutParams.setMargins(0, 0, 0, _originalBottomMargin);
|
layoutParams.setMargins(0, 0, 0, _originalBottomMargin);
|
||||||
_videoView.layoutParams = layoutParams;
|
_videoView.layoutParams = layoutParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
var h = videoSize?.height ?: lastVideoSource?.height ?: exoPlayer?.player?.videoSize?.height ?: 0;
|
var h = videoSize?.height ?: lastVideoSource?.height ?: exoPlayer?.player?.videoSize?.height
|
||||||
var w = videoSize?.width ?: lastVideoSource?.width ?: exoPlayer?.player?.videoSize?.width ?: 0;
|
?: 0;
|
||||||
|
var w =
|
||||||
|
videoSize?.width ?: lastVideoSource?.width ?: exoPlayer?.player?.videoSize?.width ?: 0;
|
||||||
|
|
||||||
if(h == 0 && w == 0) {
|
if (h == 0 && w == 0) {
|
||||||
Logger.i(TAG, "UNKNOWN VIDEO FIT: (videoSize: ${videoSize != null}, player.videoSize: ${exoPlayer?.player?.videoSize != null})");
|
Logger.i(
|
||||||
|
TAG,
|
||||||
|
"UNKNOWN VIDEO FIT: (videoSize: ${videoSize != null}, player.videoSize: ${exoPlayer?.player?.videoSize != null})"
|
||||||
|
);
|
||||||
w = 1280;
|
w = 1280;
|
||||||
h = 720;
|
h = 720;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_lastSourceFit == null) {
|
||||||
if(_lastSourceFit == null){
|
|
||||||
val metrics = StateApp.instance.displayMetrics ?: resources.displayMetrics;
|
val metrics = StateApp.instance.displayMetrics ?: resources.displayMetrics;
|
||||||
|
|
||||||
val viewWidth = Math.min(metrics.widthPixels, metrics.heightPixels); //TODO: Get parent width. was this.width
|
val viewWidth = Math.min(
|
||||||
|
metrics.widthPixels,
|
||||||
|
metrics.heightPixels
|
||||||
|
); //TODO: Get parent width. was this.width
|
||||||
val deviceHeight = Math.max(metrics.widthPixels, metrics.heightPixels);
|
val deviceHeight = Math.max(metrics.widthPixels, metrics.heightPixels);
|
||||||
val maxHeight = deviceHeight * 0.4;
|
val maxHeight = deviceHeight * 0.4;
|
||||||
|
|
||||||
val determinedHeight = if(w > h)
|
val determinedHeight = if (w > h)
|
||||||
((h * (viewWidth.toDouble() / w)).toInt())
|
((h * (viewWidth.toDouble() / w)).toInt())
|
||||||
else
|
else
|
||||||
((h * (viewWidth.toDouble() / w)).toInt());
|
((h * (viewWidth.toDouble() / w)).toInt());
|
||||||
_lastSourceFit = determinedHeight;
|
_lastSourceFit = determinedHeight;
|
||||||
_lastSourceFit = Math.max(_lastSourceFit!!, 250);
|
_lastSourceFit = Math.max(_lastSourceFit!!, 250);
|
||||||
_lastSourceFit = Math.min(_lastSourceFit!!, maxHeight.toInt());
|
_lastSourceFit = Math.min(_lastSourceFit!!, maxHeight.toInt());
|
||||||
if((_lastSourceFit ?: 0) < 300 || (_lastSourceFit ?: 0) > viewWidth) {
|
if ((_lastSourceFit ?: 0) < 300 || (_lastSourceFit ?: 0) > viewWidth) {
|
||||||
Log.d(TAG, "WEIRD HEIGHT DETECTED: ${_lastSourceFit}, Width: ${w}, Height: ${h}, VWidth: ${viewWidth}");
|
Log.d(
|
||||||
|
TAG,
|
||||||
|
"WEIRD HEIGHT DETECTED: ${_lastSourceFit}, Width: ${w}, Height: ${h}, VWidth: ${viewWidth}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if(_lastSourceFit != determinedHeight)
|
|
||||||
_desiredResizeModePortrait = AspectRatioFrameLayout.RESIZE_MODE_FIT;
|
_desiredResizeModePortrait = AspectRatioFrameLayout.RESIZE_MODE_FIT;
|
||||||
else
|
|
||||||
_desiredResizeModePortrait = AspectRatioFrameLayout.RESIZE_MODE_ZOOM;
|
|
||||||
_videoView.resizeMode = _desiredResizeModePortrait
|
_videoView.resizeMode = _desiredResizeModePortrait
|
||||||
}
|
}
|
||||||
|
_videoView.resizeMode = _desiredResizeModePortrait
|
||||||
|
|
||||||
val marginBottom = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 7f, resources.displayMetrics).toInt();
|
val marginBottom =
|
||||||
|
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 7f, resources.displayMetrics)
|
||||||
|
.toInt();
|
||||||
val rootParams = LayoutParams(LayoutParams.MATCH_PARENT, _lastSourceFit!! + marginBottom)
|
val rootParams = LayoutParams(LayoutParams.MATCH_PARENT, _lastSourceFit!! + marginBottom)
|
||||||
rootParams.bottomMargin = marginBottom;
|
rootParams.bottomMargin = marginBottom;
|
||||||
_root.layoutParams = rootParams
|
_root.layoutParams = rootParams
|
||||||
isFitMode = true;
|
isFitMode = true;
|
||||||
}
|
}
|
||||||
fun fillHeight(){
|
|
||||||
|
@OptIn(UnstableApi::class)
|
||||||
|
fun fillHeight() {
|
||||||
Logger.i(TAG, "Video Fill Height");
|
Logger.i(TAG, "Video Fill Height");
|
||||||
val layoutParams = _videoView.layoutParams as ConstraintLayout.LayoutParams;
|
val layoutParams = _videoView.layoutParams as ConstraintLayout.LayoutParams;
|
||||||
_originalBottomMargin = if(layoutParams.bottomMargin > 0) layoutParams.bottomMargin else _originalBottomMargin;
|
_originalBottomMargin =
|
||||||
|
if (layoutParams.bottomMargin > 0) layoutParams.bottomMargin else _originalBottomMargin;
|
||||||
layoutParams.setMargins(0);
|
layoutParams.setMargins(0);
|
||||||
_videoView.layoutParams = layoutParams;
|
_videoView.layoutParams = layoutParams;
|
||||||
_videoView.invalidate();
|
_videoView.invalidate();
|
||||||
@ -777,6 +791,8 @@ class FutoVideoPlayer : FutoVideoPlayerBase {
|
|||||||
val rootParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
val rootParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
||||||
_root.layoutParams = rootParams;
|
_root.layoutParams = rootParams;
|
||||||
_root.invalidate();
|
_root.invalidate();
|
||||||
|
|
||||||
|
_videoView.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_ZOOM
|
||||||
isFitMode = false;
|
isFitMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<dimen name="video_view_right_padding"></dimen>
|
<dimen name="minimized_player_max_width">500dp</dimen>
|
||||||
<dimen name="app_bar_height">200dp</dimen>
|
<dimen name="app_bar_height">200dp</dimen>
|
||||||
<dimen name="landscape_threshold">300dp</dimen>
|
<dimen name="landscape_threshold">300dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user