diff --git a/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt index 58d36b1a..5e7f060e 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt @@ -33,7 +33,6 @@ object CommonActivity { var canShowPipMode: Boolean = false var isInPIPMode: Boolean = false - val backEvent = Event() val onColorSelectedEvent = Event>() val onDialogDismissedEvent = Event() diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt index 4c3b1933..aadf00a7 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt @@ -28,7 +28,6 @@ import com.lagradost.cloudstream3.APIHolder.allProviders import com.lagradost.cloudstream3.APIHolder.apis import com.lagradost.cloudstream3.APIHolder.getApiDubstatusSettings import com.lagradost.cloudstream3.APIHolder.initAll -import com.lagradost.cloudstream3.CommonActivity.backEvent import com.lagradost.cloudstream3.CommonActivity.loadThemes import com.lagradost.cloudstream3.CommonActivity.onColorSelectedEvent import com.lagradost.cloudstream3.CommonActivity.onDialogDismissedEvent @@ -60,6 +59,7 @@ import com.lagradost.cloudstream3.utils.DataStore.removeKey import com.lagradost.cloudstream3.utils.DataStore.setKey import com.lagradost.cloudstream3.utils.DataStoreHelper.migrateResumeWatching import com.lagradost.cloudstream3.utils.DataStoreHelper.setViewPos +import com.lagradost.cloudstream3.utils.IOnBackPressed import com.lagradost.cloudstream3.utils.InAppUpdater.Companion.runAutoUpdate import com.lagradost.cloudstream3.utils.UIHelper.changeStatusBarState import com.lagradost.cloudstream3.utils.UIHelper.checkWrite @@ -235,15 +235,23 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener { onUserLeaveHint(this) } - override fun onBackPressed() { + private fun backPressed() { this.window?.navigationBarColor = this.colorFromAttribute(R.attr.primaryGrayBackground) this.updateLocale() - backEvent.invoke(true) super.onBackPressed() this.updateLocale() } + override fun onBackPressed() { + ((supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as? NavHostFragment?)?.childFragmentManager?.primaryNavigationFragment as? IOnBackPressed)?.onBackPressed() + ?.let { runNormal -> + if (runNormal) backPressed() + } ?: run { + backPressed() + } + } + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { if (VLC_REQUEST_CODE == requestCode) { if (resultCode == RESULT_OK && data != null) { @@ -363,7 +371,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener { runBlocking { val query = """ - query { + query { searchShows(search: "spider", limit: 10) { id name diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt index c0dc49e0..7e9174b7 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt @@ -62,7 +62,14 @@ import kotlinx.android.synthetic.main.player_custom_layout.player_ffwd_holder import kotlinx.android.synthetic.main.player_custom_layout.player_holder import kotlinx.android.synthetic.main.player_custom_layout.player_pause_play import kotlinx.android.synthetic.main.player_custom_layout.player_pause_play_holder +import kotlinx.android.synthetic.main.player_custom_layout.player_progressbar_left +import kotlinx.android.synthetic.main.player_custom_layout.player_progressbar_left_holder +import kotlinx.android.synthetic.main.player_custom_layout.player_progressbar_left_icon +import kotlinx.android.synthetic.main.player_custom_layout.player_progressbar_right +import kotlinx.android.synthetic.main.player_custom_layout.player_progressbar_right_holder +import kotlinx.android.synthetic.main.player_custom_layout.player_progressbar_right_icon import kotlinx.android.synthetic.main.player_custom_layout.player_rew_holder +import kotlinx.android.synthetic.main.player_custom_layout.player_time_text import kotlinx.android.synthetic.main.player_custom_layout.player_video_bar import kotlinx.android.synthetic.main.player_custom_layout.shadow_overlay import kotlinx.android.synthetic.main.trailer_custom_layout.* @@ -226,7 +233,7 @@ open class FullScreenPlayer : AbstractPlayerFragment() { player_ffwd_holder?.alpha = 1f player_rew_holder?.alpha = 1f // player_pause_play_holder?.alpha = 1f - + shadow_overlay?.isVisible = true shadow_overlay?.startAnimation(fadeAnimation) player_ffwd_holder?.startAnimation(fadeAnimation) player_rew_holder?.startAnimation(fadeAnimation) @@ -251,7 +258,7 @@ open class FullScreenPlayer : AbstractPlayerFragment() { player_subtitle_offset_btt?.isGone = player.getCurrentPreferredSubtitle() == null } - override fun onResume() { + protected fun enterFullscreen() { if (isFullScreenPlayer) { activity?.hideSystemUI() if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && fullscreenNotch) { @@ -262,15 +269,12 @@ open class FullScreenPlayer : AbstractPlayerFragment() { } if (lockRotation) activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE - - - super.onResume() } - override fun onDestroy() { + protected fun exitFullscreen() { activity?.showSystemUI() - if (lockRotation) - activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER + //if (lockRotation) + activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER // simply resets brightness and notch settings that might have been overridden val lp = activity?.window?.attributes @@ -280,6 +284,15 @@ open class FullScreenPlayer : AbstractPlayerFragment() { WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT } activity?.window?.attributes = lp + } + + override fun onResume() { + enterFullscreen() + super.onResume() + } + + override fun onDestroy() { + exitFullscreen() super.onDestroy() } @@ -529,6 +542,7 @@ open class FullScreenPlayer : AbstractPlayerFragment() { player_lock_holder?.startAnimation(fadeAnimation) //player_go_back_holder?.startAnimation(fadeAnimation) + shadow_overlay?.isVisible = true shadow_overlay?.startAnimation(fadeAnimation) updateLockUI() @@ -774,14 +788,14 @@ open class FullScreenPlayer : AbstractPlayerFragment() { if (currentClickCount >= 1) { // have double clicked currentDoubleTapIndex++ - if (doubleTapPauseEnabled) { // you can pause if your tap is in the middle of the screen + if (doubleTapPauseEnabled && isFullScreenPlayer) { // you can pause if your tap is in the middle of the screen when { currentTouch.x < screenWidth / 2 - (DOUBLE_TAB_PAUSE_PERCENTAGE * screenWidth) -> { - if (doubleTapEnabled && isFullScreenPlayer) + if (doubleTapEnabled) rewind() } currentTouch.x > screenWidth / 2 + (DOUBLE_TAB_PAUSE_PERCENTAGE * screenWidth) -> { - if (doubleTapEnabled && isFullScreenPlayer) + if (doubleTapEnabled) fastForward() } else -> { @@ -1050,6 +1064,7 @@ open class FullScreenPlayer : AbstractPlayerFragment() { // if nothing has loaded these buttons should not be visible player_skip_episode?.isVisible = false player_skip_op?.isVisible = false + shadow_overlay?.isVisible = false updateLockUI() updateUIVisibility() diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt index 2ee9b719..a1ddebe6 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt @@ -641,9 +641,15 @@ class ResultFragment : ResultTrailerPlayer() { } private fun setTrailers(trailers: List?) { - if(context?.isTvSettings() == true) return - currentTrailers = trailers ?: emptyList() - loadTrailer() + context?.let { ctx -> + if (ctx.isTvSettings()) return + val settingsManager = PreferenceManager.getDefaultSharedPreferences(ctx) + val showTrailers = + settingsManager.getBoolean(ctx.getString(R.string.show_trailers_key), true) + if (!showTrailers) return + currentTrailers = trailers ?: emptyList() + loadTrailer() + } } private fun setActors(actors: List?) { diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultTrailerPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultTrailerPlayer.kt index 66ac2dc2..ebc2c5be 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultTrailerPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultTrailerPlayer.kt @@ -2,14 +2,22 @@ package com.lagradost.cloudstream3.ui.result import android.content.res.Configuration import android.graphics.Rect -import android.widget.LinearLayout +import android.os.Bundle +import android.view.View +import android.view.ViewGroup +import android.widget.FrameLayout import androidx.core.view.isVisible import com.discord.panels.PanelsChildGestureRegionObserver +import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.ui.player.SubtitleData +import com.lagradost.cloudstream3.utils.IOnBackPressed +import kotlinx.android.synthetic.main.fragment_result.* +import kotlinx.android.synthetic.main.fragment_result_swipe.* import kotlinx.android.synthetic.main.fragment_trailer.* +import kotlinx.android.synthetic.main.trailer_custom_layout.* open class ResultTrailerPlayer : com.lagradost.cloudstream3.ui.player.FullScreenPlayer(), - PanelsChildGestureRegionObserver.GestureRegionsListener { + PanelsChildGestureRegionObserver.GestureRegionsListener, IOnBackPressed { override var lockRotation = false override var isFullScreenPlayer = false @@ -37,7 +45,7 @@ open class ResultTrailerPlayer : com.lagradost.cloudstream3.ui.player.FullScreen private fun fixPlayerSize() { playerWidthHeight?.let { (w, h) -> - val orientation = this.resources.configuration?.orientation ?: return + val orientation = context?.resources?.configuration?.orientation ?: return val sw = if (orientation == Configuration.ORIENTATION_LANDSCAPE) { screenWidth @@ -48,7 +56,10 @@ open class ResultTrailerPlayer : com.lagradost.cloudstream3.ui.player.FullScreen player_background?.apply { isVisible = true layoutParams = - LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, sw * h / w) + FrameLayout.LayoutParams( + FrameLayout.LayoutParams.MATCH_PARENT, + if (isFullScreenPlayer) FrameLayout.LayoutParams.MATCH_PARENT else sw * h / w + ) } } } @@ -65,4 +76,49 @@ open class ResultTrailerPlayer : com.lagradost.cloudstream3.ui.player.FullScreen override fun exitedPipMode() {} override fun onGestureRegionsUpdate(gestureRegions: List) {} + + private fun updateFullscreen(fullscreen: Boolean) { + isFullScreenPlayer = fullscreen + lockRotation = fullscreen + player_fullscreen?.setImageResource(if (fullscreen) R.drawable.baseline_fullscreen_exit_24 else R.drawable.baseline_fullscreen_24) + uiReset() + if (fullscreen) { + enterFullscreen() + result_top_bar?.isVisible = false + result_fullscreen_holder?.isVisible = true + result_main_holder?.isVisible = false + player_background?.let { view -> + (view.parent as ViewGroup?)?.removeView(view) + result_fullscreen_holder?.addView(view) + } + } else { + result_top_bar?.isVisible = true + result_fullscreen_holder?.isVisible = false + result_main_holder?.isVisible = true + player_background?.let { view -> + (view.parent as ViewGroup?)?.removeView(view) + result_smallscreen_holder?.addView(view) + } + exitFullscreen() + } + fixPlayerSize() + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + player_fullscreen?.setOnClickListener { + updateFullscreen(!isFullScreenPlayer) + } + updateFullscreen(isFullScreenPlayer) + uiReset() + } + + override fun onBackPressed(): Boolean { + return if (isFullScreenPlayer) { + updateFullscreen(false) + false + } else { + true + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/IOnBackPressed.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/IOnBackPressed.kt new file mode 100644 index 00000000..b4922945 --- /dev/null +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/IOnBackPressed.kt @@ -0,0 +1,5 @@ +package com.lagradost.cloudstream3.utils + +interface IOnBackPressed { + fun onBackPressed(): Boolean +} \ No newline at end of file diff --git a/app/src/main/res/drawable/baseline_fullscreen_24.xml b/app/src/main/res/drawable/baseline_fullscreen_24.xml new file mode 100644 index 00000000..804cebcf --- /dev/null +++ b/app/src/main/res/drawable/baseline_fullscreen_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/baseline_fullscreen_exit_24.xml b/app/src/main/res/drawable/baseline_fullscreen_exit_24.xml new file mode 100644 index 00000000..1efbe0a9 --- /dev/null +++ b/app/src/main/res/drawable/baseline_fullscreen_exit_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/baseline_theaters_24.xml b/app/src/main/res/drawable/baseline_theaters_24.xml new file mode 100644 index 00000000..d936b13e --- /dev/null +++ b/app/src/main/res/drawable/baseline_theaters_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/fragment_result.xml b/app/src/main/res/layout/fragment_result.xml index cb95b991..4c1aef8a 100644 --- a/app/src/main/res/layout/fragment_result.xml +++ b/app/src/main/res/layout/fragment_result.xml @@ -138,7 +138,13 @@ android:background="?attr/primaryBlackBackground" android:orientation="vertical"> - + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-es/strings-es.xml b/app/src/main/res/values-es/strings-es.xml index 3c6f6eec..9aa66bd9 100644 --- a/app/src/main/res/values-es/strings-es.xml +++ b/app/src/main/res/values-es/strings-es.xml @@ -1,55 +1,5 @@ - - - search_providers_list - app_locale - search_type_list - auto_update - skip_update_key - prerelease_update - manual_check_update - fast_forward_button_time - benene_count - subtitle_settings_key - subtitle_settings_chromecast_key - quality_pref_key - prefer_limit_title_key - prefer_limit_title_rez_key - video_buffer_size_key - video_buffer_length_key - video_buffer_clear_key - video_buffer_disk_key - unknown_prerelease - use_system_brightness_key - swipe_enabled_key - playback_speed_enabled_key - player_resize_enabled_key - pip_enabled_key - double_tap_enabled_key - double_tap_pause_enabled_key - double_tap_seek_time_key - swipe_vertical_enabled_key - display_sub_key - show_fillers_key - random_button_key - provider_lang_key - dns_key - download_path_key - Cloudstream - app_layout_key - primary_color_key - restore_key - killswitch_key - backup_key - prefer_media_type_key - app_theme_key - episode_sync_enabled_key - log_enabled_key - show_logcat_key - bottom_title_key - poster_ui_key - subtitles_encoding_key - + %d %s | %sMB %s • %sGB diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 775f3501..b1232736 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -31,6 +31,7 @@ swipe_vertical_enabled_key display_sub_key show_fillers_key + show_trailers_key random_button_key provider_lang_key dns_key @@ -249,6 +250,7 @@ Only sends data on crashes Sends no data Show filler episode for anime + Show trailers Show app updates Automatically search for new updates on start Update to prereleases diff --git a/app/src/main/res/xml/settins_ui.xml b/app/src/main/res/xml/settins_ui.xml index 2c964cff..cbb0a654 100644 --- a/app/src/main/res/xml/settins_ui.xml +++ b/app/src/main/res/xml/settins_ui.xml @@ -29,6 +29,11 @@ android:key="@string/bottom_title_key" android:summary="@string/bottom_title_settings_des" android:title="@string/bottom_title_settings" /> +