diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2023-05-03 15:24:29 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2023-05-03 15:24:29 +0000 |
commit | c3cd1620929aa6c92e064e5e313046bd47d2df90 (patch) | |
tree | c773bd7b05dd9e724285f225aacbc5d6084c6145 /app/src/main | |
parent | 3c1ecfdee0937d7294b12ec79ba6f60d320fa17d (diff) | |
download | infinity-for-reddit-c3cd1620929aa6c92e064e5e313046bd47d2df90.tar infinity-for-reddit-c3cd1620929aa6c92e064e5e313046bd47d2df90.tar.gz infinity-for-reddit-c3cd1620929aa6c92e064e5e313046bd47d2df90.tar.bz2 infinity-for-reddit-c3cd1620929aa6c92e064e5e313046bd47d2df90.tar.lz infinity-for-reddit-c3cd1620929aa6c92e064e5e313046bd47d2df90.tar.xz infinity-for-reddit-c3cd1620929aa6c92e064e5e313046bd47d2df90.tar.zst infinity-for-reddit-c3cd1620929aa6c92e064e5e313046bd47d2df90.zip |
Do not render ZoomSurfaceView when pinch to to zoom video is disabled.
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java | 120 |
1 files changed, 71 insertions, 49 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java index f819fe17..ed8a6cd8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java @@ -61,6 +61,7 @@ import com.google.android.exoplayer2.source.hls.HlsMediaSource; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.trackselection.TrackSelectionOverride; import com.google.android.exoplayer2.ui.PlayerControlView; +import com.google.android.exoplayer2.ui.PlayerView; import com.google.android.exoplayer2.ui.TrackSelectionDialogBuilder; import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DefaultHttpDataSource; @@ -159,10 +160,6 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe CoordinatorLayout coordinatorLayout; @BindView(R.id.progress_bar_view_video_activity) ProgressBar progressBar; - @BindView(R.id.zoom_surface_view_view_video_activity) - ZoomSurfaceView zoomSurfaceView; - @BindView(R.id.player_control_view_view_video_activity) - PlayerControlView playerControlView; @BindView(R.id.mute_exo_playback_control_view) ImageButton muteButton; @BindView(R.id.hd_exo_playback_control_view) @@ -293,7 +290,12 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe getTheme().applyStyle(ContentFontFamily.valueOf(mSharedPreferences .getString(SharedPreferencesUtils.CONTENT_FONT_FAMILY_KEY, ContentFontFamily.Default.name())).getResId(), true); - setContentView(R.layout.activity_view_video); + boolean zoomable = mSharedPreferences.getBoolean(SharedPreferencesUtils.PINCH_TO_ZOOM_VIDEO, false); + if (zoomable) { + setContentView(R.layout.activity_view_video_zoomable); + } else { + setContentView(R.layout.activity_view_video); + } ButterKnife.bind(this); setVolumeControlStream(AudioManager.STREAM_MUSIC); @@ -406,25 +408,6 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe String postTitle = intent.getStringExtra(EXTRA_POST_TITLE); setSmallTitle(postTitle); - playerControlView.addVisibilityListener(visibility -> { - switch (visibility) { - case View.GONE: - getWindow().getDecorView().setSystemUiVisibility( - View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_FULLSCREEN - | View.SYSTEM_UI_FLAG_IMMERSIVE); - break; - case View.VISIBLE: - getWindow().getDecorView().setSystemUiVisibility( - View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - } - }); - trackSelector = new DefaultTrackSelector(this); if (videoType == VIDEO_TYPE_NORMAL && isDataSavingMode && dataSavingModeDefaultResolution > 0) { trackSelector.setParameters( @@ -433,26 +416,46 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe } player = new ExoPlayer.Builder(this).setTrackSelector(trackSelector).build(); - playerControlView.setPlayer(player); + if (zoomable) { + PlayerControlView playerControlView = findViewById(R.id.player_control_view_view_video_activity); + playerControlView.addVisibilityListener(visibility -> { + switch (visibility) { + case View.GONE: + getWindow().getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_IMMERSIVE); + break; + case View.VISIBLE: + getWindow().getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + } + }); + playerControlView.setPlayer(player); - player.addListener(new Player.Listener() { - @Override - public void onVideoSizeChanged(VideoSize videoSize) { - zoomSurfaceView.setContentSize(videoSize.width, videoSize.height); - } - }); - zoomSurfaceView.addCallback(new ZoomSurfaceView.Callback() { - @Override - public void onZoomSurfaceCreated(@NonNull ZoomSurfaceView zoomSurfaceView) { - player.setVideoSurface(zoomSurfaceView.getSurface()); - } + ZoomSurfaceView zoomSurfaceView = findViewById(R.id.zoom_surface_view_view_video_activity); + player.addListener(new Player.Listener() { + @Override + public void onVideoSizeChanged(VideoSize videoSize) { + zoomSurfaceView.setContentSize(videoSize.width, videoSize.height); + } + }); + zoomSurfaceView.addCallback(new ZoomSurfaceView.Callback() { + @Override + public void onZoomSurfaceCreated(@NonNull ZoomSurfaceView zoomSurfaceView) { + player.setVideoSurface(zoomSurfaceView.getSurface()); + } - @Override - public void onZoomSurfaceDestroyed(@NonNull ZoomSurfaceView zoomSurfaceView) { + @Override + public void onZoomSurfaceDestroyed(@NonNull ZoomSurfaceView zoomSurfaceView) { - } - }); - if (mSharedPreferences.getBoolean(SharedPreferencesUtils.PINCH_TO_ZOOM_VIDEO, false)) { + } + }); zoomSurfaceView.getEngine().addListener(new ZoomEngine.Listener() { @Override public void onUpdate(@NonNull ZoomEngine zoomEngine, @NonNull Matrix matrix) { @@ -470,16 +473,35 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe } }); + zoomSurfaceView.setOnClickListener(view -> { + if (playerControlView.isVisible()) { + playerControlView.hide(); + } else { + playerControlView.show(); + } + }); } else { - zoomSurfaceView.setZoomEnabled(false); + PlayerView videoPlayerView = findViewById(R.id.player_view_view_video_activity); + videoPlayerView.setPlayer(player); + videoPlayerView.setControllerVisibilityListener(visibility -> { + switch (visibility) { + case View.GONE: + getWindow().getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_IMMERSIVE); + break; + case View.VISIBLE: + getWindow().getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + } + }); } - zoomSurfaceView.setOnClickListener(view -> { - if (playerControlView.isVisible()) { - playerControlView.hide(); - } else { - playerControlView.show(); - } - }); if (savedInstanceState == null) { mVideoUri = intent.getData(); |