mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
commit
b2cbae73db
@ -3,17 +3,16 @@ import java.time.Instant
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'kotlin-android'
|
||||
id 'kotlin-android-extensions'
|
||||
id 'kotlin-kapt'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk 31
|
||||
compileSdk 33
|
||||
|
||||
defaultConfig {
|
||||
applicationId 'com.github.libretube'
|
||||
minSdk 21
|
||||
targetSdk 31
|
||||
targetSdk 33
|
||||
versionCode 17
|
||||
versionName '0.5.0'
|
||||
multiDexEnabled true
|
||||
@ -75,8 +74,7 @@ android {
|
||||
dependencies {
|
||||
//debugImplementation libs.square.leakcanary
|
||||
|
||||
kapt libs.room.compiler
|
||||
|
||||
/* Android Core */
|
||||
implementation libs.androidx.appcompat
|
||||
implementation libs.androidx.constraintlayout
|
||||
implementation libs.androidx.legacySupport
|
||||
@ -86,30 +84,37 @@ dependencies {
|
||||
implementation libs.androidx.preference
|
||||
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.espressoCore
|
||||
|
||||
/* Design */
|
||||
implementation libs.material
|
||||
implementation libs.circleimageview
|
||||
|
||||
implementation libs.material
|
||||
/* ExoPlayer */
|
||||
implementation libs.exoplayer
|
||||
implementation(libs.exoplayer.extension.cronet) { exclude group: 'com.google.android.gms' }
|
||||
implementation libs.exoplayer.extension.mediasession
|
||||
|
||||
/* Retrofit and Jackson */
|
||||
implementation libs.square.retrofit
|
||||
implementation libs.square.retrofit.converterJackson
|
||||
// Do not update jackson annotations! It does not supports < API 26.
|
||||
implementation libs.jacksonAnnotations
|
||||
|
||||
/* Cronet and Coil */
|
||||
coreLibraryDesugaring libs.desugaring
|
||||
implementation libs.cronet.embedded
|
||||
implementation libs.cronet.okhttp
|
||||
implementation libs.coil
|
||||
|
||||
implementation libs.lifecycle.viewmodel
|
||||
implementation libs.lifecycle.runtime
|
||||
implementation libs.lifecycle.livedata
|
||||
|
||||
/* Room */
|
||||
kapt libs.room.compiler
|
||||
implementation libs.room
|
||||
}
|
||||
|
||||
|
@ -123,6 +123,7 @@ class AboutActivity : BaseActivity() {
|
||||
it?.readText()
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
val licenseHtml = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
Html.fromHtml(licenseString.toString(), 1)
|
||||
} else {
|
||||
|
@ -205,7 +205,7 @@ class MainActivity : BaseActivity() {
|
||||
/**
|
||||
* Remove the focus of the search view in the toolbar
|
||||
*/
|
||||
fun removeSearchFocus() {
|
||||
private fun removeSearchFocus() {
|
||||
searchView.setQuery("", false)
|
||||
searchView.clearFocus()
|
||||
searchView.onActionViewCollapsed()
|
||||
@ -250,13 +250,14 @@ class MainActivity : BaseActivity() {
|
||||
|
||||
searchItem.setOnActionExpandListener(
|
||||
object : MenuItem.OnActionExpandListener {
|
||||
override fun onMenuItemActionExpand(p0: MenuItem?): Boolean {
|
||||
override fun onMenuItemActionExpand(p0: MenuItem): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onMenuItemActionCollapse(p0: MenuItem?): Boolean {
|
||||
override fun onMenuItemActionCollapse(p0: MenuItem): Boolean {
|
||||
val currentFragmentId = navController.currentDestination?.id
|
||||
if (currentFragmentId == R.id.searchFragment || currentFragmentId == R.id.searchResultFragment) {
|
||||
@Suppress("DEPRECATION")
|
||||
onBackPressed()
|
||||
}
|
||||
return true
|
||||
@ -443,6 +444,7 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
} else if (navController.currentDestination?.id == startFragmentId) {
|
||||
@Suppress("DEPRECATION")
|
||||
super.onBackPressed()
|
||||
} else {
|
||||
navController.popBackStack()
|
||||
@ -494,7 +496,7 @@ class MainActivity : BaseActivity() {
|
||||
hide(WindowInsets.Type.statusBars() or WindowInsets.Type.navigationBars())
|
||||
systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||
}
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
window.decorView.systemUiVisibility = (
|
||||
View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
@ -528,7 +530,7 @@ class MainActivity : BaseActivity() {
|
||||
show(WindowInsets.Type.statusBars() or WindowInsets.Type.navigationBars())
|
||||
systemBarsBehavior = WindowInsetsController.BEHAVIOR_DEFAULT
|
||||
}
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
window.decorView.systemUiVisibility =
|
||||
(View.SYSTEM_UI_FLAG_VISIBLE or View.SYSTEM_UI_FLAG_LAYOUT_STABLE)
|
||||
@ -554,7 +556,7 @@ class MainActivity : BaseActivity() {
|
||||
/**
|
||||
* show the status bar
|
||||
*/
|
||||
fun showSystemBars() {
|
||||
private fun showSystemBars() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
window.insetsController?.show(WindowInsets.Type.statusBars())
|
||||
} else {
|
||||
|
@ -31,6 +31,7 @@ class SettingsActivity : BaseActivity() {
|
||||
override fun onBackPressed() {
|
||||
when (supportFragmentManager.findFragmentById(R.id.settings)) {
|
||||
is MainSettings -> {
|
||||
@Suppress("DEPRECATION")
|
||||
super.onBackPressed()
|
||||
finishAndRemoveTask()
|
||||
}
|
||||
|
@ -7,12 +7,12 @@ import androidx.fragment.app.FragmentManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.libretube.databinding.VideoRowBinding
|
||||
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.util.ImageHelper
|
||||
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(
|
||||
private val videoFeed: MutableList<StreamItem>,
|
||||
|
@ -11,11 +11,11 @@ import com.github.libretube.R
|
||||
import com.github.libretube.api.RetrofitInstance
|
||||
import com.github.libretube.databinding.CommentsRowBinding
|
||||
import com.github.libretube.extensions.TAG
|
||||
import com.github.libretube.extensions.formatShort
|
||||
import com.github.libretube.obj.Comment
|
||||
import com.github.libretube.obj.CommentsPage
|
||||
import com.github.libretube.util.ImageHelper
|
||||
import com.github.libretube.util.NavigationHelper
|
||||
import com.github.libretube.util.formatShort
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -4,10 +4,10 @@ import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.libretube.databinding.LegacySubscriptionChannelBinding
|
||||
import com.github.libretube.extensions.toID
|
||||
import com.github.libretube.obj.Subscription
|
||||
import com.github.libretube.util.ImageHelper
|
||||
import com.github.libretube.util.NavigationHelper
|
||||
import com.github.libretube.util.toID
|
||||
|
||||
class LegacySubscriptionAdapter(
|
||||
private val subscriptions: List<Subscription>
|
||||
|
@ -12,13 +12,13 @@ import com.github.libretube.databinding.PlaylistRowBinding
|
||||
import com.github.libretube.dialogs.VideoOptionsDialog
|
||||
import com.github.libretube.extensions.TAG
|
||||
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.StreamItem
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
import com.github.libretube.util.ImageHelper
|
||||
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.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -5,10 +5,10 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.libretube.databinding.RepliesRowBinding
|
||||
import com.github.libretube.extensions.formatShort
|
||||
import com.github.libretube.obj.Comment
|
||||
import com.github.libretube.util.ImageHelper
|
||||
import com.github.libretube.util.NavigationHelper
|
||||
import com.github.libretube.util.formatShort
|
||||
|
||||
class RepliesAdapter(
|
||||
private val replies: MutableList<Comment>
|
||||
|
@ -12,13 +12,13 @@ import com.github.libretube.databinding.PlaylistSearchRowBinding
|
||||
import com.github.libretube.databinding.VideoRowBinding
|
||||
import com.github.libretube.dialogs.PlaylistOptionsDialog
|
||||
import com.github.libretube.dialogs.VideoOptionsDialog
|
||||
import com.github.libretube.extensions.formatShort
|
||||
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.util.ImageHelper
|
||||
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.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -6,10 +6,10 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.api.SubscriptionHelper
|
||||
import com.github.libretube.databinding.ChannelSubscriptionRowBinding
|
||||
import com.github.libretube.extensions.toID
|
||||
import com.github.libretube.obj.Subscription
|
||||
import com.github.libretube.util.ImageHelper
|
||||
import com.github.libretube.util.NavigationHelper
|
||||
import com.github.libretube.util.toID
|
||||
|
||||
class SubscriptionChannelAdapter(private val subscriptions: MutableList<Subscription>) :
|
||||
RecyclerView.Adapter<SubscriptionChannelViewHolder>() {
|
||||
|
@ -7,13 +7,13 @@ import androidx.fragment.app.FragmentManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.libretube.databinding.TrendingRowBinding
|
||||
import com.github.libretube.dialogs.VideoOptionsDialog
|
||||
import com.github.libretube.extensions.formatShort
|
||||
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.util.ImageHelper
|
||||
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(
|
||||
private val streamItems: List<StreamItem>,
|
||||
|
@ -9,9 +9,9 @@ import com.github.libretube.db.DatabaseHelper
|
||||
import com.github.libretube.db.obj.WatchHistoryItem
|
||||
import com.github.libretube.dialogs.VideoOptionsDialog
|
||||
import com.github.libretube.extensions.setFormattedDuration
|
||||
import com.github.libretube.extensions.setWatchProgressLength
|
||||
import com.github.libretube.util.ImageHelper
|
||||
import com.github.libretube.util.NavigationHelper
|
||||
import com.github.libretube.util.setWatchProgressLength
|
||||
|
||||
class WatchHistoryAdapter(
|
||||
private val watchHistory: MutableList<WatchHistoryItem>,
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.github.libretube.util
|
||||
package com.github.libretube.api
|
||||
|
||||
import java.util.*
|
||||
import kotlin.reflect.KProperty
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.github.libretube.api
|
||||
|
||||
import com.github.libretube.util.resettableLazy
|
||||
import com.github.libretube.util.resettableManager
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.converter.jackson.JacksonConverterFactory
|
||||
|
||||
|
@ -3,10 +3,10 @@ package com.github.libretube.db
|
||||
import com.github.libretube.db.obj.SearchHistoryItem
|
||||
import com.github.libretube.db.obj.WatchHistoryItem
|
||||
import com.github.libretube.db.obj.WatchPosition
|
||||
import com.github.libretube.extensions.toID
|
||||
import com.github.libretube.obj.Streams
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
import com.github.libretube.preferences.PreferenceKeys
|
||||
import com.github.libretube.util.toID
|
||||
|
||||
object DatabaseHelper {
|
||||
fun addToWatchHistory(videoId: String, streams: Streams) {
|
||||
|
@ -9,10 +9,10 @@ import androidx.fragment.app.DialogFragment
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.api.RetrofitInstance
|
||||
import com.github.libretube.extensions.TAG
|
||||
import com.github.libretube.extensions.toID
|
||||
import com.github.libretube.obj.PlaylistId
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
import com.github.libretube.util.BackgroundHelper
|
||||
import com.github.libretube.util.toID
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.github.libretube.util
|
||||
package com.github.libretube.extensions
|
||||
|
||||
import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.github.libretube.util
|
||||
package com.github.libretube.extensions
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
|
@ -1,10 +1,9 @@
|
||||
package com.github.libretube.util
|
||||
package com.github.libretube.extensions
|
||||
|
||||
import android.view.View
|
||||
import android.view.ViewTreeObserver
|
||||
import android.widget.LinearLayout
|
||||
import com.github.libretube.db.DatabaseHolder
|
||||
import com.github.libretube.extensions.await
|
||||
|
||||
/**
|
||||
* shows the already watched time under the video
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.github.libretube.util
|
||||
package com.github.libretube.extensions
|
||||
|
||||
/**
|
||||
* format a Piped route to an ID
|
||||
|
@ -14,9 +14,9 @@ import com.github.libretube.api.SubscriptionHelper
|
||||
import com.github.libretube.databinding.FragmentChannelBinding
|
||||
import com.github.libretube.extensions.BaseFragment
|
||||
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.formatShort
|
||||
import com.github.libretube.util.toID
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
|
||||
|
@ -46,7 +46,7 @@ class HomeFragment : BaseFragment() {
|
||||
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
|
||||
region = if (regionPref == "sys") {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.github.libretube.fragments
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.ActivityManager
|
||||
import android.app.PictureInPictureParams
|
||||
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.TAG
|
||||
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.toID
|
||||
import com.github.libretube.interfaces.DoubleTapInterface
|
||||
import com.github.libretube.interfaces.PlayerOptionsInterface
|
||||
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.NowPlayingNotification
|
||||
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.google.android.exoplayer2.C
|
||||
import com.google.android.exoplayer2.DefaultLoadControl
|
||||
@ -211,6 +212,7 @@ class PlayerFragment : BaseFragment() {
|
||||
return binding.root
|
||||
}
|
||||
|
||||
@SuppressLint("SourceLockedOrientationActivity")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
context?.hideKeyboard(view)
|
||||
@ -352,6 +354,7 @@ class PlayerFragment : BaseFragment() {
|
||||
)
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private fun initializeTransitionLayout() {
|
||||
val mainActivity = activity as MainActivity
|
||||
mainActivity.binding.container.visibility = View.VISIBLE
|
||||
@ -408,6 +411,7 @@ class PlayerFragment : BaseFragment() {
|
||||
binding.playerMotionLayout.transitionToStart()
|
||||
|
||||
// quitting miniPlayer on single click
|
||||
|
||||
binding.titleTextView.setOnTouchListener { view, motionEvent ->
|
||||
view.onTouchEvent(motionEvent)
|
||||
if (motionEvent.action == MotionEvent.ACTION_UP) view.performClick()
|
||||
@ -762,6 +766,7 @@ class PlayerFragment : BaseFragment() {
|
||||
viewModel.isFullscreen.value = true
|
||||
}
|
||||
|
||||
@SuppressLint("SourceLockedOrientationActivity")
|
||||
private fun unsetFullscreen() {
|
||||
// leave fullscreen mode
|
||||
with(binding.playerMotionLayout) {
|
||||
@ -950,6 +955,7 @@ class PlayerFragment : BaseFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun refreshLiveStatus() {
|
||||
// switch back to normal speed when on the end of live stream
|
||||
if (exoPlayer.duration - exoPlayer.currentPosition < 7000) {
|
||||
@ -1040,6 +1046,7 @@ class PlayerFragment : BaseFragment() {
|
||||
refreshLiveStatus()
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun initializePlayerView(response: Streams) {
|
||||
binding.apply {
|
||||
playerViewsInfo.text =
|
||||
@ -1698,7 +1705,11 @@ class PlayerFragment : BaseFragment() {
|
||||
|
||||
fun onUserLeaveHint() {
|
||||
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
|
||||
}
|
||||
|
||||
private fun updatePipParams() = PictureInPictureParams.Builder()
|
||||
.setActions(emptyList())
|
||||
.build()
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
|
||||
|
@ -16,7 +16,7 @@ import com.github.libretube.databinding.FragmentPlaylistBinding
|
||||
import com.github.libretube.dialogs.PlaylistOptionsDialog
|
||||
import com.github.libretube.extensions.BaseFragment
|
||||
import com.github.libretube.extensions.TAG
|
||||
import com.github.libretube.util.toID
|
||||
import com.github.libretube.extensions.toID
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
|
||||
|
@ -20,11 +20,10 @@ import com.github.libretube.extensions.BaseFragment
|
||||
import com.github.libretube.extensions.TAG
|
||||
import com.github.libretube.extensions.await
|
||||
import com.github.libretube.models.SearchViewModel
|
||||
import kotlinx.android.synthetic.main.activity_main.toolbar
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
|
||||
class SearchFragment() : BaseFragment() {
|
||||
class SearchFragment : BaseFragment() {
|
||||
private lateinit var binding: FragmentSearchBinding
|
||||
private val viewModel: SearchViewModel by activityViewModels()
|
||||
|
||||
@ -117,7 +116,7 @@ class SearchFragment() : BaseFragment() {
|
||||
if (findNavController().currentDestination?.id != R.id.searchResultFragment) {
|
||||
// remove the search focus
|
||||
(activity as MainActivity)
|
||||
.toolbar.menu
|
||||
.binding.toolbar.menu
|
||||
.findItem(R.id.action_search).collapseActionView()
|
||||
}
|
||||
super.onStop()
|
||||
|
@ -17,10 +17,9 @@ import com.github.libretube.db.DatabaseHelper
|
||||
import com.github.libretube.db.obj.SearchHistoryItem
|
||||
import com.github.libretube.extensions.BaseFragment
|
||||
import com.github.libretube.extensions.TAG
|
||||
import com.github.libretube.extensions.hideKeyboard
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
import com.github.libretube.preferences.PreferenceKeys
|
||||
import com.github.libretube.util.hideKeyboard
|
||||
import kotlinx.android.synthetic.main.activity_main.toolbar
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
|
||||
@ -149,7 +148,7 @@ class SearchResultFragment : BaseFragment() {
|
||||
if (findNavController().currentDestination?.id != R.id.searchFragment) {
|
||||
// remove the search focus
|
||||
(activity as MainActivity)
|
||||
.toolbar.menu
|
||||
.binding.toolbar.menu
|
||||
.findItem(R.id.action_search).collapseActionView()
|
||||
}
|
||||
super.onStop()
|
||||
|
@ -6,10 +6,10 @@ import androidx.lifecycle.ViewModel
|
||||
import com.github.libretube.api.RetrofitInstance
|
||||
import com.github.libretube.api.SubscriptionHelper
|
||||
import com.github.libretube.extensions.TAG
|
||||
import com.github.libretube.extensions.toID
|
||||
import com.github.libretube.obj.StreamItem
|
||||
import com.github.libretube.obj.Subscription
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
import com.github.libretube.util.toID
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -4,6 +4,7 @@ import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.activity.result.contract.ActivityResultContracts.CreateDocument
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.Preference
|
||||
import com.github.libretube.R
|
||||
@ -29,7 +30,7 @@ class AdvancedSettings : MaterialPreferenceFragment() {
|
||||
BackupHelper(requireContext()).restoreSharedPreferences(uri)
|
||||
}
|
||||
createFile = registerForActivityResult(
|
||||
ActivityResultContracts.CreateDocument()
|
||||
CreateDocument("application/json")
|
||||
) { uri: Uri? ->
|
||||
BackupHelper(requireContext()).backupSharedPreferences(uri)
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.activity.result.contract.ActivityResultContracts.CreateDocument
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.preference.ListPreference
|
||||
@ -40,7 +41,7 @@ class InstanceSettings : MaterialPreferenceFragment() {
|
||||
ImportHelper(requireActivity()).importSubscriptions(uri)
|
||||
}
|
||||
createFile = registerForActivityResult(
|
||||
ActivityResultContracts.CreateDocument()
|
||||
CreateDocument("application/json")
|
||||
) { uri: Uri? ->
|
||||
ImportHelper(requireActivity()).exportSubscriptions(uri)
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import com.github.libretube.Globals
|
||||
import com.github.libretube.PLAYER_NOTIFICATION_ID
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.api.RetrofitInstance
|
||||
import com.github.libretube.extensions.toID
|
||||
import com.github.libretube.obj.Segment
|
||||
import com.github.libretube.obj.Segments
|
||||
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.NowPlayingNotification
|
||||
import com.github.libretube.util.PlayerHelper
|
||||
import com.github.libretube.util.toID
|
||||
import com.google.android.exoplayer2.C
|
||||
import com.google.android.exoplayer2.ExoPlayer
|
||||
import com.google.android.exoplayer2.MediaItem
|
||||
@ -130,8 +130,7 @@ class BackgroundMode : Service() {
|
||||
// play the audio in the background
|
||||
playAudio(videoId, position)
|
||||
} catch (e: Exception) {
|
||||
stopForeground(true)
|
||||
stopSelf()
|
||||
onDestroy()
|
||||
}
|
||||
return super.onStartCommand(intent, flags, startId)
|
||||
}
|
||||
@ -209,6 +208,8 @@ class BackgroundMode : Service() {
|
||||
Player.STATE_IDLE -> {
|
||||
onDestroy()
|
||||
}
|
||||
Player.STATE_BUFFERING -> {}
|
||||
Player.STATE_READY -> {}
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -309,7 +310,12 @@ class BackgroundMode : Service() {
|
||||
override fun onDestroy() {
|
||||
// called when the user pressed stop in the notification
|
||||
// stop the service from being in the foreground and remove the notification
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
stopForeground(STOP_FOREGROUND_REMOVE)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
stopForeground(true)
|
||||
}
|
||||
// destroy the service
|
||||
stopSelf()
|
||||
if (this::nowPlayingNotification.isInitialized) nowPlayingNotification.destroy()
|
||||
|
@ -2,6 +2,7 @@ package com.github.libretube.util
|
||||
|
||||
import com.github.libretube.Globals
|
||||
import com.github.libretube.api.RetrofitInstance
|
||||
import com.github.libretube.extensions.toID
|
||||
import com.github.libretube.obj.StreamItem
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
@ -13,7 +13,7 @@ object LocaleHelper {
|
||||
val languageName = PreferenceHelper.getString(PreferenceKeys.LANGUAGE, "sys")
|
||||
if (languageName == "sys") {
|
||||
updateLocaleConf(context, Locale.getDefault())
|
||||
} else if (languageName?.contains("-") == true) {
|
||||
} else if (languageName.contains("-") == true) {
|
||||
val languageParts = languageName.split("-")
|
||||
val locale = Locale(
|
||||
languageParts[0],
|
||||
|
@ -7,6 +7,7 @@ import androidx.constraintlayout.motion.widget.MotionLayout
|
||||
import androidx.core.os.bundleOf
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.activities.MainActivity
|
||||
import com.github.libretube.extensions.toID
|
||||
import com.github.libretube.fragments.PlayerFragment
|
||||
|
||||
object NavigationHelper {
|
||||
|
@ -17,6 +17,7 @@ import com.github.libretube.R
|
||||
import com.github.libretube.activities.MainActivity
|
||||
import com.github.libretube.api.RetrofitInstance
|
||||
import com.github.libretube.api.SubscriptionHelper
|
||||
import com.github.libretube.extensions.toID
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
import com.github.libretube.preferences.PreferenceKeys
|
||||
import kotlinx.coroutines.async
|
||||
|
@ -26,6 +26,6 @@ class CustomSwipeToRefresh(context: Context?, attrs: AttributeSet?) :
|
||||
}
|
||||
|
||||
init {
|
||||
mTouchSlop = ViewConfiguration.get(context).scaledTouchSlop
|
||||
mTouchSlop = ViewConfiguration.get(this.context).scaledTouchSlop
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.github.libretube.views
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.Rect
|
||||
import android.util.AttributeSet
|
||||
@ -89,13 +90,14 @@ class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeS
|
||||
private val gestureDetector = GestureDetector(
|
||||
context,
|
||||
object : GestureDetector.SimpleOnGestureListener() {
|
||||
override fun onSingleTapConfirmed(e: MotionEvent?): Boolean {
|
||||
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
|
||||
transitionToEnd()
|
||||
return false
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
// gestureDetector.onTouchEvent(event)
|
||||
when (event.actionMasked) {
|
||||
|
@ -2,5 +2,6 @@
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background" />
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
|
||||
<!--suppress AndroidElementNotAllowed -->
|
||||
<monochrome android:drawable="@drawable/ic_launcher_monochrome" />
|
||||
</adaptive-icon>
|
@ -2,5 +2,6 @@
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background" />
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
|
||||
<!--suppress AndroidElementNotAllowed -->
|
||||
<monochrome android:drawable="@drawable/ic_launcher_monochrome" />
|
||||
</adaptive-icon>
|
@ -1,9 +1,9 @@
|
||||
[versions]
|
||||
appcompat = "1.4.1"
|
||||
appcompat = "1.5.0"
|
||||
lifecycle = "2.5.1"
|
||||
constraintlayout = "2.1.3"
|
||||
constraintlayout = "2.1.4"
|
||||
material = "1.6.0"
|
||||
navigation = "2.4.2"
|
||||
navigation = "2.5.1"
|
||||
legacySupport = "1.0.0"
|
||||
preference = "1.2.0"
|
||||
extJunit = "1.1.3"
|
||||
@ -14,11 +14,10 @@ exoplayer = "2.17.1"
|
||||
multidex = "2.0.1"
|
||||
retrofit = "2.9.0"
|
||||
jacksonAnnotations = "2.13.3"
|
||||
mobileffmpeg = "4.5.1.LTS"
|
||||
desugaring = "1.1.5"
|
||||
cronetEmbedded = "101.4951.41"
|
||||
cronetOkHttp = "0.1.0"
|
||||
coil = "2.1.0"
|
||||
coil = "2.2.0"
|
||||
leakcanary = "2.8.1"
|
||||
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-converterJackson = { group = "com.squareup.retrofit2", name = "converter-jackson", version.ref = "retrofit" }
|
||||
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" }
|
||||
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" }
|
||||
|
Loading…
Reference in New Issue
Block a user