mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
moved to nav_view
This commit is contained in:
parent
58b131ec49
commit
0f7745449e
11 changed files with 302 additions and 104 deletions
|
@ -5,6 +5,7 @@ import android.app.PictureInPictureParams
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.pm.ActivityInfo
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
|
@ -12,14 +13,23 @@ import android.content.res.Resources
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.*
|
import android.view.*
|
||||||
|
import android.view.View.GONE
|
||||||
|
import android.view.View.VISIBLE
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
import androidx.core.view.isVisible
|
||||||
|
import androidx.core.view.marginBottom
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
import androidx.navigation.NavOptions
|
import androidx.navigation.NavOptions
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
import androidx.navigation.fragment.NavHostFragment
|
import androidx.navigation.fragment.NavHostFragment
|
||||||
|
import androidx.navigation.ui.setupWithNavController
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
|
import androidx.transition.ChangeBounds
|
||||||
|
import androidx.transition.TransitionManager
|
||||||
import com.google.android.gms.cast.framework.CastButtonFactory
|
import com.google.android.gms.cast.framework.CastButtonFactory
|
||||||
import com.jaredrummler.android.colorpicker.ColorPickerDialogListener
|
import com.jaredrummler.android.colorpicker.ColorPickerDialogListener
|
||||||
import com.lagradost.cloudstream3.APIHolder.apis
|
import com.lagradost.cloudstream3.APIHolder.apis
|
||||||
|
@ -43,6 +53,7 @@ import com.lagradost.cloudstream3.utils.InAppUpdater.Companion.runAutoUpdate
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.checkWrite
|
import com.lagradost.cloudstream3.utils.UIHelper.checkWrite
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.getResourceColor
|
import com.lagradost.cloudstream3.utils.UIHelper.getResourceColor
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.hasPIPPermission
|
import com.lagradost.cloudstream3.utils.UIHelper.hasPIPPermission
|
||||||
|
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.requestRW
|
import com.lagradost.cloudstream3.utils.UIHelper.requestRW
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.shouldShowPIPMode
|
import com.lagradost.cloudstream3.utils.UIHelper.shouldShowPIPMode
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.toPx
|
import com.lagradost.cloudstream3.utils.UIHelper.toPx
|
||||||
|
@ -172,7 +183,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun AppCompatActivity.backPressed(): Boolean {
|
private fun AppCompatActivity.backPressed(): Boolean {
|
||||||
val currentFragment = supportFragmentManager.fragments.last {
|
/*val currentFragment = supportFragmentManager.fragments.last {
|
||||||
it.isVisible
|
it.isVisible
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,8 +211,8 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
||||||
backEvent.invoke(true)
|
backEvent.invoke(true)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
backEvent.invoke(false)
|
backEvent.invoke(false)
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,16 +293,60 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
||||||
|
|
||||||
val navController = findNavController(R.id.nav_host_fragment)
|
val navController = findNavController(R.id.nav_host_fragment)
|
||||||
|
|
||||||
navOptions = NavOptions.Builder()
|
/*navOptions = NavOptions.Builder()
|
||||||
.setLaunchSingleTop(true)
|
.setLaunchSingleTop(true)
|
||||||
.setEnterAnim(R.anim.nav_enter_anim)
|
.setEnterAnim(R.anim.nav_enter_anim)
|
||||||
.setExitAnim(R.anim.nav_exit_anim)
|
.setExitAnim(R.anim.nav_exit_anim)
|
||||||
.setPopEnterAnim(R.anim.nav_pop_enter)
|
.setPopEnterAnim(R.anim.nav_pop_enter)
|
||||||
.setPopExitAnim(R.anim.nav_pop_exit)
|
.setPopExitAnim(R.anim.nav_pop_exit)
|
||||||
.setPopUpTo(navController.graph.startDestination, false)
|
.setPopUpTo(navController.graph.startDestination, false)
|
||||||
.build()
|
.build()*/
|
||||||
|
nav_view.setupWithNavController(navController)
|
||||||
|
|
||||||
nav_view.setOnNavigationItemSelectedListener { item ->
|
var startUp = true
|
||||||
|
navController.addOnDestinationChangedListener { _, destination, _ ->
|
||||||
|
// nav_view.hideKeyboard()
|
||||||
|
/*if (destination.id != R.id.navigation_player) {
|
||||||
|
requestedOrientation = if (settingsManager?.getBoolean("force_landscape", false) == true) {
|
||||||
|
ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
|
||||||
|
} else {
|
||||||
|
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// Fucks up anime info layout since that has its own layout
|
||||||
|
cast_mini_controller_holder?.isVisible = destination.id != R.id.navigation_results
|
||||||
|
|
||||||
|
if (listOf(
|
||||||
|
R.id.navigation_home,
|
||||||
|
R.id.navigation_search,
|
||||||
|
R.id.navigation_downloads,
|
||||||
|
R.id.navigation_settings,
|
||||||
|
R.id.navigation_download_child
|
||||||
|
).contains(destination.id)
|
||||||
|
) {
|
||||||
|
nav_view.visibility = VISIBLE
|
||||||
|
if (nav_view.marginBottom < 0) {
|
||||||
|
nav_view.layoutParams = nav_view.layoutParams.apply {
|
||||||
|
val transition = ChangeBounds()
|
||||||
|
transition.duration = 100 // DURATION OF ANIMATION IN MS
|
||||||
|
TransitionManager.beginDelayedTransition(homeRoot, transition)
|
||||||
|
(this as ConstraintLayout.LayoutParams).setMargins(0, 0, 0, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (startUp) nav_view.visibility = GONE
|
||||||
|
nav_view.layoutParams = nav_view.layoutParams.apply {
|
||||||
|
val transition = ChangeBounds()
|
||||||
|
transition.duration = 100 // DURATION OF ANIMATION IN MS
|
||||||
|
TransitionManager.beginDelayedTransition(homeRoot, transition)
|
||||||
|
(this as ConstraintLayout.LayoutParams).setMargins(0, 0, 0, -nav_view.height)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
startUp = false
|
||||||
|
}
|
||||||
|
|
||||||
|
/*nav_view.setOnNavigationItemSelectedListener { item ->
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.navigation_home -> {
|
R.id.navigation_home -> {
|
||||||
navController.navigate(R.id.navigation_home, null, navOptions)
|
navController.navigate(R.id.navigation_home, null, navOptions)
|
||||||
|
@ -307,7 +362,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}*/
|
||||||
|
|
||||||
nav_view.itemRippleColor = ColorStateList.valueOf(getResourceColor(R.attr.colorPrimary, 0.1f))
|
nav_view.itemRippleColor = ColorStateList.valueOf(getResourceColor(R.attr.colorPrimary, 0.1f))
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import android.app.Activity
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.fragment.app.FragmentActivity
|
|
||||||
import com.lagradost.cloudstream3.MainActivity
|
import com.lagradost.cloudstream3.MainActivity
|
||||||
import com.lagradost.cloudstream3.R
|
import com.lagradost.cloudstream3.R
|
||||||
import com.lagradost.cloudstream3.ui.player.PlayerFragment
|
import com.lagradost.cloudstream3.ui.player.PlayerFragment
|
||||||
|
@ -12,6 +11,7 @@ import com.lagradost.cloudstream3.ui.player.UriData
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.getNameFull
|
import com.lagradost.cloudstream3.utils.AppUtils.getNameFull
|
||||||
import com.lagradost.cloudstream3.utils.DataStore.getKey
|
import com.lagradost.cloudstream3.utils.DataStore.getKey
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.getViewPos
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.getViewPos
|
||||||
|
import com.lagradost.cloudstream3.utils.UIHelper.navigate
|
||||||
import com.lagradost.cloudstream3.utils.VideoDownloadHelper
|
import com.lagradost.cloudstream3.utils.VideoDownloadHelper
|
||||||
import com.lagradost.cloudstream3.utils.VideoDownloadManager
|
import com.lagradost.cloudstream3.utils.VideoDownloadManager
|
||||||
|
|
||||||
|
@ -85,30 +85,20 @@ object DownloadButtonSetup {
|
||||||
VideoDownloadManager.KEY_DOWNLOAD_INFO,
|
VideoDownloadManager.KEY_DOWNLOAD_INFO,
|
||||||
click.data.id.toString()
|
click.data.id.toString()
|
||||||
) ?: return
|
) ?: return
|
||||||
(act as FragmentActivity).supportFragmentManager.beginTransaction()
|
|
||||||
.setCustomAnimations(
|
act.navigate(R.id.global_to_navigation_player, PlayerFragment.newInstance(
|
||||||
R.anim.enter_anim,
|
UriData(
|
||||||
R.anim.exit_anim,
|
info.path.toString(),
|
||||||
R.anim.pop_enter,
|
keyInfo.relativePath,
|
||||||
R.anim.pop_exit
|
keyInfo.displayName,
|
||||||
)
|
click.data.parentId,
|
||||||
.add(
|
click.data.id,
|
||||||
R.id.homeRoot,
|
headerName ?: "null",
|
||||||
PlayerFragment.newInstance(
|
if (click.data.episode <= 0) null else click.data.episode,
|
||||||
UriData(
|
click.data.season
|
||||||
info.path.toString(),
|
),
|
||||||
keyInfo.relativePath,
|
act.getViewPos(click.data.id)?.position ?: 0
|
||||||
keyInfo.displayName,
|
))
|
||||||
click.data.parentId,
|
|
||||||
click.data.id,
|
|
||||||
headerName ?: "null",
|
|
||||||
if (click.data.episode <= 0) null else click.data.episode,
|
|
||||||
click.data.season
|
|
||||||
),
|
|
||||||
act.getViewPos(click.data.id)?.position ?: 0
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.commit()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,13 +21,12 @@ import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
class DownloadChildFragment : Fragment() {
|
class DownloadChildFragment : Fragment() {
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance(headerName: String, folder: String) =
|
fun newInstance(headerName: String, folder: String) : Bundle {
|
||||||
DownloadChildFragment().apply {
|
return Bundle().apply {
|
||||||
arguments = Bundle().apply {
|
putString("folder", folder)
|
||||||
putString("folder", folder)
|
putString("name", headerName)
|
||||||
putString("name", headerName)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import android.widget.FrameLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
@ -92,15 +93,15 @@ class HomeFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var homeViewModel: HomeViewModel
|
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View? {
|
): View? {
|
||||||
homeViewModel =
|
// homeViewModel =
|
||||||
ViewModelProvider(this).get(HomeViewModel::class.java)
|
// ViewModelProvider(activity ?: this).get(HomeViewModel::class.java)
|
||||||
|
|
||||||
return inflater.inflate(R.layout.fragment_home, container, false)
|
return inflater.inflate(R.layout.fragment_home, container, false)
|
||||||
}
|
}
|
||||||
|
@ -406,6 +407,10 @@ class HomeFragment : Fragment() {
|
||||||
home_master_recycler.layoutManager = GridLayoutManager(context, 1)
|
home_master_recycler.layoutManager = GridLayoutManager(context, 1)
|
||||||
|
|
||||||
reloadStored()
|
reloadStored()
|
||||||
homeViewModel.loadAndCancel(context?.getKey<String>(HOMEPAGE_API))
|
val apiName = context?.getKey<String>(HOMEPAGE_API)
|
||||||
|
if(homeViewModel.apiName.value != apiName) {
|
||||||
|
println("COUGHT HOME : " + homeViewModel.apiName.value + " AT " + apiName)
|
||||||
|
homeViewModel.loadAndCancel(apiName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -169,6 +169,7 @@ class PlayerFragment : Fragment() {
|
||||||
// ============ TORRENT ============
|
// ============ TORRENT ============
|
||||||
//private var torrentStream: TorrentStream? = null
|
//private var torrentStream: TorrentStream? = null
|
||||||
private var lastTorrentUrl = ""
|
private var lastTorrentUrl = ""
|
||||||
|
|
||||||
//private val isTorrent: Boolean get() = torrentStream != null
|
//private val isTorrent: Boolean get() = torrentStream != null
|
||||||
private fun initTorrentStream(torrentUrl: String) {
|
private fun initTorrentStream(torrentUrl: String) {
|
||||||
if (lastTorrentUrl == torrentUrl) return
|
if (lastTorrentUrl == torrentUrl) return
|
||||||
|
@ -751,29 +752,27 @@ class PlayerFragment : Fragment() {
|
||||||
private var volumeObserver: SettingsContentObserver? = null
|
private var volumeObserver: SettingsContentObserver? = null
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance(data: PlayerData, startPos: Long? = null) =
|
fun newInstance(data: PlayerData, startPos: Long? = null): Bundle {
|
||||||
PlayerFragment().apply {
|
return Bundle().apply {
|
||||||
arguments = Bundle().apply {
|
//println(data)
|
||||||
//println(data)
|
putString("data", mapper.writeValueAsString(data))
|
||||||
putString("data", mapper.writeValueAsString(data))
|
println("PUT START: " + startPos)
|
||||||
println("PUT START: " + startPos)
|
if (startPos != null) {
|
||||||
if (startPos != null) {
|
putLong(STATE_RESUME_POSITION, startPos)
|
||||||
putLong(STATE_RESUME_POSITION, startPos)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun newInstance(uriData: UriData, startPos: Long? = null) =
|
fun newInstance(uriData: UriData, startPos: Long? = null): Bundle {
|
||||||
PlayerFragment().apply {
|
return Bundle().apply {
|
||||||
arguments = Bundle().apply {
|
//println(data)
|
||||||
//println(data)
|
putString("uriData", mapper.writeValueAsString(uriData))
|
||||||
putString("uriData", mapper.writeValueAsString(uriData))
|
|
||||||
|
|
||||||
if (startPos != null) {
|
if (startPos != null) {
|
||||||
putLong(STATE_RESUME_POSITION, startPos)
|
putLong(STATE_RESUME_POSITION, startPos)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun savePos() {
|
private fun savePos() {
|
||||||
|
@ -1662,8 +1661,8 @@ class PlayerFragment : Fragment() {
|
||||||
savePos()
|
savePos()
|
||||||
SubtitlesFragment.applyStyleEvent -= ::onSubStyleChanged
|
SubtitlesFragment.applyStyleEvent -= ::onSubStyleChanged
|
||||||
|
|
||||||
// torrentStream?.stopStream()
|
// torrentStream?.stopStream()
|
||||||
// torrentStream = null
|
// torrentStream = null
|
||||||
|
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
canEnterPipMode = false
|
canEnterPipMode = false
|
||||||
|
@ -1680,7 +1679,7 @@ class PlayerFragment : Fragment() {
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
savePos()
|
savePos()
|
||||||
super.onPause()
|
super.onPause()
|
||||||
// torrentStream?.currentTorrent?.pause()
|
// torrentStream?.currentTorrent?.pause()
|
||||||
if (Util.SDK_INT <= 23) {
|
if (Util.SDK_INT <= 23) {
|
||||||
if (player_view != null) player_view.onPause()
|
if (player_view != null) player_view.onPause()
|
||||||
releasePlayer()
|
releasePlayer()
|
||||||
|
@ -1987,12 +1986,12 @@ class PlayerFragment : Fragment() {
|
||||||
video_title_rez?.text =
|
video_title_rez?.text =
|
||||||
if (height == null || width == null) currentUrl?.name
|
if (height == null || width == null) currentUrl?.name
|
||||||
?: "" else
|
?: "" else
|
||||||
// if (isTorrent) "${width}x${height}" else
|
// if (isTorrent) "${width}x${height}" else
|
||||||
if (isDownloadedFile || currentUrl?.name == null) "${width}x${height}" else "${currentUrl.name} - ${width}x${height}"
|
if (isDownloadedFile || currentUrl?.name == null) "${width}x${height}" else "${currentUrl.name} - ${width}x${height}"
|
||||||
|
|
||||||
if (!hasUsedFirstRender) { // DON'T WANT TO SET MULTIPLE MESSAGES
|
if (!hasUsedFirstRender) { // DON'T WANT TO SET MULTIPLE MESSAGES
|
||||||
//&& !isTorrent
|
//&& !isTorrent
|
||||||
if (!isDownloadedFile && exoPlayer.duration in 5_000..10_000) {
|
if (!isDownloadedFile && exoPlayer.duration in 5_000..10_000) {
|
||||||
// if(getapi apiName )
|
// if(getapi apiName )
|
||||||
showToast(activity, R.string.vpn_might_be_needed, LENGTH_SHORT)
|
showToast(activity, R.string.vpn_might_be_needed, LENGTH_SHORT)
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@ import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
|
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.getStatusBarHeight
|
import com.lagradost.cloudstream3.utils.UIHelper.getStatusBarHeight
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
|
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
|
||||||
|
import com.lagradost.cloudstream3.utils.UIHelper.navigate
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.popCurrentPage
|
import com.lagradost.cloudstream3.utils.UIHelper.popCurrentPage
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIcons
|
import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIcons
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIconsAndNoStringRes
|
import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIconsAndNoStringRes
|
||||||
|
@ -152,15 +153,15 @@ fun ResultEpisode.getWatchProgress(): Float {
|
||||||
|
|
||||||
class ResultFragment : Fragment() {
|
class ResultFragment : Fragment() {
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance(url: String, apiName: String, startAction: Int = 0, startValue: Int = 0) =
|
fun newInstance(url: String, apiName: String, startAction: Int = 0, startValue: Int = 0): Bundle {
|
||||||
ResultFragment().apply {
|
return Bundle().apply {
|
||||||
arguments = Bundle().apply {
|
putString("url", url)
|
||||||
putString("url", url)
|
putString("apiName", apiName)
|
||||||
putString("apiName", apiName)
|
putInt("startAction", startAction)
|
||||||
putInt("startAction", startAction)
|
putInt("startValue", startValue)
|
||||||
putInt("startValue", startValue)
|
putBoolean("restart", true)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var currentLoadingCount = 0 // THIS IS USED TO PREVENT LATE EVENTS, AFTER DISMISS WAS CLICKED
|
private var currentLoadingCount = 0 // THIS IS USED TO PREVENT LATE EVENTS, AFTER DISMISS WAS CLICKED
|
||||||
|
@ -262,6 +263,11 @@ class ResultFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
val restart = arguments?.getBoolean("restart") ?: false
|
||||||
|
if (restart) {
|
||||||
|
arguments?.putBoolean("restart", false)
|
||||||
|
}
|
||||||
|
|
||||||
activity?.window?.decorView?.clearFocus()
|
activity?.window?.decorView?.clearFocus()
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
|
|
||||||
|
@ -284,6 +290,7 @@ class ResultFragment : Fragment() {
|
||||||
startAction = arguments?.getInt("startAction") ?: START_ACTION_NORMAL
|
startAction = arguments?.getInt("startAction") ?: START_ACTION_NORMAL
|
||||||
startValue = arguments?.getInt("startValue") ?: START_VALUE_NORMAL
|
startValue = arguments?.getInt("startValue") ?: START_VALUE_NORMAL
|
||||||
|
|
||||||
|
|
||||||
val api = getApiFromName(apiName)
|
val api = getApiFromName(apiName)
|
||||||
if (media_route_button != null) {
|
if (media_route_button != null) {
|
||||||
val chromecastSupport = api.hasChromecastSupport
|
val chromecastSupport = api.hasChromecastSupport
|
||||||
|
@ -701,19 +708,12 @@ class ResultFragment : Fragment() {
|
||||||
|
|
||||||
ACTION_PLAY_EPISODE_IN_PLAYER -> {
|
ACTION_PLAY_EPISODE_IN_PLAYER -> {
|
||||||
if (buildInPlayer) {
|
if (buildInPlayer) {
|
||||||
(activity as AppCompatActivity?)?.supportFragmentManager?.beginTransaction()
|
activity.navigate(
|
||||||
?.setCustomAnimations(
|
R.id.global_to_navigation_player, PlayerFragment.newInstance(
|
||||||
R.anim.enter_anim,
|
PlayerData(index, null, 0),
|
||||||
R.anim.exit_anim,
|
episodeClick.data.getRealPosition()
|
||||||
R.anim.pop_enter,
|
)
|
||||||
R.anim.pop_exit
|
)
|
||||||
)?.add(
|
|
||||||
R.id.homeRoot,
|
|
||||||
PlayerFragment.newInstance(
|
|
||||||
PlayerData(index, null, 0),
|
|
||||||
episodeClick.data.getRealPosition()
|
|
||||||
)
|
|
||||||
)?.commit()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -827,13 +827,16 @@ class ResultFragment : Fragment() {
|
||||||
observe(viewModel.publicEpisodes) { episodes ->
|
observe(viewModel.publicEpisodes) { episodes ->
|
||||||
when (episodes) {
|
when (episodes) {
|
||||||
is Resource.Failure -> {
|
is Resource.Failure -> {
|
||||||
result_episode_loading.isVisible = false
|
result_episode_loading?.isVisible = false
|
||||||
|
//result_episodes?.isVisible = false
|
||||||
}
|
}
|
||||||
is Resource.Loading -> {
|
is Resource.Loading -> {
|
||||||
result_episode_loading.isVisible = true
|
result_episode_loading?.isVisible = true
|
||||||
|
// result_episodes?.isVisible = false
|
||||||
}
|
}
|
||||||
is Resource.Success -> {
|
is Resource.Success -> {
|
||||||
result_episode_loading.isVisible = false
|
//result_episodes?.isVisible = true
|
||||||
|
result_episode_loading?.isVisible = false
|
||||||
if (result_episodes == null || result_episodes.adapter == null) return@observe
|
if (result_episodes == null || result_episodes.adapter == null) return@observe
|
||||||
currentEpisodes = episodes.value
|
currentEpisodes = episodes.value
|
||||||
(result_episodes?.adapter as EpisodeAdapter?)?.cardList = episodes.value
|
(result_episodes?.adapter as EpisodeAdapter?)?.cardList = episodes.value
|
||||||
|
@ -862,8 +865,13 @@ class ResultFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
observe(viewModel.publicEpisodesCount) { count ->
|
observe(viewModel.publicEpisodesCount) { count ->
|
||||||
result_episodes_text.text =
|
if (count < 0) {
|
||||||
"$count ${if (count == 1) getString(R.string.episode) else getString(R.string.episodes)}"
|
result_episodes_text?.isVisible = false
|
||||||
|
} else {
|
||||||
|
// result_episodes_text?.isVisible = true
|
||||||
|
result_episodes_text?.text =
|
||||||
|
"$count ${if (count == 1) getString(R.string.episode) else getString(R.string.episodes)}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
observe(viewModel.id) {
|
observe(viewModel.id) {
|
||||||
|
@ -1117,7 +1125,7 @@ class ResultFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viewModel.resultResponse.value == null) {
|
if (restart || viewModel.resultResponse.value == null) {
|
||||||
viewModel.load(ctx, tempUrl, apiName, showFillers)
|
viewModel.load(ctx, tempUrl, apiName, showFillers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
|
|
||||||
// idk, if you find a way of automating this it would be great
|
// idk, if you find a way of automating this it would be great
|
||||||
private val languages = arrayListOf(
|
private val languages = arrayListOf(
|
||||||
Triple("\uD83C\uDDEC\uD83C\uDDE7", "Spanish", "es"),
|
Triple("\uD83C\uDDEA\uD83C\uDDF8", "Spanish", "es"),
|
||||||
Triple("\uD83C\uDDEC\uD83C\uDDE7", "English", "en"),
|
Triple("\uD83C\uDDEC\uD83C\uDDE7", "English", "en"),
|
||||||
Triple("\uD83C\uDDFB\uD83C\uDDF3", "Viet Nam", "vi"),
|
Triple("\uD83C\uDDFB\uD83C\uDDF3", "Viet Nam", "vi"),
|
||||||
Triple("\uD83C\uDDF3\uD83C\uDDF1", "Dutch", "nl"),
|
Triple("\uD83C\uDDF3\uD83C\uDDF1", "Dutch", "nl"),
|
||||||
|
|
|
@ -32,6 +32,7 @@ import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showMultiDialog
|
||||||
import com.lagradost.cloudstream3.utils.SubtitleHelper
|
import com.lagradost.cloudstream3.utils.SubtitleHelper
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
|
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.hideSystemUI
|
import com.lagradost.cloudstream3.utils.UIHelper.hideSystemUI
|
||||||
|
import com.lagradost.cloudstream3.utils.UIHelper.navigate
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.popCurrentPage
|
import com.lagradost.cloudstream3.utils.UIHelper.popCurrentPage
|
||||||
import kotlinx.android.synthetic.main.subtitle_settings.*
|
import kotlinx.android.synthetic.main.subtitle_settings.*
|
||||||
|
|
||||||
|
@ -67,7 +68,10 @@ class SubtitlesFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun push(activity: Activity?, hide: Boolean = true) {
|
fun push(activity: Activity?, hide: Boolean = true) {
|
||||||
(activity as FragmentActivity?)?.supportFragmentManager?.beginTransaction()
|
activity.navigate(R.id.global_to_navigation_subtitles, Bundle().apply {
|
||||||
|
putBoolean("hide", hide)
|
||||||
|
})
|
||||||
|
/*(activity as FragmentActivity?)?.supportFragmentManager?.beginTransaction()
|
||||||
?.setCustomAnimations(
|
?.setCustomAnimations(
|
||||||
R.anim.enter_anim,
|
R.anim.enter_anim,
|
||||||
R.anim.exit_anim,
|
R.anim.exit_anim,
|
||||||
|
@ -82,7 +86,7 @@ class SubtitlesFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
?.commit()
|
?.commit()*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDefColor(id: Int): Int {
|
private fun getDefColor(id: Int): Int {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import com.google.android.gms.common.wrappers.Wrappers
|
||||||
import com.lagradost.cloudstream3.R
|
import com.lagradost.cloudstream3.R
|
||||||
import com.lagradost.cloudstream3.SearchResponse
|
import com.lagradost.cloudstream3.SearchResponse
|
||||||
import com.lagradost.cloudstream3.ui.result.ResultFragment
|
import com.lagradost.cloudstream3.ui.result.ResultFragment
|
||||||
|
import com.lagradost.cloudstream3.utils.UIHelper.navigate
|
||||||
|
|
||||||
object AppUtils {
|
object AppUtils {
|
||||||
fun getVideoContentUri(context: Context, videoFilePath: String): Uri? {
|
fun getVideoContentUri(context: Context, videoFilePath: String): Uri? {
|
||||||
|
@ -77,10 +78,7 @@ object AppUtils {
|
||||||
fun AppCompatActivity.loadResult(url: String, apiName: String, startAction: Int = 0, startValue: Int = 0) {
|
fun AppCompatActivity.loadResult(url: String, apiName: String, startAction: Int = 0, startValue: Int = 0) {
|
||||||
this.runOnUiThread {
|
this.runOnUiThread {
|
||||||
viewModelStore.clear()
|
viewModelStore.clear()
|
||||||
this.supportFragmentManager.beginTransaction()
|
this.navigate(R.id.global_to_navigation_results, ResultFragment.newInstance(url, apiName, startAction, startValue))
|
||||||
.setCustomAnimations(R.anim.enter_anim, R.anim.exit_anim, R.anim.pop_enter, R.anim.pop_exit)
|
|
||||||
.add(R.id.homeRoot, ResultFragment.newInstance(url, apiName, startAction, startValue))
|
|
||||||
.commit()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,15 +9,14 @@ import android.content.pm.PackageManager
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.os.Bundle
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import androidx.annotation.AttrRes
|
import androidx.annotation.*
|
||||||
import androidx.annotation.ColorInt
|
|
||||||
import androidx.annotation.RequiresApi
|
|
||||||
import androidx.appcompat.view.ContextThemeWrapper
|
import androidx.appcompat.view.ContextThemeWrapper
|
||||||
import androidx.appcompat.view.menu.MenuBuilder
|
import androidx.appcompat.view.menu.MenuBuilder
|
||||||
import androidx.appcompat.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
|
@ -29,6 +28,7 @@ import androidx.core.graphics.green
|
||||||
import androidx.core.graphics.red
|
import androidx.core.graphics.red
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
|
import androidx.navigation.fragment.NavHostFragment
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.model.GlideUrl
|
import com.bumptech.glide.load.model.GlideUrl
|
||||||
|
@ -71,6 +71,14 @@ object UIHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Activity?.navigate(@IdRes navigation : Int, arguments : Bundle? = null) {
|
||||||
|
if(this is FragmentActivity) {
|
||||||
|
(supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as? NavHostFragment?)?.navController?.navigate(
|
||||||
|
navigation, arguments
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ColorInt
|
@ColorInt
|
||||||
fun Context.getResourceColor(@AttrRes resource: Int, alphaFactor: Float = 1f): Int {
|
fun Context.getResourceColor(@AttrRes resource: Int, alphaFactor: Float = 1f): Int {
|
||||||
val typedArray = obtainStyledAttributes(intArrayOf(resource))
|
val typedArray = obtainStyledAttributes(intArrayOf(resource))
|
||||||
|
@ -131,7 +139,8 @@ object UIHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun FragmentActivity.popCurrentPage() {
|
fun FragmentActivity.popCurrentPage() {
|
||||||
val currentFragment = supportFragmentManager.fragments.lastOrNull {
|
this.onBackPressed()
|
||||||
|
/*val currentFragment = supportFragmentManager.fragments.lastOrNull {
|
||||||
it.isVisible
|
it.isVisible
|
||||||
} ?: return
|
} ?: return
|
||||||
|
|
||||||
|
@ -143,7 +152,7 @@ object UIHelper {
|
||||||
R.anim.pop_exit
|
R.anim.pop_exit
|
||||||
)
|
)
|
||||||
.remove(currentFragment)
|
.remove(currentFragment)
|
||||||
.commitAllowingStateLoss()
|
.commitAllowingStateLoss()*/
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
fun FragmentActivity.popCurrentPage(isInPlayer: Boolean, isInExpandedView: Boolean, isInResults: Boolean) {
|
fun FragmentActivity.popCurrentPage(isInPlayer: Boolean, isInExpandedView: Boolean, isInResults: Boolean) {
|
||||||
|
|
|
@ -5,6 +5,109 @@
|
||||||
android:id="@+id/mobile_navigation"
|
android:id="@+id/mobile_navigation"
|
||||||
app:startDestination="@+id/navigation_home">
|
app:startDestination="@+id/navigation_home">
|
||||||
|
|
||||||
|
<action android:id="@+id/global_to_navigation_results"
|
||||||
|
app:destination="@id/navigation_results"
|
||||||
|
app:enterAnim="@anim/enter_anim"
|
||||||
|
app:exitAnim="@anim/exit_anim"
|
||||||
|
app:popEnterAnim="@anim/enter_anim"
|
||||||
|
app:popExitAnim="@anim/exit_anim"
|
||||||
|
>
|
||||||
|
<argument
|
||||||
|
android:name="url"
|
||||||
|
app:argType="string"/>
|
||||||
|
<argument
|
||||||
|
android:name="apiName"
|
||||||
|
app:argType="string"
|
||||||
|
/>
|
||||||
|
<argument
|
||||||
|
android:name="startAction"
|
||||||
|
app:argType="integer"
|
||||||
|
android:defaultValue="0"
|
||||||
|
/>
|
||||||
|
<argument
|
||||||
|
android:name="startValue"
|
||||||
|
app:argType="integer"
|
||||||
|
android:defaultValue="0"
|
||||||
|
/>
|
||||||
|
<argument
|
||||||
|
android:name="restart"
|
||||||
|
app:argType="boolean"
|
||||||
|
android:defaultValue="false"
|
||||||
|
/>
|
||||||
|
</action>
|
||||||
|
<action android:id="@+id/global_to_navigation_player"
|
||||||
|
app:destination="@id/navigation_player"
|
||||||
|
app:enterAnim="@anim/enter_anim"
|
||||||
|
app:exitAnim="@anim/exit_anim"
|
||||||
|
app:popEnterAnim="@anim/enter_anim"
|
||||||
|
app:popExitAnim="@anim/exit_anim"
|
||||||
|
>
|
||||||
|
<argument
|
||||||
|
android:name="data"
|
||||||
|
app:argType="string"
|
||||||
|
android:defaultValue="@null"
|
||||||
|
/>
|
||||||
|
<argument
|
||||||
|
android:name="uriData"
|
||||||
|
app:argType="string"
|
||||||
|
android:defaultValue="@null"
|
||||||
|
/>
|
||||||
|
<argument
|
||||||
|
android:name="resumePosition"
|
||||||
|
app:argType="long"
|
||||||
|
android:defaultValue="0L"
|
||||||
|
/>
|
||||||
|
</action>
|
||||||
|
|
||||||
|
<action android:id="@+id/global_to_navigation_home"
|
||||||
|
app:destination="@id/navigation_home"
|
||||||
|
app:enterAnim="@anim/enter_anim"
|
||||||
|
app:exitAnim="@anim/exit_anim"
|
||||||
|
app:popEnterAnim="@anim/enter_anim"
|
||||||
|
app:popExitAnim="@anim/exit_anim"
|
||||||
|
>
|
||||||
|
</action>
|
||||||
|
|
||||||
|
<action android:id="@+id/global_to_navigation_subtitles"
|
||||||
|
app:destination="@id/navigation_subtitles"
|
||||||
|
app:enterAnim="@anim/enter_anim"
|
||||||
|
app:exitAnim="@anim/exit_anim"
|
||||||
|
app:popEnterAnim="@anim/enter_anim"
|
||||||
|
app:popExitAnim="@anim/exit_anim">
|
||||||
|
<argument
|
||||||
|
android:name="hide"
|
||||||
|
app:argType="boolean"
|
||||||
|
android:defaultValue="true"
|
||||||
|
/>
|
||||||
|
</action>
|
||||||
|
|
||||||
|
<action android:id="@+id/global_to_navigation_settings"
|
||||||
|
app:destination="@id/navigation_settings"
|
||||||
|
app:enterAnim="@anim/enter_anim"
|
||||||
|
app:exitAnim="@anim/exit_anim"
|
||||||
|
app:popEnterAnim="@anim/enter_anim"
|
||||||
|
app:popExitAnim="@anim/exit_anim"
|
||||||
|
>
|
||||||
|
</action>
|
||||||
|
|
||||||
|
<action android:id="@+id/global_to_navigation_downloads"
|
||||||
|
app:destination="@id/navigation_downloads"
|
||||||
|
app:enterAnim="@anim/enter_anim"
|
||||||
|
app:exitAnim="@anim/exit_anim"
|
||||||
|
app:popEnterAnim="@anim/enter_anim"
|
||||||
|
app:popExitAnim="@anim/exit_anim"
|
||||||
|
>
|
||||||
|
</action>
|
||||||
|
|
||||||
|
<action android:id="@+id/global_to_navigation_search"
|
||||||
|
app:destination="@id/navigation_search"
|
||||||
|
app:enterAnim="@anim/enter_anim"
|
||||||
|
app:exitAnim="@anim/exit_anim"
|
||||||
|
app:popEnterAnim="@anim/enter_anim"
|
||||||
|
app:popExitAnim="@anim/exit_anim"
|
||||||
|
>
|
||||||
|
</action>
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/navigation_home"
|
android:id="@+id/navigation_home"
|
||||||
android:name="com.lagradost.cloudstream3.ui.home.HomeFragment"
|
android:name="com.lagradost.cloudstream3.ui.home.HomeFragment"
|
||||||
|
@ -21,16 +124,44 @@
|
||||||
android:id="@+id/navigation_downloads"
|
android:id="@+id/navigation_downloads"
|
||||||
android:name="com.lagradost.cloudstream3.ui.download.DownloadFragment"
|
android:name="com.lagradost.cloudstream3.ui.download.DownloadFragment"
|
||||||
android:label="@string/title_downloads"
|
android:label="@string/title_downloads"
|
||||||
tools:layout="@layout/fragment_downloads"/>
|
tools:layout="@layout/fragment_downloads">
|
||||||
|
|
||||||
|
<action android:id="@+id/action_navigation_downloads_to_navigation_download_child"
|
||||||
|
app:destination="@id/navigation_download_child">
|
||||||
|
<argument
|
||||||
|
android:name="name"
|
||||||
|
app:argType="string"/>
|
||||||
|
<argument
|
||||||
|
android:name="folder"
|
||||||
|
app:argType="string"
|
||||||
|
/>
|
||||||
|
</action>
|
||||||
|
</fragment>
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/navigation_settings"
|
android:id="@+id/navigation_settings"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:name="com.lagradost.cloudstream3.ui.settings.SettingsFragment"
|
android:name="com.lagradost.cloudstream3.ui.settings.SettingsFragment"
|
||||||
android:label="@string/title_settings"/>
|
android:label="@string/title_settings"/>
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/navigation_subtitles"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:name="com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment"
|
||||||
|
android:label="@string/subtitles_settings"/>
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/navigation_download_child"
|
android:id="@+id/navigation_download_child"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:name="com.lagradost.cloudstream3.ui.download.DownloadChildFragment"
|
android:name="com.lagradost.cloudstream3.ui.download.DownloadChildFragment"
|
||||||
android:label="@string/title_settings"/>
|
android:label="@string/title_settings"/>
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/navigation_results"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:name="com.lagradost.cloudstream3.ui.result.ResultFragment"/>
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/navigation_player"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:name="com.lagradost.cloudstream3.ui.player.PlayerFragment"/>
|
||||||
</navigation>
|
</navigation>
|
Loading…
Reference in a new issue