Merge pull request #1182 from Bnyro/master

bump dependencies
This commit is contained in:
Bnyro 2022-08-27 15:23:38 +02:00 committed by GitHub
commit b2cbae73db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 101 additions and 77 deletions

View File

@ -3,17 +3,16 @@ import java.time.Instant
plugins { plugins {
id 'com.android.application' id 'com.android.application'
id 'kotlin-android' id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt' id 'kotlin-kapt'
} }
android { android {
compileSdk 31 compileSdk 33
defaultConfig { defaultConfig {
applicationId 'com.github.libretube' applicationId 'com.github.libretube'
minSdk 21 minSdk 21
targetSdk 31 targetSdk 33
versionCode 17 versionCode 17
versionName '0.5.0' versionName '0.5.0'
multiDexEnabled true multiDexEnabled true
@ -75,8 +74,7 @@ android {
dependencies { dependencies {
//debugImplementation libs.square.leakcanary //debugImplementation libs.square.leakcanary
kapt libs.room.compiler /* Android Core */
implementation libs.androidx.appcompat implementation libs.androidx.appcompat
implementation libs.androidx.constraintlayout implementation libs.androidx.constraintlayout
implementation libs.androidx.legacySupport implementation libs.androidx.legacySupport
@ -86,30 +84,37 @@ dependencies {
implementation libs.androidx.preference implementation libs.androidx.preference
implementation libs.androidx.work.runtime implementation libs.androidx.work.runtime
/* Android Lifecycle */
implementation libs.lifecycle.viewmodel
implementation libs.lifecycle.runtime
implementation libs.lifecycle.livedata
/* Testing */
androidTestImplementation libs.androidx.test.junit androidTestImplementation libs.androidx.test.junit
androidTestImplementation libs.androidx.test.espressoCore androidTestImplementation libs.androidx.test.espressoCore
/* Design */
implementation libs.material
implementation libs.circleimageview implementation libs.circleimageview
implementation libs.material /* ExoPlayer */
implementation libs.exoplayer implementation libs.exoplayer
implementation(libs.exoplayer.extension.cronet) { exclude group: 'com.google.android.gms' } implementation(libs.exoplayer.extension.cronet) { exclude group: 'com.google.android.gms' }
implementation libs.exoplayer.extension.mediasession implementation libs.exoplayer.extension.mediasession
/* Retrofit and Jackson */
implementation libs.square.retrofit implementation libs.square.retrofit
implementation libs.square.retrofit.converterJackson implementation libs.square.retrofit.converterJackson
// Do not update jackson annotations! It does not supports < API 26.
implementation libs.jacksonAnnotations implementation libs.jacksonAnnotations
/* Cronet and Coil */
coreLibraryDesugaring libs.desugaring coreLibraryDesugaring libs.desugaring
implementation libs.cronet.embedded implementation libs.cronet.embedded
implementation libs.cronet.okhttp implementation libs.cronet.okhttp
implementation libs.coil implementation libs.coil
implementation libs.lifecycle.viewmodel /* Room */
implementation libs.lifecycle.runtime kapt libs.room.compiler
implementation libs.lifecycle.livedata
implementation libs.room implementation libs.room
} }

View File

@ -123,6 +123,7 @@ class AboutActivity : BaseActivity() {
it?.readText() it?.readText()
} }
@Suppress("DEPRECATION")
val licenseHtml = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { val licenseHtml = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Html.fromHtml(licenseString.toString(), 1) Html.fromHtml(licenseString.toString(), 1)
} else { } else {

View File

@ -205,7 +205,7 @@ class MainActivity : BaseActivity() {
/** /**
* Remove the focus of the search view in the toolbar * Remove the focus of the search view in the toolbar
*/ */
fun removeSearchFocus() { private fun removeSearchFocus() {
searchView.setQuery("", false) searchView.setQuery("", false)
searchView.clearFocus() searchView.clearFocus()
searchView.onActionViewCollapsed() searchView.onActionViewCollapsed()
@ -250,13 +250,14 @@ class MainActivity : BaseActivity() {
searchItem.setOnActionExpandListener( searchItem.setOnActionExpandListener(
object : MenuItem.OnActionExpandListener { object : MenuItem.OnActionExpandListener {
override fun onMenuItemActionExpand(p0: MenuItem?): Boolean { override fun onMenuItemActionExpand(p0: MenuItem): Boolean {
return true return true
} }
override fun onMenuItemActionCollapse(p0: MenuItem?): Boolean { override fun onMenuItemActionCollapse(p0: MenuItem): Boolean {
val currentFragmentId = navController.currentDestination?.id val currentFragmentId = navController.currentDestination?.id
if (currentFragmentId == R.id.searchFragment || currentFragmentId == R.id.searchResultFragment) { if (currentFragmentId == R.id.searchFragment || currentFragmentId == R.id.searchResultFragment) {
@Suppress("DEPRECATION")
onBackPressed() onBackPressed()
} }
return true return true
@ -443,6 +444,7 @@ class MainActivity : BaseActivity() {
} }
} }
} else if (navController.currentDestination?.id == startFragmentId) { } else if (navController.currentDestination?.id == startFragmentId) {
@Suppress("DEPRECATION")
super.onBackPressed() super.onBackPressed()
} else { } else {
navController.popBackStack() navController.popBackStack()
@ -494,7 +496,7 @@ class MainActivity : BaseActivity() {
hide(WindowInsets.Type.statusBars() or WindowInsets.Type.navigationBars()) hide(WindowInsets.Type.statusBars() or WindowInsets.Type.navigationBars())
systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
} }
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { } else {
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
window.decorView.systemUiVisibility = ( window.decorView.systemUiVisibility = (
View.SYSTEM_UI_FLAG_FULLSCREEN View.SYSTEM_UI_FLAG_FULLSCREEN
@ -528,7 +530,7 @@ class MainActivity : BaseActivity() {
show(WindowInsets.Type.statusBars() or WindowInsets.Type.navigationBars()) show(WindowInsets.Type.statusBars() or WindowInsets.Type.navigationBars())
systemBarsBehavior = WindowInsetsController.BEHAVIOR_DEFAULT systemBarsBehavior = WindowInsetsController.BEHAVIOR_DEFAULT
} }
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { } else {
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility =
(View.SYSTEM_UI_FLAG_VISIBLE or View.SYSTEM_UI_FLAG_LAYOUT_STABLE) (View.SYSTEM_UI_FLAG_VISIBLE or View.SYSTEM_UI_FLAG_LAYOUT_STABLE)
@ -554,7 +556,7 @@ class MainActivity : BaseActivity() {
/** /**
* show the status bar * show the status bar
*/ */
fun showSystemBars() { private fun showSystemBars() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.insetsController?.show(WindowInsets.Type.statusBars()) window.insetsController?.show(WindowInsets.Type.statusBars())
} else { } else {

View File

@ -31,6 +31,7 @@ class SettingsActivity : BaseActivity() {
override fun onBackPressed() { override fun onBackPressed() {
when (supportFragmentManager.findFragmentById(R.id.settings)) { when (supportFragmentManager.findFragmentById(R.id.settings)) {
is MainSettings -> { is MainSettings -> {
@Suppress("DEPRECATION")
super.onBackPressed() super.onBackPressed()
finishAndRemoveTask() finishAndRemoveTask()
} }

View File

@ -7,12 +7,12 @@ import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.databinding.VideoRowBinding import com.github.libretube.databinding.VideoRowBinding
import com.github.libretube.dialogs.VideoOptionsDialog import com.github.libretube.dialogs.VideoOptionsDialog
import com.github.libretube.extensions.formatShort
import com.github.libretube.extensions.setWatchProgressLength
import com.github.libretube.extensions.toID
import com.github.libretube.obj.StreamItem import com.github.libretube.obj.StreamItem
import com.github.libretube.util.ImageHelper import com.github.libretube.util.ImageHelper
import com.github.libretube.util.NavigationHelper import com.github.libretube.util.NavigationHelper
import com.github.libretube.util.formatShort
import com.github.libretube.util.setWatchProgressLength
import com.github.libretube.util.toID
class ChannelAdapter( class ChannelAdapter(
private val videoFeed: MutableList<StreamItem>, private val videoFeed: MutableList<StreamItem>,

View File

@ -11,11 +11,11 @@ import com.github.libretube.R
import com.github.libretube.api.RetrofitInstance 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.extensions.TAG
import com.github.libretube.extensions.formatShort
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.ImageHelper import com.github.libretube.util.ImageHelper
import com.github.libretube.util.NavigationHelper import com.github.libretube.util.NavigationHelper
import com.github.libretube.util.formatShort
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch

View File

@ -4,10 +4,10 @@ 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.databinding.LegacySubscriptionChannelBinding import com.github.libretube.databinding.LegacySubscriptionChannelBinding
import com.github.libretube.extensions.toID
import com.github.libretube.obj.Subscription import com.github.libretube.obj.Subscription
import com.github.libretube.util.ImageHelper import com.github.libretube.util.ImageHelper
import com.github.libretube.util.NavigationHelper import com.github.libretube.util.NavigationHelper
import com.github.libretube.util.toID
class LegacySubscriptionAdapter( class LegacySubscriptionAdapter(
private val subscriptions: List<Subscription> private val subscriptions: List<Subscription>

View File

@ -12,13 +12,13 @@ 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.TAG
import com.github.libretube.extensions.setFormattedDuration import com.github.libretube.extensions.setFormattedDuration
import com.github.libretube.extensions.setWatchProgressLength
import com.github.libretube.extensions.toID
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.ImageHelper import com.github.libretube.util.ImageHelper
import com.github.libretube.util.NavigationHelper import com.github.libretube.util.NavigationHelper
import com.github.libretube.util.setWatchProgressLength
import com.github.libretube.util.toID
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch

View File

@ -5,10 +5,10 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.databinding.RepliesRowBinding import com.github.libretube.databinding.RepliesRowBinding
import com.github.libretube.extensions.formatShort
import com.github.libretube.obj.Comment import com.github.libretube.obj.Comment
import com.github.libretube.util.ImageHelper import com.github.libretube.util.ImageHelper
import com.github.libretube.util.NavigationHelper import com.github.libretube.util.NavigationHelper
import com.github.libretube.util.formatShort
class RepliesAdapter( class RepliesAdapter(
private val replies: MutableList<Comment> private val replies: MutableList<Comment>

View File

@ -12,13 +12,13 @@ import com.github.libretube.databinding.PlaylistSearchRowBinding
import com.github.libretube.databinding.VideoRowBinding import com.github.libretube.databinding.VideoRowBinding
import com.github.libretube.dialogs.PlaylistOptionsDialog import com.github.libretube.dialogs.PlaylistOptionsDialog
import com.github.libretube.dialogs.VideoOptionsDialog import com.github.libretube.dialogs.VideoOptionsDialog
import com.github.libretube.extensions.formatShort
import com.github.libretube.extensions.setFormattedDuration import com.github.libretube.extensions.setFormattedDuration
import com.github.libretube.extensions.setWatchProgressLength
import com.github.libretube.extensions.toID
import com.github.libretube.obj.SearchItem import com.github.libretube.obj.SearchItem
import com.github.libretube.util.ImageHelper import com.github.libretube.util.ImageHelper
import com.github.libretube.util.NavigationHelper import com.github.libretube.util.NavigationHelper
import com.github.libretube.util.formatShort
import com.github.libretube.util.setWatchProgressLength
import com.github.libretube.util.toID
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch

View File

@ -6,10 +6,10 @@ 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.api.SubscriptionHelper
import com.github.libretube.databinding.ChannelSubscriptionRowBinding import com.github.libretube.databinding.ChannelSubscriptionRowBinding
import com.github.libretube.extensions.toID
import com.github.libretube.obj.Subscription import com.github.libretube.obj.Subscription
import com.github.libretube.util.ImageHelper import com.github.libretube.util.ImageHelper
import com.github.libretube.util.NavigationHelper import com.github.libretube.util.NavigationHelper
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>() {

View File

@ -7,13 +7,13 @@ import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.databinding.TrendingRowBinding import com.github.libretube.databinding.TrendingRowBinding
import com.github.libretube.dialogs.VideoOptionsDialog import com.github.libretube.dialogs.VideoOptionsDialog
import com.github.libretube.extensions.formatShort
import com.github.libretube.extensions.setFormattedDuration import com.github.libretube.extensions.setFormattedDuration
import com.github.libretube.extensions.setWatchProgressLength
import com.github.libretube.extensions.toID
import com.github.libretube.obj.StreamItem import com.github.libretube.obj.StreamItem
import com.github.libretube.util.ImageHelper import com.github.libretube.util.ImageHelper
import com.github.libretube.util.NavigationHelper import com.github.libretube.util.NavigationHelper
import com.github.libretube.util.formatShort
import com.github.libretube.util.setWatchProgressLength
import com.github.libretube.util.toID
class TrendingAdapter( class TrendingAdapter(
private val streamItems: List<StreamItem>, private val streamItems: List<StreamItem>,

View File

@ -9,9 +9,9 @@ import com.github.libretube.db.DatabaseHelper
import com.github.libretube.db.obj.WatchHistoryItem 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.extensions.setWatchProgressLength
import com.github.libretube.util.ImageHelper import com.github.libretube.util.ImageHelper
import com.github.libretube.util.NavigationHelper import com.github.libretube.util.NavigationHelper
import com.github.libretube.util.setWatchProgressLength
class WatchHistoryAdapter( class WatchHistoryAdapter(
private val watchHistory: MutableList<WatchHistoryItem>, private val watchHistory: MutableList<WatchHistoryItem>,

View File

@ -1,4 +1,4 @@
package com.github.libretube.util package com.github.libretube.api
import java.util.* import java.util.*
import kotlin.reflect.KProperty import kotlin.reflect.KProperty

View File

@ -1,7 +1,5 @@
package com.github.libretube.api 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

@ -3,10 +3,10 @@ package com.github.libretube.db
import com.github.libretube.db.obj.SearchHistoryItem import com.github.libretube.db.obj.SearchHistoryItem
import com.github.libretube.db.obj.WatchHistoryItem import com.github.libretube.db.obj.WatchHistoryItem
import com.github.libretube.db.obj.WatchPosition import com.github.libretube.db.obj.WatchPosition
import com.github.libretube.extensions.toID
import com.github.libretube.obj.Streams import com.github.libretube.obj.Streams
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
object DatabaseHelper { object DatabaseHelper {
fun addToWatchHistory(videoId: String, streams: Streams) { fun addToWatchHistory(videoId: String, streams: Streams) {

View File

@ -9,10 +9,10 @@ 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.api.RetrofitInstance
import com.github.libretube.extensions.TAG import com.github.libretube.extensions.TAG
import com.github.libretube.extensions.toID
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.toID
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

View File

@ -1,4 +1,4 @@
package com.github.libretube.util package com.github.libretube.extensions
import java.math.BigDecimal import java.math.BigDecimal
import java.math.RoundingMode import java.math.RoundingMode

View File

@ -1,4 +1,4 @@
package com.github.libretube.util package com.github.libretube.extensions
import android.app.Activity import android.app.Activity
import android.content.Context import android.content.Context

View File

@ -1,10 +1,9 @@
package com.github.libretube.util package com.github.libretube.extensions
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.db.DatabaseHolder import com.github.libretube.db.DatabaseHolder
import com.github.libretube.extensions.await
/** /**
* shows the already watched time under the video * shows the already watched time under the video

View File

@ -1,4 +1,4 @@
package com.github.libretube.util package com.github.libretube.extensions
/** /**
* format a Piped route to an ID * format a Piped route to an ID

View File

@ -14,9 +14,9 @@ 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.extensions.TAG
import com.github.libretube.extensions.formatShort
import com.github.libretube.extensions.toID
import com.github.libretube.util.ImageHelper import com.github.libretube.util.ImageHelper
import com.github.libretube.util.formatShort
import com.github.libretube.util.toID
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException

View File

@ -46,7 +46,7 @@ class HomeFragment : BaseFragment() {
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")
// get the system default country if auto region selected // get the system default country if auto region selected
region = if (regionPref == "sys") { region = if (regionPref == "sys") {

View File

@ -1,5 +1,6 @@
package com.github.libretube.fragments package com.github.libretube.fragments
import android.annotation.SuppressLint
import android.app.ActivityManager import android.app.ActivityManager
import android.app.PictureInPictureParams import android.app.PictureInPictureParams
import android.content.Context import android.content.Context
@ -55,7 +56,10 @@ 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.TAG
import com.github.libretube.extensions.await import com.github.libretube.extensions.await
import com.github.libretube.extensions.formatShort
import com.github.libretube.extensions.hideKeyboard
import com.github.libretube.extensions.setSliderRangeAndValue import com.github.libretube.extensions.setSliderRangeAndValue
import com.github.libretube.extensions.toID
import com.github.libretube.interfaces.DoubleTapInterface import com.github.libretube.interfaces.DoubleTapInterface
import com.github.libretube.interfaces.PlayerOptionsInterface import com.github.libretube.interfaces.PlayerOptionsInterface
import com.github.libretube.models.PlayerViewModel import com.github.libretube.models.PlayerViewModel
@ -72,9 +76,6 @@ import com.github.libretube.util.BackgroundHelper
import com.github.libretube.util.ImageHelper import com.github.libretube.util.ImageHelper
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.formatShort
import com.github.libretube.util.hideKeyboard
import com.github.libretube.util.toID
import com.github.libretube.views.PlayerOptionsBottomSheet import com.github.libretube.views.PlayerOptionsBottomSheet
import com.google.android.exoplayer2.C import com.google.android.exoplayer2.C
import com.google.android.exoplayer2.DefaultLoadControl import com.google.android.exoplayer2.DefaultLoadControl
@ -211,6 +212,7 @@ class PlayerFragment : BaseFragment() {
return binding.root return binding.root
} }
@SuppressLint("SourceLockedOrientationActivity")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
context?.hideKeyboard(view) context?.hideKeyboard(view)
@ -352,6 +354,7 @@ class PlayerFragment : BaseFragment() {
) )
} }
@SuppressLint("ClickableViewAccessibility")
private fun initializeTransitionLayout() { private fun initializeTransitionLayout() {
val mainActivity = activity as MainActivity val mainActivity = activity as MainActivity
mainActivity.binding.container.visibility = View.VISIBLE mainActivity.binding.container.visibility = View.VISIBLE
@ -408,6 +411,7 @@ class PlayerFragment : BaseFragment() {
binding.playerMotionLayout.transitionToStart() binding.playerMotionLayout.transitionToStart()
// quitting miniPlayer on single click // quitting miniPlayer on single click
binding.titleTextView.setOnTouchListener { view, motionEvent -> binding.titleTextView.setOnTouchListener { view, motionEvent ->
view.onTouchEvent(motionEvent) view.onTouchEvent(motionEvent)
if (motionEvent.action == MotionEvent.ACTION_UP) view.performClick() if (motionEvent.action == MotionEvent.ACTION_UP) view.performClick()
@ -762,6 +766,7 @@ class PlayerFragment : BaseFragment() {
viewModel.isFullscreen.value = true viewModel.isFullscreen.value = true
} }
@SuppressLint("SourceLockedOrientationActivity")
private fun unsetFullscreen() { private fun unsetFullscreen() {
// leave fullscreen mode // leave fullscreen mode
with(binding.playerMotionLayout) { with(binding.playerMotionLayout) {
@ -950,6 +955,7 @@ class PlayerFragment : BaseFragment() {
} }
} }
@SuppressLint("SetTextI18n")
private fun refreshLiveStatus() { private fun refreshLiveStatus() {
// switch back to normal speed when on the end of live stream // switch back to normal speed when on the end of live stream
if (exoPlayer.duration - exoPlayer.currentPosition < 7000) { if (exoPlayer.duration - exoPlayer.currentPosition < 7000) {
@ -1040,6 +1046,7 @@ class PlayerFragment : BaseFragment() {
refreshLiveStatus() refreshLiveStatus()
} }
@SuppressLint("SetTextI18n")
private fun initializePlayerView(response: Streams) { private fun initializePlayerView(response: Streams) {
binding.apply { binding.apply {
playerViewsInfo.text = playerViewsInfo.text =
@ -1698,7 +1705,11 @@ class PlayerFragment : BaseFragment() {
fun onUserLeaveHint() { fun onUserLeaveHint() {
if (SDK_INT >= Build.VERSION_CODES.O && shouldStartPiP()) { if (SDK_INT >= Build.VERSION_CODES.O && shouldStartPiP()) {
activity?.enterPictureInPictureMode(updatePipParams()) activity?.enterPictureInPictureMode(
PictureInPictureParams.Builder()
.setActions(emptyList())
.build()
)
} }
} }
@ -1727,10 +1738,6 @@ class PlayerFragment : BaseFragment() {
return false return false
} }
private fun updatePipParams() = PictureInPictureParams.Builder()
.setActions(emptyList())
.build()
override fun onConfigurationChanged(newConfig: Configuration) { override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig) super.onConfigurationChanged(newConfig)

View File

@ -16,7 +16,7 @@ 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.extensions.TAG import com.github.libretube.extensions.TAG
import com.github.libretube.util.toID import com.github.libretube.extensions.toID
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException

View File

@ -20,11 +20,10 @@ import com.github.libretube.extensions.BaseFragment
import com.github.libretube.extensions.TAG 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 kotlinx.android.synthetic.main.activity_main.toolbar
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
class SearchFragment() : BaseFragment() { class SearchFragment : BaseFragment() {
private lateinit var binding: FragmentSearchBinding private lateinit var binding: FragmentSearchBinding
private val viewModel: SearchViewModel by activityViewModels() private val viewModel: SearchViewModel by activityViewModels()
@ -117,7 +116,7 @@ class SearchFragment() : BaseFragment() {
if (findNavController().currentDestination?.id != R.id.searchResultFragment) { if (findNavController().currentDestination?.id != R.id.searchResultFragment) {
// remove the search focus // remove the search focus
(activity as MainActivity) (activity as MainActivity)
.toolbar.menu .binding.toolbar.menu
.findItem(R.id.action_search).collapseActionView() .findItem(R.id.action_search).collapseActionView()
} }
super.onStop() super.onStop()

View File

@ -17,10 +17,9 @@ import com.github.libretube.db.DatabaseHelper
import com.github.libretube.db.obj.SearchHistoryItem 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.TAG
import com.github.libretube.extensions.hideKeyboard
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.hideKeyboard
import kotlinx.android.synthetic.main.activity_main.toolbar
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
@ -149,7 +148,7 @@ class SearchResultFragment : BaseFragment() {
if (findNavController().currentDestination?.id != R.id.searchFragment) { if (findNavController().currentDestination?.id != R.id.searchFragment) {
// remove the search focus // remove the search focus
(activity as MainActivity) (activity as MainActivity)
.toolbar.menu .binding.toolbar.menu
.findItem(R.id.action_search).collapseActionView() .findItem(R.id.action_search).collapseActionView()
} }
super.onStop() super.onStop()

View File

@ -6,10 +6,10 @@ import androidx.lifecycle.ViewModel
import com.github.libretube.api.RetrofitInstance import com.github.libretube.api.RetrofitInstance
import com.github.libretube.api.SubscriptionHelper import com.github.libretube.api.SubscriptionHelper
import com.github.libretube.extensions.TAG import com.github.libretube.extensions.TAG
import com.github.libretube.extensions.toID
import com.github.libretube.obj.StreamItem import com.github.libretube.obj.StreamItem
import com.github.libretube.obj.Subscription import com.github.libretube.obj.Subscription
import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.util.toID
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch

View File

@ -4,6 +4,7 @@ import android.net.Uri
import android.os.Bundle import android.os.Bundle
import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.result.contract.ActivityResultContracts.CreateDocument
import androidx.preference.ListPreference import androidx.preference.ListPreference
import androidx.preference.Preference import androidx.preference.Preference
import com.github.libretube.R import com.github.libretube.R
@ -29,7 +30,7 @@ class AdvancedSettings : MaterialPreferenceFragment() {
BackupHelper(requireContext()).restoreSharedPreferences(uri) BackupHelper(requireContext()).restoreSharedPreferences(uri)
} }
createFile = registerForActivityResult( createFile = registerForActivityResult(
ActivityResultContracts.CreateDocument() CreateDocument("application/json")
) { uri: Uri? -> ) { uri: Uri? ->
BackupHelper(requireContext()).backupSharedPreferences(uri) BackupHelper(requireContext()).backupSharedPreferences(uri)
} }

View File

@ -5,6 +5,7 @@ import android.os.Bundle
import android.widget.Toast import android.widget.Toast
import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.result.contract.ActivityResultContracts.CreateDocument
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.preference.ListPreference import androidx.preference.ListPreference
@ -40,7 +41,7 @@ class InstanceSettings : MaterialPreferenceFragment() {
ImportHelper(requireActivity()).importSubscriptions(uri) ImportHelper(requireActivity()).importSubscriptions(uri)
} }
createFile = registerForActivityResult( createFile = registerForActivityResult(
ActivityResultContracts.CreateDocument() CreateDocument("application/json")
) { uri: Uri? -> ) { uri: Uri? ->
ImportHelper(requireActivity()).exportSubscriptions(uri) ImportHelper(requireActivity()).exportSubscriptions(uri)
} }

View File

@ -16,6 +16,7 @@ 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.api.RetrofitInstance
import com.github.libretube.extensions.toID
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
@ -24,7 +25,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.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
import com.google.android.exoplayer2.MediaItem import com.google.android.exoplayer2.MediaItem
@ -130,8 +130,7 @@ class BackgroundMode : Service() {
// play the audio in the background // play the audio in the background
playAudio(videoId, position) playAudio(videoId, position)
} catch (e: Exception) { } catch (e: Exception) {
stopForeground(true) onDestroy()
stopSelf()
} }
return super.onStartCommand(intent, flags, startId) return super.onStartCommand(intent, flags, startId)
} }
@ -209,6 +208,8 @@ class BackgroundMode : Service() {
Player.STATE_IDLE -> { Player.STATE_IDLE -> {
onDestroy() onDestroy()
} }
Player.STATE_BUFFERING -> {}
Player.STATE_READY -> {}
} }
} }
}) })
@ -309,7 +310,12 @@ class BackgroundMode : Service() {
override fun onDestroy() { override fun onDestroy() {
// called when the user pressed stop in the notification // called when the user pressed stop in the notification
// stop the service from being in the foreground and remove the notification // stop the service from being in the foreground and remove the notification
stopForeground(true) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
stopForeground(STOP_FOREGROUND_REMOVE)
} else {
@Suppress("DEPRECATION")
stopForeground(true)
}
// destroy the service // destroy the service
stopSelf() stopSelf()
if (this::nowPlayingNotification.isInitialized) nowPlayingNotification.destroy() if (this::nowPlayingNotification.isInitialized) nowPlayingNotification.destroy()

View File

@ -2,6 +2,7 @@ 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.api.RetrofitInstance
import com.github.libretube.extensions.toID
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

View File

@ -13,7 +13,7 @@ object LocaleHelper {
val languageName = PreferenceHelper.getString(PreferenceKeys.LANGUAGE, "sys") val languageName = PreferenceHelper.getString(PreferenceKeys.LANGUAGE, "sys")
if (languageName == "sys") { if (languageName == "sys") {
updateLocaleConf(context, Locale.getDefault()) updateLocaleConf(context, Locale.getDefault())
} else if (languageName?.contains("-") == true) { } else if (languageName.contains("-") == true) {
val languageParts = languageName.split("-") val languageParts = languageName.split("-")
val locale = Locale( val locale = Locale(
languageParts[0], languageParts[0],

View File

@ -7,6 +7,7 @@ import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
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.extensions.toID
import com.github.libretube.fragments.PlayerFragment import com.github.libretube.fragments.PlayerFragment
object NavigationHelper { object NavigationHelper {

View File

@ -17,6 +17,7 @@ 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.RetrofitInstance
import com.github.libretube.api.SubscriptionHelper import com.github.libretube.api.SubscriptionHelper
import com.github.libretube.extensions.toID
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

@ -26,6 +26,6 @@ class CustomSwipeToRefresh(context: Context?, attrs: AttributeSet?) :
} }
init { init {
mTouchSlop = ViewConfiguration.get(context).scaledTouchSlop mTouchSlop = ViewConfiguration.get(this.context).scaledTouchSlop
} }
} }

View File

@ -1,5 +1,6 @@
package com.github.libretube.views package com.github.libretube.views
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.graphics.Rect import android.graphics.Rect
import android.util.AttributeSet import android.util.AttributeSet
@ -89,13 +90,14 @@ class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeS
private val gestureDetector = GestureDetector( private val gestureDetector = GestureDetector(
context, context,
object : GestureDetector.SimpleOnGestureListener() { object : GestureDetector.SimpleOnGestureListener() {
override fun onSingleTapConfirmed(e: MotionEvent?): Boolean { override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
transitionToEnd() transitionToEnd()
return false return false
} }
} }
) )
@SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(event: MotionEvent): Boolean { override fun onTouchEvent(event: MotionEvent): Boolean {
// gestureDetector.onTouchEvent(event) // gestureDetector.onTouchEvent(event)
when (event.actionMasked) { when (event.actionMasked) {

View File

@ -2,5 +2,6 @@
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" /> <background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" /> <foreground android:drawable="@mipmap/ic_launcher_foreground" />
<!--suppress AndroidElementNotAllowed -->
<monochrome android:drawable="@drawable/ic_launcher_monochrome" /> <monochrome android:drawable="@drawable/ic_launcher_monochrome" />
</adaptive-icon> </adaptive-icon>

View File

@ -2,5 +2,6 @@
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" /> <background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" /> <foreground android:drawable="@mipmap/ic_launcher_foreground" />
<!--suppress AndroidElementNotAllowed -->
<monochrome android:drawable="@drawable/ic_launcher_monochrome" /> <monochrome android:drawable="@drawable/ic_launcher_monochrome" />
</adaptive-icon> </adaptive-icon>

View File

@ -1,9 +1,9 @@
[versions] [versions]
appcompat = "1.4.1" appcompat = "1.5.0"
lifecycle = "2.5.1" lifecycle = "2.5.1"
constraintlayout = "2.1.3" constraintlayout = "2.1.4"
material = "1.6.0" material = "1.6.0"
navigation = "2.4.2" navigation = "2.5.1"
legacySupport = "1.0.0" legacySupport = "1.0.0"
preference = "1.2.0" preference = "1.2.0"
extJunit = "1.1.3" extJunit = "1.1.3"
@ -14,11 +14,10 @@ exoplayer = "2.17.1"
multidex = "2.0.1" multidex = "2.0.1"
retrofit = "2.9.0" retrofit = "2.9.0"
jacksonAnnotations = "2.13.3" jacksonAnnotations = "2.13.3"
mobileffmpeg = "4.5.1.LTS"
desugaring = "1.1.5" desugaring = "1.1.5"
cronetEmbedded = "101.4951.41" cronetEmbedded = "101.4951.41"
cronetOkHttp = "0.1.0" cronetOkHttp = "0.1.0"
coil = "2.1.0" coil = "2.2.0"
leakcanary = "2.8.1" leakcanary = "2.8.1"
room = "2.4.3" room = "2.4.3"
@ -40,7 +39,6 @@ androidx-multidex = { group = "androidx.multidex", name = "multidex", version.re
square-retrofit = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" } square-retrofit = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" }
square-retrofit-converterJackson = { group = "com.squareup.retrofit2", name = "converter-jackson", version.ref = "retrofit" } square-retrofit-converterJackson = { group = "com.squareup.retrofit2", name = "converter-jackson", version.ref = "retrofit" }
jacksonAnnotations = { group = "com.fasterxml.jackson.core", name = "jackson-annotations", version.ref = "jacksonAnnotations" } jacksonAnnotations = { group = "com.fasterxml.jackson.core", name = "jackson-annotations", version.ref = "jacksonAnnotations" }
mobileffmpeg = { group = "com.arthenica", name = "ffmpeg-kit-min", version.ref = "mobileffmpeg" }
desugaring = { group = "com.android.tools", name = "desugar_jdk_libs", version.ref = "desugaring" } desugaring = { group = "com.android.tools", name = "desugar_jdk_libs", version.ref = "desugaring" }
exoplayer-extension-cronet = { group = "com.google.android.exoplayer", name = "extension-cronet", version.ref = "exoplayer" } exoplayer-extension-cronet = { group = "com.google.android.exoplayer", name = "extension-cronet", version.ref = "exoplayer" }
cronet-embedded = { group = "org.chromium.net", name = "cronet-embedded", version.ref = "cronetEmbedded" } cronet-embedded = { group = "org.chromium.net", name = "cronet-embedded", version.ref = "cronetEmbedded" }