diff --git a/app/build.gradle b/app/build.gradle index 200ed3e41..9a5e1cc8e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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 } diff --git a/app/src/main/java/com/github/libretube/activities/AboutActivity.kt b/app/src/main/java/com/github/libretube/activities/AboutActivity.kt index e02a1edd7..f2e7a514d 100644 --- a/app/src/main/java/com/github/libretube/activities/AboutActivity.kt +++ b/app/src/main/java/com/github/libretube/activities/AboutActivity.kt @@ -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 { diff --git a/app/src/main/java/com/github/libretube/activities/MainActivity.kt b/app/src/main/java/com/github/libretube/activities/MainActivity.kt index b6daa86c9..266822d7b 100644 --- a/app/src/main/java/com/github/libretube/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/activities/MainActivity.kt @@ -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 { diff --git a/app/src/main/java/com/github/libretube/activities/SettingsActivity.kt b/app/src/main/java/com/github/libretube/activities/SettingsActivity.kt index 184c69e06..b081d9c4f 100644 --- a/app/src/main/java/com/github/libretube/activities/SettingsActivity.kt +++ b/app/src/main/java/com/github/libretube/activities/SettingsActivity.kt @@ -31,6 +31,7 @@ class SettingsActivity : BaseActivity() { override fun onBackPressed() { when (supportFragmentManager.findFragmentById(R.id.settings)) { is MainSettings -> { + @Suppress("DEPRECATION") super.onBackPressed() finishAndRemoveTask() } diff --git a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt index 9fdc4893c..ac781fbb3 100644 --- a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt @@ -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, diff --git a/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt b/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt index 44e03ba82..4f40dc1f8 100644 --- a/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt @@ -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 diff --git a/app/src/main/java/com/github/libretube/adapters/LegacySubscriptionAdapter.kt b/app/src/main/java/com/github/libretube/adapters/LegacySubscriptionAdapter.kt index b76b76c36..677c8f742 100644 --- a/app/src/main/java/com/github/libretube/adapters/LegacySubscriptionAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/LegacySubscriptionAdapter.kt @@ -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 diff --git a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt index 2874843c2..7127d1e81 100644 --- a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt @@ -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 diff --git a/app/src/main/java/com/github/libretube/adapters/RepliesAdapter.kt b/app/src/main/java/com/github/libretube/adapters/RepliesAdapter.kt index e4a31b4af..3339d25dd 100644 --- a/app/src/main/java/com/github/libretube/adapters/RepliesAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/RepliesAdapter.kt @@ -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 diff --git a/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt index 174889726..5abacf141 100644 --- a/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt @@ -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 diff --git a/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt index 1357b25dd..ad1145412 100644 --- a/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt @@ -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) : RecyclerView.Adapter() { diff --git a/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt b/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt index 238d04c82..322a8ca1d 100644 --- a/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt @@ -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, diff --git a/app/src/main/java/com/github/libretube/adapters/WatchHistoryAdapter.kt b/app/src/main/java/com/github/libretube/adapters/WatchHistoryAdapter.kt index 07fd2a0fe..15751aa2a 100644 --- a/app/src/main/java/com/github/libretube/adapters/WatchHistoryAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/WatchHistoryAdapter.kt @@ -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, diff --git a/app/src/main/java/com/github/libretube/api/ResettableLazy.kt b/app/src/main/java/com/github/libretube/api/ResettableLazy.kt index 129e27de6..01b479fca 100644 --- a/app/src/main/java/com/github/libretube/api/ResettableLazy.kt +++ b/app/src/main/java/com/github/libretube/api/ResettableLazy.kt @@ -1,4 +1,4 @@ -package com.github.libretube.util +package com.github.libretube.api import java.util.* import kotlin.reflect.KProperty diff --git a/app/src/main/java/com/github/libretube/api/RetrofitInstance.kt b/app/src/main/java/com/github/libretube/api/RetrofitInstance.kt index 012051636..350accbab 100644 --- a/app/src/main/java/com/github/libretube/api/RetrofitInstance.kt +++ b/app/src/main/java/com/github/libretube/api/RetrofitInstance.kt @@ -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 diff --git a/app/src/main/java/com/github/libretube/db/DatabaseHelper.kt b/app/src/main/java/com/github/libretube/db/DatabaseHelper.kt index 0c162dc3a..664def33d 100644 --- a/app/src/main/java/com/github/libretube/db/DatabaseHelper.kt +++ b/app/src/main/java/com/github/libretube/db/DatabaseHelper.kt @@ -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) { diff --git a/app/src/main/java/com/github/libretube/dialogs/PlaylistOptionsDialog.kt b/app/src/main/java/com/github/libretube/dialogs/PlaylistOptionsDialog.kt index 644f064ea..dcc8557af 100644 --- a/app/src/main/java/com/github/libretube/dialogs/PlaylistOptionsDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/PlaylistOptionsDialog.kt @@ -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 diff --git a/app/src/main/java/com/github/libretube/extensions/FormatShort.kt b/app/src/main/java/com/github/libretube/extensions/FormatShort.kt index 5de54163d..f0751db56 100644 --- a/app/src/main/java/com/github/libretube/extensions/FormatShort.kt +++ b/app/src/main/java/com/github/libretube/extensions/FormatShort.kt @@ -1,4 +1,4 @@ -package com.github.libretube.util +package com.github.libretube.extensions import java.math.BigDecimal import java.math.RoundingMode diff --git a/app/src/main/java/com/github/libretube/extensions/HideKeyboard.kt b/app/src/main/java/com/github/libretube/extensions/HideKeyboard.kt index de99f682d..f46ba492c 100644 --- a/app/src/main/java/com/github/libretube/extensions/HideKeyboard.kt +++ b/app/src/main/java/com/github/libretube/extensions/HideKeyboard.kt @@ -1,4 +1,4 @@ -package com.github.libretube.util +package com.github.libretube.extensions import android.app.Activity import android.content.Context diff --git a/app/src/main/java/com/github/libretube/extensions/SetWatchProgressLength.kt b/app/src/main/java/com/github/libretube/extensions/SetWatchProgressLength.kt index ed8fa85bf..99add5759 100644 --- a/app/src/main/java/com/github/libretube/extensions/SetWatchProgressLength.kt +++ b/app/src/main/java/com/github/libretube/extensions/SetWatchProgressLength.kt @@ -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 diff --git a/app/src/main/java/com/github/libretube/extensions/ToID.kt b/app/src/main/java/com/github/libretube/extensions/ToID.kt index 43ff8420d..9c6606c57 100644 --- a/app/src/main/java/com/github/libretube/extensions/ToID.kt +++ b/app/src/main/java/com/github/libretube/extensions/ToID.kt @@ -1,4 +1,4 @@ -package com.github.libretube.util +package com.github.libretube.extensions /** * format a Piped route to an ID diff --git a/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt b/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt index c23814656..0c9595e9f 100644 --- a/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt @@ -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 diff --git a/app/src/main/java/com/github/libretube/fragments/HomeFragment.kt b/app/src/main/java/com/github/libretube/fragments/HomeFragment.kt index c9923c6bc..6312f9dbe 100644 --- a/app/src/main/java/com/github/libretube/fragments/HomeFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/HomeFragment.kt @@ -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") { diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt index d277719ca..8c23ec527 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -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) diff --git a/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt index 6c310798c..fc7fcc63c 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt @@ -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 diff --git a/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt b/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt index 40ec66cb5..3c65c9e9b 100644 --- a/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt @@ -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() diff --git a/app/src/main/java/com/github/libretube/fragments/SearchResultFragment.kt b/app/src/main/java/com/github/libretube/fragments/SearchResultFragment.kt index 08bc72e09..1ee58b55b 100644 --- a/app/src/main/java/com/github/libretube/fragments/SearchResultFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/SearchResultFragment.kt @@ -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() diff --git a/app/src/main/java/com/github/libretube/models/SubscriptionsViewModel.kt b/app/src/main/java/com/github/libretube/models/SubscriptionsViewModel.kt index 44fedd4fb..a1c6c8cfc 100644 --- a/app/src/main/java/com/github/libretube/models/SubscriptionsViewModel.kt +++ b/app/src/main/java/com/github/libretube/models/SubscriptionsViewModel.kt @@ -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 diff --git a/app/src/main/java/com/github/libretube/preferences/AdvancedSettings.kt b/app/src/main/java/com/github/libretube/preferences/AdvancedSettings.kt index 764de788c..c5adbfe2a 100644 --- a/app/src/main/java/com/github/libretube/preferences/AdvancedSettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/AdvancedSettings.kt @@ -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) } diff --git a/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt b/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt index e2bdfc5ab..15b966bf2 100644 --- a/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt @@ -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) } diff --git a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt index 899576dbe..0806ee2dc 100644 --- a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt +++ b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt @@ -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 - stopForeground(true) + 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() diff --git a/app/src/main/java/com/github/libretube/util/AutoPlayHelper.kt b/app/src/main/java/com/github/libretube/util/AutoPlayHelper.kt index 76e8c704f..cfd804cb6 100644 --- a/app/src/main/java/com/github/libretube/util/AutoPlayHelper.kt +++ b/app/src/main/java/com/github/libretube/util/AutoPlayHelper.kt @@ -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 diff --git a/app/src/main/java/com/github/libretube/util/LocaleHelper.kt b/app/src/main/java/com/github/libretube/util/LocaleHelper.kt index 0b294e1e7..f0defb1e5 100644 --- a/app/src/main/java/com/github/libretube/util/LocaleHelper.kt +++ b/app/src/main/java/com/github/libretube/util/LocaleHelper.kt @@ -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], diff --git a/app/src/main/java/com/github/libretube/util/NavigationHelper.kt b/app/src/main/java/com/github/libretube/util/NavigationHelper.kt index 219aa3dac..54c7cb72d 100644 --- a/app/src/main/java/com/github/libretube/util/NavigationHelper.kt +++ b/app/src/main/java/com/github/libretube/util/NavigationHelper.kt @@ -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 { diff --git a/app/src/main/java/com/github/libretube/util/NotificationHelper.kt b/app/src/main/java/com/github/libretube/util/NotificationHelper.kt index ec960c64b..bda483a0d 100644 --- a/app/src/main/java/com/github/libretube/util/NotificationHelper.kt +++ b/app/src/main/java/com/github/libretube/util/NotificationHelper.kt @@ -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 diff --git a/app/src/main/java/com/github/libretube/views/CustomSwipeToRefresh.kt b/app/src/main/java/com/github/libretube/views/CustomSwipeToRefresh.kt index 87ee39d51..96476579c 100644 --- a/app/src/main/java/com/github/libretube/views/CustomSwipeToRefresh.kt +++ b/app/src/main/java/com/github/libretube/views/CustomSwipeToRefresh.kt @@ -26,6 +26,6 @@ class CustomSwipeToRefresh(context: Context?, attrs: AttributeSet?) : } init { - mTouchSlop = ViewConfiguration.get(context).scaledTouchSlop + mTouchSlop = ViewConfiguration.get(this.context).scaledTouchSlop } } diff --git a/app/src/main/java/com/github/libretube/views/SingleViewTouchableMotionLayout.kt b/app/src/main/java/com/github/libretube/views/SingleViewTouchableMotionLayout.kt index a9863d535..36f889145 100644 --- a/app/src/main/java/com/github/libretube/views/SingleViewTouchableMotionLayout.kt +++ b/app/src/main/java/com/github/libretube/views/SingleViewTouchableMotionLayout.kt @@ -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) { diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index 6c7bd4e4a..bbcc85210 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -2,5 +2,6 @@ + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml index 6c7bd4e4a..bbcc85210 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -2,5 +2,6 @@ + \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b782922ac..da02274fa 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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" }