kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fade out video player controls on playback.
2 second delay, cancelable if the video is paused or finished.main
rodzic
c218e22566
commit
af89d85696
|
@ -98,6 +98,8 @@ public abstract class MediaPreviewFragment extends Fragment {
|
||||||
boolean singleTapOnMedia();
|
boolean singleTapOnMedia();
|
||||||
void onMediaNotAvailable();
|
void onMediaNotAvailable();
|
||||||
void onMediaReady();
|
void onMediaReady();
|
||||||
|
void onPlaying();
|
||||||
|
void onStopped();
|
||||||
default @Nullable VideoControlsDelegate getVideoControlsDelegate() {
|
default @Nullable VideoControlsDelegate getVideoControlsDelegate() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ import org.thoughtcrime.securesms.mms.PartAuthority
|
||||||
import org.thoughtcrime.securesms.permissions.Permissions
|
import org.thoughtcrime.securesms.permissions.Permissions
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient
|
import org.thoughtcrime.securesms.recipients.Recipient
|
||||||
import org.thoughtcrime.securesms.util.DateUtils
|
import org.thoughtcrime.securesms.util.DateUtils
|
||||||
|
import org.thoughtcrime.securesms.util.Debouncer
|
||||||
import org.thoughtcrime.securesms.util.FullscreenHelper
|
import org.thoughtcrime.securesms.util.FullscreenHelper
|
||||||
import org.thoughtcrime.securesms.util.LifecycleDisposable
|
import org.thoughtcrime.securesms.util.LifecycleDisposable
|
||||||
import org.thoughtcrime.securesms.util.MediaUtil
|
import org.thoughtcrime.securesms.util.MediaUtil
|
||||||
|
@ -49,6 +50,7 @@ import org.thoughtcrime.securesms.util.StorageUtil
|
||||||
import org.thoughtcrime.securesms.util.ViewUtil
|
import org.thoughtcrime.securesms.util.ViewUtil
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import java.util.Optional
|
import java.util.Optional
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), MediaPreviewFragment.Events {
|
class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), MediaPreviewFragment.Events {
|
||||||
private val TAG = Log.tag(MediaPreviewV2Fragment::class.java)
|
private val TAG = Log.tag(MediaPreviewV2Fragment::class.java)
|
||||||
|
@ -56,6 +58,8 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
||||||
private val lifecycleDisposable = LifecycleDisposable()
|
private val lifecycleDisposable = LifecycleDisposable()
|
||||||
private val binding by ViewBinderDelegate(FragmentMediaPreviewV2Binding::bind)
|
private val binding by ViewBinderDelegate(FragmentMediaPreviewV2Binding::bind)
|
||||||
private val viewModel: MediaPreviewV2ViewModel by viewModels()
|
private val viewModel: MediaPreviewV2ViewModel by viewModels()
|
||||||
|
private val debouncer = Debouncer(2, TimeUnit.SECONDS)
|
||||||
|
|
||||||
|
|
||||||
private lateinit var fullscreenHelper: FullscreenHelper
|
private lateinit var fullscreenHelper: FullscreenHelper
|
||||||
|
|
||||||
|
@ -337,6 +341,14 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
||||||
viewModel.setMediaReady()
|
viewModel.setMediaReady()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onPlaying() {
|
||||||
|
debouncer.publish { fullscreenHelper.hideSystemUI() }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStopped() {
|
||||||
|
debouncer.clear()
|
||||||
|
}
|
||||||
|
|
||||||
private fun forward(mediaItem: MediaDatabase.MediaRecord) {
|
private fun forward(mediaItem: MediaDatabase.MediaRecord) {
|
||||||
val attachment = mediaItem.attachment
|
val attachment = mediaItem.attachment
|
||||||
val uri = attachment?.uri
|
val uri = attachment?.uri
|
||||||
|
|
|
@ -74,10 +74,12 @@ public final class VideoMediaPreviewFragment extends MediaPreviewFragment {
|
||||||
if (!isVideoGif && activity instanceof VoiceNoteMediaControllerOwner) {
|
if (!isVideoGif && activity instanceof VoiceNoteMediaControllerOwner) {
|
||||||
((VoiceNoteMediaControllerOwner) activity).getVoiceNoteMediaController().pausePlayback();
|
((VoiceNoteMediaControllerOwner) activity).getVoiceNoteMediaController().pausePlayback();
|
||||||
}
|
}
|
||||||
|
events.onPlaying();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStopped() {
|
public void onStopped() {
|
||||||
|
events.onStopped();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -107,7 +107,11 @@ public class VideoPlayer extends FrameLayout {
|
||||||
switch (playbackState) {
|
switch (playbackState) {
|
||||||
case Player.STATE_READY:
|
case Player.STATE_READY:
|
||||||
playerCallback.onReady();
|
playerCallback.onReady();
|
||||||
if (playWhenReady) playerCallback.onPlaying();
|
if (playWhenReady) {
|
||||||
|
playerCallback.onPlaying();
|
||||||
|
} else {
|
||||||
|
playerCallback.onStopped();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Player.STATE_ENDED:
|
case Player.STATE_ENDED:
|
||||||
playerCallback.onStopped();
|
playerCallback.onStopped();
|
||||||
|
|
Ładowanie…
Reference in New Issue