From 64ce14e290670c5214ca05d900acb87218700fb0 Mon Sep 17 00:00:00 2001 From: LagradOst Date: Sat, 4 Dec 2021 23:40:24 +0100 Subject: [PATCH] small fixes --- app/build.gradle | 8 ++-- app/src/main/AndroidManifest.xml | 12 ++++-- .../cloudstream3/ui/home/HomeFragment.kt | 8 ++-- .../cloudstream3/ui/player/PlayerFragment.kt | 37 ++++++++++++++++--- .../widget/CenterZoomLayoutManager.kt | 1 - build.gradle | 4 +- 6 files changed, 50 insertions(+), 20 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 34ff6d40..6c8713f5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -88,7 +88,7 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation 'androidx.core:core-ktx:1.7.0' - implementation 'androidx.appcompat:appcompat:1.3.1' + implementation 'androidx.appcompat:appcompat:1.4.0' implementation 'com.google.android.material:material:1.4.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.2' implementation 'androidx.navigation:navigation-fragment-ktx:2.4.0-beta02' @@ -118,9 +118,9 @@ dependencies { // implementation "androidx.leanback:leanback-paging:1.1.0-alpha09" // Exoplayer - implementation 'com.google.android.exoplayer:exoplayer:2.15.1' - implementation 'com.google.android.exoplayer:extension-cast:2.15.1' - implementation "com.google.android.exoplayer:extension-mediasession:2.15.1" + implementation 'com.google.android.exoplayer:exoplayer:2.16.1' + implementation 'com.google.android.exoplayer:extension-cast:2.16.1' + implementation "com.google.android.exoplayer:extension-mediasession:2.16.1" //implementation "com.google.android.exoplayer:extension-leanback:2.14.0" // Bug reports diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5bc1eaf1..f10f5b9d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -49,6 +49,7 @@ + @@ -57,11 +58,16 @@ - - - + + + + + + + + diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt index 5c7fb5a8..937832be 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt @@ -221,8 +221,8 @@ class HomeFragment : Fragment() { ) { callback -> handleSearchClickCallback(activity, callback) } - home_main_poster_recyclerview.post { - (home_main_poster_recyclerview.layoutManager as CenterZoomLayoutManager?)?.let { manager -> + home_main_poster_recyclerview?.post { + (home_main_poster_recyclerview?.layoutManager as CenterZoomLayoutManager?)?.let { manager -> manager.updateSize(forceUpdate = true) if (randomSize > 2) { manager.scrollToPosition(randomSize / 2) @@ -409,7 +409,7 @@ class HomeFragment : Fragment() { LinearSnapHelper().attachToRecyclerView(home_main_poster_recyclerview) // snap val centerLayoutManager = CenterZoomLayoutManager(context, LinearLayoutManager.HORIZONTAL, false) centerLayoutManager.setOnSizeListener { index -> - (home_main_poster_recyclerview.adapter as HomeChildItemAdapter?)?.cardList?.get(index)?.let { random -> + (home_main_poster_recyclerview?.adapter as HomeChildItemAdapter?)?.cardList?.get(index)?.let { random -> home_main_play.setOnClickListener { activity.loadSearchResult(random, START_ACTION_RESUME_LATEST) } @@ -423,7 +423,7 @@ class HomeFragment : Fragment() { } else "" } } - home_main_poster_recyclerview.layoutManager = centerLayoutManager // scale + home_main_poster_recyclerview?.layoutManager = centerLayoutManager // scale reloadStored() val apiName = context?.getKey(HOMEPAGE_API) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt index a1636f48..f7a6f6f0 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt @@ -119,6 +119,7 @@ const val EXTRA_CONTROL_TYPE = "control_type" const val PLAYBACK_SPEED = "playback_speed" const val RESIZE_MODE_KEY = "resize_mode" // Last used resize mode const val PLAYBACK_SPEED_KEY = "playback_speed" // Last used playback speed +const val PREFERRED_SUBS_KEY = "preferred_subtitles" // Last used resize mode const val OPENING_PERCENTAGE = 50 const val AUTOLOAD_NEXT_EPISODE_PERCENTAGE = 80 @@ -1428,6 +1429,10 @@ class PlayerFragment : Fragment() { playbackPosition = it } + arguments?.getString(PREFERRED_SUBS_KEY)?.let { + setPreferredSubLanguage(it) + } + sources_btt.visibility = if (isDownloadedFile) if (context?.getSubs()?.isNullOrEmpty() != false) @@ -1443,11 +1448,17 @@ class PlayerFragment : Fragment() { isFullscreen = savedInstanceState.getBoolean(STATE_PLAYER_FULLSCREEN) isPlayerPlaying = savedInstanceState.getBoolean(STATE_PLAYER_PLAYING) resizeMode = savedInstanceState.getInt(RESIZE_MODE_KEY) + savedInstanceState.getString(PREFERRED_SUBS_KEY)?.let { + setPreferredSubLanguage(it) + } + savedInstanceState.getString("data")?.let { + playerData = mapper.readValue(it) + } playbackSpeed = savedInstanceState.getFloat(PLAYBACK_SPEED) } - resizeMode = requireContext().getKey(RESIZE_MODE_KEY, 0)!! - playbackSpeed = requireContext().getKey(PLAYBACK_SPEED_KEY, 1f)!! + resizeMode = context?.getKey(RESIZE_MODE_KEY, 0) ?: 0 + playbackSpeed = context?.getKey(PLAYBACK_SPEED_KEY, 1f) ?: 1f activity?.let { it.contentResolver?.registerContentObserver( @@ -1666,7 +1677,7 @@ class PlayerFragment : Fragment() { changeSkip() - // initPlayer() + initPlayer() } private fun getCurrentUrl(): ExtractorLink? { @@ -1741,7 +1752,7 @@ class PlayerFragment : Fragment() { if (item.getId() == id) { if (sorted.size > i + 1) { setMirrorId(sorted[i + 1].getId()) - initPlayer() + initPlayer(getCurrentUrl()) } } } @@ -1769,7 +1780,13 @@ class PlayerFragment : Fragment() { override fun onStart() { super.onStart() if (!isCurrentlyPlaying) { - initPlayer() + if (isDownloadedFile) { + initPlayer(null, uriData.uri) + } else { + getCurrentUrl()?.let { + initPlayer(it) + } + } } if (player_view != null) player_view?.onResume() } @@ -1790,7 +1807,13 @@ class PlayerFragment : Fragment() { activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE if (Util.SDK_INT <= 23) { if (!isCurrentlyPlaying) { - initPlayer() + if (isDownloadedFile) { + initPlayer(null, uriData.uri) + } else { + getCurrentUrl()?.let { + initPlayer(it) + } + } } if (player_view != null) player_view?.onResume() } @@ -1864,6 +1887,7 @@ class PlayerFragment : Fragment() { arguments?.putBoolean(STATE_PLAYER_FULLSCREEN, isFullscreen) arguments?.putBoolean(STATE_PLAYER_PLAYING, isPlayerPlaying) arguments?.putInt(RESIZE_MODE_KEY, resizeMode) + arguments?.putString(PREFERRED_SUBS_KEY, preferredSubtitles) arguments?.putFloat(PLAYBACK_SPEED, playbackSpeed) if (!isDownloadedFile && this::playerData.isInitialized) { arguments?.putString("data", mapper.writeValueAsString(playerData)) @@ -1880,6 +1904,7 @@ class PlayerFragment : Fragment() { outState.putBoolean(STATE_PLAYER_FULLSCREEN, isFullscreen) outState.putBoolean(STATE_PLAYER_PLAYING, isPlayerPlaying) outState.putInt(RESIZE_MODE_KEY, resizeMode) + outState.putString(PREFERRED_SUBS_KEY, preferredSubtitles) outState.putFloat(PLAYBACK_SPEED, playbackSpeed) if (!isDownloadedFile && this::playerData.isInitialized) { outState.putString("data", mapper.writeValueAsString(playerData)) diff --git a/app/src/main/java/com/lagradost/cloudstream3/widget/CenterZoomLayoutManager.kt b/app/src/main/java/com/lagradost/cloudstream3/widget/CenterZoomLayoutManager.kt index e6b833ea..6f5d7592 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/widget/CenterZoomLayoutManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/widget/CenterZoomLayoutManager.kt @@ -81,7 +81,6 @@ class CenterZoomLayoutManager : LinearLayoutManager { if(waitForSnap != null) { this.getChildAt(snapChild ?: 1)?.let { view -> LinearSnapHelper().calculateDistanceToFinalSnap(this,view)?.get(0)?.let { dx -> - println("DX: $dx") waitForSnap?.invoke(dx) waitForSnap = null } diff --git a/build.gradle b/build.gradle index 3d5d3859..47a254a0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,12 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = "1.4.32" + ext.kotlin_version = "1.5.21" repositories { google() jcenter() } dependencies { - classpath "com.android.tools.build:gradle:4.1.1" + classpath "com.android.tools.build:gradle:4.1.3" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong