diff --git a/app/src/main/java/com/mrikso/anitube/app/ui/player/PlayerActivity.java b/app/src/main/java/com/mrikso/anitube/app/ui/player/PlayerActivity.java index acf2ec9..05ed8d5 100644 --- a/app/src/main/java/com/mrikso/anitube/app/ui/player/PlayerActivity.java +++ b/app/src/main/java/com/mrikso/anitube/app/ui/player/PlayerActivity.java @@ -17,12 +17,12 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; -import android.util.Log; import android.util.Rational; import android.view.KeyEvent; import android.view.SurfaceView; import android.view.View; import android.widget.ArrayAdapter; +import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; @@ -127,9 +127,9 @@ public class PlayerActivity extends AppCompatActivity { private ImageView exoNextEp; // Bottom buttons - private ImageView exoPip; - private ImageView exoSkip; - private ImageView exoScreen; + private ImageButton exoPip; + private ImageButton exoSkip; + private ImageButton exoScreen; private LinearLayout exoTopControllers; private LinearLayout exoMiddleControllers; @@ -164,6 +164,7 @@ public class PlayerActivity extends AppCompatActivity { private BaseAnimeModel animeModel; private String episodePath; private int doubleTapSeek; + private int fastSeek; private boolean autoPlayNextEpisode; private boolean gesturesEnabled; private boolean autoContinue; @@ -173,11 +174,12 @@ public class PlayerActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + loadSettings(); setView(); initViewModel(); setupViews(); - loadSettings(); + // if (savedInstanceState == null) { hideNavBar(); parseExtra(); @@ -228,7 +230,10 @@ private void setupViews() { // Bottom buttons exoPip = findViewById(R.id.exo_pip); - // exoSkip = findViewById(R.id.exo_skip); + exoSkip = findViewById(R.id.exo_quick_skip); + if (!(fastSeek > 0)) { + exoSkip.setVisibility(View.GONE); + } exoScreen = findViewById(R.id.exo_screen); youTubeOverlay = findViewById(R.id.youtube_overlay); @@ -337,7 +342,7 @@ private void preparePlayer(boolean restorePlayer) { exoPlayer.prepare(); playVideo(); - if (Utils.isPiPSupported(this)){ + if (Utils.isPiPSupported(this)) { setPictureInPictureParams(getPipParams(exoPlayer.isPlaying())); } } @@ -348,7 +353,7 @@ private void setupTextViewValues() { } private void setupMiddleControllers() { - // Log.i("TAG", "epnum:" + episodeNumber + "size:" + listRepo.getList().size()); + // Log.i("TAG", "epnum:" + episodeNumber + "size:" + listRepo.getList().size()); if (episodeNumber == 1) { exoPrevEp.setAlpha(0.4f); @@ -434,7 +439,7 @@ private void setupQuality() { exoQuality.setOnItemClickListener((parent, view, position, id) -> { currentQuality = (String) parent.getAdapter().getItem(position); String qualityItem = episodeLinks.getLinksQuality().get(currentQuality); - currentPosition = Math.max(0, exoPlayer.getContentPosition()); + currentPosition = Math.max(0, exoPlayer.getCurrentPosition()); MediaSource mediaSource = mediaSourceHelper.getMediaSource(qualityItem, true); exoPlayer.setMediaSource(mediaSource); @@ -474,7 +479,7 @@ private void updateQualityArray() { private void savePlayer() { if (exoPlayer != null) { - currentPosition = Math.max(0, exoPlayer.getContentPosition()); + currentPosition = Math.max(0, exoPlayer.getCurrentPosition()); sharedViewModel.addOrUpdateWatchedAnime( animeModel, episodePath, episodeNumber, exoPlayer.getContentDuration(), currentPosition); sharedViewModel.addOrUpdateWatchedEpisode( @@ -547,6 +552,9 @@ private void setClickListeners() { exoPip.setOnClickListener(v -> { enterPiP(); }); + exoSkip.setOnClickListener(v -> { + exoPlayer.seekTo(exoPlayer.getCurrentPosition() + fastSeek * 1000L); + }); } private void playPrevEpisode() { @@ -831,6 +839,7 @@ private void loadSettings() { var prefs = PreferencesHelper.getInstance(); doubleTapSeek = prefs.getPlayerDoubleTapSeek(); + fastSeek = prefs.getPlayerFastSeek(); autoPlayNextEpisode = prefs.isPlayerEnabledPlayNextEpisode(); gesturesEnabled = prefs.isPlayerEnabledSwipeControls(); autoContinue = prefs.isPlayerAutoContinuePlay(); @@ -870,7 +879,7 @@ public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, @Non } else { if (broadcastReceiver != null) { unregisterReceiver(broadcastReceiver); - broadcastReceiver=null; + broadcastReceiver = null; } } diff --git a/app/src/main/java/com/mrikso/anitube/app/utils/PreferenceKeys.java b/app/src/main/java/com/mrikso/anitube/app/utils/PreferenceKeys.java index 0954c12..f84bf6a 100644 --- a/app/src/main/java/com/mrikso/anitube/app/utils/PreferenceKeys.java +++ b/app/src/main/java/com/mrikso/anitube/app/utils/PreferenceKeys.java @@ -10,6 +10,7 @@ public class PreferenceKeys { public static final String PREF_KEY_REVERSE_EPISODE_LIST = "pref_key_reverse_episode_list"; public static final String PREF_ENDPOINT_KEY = "pref_streamsb_api_endpoint"; public static final String PREF_PLAYER_DOUBLE_TAP_SEEK = "player_double_tap_seek"; + public static final String PREF_PLAYER_FAST_SEEK = "player_fast_seek"; public static final String PREF_PLAYER_SWIPE_CONTROLS = "player_swipe_controls"; public static final String PREF_PLAYER_AUTOPLAY_NEXT_EPISODE = "player_autoplay_next_episode"; public static final String PREF_PLAYER_AUTO_CONTINUE_PLAY = "player_auto_continue_play"; diff --git a/app/src/main/java/com/mrikso/anitube/app/utils/PreferencesHelper.java b/app/src/main/java/com/mrikso/anitube/app/utils/PreferencesHelper.java index 7dc5319..0274e91 100644 --- a/app/src/main/java/com/mrikso/anitube/app/utils/PreferencesHelper.java +++ b/app/src/main/java/com/mrikso/anitube/app/utils/PreferencesHelper.java @@ -92,11 +92,16 @@ public void setDleHash(String hash) { } public int getPlayerDoubleTapSeek() { - String sec = preferences.getString(PreferenceKeys.PREF_PLAYER_DOUBLE_TAP_SEEK, "10"); - if(sec.equals("off")){ + String seek = preferences.getString(PreferenceKeys.PREF_PLAYER_DOUBLE_TAP_SEEK, "10"); + if (seek.equals("off")) { return -1; } - return Integer.parseInt(sec); + return Integer.parseInt(seek); + } + + public int getPlayerFastSeek() { + String seek = preferences.getString(PreferenceKeys.PREF_PLAYER_FAST_SEEK, "60"); + return Integer.parseInt(seek); } public boolean isPlayerEnabledSwipeControls() { diff --git a/app/src/main/res/drawable/ic_fast_forward.xml b/app/src/main/res/drawable/ic_fast_forward.xml new file mode 100644 index 0000000..0def62d --- /dev/null +++ b/app/src/main/res/drawable/ic_fast_forward.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/custom_controller.xml b/app/src/main/res/layout/custom_controller.xml index 9403647..865150e 100644 --- a/app/src/main/res/layout/custom_controller.xml +++ b/app/src/main/res/layout/custom_controller.xml @@ -241,13 +241,26 @@ tools:ignore="TextContrastCheck" tools:text="24:00" /> + + @@ -257,7 +270,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/transparent_circle_background" - android:padding="8dp" + android:padding="11dp" app:srcCompat="@drawable/ic_open_in_fullscreen" app:tint="@color/white" tools:ignore="ContentDescription,SpeakableTextPresentCheck,TouchTargetSizeCheck" /> diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 432a521..07c0050 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -41,8 +41,8 @@ 10 секунд 15 секунд 30 секунд - 60 секунд - 120 секунд + 1 хвилина + 2 хвилини @@ -55,4 +55,26 @@ 60 120 + + + @string/disabled + 30 секунд + 45 секунд + 1 хвилина + 1 хвилина 30 cекунд + 2 хвилини + 3 хвилини + 4 хвилини + + + + 0 + 30 + 45 + 60 + 90 + 120 + 180 + 240 + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e671a85..4da21a6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -165,4 +165,5 @@ Почніть шукати аніме і тут з\'явиться історія вашого пошуку Пауза Відновити + Швидка перемотка diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml index 911072c..c8671a7 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -33,6 +33,15 @@ app:title="@string/double_tap_seek" app:useSimpleSummaryProvider="true" /> + +