Mini player slide to botom fix, buttons size fix

This commit is contained in:
Avently 2020-07-14 21:52:55 +03:00
parent d8f7db4715
commit 08412d6108
4 changed files with 28 additions and 27 deletions

View File

@ -2245,14 +2245,16 @@ public class VideoDetailFragment
private void setOverlayLook(final AppBarLayout appBar,
final AppBarLayout.Behavior behavior,
final float slideOffset) {
if (behavior != null) {
overlay.setAlpha(Math.min(MAX_OVERLAY_ALPHA, 1 - slideOffset));
// These numbers are not special. They just do a cool transition
behavior.setTopAndBottomOffset(
(int) (-thumbnailImageView.getHeight() * 2 * (1 - slideOffset) / 3));
appBar.requestLayout();
// SlideOffset < 0 when mini player is about to close via swipe.
// Stop animation in this case
if (behavior == null || slideOffset < 0) {
return;
}
overlay.setAlpha(Math.min(MAX_OVERLAY_ALPHA, 1 - slideOffset));
// These numbers are not special. They just do a cool transition
behavior.setTopAndBottomOffset(
(int) (-thumbnailImageView.getHeight() * 2 * (1 - slideOffset) / 3));
appBar.requestLayout();
}
private void setOverlayElementsClickable(final boolean enable) {

View File

@ -106,7 +106,7 @@ import java.util.List;
import static android.content.Context.WINDOW_SERVICE;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static org.schabi.newpipe.player.BackgroundPlayer.ACTION_CLOSE;
import static org.schabi.newpipe.player.MainPlayer.ACTION_CLOSE;
import static org.schabi.newpipe.player.MainPlayer.ACTION_FAST_FORWARD;
import static org.schabi.newpipe.player.MainPlayer.ACTION_FAST_REWIND;
import static org.schabi.newpipe.player.MainPlayer.ACTION_OPEN_CONTROLS;
@ -376,12 +376,7 @@ public class VideoPlayerImpl extends VideoPlayer
moreOptionsButton.setImageDrawable(service.getResources().getDrawable(
R.drawable.ic_expand_more_white_24dp));
shareButton.setVisibility(View.VISIBLE);
final boolean supportedByKore = playQueue != null
&& playQueue.getItem() != null
&& KoreUtil.isServiceSupportedByKore(playQueue.getItem().getServiceId());
final boolean kodiEnabled = defaultPreferences.getBoolean(
service.getString(R.string.show_play_with_kodi_key), false);
playWithKodi.setVisibility(kodiEnabled && supportedByKore ? View.VISIBLE : View.GONE);
showHideKodiButton();
openInBrowser.setVisibility(View.VISIBLE);
muteButton.setVisibility(View.VISIBLE);
playerCloseButton.setVisibility(isFullscreen ? View.GONE : View.VISIBLE);
@ -418,11 +413,8 @@ public class VideoPlayerImpl extends VideoPlayer
buttonsPadding, buttonsPadding, buttonsPadding, buttonsPadding);
getPlaybackSpeedTextView().setPadding(
buttonsPadding, buttonsPadding, buttonsPadding, buttonsPadding);
getQualityTextView().setPadding(
buttonsPadding, buttonsPadding, buttonsPadding, buttonsPadding);
getCaptionTextView().setPadding(
buttonsPadding, buttonsPadding, buttonsPadding, buttonsPadding);
getQualityTextView().setMinimumWidth(0);
getPlaybackSpeedTextView().setMinimumWidth(0);
} else if (videoPlayerSelected()) {
final int buttonsMinWidth = service.getResources()
@ -440,7 +432,6 @@ public class VideoPlayerImpl extends VideoPlayer
buttonsPadding, buttonsPadding, buttonsPadding, buttonsPadding);
getPlaybackSpeedTextView().setPadding(
buttonsPadding, buttonsPadding, buttonsPadding, buttonsPadding);
getQualityTextView().setMinimumWidth(buttonsMinWidth);
getPlaybackSpeedTextView().setMinimumWidth(buttonsMinWidth);
getCaptionTextView().setPadding(
buttonsPadding, buttonsPadding, buttonsPadding, buttonsPadding);
@ -615,12 +606,7 @@ public class VideoPlayerImpl extends VideoPlayer
protected void onMetadataChanged(@NonNull final MediaSourceTag tag) {
super.onMetadataChanged(tag);
// show kodi button if it supports the current service and it is enabled in settings
final boolean showKodiButton =
KoreUtil.isServiceSupportedByKore(tag.getMetadata().getServiceId())
&& PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(context.getString(R.string.show_play_with_kodi_key), false);
playWithKodi.setVisibility(showKodiButton ? View.VISIBLE : View.GONE);
showHideKodiButton();
titleTextView.setText(tag.getMetadata().getName());
channelTextView.setText(tag.getMetadata().getUploaderName());
@ -920,6 +906,18 @@ public class VideoPlayerImpl extends VideoPlayer
getCurrentMetadata().getMetadata().getOriginalUrl());
}
private void showHideKodiButton() {
final boolean kodiEnabled = defaultPreferences.getBoolean(
service.getString(R.string.show_play_with_kodi_key), false);
// show kodi button if it supports the current service and it is enabled in settings
final boolean showKodiButton = playQueue != null && playQueue.getItem() != null
&& KoreUtil.isServiceSupportedByKore(playQueue.getItem().getServiceId())
&& PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(context.getString(R.string.show_play_with_kodi_key), false);
playWithKodi.setVisibility(videoPlayerSelected() && kodiEnabled && showKodiButton
? View.VISIBLE : View.GONE);
}
private static void showInstallKoreDialog(final Context context) {
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage(R.string.kore_not_found)

View File

@ -218,10 +218,10 @@
<Button
android:id="@+id/qualityTextView"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="50dp"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:paddingTop="@dimen/player_main_buttons_padding"
android:paddingBottom="@dimen/player_main_buttons_padding"
android:minWidth="0dp"
android:padding="@dimen/player_main_buttons_padding"
android:layout_marginEnd="8dp"
android:gravity="center"
android:text="720p"

View File

@ -223,6 +223,7 @@
android:id="@+id/qualityTextView"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:minWidth="0dp"
android:padding="@dimen/player_main_buttons_padding"
android:layout_marginEnd="8dp"
android:gravity="center"