Loading app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java +39 −0 Original line number Diff line number Diff line Loading @@ -196,6 +196,9 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload binding.mediaDescriptionTranslated.setText(translated); binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE); binding.mediaDescription.setVisibility(View.GONE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(false); } } else { Toasty.error(MediaActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show(); } Loading @@ -203,10 +206,16 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload }); if (attachments.get(mediaPosition - 1).translation != null) { binding.mediaDescription.setVisibility(View.GONE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(false); } binding.mediaDescriptionTranslated.setText(attachments.get(mediaPosition - 1).translation); binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE); } else { binding.mediaDescription.setVisibility(View.VISIBLE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(true); } binding.mediaDescriptionTranslated.setVisibility(View.GONE); } } Loading Loading @@ -236,6 +245,9 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload binding.mediaDescriptionTranslated.setText(translated); binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE); binding.mediaDescription.setVisibility(View.GONE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(false); } } else { Toasty.error(MediaActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show(); } Loading @@ -244,14 +256,23 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload if (!fullscreen) { if (attachments.get(position).translation != null) { binding.mediaDescription.setVisibility(View.GONE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(false); } binding.mediaDescriptionTranslated.setText(attachments.get(position).translation); binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE); } else { binding.mediaDescription.setVisibility(View.VISIBLE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(true); } binding.mediaDescriptionTranslated.setVisibility(View.GONE); } } else { binding.mediaDescription.setVisibility(View.GONE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(false); } binding.mediaDescriptionTranslated.setVisibility(View.GONE); } } Loading Loading @@ -407,10 +428,16 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload binding.mediaDescription.setText(linkify(MediaActivity.this, description), TextView.BufferType.SPANNABLE); if (attachments.get(binding.mediaViewpager.getCurrentItem()).translation != null) { binding.mediaDescription.setVisibility(View.GONE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(false); } binding.mediaDescriptionTranslated.setText(attachments.get(binding.mediaViewpager.getCurrentItem()).translation); binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE); } else { binding.mediaDescription.setVisibility(View.VISIBLE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(true); } binding.mediaDescriptionTranslated.setVisibility(View.GONE); } } else { Loading @@ -422,12 +449,18 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload } binding.mediaDescriptionTranslated.setVisibility(View.GONE); binding.mediaDescription.setVisibility(View.GONE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(false); } } } else { binding.originalMessage.setVisibility(View.INVISIBLE); binding.translate.setVisibility(View.GONE); binding.mediaDescriptionTranslated.setVisibility(View.GONE); binding.mediaDescription.setVisibility(View.GONE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(false); } } } Loading Loading @@ -476,6 +509,9 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload if (!fullscreen) { showSystemUI(); binding.mediaDescription.setVisibility(View.VISIBLE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(true); } binding.translate.setVisibility(View.VISIBLE); if (mediaFromProfile) { binding.originalMessage.setVisibility(View.VISIBLE); Loading @@ -483,6 +519,9 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload } else { hideSystemUI(); binding.mediaDescription.setVisibility(View.GONE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(false); } binding.translate.setVisibility(View.GONE); binding.originalMessage.setVisibility(View.INVISIBLE); } Loading app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMedia.java +12 −8 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; Loading @@ -30,12 +31,14 @@ import android.widget.ImageView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.OptIn; import androidx.core.app.ActivityCompat; import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; import androidx.media3.common.MediaItem; import androidx.media3.common.PlaybackException; import androidx.media3.common.Player; import androidx.media3.common.util.UnstableApi; import androidx.media3.datasource.DataSource; import androidx.media3.datasource.DefaultDataSource; import androidx.media3.exoplayer.ExoPlayer; Loading Loading @@ -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 public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Loading Loading @@ -275,14 +287,6 @@ public class FragmentMedia extends Fragment { player.setRepeatMode(Player.REPEAT_MODE_ONE); 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.controls.setPlayer(player); binding.loader.setVisibility(View.GONE); Loading app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java +1 −4 Original line number Diff line number Diff line Loading @@ -209,7 +209,6 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis private Status status; private int flags; private boolean humanInteraction; private MediaSession mediaSession; public static void hideKeyboard(Activity activity) { if (activity != null && activity.getWindow() != null) { activity.getWindow().getDecorView(); Loading Loading @@ -1559,7 +1558,6 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis binding = null; if (player != null) { player.release(); mediaSession = null; } unregisterReceiver(); } Loading Loading @@ -1639,7 +1637,6 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis if (playInMinimized && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && player != null) { isPlayInMinimized = true; setRequestedOrientationCustom(initialOrientation); mediaSession = new MediaSession.Builder(this, player).build(); PlayerControlView controlView = binding.doubleTapPlayerView.findViewById(R.id.exo_controller); controlView.hide(); binding.doubleTapPlayerView.setControllerAutoShow(false); Loading Loading @@ -2225,7 +2222,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis if (fullScreenButton != null) { fullScreenButton.setOnClickListener(v -> toggleFullScreen()); } ImageButton playButton = controlView.findViewById(R.id.exo_play); ImageButton playButton = controlView.findViewById(R.id.exo_play_pause); if (playButton != null) { playButton.setOnClickListener(v -> { if (autoFullscreen && !fullScreenMode) { Loading app/src/main/res/layouts/mastodon/layout/fragment_slide_media.xml +1 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ android:layout_height="wrap_content" android:layout_gravity="bottom" android:layout_marginBottom="50dp" app:show_timeout="2000" /> app:show_timeout="0" /> </FrameLayout> Loading app/src/main/res/layouts/peertube/layout/peertube_exo_player_control_view.xml +1 −4 Original line number Diff line number Diff line Loading @@ -40,12 +40,9 @@ style="@style/ExoMediaButton.Previous" /> <ImageButton android:id="@id/exo_play" style="@style/ExoMediaButton.Play" /> <ImageButton android:id="@id/exo_pause" android:id="@id/exo_play_pause" style="@style/ExoMediaButton.Pause" /> Loading Loading
app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java +39 −0 Original line number Diff line number Diff line Loading @@ -196,6 +196,9 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload binding.mediaDescriptionTranslated.setText(translated); binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE); binding.mediaDescription.setVisibility(View.GONE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(false); } } else { Toasty.error(MediaActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show(); } Loading @@ -203,10 +206,16 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload }); if (attachments.get(mediaPosition - 1).translation != null) { binding.mediaDescription.setVisibility(View.GONE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(false); } binding.mediaDescriptionTranslated.setText(attachments.get(mediaPosition - 1).translation); binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE); } else { binding.mediaDescription.setVisibility(View.VISIBLE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(true); } binding.mediaDescriptionTranslated.setVisibility(View.GONE); } } Loading Loading @@ -236,6 +245,9 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload binding.mediaDescriptionTranslated.setText(translated); binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE); binding.mediaDescription.setVisibility(View.GONE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(false); } } else { Toasty.error(MediaActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show(); } Loading @@ -244,14 +256,23 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload if (!fullscreen) { if (attachments.get(position).translation != null) { binding.mediaDescription.setVisibility(View.GONE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(false); } binding.mediaDescriptionTranslated.setText(attachments.get(position).translation); binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE); } else { binding.mediaDescription.setVisibility(View.VISIBLE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(true); } binding.mediaDescriptionTranslated.setVisibility(View.GONE); } } else { binding.mediaDescription.setVisibility(View.GONE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(false); } binding.mediaDescriptionTranslated.setVisibility(View.GONE); } } Loading Loading @@ -407,10 +428,16 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload binding.mediaDescription.setText(linkify(MediaActivity.this, description), TextView.BufferType.SPANNABLE); if (attachments.get(binding.mediaViewpager.getCurrentItem()).translation != null) { binding.mediaDescription.setVisibility(View.GONE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(false); } binding.mediaDescriptionTranslated.setText(attachments.get(binding.mediaViewpager.getCurrentItem()).translation); binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE); } else { binding.mediaDescription.setVisibility(View.VISIBLE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(true); } binding.mediaDescriptionTranslated.setVisibility(View.GONE); } } else { Loading @@ -422,12 +449,18 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload } binding.mediaDescriptionTranslated.setVisibility(View.GONE); binding.mediaDescription.setVisibility(View.GONE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(false); } } } else { binding.originalMessage.setVisibility(View.INVISIBLE); binding.translate.setVisibility(View.GONE); binding.mediaDescriptionTranslated.setVisibility(View.GONE); binding.mediaDescription.setVisibility(View.GONE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(false); } } } Loading Loading @@ -476,6 +509,9 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload if (!fullscreen) { showSystemUI(); binding.mediaDescription.setVisibility(View.VISIBLE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(true); } binding.translate.setVisibility(View.VISIBLE); if (mediaFromProfile) { binding.originalMessage.setVisibility(View.VISIBLE); Loading @@ -483,6 +519,9 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload } else { hideSystemUI(); binding.mediaDescription.setVisibility(View.GONE); if(mCurrentFragment != null) { mCurrentFragment.toggleController(false); } binding.translate.setVisibility(View.GONE); binding.originalMessage.setVisibility(View.INVISIBLE); } Loading
app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMedia.java +12 −8 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; Loading @@ -30,12 +31,14 @@ import android.widget.ImageView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.OptIn; import androidx.core.app.ActivityCompat; import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; import androidx.media3.common.MediaItem; import androidx.media3.common.PlaybackException; import androidx.media3.common.Player; import androidx.media3.common.util.UnstableApi; import androidx.media3.datasource.DataSource; import androidx.media3.datasource.DefaultDataSource; import androidx.media3.exoplayer.ExoPlayer; Loading Loading @@ -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 public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Loading Loading @@ -275,14 +287,6 @@ public class FragmentMedia extends Fragment { player.setRepeatMode(Player.REPEAT_MODE_ONE); 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.controls.setPlayer(player); binding.loader.setVisibility(View.GONE); Loading
app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java +1 −4 Original line number Diff line number Diff line Loading @@ -209,7 +209,6 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis private Status status; private int flags; private boolean humanInteraction; private MediaSession mediaSession; public static void hideKeyboard(Activity activity) { if (activity != null && activity.getWindow() != null) { activity.getWindow().getDecorView(); Loading Loading @@ -1559,7 +1558,6 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis binding = null; if (player != null) { player.release(); mediaSession = null; } unregisterReceiver(); } Loading Loading @@ -1639,7 +1637,6 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis if (playInMinimized && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && player != null) { isPlayInMinimized = true; setRequestedOrientationCustom(initialOrientation); mediaSession = new MediaSession.Builder(this, player).build(); PlayerControlView controlView = binding.doubleTapPlayerView.findViewById(R.id.exo_controller); controlView.hide(); binding.doubleTapPlayerView.setControllerAutoShow(false); Loading Loading @@ -2225,7 +2222,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis if (fullScreenButton != null) { fullScreenButton.setOnClickListener(v -> toggleFullScreen()); } ImageButton playButton = controlView.findViewById(R.id.exo_play); ImageButton playButton = controlView.findViewById(R.id.exo_play_pause); if (playButton != null) { playButton.setOnClickListener(v -> { if (autoFullscreen && !fullScreenMode) { Loading
app/src/main/res/layouts/mastodon/layout/fragment_slide_media.xml +1 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ android:layout_height="wrap_content" android:layout_gravity="bottom" android:layout_marginBottom="50dp" app:show_timeout="2000" /> app:show_timeout="0" /> </FrameLayout> Loading
app/src/main/res/layouts/peertube/layout/peertube_exo_player_control_view.xml +1 −4 Original line number Diff line number Diff line Loading @@ -40,12 +40,9 @@ style="@style/ExoMediaButton.Previous" /> <ImageButton android:id="@id/exo_play" style="@style/ExoMediaButton.Play" /> <ImageButton android:id="@id/exo_pause" android:id="@id/exo_play_pause" style="@style/ExoMediaButton.Pause" /> Loading