Use context menu when selecting a message in chat.

This commit is contained in:
Rashad Sookram
2022-01-28 15:12:35 -05:00
committed by Cody Henthorne
parent d254d24d77
commit e4d43ade93
38 changed files with 1013 additions and 435 deletions

View File

@@ -51,4 +51,10 @@ public interface GiphyMp4Playable {
* Specifies whether the content can start playing.
*/
boolean canPlayContent();
/**
* Specifies whether the projection from {@link #getGiphyMp4PlayableProjection(ViewGroup)} should
* be used to project into a view.
*/
boolean shouldProjectContent();
}

View File

@@ -1,6 +1,7 @@
package org.thoughtcrime.securesms.giph.mp4;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -98,10 +99,18 @@ public final class GiphyMp4ProjectionPlayerHolder implements Player.Listener, De
container.setVisibility(View.GONE);
}
public void pause() {
player.pause();
}
public void show() {
container.setVisibility(View.VISIBLE);
}
public void resume() {
player.play();
}
@Override
public void onPlaybackStateChanged(int playbackState) {
if (playbackState == Player.STATE_READY) {
@@ -177,4 +186,8 @@ public final class GiphyMp4ProjectionPlayerHolder implements Player.Listener, De
public void setCorners(@Nullable Projection.Corners corners) {
player.setCorners(corners);
}
public @Nullable Bitmap getBitmap() {
return player.getBitmap();
}
}

View File

@@ -121,7 +121,7 @@ public final class GiphyMp4ProjectionRecycler implements GiphyMp4PlaybackControl
}
}
private @Nullable GiphyMp4ProjectionPlayerHolder getCurrentHolder(int adapterPosition) {
public @Nullable GiphyMp4ProjectionPlayerHolder getCurrentHolder(int adapterPosition) {
if (playing.get(adapterPosition) != null) {
return playing.get(adapterPosition);
} else if (notPlaying.get(adapterPosition) != null) {

View File

@@ -1,8 +1,11 @@
package org.thoughtcrime.securesms.giph.mp4;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.TextureView;
import android.view.View;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
@@ -103,6 +106,12 @@ public final class GiphyMp4VideoPlayer extends FrameLayout implements DefaultLif
}
}
void pause() {
if (exoPlayer != null) {
exoPlayer.pause();
}
}
void stop() {
if (exoPlayer != null) {
exoPlayer.stop();
@@ -122,4 +131,13 @@ public final class GiphyMp4VideoPlayer extends FrameLayout implements DefaultLif
void setResizeMode(@AspectRatioFrameLayout.ResizeMode int resizeMode) {
exoView.setResizeMode(resizeMode);
}
@Nullable Bitmap getBitmap() {
final View view = exoView.getVideoSurfaceView();
if (view instanceof TextureView) {
return ((TextureView) view).getBitmap();
}
return null;
}
}

View File

@@ -89,6 +89,11 @@ final class GiphyMp4ViewHolder extends MappingViewHolder<GiphyImage> implements
return true;
}
@Override
public boolean shouldProjectContent() {
return true;
}
private void loadPlaceholderImage(@NonNull GiphyImage giphyImage) {
GlideApp.with(itemView)
.load(new ChunkedImageUrl(giphyImage.getStillUrl()))