diff --git a/app/build.gradle b/app/build.gradle index 85319bc2d..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 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..5a8dfc391 100644 --- a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt @@ -10,9 +10,9 @@ import com.github.libretube.dialogs.VideoOptionsDialog 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 +import com.github.libretube.extensions.formatShort +import com.github.libretube.extensions.setWatchProgressLength +import com.github.libretube.extensions.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..5a8c75ac3 100644 --- a/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt @@ -15,7 +15,7 @@ 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 com.github.libretube.extensions.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..56917f204 100644 --- a/app/src/main/java/com/github/libretube/adapters/LegacySubscriptionAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/LegacySubscriptionAdapter.kt @@ -7,7 +7,7 @@ import com.github.libretube.databinding.LegacySubscriptionChannelBinding import com.github.libretube.obj.Subscription import com.github.libretube.util.ImageHelper import com.github.libretube.util.NavigationHelper -import com.github.libretube.util.toID +import com.github.libretube.extensions.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..05a54dfca 100644 --- a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt @@ -17,8 +17,8 @@ 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 com.github.libretube.extensions.setWatchProgressLength +import com.github.libretube.extensions.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..4effc17d8 100644 --- a/app/src/main/java/com/github/libretube/adapters/RepliesAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/RepliesAdapter.kt @@ -8,7 +8,7 @@ import com.github.libretube.databinding.RepliesRowBinding import com.github.libretube.obj.Comment import com.github.libretube.util.ImageHelper import com.github.libretube.util.NavigationHelper -import com.github.libretube.util.formatShort +import com.github.libretube.extensions.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..699e989ce 100644 --- a/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt @@ -16,9 +16,9 @@ import com.github.libretube.extensions.setFormattedDuration 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 com.github.libretube.extensions.formatShort +import com.github.libretube.extensions.setWatchProgressLength +import com.github.libretube.extensions.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..ed52886f0 100644 --- a/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt @@ -9,7 +9,7 @@ import com.github.libretube.databinding.ChannelSubscriptionRowBinding import com.github.libretube.obj.Subscription import com.github.libretube.util.ImageHelper import com.github.libretube.util.NavigationHelper -import com.github.libretube.util.toID +import com.github.libretube.extensions.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..1326e1293 100644 --- a/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt @@ -11,9 +11,9 @@ import com.github.libretube.extensions.setFormattedDuration 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 +import com.github.libretube.extensions.formatShort +import com.github.libretube.extensions.setWatchProgressLength +import com.github.libretube.extensions.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..8e5020994 100644 --- a/app/src/main/java/com/github/libretube/adapters/WatchHistoryAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/WatchHistoryAdapter.kt @@ -11,7 +11,7 @@ import com.github.libretube.dialogs.VideoOptionsDialog import com.github.libretube.extensions.setFormattedDuration import com.github.libretube.util.ImageHelper import com.github.libretube.util.NavigationHelper -import com.github.libretube.util.setWatchProgressLength +import com.github.libretube.extensions.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..856d64dc3 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 @@ -47,7 +47,7 @@ class ResettableLazy(val manager: ResettableLazyManager, val init: () } fun resettableLazy(manager: ResettableLazyManager, init: () -> PROPTYPE): - ResettableLazy { + ResettableLazy { return ResettableLazy(manager, init) } 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..ddd9fcc96 100644 --- a/app/src/main/java/com/github/libretube/db/DatabaseHelper.kt +++ b/app/src/main/java/com/github/libretube/db/DatabaseHelper.kt @@ -6,7 +6,7 @@ import com.github.libretube.db.obj.WatchPosition import com.github.libretube.obj.Streams import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.preferences.PreferenceKeys -import com.github.libretube.util.toID +import com.github.libretube.extensions.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..d89a88c46 100644 --- a/app/src/main/java/com/github/libretube/dialogs/PlaylistOptionsDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/PlaylistOptionsDialog.kt @@ -12,7 +12,7 @@ import com.github.libretube.extensions.TAG 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.github.libretube.extensions.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..e53ed4339 100644 --- a/app/src/main/java/com/github/libretube/extensions/SetWatchProgressLength.kt +++ b/app/src/main/java/com/github/libretube/extensions/SetWatchProgressLength.kt @@ -1,4 +1,4 @@ -package com.github.libretube.util +package com.github.libretube.extensions import android.view.View import android.view.ViewTreeObserver 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..2881faeb5 100644 --- a/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt @@ -15,8 +15,8 @@ import com.github.libretube.databinding.FragmentChannelBinding import com.github.libretube.extensions.BaseFragment import com.github.libretube.extensions.TAG import com.github.libretube.util.ImageHelper -import com.github.libretube.util.formatShort -import com.github.libretube.util.toID +import com.github.libretube.extensions.formatShort +import com.github.libretube.extensions.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..6de90ce29 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -72,9 +72,9 @@ 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.extensions.formatShort +import com.github.libretube.extensions.hideKeyboard +import com.github.libretube.extensions.toID import com.github.libretube.views.PlayerOptionsBottomSheet import com.google.android.exoplayer2.C import com.google.android.exoplayer2.DefaultLoadControl 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..5e01bad17 100644 --- a/app/src/main/java/com/github/libretube/models/SubscriptionsViewModel.kt +++ b/app/src/main/java/com/github/libretube/models/SubscriptionsViewModel.kt @@ -9,7 +9,7 @@ import com.github.libretube.extensions.TAG 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 com.github.libretube.extensions.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