mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
improve media
This commit is contained in:
parent
e18db746a0
commit
b16ecbbe72
5 changed files with 54 additions and 17 deletions
|
@ -196,6 +196,9 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
|
||||||
binding.mediaDescriptionTranslated.setText(translated);
|
binding.mediaDescriptionTranslated.setText(translated);
|
||||||
binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE);
|
binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE);
|
||||||
binding.mediaDescription.setVisibility(View.GONE);
|
binding.mediaDescription.setVisibility(View.GONE);
|
||||||
|
if(mCurrentFragment != null) {
|
||||||
|
mCurrentFragment.toggleController(false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Toasty.error(MediaActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
|
Toasty.error(MediaActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
@ -203,10 +206,16 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
|
||||||
});
|
});
|
||||||
if (attachments.get(mediaPosition - 1).translation != null) {
|
if (attachments.get(mediaPosition - 1).translation != null) {
|
||||||
binding.mediaDescription.setVisibility(View.GONE);
|
binding.mediaDescription.setVisibility(View.GONE);
|
||||||
|
if(mCurrentFragment != null) {
|
||||||
|
mCurrentFragment.toggleController(false);
|
||||||
|
}
|
||||||
binding.mediaDescriptionTranslated.setText(attachments.get(mediaPosition - 1).translation);
|
binding.mediaDescriptionTranslated.setText(attachments.get(mediaPosition - 1).translation);
|
||||||
binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE);
|
binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
binding.mediaDescription.setVisibility(View.VISIBLE);
|
binding.mediaDescription.setVisibility(View.VISIBLE);
|
||||||
|
if(mCurrentFragment != null) {
|
||||||
|
mCurrentFragment.toggleController(true);
|
||||||
|
}
|
||||||
binding.mediaDescriptionTranslated.setVisibility(View.GONE);
|
binding.mediaDescriptionTranslated.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -236,6 +245,9 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
|
||||||
binding.mediaDescriptionTranslated.setText(translated);
|
binding.mediaDescriptionTranslated.setText(translated);
|
||||||
binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE);
|
binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE);
|
||||||
binding.mediaDescription.setVisibility(View.GONE);
|
binding.mediaDescription.setVisibility(View.GONE);
|
||||||
|
if(mCurrentFragment != null) {
|
||||||
|
mCurrentFragment.toggleController(false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Toasty.error(MediaActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
|
Toasty.error(MediaActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
@ -244,14 +256,23 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
|
||||||
if (!fullscreen) {
|
if (!fullscreen) {
|
||||||
if (attachments.get(position).translation != null) {
|
if (attachments.get(position).translation != null) {
|
||||||
binding.mediaDescription.setVisibility(View.GONE);
|
binding.mediaDescription.setVisibility(View.GONE);
|
||||||
|
if(mCurrentFragment != null) {
|
||||||
|
mCurrentFragment.toggleController(false);
|
||||||
|
}
|
||||||
binding.mediaDescriptionTranslated.setText(attachments.get(position).translation);
|
binding.mediaDescriptionTranslated.setText(attachments.get(position).translation);
|
||||||
binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE);
|
binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
binding.mediaDescription.setVisibility(View.VISIBLE);
|
binding.mediaDescription.setVisibility(View.VISIBLE);
|
||||||
|
if(mCurrentFragment != null) {
|
||||||
|
mCurrentFragment.toggleController(true);
|
||||||
|
}
|
||||||
binding.mediaDescriptionTranslated.setVisibility(View.GONE);
|
binding.mediaDescriptionTranslated.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
binding.mediaDescription.setVisibility(View.GONE);
|
binding.mediaDescription.setVisibility(View.GONE);
|
||||||
|
if(mCurrentFragment != null) {
|
||||||
|
mCurrentFragment.toggleController(false);
|
||||||
|
}
|
||||||
binding.mediaDescriptionTranslated.setVisibility(View.GONE);
|
binding.mediaDescriptionTranslated.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -407,10 +428,16 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
|
||||||
binding.mediaDescription.setText(linkify(MediaActivity.this, description), TextView.BufferType.SPANNABLE);
|
binding.mediaDescription.setText(linkify(MediaActivity.this, description), TextView.BufferType.SPANNABLE);
|
||||||
if (attachments.get(binding.mediaViewpager.getCurrentItem()).translation != null) {
|
if (attachments.get(binding.mediaViewpager.getCurrentItem()).translation != null) {
|
||||||
binding.mediaDescription.setVisibility(View.GONE);
|
binding.mediaDescription.setVisibility(View.GONE);
|
||||||
|
if(mCurrentFragment != null) {
|
||||||
|
mCurrentFragment.toggleController(false);
|
||||||
|
}
|
||||||
binding.mediaDescriptionTranslated.setText(attachments.get(binding.mediaViewpager.getCurrentItem()).translation);
|
binding.mediaDescriptionTranslated.setText(attachments.get(binding.mediaViewpager.getCurrentItem()).translation);
|
||||||
binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE);
|
binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
binding.mediaDescription.setVisibility(View.VISIBLE);
|
binding.mediaDescription.setVisibility(View.VISIBLE);
|
||||||
|
if(mCurrentFragment != null) {
|
||||||
|
mCurrentFragment.toggleController(true);
|
||||||
|
}
|
||||||
binding.mediaDescriptionTranslated.setVisibility(View.GONE);
|
binding.mediaDescriptionTranslated.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -422,12 +449,18 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
|
||||||
}
|
}
|
||||||
binding.mediaDescriptionTranslated.setVisibility(View.GONE);
|
binding.mediaDescriptionTranslated.setVisibility(View.GONE);
|
||||||
binding.mediaDescription.setVisibility(View.GONE);
|
binding.mediaDescription.setVisibility(View.GONE);
|
||||||
|
if(mCurrentFragment != null) {
|
||||||
|
mCurrentFragment.toggleController(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
binding.originalMessage.setVisibility(View.INVISIBLE);
|
binding.originalMessage.setVisibility(View.INVISIBLE);
|
||||||
binding.translate.setVisibility(View.GONE);
|
binding.translate.setVisibility(View.GONE);
|
||||||
binding.mediaDescriptionTranslated.setVisibility(View.GONE);
|
binding.mediaDescriptionTranslated.setVisibility(View.GONE);
|
||||||
binding.mediaDescription.setVisibility(View.GONE);
|
binding.mediaDescription.setVisibility(View.GONE);
|
||||||
|
if(mCurrentFragment != null) {
|
||||||
|
mCurrentFragment.toggleController(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,6 +509,9 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
|
||||||
if (!fullscreen) {
|
if (!fullscreen) {
|
||||||
showSystemUI();
|
showSystemUI();
|
||||||
binding.mediaDescription.setVisibility(View.VISIBLE);
|
binding.mediaDescription.setVisibility(View.VISIBLE);
|
||||||
|
if(mCurrentFragment != null) {
|
||||||
|
mCurrentFragment.toggleController(true);
|
||||||
|
}
|
||||||
binding.translate.setVisibility(View.VISIBLE);
|
binding.translate.setVisibility(View.VISIBLE);
|
||||||
if (mediaFromProfile) {
|
if (mediaFromProfile) {
|
||||||
binding.originalMessage.setVisibility(View.VISIBLE);
|
binding.originalMessage.setVisibility(View.VISIBLE);
|
||||||
|
@ -483,6 +519,9 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
|
||||||
} else {
|
} else {
|
||||||
hideSystemUI();
|
hideSystemUI();
|
||||||
binding.mediaDescription.setVisibility(View.GONE);
|
binding.mediaDescription.setVisibility(View.GONE);
|
||||||
|
if(mCurrentFragment != null) {
|
||||||
|
mCurrentFragment.toggleController(false);
|
||||||
|
}
|
||||||
binding.translate.setVisibility(View.GONE);
|
binding.translate.setVisibility(View.GONE);
|
||||||
binding.originalMessage.setVisibility(View.INVISIBLE);
|
binding.originalMessage.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -30,12 +31,14 @@ import android.widget.ImageView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.annotation.OptIn;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.media3.common.MediaItem;
|
import androidx.media3.common.MediaItem;
|
||||||
import androidx.media3.common.PlaybackException;
|
import androidx.media3.common.PlaybackException;
|
||||||
import androidx.media3.common.Player;
|
import androidx.media3.common.Player;
|
||||||
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.datasource.DataSource;
|
import androidx.media3.datasource.DataSource;
|
||||||
import androidx.media3.datasource.DefaultDataSource;
|
import androidx.media3.datasource.DefaultDataSource;
|
||||||
import androidx.media3.exoplayer.ExoPlayer;
|
import androidx.media3.exoplayer.ExoPlayer;
|
||||||
|
@ -90,6 +93,15 @@ public class FragmentMedia extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OptIn(markerClass = UnstableApi.class)
|
||||||
|
public void toggleController(boolean display) {
|
||||||
|
if(display) {
|
||||||
|
binding.controls.show();
|
||||||
|
} else {
|
||||||
|
binding.controls.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
@ -275,14 +287,6 @@ public class FragmentMedia extends Fragment {
|
||||||
player.setRepeatMode(Player.REPEAT_MODE_ONE);
|
player.setRepeatMode(Player.REPEAT_MODE_ONE);
|
||||||
binding.mediaVideo.setUseController(false);
|
binding.mediaVideo.setUseController(false);
|
||||||
}
|
}
|
||||||
binding.mediaVideo.setOnTouchListener((view, motionEvent) -> {
|
|
||||||
if (binding.controls.getVisibility() != View.VISIBLE) {
|
|
||||||
binding.controls.setVisibility(View.VISIBLE);
|
|
||||||
final Handler handler = new Handler(Looper.getMainLooper());
|
|
||||||
handler.postDelayed(() -> binding.controls.setVisibility(View.GONE), 2000);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
binding.mediaVideo.setPlayer(player);
|
binding.mediaVideo.setPlayer(player);
|
||||||
binding.controls.setPlayer(player);
|
binding.controls.setPlayer(player);
|
||||||
binding.loader.setVisibility(View.GONE);
|
binding.loader.setVisibility(View.GONE);
|
||||||
|
|
|
@ -209,7 +209,6 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
||||||
private Status status;
|
private Status status;
|
||||||
private int flags;
|
private int flags;
|
||||||
private boolean humanInteraction;
|
private boolean humanInteraction;
|
||||||
private MediaSession mediaSession;
|
|
||||||
public static void hideKeyboard(Activity activity) {
|
public static void hideKeyboard(Activity activity) {
|
||||||
if (activity != null && activity.getWindow() != null) {
|
if (activity != null && activity.getWindow() != null) {
|
||||||
activity.getWindow().getDecorView();
|
activity.getWindow().getDecorView();
|
||||||
|
@ -1559,7 +1558,6 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
||||||
binding = null;
|
binding = null;
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.release();
|
player.release();
|
||||||
mediaSession = null;
|
|
||||||
}
|
}
|
||||||
unregisterReceiver();
|
unregisterReceiver();
|
||||||
}
|
}
|
||||||
|
@ -1639,7 +1637,6 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
||||||
if (playInMinimized && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && player != null) {
|
if (playInMinimized && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && player != null) {
|
||||||
isPlayInMinimized = true;
|
isPlayInMinimized = true;
|
||||||
setRequestedOrientationCustom(initialOrientation);
|
setRequestedOrientationCustom(initialOrientation);
|
||||||
mediaSession = new MediaSession.Builder(this, player).build();
|
|
||||||
PlayerControlView controlView = binding.doubleTapPlayerView.findViewById(R.id.exo_controller);
|
PlayerControlView controlView = binding.doubleTapPlayerView.findViewById(R.id.exo_controller);
|
||||||
controlView.hide();
|
controlView.hide();
|
||||||
binding.doubleTapPlayerView.setControllerAutoShow(false);
|
binding.doubleTapPlayerView.setControllerAutoShow(false);
|
||||||
|
@ -2225,7 +2222,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
||||||
if (fullScreenButton != null) {
|
if (fullScreenButton != null) {
|
||||||
fullScreenButton.setOnClickListener(v -> toggleFullScreen());
|
fullScreenButton.setOnClickListener(v -> toggleFullScreen());
|
||||||
}
|
}
|
||||||
ImageButton playButton = controlView.findViewById(R.id.exo_play);
|
ImageButton playButton = controlView.findViewById(R.id.exo_play_pause);
|
||||||
if (playButton != null) {
|
if (playButton != null) {
|
||||||
playButton.setOnClickListener(v -> {
|
playButton.setOnClickListener(v -> {
|
||||||
if (autoFullscreen && !fullScreenMode) {
|
if (autoFullscreen && !fullScreenMode) {
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:layout_marginBottom="50dp"
|
android:layout_marginBottom="50dp"
|
||||||
app:show_timeout="2000" />
|
app:show_timeout="0" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
|
@ -40,12 +40,9 @@
|
||||||
style="@style/ExoMediaButton.Previous" />
|
style="@style/ExoMediaButton.Previous" />
|
||||||
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@id/exo_play"
|
|
||||||
style="@style/ExoMediaButton.Play" />
|
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@id/exo_pause"
|
android:id="@id/exo_play_pause"
|
||||||
style="@style/ExoMediaButton.Pause" />
|
style="@style/ExoMediaButton.Pause" />
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue