mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-22 23:17:00 +00:00
Implemented share button in MainVideoPlayer
Android Studio also decided to change the indentation of some lines
This commit is contained in:
parent
8eead9fda2
commit
40957c445f
@ -75,6 +75,7 @@ import org.schabi.newpipe.util.AnimationUtils;
|
|||||||
import org.schabi.newpipe.util.ListHelper;
|
import org.schabi.newpipe.util.ListHelper;
|
||||||
import org.schabi.newpipe.util.NavigationHelper;
|
import org.schabi.newpipe.util.NavigationHelper;
|
||||||
import org.schabi.newpipe.util.PermissionHelper;
|
import org.schabi.newpipe.util.PermissionHelper;
|
||||||
|
import org.schabi.newpipe.util.ShareUtils;
|
||||||
import org.schabi.newpipe.util.StateSaver;
|
import org.schabi.newpipe.util.StateSaver;
|
||||||
import org.schabi.newpipe.util.ThemeHelper;
|
import org.schabi.newpipe.util.ThemeHelper;
|
||||||
|
|
||||||
@ -283,8 +284,8 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||||||
if (playerImpl != null && playerImpl.queueVisible) return;
|
if (playerImpl != null && playerImpl.queueVisible) return;
|
||||||
|
|
||||||
final int visibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
final int visibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
|
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
@ColorInt final int systenUiColor =
|
@ColorInt final int systenUiColor =
|
||||||
@ -402,6 +403,7 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||||||
private boolean queueVisible;
|
private boolean queueVisible;
|
||||||
|
|
||||||
private ImageButton moreOptionsButton;
|
private ImageButton moreOptionsButton;
|
||||||
|
private ImageButton shareButton;
|
||||||
private ImageButton toggleOrientationButton;
|
private ImageButton toggleOrientationButton;
|
||||||
private ImageButton switchPopupButton;
|
private ImageButton switchPopupButton;
|
||||||
private ImageButton switchBackgroundButton;
|
private ImageButton switchBackgroundButton;
|
||||||
@ -436,6 +438,7 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||||||
|
|
||||||
this.moreOptionsButton = rootView.findViewById(R.id.moreOptionsButton);
|
this.moreOptionsButton = rootView.findViewById(R.id.moreOptionsButton);
|
||||||
this.secondaryControls = rootView.findViewById(R.id.secondaryControls);
|
this.secondaryControls = rootView.findViewById(R.id.secondaryControls);
|
||||||
|
this.shareButton = rootView.findViewById(R.id.share);
|
||||||
this.toggleOrientationButton = rootView.findViewById(R.id.toggleOrientation);
|
this.toggleOrientationButton = rootView.findViewById(R.id.toggleOrientation);
|
||||||
this.switchBackgroundButton = rootView.findViewById(R.id.switchBackground);
|
this.switchBackgroundButton = rootView.findViewById(R.id.switchBackground);
|
||||||
this.switchPopupButton = rootView.findViewById(R.id.switchPopup);
|
this.switchPopupButton = rootView.findViewById(R.id.switchPopup);
|
||||||
@ -481,6 +484,7 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||||||
playNextButton.setOnClickListener(this);
|
playNextButton.setOnClickListener(this);
|
||||||
|
|
||||||
moreOptionsButton.setOnClickListener(this);
|
moreOptionsButton.setOnClickListener(this);
|
||||||
|
shareButton.setOnClickListener(this);
|
||||||
toggleOrientationButton.setOnClickListener(this);
|
toggleOrientationButton.setOnClickListener(this);
|
||||||
switchBackgroundButton.setOnClickListener(this);
|
switchBackgroundButton.setOnClickListener(this);
|
||||||
switchPopupButton.setOnClickListener(this);
|
switchPopupButton.setOnClickListener(this);
|
||||||
@ -631,6 +635,9 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||||||
} else if (v.getId() == moreOptionsButton.getId()) {
|
} else if (v.getId() == moreOptionsButton.getId()) {
|
||||||
onMoreOptionsClicked();
|
onMoreOptionsClicked();
|
||||||
|
|
||||||
|
} else if (v.getId() == shareButton.getId()) {
|
||||||
|
onShareClicked();
|
||||||
|
|
||||||
} else if (v.getId() == toggleOrientationButton.getId()) {
|
} else if (v.getId() == toggleOrientationButton.getId()) {
|
||||||
onScreenRotationClicked();
|
onScreenRotationClicked();
|
||||||
|
|
||||||
@ -684,6 +691,13 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||||||
showControls(DEFAULT_CONTROLS_DURATION);
|
showControls(DEFAULT_CONTROLS_DURATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onShareClicked() {
|
||||||
|
// share video at the current time (youtube.com/watch?v=ID&t=SECONDS)
|
||||||
|
ShareUtils.shareUrl(MainVideoPlayer.this,
|
||||||
|
playerImpl.getVideoTitle(),
|
||||||
|
playerImpl.getVideoUrl() + "&t=" + String.valueOf(playerImpl.getPlaybackSeekBar().getProgress()/1000));
|
||||||
|
}
|
||||||
|
|
||||||
private void onScreenRotationClicked() {
|
private void onScreenRotationClicked() {
|
||||||
if (DEBUG) Log.d(TAG, "onScreenRotationClicked() called");
|
if (DEBUG) Log.d(TAG, "onScreenRotationClicked() called");
|
||||||
toggleOrientation();
|
toggleOrientation();
|
||||||
@ -847,8 +861,8 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||||||
if (DEBUG) Log.d(TAG, "hideControls() called with: delay = [" + delay + "]");
|
if (DEBUG) Log.d(TAG, "hideControls() called with: delay = [" + delay + "]");
|
||||||
getControlsVisibilityHandler().removeCallbacksAndMessages(null);
|
getControlsVisibilityHandler().removeCallbacksAndMessages(null);
|
||||||
getControlsVisibilityHandler().postDelayed(() ->
|
getControlsVisibilityHandler().postDelayed(() ->
|
||||||
animateView(getControlsRoot(), false, duration, 0,
|
animateView(getControlsRoot(), false, duration, 0,
|
||||||
MainVideoPlayer.this::hideSystemUi),
|
MainVideoPlayer.this::hideSystemUi),
|
||||||
/*delayMillis=*/delay
|
/*delayMillis=*/delay
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1052,9 +1066,9 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||||||
|
|
||||||
final int resId =
|
final int resId =
|
||||||
currentProgressPercent <= 0 ? R.drawable.ic_volume_off_white_72dp
|
currentProgressPercent <= 0 ? R.drawable.ic_volume_off_white_72dp
|
||||||
: currentProgressPercent < 0.25 ? R.drawable.ic_volume_mute_white_72dp
|
: currentProgressPercent < 0.25 ? R.drawable.ic_volume_mute_white_72dp
|
||||||
: currentProgressPercent < 0.75 ? R.drawable.ic_volume_down_white_72dp
|
: currentProgressPercent < 0.75 ? R.drawable.ic_volume_down_white_72dp
|
||||||
: R.drawable.ic_volume_up_white_72dp;
|
: R.drawable.ic_volume_up_white_72dp;
|
||||||
|
|
||||||
playerImpl.getVolumeImageView().setImageDrawable(
|
playerImpl.getVolumeImageView().setImageDrawable(
|
||||||
AppCompatResources.getDrawable(getApplicationContext(), resId)
|
AppCompatResources.getDrawable(getApplicationContext(), resId)
|
||||||
@ -1078,8 +1092,8 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||||||
|
|
||||||
final int resId =
|
final int resId =
|
||||||
currentProgressPercent < 0.25 ? R.drawable.ic_brightness_low_white_72dp
|
currentProgressPercent < 0.25 ? R.drawable.ic_brightness_low_white_72dp
|
||||||
: currentProgressPercent < 0.75 ? R.drawable.ic_brightness_medium_white_72dp
|
: currentProgressPercent < 0.75 ? R.drawable.ic_brightness_medium_white_72dp
|
||||||
: R.drawable.ic_brightness_high_white_72dp;
|
: R.drawable.ic_brightness_high_white_72dp;
|
||||||
|
|
||||||
playerImpl.getBrightnessImageView().setImageDrawable(
|
playerImpl.getBrightnessImageView().setImageDrawable(
|
||||||
AppCompatResources.getDrawable(getApplicationContext(), resId)
|
AppCompatResources.getDrawable(getApplicationContext(), resId)
|
||||||
|
Loading…
Reference in New Issue
Block a user