mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 19:48:33 +00:00
Add tap to pause to video trimming editor.
This commit is contained in:
parent
28bbfd88b2
commit
5038210d78
@ -38,7 +38,7 @@ public class MediaSendVideoFragment extends Fragment implements VideoEditorHud.E
|
|||||||
private Data data = new Data();
|
private Data data = new Data();
|
||||||
private Uri uri;
|
private Uri uri;
|
||||||
private VideoPlayer player;
|
private VideoPlayer player;
|
||||||
private VideoEditorHud hud;
|
@Nullable private VideoEditorHud hud;
|
||||||
private Runnable updatePosition;
|
private Runnable updatePosition;
|
||||||
|
|
||||||
public static MediaSendVideoFragment newInstance(@NonNull Uri uri) {
|
public static MediaSendVideoFragment newInstance(@NonNull Uri uri) {
|
||||||
@ -92,16 +92,21 @@ public class MediaSendVideoFragment extends Fragment implements VideoEditorHud.E
|
|||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player.setOnClickListener(v -> {
|
||||||
|
player.pause();
|
||||||
|
hud.showPlayButton();
|
||||||
|
});
|
||||||
|
|
||||||
player.setPlayerCallback(new VideoPlayer.PlayerCallback() {
|
player.setPlayerCallback(new VideoPlayer.PlayerCallback() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlaying() {
|
public void onPlaying() {
|
||||||
hud.playing();
|
hud.fadePlayButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStopped() {
|
public void onStopped() {
|
||||||
hud.stopped();
|
hud.showPlayButton();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -200,6 +205,9 @@ public class MediaSendVideoFragment extends Fragment implements VideoEditorHud.E
|
|||||||
public void notifyHidden() {
|
public void notifyHidden() {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.pause();
|
player.pause();
|
||||||
|
if (hud != null) {
|
||||||
|
hud.showPlayButton();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,6 +215,10 @@ public class MediaSendVideoFragment extends Fragment implements VideoEditorHud.E
|
|||||||
public void onEditVideoDuration(long totalDurationUs, long startTimeUs, long endTimeUs, boolean fromEdited, boolean editingComplete) {
|
public void onEditVideoDuration(long totalDurationUs, long startTimeUs, long endTimeUs, boolean fromEdited, boolean editingComplete) {
|
||||||
controller.onTouchEventsNeeded(!editingComplete);
|
controller.onTouchEventsNeeded(!editingComplete);
|
||||||
|
|
||||||
|
if (hud != null) {
|
||||||
|
hud.hidePlayButton();
|
||||||
|
}
|
||||||
|
|
||||||
boolean wasEdited = data.durationEdited;
|
boolean wasEdited = data.durationEdited;
|
||||||
boolean durationEdited = startTimeUs > 0 || endTimeUs < totalDurationUs;
|
boolean durationEdited = startTimeUs > 0 || endTimeUs < totalDurationUs;
|
||||||
|
|
||||||
@ -241,7 +253,7 @@ public class MediaSendVideoFragment extends Fragment implements VideoEditorHud.E
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlay() {
|
public void onPlay() {
|
||||||
player.playFromStart();
|
player.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package org.thoughtcrime.securesms.scribbles;
|
package org.thoughtcrime.securesms.scribbles;
|
||||||
|
|
||||||
|
import android.animation.Animator;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.animation.OvershootInterpolator;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -101,12 +103,43 @@ public final class VideoEditorHud extends LinearLayout {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playing() {
|
public void showPlayButton() {
|
||||||
playOverlay.setVisibility(INVISIBLE);
|
playOverlay.setVisibility(VISIBLE);
|
||||||
|
playOverlay.animate()
|
||||||
|
.setListener(null)
|
||||||
|
.alpha(1)
|
||||||
|
.scaleX(1).scaleY(1)
|
||||||
|
.setInterpolator(new OvershootInterpolator())
|
||||||
|
.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopped() {
|
public void fadePlayButton() {
|
||||||
playOverlay.setVisibility(VISIBLE);
|
playOverlay.animate()
|
||||||
|
.setListener(new Animator.AnimatorListener() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animator animation) {
|
||||||
|
playOverlay.setVisibility(GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationStart(Animator animation) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationCancel(Animator animation) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationRepeat(Animator animation) {}
|
||||||
|
})
|
||||||
|
.alpha(0)
|
||||||
|
.scaleX(0.8f).scaleY(0.8f)
|
||||||
|
.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hidePlayButton() {
|
||||||
|
playOverlay.setVisibility(GONE);
|
||||||
|
playOverlay.setAlpha(0);
|
||||||
|
playOverlay.setScaleX(0.8f);
|
||||||
|
playOverlay.setScaleY(0.8f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(api = 23)
|
@RequiresApi(api = 23)
|
||||||
|
@ -52,7 +52,7 @@ public final class FeatureFlags {
|
|||||||
private static final String PINS_FOR_ALL = "android.pinsForAll";
|
private static final String PINS_FOR_ALL = "android.pinsForAll";
|
||||||
private static final String PINS_MEGAPHONE_KILL_SWITCH = "android.pinsMegaphoneKillSwitch";
|
private static final String PINS_MEGAPHONE_KILL_SWITCH = "android.pinsMegaphoneKillSwitch";
|
||||||
private static final String PROFILE_NAMES_MEGAPHONE = "android.profileNamesMegaphone";
|
private static final String PROFILE_NAMES_MEGAPHONE = "android.profileNamesMegaphone";
|
||||||
private static final String VIDEO_TRIMMING = "android.videoTrimming";
|
private static final String VIDEO_TRIMMING = "android.videoTrimming.2";
|
||||||
private static final String STORAGE_SERVICE = "android.storageService.2";
|
private static final String STORAGE_SERVICE = "android.storageService.2";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -216,12 +216,17 @@ public class VideoPlayer extends FrameLayout {
|
|||||||
this.playerCallback = playerCallback;
|
this.playerCallback = playerCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playFromStart() {
|
/**
|
||||||
|
* Resumes a paused video, or restarts if at end of video.
|
||||||
|
*/
|
||||||
|
public void play() {
|
||||||
if (exoPlayer != null) {
|
if (exoPlayer != null) {
|
||||||
exoPlayer.setPlayWhenReady(true);
|
exoPlayer.setPlayWhenReady(true);
|
||||||
|
if (exoPlayer.getCurrentPosition() >= exoPlayer.getDuration()) {
|
||||||
exoPlayer.seekTo(0);
|
exoPlayer.seekTo(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class ExoPlayerListener extends Player.DefaultEventListener {
|
private static class ExoPlayerListener extends Player.DefaultEventListener {
|
||||||
private final Window window;
|
private final Window window;
|
||||||
|
@ -33,14 +33,14 @@
|
|||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
android:alpha="0"
|
||||||
android:background="@drawable/circle_white"
|
android:background="@drawable/circle_white"
|
||||||
android:longClickable="false"
|
android:longClickable="false"
|
||||||
android:visibility="invisible"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:visibility="visible">
|
tools:alpha="1">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="19dp"
|
android:layout_width="19dp"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user