Merge pull request #996 from Bnyro/notification

cleanup and fixes
This commit is contained in:
Bnyro 2022-08-08 12:02:06 +02:00 committed by GitHub
commit 6d1e691f1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 126 additions and 138 deletions

View File

@ -5,7 +5,6 @@ import android.net.Uri
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.text.Html import android.text.Html
import androidx.appcompat.app.AppCompatActivity
import com.github.libretube.DONATE_URL import com.github.libretube.DONATE_URL
import com.github.libretube.GITHUB_URL import com.github.libretube.GITHUB_URL
import com.github.libretube.PIPED_GITHUB_URL import com.github.libretube.PIPED_GITHUB_URL
@ -13,10 +12,11 @@ import com.github.libretube.R
import com.github.libretube.WEBLATE_URL import com.github.libretube.WEBLATE_URL
import com.github.libretube.WEBSITE_URL import com.github.libretube.WEBSITE_URL
import com.github.libretube.databinding.ActivityAboutBinding import com.github.libretube.databinding.ActivityAboutBinding
import com.github.libretube.extensions.BaseActivity
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
class AboutActivity : AppCompatActivity() { class AboutActivity : BaseActivity() {
private lateinit var binding: ActivityAboutBinding private lateinit var binding: ActivityAboutBinding
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {

View File

@ -3,15 +3,15 @@ package com.github.libretube.activities
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.github.libretube.DISCORD_URL import com.github.libretube.DISCORD_URL
import com.github.libretube.MATRIX_URL import com.github.libretube.MATRIX_URL
import com.github.libretube.REDDIT_URL import com.github.libretube.REDDIT_URL
import com.github.libretube.TELEGRAM_URL import com.github.libretube.TELEGRAM_URL
import com.github.libretube.TWITTER_URL import com.github.libretube.TWITTER_URL
import com.github.libretube.databinding.ActivityCommunityBinding import com.github.libretube.databinding.ActivityCommunityBinding
import com.github.libretube.extensions.BaseActivity
class CommunityActivity : AppCompatActivity() { class CommunityActivity : BaseActivity() {
private lateinit var binding: ActivityCommunityBinding private lateinit var binding: ActivityCommunityBinding
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {

View File

@ -16,7 +16,6 @@ import android.view.WindowInsets
import android.view.WindowInsetsController import android.view.WindowInsetsController
import android.view.WindowManager import android.view.WindowManager
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.constraintlayout.motion.widget.MotionLayout import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintLayout
@ -30,6 +29,7 @@ import com.github.libretube.Globals
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.databinding.ActivityMainBinding import com.github.libretube.databinding.ActivityMainBinding
import com.github.libretube.dialogs.ErrorDialog import com.github.libretube.dialogs.ErrorDialog
import com.github.libretube.extensions.BaseActivity
import com.github.libretube.fragments.PlayerFragment import com.github.libretube.fragments.PlayerFragment
import com.github.libretube.models.SearchViewModel import com.github.libretube.models.SearchViewModel
import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.preferences.PreferenceHelper
@ -42,7 +42,7 @@ import com.github.libretube.util.ThemeHelper
import com.google.android.material.elevation.SurfaceColors import com.google.android.material.elevation.SurfaceColors
import com.google.android.material.navigation.NavigationBarView import com.google.android.material.navigation.NavigationBarView
class MainActivity : AppCompatActivity() { class MainActivity : BaseActivity() {
val TAG = "MainActivity" val TAG = "MainActivity"
lateinit var binding: ActivityMainBinding lateinit var binding: ActivityMainBinding
@ -54,9 +54,6 @@ class MainActivity : AppCompatActivity() {
lateinit var searchView: SearchView lateinit var searchView: SearchView
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
// set the app theme (e.g. Material You)
ThemeHelper.updateTheme(this)
// set the language // set the language
LocaleHelper.updateLanguage(this) LocaleHelper.updateLanguage(this)

View File

@ -2,18 +2,17 @@ package com.github.libretube.activities
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.databinding.ActivityNointernetBinding import com.github.libretube.databinding.ActivityNointernetBinding
import com.github.libretube.extensions.BaseActivity
import com.github.libretube.util.ConnectionHelper import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.ThemeHelper import com.github.libretube.util.ThemeHelper
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
class NoInternetActivity : AppCompatActivity() { class NoInternetActivity : BaseActivity() {
private lateinit var binding: ActivityNointernetBinding private lateinit var binding: ActivityNointernetBinding
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
ThemeHelper.updateTheme(this)
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
binding = ActivityNointernetBinding.inflate(layoutInflater) binding = ActivityNointernetBinding.inflate(layoutInflater)

View File

@ -5,11 +5,11 @@ import android.content.pm.PackageManager
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.extensions.BaseActivity
import com.github.libretube.util.ThemeHelper import com.github.libretube.util.ThemeHelper
class RouterActivity : AppCompatActivity() { class RouterActivity : BaseActivity() {
val TAG = "RouterActivity" val TAG = "RouterActivity"
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)

View File

@ -1,31 +1,20 @@
package com.github.libretube.activities package com.github.libretube.activities
import android.os.Build
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.databinding.ActivitySettingsBinding import com.github.libretube.databinding.ActivitySettingsBinding
import com.github.libretube.extensions.BaseActivity
import com.github.libretube.preferences.MainSettings import com.github.libretube.preferences.MainSettings
import com.github.libretube.util.ThemeHelper
class SettingsActivity : AppCompatActivity() { class SettingsActivity : BaseActivity() {
val TAG = "SettingsActivity" val TAG = "SettingsActivity"
lateinit var binding: ActivitySettingsBinding lateinit var binding: ActivitySettingsBinding
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
ThemeHelper.updateTheme(this)
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
binding = ActivitySettingsBinding.inflate(layoutInflater) binding = ActivitySettingsBinding.inflate(layoutInflater)
// animate the layout transition
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
overridePendingTransition(50, 50)
}
binding.root.alpha = 0F
binding.root.animate().alpha(1F).duration = 300
setContentView(binding.root) setContentView(binding.root)
binding.backImageButton.setOnClickListener { binding.backImageButton.setOnClickListener {

View File

@ -52,7 +52,7 @@ class ChannelAdapter(
val videoId = trending.url.toID() val videoId = trending.url.toID()
root.setOnLongClickListener { root.setOnLongClickListener {
VideoOptionsDialog(videoId) VideoOptionsDialog(videoId)
.show(childFragmentManager, "VideoOptionsDialog") .show(childFragmentManager, VideoOptionsDialog::class.java.name)
true true
} }
watchProgress.setWatchProgressLength(videoId, trending.duration!!) watchProgress.setWatchProgressLength(videoId, trending.duration!!)

View File

@ -61,7 +61,7 @@ class PlaylistAdapter(
val videoId = streamItem.url.toID() val videoId = streamItem.url.toID()
root.setOnLongClickListener { root.setOnLongClickListener {
VideoOptionsDialog(videoId) VideoOptionsDialog(videoId)
.show(childFragmentManager, "VideoOptionsDialog") .show(childFragmentManager, VideoOptionsDialog::class.java.name)
true true
} }

View File

@ -48,7 +48,6 @@ class PlaylistsAdapter(
val playlist = playlists[position] val playlist = playlists[position]
holder.binding.apply { holder.binding.apply {
// set imageview drawable as empty playlist if imageview empty // set imageview drawable as empty playlist if imageview empty
Log.e(TAG, playlist.thumbnail.toString())
if (playlist.thumbnail!!.split("/").size <= 4) { if (playlist.thumbnail!!.split("/").size <= 4) {
playlistThumbnail.setImageResource(R.drawable.ic_empty_playlist) playlistThumbnail.setImageResource(R.drawable.ic_empty_playlist)
playlistThumbnail.setBackgroundColor(R.attr.colorSurface) playlistThumbnail.setBackgroundColor(R.attr.colorSurface)

View File

@ -103,7 +103,7 @@ class SearchAdapter(
val videoId = item.url.toID() val videoId = item.url.toID()
root.setOnLongClickListener { root.setOnLongClickListener {
VideoOptionsDialog(videoId) VideoOptionsDialog(videoId)
.show(childFragmentManager, "VideoOptionsDialog") .show(childFragmentManager, VideoOptionsDialog::class.java.name)
true true
} }
channelImage.setOnClickListener { channelImage.setOnClickListener {
@ -176,7 +176,7 @@ class SearchAdapter(
root.setOnLongClickListener { root.setOnLongClickListener {
val playlistId = item.url!!.toID() val playlistId = item.url!!.toID()
PlaylistOptionsDialog(playlistId, false) PlaylistOptionsDialog(playlistId, false)
.show(childFragmentManager, "PlaylistOptionsDialog") .show(childFragmentManager, PlaylistOptionsDialog::class.java.name)
true true
} }
} }

View File

@ -66,7 +66,7 @@ class TrendingAdapter(
val videoId = trending.url!!.toID() val videoId = trending.url!!.toID()
root.setOnLongClickListener { root.setOnLongClickListener {
VideoOptionsDialog(videoId) VideoOptionsDialog(videoId)
.show(childFragmentManager, "VideoOptionsDialog") .show(childFragmentManager, VideoOptionsDialog::class.java.name)
true true
} }
watchProgress.setWatchProgressLength(videoId, trending.duration!!) watchProgress.setWatchProgressLength(videoId, trending.duration!!)

View File

@ -51,7 +51,7 @@ class WatchHistoryAdapter(
} }
root.setOnLongClickListener { root.setOnLongClickListener {
VideoOptionsDialog(video.videoId!!) VideoOptionsDialog(video.videoId!!)
.show(childFragmentManager, "VideoOptionsDialog") .show(childFragmentManager, VideoOptionsDialog::class.java.name)
true true
} }

View File

@ -57,7 +57,7 @@ class DeleteAccountDialog : DialogFragment() {
Toast.makeText(context, R.string.success, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.success, Toast.LENGTH_SHORT).show()
logout() logout()
val restartDialog = RequireRestartDialog() val restartDialog = RequireRestartDialog()
restartDialog.show(childFragmentManager, "RequireRestartDialog") restartDialog.show(childFragmentManager, RequireRestartDialog::class.java.name)
} }
} }
run() run()

View File

@ -7,7 +7,6 @@ import android.util.Log
import android.view.View import android.view.View
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.size import androidx.core.view.size
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
@ -38,7 +37,7 @@ class DownloadDialog : DialogFragment() {
fetchAvailableSources() fetchAvailableSources()
PermissionHelper.requestReadWrite(activity as AppCompatActivity) PermissionHelper.requestReadWrite(requireActivity())
binding.title.text = ThemeHelper.getStyledAppName(requireContext()) binding.title.text = ThemeHelper.getStyledAppName(requireContext())

View File

@ -55,8 +55,9 @@ class PlaylistOptionsDialog(
// play the playlist in the background // play the playlist in the background
context?.getString(R.string.playOnBackground) -> { context?.getString(R.string.playOnBackground) -> {
runBlocking { runBlocking {
val playlist = if (isOwner) RetrofitInstance.authApi.getPlaylist(playlistId) val playlist =
else RetrofitInstance.api.getPlaylist(playlistId) if (isOwner) RetrofitInstance.authApi.getPlaylist(playlistId)
else RetrofitInstance.api.getPlaylist(playlistId)
BackgroundHelper.playOnBackground( BackgroundHelper.playOnBackground(
context = requireContext(), context = requireContext(),
videoId = playlist.relatedStreams!![0].url.toID(), videoId = playlist.relatedStreams!![0].url.toID(),
@ -81,7 +82,7 @@ class PlaylistOptionsDialog(
context?.getString(R.string.share) -> { context?.getString(R.string.share) -> {
val shareDialog = ShareDialog(playlistId, true) val shareDialog = ShareDialog(playlistId, true)
// using parentFragmentManager, childFragmentManager doesn't work here // using parentFragmentManager, childFragmentManager doesn't work here
shareDialog.show(parentFragmentManager, "ShareDialog") shareDialog.show(parentFragmentManager, ShareDialog::class.java.name)
} }
context?.getString(R.string.deletePlaylist) -> { context?.getString(R.string.deletePlaylist) -> {
val token = PreferenceHelper.getToken() val token = PreferenceHelper.getToken()

View File

@ -6,7 +6,6 @@ import android.net.Uri
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.services.UpdateService import com.github.libretube.services.UpdateService
@ -28,7 +27,7 @@ class UpdateDialog(
val downloadUrl = getDownloadUrl(updateInfo) val downloadUrl = getDownloadUrl(updateInfo)
Log.i("downloadUrl", downloadUrl.toString()) Log.i("downloadUrl", downloadUrl.toString())
if (downloadUrl != null) { if (downloadUrl != null) {
PermissionHelper.requestReadWrite(activity as AppCompatActivity) PermissionHelper.requestReadWrite(requireActivity())
val intent = Intent(context, UpdateService::class.java) val intent = Intent(context, UpdateService::class.java)
intent.putExtra("downloadUrl", downloadUrl) intent.putExtra("downloadUrl", downloadUrl)
context?.startService(intent) context?.startService(intent)

View File

@ -55,7 +55,10 @@ class VideoOptionsDialog(
val bundle = Bundle() val bundle = Bundle()
bundle.putString("videoId", videoId) bundle.putString("videoId", videoId)
newFragment.arguments = bundle newFragment.arguments = bundle
newFragment.show(parentFragmentManager, "AddToPlaylist") newFragment.show(
parentFragmentManager,
AddToPlaylistDialog::class.java.name
)
} else { } else {
Toast.makeText(context, R.string.login_first, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.login_first, Toast.LENGTH_SHORT).show()
} }
@ -63,7 +66,7 @@ class VideoOptionsDialog(
context?.getString(R.string.share) -> { context?.getString(R.string.share) -> {
val shareDialog = ShareDialog(videoId, false) val shareDialog = ShareDialog(videoId, false)
// using parentFragmentManager is important here // using parentFragmentManager is important here
shareDialog.show(parentFragmentManager, "ShareDialog") shareDialog.show(parentFragmentManager, ShareDialog::class.java.name)
} }
} }
} }

View File

@ -0,0 +1,14 @@
package com.github.libretube.extensions
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.github.libretube.util.ThemeHelper
open class BaseActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
// set the app theme (e.g. Material You)
ThemeHelper.updateTheme(this)
super.onCreate(savedInstanceState)
}
}

View File

@ -0,0 +1,10 @@
package com.github.libretube.extensions
import androidx.fragment.app.Fragment
open class BaseFragment : Fragment() {
fun runOnUiThread(action: () -> Unit) {
if (!isAdded) return // Fragment not attached to an Activity
activity?.runOnUiThread(action)
}
}

View File

@ -5,12 +5,12 @@ import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.adapters.ChannelAdapter import com.github.libretube.adapters.ChannelAdapter
import com.github.libretube.databinding.FragmentChannelBinding import com.github.libretube.databinding.FragmentChannelBinding
import com.github.libretube.extensions.BaseFragment
import com.github.libretube.util.ConnectionHelper import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.RetrofitInstance import com.github.libretube.util.RetrofitInstance
import com.github.libretube.util.SubscriptionHelper import com.github.libretube.util.SubscriptionHelper
@ -19,7 +19,7 @@ import com.github.libretube.util.toID
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
class ChannelFragment : Fragment() { class ChannelFragment : BaseFragment() {
private val TAG = "ChannelFragment" private val TAG = "ChannelFragment"
private lateinit var binding: FragmentChannelBinding private lateinit var binding: FragmentChannelBinding
@ -184,10 +184,4 @@ class ChannelFragment : Fragment() {
} }
run() run()
} }
private fun Fragment?.runOnUiThread(action: () -> Unit) {
this ?: return
if (!isAdded) return // Fragment not attached to an Activity
activity?.runOnUiThread(action)
}
} }

View File

@ -6,12 +6,12 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Toast import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.adapters.TrendingAdapter import com.github.libretube.adapters.TrendingAdapter
import com.github.libretube.databinding.FragmentHomeBinding import com.github.libretube.databinding.FragmentHomeBinding
import com.github.libretube.extensions.BaseFragment
import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.preferences.PreferenceKeys import com.github.libretube.preferences.PreferenceKeys
import com.github.libretube.util.LocaleHelper import com.github.libretube.util.LocaleHelper
@ -19,7 +19,7 @@ import com.github.libretube.util.RetrofitInstance
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
class HomeFragment : Fragment() { class HomeFragment : BaseFragment() {
private val TAG = "HomeFragment" private val TAG = "HomeFragment"
private lateinit var binding: FragmentHomeBinding private lateinit var binding: FragmentHomeBinding
private lateinit var region: String private lateinit var region: String
@ -88,10 +88,4 @@ class HomeFragment : Fragment() {
} }
run() run()
} }
private fun Fragment?.runOnUiThread(action: () -> Unit) {
this ?: return
if (!isAdded) return // Fragment not attached to an Activity
activity?.runOnUiThread(action)
}
} }

View File

@ -6,7 +6,6 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Toast import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -15,13 +14,14 @@ import com.github.libretube.R
import com.github.libretube.adapters.PlaylistsAdapter import com.github.libretube.adapters.PlaylistsAdapter
import com.github.libretube.databinding.FragmentLibraryBinding import com.github.libretube.databinding.FragmentLibraryBinding
import com.github.libretube.dialogs.CreatePlaylistDialog import com.github.libretube.dialogs.CreatePlaylistDialog
import com.github.libretube.extensions.BaseFragment
import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.preferences.PreferenceKeys import com.github.libretube.preferences.PreferenceKeys
import com.github.libretube.util.RetrofitInstance import com.github.libretube.util.RetrofitInstance
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
class LibraryFragment : Fragment() { class LibraryFragment : BaseFragment() {
private val TAG = "LibraryFragment" private val TAG = "LibraryFragment"
lateinit var token: String lateinit var token: String
@ -68,7 +68,7 @@ class LibraryFragment : Fragment() {
} }
binding.createPlaylist.setOnClickListener { binding.createPlaylist.setOnClickListener {
val newFragment = CreatePlaylistDialog() val newFragment = CreatePlaylistDialog()
newFragment.show(childFragmentManager, "Create Playlist") newFragment.show(childFragmentManager, CreatePlaylistDialog::class.java.name)
} }
} else { } else {
binding.playlistRefresh.isEnabled = false binding.playlistRefresh.isEnabled = false
@ -129,10 +129,4 @@ class LibraryFragment : Fragment() {
} }
run() run()
} }
private fun Fragment?.runOnUiThread(action: () -> Unit) {
this ?: return
if (!isAdded) return // Fragment not attached to an Activity
activity?.runOnUiThread(action)
}
} }

View File

@ -28,7 +28,6 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.net.toUri import androidx.core.net.toUri
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -45,6 +44,7 @@ import com.github.libretube.databinding.FragmentPlayerBinding
import com.github.libretube.dialogs.AddToPlaylistDialog import com.github.libretube.dialogs.AddToPlaylistDialog
import com.github.libretube.dialogs.DownloadDialog import com.github.libretube.dialogs.DownloadDialog
import com.github.libretube.dialogs.ShareDialog import com.github.libretube.dialogs.ShareDialog
import com.github.libretube.extensions.BaseFragment
import com.github.libretube.obj.ChapterSegment import com.github.libretube.obj.ChapterSegment
import com.github.libretube.obj.Segment import com.github.libretube.obj.Segment
import com.github.libretube.obj.Segments import com.github.libretube.obj.Segments
@ -97,7 +97,7 @@ import java.io.IOException
import java.util.concurrent.Executors import java.util.concurrent.Executors
import kotlin.math.abs import kotlin.math.abs
class PlayerFragment : Fragment() { class PlayerFragment : BaseFragment() {
private val TAG = "PlayerFragment" private val TAG = "PlayerFragment"
private lateinit var binding: FragmentPlayerBinding private lateinit var binding: FragmentPlayerBinding
@ -523,7 +523,7 @@ class PlayerFragment : Fragment() {
// share button // share button
binding.relPlayerShare.setOnClickListener { binding.relPlayerShare.setOnClickListener {
val shareDialog = ShareDialog(videoId!!, false, exoPlayer.currentPosition) val shareDialog = ShareDialog(videoId!!, false, exoPlayer.currentPosition)
shareDialog.show(childFragmentManager, "ShareDialog") shareDialog.show(childFragmentManager, ShareDialog::class.java.name)
} }
binding.relPlayerBackground.setOnClickListener { binding.relPlayerBackground.setOnClickListener {
@ -979,7 +979,7 @@ class PlayerFragment : Fragment() {
val bundle = Bundle() val bundle = Bundle()
bundle.putString("video_id", videoId) bundle.putString("video_id", videoId)
newFragment.arguments = bundle newFragment.arguments = bundle
newFragment.show(childFragmentManager, "DownloadDialog") newFragment.show(childFragmentManager, DownloadDialog::class.java.name)
} else { } else {
Toast.makeText(context, R.string.dlisinprogress, Toast.LENGTH_SHORT) Toast.makeText(context, R.string.dlisinprogress, Toast.LENGTH_SHORT)
.show() .show()
@ -1045,7 +1045,7 @@ class PlayerFragment : Fragment() {
val bundle = Bundle() val bundle = Bundle()
bundle.putString("videoId", videoId) bundle.putString("videoId", videoId)
newFragment.arguments = bundle newFragment.arguments = bundle
newFragment.show(childFragmentManager, "AddToPlaylist") newFragment.show(childFragmentManager, AddToPlaylistDialog::class.java.name)
} }
} else { } else {
binding.relPlayerSave.setOnClickListener { binding.relPlayerSave.setOnClickListener {
@ -1509,12 +1509,6 @@ class PlayerFragment : Fragment() {
run() run()
} }
private fun Fragment?.runOnUiThread(action: () -> Unit) {
this ?: return
if (!isAdded) return // Fragment not attached to an Activity
activity?.runOnUiThread(action)
}
private fun fetchComments() { private fun fetchComments() {
lifecycleScope.launchWhenCreated { lifecycleScope.launchWhenCreated {
val commentsResponse = try { val commentsResponse = try {

View File

@ -5,7 +5,6 @@ import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -14,13 +13,14 @@ import com.github.libretube.R
import com.github.libretube.adapters.PlaylistAdapter import com.github.libretube.adapters.PlaylistAdapter
import com.github.libretube.databinding.FragmentPlaylistBinding import com.github.libretube.databinding.FragmentPlaylistBinding
import com.github.libretube.dialogs.PlaylistOptionsDialog import com.github.libretube.dialogs.PlaylistOptionsDialog
import com.github.libretube.extensions.BaseFragment
import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.util.RetrofitInstance import com.github.libretube.util.RetrofitInstance
import com.github.libretube.util.toID import com.github.libretube.util.toID
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
class PlaylistFragment : Fragment() { class PlaylistFragment : BaseFragment() {
private val TAG = "PlaylistFragment" private val TAG = "PlaylistFragment"
private lateinit var binding: FragmentPlaylistBinding private lateinit var binding: FragmentPlaylistBinding
@ -87,7 +87,10 @@ class PlaylistFragment : Fragment() {
binding.optionsMenu.setOnClickListener { binding.optionsMenu.setOnClickListener {
val optionsDialog = val optionsDialog =
PlaylistOptionsDialog(playlistId!!, isOwner) PlaylistOptionsDialog(playlistId!!, isOwner)
optionsDialog.show(childFragmentManager, "PlaylistOptionsDialog") optionsDialog.show(
childFragmentManager,
PlaylistOptionsDialog::class.java.name
)
} }
playlistAdapter = PlaylistAdapter( playlistAdapter = PlaylistAdapter(
@ -171,10 +174,4 @@ class PlaylistFragment : Fragment() {
} }
run() run()
} }
private fun Fragment?.runOnUiThread(action: () -> Unit) {
this ?: return
if (!isAdded) return // Fragment not attached to an Activity
activity?.runOnUiThread(action)
}
} }

View File

@ -5,7 +5,6 @@ import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -13,13 +12,14 @@ import com.github.libretube.activities.MainActivity
import com.github.libretube.adapters.SearchHistoryAdapter import com.github.libretube.adapters.SearchHistoryAdapter
import com.github.libretube.adapters.SearchSuggestionsAdapter import com.github.libretube.adapters.SearchSuggestionsAdapter
import com.github.libretube.databinding.FragmentSearchBinding import com.github.libretube.databinding.FragmentSearchBinding
import com.github.libretube.extensions.BaseFragment
import com.github.libretube.models.SearchViewModel import com.github.libretube.models.SearchViewModel
import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.util.RetrofitInstance import com.github.libretube.util.RetrofitInstance
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
class SearchFragment() : Fragment() { class SearchFragment() : BaseFragment() {
private val TAG = "SearchFragment" private val TAG = "SearchFragment"
private lateinit var binding: FragmentSearchBinding private lateinit var binding: FragmentSearchBinding
private val viewModel: SearchViewModel by activityViewModels() private val viewModel: SearchViewModel by activityViewModels()
@ -101,10 +101,4 @@ class SearchFragment() : Fragment() {
binding.historyEmpty.visibility = View.VISIBLE binding.historyEmpty.visibility = View.VISIBLE
} }
} }
private fun Fragment?.runOnUiThread(action: () -> Unit) {
this ?: return
if (!isAdded) return // Fragment not attached to an Activity
activity?.runOnUiThread(action)
}
} }

View File

@ -5,12 +5,12 @@ import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.adapters.SearchAdapter import com.github.libretube.adapters.SearchAdapter
import com.github.libretube.databinding.FragmentSearchResultBinding import com.github.libretube.databinding.FragmentSearchResultBinding
import com.github.libretube.extensions.BaseFragment
import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.preferences.PreferenceKeys import com.github.libretube.preferences.PreferenceKeys
import com.github.libretube.util.RetrofitInstance import com.github.libretube.util.RetrofitInstance
@ -18,7 +18,7 @@ import com.github.libretube.util.hideKeyboard
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
class SearchResultFragment : Fragment() { class SearchResultFragment : BaseFragment() {
private val TAG = "SearchResultFragment" private val TAG = "SearchResultFragment"
private lateinit var binding: FragmentSearchResultBinding private lateinit var binding: FragmentSearchResultBinding
@ -135,10 +135,4 @@ class SearchResultFragment : Fragment() {
PreferenceHelper.saveToSearchHistory(query) PreferenceHelper.saveToSearchHistory(query)
} }
} }
private fun Fragment?.runOnUiThread(action: () -> Unit) {
this ?: return
if (!isAdded) return // Fragment not attached to an Activity
activity?.runOnUiThread(action)
}
} }

View File

@ -7,7 +7,6 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Toast import android.widget.Toast
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -15,6 +14,7 @@ import com.github.libretube.R
import com.github.libretube.adapters.SubscriptionChannelAdapter import com.github.libretube.adapters.SubscriptionChannelAdapter
import com.github.libretube.adapters.TrendingAdapter import com.github.libretube.adapters.TrendingAdapter
import com.github.libretube.databinding.FragmentSubscriptionsBinding import com.github.libretube.databinding.FragmentSubscriptionsBinding
import com.github.libretube.extensions.BaseFragment
import com.github.libretube.obj.StreamItem import com.github.libretube.obj.StreamItem
import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.preferences.PreferenceKeys import com.github.libretube.preferences.PreferenceKeys
@ -25,7 +25,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
class SubscriptionsFragment : Fragment() { class SubscriptionsFragment : BaseFragment() {
val TAG = "SubFragment" val TAG = "SubFragment"
private lateinit var binding: FragmentSubscriptionsBinding private lateinit var binding: FragmentSubscriptionsBinding
@ -199,10 +199,4 @@ class SubscriptionsFragment : Fragment() {
} }
run() run()
} }
private fun Fragment?.runOnUiThread(action: () -> Unit) {
this ?: return
if (!isAdded) return // Fragment not attached to an Activity
activity?.runOnUiThread(action)
}
} }

View File

@ -4,13 +4,13 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.github.libretube.adapters.WatchHistoryAdapter import com.github.libretube.adapters.WatchHistoryAdapter
import com.github.libretube.databinding.FragmentWatchHistoryBinding import com.github.libretube.databinding.FragmentWatchHistoryBinding
import com.github.libretube.extensions.BaseFragment
import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.preferences.PreferenceHelper
class WatchHistoryFragment : Fragment() { class WatchHistoryFragment : BaseFragment() {
private val TAG = "WatchHistoryFragment" private val TAG = "WatchHistoryFragment"
private lateinit var binding: FragmentWatchHistoryBinding private lateinit var binding: FragmentWatchHistoryBinding

View File

@ -26,14 +26,14 @@ class AppearanceSettings : MaterialPreferenceFragment() {
val themeToggle = findPreference<ListPreference>(PreferenceKeys.THEME_MODE) val themeToggle = findPreference<ListPreference>(PreferenceKeys.THEME_MODE)
themeToggle?.setOnPreferenceChangeListener { _, _ -> themeToggle?.setOnPreferenceChangeListener { _, _ ->
val restartDialog = RequireRestartDialog() val restartDialog = RequireRestartDialog()
restartDialog.show(childFragmentManager, "RequireRestartDialog") restartDialog.show(childFragmentManager, RequireRestartDialog::class.java.name)
true true
} }
val pureTheme = findPreference<SwitchPreferenceCompat>(PreferenceKeys.PURE_THEME) val pureTheme = findPreference<SwitchPreferenceCompat>(PreferenceKeys.PURE_THEME)
pureTheme?.setOnPreferenceChangeListener { _, _ -> pureTheme?.setOnPreferenceChangeListener { _, _ ->
val restartDialog = RequireRestartDialog() val restartDialog = RequireRestartDialog()
restartDialog.show(childFragmentManager, "RequireRestartDialog") restartDialog.show(childFragmentManager, RequireRestartDialog::class.java.name)
true true
} }
@ -41,7 +41,7 @@ class AppearanceSettings : MaterialPreferenceFragment() {
updateAccentColorValues(accentColor!!) updateAccentColorValues(accentColor!!)
accentColor.setOnPreferenceChangeListener { _, _ -> accentColor.setOnPreferenceChangeListener { _, _ ->
val restartDialog = RequireRestartDialog() val restartDialog = RequireRestartDialog()
restartDialog.show(childFragmentManager, "RequireRestartDialog") restartDialog.show(childFragmentManager, RequireRestartDialog::class.java.name)
true true
} }
@ -54,7 +54,7 @@ class AppearanceSettings : MaterialPreferenceFragment() {
val labelVisibilityMode = findPreference<ListPreference>(PreferenceKeys.LABEL_VISIBILITY) val labelVisibilityMode = findPreference<ListPreference>(PreferenceKeys.LABEL_VISIBILITY)
labelVisibilityMode?.setOnPreferenceChangeListener { _, _ -> labelVisibilityMode?.setOnPreferenceChangeListener { _, _ ->
val restartDialog = RequireRestartDialog() val restartDialog = RequireRestartDialog()
restartDialog.show(childFragmentManager, "RequireRestartDialog") restartDialog.show(childFragmentManager, RequireRestartDialog::class.java.name)
true true
} }

View File

@ -20,21 +20,21 @@ class GeneralSettings : MaterialPreferenceFragment() {
val language = findPreference<ListPreference>("language") val language = findPreference<ListPreference>("language")
language?.setOnPreferenceChangeListener { _, _ -> language?.setOnPreferenceChangeListener { _, _ ->
val restartDialog = RequireRestartDialog() val restartDialog = RequireRestartDialog()
restartDialog.show(childFragmentManager, "RequireRestartDialog") restartDialog.show(childFragmentManager, RequireRestartDialog::class.java.name)
true true
} }
val autoRotation = findPreference<SwitchPreferenceCompat>(PreferenceKeys.AUTO_ROTATION) val autoRotation = findPreference<SwitchPreferenceCompat>(PreferenceKeys.AUTO_ROTATION)
autoRotation?.setOnPreferenceChangeListener { _, _ -> autoRotation?.setOnPreferenceChangeListener { _, _ ->
val restartDialog = RequireRestartDialog() val restartDialog = RequireRestartDialog()
restartDialog.show(childFragmentManager, "RequireRestartDialog") restartDialog.show(childFragmentManager, RequireRestartDialog::class.java.name)
true true
} }
val hideTrending = findPreference<SwitchPreferenceCompat>(PreferenceKeys.HIDE_TRENDING_PAGE) val hideTrending = findPreference<SwitchPreferenceCompat>(PreferenceKeys.HIDE_TRENDING_PAGE)
hideTrending?.setOnPreferenceChangeListener { _, _ -> hideTrending?.setOnPreferenceChangeListener { _, _ ->
val restartDialog = RequireRestartDialog() val restartDialog = RequireRestartDialog()
restartDialog.show(childFragmentManager, "RequireRestartDialog") restartDialog.show(childFragmentManager, RequireRestartDialog::class.java.name)
true true
} }
} }

View File

@ -6,7 +6,6 @@ import android.os.Bundle
import android.widget.Toast import android.widget.Toast
import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.preference.ListPreference import androidx.preference.ListPreference
@ -99,7 +98,7 @@ class InstanceSettings : MaterialPreferenceFragment() {
val customInstance = findPreference<Preference>(PreferenceKeys.CUSTOM_INSTANCE) val customInstance = findPreference<Preference>(PreferenceKeys.CUSTOM_INSTANCE)
customInstance?.setOnPreferenceClickListener { customInstance?.setOnPreferenceClickListener {
val newFragment = CustomInstanceDialog() val newFragment = CustomInstanceDialog()
newFragment.show(childFragmentManager, "CustomInstanceDialog") newFragment.show(childFragmentManager, CustomInstanceDialog::class.java.name)
true true
} }
@ -117,10 +116,10 @@ class InstanceSettings : MaterialPreferenceFragment() {
login?.setOnPreferenceClickListener { login?.setOnPreferenceClickListener {
if (token == "") { if (token == "") {
val newFragment = LoginDialog() val newFragment = LoginDialog()
newFragment.show(childFragmentManager, "Login") newFragment.show(childFragmentManager, LoginDialog::class.java.name)
} else { } else {
val newFragment = LogoutDialog() val newFragment = LogoutDialog()
newFragment.show(childFragmentManager, "Logout") newFragment.show(childFragmentManager, LogoutDialog::class.java.name)
} }
true true
@ -131,7 +130,7 @@ class InstanceSettings : MaterialPreferenceFragment() {
val token = PreferenceHelper.getToken() val token = PreferenceHelper.getToken()
if (token != "") { if (token != "") {
val newFragment = DeleteAccountDialog() val newFragment = DeleteAccountDialog()
newFragment.show(childFragmentManager, "DeleteAccountDialog") newFragment.show(childFragmentManager, DeleteAccountDialog::class.java.name)
} else { } else {
Toast.makeText(context, R.string.login_first, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.login_first, Toast.LENGTH_SHORT).show()
} }
@ -142,11 +141,11 @@ class InstanceSettings : MaterialPreferenceFragment() {
importSubscriptions?.setOnPreferenceClickListener { importSubscriptions?.setOnPreferenceClickListener {
// check StorageAccess // check StorageAccess
val accessGranted = val accessGranted =
PermissionHelper.isStoragePermissionGranted(activity as AppCompatActivity) PermissionHelper.isStoragePermissionGranted(requireActivity())
// import subscriptions // import subscriptions
if (accessGranted) getContent.launch("*/*") if (accessGranted) getContent.launch("*/*")
// request permissions if not granted // request permissions if not granted
else PermissionHelper.requestReadWrite(activity as AppCompatActivity) else PermissionHelper.requestReadWrite(requireActivity())
true true
} }

View File

@ -101,7 +101,7 @@ class MainSettings : MaterialPreferenceFragment() {
} else if (BuildConfig.VERSION_NAME != updateInfo.name) { } else if (BuildConfig.VERSION_NAME != updateInfo.name) {
// show the UpdateAvailableDialog if there's an update available // show the UpdateAvailableDialog if there's an update available
val updateAvailableDialog = UpdateDialog(updateInfo) val updateAvailableDialog = UpdateDialog(updateInfo)
updateAvailableDialog.show(childFragmentManager, "UpdateAvailableDialog") updateAvailableDialog.show(childFragmentManager, UpdateDialog::class.java.name)
} else { } else {
// otherwise show the no update available snackBar // otherwise show the no update available snackBar
val settingsActivity = activity as SettingsActivity val settingsActivity = activity as SettingsActivity

View File

@ -9,6 +9,7 @@ import android.os.Build
import android.os.Handler import android.os.Handler
import android.os.IBinder import android.os.IBinder
import android.os.Looper import android.os.Looper
import android.widget.Toast
import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.ObjectMapper
import com.github.libretube.BACKGROUND_CHANNEL_ID import com.github.libretube.BACKGROUND_CHANNEL_ID
import com.github.libretube.PLAYER_NOTIFICATION_ID import com.github.libretube.PLAYER_NOTIFICATION_ID
@ -205,7 +206,6 @@ class BackgroundMode : Service() {
nextStreamId = streams?.relatedStreams!![0].url.toID() nextStreamId = streams?.relatedStreams!![0].url.toID()
} }
return
if (playlistId == null) return if (playlistId == null) return
if (!this::autoPlayHelper.isInitialized) autoPlayHelper = AutoPlayHelper(playlistId!!) if (!this::autoPlayHelper.isInitialized) autoPlayHelper = AutoPlayHelper(playlistId!!)
// search for the next videoId in the playlist // search for the next videoId in the playlist
@ -270,6 +270,18 @@ class BackgroundMode : Service() {
val segmentEnd = (segment.segment[1] * 1000f).toLong() val segmentEnd = (segment.segment[1] * 1000f).toLong()
val currentPosition = player?.currentPosition val currentPosition = player?.currentPosition
if (currentPosition in segmentStart until segmentEnd) { if (currentPosition in segmentStart until segmentEnd) {
if (PreferenceHelper.getBoolean(
"sb_notifications_key",
true
)
) {
try {
Toast.makeText(this, R.string.segment_skipped, Toast.LENGTH_SHORT)
.show()
} catch (e: Exception) {
// Do nothing.
}
}
player?.seekTo(segmentEnd) player?.seekTo(segmentEnd)
} }
} }

View File

@ -9,6 +9,7 @@ import android.content.IntentFilter
import android.net.Uri import android.net.Uri
import android.os.Environment import android.os.Environment
import android.os.IBinder import android.os.IBinder
import android.widget.Toast
import com.github.libretube.R import com.github.libretube.R
import java.io.File import java.io.File
@ -64,7 +65,15 @@ class UpdateService : Service() {
Uri.fromFile(file), Uri.fromFile(file),
downloadManager.getMimeTypeForDownloadedFile(downloadId) downloadManager.getMimeTypeForDownloadedFile(downloadId)
) )
startActivity(installIntent) try {
startActivity(installIntent)
} catch (e: Exception) {
Toast.makeText(
context,
R.string.downloadsucceeded,
Toast.LENGTH_SHORT
).show()
}
} }
} }
} }

View File

@ -25,7 +25,10 @@ class AutoPlayHelper(
// fetch the playlists or its nextPage's videos // fetch the playlists or its nextPage's videos
val playlist = val playlist =
if (playlistNextPage == null) RetrofitInstance.authApi.getPlaylist(playlistId) if (playlistNextPage == null) RetrofitInstance.authApi.getPlaylist(playlistId)
else RetrofitInstance.authApi.getPlaylistNextPage(playlistId, playlistNextPage!!) else RetrofitInstance.authApi.getPlaylistNextPage(
playlistId,
playlistNextPage!!
)
// save the playlist urls to the list // save the playlist urls to the list
playlistStreamIds += playlist.relatedStreams!!.map { it.url.toID() } playlistStreamIds += playlist.relatedStreams!!.map { it.url.toID() }
// save playlistNextPage for usage if video is not contained // save playlistNextPage for usage if video is not contained

View File

@ -1,14 +1,14 @@
package com.github.libretube.util package com.github.libretube.util
import android.Manifest import android.Manifest
import android.app.Activity
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.os.Build import android.os.Build
import android.os.Environment import android.os.Environment
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
object PermissionHelper { object PermissionHelper {
fun requestReadWrite(activity: AppCompatActivity): Boolean { fun requestReadWrite(activity: Activity): Boolean {
// request storage permissions if not granted yet // request storage permissions if not granted yet
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (!Environment.isExternalStorageManager()) { if (!Environment.isExternalStorageManager()) {
@ -46,7 +46,7 @@ object PermissionHelper {
return true return true
} }
fun isStoragePermissionGranted(activity: AppCompatActivity): Boolean { fun isStoragePermissionGranted(activity: Activity): Boolean {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) if (activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
== PackageManager.PERMISSION_GRANTED == PackageManager.PERMISSION_GRANTED

View File

@ -100,7 +100,7 @@ object ThemeHelper {
fun restartMainActivity(context: Context) { fun restartMainActivity(context: Context) {
// kill player notification // kill player notification
val nManager = context val nManager = context
.getSystemService(AppCompatActivity.NOTIFICATION_SERVICE) as NotificationManager .getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
nManager.cancelAll() nManager.cancelAll()
// start a new Intent of the app // start a new Intent of the app
val pm: PackageManager = context.packageManager val pm: PackageManager = context.packageManager

View File

@ -289,7 +289,7 @@
<string name="no_search_result">No results.</string> <string name="no_search_result">No results.</string>
<string name="error_occurred">Error</string> <string name="error_occurred">Error</string>
<string name="copied">Copied</string> <string name="copied">Copied</string>
<string name="downloadsucceeded">Downloaded</string> <string name="downloadsucceeded">Download succeeded</string>
<string name="share_with_time">Share with start time</string> <string name="share_with_time">Share with start time</string>
<string name="export_subscriptions">Export Subscriptions</string> <string name="export_subscriptions">Export Subscriptions</string>
</resources> </resources>