use better tags

This commit is contained in:
Bnyro 2022-08-08 11:38:50 +02:00
parent 71fcfc075f
commit 57b3053b58
18 changed files with 33 additions and 29 deletions

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

@ -81,7 +81,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

@ -55,7 +55,7 @@ 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 +63,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,6 @@
package com.github.libretube.extensions
import androidx.appcompat.app.AppCompatActivity
class BaseActivity: AppCompatActivity() {
}

View File

@ -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

View File

@ -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 {

View File

@ -87,7 +87,7 @@ 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(

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

@ -99,7 +99,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 +117,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 +131,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()
} }

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

@ -205,7 +205,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