Merge pull request #1056 from Bnyro/master

cleanup
This commit is contained in:
Bnyro 2022-08-14 10:00:49 +02:00 committed by GitHub
commit d055ca30c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
76 changed files with 246 additions and 256 deletions

View File

@ -8,12 +8,12 @@ import android.os.Build
import android.os.StrictMode import android.os.StrictMode
import android.os.StrictMode.VmPolicy import android.os.StrictMode.VmPolicy
import androidx.work.ExistingPeriodicWorkPolicy import androidx.work.ExistingPeriodicWorkPolicy
import com.github.libretube.database.DatabaseHolder import com.github.libretube.api.RetrofitInstance
import com.github.libretube.db.DatabaseHolder
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.ExceptionHandler import com.github.libretube.util.ExceptionHandler
import com.github.libretube.util.NotificationHelper import com.github.libretube.util.NotificationHelper
import com.github.libretube.util.RetrofitInstance
class MyApp : Application() { class MyApp : Application() {
override fun onCreate() { override fun onCreate() {

View File

@ -28,16 +28,17 @@ import androidx.navigation.ui.setupWithNavController
import coil.ImageLoader import coil.ImageLoader
import com.github.libretube.Globals import com.github.libretube.Globals
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.CronetHelper
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.extensions.BaseActivity
import com.github.libretube.extensions.TAG
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
import com.github.libretube.preferences.PreferenceKeys import com.github.libretube.preferences.PreferenceKeys
import com.github.libretube.services.ClosingService import com.github.libretube.services.ClosingService
import com.github.libretube.util.ConnectionHelper import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.CronetHelper
import com.github.libretube.util.LocaleHelper import com.github.libretube.util.LocaleHelper
import com.github.libretube.util.ThemeHelper import com.github.libretube.util.ThemeHelper
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
@ -45,7 +46,6 @@ import com.google.android.material.elevation.SurfaceColors
import com.google.android.material.navigation.NavigationBarView import com.google.android.material.navigation.NavigationBarView
class MainActivity : BaseActivity() { class MainActivity : BaseActivity() {
val TAG = "MainActivity"
lateinit var binding: ActivityMainBinding lateinit var binding: ActivityMainBinding
@ -301,7 +301,7 @@ class MainActivity : BaseActivity() {
val intentData: Uri? = intent?.data val intentData: Uri? = intent?.data
// check whether an URI got submitted over the intent data // check whether an URI got submitted over the intent data
if (intentData != null && intentData.host != null && intentData.path != null) { if (intentData != null && intentData.host != null && intentData.path != null) {
Log.d(TAG, "intentData: ${intentData.host} ${intentData.path} ") Log.d(TAG(), "intentData: ${intentData.host} ${intentData.path} ")
// load the URI of the submitted link (e.g. video) // load the URI of the submitted link (e.g. video)
loadIntentData(intentData) loadIntentData(intentData)
} }
@ -375,10 +375,10 @@ class MainActivity : BaseActivity() {
} }
private fun loadVideo(videoId: String, query: String?) { private fun loadVideo(videoId: String, query: String?) {
Log.i(TAG, "URI type: Video") Log.i(TAG(), "URI type: Video")
val bundle = Bundle() val bundle = Bundle()
Log.e(TAG, videoId) Log.e(TAG(), videoId)
// for time stamped links // for time stamped links
if (query != null && query.contains("t=")) { if (query != null && query.contains("t=")) {
@ -407,7 +407,7 @@ class MainActivity : BaseActivity() {
channelId: String? = null, channelId: String? = null,
channelName: String? = null channelName: String? = null
) { ) {
Log.i(TAG, "Uri Type: Channel") Log.i(TAG(), "Uri Type: Channel")
val bundle = if (channelId != null) bundleOf("channel_id" to channelId) val bundle = if (channelId != null) bundleOf("channel_id" to channelId)
else bundleOf("channel_name" to channelName) else bundleOf("channel_name" to channelName)
@ -415,7 +415,7 @@ class MainActivity : BaseActivity() {
} }
private fun loadPlaylist(playlistId: String) { private fun loadPlaylist(playlistId: String) {
Log.i(TAG, "Uri Type: Playlist") Log.i(TAG(), "Uri Type: Playlist")
val bundle = bundleOf("playlist_id" to playlistId) val bundle = bundleOf("playlist_id" to playlistId)
navController.navigate(R.id.playlistFragment, bundle) navController.navigate(R.id.playlistFragment, bundle)
@ -497,7 +497,10 @@ class MainActivity : BaseActivity() {
) )
} }
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS) window.setFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
)
} }
private fun unsetFullscreen() { private fun unsetFullscreen() {

View File

@ -7,10 +7,10 @@ import android.os.Bundle
import android.util.Log import android.util.Log
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.extensions.BaseActivity import com.github.libretube.extensions.BaseActivity
import com.github.libretube.extensions.TAG
import com.github.libretube.util.ThemeHelper import com.github.libretube.util.ThemeHelper
class RouterActivity : BaseActivity() { class RouterActivity : BaseActivity() {
val TAG = "RouterActivity"
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
if (intent.getStringExtra(Intent.EXTRA_TEXT) != null && checkHost(intent)) { if (intent.getStringExtra(Intent.EXTRA_TEXT) != null && checkHost(intent)) {
@ -31,12 +31,12 @@ class RouterActivity : BaseActivity() {
val hostsList = resources.getStringArray(R.array.shareHostsList) val hostsList = resources.getStringArray(R.array.shareHostsList)
val intentDataUri: Uri = Uri.parse(intent.getStringExtra(Intent.EXTRA_TEXT)) val intentDataUri: Uri = Uri.parse(intent.getStringExtra(Intent.EXTRA_TEXT))
val intentDataHost = intentDataUri.host val intentDataHost = intentDataUri.host
Log.d(TAG, "$intentDataHost") Log.d(TAG(), "$intentDataHost")
return hostsList.contains(intentDataHost) return hostsList.contains(intentDataHost)
} }
private fun handleSendText(uri: Uri) { private fun handleSendText(uri: Uri) {
Log.i(TAG, uri.toString()) Log.i(TAG(), uri.toString())
val pm: PackageManager = this.packageManager val pm: PackageManager = this.packageManager
val intent = pm.getLaunchIntentForPackage(this.packageName) val intent = pm.getLaunchIntentForPackage(this.packageName)
intent?.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK intent?.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK

View File

@ -7,7 +7,6 @@ import com.github.libretube.extensions.BaseActivity
import com.github.libretube.preferences.MainSettings import com.github.libretube.preferences.MainSettings
class SettingsActivity : BaseActivity() { class SettingsActivity : BaseActivity() {
val TAG = "SettingsActivity"
lateinit var binding: ActivitySettingsBinding lateinit var binding: ActivitySettingsBinding
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {

View File

@ -14,7 +14,6 @@ class ChaptersAdapter(
private val chapters: List<ChapterSegment>, private val chapters: List<ChapterSegment>,
private val exoPlayer: ExoPlayer private val exoPlayer: ExoPlayer
) : RecyclerView.Adapter<ChaptersViewHolder>() { ) : RecyclerView.Adapter<ChaptersViewHolder>() {
val TAG = "ChaptersAdapter"
private var selectedPosition = 0 private var selectedPosition = 0
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ChaptersViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ChaptersViewHolder {

View File

@ -8,12 +8,13 @@ import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.RetrofitInstance
import com.github.libretube.databinding.CommentsRowBinding import com.github.libretube.databinding.CommentsRowBinding
import com.github.libretube.extensions.TAG
import com.github.libretube.obj.Comment import com.github.libretube.obj.Comment
import com.github.libretube.obj.CommentsPage import com.github.libretube.obj.CommentsPage
import com.github.libretube.util.ConnectionHelper import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.NavigationHelper import com.github.libretube.util.NavigationHelper
import com.github.libretube.util.RetrofitInstance
import com.github.libretube.util.formatShort import com.github.libretube.util.formatShort
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -25,7 +26,6 @@ class CommentsAdapter(
private val videoId: String, private val videoId: String,
private val comments: MutableList<Comment> private val comments: MutableList<Comment>
) : RecyclerView.Adapter<CommentsViewHolder>() { ) : RecyclerView.Adapter<CommentsViewHolder>() {
private val TAG = "CommentsAdapter"
private var isLoading = false private var isLoading = false
private var nextpage = "" private var nextpage = ""
@ -97,9 +97,9 @@ class CommentsAdapter(
repliesPage = RetrofitInstance.api.getCommentsNextPage(videoId, nextPage) repliesPage = RetrofitInstance.api.getCommentsNextPage(videoId, nextPage)
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response," + e.response()) Log.e(TAG(), "HttpException, unexpected response," + e.response())
} }
repliesAdapter.updateItems(repliesPage.comments) repliesAdapter.updateItems(repliesPage.comments)
isLoading = false isLoading = false

View File

@ -7,15 +7,16 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.api.RetrofitInstance
import com.github.libretube.databinding.PlaylistRowBinding import com.github.libretube.databinding.PlaylistRowBinding
import com.github.libretube.dialogs.VideoOptionsDialog import com.github.libretube.dialogs.VideoOptionsDialog
import com.github.libretube.extensions.TAG
import com.github.libretube.extensions.setFormattedDuration import com.github.libretube.extensions.setFormattedDuration
import com.github.libretube.obj.PlaylistId import com.github.libretube.obj.PlaylistId
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.util.ConnectionHelper import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.NavigationHelper import com.github.libretube.util.NavigationHelper
import com.github.libretube.util.RetrofitInstance
import com.github.libretube.util.setWatchProgressLength import com.github.libretube.util.setWatchProgressLength
import com.github.libretube.util.toID import com.github.libretube.util.toID
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@ -31,7 +32,6 @@ class PlaylistAdapter(
private val activity: Activity, private val activity: Activity,
private val childFragmentManager: FragmentManager private val childFragmentManager: FragmentManager
) : RecyclerView.Adapter<PlaylistViewHolder>() { ) : RecyclerView.Adapter<PlaylistViewHolder>() {
private val TAG = "PlaylistAdapter"
override fun getItemCount(): Int { override fun getItemCount(): Int {
return videoFeed.size return videoFeed.size
@ -86,10 +86,10 @@ class PlaylistAdapter(
) )
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
return@launch return@launch
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response") Log.e(TAG(), "HttpException, unexpected response")
return@launch return@launch
} }
} }

View File

@ -7,14 +7,15 @@ import android.view.ViewGroup
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.RetrofitInstance
import com.github.libretube.databinding.PlaylistsRowBinding import com.github.libretube.databinding.PlaylistsRowBinding
import com.github.libretube.dialogs.PlaylistOptionsDialog import com.github.libretube.dialogs.PlaylistOptionsDialog
import com.github.libretube.extensions.TAG
import com.github.libretube.obj.PlaylistId import com.github.libretube.obj.PlaylistId
import com.github.libretube.obj.Playlists import com.github.libretube.obj.Playlists
import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.util.ConnectionHelper import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.NavigationHelper import com.github.libretube.util.NavigationHelper
import com.github.libretube.util.RetrofitInstance
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -27,7 +28,6 @@ class PlaylistsAdapter(
private val childFragmentManager: FragmentManager, private val childFragmentManager: FragmentManager,
private val activity: Activity private val activity: Activity
) : RecyclerView.Adapter<PlaylistsViewHolder>() { ) : RecyclerView.Adapter<PlaylistsViewHolder>() {
val TAG = "PlaylistsAdapter"
override fun getItemCount(): Int { override fun getItemCount(): Int {
return playlists.size return playlists.size
@ -94,10 +94,10 @@ class PlaylistsAdapter(
) )
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
return@launch return@launch
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response") Log.e(TAG(), "HttpException, unexpected response")
return@launch return@launch
} }
try { try {
@ -106,7 +106,7 @@ class PlaylistsAdapter(
activity.runOnUiThread { notifyDataSetChanged() } activity.runOnUiThread { notifyDataSetChanged() }
} }
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, e.toString()) Log.e(TAG(), e.toString())
} }
} }
} }

View File

@ -13,7 +13,6 @@ import com.github.libretube.util.formatShort
class RepliesAdapter( class RepliesAdapter(
private val replies: MutableList<Comment> private val replies: MutableList<Comment>
) : RecyclerView.Adapter<RepliesViewHolder>() { ) : RecyclerView.Adapter<RepliesViewHolder>() {
private val TAG = "RepliesAdapter"
fun clear() { fun clear() {
val size: Int = replies.size val size: Int = replies.size

View File

@ -6,6 +6,7 @@ import android.view.ViewGroup
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.SubscriptionHelper
import com.github.libretube.databinding.ChannelRowBinding import com.github.libretube.databinding.ChannelRowBinding
import com.github.libretube.databinding.PlaylistSearchRowBinding import com.github.libretube.databinding.PlaylistSearchRowBinding
import com.github.libretube.databinding.VideoRowBinding import com.github.libretube.databinding.VideoRowBinding
@ -15,7 +16,6 @@ import com.github.libretube.extensions.setFormattedDuration
import com.github.libretube.obj.SearchItem import com.github.libretube.obj.SearchItem
import com.github.libretube.util.ConnectionHelper import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.NavigationHelper import com.github.libretube.util.NavigationHelper
import com.github.libretube.util.SubscriptionHelper
import com.github.libretube.util.formatShort import com.github.libretube.util.formatShort
import com.github.libretube.util.setWatchProgressLength import com.github.libretube.util.setWatchProgressLength
import com.github.libretube.util.toID import com.github.libretube.util.toID

View File

@ -4,9 +4,9 @@ import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.database.DatabaseHolder
import com.github.libretube.databinding.SearchhistoryRowBinding import com.github.libretube.databinding.SearchhistoryRowBinding
import com.github.libretube.obj.SearchHistoryItem import com.github.libretube.db.DatabaseHolder
import com.github.libretube.db.obj.SearchHistoryItem
class SearchHistoryAdapter( class SearchHistoryAdapter(
private var historyList: List<String>, private var historyList: List<String>,
@ -32,7 +32,7 @@ class SearchHistoryAdapter(
deleteHistory.setOnClickListener { deleteHistory.setOnClickListener {
historyList -= historyQuery historyList -= historyQuery
Thread { Thread {
DatabaseHolder.database.searchHistoryDao().delete( DatabaseHolder.db.searchHistoryDao().delete(
SearchHistoryItem(query = historyQuery) SearchHistoryItem(query = historyQuery)
) )
}.start() }.start()

View File

@ -12,8 +12,6 @@ class SearchSuggestionsAdapter(
) : ) :
RecyclerView.Adapter<SearchSuggestionsViewHolder>() { RecyclerView.Adapter<SearchSuggestionsViewHolder>() {
private val TAG = "SearchSuggestionsAdapter"
override fun getItemCount(): Int { override fun getItemCount(): Int {
return suggestionsList.size return suggestionsList.size
} }

View File

@ -4,16 +4,15 @@ import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.SubscriptionHelper
import com.github.libretube.databinding.ChannelSubscriptionRowBinding import com.github.libretube.databinding.ChannelSubscriptionRowBinding
import com.github.libretube.obj.Subscription import com.github.libretube.obj.Subscription
import com.github.libretube.util.ConnectionHelper import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.NavigationHelper import com.github.libretube.util.NavigationHelper
import com.github.libretube.util.SubscriptionHelper
import com.github.libretube.util.toID import com.github.libretube.util.toID
class SubscriptionChannelAdapter(private val subscriptions: MutableList<Subscription>) : class SubscriptionChannelAdapter(private val subscriptions: MutableList<Subscription>) :
RecyclerView.Adapter<SubscriptionChannelViewHolder>() { RecyclerView.Adapter<SubscriptionChannelViewHolder>() {
val TAG = "SubChannelAdapter"
override fun getItemCount(): Int { override fun getItemCount(): Int {
return subscriptions.size return subscriptions.size

View File

@ -20,7 +20,6 @@ class TrendingAdapter(
private val childFragmentManager: FragmentManager, private val childFragmentManager: FragmentManager,
private val showAllAtOne: Boolean = true private val showAllAtOne: Boolean = true
) : RecyclerView.Adapter<SubscriptionViewHolder>() { ) : RecyclerView.Adapter<SubscriptionViewHolder>() {
private val TAG = "TrendingAdapter"
var index = 10 var index = 10

View File

@ -4,11 +4,11 @@ import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.database.DatabaseHelper
import com.github.libretube.databinding.WatchHistoryRowBinding import com.github.libretube.databinding.WatchHistoryRowBinding
import com.github.libretube.db.DatabaseHelper
import com.github.libretube.db.obj.WatchHistoryItem
import com.github.libretube.dialogs.VideoOptionsDialog import com.github.libretube.dialogs.VideoOptionsDialog
import com.github.libretube.extensions.setFormattedDuration import com.github.libretube.extensions.setFormattedDuration
import com.github.libretube.obj.WatchHistoryItem
import com.github.libretube.util.ConnectionHelper import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.NavigationHelper import com.github.libretube.util.NavigationHelper
import com.github.libretube.util.setWatchProgressLength import com.github.libretube.util.setWatchProgressLength
@ -18,7 +18,6 @@ class WatchHistoryAdapter(
private val childFragmentManager: FragmentManager private val childFragmentManager: FragmentManager
) : ) :
RecyclerView.Adapter<WatchHistoryViewHolder>() { RecyclerView.Adapter<WatchHistoryViewHolder>() {
private val TAG = "WatchHistoryAdapter"
fun removeFromWatchHistory(position: Int) { fun removeFromWatchHistory(position: Int) {
DatabaseHelper.removeFromWatchHistory(position) DatabaseHelper.removeFromWatchHistory(position)

View File

@ -1,4 +1,4 @@
package com.github.libretube.util package com.github.libretube.api
import android.content.Context import android.content.Context
import com.google.net.cronet.okhttptransport.CronetCallFactory import com.google.net.cronet.okhttptransport.CronetCallFactory
@ -10,10 +10,10 @@ class CronetHelper {
lateinit var callFactory: CronetCallFactory lateinit var callFactory: CronetCallFactory
fun initCronet(context: Context) { fun initCronet(context: Context) {
this.engine = CronetEngine.Builder(context) engine = CronetEngine.Builder(context)
.enableBrotli(true) .enableBrotli(true)
.build() .build()
callFactory = CronetCallFactory.newBuilder(this.engine) callFactory = CronetCallFactory.newBuilder(engine)
.build() .build()
} }

View File

@ -1,4 +1,4 @@
package com.github.libretube.util package com.github.libretube.api
import com.github.libretube.obj.Channel import com.github.libretube.obj.Channel
import com.github.libretube.obj.CommentsPage import com.github.libretube.obj.CommentsPage

View File

@ -1,5 +1,7 @@
package com.github.libretube.util package com.github.libretube.api
import com.github.libretube.util.resettableLazy
import com.github.libretube.util.resettableManager
import retrofit2.Retrofit import retrofit2.Retrofit
import retrofit2.converter.jackson.JacksonConverterFactory import retrofit2.converter.jackson.JacksonConverterFactory

View File

@ -1,6 +1,7 @@
package com.github.libretube.util package com.github.libretube.api
import android.util.Log import android.util.Log
import com.github.libretube.extensions.TAG
import com.github.libretube.obj.Subscribe import com.github.libretube.obj.Subscribe
import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.preferences.PreferenceHelper
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@ -8,7 +9,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
object SubscriptionHelper { object SubscriptionHelper {
val TAG = "SubscriptionHelper"
fun subscribe(channelId: String) { fun subscribe(channelId: String) {
if (PreferenceHelper.getToken() != "") { if (PreferenceHelper.getToken() != "") {
@ -19,7 +19,7 @@ object SubscriptionHelper {
Subscribe(channelId) Subscribe(channelId)
) )
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, e.toString()) Log.e(TAG(), e.toString())
} }
} }
} else { } else {
@ -38,7 +38,7 @@ object SubscriptionHelper {
Subscribe(channelId) Subscribe(channelId)
) )
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, e.toString()) Log.e(TAG(), e.toString())
} }
} }
} else { } else {
@ -56,7 +56,7 @@ object SubscriptionHelper {
PreferenceHelper.getToken() PreferenceHelper.getToken()
) )
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, e.toString()) Log.e(TAG(), e.toString())
return null return null
} }
return isSubscribed.subscribed return isSubscribed.subscribed

View File

@ -1,11 +1,15 @@
package com.github.libretube.database package com.github.libretube.db
import androidx.room.Database import androidx.room.Database
import androidx.room.RoomDatabase import androidx.room.RoomDatabase
import com.github.libretube.obj.CustomInstance import com.github.libretube.db.dao.CustomInstanceDao
import com.github.libretube.obj.SearchHistoryItem import com.github.libretube.db.dao.SearchHistoryDao
import com.github.libretube.obj.WatchHistoryItem import com.github.libretube.db.dao.WatchHistoryDao
import com.github.libretube.obj.WatchPosition import com.github.libretube.db.dao.WatchPositionDao
import com.github.libretube.db.obj.CustomInstance
import com.github.libretube.db.obj.SearchHistoryItem
import com.github.libretube.db.obj.WatchHistoryItem
import com.github.libretube.db.obj.WatchPosition
@Database( @Database(
entities = [ entities = [

View File

@ -1,8 +1,8 @@
package com.github.libretube.database package com.github.libretube.db
import com.github.libretube.db.obj.WatchHistoryItem
import com.github.libretube.db.obj.WatchPosition
import com.github.libretube.obj.Streams import com.github.libretube.obj.Streams
import com.github.libretube.obj.WatchHistoryItem
import com.github.libretube.obj.WatchPosition
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.toID import com.github.libretube.util.toID
@ -20,14 +20,15 @@ object DatabaseHelper {
streams.duration streams.duration
) )
Thread { Thread {
DatabaseHolder.database.watchHistoryDao().insertAll(watchHistoryItem) DatabaseHolder.db.watchHistoryDao().insertAll(watchHistoryItem)
val maxHistorySize = PreferenceHelper.getString(PreferenceKeys.WATCH_HISTORY_SIZE, "unlimited") val maxHistorySize =
PreferenceHelper.getString(PreferenceKeys.WATCH_HISTORY_SIZE, "unlimited")
if (maxHistorySize == "unlimited") return@Thread if (maxHistorySize == "unlimited") return@Thread
// delete the first watch history entry if the limit is reached // delete the first watch history entry if the limit is reached
val watchHistory = DatabaseHolder.database.watchHistoryDao().getAll() val watchHistory = DatabaseHolder.db.watchHistoryDao().getAll()
if (watchHistory.size > maxHistorySize.toInt()) { if (watchHistory.size > maxHistorySize.toInt()) {
DatabaseHolder.database.watchHistoryDao() DatabaseHolder.db.watchHistoryDao()
.delete(watchHistory.first()) .delete(watchHistory.first())
} }
}.start() }.start()
@ -35,8 +36,8 @@ object DatabaseHelper {
fun removeFromWatchHistory(index: Int) { fun removeFromWatchHistory(index: Int) {
Thread { Thread {
DatabaseHolder.database.watchHistoryDao().delete( DatabaseHolder.db.watchHistoryDao().delete(
DatabaseHolder.database.watchHistoryDao().getAll()[index] DatabaseHolder.db.watchHistoryDao().getAll()[index]
) )
}.start() }.start()
} }
@ -47,14 +48,14 @@ object DatabaseHelper {
position position
) )
Thread { Thread {
DatabaseHolder.database.watchPositionDao().insertAll(watchPosition) DatabaseHolder.db.watchPositionDao().insertAll(watchPosition)
}.start() }.start()
} }
fun removeWatchPosition(videoId: String) { fun removeWatchPosition(videoId: String) {
Thread { Thread {
DatabaseHolder.database.watchPositionDao().delete( DatabaseHolder.db.watchPositionDao().delete(
DatabaseHolder.database.watchPositionDao().findById(videoId) DatabaseHolder.db.watchPositionDao().findById(videoId)
) )
}.start() }.start()
} }

View File

@ -1,14 +1,14 @@
package com.github.libretube.database package com.github.libretube.db
import android.content.Context import android.content.Context
import androidx.room.Room import androidx.room.Room
import com.github.libretube.DATABASE_NAME import com.github.libretube.DATABASE_NAME
object DatabaseHolder { object DatabaseHolder {
lateinit var database: AppDatabase lateinit var db: AppDatabase
fun initializeDatabase(context: Context) { fun initializeDatabase(context: Context) {
database = Room.databaseBuilder( db = Room.databaseBuilder(
context, context,
AppDatabase::class.java, AppDatabase::class.java,
DATABASE_NAME DATABASE_NAME

View File

@ -1,11 +1,11 @@
package com.github.libretube.database package com.github.libretube.db.dao
import androidx.room.Dao import androidx.room.Dao
import androidx.room.Delete import androidx.room.Delete
import androidx.room.Insert import androidx.room.Insert
import androidx.room.OnConflictStrategy import androidx.room.OnConflictStrategy
import androidx.room.Query import androidx.room.Query
import com.github.libretube.obj.CustomInstance import com.github.libretube.db.obj.CustomInstance
@Dao @Dao
interface CustomInstanceDao { interface CustomInstanceDao {

View File

@ -1,11 +1,11 @@
package com.github.libretube.database package com.github.libretube.db.dao
import androidx.room.Dao import androidx.room.Dao
import androidx.room.Delete import androidx.room.Delete
import androidx.room.Insert import androidx.room.Insert
import androidx.room.OnConflictStrategy import androidx.room.OnConflictStrategy
import androidx.room.Query import androidx.room.Query
import com.github.libretube.obj.SearchHistoryItem import com.github.libretube.db.obj.SearchHistoryItem
@Dao @Dao
interface SearchHistoryDao { interface SearchHistoryDao {

View File

@ -1,11 +1,11 @@
package com.github.libretube.database package com.github.libretube.db.dao
import androidx.room.Dao import androidx.room.Dao
import androidx.room.Delete import androidx.room.Delete
import androidx.room.Insert import androidx.room.Insert
import androidx.room.OnConflictStrategy import androidx.room.OnConflictStrategy
import androidx.room.Query import androidx.room.Query
import com.github.libretube.obj.WatchHistoryItem import com.github.libretube.db.obj.WatchHistoryItem
@Dao @Dao
interface WatchHistoryDao { interface WatchHistoryDao {

View File

@ -1,11 +1,11 @@
package com.github.libretube.database package com.github.libretube.db.dao
import androidx.room.Dao import androidx.room.Dao
import androidx.room.Delete import androidx.room.Delete
import androidx.room.Insert import androidx.room.Insert
import androidx.room.OnConflictStrategy import androidx.room.OnConflictStrategy
import androidx.room.Query import androidx.room.Query
import com.github.libretube.obj.WatchPosition import com.github.libretube.db.obj.WatchPosition
@Dao @Dao
interface WatchPositionDao { interface WatchPositionDao {

View File

@ -1,4 +1,4 @@
package com.github.libretube.obj package com.github.libretube.db.obj
import androidx.room.ColumnInfo import androidx.room.ColumnInfo
import androidx.room.Entity import androidx.room.Entity

View File

@ -1,4 +1,4 @@
package com.github.libretube.obj package com.github.libretube.db.obj
import androidx.room.Entity import androidx.room.Entity
import androidx.room.PrimaryKey import androidx.room.PrimaryKey

View File

@ -1,4 +1,4 @@
package com.github.libretube.obj package com.github.libretube.db.obj
import androidx.room.ColumnInfo import androidx.room.ColumnInfo
import androidx.room.Entity import androidx.room.Entity

View File

@ -1,4 +1,4 @@
package com.github.libretube.obj package com.github.libretube.db.obj
import androidx.room.ColumnInfo import androidx.room.ColumnInfo
import androidx.room.Entity import androidx.room.Entity

View File

@ -10,17 +10,17 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.github.libretube.Globals import com.github.libretube.Globals
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.RetrofitInstance
import com.github.libretube.databinding.DialogAddtoplaylistBinding import com.github.libretube.databinding.DialogAddtoplaylistBinding
import com.github.libretube.extensions.TAG
import com.github.libretube.obj.PlaylistId import com.github.libretube.obj.PlaylistId
import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.util.RetrofitInstance
import com.github.libretube.util.ThemeHelper import com.github.libretube.util.ThemeHelper
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
class AddToPlaylistDialog : DialogFragment() { class AddToPlaylistDialog : DialogFragment() {
private val TAG = "AddToPlaylistDialog"
private lateinit var binding: DialogAddtoplaylistBinding private lateinit var binding: DialogAddtoplaylistBinding
private lateinit var videoId: String private lateinit var videoId: String
@ -51,11 +51,11 @@ class AddToPlaylistDialog : DialogFragment() {
RetrofitInstance.authApi.playlists(token) RetrofitInstance.authApi.playlists(token)
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response") Log.e(TAG(), "HttpException, unexpected response")
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} }
@ -96,11 +96,11 @@ class AddToPlaylistDialog : DialogFragment() {
RetrofitInstance.authApi.addToPlaylist(token, PlaylistId(playlistId, videoId)) RetrofitInstance.authApi.addToPlaylist(token, PlaylistId(playlistId, videoId))
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response") Log.e(TAG(), "HttpException, unexpected response")
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} }

View File

@ -7,18 +7,18 @@ import android.widget.Toast
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.RetrofitInstance
import com.github.libretube.databinding.DialogCreatePlaylistBinding import com.github.libretube.databinding.DialogCreatePlaylistBinding
import com.github.libretube.extensions.TAG
import com.github.libretube.fragments.LibraryFragment import com.github.libretube.fragments.LibraryFragment
import com.github.libretube.obj.Playlists import com.github.libretube.obj.Playlists
import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.util.RetrofitInstance
import com.github.libretube.util.ThemeHelper import com.github.libretube.util.ThemeHelper
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
class CreatePlaylistDialog : DialogFragment() { class CreatePlaylistDialog : DialogFragment() {
val TAG = "CreatePlaylistDialog"
private var token: String = "" private var token: String = ""
private lateinit var binding: DialogCreatePlaylistBinding private lateinit var binding: DialogCreatePlaylistBinding
@ -58,15 +58,15 @@ class CreatePlaylistDialog : DialogFragment() {
RetrofitInstance.authApi.createPlaylist(token, Playlists(name = name)) RetrofitInstance.authApi.createPlaylist(token, Playlists(name = name))
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response $e") Log.e(TAG(), "HttpException, unexpected response $e")
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} }
if (response != null) { if (response.playlistId != null) {
Toast.makeText(context, R.string.playlistCreated, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.playlistCreated, Toast.LENGTH_SHORT).show()
} else { } else {
Toast.makeText(context, getString(R.string.unknown_error), Toast.LENGTH_SHORT) Toast.makeText(context, getString(R.string.unknown_error), Toast.LENGTH_SHORT)
@ -77,7 +77,7 @@ class CreatePlaylistDialog : DialogFragment() {
val parent = parentFragment as LibraryFragment val parent = parentFragment as LibraryFragment
parent.fetchPlaylists() parent.fetchPlaylists()
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, e.toString()) Log.e(TAG(), e.toString())
} }
dismiss() dismiss()
} }

View File

@ -5,15 +5,14 @@ import android.os.Bundle
import android.widget.Toast import android.widget.Toast
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.database.DatabaseHolder
import com.github.libretube.databinding.DialogCustomInstanceBinding import com.github.libretube.databinding.DialogCustomInstanceBinding
import com.github.libretube.obj.CustomInstance import com.github.libretube.db.DatabaseHolder
import com.github.libretube.db.obj.CustomInstance
import com.github.libretube.util.ThemeHelper import com.github.libretube.util.ThemeHelper
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import java.net.URL import java.net.URL
class CustomInstanceDialog : DialogFragment() { class CustomInstanceDialog : DialogFragment() {
val TAG = "CustomInstanceDialog"
private lateinit var binding: DialogCustomInstanceBinding private lateinit var binding: DialogCustomInstanceBinding
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
@ -43,7 +42,7 @@ class CustomInstanceDialog : DialogFragment() {
URL(customInstance.frontendUrl).toURI() URL(customInstance.frontendUrl).toURI()
Thread { Thread {
DatabaseHolder.database.customInstanceDao().insertAll(customInstance) DatabaseHolder.db.customInstanceDao().insertAll(customInstance)
}.start() }.start()
activity?.recreate() activity?.recreate()

View File

@ -7,15 +7,15 @@ import android.widget.Toast
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.RetrofitInstance
import com.github.libretube.databinding.DialogDeleteAccountBinding import com.github.libretube.databinding.DialogDeleteAccountBinding
import com.github.libretube.extensions.TAG
import com.github.libretube.obj.DeleteUserRequest import com.github.libretube.obj.DeleteUserRequest
import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.util.RetrofitInstance
import com.github.libretube.util.ThemeHelper import com.github.libretube.util.ThemeHelper
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
class DeleteAccountDialog : DialogFragment() { class DeleteAccountDialog : DialogFragment() {
private val TAG = "DeleteAccountDialog"
private lateinit var binding: DialogDeleteAccountBinding private lateinit var binding: DialogDeleteAccountBinding
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
@ -50,7 +50,7 @@ class DeleteAccountDialog : DialogFragment() {
try { try {
RetrofitInstance.authApi.deleteAccount(token, DeleteUserRequest(password)) RetrofitInstance.authApi.deleteAccount(token, DeleteUserRequest(password))
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, e.toString()) Log.e(TAG(), e.toString())
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} }

View File

@ -11,18 +11,18 @@ import androidx.core.view.size
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.RetrofitInstance
import com.github.libretube.databinding.DialogDownloadBinding import com.github.libretube.databinding.DialogDownloadBinding
import com.github.libretube.extensions.TAG
import com.github.libretube.obj.Streams import com.github.libretube.obj.Streams
import com.github.libretube.services.DownloadService import com.github.libretube.services.DownloadService
import com.github.libretube.util.PermissionHelper import com.github.libretube.util.PermissionHelper
import com.github.libretube.util.RetrofitInstance
import com.github.libretube.util.ThemeHelper import com.github.libretube.util.ThemeHelper
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
class DownloadDialog : DialogFragment() { class DownloadDialog : DialogFragment() {
private val TAG = "DownloadDialog"
private lateinit var binding: DialogDownloadBinding private lateinit var binding: DialogDownloadBinding
private lateinit var videoId: String private lateinit var videoId: String
@ -62,11 +62,11 @@ class DownloadDialog : DialogFragment() {
RetrofitInstance.api.getStreams(videoId) RetrofitInstance.api.getStreams(videoId)
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response") Log.e(TAG(), "HttpException, unexpected response")
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} }

View File

@ -7,17 +7,17 @@ import android.widget.Toast
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.RetrofitInstance
import com.github.libretube.databinding.DialogLoginBinding import com.github.libretube.databinding.DialogLoginBinding
import com.github.libretube.extensions.TAG
import com.github.libretube.obj.Login import com.github.libretube.obj.Login
import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.util.RetrofitInstance
import com.github.libretube.util.ThemeHelper import com.github.libretube.util.ThemeHelper
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
class LoginDialog : DialogFragment() { class LoginDialog : DialogFragment() {
private val TAG = "LoginDialog"
private lateinit var binding: DialogLoginBinding private lateinit var binding: DialogLoginBinding
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
@ -64,15 +64,15 @@ class LoginDialog : DialogFragment() {
RetrofitInstance.authApi.login(login) RetrofitInstance.authApi.login(login)
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response") Log.e(TAG(), "HttpException, unexpected response")
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, "dafaq?$e") Log.e(TAG(), "dafaq?$e")
return@launchWhenCreated return@launchWhenCreated
} }
if (response.error != null) { if (response.error != null) {
@ -96,15 +96,15 @@ class LoginDialog : DialogFragment() {
RetrofitInstance.authApi.register(login) RetrofitInstance.authApi.register(login)
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response") Log.e(TAG(), "HttpException, unexpected response")
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, "dafaq?$e") Log.e(TAG(), "dafaq?$e")
return@launchWhenCreated return@launchWhenCreated
} }
if (response.error != null) { if (response.error != null) {

View File

@ -11,7 +11,6 @@ import com.github.libretube.util.ThemeHelper
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
class LogoutDialog : DialogFragment() { class LogoutDialog : DialogFragment() {
private val TAG = "LogoutDialog"
private lateinit var binding: DialogLogoutBinding private lateinit var binding: DialogLogoutBinding
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {

View File

@ -7,10 +7,11 @@ import android.widget.ArrayAdapter
import android.widget.Toast import android.widget.Toast
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.RetrofitInstance
import com.github.libretube.extensions.TAG
import com.github.libretube.obj.PlaylistId import com.github.libretube.obj.PlaylistId
import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.util.BackgroundHelper import com.github.libretube.util.BackgroundHelper
import com.github.libretube.util.RetrofitInstance
import com.github.libretube.util.toID import com.github.libretube.util.toID
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@ -24,7 +25,6 @@ class PlaylistOptionsDialog(
private val playlistId: String, private val playlistId: String,
private val isOwner: Boolean private val isOwner: Boolean
) : DialogFragment() { ) : DialogFragment() {
val TAG = "PlaylistOptionsDialog"
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
// options for the dialog // options for the dialog
@ -104,7 +104,7 @@ class PlaylistOptionsDialog(
} catch (e: HttpException) { } catch (e: HttpException) {
return@launch return@launch
} }
Log.e(TAG, response.toString()) Log.e(TAG(), response.toString())
} }
} }
run() run()
@ -113,14 +113,14 @@ class PlaylistOptionsDialog(
private fun deletePlaylist(id: String, token: String) { private fun deletePlaylist(id: String, token: String) {
fun run() { fun run() {
CoroutineScope(Dispatchers.IO).launch { CoroutineScope(Dispatchers.IO).launch {
val response = try { try {
RetrofitInstance.authApi.deletePlaylist(token, PlaylistId(id)) RetrofitInstance.authApi.deletePlaylist(token, PlaylistId(id))
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
return@launch return@launch
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response") Log.e(TAG(), "HttpException, unexpected response")
return@launch return@launch
} }
} }

View File

@ -7,9 +7,9 @@ import androidx.fragment.app.DialogFragment
import com.github.libretube.PIPED_FRONTEND_URL import com.github.libretube.PIPED_FRONTEND_URL
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.YOUTUBE_FRONTEND_URL import com.github.libretube.YOUTUBE_FRONTEND_URL
import com.github.libretube.database.DatabaseHolder import com.github.libretube.db.DatabaseHolder
import com.github.libretube.db.obj.CustomInstance
import com.github.libretube.extensions.await import com.github.libretube.extensions.await
import com.github.libretube.obj.CustomInstance
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.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
@ -76,7 +76,7 @@ class ShareDialog(
// get the api urls of the other custom instances // get the api urls of the other custom instances
var customInstances = listOf<CustomInstance>() var customInstances = listOf<CustomInstance>()
Thread { Thread {
customInstances = DatabaseHolder.database.customInstanceDao().getAll() customInstances = DatabaseHolder.db.customInstanceDao().getAll()
}.await() }.await()
// return the custom instance frontend url if available // return the custom instance frontend url if available

View File

@ -22,7 +22,6 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
class VideoOptionsDialog( class VideoOptionsDialog(
private val videoId: String private val videoId: String
) : DialogFragment() { ) : DialogFragment() {
private val TAG = "VideoOptionsDialog"
/** /**
* Dialog that returns a [MaterialAlertDialogBuilder] showing a menu of options. * Dialog that returns a [MaterialAlertDialogBuilder] showing a menu of options.
@ -40,7 +39,8 @@ class VideoOptionsDialog(
/** /**
* Check whether the player is running by observing the notification * Check whether the player is running by observing the notification
*/ */
val notificationManager = context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager val notificationManager =
context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.activeNotifications.forEach { notificationManager.activeNotifications.forEach {
if (it.id == PLAYER_NOTIFICATION_ID) { if (it.id == PLAYER_NOTIFICATION_ID) {
optionsList += context?.getString(R.string.add_to_queue) optionsList += context?.getString(R.string.add_to_queue)

View File

@ -3,7 +3,7 @@ package com.github.libretube.util
import android.view.View import android.view.View
import android.view.ViewTreeObserver import android.view.ViewTreeObserver
import android.widget.LinearLayout import android.widget.LinearLayout
import com.github.libretube.database.DatabaseHolder import com.github.libretube.db.DatabaseHolder
import com.github.libretube.extensions.await import com.github.libretube.extensions.await
/** /**
@ -15,7 +15,7 @@ fun View?.setWatchProgressLength(videoId: String, duration: Long) {
Thread { Thread {
try { try {
progress = DatabaseHolder.database.watchPositionDao().findById(videoId).position progress = DatabaseHolder.db.watchPositionDao().findById(videoId).position
} catch (e: Exception) { } catch (e: Exception) {
progress = null progress = null
} }

View File

@ -0,0 +1,3 @@
package com.github.libretube.extensions
fun Any.TAG(): String = this::class.java.name

View File

@ -9,18 +9,18 @@ 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.api.RetrofitInstance
import com.github.libretube.api.SubscriptionHelper
import com.github.libretube.databinding.FragmentChannelBinding import com.github.libretube.databinding.FragmentChannelBinding
import com.github.libretube.extensions.BaseFragment import com.github.libretube.extensions.BaseFragment
import com.github.libretube.extensions.TAG
import com.github.libretube.util.ConnectionHelper import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.RetrofitInstance
import com.github.libretube.util.SubscriptionHelper
import com.github.libretube.util.formatShort import com.github.libretube.util.formatShort
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 ChannelFragment : BaseFragment() { class ChannelFragment : BaseFragment() {
private val TAG = "ChannelFragment"
private lateinit var binding: FragmentChannelBinding private lateinit var binding: FragmentChannelBinding
private var channelId: String? = null private var channelId: String? = null
@ -115,11 +115,11 @@ class ChannelFragment : BaseFragment() {
} catch (e: IOException) { } catch (e: IOException) {
binding.channelRefresh.isRefreshing = false binding.channelRefresh.isRefreshing = false
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
binding.channelRefresh.isRefreshing = false binding.channelRefresh.isRefreshing = false
Log.e(TAG, "HttpException, unexpected response") Log.e(TAG(), "HttpException, unexpected response")
return@launchWhenCreated return@launchWhenCreated
} }
nextPage = response.nextpage nextPage = response.nextpage
@ -169,11 +169,11 @@ class ChannelFragment : BaseFragment() {
} catch (e: IOException) { } catch (e: IOException) {
binding.channelRefresh.isRefreshing = false binding.channelRefresh.isRefreshing = false
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
binding.channelRefresh.isRefreshing = false binding.channelRefresh.isRefreshing = false
Log.e(TAG, "HttpException, unexpected response," + e.response()) Log.e(TAG(), "HttpException, unexpected response," + e.response())
return@launchWhenCreated return@launchWhenCreated
} }
nextPage = response.nextpage nextPage = response.nextpage

View File

@ -10,17 +10,17 @@ 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.api.RetrofitInstance
import com.github.libretube.databinding.FragmentHomeBinding import com.github.libretube.databinding.FragmentHomeBinding
import com.github.libretube.extensions.BaseFragment import com.github.libretube.extensions.BaseFragment
import com.github.libretube.extensions.TAG
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
import com.github.libretube.util.RetrofitInstance
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
class HomeFragment : BaseFragment() { class HomeFragment : BaseFragment() {
private val TAG = "HomeFragment"
private lateinit var binding: FragmentHomeBinding private lateinit var binding: FragmentHomeBinding
private lateinit var region: String private lateinit var region: String
@ -44,7 +44,7 @@ class HomeFragment : BaseFragment() {
val grid = PreferenceHelper.getString( val grid = PreferenceHelper.getString(
PreferenceKeys.GRID_COLUMNS, PreferenceKeys.GRID_COLUMNS,
resources.getInteger(R.integer.grid_items).toString() resources.getInteger(R.integer.grid_items).toString()
)!! )
val regionPref = PreferenceHelper.getString(PreferenceKeys.REGION, "sys")!! val regionPref = PreferenceHelper.getString(PreferenceKeys.REGION, "sys")!!
@ -70,11 +70,11 @@ class HomeFragment : BaseFragment() {
RetrofitInstance.api.getTrending(region) RetrofitInstance.api.getTrending(region)
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response") Log.e(TAG(), "HttpException, unexpected response")
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} finally { } finally {

View File

@ -13,18 +13,18 @@ import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.Globals import com.github.libretube.Globals
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.adapters.PlaylistsAdapter import com.github.libretube.adapters.PlaylistsAdapter
import com.github.libretube.api.RetrofitInstance
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.extensions.BaseFragment
import com.github.libretube.extensions.TAG
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 retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
class LibraryFragment : BaseFragment() { class LibraryFragment : BaseFragment() {
private val TAG = "LibraryFragment"
lateinit var token: String lateinit var token: String
private lateinit var binding: FragmentLibraryBinding private lateinit var binding: FragmentLibraryBinding
@ -92,11 +92,11 @@ class LibraryFragment : BaseFragment() {
RetrofitInstance.authApi.playlists(token) RetrofitInstance.authApi.playlists(token)
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response") Log.e(TAG(), "HttpException, unexpected response")
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} finally { } finally {
@ -115,7 +115,7 @@ class LibraryFragment : BaseFragment() {
playlistsAdapter.registerAdapterDataObserver(object : playlistsAdapter.registerAdapterDataObserver(object :
RecyclerView.AdapterDataObserver() { RecyclerView.AdapterDataObserver() {
override fun onChanged() { override fun onChanged() {
Log.e(TAG, playlistsAdapter.itemCount.toString()) Log.e(TAG(), playlistsAdapter.itemCount.toString())
if (playlistsAdapter.itemCount == 0) { if (playlistsAdapter.itemCount == 0) {
binding.loginOrRegister.visibility = View.VISIBLE binding.loginOrRegister.visibility = View.VISIBLE
} }

View File

@ -37,15 +37,19 @@ import com.github.libretube.activities.MainActivity
import com.github.libretube.adapters.ChaptersAdapter import com.github.libretube.adapters.ChaptersAdapter
import com.github.libretube.adapters.CommentsAdapter import com.github.libretube.adapters.CommentsAdapter
import com.github.libretube.adapters.TrendingAdapter import com.github.libretube.adapters.TrendingAdapter
import com.github.libretube.database.DatabaseHelper import com.github.libretube.api.CronetHelper
import com.github.libretube.database.DatabaseHolder import com.github.libretube.api.RetrofitInstance
import com.github.libretube.api.SubscriptionHelper
import com.github.libretube.databinding.DoubleTapOverlayBinding import com.github.libretube.databinding.DoubleTapOverlayBinding
import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding
import com.github.libretube.databinding.FragmentPlayerBinding import com.github.libretube.databinding.FragmentPlayerBinding
import com.github.libretube.db.DatabaseHelper
import com.github.libretube.db.DatabaseHolder
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.extensions.BaseFragment
import com.github.libretube.extensions.TAG
import com.github.libretube.extensions.await import com.github.libretube.extensions.await
import com.github.libretube.interfaces.DoubleTapInterface import com.github.libretube.interfaces.DoubleTapInterface
import com.github.libretube.interfaces.PlayerOptionsInterface import com.github.libretube.interfaces.PlayerOptionsInterface
@ -59,11 +63,8 @@ import com.github.libretube.services.BackgroundMode
import com.github.libretube.util.AutoPlayHelper import com.github.libretube.util.AutoPlayHelper
import com.github.libretube.util.BackgroundHelper import com.github.libretube.util.BackgroundHelper
import com.github.libretube.util.ConnectionHelper import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.CronetHelper
import com.github.libretube.util.NowPlayingNotification import com.github.libretube.util.NowPlayingNotification
import com.github.libretube.util.PlayerHelper import com.github.libretube.util.PlayerHelper
import com.github.libretube.util.RetrofitInstance
import com.github.libretube.util.SubscriptionHelper
import com.github.libretube.util.formatShort import com.github.libretube.util.formatShort
import com.github.libretube.util.hideKeyboard import com.github.libretube.util.hideKeyboard
import com.github.libretube.util.toID import com.github.libretube.util.toID
@ -102,7 +103,6 @@ import kotlin.math.abs
class PlayerFragment : BaseFragment() { class PlayerFragment : BaseFragment() {
private val TAG = "PlayerFragment"
private lateinit var binding: FragmentPlayerBinding private lateinit var binding: FragmentPlayerBinding
private lateinit var playerBinding: ExoStyledPlayerControlViewBinding private lateinit var playerBinding: ExoStyledPlayerControlViewBinding
private lateinit var doubleTapOverlayBinding: DoubleTapOverlayBinding private lateinit var doubleTapOverlayBinding: DoubleTapOverlayBinding
@ -581,12 +581,14 @@ class PlayerFragment : BaseFragment() {
currentAutoplayMode = if (autoplayEnabled) context.getString(R.string.enabled) currentAutoplayMode = if (autoplayEnabled) context.getString(R.string.enabled)
else context.getString(R.string.disabled) else context.getString(R.string.disabled)
// set the current caption language // set the current caption language
currentCaptions = if (trackSelector.parameters.preferredTextLanguages.isNotEmpty()) { currentCaptions =
trackSelector.parameters.preferredTextLanguages[0] if (trackSelector.parameters.preferredTextLanguages.isNotEmpty()) {
} else context.getString(R.string.none) trackSelector.parameters.preferredTextLanguages[0]
} else context.getString(R.string.none)
// set the playback speed // set the playback speed
val playbackSpeeds = context.resources.getStringArray(R.array.playbackSpeed) val playbackSpeeds = context.resources.getStringArray(R.array.playbackSpeed)
val playbackSpeedValues = context.resources.getStringArray(R.array.playbackSpeedValues) val playbackSpeedValues =
context.resources.getStringArray(R.array.playbackSpeedValues)
val playbackSpeed = exoPlayer.playbackParameters.speed.toString() val playbackSpeed = exoPlayer.playbackParameters.speed.toString()
currentPlaybackSpeed = playbackSpeeds[playbackSpeedValues.indexOf(playbackSpeed)] currentPlaybackSpeed = playbackSpeeds[playbackSpeedValues.indexOf(playbackSpeed)]
// set the quality text // set the quality text
@ -598,9 +600,10 @@ class PlayerFragment : BaseFragment() {
else "${quality}p" else "${quality}p"
} }
// set the repeat mode // set the repeat mode
currentRepeatMode = if (exoPlayer.repeatMode == RepeatModeUtil.REPEAT_TOGGLE_MODE_NONE) { currentRepeatMode =
context.getString(R.string.repeat_mode_none) if (exoPlayer.repeatMode == RepeatModeUtil.REPEAT_TOGGLE_MODE_NONE) {
} else context.getString(R.string.repeat_mode_current) context.getString(R.string.repeat_mode_none)
} else context.getString(R.string.repeat_mode_current)
// set the aspect ratio mode // set the aspect ratio mode
currentAspectRatio = when (exoPlayerView.resizeMode) { currentAspectRatio = when (exoPlayerView.resizeMode) {
AspectRatioFrameLayout.RESIZE_MODE_FIT -> context.getString(R.string.resize_mode_fit) AspectRatioFrameLayout.RESIZE_MODE_FIT -> context.getString(R.string.resize_mode_fit)
@ -854,11 +857,11 @@ class PlayerFragment : BaseFragment() {
RetrofitInstance.api.getStreams(videoId!!) RetrofitInstance.api.getStreams(videoId!!)
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response") Log.e(TAG(), "HttpException, unexpected response")
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} }
@ -920,7 +923,7 @@ class PlayerFragment : BaseFragment() {
playerBinding.liveSeparator.visibility = View.GONE playerBinding.liveSeparator.visibility = View.GONE
playerBinding.liveDiff.text = "" playerBinding.liveDiff.text = ""
} else { } else {
Log.e(TAG, "changing the time") Log.e(TAG(), "changing the time")
// live stream but not watching at the end/live position // live stream but not watching at the end/live position
playerBinding.liveSeparator.visibility = View.VISIBLE playerBinding.liveSeparator.visibility = View.VISIBLE
val diffText = DateUtils.formatElapsedTime( val diffText = DateUtils.formatElapsedTime(
@ -938,7 +941,7 @@ class PlayerFragment : BaseFragment() {
var position: Long? = null var position: Long? = null
Thread { Thread {
try { try {
position = DatabaseHolder.database.watchPositionDao().findById(videoId!!).position position = DatabaseHolder.db.watchPositionDao().findById(videoId!!).position
} catch (e: Exception) { } catch (e: Exception) {
position = null position = null
} }
@ -1564,11 +1567,11 @@ class PlayerFragment : BaseFragment() {
RetrofitInstance.api.getComments(videoId!!) RetrofitInstance.api.getComments(videoId!!)
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response") Log.e(TAG(), "HttpException, unexpected response")
return@launchWhenCreated return@launchWhenCreated
} }
commentsAdapter = CommentsAdapter(videoId!!, commentsResponse.comments) commentsAdapter = CommentsAdapter(videoId!!, commentsResponse.comments)
@ -1587,10 +1590,10 @@ class PlayerFragment : BaseFragment() {
RetrofitInstance.api.getCommentsNextPage(videoId!!, nextPage!!) RetrofitInstance.api.getCommentsNextPage(videoId!!, nextPage!!)
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response," + e.response()) Log.e(TAG(), "HttpException, unexpected response," + e.response())
return@launchWhenCreated return@launchWhenCreated
} }
nextPage = response.nextpage nextPage = response.nextpage

View File

@ -11,16 +11,16 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.adapters.PlaylistAdapter import com.github.libretube.adapters.PlaylistAdapter
import com.github.libretube.api.RetrofitInstance
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.extensions.BaseFragment
import com.github.libretube.util.RetrofitInstance import com.github.libretube.extensions.TAG
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 : BaseFragment() { class PlaylistFragment : BaseFragment() {
private val TAG = "PlaylistFragment"
private lateinit var binding: FragmentPlaylistBinding private lateinit var binding: FragmentPlaylistBinding
private var playlistId: String? = null private var playlistId: String? = null
@ -65,10 +65,10 @@ class PlaylistFragment : BaseFragment() {
else RetrofitInstance.api.getPlaylist(playlistId!!) else RetrofitInstance.api.getPlaylist(playlistId!!)
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response") Log.e(TAG(), "HttpException, unexpected response")
return@launchWhenCreated return@launchWhenCreated
} }
nextPage = response.nextpage nextPage = response.nextpage
@ -103,7 +103,10 @@ class PlaylistFragment : BaseFragment() {
RecyclerView.AdapterDataObserver() { RecyclerView.AdapterDataObserver() {
override fun onChanged() { override fun onChanged() {
binding.videoCount.text = binding.videoCount.text =
getString(R.string.videoCount, playlistAdapter!!.itemCount.toString()) getString(
R.string.videoCount,
playlistAdapter!!.itemCount.toString()
)
} }
}) })
@ -169,10 +172,10 @@ class PlaylistFragment : BaseFragment() {
) )
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response," + e.response()) Log.e(TAG(), "HttpException, unexpected response," + e.response())
return@launchWhenCreated return@launchWhenCreated
} }
nextPage = response.nextpage nextPage = response.nextpage

View File

@ -11,17 +11,17 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.github.libretube.activities.MainActivity 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.database.DatabaseHolder import com.github.libretube.api.RetrofitInstance
import com.github.libretube.databinding.FragmentSearchBinding import com.github.libretube.databinding.FragmentSearchBinding
import com.github.libretube.db.DatabaseHolder
import com.github.libretube.extensions.BaseFragment import com.github.libretube.extensions.BaseFragment
import com.github.libretube.extensions.TAG
import com.github.libretube.extensions.await import com.github.libretube.extensions.await
import com.github.libretube.models.SearchViewModel import com.github.libretube.models.SearchViewModel
import com.github.libretube.util.RetrofitInstance
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
class SearchFragment() : BaseFragment() { class SearchFragment() : BaseFragment() {
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()
@ -67,10 +67,10 @@ class SearchFragment() : BaseFragment() {
RetrofitInstance.api.getSuggestions(query) RetrofitInstance.api.getSuggestions(query)
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response") Log.e(TAG(), "HttpException, unexpected response")
return@launchWhenCreated return@launchWhenCreated
} }
// only load the suggestions if the input field didn't get cleared yet // only load the suggestions if the input field didn't get cleared yet
@ -92,8 +92,8 @@ class SearchFragment() : BaseFragment() {
private fun showHistory() { private fun showHistory() {
var historyList = listOf<String>() var historyList = listOf<String>()
Thread { Thread {
val history = DatabaseHolder.database.searchHistoryDao().getAll() val history = DatabaseHolder.db.searchHistoryDao().getAll()
historyList = history.map { it.query!! } historyList = history.map { it.query }
}.await() }.await()
if (historyList.isNotEmpty()) { if (historyList.isNotEmpty()) {
binding.suggestionsRecycler.adapter = binding.suggestionsRecycler.adapter =

View File

@ -9,20 +9,20 @@ 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.database.DatabaseHolder import com.github.libretube.api.RetrofitInstance
import com.github.libretube.databinding.FragmentSearchResultBinding import com.github.libretube.databinding.FragmentSearchResultBinding
import com.github.libretube.db.DatabaseHolder
import com.github.libretube.db.obj.SearchHistoryItem
import com.github.libretube.extensions.BaseFragment import com.github.libretube.extensions.BaseFragment
import com.github.libretube.extensions.TAG
import com.github.libretube.extensions.await import com.github.libretube.extensions.await
import com.github.libretube.obj.SearchHistoryItem
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.hideKeyboard import com.github.libretube.util.hideKeyboard
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
class SearchResultFragment : BaseFragment() { class SearchResultFragment : BaseFragment() {
private val TAG = "SearchResultFragment"
private lateinit var binding: FragmentSearchResultBinding private lateinit var binding: FragmentSearchResultBinding
private var nextPage: String? = null private var nextPage: String? = null
@ -86,10 +86,10 @@ class SearchResultFragment : BaseFragment() {
RetrofitInstance.api.getSearchResults(query, apiSearchFilter) RetrofitInstance.api.getSearchResults(query, apiSearchFilter)
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection $e") Log.e(TAG(), "IOException, you might not have internet connection $e")
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response") Log.e(TAG(), "HttpException, unexpected response")
return@launchWhenCreated return@launchWhenCreated
} }
runOnUiThread { runOnUiThread {
@ -116,10 +116,10 @@ class SearchResultFragment : BaseFragment() {
) )
} catch (e: IOException) { } catch (e: IOException) {
println(e) println(e)
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response," + e.response()) Log.e(TAG(), "HttpException, unexpected response," + e.response())
return@launchWhenCreated return@launchWhenCreated
} }
nextPage = response.nextpage!! nextPage = response.nextpage!!
@ -136,7 +136,7 @@ class SearchResultFragment : BaseFragment() {
PreferenceHelper.getBoolean(PreferenceKeys.SEARCH_HISTORY_TOGGLE, true) PreferenceHelper.getBoolean(PreferenceKeys.SEARCH_HISTORY_TOGGLE, true)
if (searchHistoryEnabled && query != "") { if (searchHistoryEnabled && query != "") {
Thread { Thread {
DatabaseHolder.database.searchHistoryDao().insertAll( DatabaseHolder.db.searchHistoryDao().insertAll(
SearchHistoryItem( SearchHistoryItem(
query = query query = query
) )

View File

@ -13,20 +13,20 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.github.libretube.R 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.api.RetrofitInstance
import com.github.libretube.api.SubscriptionHelper
import com.github.libretube.databinding.FragmentSubscriptionsBinding import com.github.libretube.databinding.FragmentSubscriptionsBinding
import com.github.libretube.extensions.BaseFragment import com.github.libretube.extensions.BaseFragment
import com.github.libretube.extensions.TAG
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
import com.github.libretube.util.RetrofitInstance
import com.github.libretube.util.SubscriptionHelper
import com.github.libretube.util.toID import com.github.libretube.util.toID
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
class SubscriptionsFragment : BaseFragment() { class SubscriptionsFragment : BaseFragment() {
val TAG = "SubFragment"
private lateinit var binding: FragmentSubscriptionsBinding private lateinit var binding: FragmentSubscriptionsBinding
lateinit var token: String lateinit var token: String
@ -130,11 +130,11 @@ class SubscriptionsFragment : BaseFragment() {
SubscriptionHelper.getFormattedLocalSubscriptions() SubscriptionHelper.getFormattedLocalSubscriptions()
) )
} catch (e: IOException) { } catch (e: IOException) {
Log.e(TAG, e.toString()) Log.e(TAG(), e.toString())
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response") Log.e(TAG(), "HttpException, unexpected response")
return@launchWhenCreated return@launchWhenCreated
} finally { } finally {
binding.subRefresh.isRefreshing = false binding.subRefresh.isRefreshing = false
@ -180,11 +180,11 @@ class SubscriptionsFragment : BaseFragment() {
SubscriptionHelper.getFormattedLocalSubscriptions() SubscriptionHelper.getFormattedLocalSubscriptions()
) )
} catch (e: IOException) { } catch (e: IOException) {
Log.e(TAG, e.toString()) Log.e(TAG(), e.toString())
Log.e(TAG, "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response") Log.e(TAG(), "HttpException, unexpected response")
return@launchWhenCreated return@launchWhenCreated
} finally { } finally {
binding.subRefresh.isRefreshing = false binding.subRefresh.isRefreshing = false

View File

@ -8,14 +8,13 @@ import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.adapters.WatchHistoryAdapter import com.github.libretube.adapters.WatchHistoryAdapter
import com.github.libretube.database.DatabaseHolder
import com.github.libretube.databinding.FragmentWatchHistoryBinding import com.github.libretube.databinding.FragmentWatchHistoryBinding
import com.github.libretube.db.DatabaseHolder
import com.github.libretube.db.obj.WatchHistoryItem
import com.github.libretube.extensions.BaseFragment import com.github.libretube.extensions.BaseFragment
import com.github.libretube.extensions.await import com.github.libretube.extensions.await
import com.github.libretube.obj.WatchHistoryItem
class WatchHistoryFragment : BaseFragment() { class WatchHistoryFragment : BaseFragment() {
private val TAG = "WatchHistoryFragment"
private lateinit var binding: FragmentWatchHistoryBinding private lateinit var binding: FragmentWatchHistoryBinding
override fun onCreateView( override fun onCreateView(
@ -33,7 +32,7 @@ class WatchHistoryFragment : BaseFragment() {
var watchHistory = listOf<WatchHistoryItem>() var watchHistory = listOf<WatchHistoryItem>()
Thread { Thread {
watchHistory = DatabaseHolder.database.watchHistoryDao().getAll() watchHistory = DatabaseHolder.db.watchHistoryDao().getAll()
}.await() }.await()
if (watchHistory.isEmpty()) return if (watchHistory.isEmpty()) return

View File

@ -12,7 +12,6 @@ import com.github.libretube.views.MaterialPreferenceFragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
class AdvancedSettings : MaterialPreferenceFragment() { class AdvancedSettings : MaterialPreferenceFragment() {
val TAG = "AdvancedSettings"
/** /**
* result listeners for importing and exporting subscriptions * result listeners for importing and exporting subscriptions

View File

@ -16,7 +16,6 @@ import com.github.libretube.views.MaterialPreferenceFragment
import com.google.android.material.color.DynamicColors import com.google.android.material.color.DynamicColors
class AppearanceSettings : MaterialPreferenceFragment() { class AppearanceSettings : MaterialPreferenceFragment() {
private val TAG = "AppearanceSettings"
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.appearance_settings, rootKey) setPreferencesFromResource(R.xml.appearance_settings, rootKey)

View File

@ -9,7 +9,6 @@ import com.github.libretube.dialogs.RequireRestartDialog
import com.github.libretube.views.MaterialPreferenceFragment import com.github.libretube.views.MaterialPreferenceFragment
class GeneralSettings : MaterialPreferenceFragment() { class GeneralSettings : MaterialPreferenceFragment() {
val TAG = "SettingsFragment"
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.general_settings, rootKey) setPreferencesFromResource(R.xml.general_settings, rootKey)

View File

@ -4,7 +4,7 @@ import android.os.Bundle
import androidx.preference.Preference import androidx.preference.Preference
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.activities.SettingsActivity import com.github.libretube.activities.SettingsActivity
import com.github.libretube.database.DatabaseHolder import com.github.libretube.db.DatabaseHolder
import com.github.libretube.views.MaterialPreferenceFragment import com.github.libretube.views.MaterialPreferenceFragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
@ -20,7 +20,7 @@ class HistorySettings : MaterialPreferenceFragment() {
val clearHistory = findPreference<Preference>(PreferenceKeys.CLEAR_SEARCH_HISTORY) val clearHistory = findPreference<Preference>(PreferenceKeys.CLEAR_SEARCH_HISTORY)
clearHistory?.setOnPreferenceClickListener { clearHistory?.setOnPreferenceClickListener {
showClearDialog(R.string.clear_history) { showClearDialog(R.string.clear_history) {
DatabaseHolder.database.searchHistoryDao().deleteAll() DatabaseHolder.db.searchHistoryDao().deleteAll()
} }
true true
} }
@ -29,7 +29,7 @@ class HistorySettings : MaterialPreferenceFragment() {
val clearWatchHistory = findPreference<Preference>(PreferenceKeys.CLEAR_WATCH_HISTORY) val clearWatchHistory = findPreference<Preference>(PreferenceKeys.CLEAR_WATCH_HISTORY)
clearWatchHistory?.setOnPreferenceClickListener { clearWatchHistory?.setOnPreferenceClickListener {
showClearDialog(R.string.clear_history) { showClearDialog(R.string.clear_history) {
DatabaseHolder.database.watchHistoryDao().deleteAll() DatabaseHolder.db.watchHistoryDao().deleteAll()
} }
true true
} }
@ -38,7 +38,7 @@ class HistorySettings : MaterialPreferenceFragment() {
val clearWatchPositions = findPreference<Preference>(PreferenceKeys.CLEAR_WATCH_POSITIONS) val clearWatchPositions = findPreference<Preference>(PreferenceKeys.CLEAR_WATCH_POSITIONS)
clearWatchPositions?.setOnPreferenceClickListener { clearWatchPositions?.setOnPreferenceClickListener {
showClearDialog(R.string.reset_watch_positions) { showClearDialog(R.string.reset_watch_positions) {
DatabaseHolder.database.watchPositionDao().deleteAll() DatabaseHolder.db.watchPositionDao().deleteAll()
} }
true true
} }

View File

@ -12,20 +12,19 @@ import androidx.preference.Preference
import androidx.preference.SwitchPreferenceCompat import androidx.preference.SwitchPreferenceCompat
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.activities.SettingsActivity import com.github.libretube.activities.SettingsActivity
import com.github.libretube.database.DatabaseHolder import com.github.libretube.api.RetrofitInstance
import com.github.libretube.db.DatabaseHolder
import com.github.libretube.db.obj.CustomInstance
import com.github.libretube.dialogs.CustomInstanceDialog import com.github.libretube.dialogs.CustomInstanceDialog
import com.github.libretube.dialogs.DeleteAccountDialog import com.github.libretube.dialogs.DeleteAccountDialog
import com.github.libretube.dialogs.LoginDialog import com.github.libretube.dialogs.LoginDialog
import com.github.libretube.dialogs.LogoutDialog import com.github.libretube.dialogs.LogoutDialog
import com.github.libretube.extensions.await import com.github.libretube.extensions.await
import com.github.libretube.obj.CustomInstance
import com.github.libretube.util.ImportHelper import com.github.libretube.util.ImportHelper
import com.github.libretube.util.PermissionHelper import com.github.libretube.util.PermissionHelper
import com.github.libretube.util.RetrofitInstance
import com.github.libretube.views.MaterialPreferenceFragment import com.github.libretube.views.MaterialPreferenceFragment
class InstanceSettings : MaterialPreferenceFragment() { class InstanceSettings : MaterialPreferenceFragment() {
val TAG = "InstanceSettings"
/** /**
* result listeners for importing and exporting subscriptions * result listeners for importing and exporting subscriptions
@ -107,7 +106,7 @@ class InstanceSettings : MaterialPreferenceFragment() {
val clearCustomInstances = findPreference<Preference>(PreferenceKeys.CLEAR_CUSTOM_INSTANCES) val clearCustomInstances = findPreference<Preference>(PreferenceKeys.CLEAR_CUSTOM_INSTANCES)
clearCustomInstances?.setOnPreferenceClickListener { clearCustomInstances?.setOnPreferenceClickListener {
Thread { Thread {
DatabaseHolder.database.customInstanceDao().deleteAll() DatabaseHolder.db.customInstanceDao().deleteAll()
}.await() }.await()
activity?.recreate() activity?.recreate()
true true
@ -162,7 +161,7 @@ class InstanceSettings : MaterialPreferenceFragment() {
lifecycleScope.launchWhenCreated { lifecycleScope.launchWhenCreated {
var customInstances = listOf<CustomInstance>() var customInstances = listOf<CustomInstance>()
Thread { Thread {
customInstances = DatabaseHolder.database.customInstanceDao().getAll() customInstances = DatabaseHolder.db.customInstanceDao().getAll()
}.await() }.await()
val instanceNames = arrayListOf<String>() val instanceNames = arrayListOf<String>()

View File

@ -15,7 +15,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
class MainSettings : MaterialPreferenceFragment() { class MainSettings : MaterialPreferenceFragment() {
val TAG = "SettingsFragment"
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.settings, rootKey) setPreferencesFromResource(R.xml.settings, rootKey)

View File

@ -10,7 +10,6 @@ import com.github.libretube.util.NotificationHelper
import com.github.libretube.views.MaterialPreferenceFragment import com.github.libretube.views.MaterialPreferenceFragment
class NotificationSettings : MaterialPreferenceFragment() { class NotificationSettings : MaterialPreferenceFragment() {
val TAG = "SettingsFragment"
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.notification_settings, rootKey) setPreferencesFromResource(R.xml.notification_settings, rootKey)

View File

@ -10,7 +10,6 @@ import com.github.libretube.views.MaterialPreferenceFragment
import java.util.* import java.util.*
class PlayerSettings : MaterialPreferenceFragment() { class PlayerSettings : MaterialPreferenceFragment() {
val TAG = "PlayerSettings"
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.player_settings, rootKey) setPreferencesFromResource(R.xml.player_settings, rootKey)

View File

@ -7,10 +7,6 @@ import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.ObjectMapper
object PreferenceHelper { object PreferenceHelper {
private val TAG = "PreferenceHelper"
private lateinit var prefContext: Context
/** /**
* for normal preferences * for normal preferences
*/ */
@ -29,9 +25,7 @@ object PreferenceHelper {
* set the context that is being used to access the shared preferences * set the context that is being used to access the shared preferences
*/ */
fun setContext(context: Context) { fun setContext(context: Context) {
prefContext = context settings = getDefaultSharedPreferences(context)
settings = getDefaultSharedPreferences(prefContext)
editor = settings.edit() editor = settings.edit()
authSettings = getAuthenticationPreferences(context) authSettings = getAuthenticationPreferences(context)

View File

@ -6,7 +6,6 @@ import com.github.libretube.activities.SettingsActivity
import com.github.libretube.views.MaterialPreferenceFragment import com.github.libretube.views.MaterialPreferenceFragment
class SponsorBlockSettings : MaterialPreferenceFragment() { class SponsorBlockSettings : MaterialPreferenceFragment() {
private val TAG = "SponsorBlockSettings"
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.sponsorblock_settings, rootKey) setPreferencesFromResource(R.xml.sponsorblock_settings, rootKey)

View File

@ -15,6 +15,7 @@ import com.github.libretube.BACKGROUND_CHANNEL_ID
import com.github.libretube.Globals import com.github.libretube.Globals
import com.github.libretube.PLAYER_NOTIFICATION_ID import com.github.libretube.PLAYER_NOTIFICATION_ID
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.RetrofitInstance
import com.github.libretube.obj.Segment import com.github.libretube.obj.Segment
import com.github.libretube.obj.Segments import com.github.libretube.obj.Segments
import com.github.libretube.obj.Streams import com.github.libretube.obj.Streams
@ -23,7 +24,6 @@ import com.github.libretube.preferences.PreferenceKeys
import com.github.libretube.util.AutoPlayHelper import com.github.libretube.util.AutoPlayHelper
import com.github.libretube.util.NowPlayingNotification import com.github.libretube.util.NowPlayingNotification
import com.github.libretube.util.PlayerHelper import com.github.libretube.util.PlayerHelper
import com.github.libretube.util.RetrofitInstance
import com.github.libretube.util.toID import com.github.libretube.util.toID
import com.google.android.exoplayer2.C import com.google.android.exoplayer2.C
import com.google.android.exoplayer2.ExoPlayer import com.google.android.exoplayer2.ExoPlayer

View File

@ -9,7 +9,6 @@ import androidx.annotation.Nullable
import com.github.libretube.PLAYER_NOTIFICATION_ID import com.github.libretube.PLAYER_NOTIFICATION_ID
class ClosingService : Service() { class ClosingService : Service() {
private val TAG = "ClosingService"
@Nullable @Nullable
override fun onBind(intent: Intent?): IBinder? { override fun onBind(intent: Intent?): IBinder? {

View File

@ -23,13 +23,13 @@ import com.github.libretube.DOWNLOAD_PENDING_NOTIFICATION_ID
import com.github.libretube.DOWNLOAD_SUCCESS_NOTIFICATION_ID import com.github.libretube.DOWNLOAD_SUCCESS_NOTIFICATION_ID
import com.github.libretube.Globals import com.github.libretube.Globals
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.extensions.TAG
import com.github.libretube.obj.DownloadType import com.github.libretube.obj.DownloadType
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 java.io.File import java.io.File
class DownloadService : Service() { class DownloadService : Service() {
val TAG = "DownloadService"
private lateinit var notification: NotificationCompat.Builder private lateinit var notification: NotificationCompat.Builder
@ -78,11 +78,11 @@ class DownloadService : Service() {
) )
if (!tempDir.exists()) { if (!tempDir.exists()) {
tempDir.mkdirs() tempDir.mkdirs()
Log.e(TAG, "Directory make") Log.e(TAG(), "Directory make")
} else { } else {
tempDir.deleteRecursively() tempDir.deleteRecursively()
tempDir.mkdirs() tempDir.mkdirs()
Log.e(TAG, "Directory already have") Log.e(TAG(), "Directory already have")
} }
val downloadLocationPref = PreferenceHelper.getString(PreferenceKeys.DOWNLOAD_LOCATION, "") val downloadLocationPref = PreferenceHelper.getString(PreferenceKeys.DOWNLOAD_LOCATION, "")
@ -101,7 +101,7 @@ class DownloadService : Service() {
folderName folderName
) )
if (!libretubeDir.exists()) libretubeDir.mkdirs() if (!libretubeDir.exists()) libretubeDir.mkdirs()
Log.i(TAG, libretubeDir.toString()) Log.i(TAG(), libretubeDir.toString())
// start download // start download
try { try {
@ -130,7 +130,7 @@ class DownloadService : Service() {
} }
} }
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {
Log.e(TAG, "download error $e") Log.e(TAG(), "download error $e")
downloadFailedNotification() downloadFailedNotification()
} }
} }
@ -210,7 +210,7 @@ class DownloadService : Service() {
} }
private fun downloadSucceededNotification() { private fun downloadSucceededNotification() {
Log.i(TAG, "Download succeeded") Log.i(TAG(), "Download succeeded")
val builder = NotificationCompat.Builder(this@DownloadService, DOWNLOAD_CHANNEL_ID) val builder = NotificationCompat.Builder(this@DownloadService, DOWNLOAD_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_download) .setSmallIcon(R.drawable.ic_download)
.setContentTitle(resources.getString(R.string.success)) .setContentTitle(resources.getString(R.string.success))
@ -229,7 +229,7 @@ class DownloadService : Service() {
} }
Globals.IS_DOWNLOAD_RUNNING = false Globals.IS_DOWNLOAD_RUNNING = false
Log.d(TAG, "dl finished!") Log.d(TAG(), "dl finished!")
stopForeground(true) stopForeground(true)
stopService(Intent(this@DownloadService, DownloadService::class.java)) stopService(Intent(this@DownloadService, DownloadService::class.java))
super.onDestroy() super.onDestroy()

View File

@ -14,7 +14,6 @@ import com.github.libretube.R
import java.io.File import java.io.File
class UpdateService : Service() { class UpdateService : Service() {
private val TAG = "UpdateService"
private lateinit var downloadUrl: String private lateinit var downloadUrl: String
private var downloadId: Long = -1 private var downloadId: Long = -1
private lateinit var file: File private lateinit var file: File

View File

@ -1,6 +1,7 @@
package com.github.libretube.util package com.github.libretube.util
import com.github.libretube.Globals import com.github.libretube.Globals
import com.github.libretube.api.RetrofitInstance
import com.github.libretube.obj.StreamItem import com.github.libretube.obj.StreamItem
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
@ -8,7 +9,6 @@ import kotlinx.coroutines.withContext
class AutoPlayHelper( class AutoPlayHelper(
private val playlistId: String? private val playlistId: String?
) { ) {
private val TAG = "AutoPlayHelper"
private val playlistStreamIds = mutableListOf<String>() private val playlistStreamIds = mutableListOf<String>()
private var playlistNextPage: String? = null private var playlistNextPage: String? = null

View File

@ -16,7 +16,6 @@ import java.io.ObjectOutputStream
class BackupHelper( class BackupHelper(
private val context: Context private val context: Context
) { ) {
private val TAG = this::class.java.name
/** /**
* Backup the default shared preferences to a file * Backup the default shared preferences to a file
@ -25,7 +24,8 @@ class BackupHelper(
if (uri == null) return if (uri == null) return
var output: ObjectOutputStream? = null var output: ObjectOutputStream? = null
try { try {
val fileDescriptor = context.contentResolver.openFileDescriptor(uri, "w")?.fileDescriptor val fileDescriptor =
context.contentResolver.openFileDescriptor(uri, "w")?.fileDescriptor
output = ObjectOutputStream(FileOutputStream(fileDescriptor)) output = ObjectOutputStream(FileOutputStream(fileDescriptor))
val pref: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) val pref: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
// write all preference objects to the output file // write all preference objects to the output file
@ -53,7 +53,8 @@ class BackupHelper(
if (uri == null) return if (uri == null) return
var input: ObjectInputStream? = null var input: ObjectInputStream? = null
try { try {
val fileDescriptor = context.contentResolver.openFileDescriptor(uri, "r")?.fileDescriptor val fileDescriptor =
context.contentResolver.openFileDescriptor(uri, "r")?.fileDescriptor
input = ObjectInputStream(FileInputStream(fileDescriptor)) input = ObjectInputStream(FileInputStream(fileDescriptor))
val editor = PreferenceManager.getDefaultSharedPreferences(context).edit() val editor = PreferenceManager.getDefaultSharedPreferences(context).edit()

View File

@ -6,6 +6,9 @@ import android.util.Log
import android.widget.Toast import android.widget.Toast
import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.ObjectMapper
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.RetrofitInstance
import com.github.libretube.api.SubscriptionHelper
import com.github.libretube.extensions.TAG
import com.github.libretube.obj.NewPipeSubscription import com.github.libretube.obj.NewPipeSubscription
import com.github.libretube.obj.NewPipeSubscriptions import com.github.libretube.obj.NewPipeSubscriptions
import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.preferences.PreferenceHelper
@ -20,7 +23,6 @@ import java.io.InputStreamReader
class ImportHelper( class ImportHelper(
private val activity: Activity private val activity: Activity
) { ) {
private val TAG = "ImportHelper"
/** /**
* Import subscriptions by a file uri * Import subscriptions by a file uri
@ -65,7 +67,7 @@ class ImportHelper(
Toast.makeText(activity, R.string.importsuccess, Toast.LENGTH_SHORT).show() Toast.makeText(activity, R.string.importsuccess, Toast.LENGTH_SHORT).show()
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, e.toString()) Log.e(TAG(), e.toString())
Toast.makeText( Toast.makeText(
activity, activity,
R.string.error, R.string.error,

View File

@ -14,6 +14,8 @@ import com.github.libretube.PUSH_CHANNEL_ID
import com.github.libretube.PUSH_NOTIFICATION_ID import com.github.libretube.PUSH_NOTIFICATION_ID
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.activities.MainActivity import com.github.libretube.activities.MainActivity
import com.github.libretube.api.RetrofitInstance
import com.github.libretube.api.SubscriptionHelper
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 kotlinx.coroutines.async import kotlinx.coroutines.async

View File

@ -9,7 +9,6 @@ import androidx.work.WorkerParameters
*/ */
class NotificationWorker(appContext: Context, parameters: WorkerParameters) : class NotificationWorker(appContext: Context, parameters: WorkerParameters) :
Worker(appContext, parameters) { Worker(appContext, parameters) {
private val TAG = "NotificationWorker"
override fun doWork(): Result { override fun doWork(): Result {
// check whether there are new streams and notify if there are some // check whether there are new streams and notify if there are some

View File

@ -8,8 +8,6 @@ import com.github.libretube.preferences.PreferenceKeys
import com.google.android.exoplayer2.ui.CaptionStyleCompat import com.google.android.exoplayer2.ui.CaptionStyleCompat
object PlayerHelper { object PlayerHelper {
private val TAG = "PlayerHelper"
// get the audio source following the users preferences // get the audio source following the users preferences
fun getAudioSource(audios: List<PipedStream>): String { fun getAudioSource(audios: List<PipedStream>): String {
val audioFormat = PreferenceHelper.getString(PreferenceKeys.PLAYER_AUDIO_FORMAT, "all") val audioFormat = PreferenceHelper.getString(PreferenceKeys.PLAYER_AUDIO_FORMAT, "all")

View File

@ -14,7 +14,6 @@ internal class CustomExoPlayerView(
context: Context, context: Context,
attributeSet: AttributeSet? = null attributeSet: AttributeSet? = null
) : StyledPlayerView(context, attributeSet) { ) : StyledPlayerView(context, attributeSet) {
val TAG = "CustomExoPlayerView"
val binding: ExoStyledPlayerControlViewBinding = ExoStyledPlayerControlViewBinding.bind(this) val binding: ExoStyledPlayerControlViewBinding = ExoStyledPlayerControlViewBinding.bind(this)
private var doubleTapListener: DoubleTapInterface? = null private var doubleTapListener: DoubleTapInterface? = null

View File

@ -5,7 +5,6 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import com.github.libretube.R
import com.github.libretube.databinding.BottomSheetBinding import com.github.libretube.databinding.BottomSheetBinding
import com.github.libretube.interfaces.PlayerOptionsInterface import com.github.libretube.interfaces.PlayerOptionsInterface
import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetBehavior
@ -16,8 +15,6 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment
* Bottom Sheet including all the player options * Bottom Sheet including all the player options
*/ */
class PlayerOptionsBottomSheet : BottomSheetDialogFragment() { class PlayerOptionsBottomSheet : BottomSheetDialogFragment() {
private val TAG = this::class.java.name.toString()
lateinit var binding: BottomSheetBinding lateinit var binding: BottomSheetBinding
private lateinit var playerOptionsInterface: PlayerOptionsInterface private lateinit var playerOptionsInterface: PlayerOptionsInterface

View File

@ -4,7 +4,7 @@
android:tint="?attr/colorControlNormal" android:tint="?attr/colorControlNormal"
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:pathData="M6.719,19H10.24V5H6.719ZM13.76,5v14h3.521V5Z" android:fillColor="@android:color/white"
android:fillColor="@android:color/white"/> android:pathData="M6.719,19H10.24V5H6.719ZM13.76,5v14h3.521V5Z" />
</vector> </vector>

View File

@ -51,13 +51,13 @@
<Preference <Preference
android:icon="@drawable/ic_backup" android:icon="@drawable/ic_backup"
app:title="@string/backup" app:key="backup_settings"
app:key="backup_settings" /> app:title="@string/backup" />
<Preference <Preference
android:icon="@drawable/ic_restore" android:icon="@drawable/ic_restore"
app:title="@string/restore" app:key="restore_settings"
app:key="restore_settings" /> app:title="@string/restore" />
</PreferenceCategory> </PreferenceCategory>