From 0272a00a0a94c15e3a65bb9a76bb1cf35f977d8c Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 8 Sep 2022 18:29:00 +0200 Subject: [PATCH 1/5] move constants to its own package --- app/src/main/java/com/github/libretube/MyApp.kt | 4 ++-- .../java/com/github/libretube/activities/MainActivity.kt | 4 ++-- .../java/com/github/libretube/adapters/PlaylistAdapter.kt | 2 +- .../java/com/github/libretube/adapters/PlaylistsAdapter.kt | 2 +- .../java/com/github/libretube/api/SubscriptionHelper.kt | 2 +- .../java/com/github/libretube/{ => constants}/Constants.kt | 0 .../libretube/{preferences => constants}/PreferenceKeys.kt | 2 +- .../{preferences => constants}/PreferenceRanges.kt | 2 +- app/src/main/java/com/github/libretube/db/DatabaseHelper.kt | 4 ++-- .../com/github/libretube/dialogs/AddToPlaylistDialog.kt | 2 +- .../com/github/libretube/dialogs/CreatePlaylistDialog.kt | 2 +- .../com/github/libretube/dialogs/DeleteAccountDialog.kt | 2 +- .../main/java/com/github/libretube/dialogs/ErrorDialog.kt | 2 +- .../main/java/com/github/libretube/dialogs/LoginDialog.kt | 2 +- .../main/java/com/github/libretube/dialogs/LogoutDialog.kt | 2 +- .../com/github/libretube/dialogs/PlaylistOptionsDialog.kt | 2 +- .../main/java/com/github/libretube/dialogs/ShareDialog.kt | 4 ++-- .../java/com/github/libretube/dialogs/VideoOptionsDialog.kt | 2 +- .../com/github/libretube/extensions/SliderPreference.kt | 6 +++--- .../java/com/github/libretube/fragments/HomeFragment.kt | 4 ++-- .../java/com/github/libretube/fragments/LibraryFragment.kt | 4 ++-- .../java/com/github/libretube/fragments/PlayerFragment.kt | 6 +++--- .../com/github/libretube/fragments/SearchResultFragment.kt | 4 ++-- .../com/github/libretube/fragments/SubscriptionsFragment.kt | 4 ++-- .../com/github/libretube/models/SubscriptionsViewModel.kt | 2 +- .../com/github/libretube/preferences/AdvancedSettings.kt | 2 ++ .../com/github/libretube/preferences/AppearanceSettings.kt | 2 ++ .../com/github/libretube/preferences/GeneralSettings.kt | 2 ++ .../com/github/libretube/preferences/HistorySettings.kt | 1 + .../com/github/libretube/preferences/InstanceSettings.kt | 2 ++ .../github/libretube/preferences/NotificationSettings.kt | 1 + .../java/com/github/libretube/preferences/PlayerSettings.kt | 2 ++ .../java/com/github/libretube/services/BackgroundMode.kt | 4 ++-- .../java/com/github/libretube/services/DownloadService.kt | 4 ++-- .../main/java/com/github/libretube/util/ExceptionHandler.kt | 2 -- app/src/main/java/com/github/libretube/util/ImageHelper.kt | 3 +-- app/src/main/java/com/github/libretube/util/ImportHelper.kt | 1 - app/src/main/java/com/github/libretube/util/LocaleHelper.kt | 3 +-- .../java/com/github/libretube/util/NotificationHelper.kt | 3 +-- app/src/main/java/com/github/libretube/util/PlayerHelper.kt | 3 +-- .../libretube/{preferences => util}/PreferenceHelper.kt | 3 ++- app/src/main/java/com/github/libretube/util/ThemeHelper.kt | 3 +-- .../github/libretube/views/MaterialPreferenceFragment.kt | 2 +- 43 files changed, 60 insertions(+), 55 deletions(-) rename app/src/main/java/com/github/libretube/{ => constants}/Constants.kt (100%) rename app/src/main/java/com/github/libretube/{preferences => constants}/PreferenceKeys.kt (98%) rename app/src/main/java/com/github/libretube/{preferences => constants}/PreferenceRanges.kt (84%) rename app/src/main/java/com/github/libretube/{preferences => util}/PreferenceHelper.kt (96%) diff --git a/app/src/main/java/com/github/libretube/MyApp.kt b/app/src/main/java/com/github/libretube/MyApp.kt index 1402989461..a8de7b9917 100644 --- a/app/src/main/java/com/github/libretube/MyApp.kt +++ b/app/src/main/java/com/github/libretube/MyApp.kt @@ -13,14 +13,14 @@ import com.fasterxml.jackson.core.type.TypeReference import com.fasterxml.jackson.databind.ObjectMapper import com.github.libretube.api.CronetHelper import com.github.libretube.api.RetrofitInstance +import com.github.libretube.constants.PreferenceKeys import com.github.libretube.db.DatabaseHolder import com.github.libretube.db.obj.WatchHistoryItem import com.github.libretube.db.obj.WatchPosition -import com.github.libretube.preferences.PreferenceHelper -import com.github.libretube.preferences.PreferenceKeys import com.github.libretube.util.ExceptionHandler import com.github.libretube.util.ImageHelper import com.github.libretube.util.NotificationHelper +import com.github.libretube.util.PreferenceHelper class MyApp : Application() { override fun onCreate() { 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 0079e37c95..c2b4bbb3c6 100644 --- a/app/src/main/java/com/github/libretube/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/activities/MainActivity.kt @@ -27,6 +27,7 @@ import androidx.navigation.NavController import androidx.navigation.findNavController import androidx.navigation.ui.setupWithNavController import com.github.libretube.R +import com.github.libretube.constants.PreferenceKeys import com.github.libretube.databinding.ActivityMainBinding import com.github.libretube.dialogs.ErrorDialog import com.github.libretube.extensions.BaseActivity @@ -34,10 +35,9 @@ import com.github.libretube.extensions.TAG import com.github.libretube.fragments.PlayerFragment import com.github.libretube.models.PlayerViewModel import com.github.libretube.models.SearchViewModel -import com.github.libretube.preferences.PreferenceHelper -import com.github.libretube.preferences.PreferenceKeys import com.github.libretube.services.ClosingService import com.github.libretube.util.NetworkHelper +import com.github.libretube.util.PreferenceHelper import com.github.libretube.util.ThemeHelper import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.elevation.SurfaceColors 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 7127d1e818..f00a70e329 100644 --- a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt @@ -16,9 +16,9 @@ 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.PreferenceHelper import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt b/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt index 55a146a738..4f5b8457a6 100644 --- a/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt @@ -13,9 +13,9 @@ import com.github.libretube.dialogs.PlaylistOptionsDialog import com.github.libretube.extensions.TAG import com.github.libretube.obj.PlaylistId import com.github.libretube.obj.Playlists -import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.util.ImageHelper import com.github.libretube.util.NavigationHelper +import com.github.libretube.util.PreferenceHelper 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/api/SubscriptionHelper.kt b/app/src/main/java/com/github/libretube/api/SubscriptionHelper.kt index aec89d9e81..8360ab3f9f 100644 --- a/app/src/main/java/com/github/libretube/api/SubscriptionHelper.kt +++ b/app/src/main/java/com/github/libretube/api/SubscriptionHelper.kt @@ -6,7 +6,7 @@ import com.github.libretube.db.obj.LocalSubscription import com.github.libretube.extensions.TAG import com.github.libretube.extensions.await import com.github.libretube.obj.Subscribe -import com.github.libretube.preferences.PreferenceHelper +import com.github.libretube.util.PreferenceHelper import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/app/src/main/java/com/github/libretube/Constants.kt b/app/src/main/java/com/github/libretube/constants/Constants.kt similarity index 100% rename from app/src/main/java/com/github/libretube/Constants.kt rename to app/src/main/java/com/github/libretube/constants/Constants.kt diff --git a/app/src/main/java/com/github/libretube/preferences/PreferenceKeys.kt b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt similarity index 98% rename from app/src/main/java/com/github/libretube/preferences/PreferenceKeys.kt rename to app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt index c35622a029..58b229eae7 100644 --- a/app/src/main/java/com/github/libretube/preferences/PreferenceKeys.kt +++ b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt @@ -1,4 +1,4 @@ -package com.github.libretube.preferences +package com.github.libretube.constants /** * keys for the shared preferences diff --git a/app/src/main/java/com/github/libretube/preferences/PreferenceRanges.kt b/app/src/main/java/com/github/libretube/constants/PreferenceRanges.kt similarity index 84% rename from app/src/main/java/com/github/libretube/preferences/PreferenceRanges.kt rename to app/src/main/java/com/github/libretube/constants/PreferenceRanges.kt index 36fffda115..a82e623d32 100644 --- a/app/src/main/java/com/github/libretube/preferences/PreferenceRanges.kt +++ b/app/src/main/java/com/github/libretube/constants/PreferenceRanges.kt @@ -1,4 +1,4 @@ -package com.github.libretube.preferences +package com.github.libretube.constants import com.github.libretube.obj.SliderRange 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 664def33d1..c129d8a978 100644 --- a/app/src/main/java/com/github/libretube/db/DatabaseHelper.kt +++ b/app/src/main/java/com/github/libretube/db/DatabaseHelper.kt @@ -1,12 +1,12 @@ package com.github.libretube.db +import com.github.libretube.constants.PreferenceKeys 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.PreferenceHelper object DatabaseHelper { fun addToWatchHistory(videoId: String, streams: Streams) { diff --git a/app/src/main/java/com/github/libretube/dialogs/AddToPlaylistDialog.kt b/app/src/main/java/com/github/libretube/dialogs/AddToPlaylistDialog.kt index 1e21cbdf47..9855ed7947 100644 --- a/app/src/main/java/com/github/libretube/dialogs/AddToPlaylistDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/AddToPlaylistDialog.kt @@ -15,7 +15,7 @@ import com.github.libretube.databinding.DialogAddtoplaylistBinding import com.github.libretube.extensions.TAG import com.github.libretube.models.PlaylistViewModel import com.github.libretube.obj.PlaylistId -import com.github.libretube.preferences.PreferenceHelper +import com.github.libretube.util.PreferenceHelper import com.github.libretube.util.ThemeHelper import com.google.android.material.dialog.MaterialAlertDialogBuilder import retrofit2.HttpException diff --git a/app/src/main/java/com/github/libretube/dialogs/CreatePlaylistDialog.kt b/app/src/main/java/com/github/libretube/dialogs/CreatePlaylistDialog.kt index 66f6c10e89..eefb9256fa 100644 --- a/app/src/main/java/com/github/libretube/dialogs/CreatePlaylistDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/CreatePlaylistDialog.kt @@ -12,7 +12,7 @@ import com.github.libretube.databinding.DialogCreatePlaylistBinding import com.github.libretube.extensions.TAG import com.github.libretube.fragments.LibraryFragment import com.github.libretube.obj.Playlists -import com.github.libretube.preferences.PreferenceHelper +import com.github.libretube.util.PreferenceHelper import com.github.libretube.util.ThemeHelper import com.google.android.material.dialog.MaterialAlertDialogBuilder import retrofit2.HttpException diff --git a/app/src/main/java/com/github/libretube/dialogs/DeleteAccountDialog.kt b/app/src/main/java/com/github/libretube/dialogs/DeleteAccountDialog.kt index 1cb5e039ce..323875e06f 100644 --- a/app/src/main/java/com/github/libretube/dialogs/DeleteAccountDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/DeleteAccountDialog.kt @@ -11,7 +11,7 @@ import com.github.libretube.api.RetrofitInstance import com.github.libretube.databinding.DialogDeleteAccountBinding import com.github.libretube.extensions.TAG import com.github.libretube.obj.DeleteUserRequest -import com.github.libretube.preferences.PreferenceHelper +import com.github.libretube.util.PreferenceHelper import com.github.libretube.util.ThemeHelper import com.google.android.material.dialog.MaterialAlertDialogBuilder diff --git a/app/src/main/java/com/github/libretube/dialogs/ErrorDialog.kt b/app/src/main/java/com/github/libretube/dialogs/ErrorDialog.kt index cd0ac0b01d..66dc11a6a3 100644 --- a/app/src/main/java/com/github/libretube/dialogs/ErrorDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/ErrorDialog.kt @@ -8,7 +8,7 @@ import android.os.Bundle import android.widget.Toast import androidx.fragment.app.DialogFragment import com.github.libretube.R -import com.github.libretube.preferences.PreferenceHelper +import com.github.libretube.util.PreferenceHelper import com.google.android.material.dialog.MaterialAlertDialogBuilder class ErrorDialog : DialogFragment() { diff --git a/app/src/main/java/com/github/libretube/dialogs/LoginDialog.kt b/app/src/main/java/com/github/libretube/dialogs/LoginDialog.kt index dea8cc329f..4777bc4ca7 100644 --- a/app/src/main/java/com/github/libretube/dialogs/LoginDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/LoginDialog.kt @@ -11,7 +11,7 @@ import com.github.libretube.api.RetrofitInstance import com.github.libretube.databinding.DialogLoginBinding import com.github.libretube.extensions.TAG import com.github.libretube.obj.Login -import com.github.libretube.preferences.PreferenceHelper +import com.github.libretube.util.PreferenceHelper import com.github.libretube.util.ThemeHelper import com.google.android.material.dialog.MaterialAlertDialogBuilder import retrofit2.HttpException diff --git a/app/src/main/java/com/github/libretube/dialogs/LogoutDialog.kt b/app/src/main/java/com/github/libretube/dialogs/LogoutDialog.kt index c5dd117d7b..b4df8e9a96 100644 --- a/app/src/main/java/com/github/libretube/dialogs/LogoutDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/LogoutDialog.kt @@ -6,7 +6,7 @@ import android.widget.Toast import androidx.fragment.app.DialogFragment import com.github.libretube.R import com.github.libretube.databinding.DialogLogoutBinding -import com.github.libretube.preferences.PreferenceHelper +import com.github.libretube.util.PreferenceHelper import com.github.libretube.util.ThemeHelper import com.google.android.material.dialog.MaterialAlertDialogBuilder 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 dcc8557af9..57402c18b5 100644 --- a/app/src/main/java/com/github/libretube/dialogs/PlaylistOptionsDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/PlaylistOptionsDialog.kt @@ -11,8 +11,8 @@ 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.PreferenceHelper 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/dialogs/ShareDialog.kt b/app/src/main/java/com/github/libretube/dialogs/ShareDialog.kt index f46306cf66..032343b9b2 100644 --- a/app/src/main/java/com/github/libretube/dialogs/ShareDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/ShareDialog.kt @@ -7,12 +7,12 @@ import androidx.fragment.app.DialogFragment import com.github.libretube.PIPED_FRONTEND_URL import com.github.libretube.R import com.github.libretube.YOUTUBE_FRONTEND_URL +import com.github.libretube.constants.PreferenceKeys import com.github.libretube.databinding.DialogShareBinding import com.github.libretube.db.DatabaseHolder import com.github.libretube.db.obj.CustomInstance import com.github.libretube.extensions.await -import com.github.libretube.preferences.PreferenceHelper -import com.github.libretube.preferences.PreferenceKeys +import com.github.libretube.util.PreferenceHelper import com.google.android.material.dialog.MaterialAlertDialogBuilder class ShareDialog( diff --git a/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt b/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt index 0df687c03e..4b8700b5a6 100644 --- a/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt @@ -10,8 +10,8 @@ import androidx.fragment.app.DialogFragment import com.github.libretube.Globals import com.github.libretube.PLAYER_NOTIFICATION_ID import com.github.libretube.R -import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.util.BackgroundHelper +import com.github.libretube.util.PreferenceHelper import com.google.android.material.dialog.MaterialAlertDialogBuilder /** diff --git a/app/src/main/java/com/github/libretube/extensions/SliderPreference.kt b/app/src/main/java/com/github/libretube/extensions/SliderPreference.kt index c37fb9dc73..324a1f9def 100644 --- a/app/src/main/java/com/github/libretube/extensions/SliderPreference.kt +++ b/app/src/main/java/com/github/libretube/extensions/SliderPreference.kt @@ -5,10 +5,10 @@ import android.util.AttributeSet import android.view.LayoutInflater import androidx.preference.Preference import com.github.libretube.R +import com.github.libretube.constants.PreferenceKeys +import com.github.libretube.constants.PreferenceRanges import com.github.libretube.databinding.DialogSliderBinding -import com.github.libretube.preferences.PreferenceHelper -import com.github.libretube.preferences.PreferenceKeys -import com.github.libretube.preferences.PreferenceRanges +import com.github.libretube.util.PreferenceHelper import com.google.android.material.dialog.MaterialAlertDialogBuilder /** 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 6312f9dbe5..3807246292 100644 --- a/app/src/main/java/com/github/libretube/fragments/HomeFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/HomeFragment.kt @@ -11,12 +11,12 @@ import androidx.recyclerview.widget.GridLayoutManager import com.github.libretube.R import com.github.libretube.adapters.TrendingAdapter import com.github.libretube.api.RetrofitInstance +import com.github.libretube.constants.PreferenceKeys import com.github.libretube.databinding.FragmentHomeBinding import com.github.libretube.extensions.BaseFragment import com.github.libretube.extensions.TAG -import com.github.libretube.preferences.PreferenceHelper -import com.github.libretube.preferences.PreferenceKeys import com.github.libretube.util.LocaleHelper +import com.github.libretube.util.PreferenceHelper import retrofit2.HttpException import java.io.IOException diff --git a/app/src/main/java/com/github/libretube/fragments/LibraryFragment.kt b/app/src/main/java/com/github/libretube/fragments/LibraryFragment.kt index 2e73b6c50d..b47b06ce54 100644 --- a/app/src/main/java/com/github/libretube/fragments/LibraryFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/LibraryFragment.kt @@ -14,13 +14,13 @@ import androidx.recyclerview.widget.RecyclerView import com.github.libretube.R import com.github.libretube.adapters.PlaylistsAdapter import com.github.libretube.api.RetrofitInstance +import com.github.libretube.constants.PreferenceKeys import com.github.libretube.databinding.FragmentLibraryBinding import com.github.libretube.dialogs.CreatePlaylistDialog import com.github.libretube.extensions.BaseFragment import com.github.libretube.extensions.TAG import com.github.libretube.models.PlayerViewModel -import com.github.libretube.preferences.PreferenceHelper -import com.github.libretube.preferences.PreferenceKeys +import com.github.libretube.util.PreferenceHelper import retrofit2.HttpException import java.io.IOException 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 8c23ec5271..8de655787c 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -44,6 +44,8 @@ import com.github.libretube.adapters.TrendingAdapter import com.github.libretube.api.CronetHelper import com.github.libretube.api.RetrofitInstance import com.github.libretube.api.SubscriptionHelper +import com.github.libretube.constants.PreferenceKeys +import com.github.libretube.constants.PreferenceRanges import com.github.libretube.databinding.DialogSliderBinding import com.github.libretube.databinding.DoubleTapOverlayBinding import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding @@ -67,15 +69,13 @@ import com.github.libretube.obj.ChapterSegment import com.github.libretube.obj.Segment import com.github.libretube.obj.Segments import com.github.libretube.obj.Streams -import com.github.libretube.preferences.PreferenceHelper -import com.github.libretube.preferences.PreferenceKeys -import com.github.libretube.preferences.PreferenceRanges import com.github.libretube.services.BackgroundMode import com.github.libretube.util.AutoPlayHelper 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.PreferenceHelper 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/SearchResultFragment.kt b/app/src/main/java/com/github/libretube/fragments/SearchResultFragment.kt index 1ee58b55b6..dbc6a5bf1f 100644 --- a/app/src/main/java/com/github/libretube/fragments/SearchResultFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/SearchResultFragment.kt @@ -12,14 +12,14 @@ import com.github.libretube.R import com.github.libretube.activities.MainActivity import com.github.libretube.adapters.SearchAdapter import com.github.libretube.api.RetrofitInstance +import com.github.libretube.constants.PreferenceKeys import com.github.libretube.databinding.FragmentSearchResultBinding 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.PreferenceHelper import retrofit2.HttpException import java.io.IOException diff --git a/app/src/main/java/com/github/libretube/fragments/SubscriptionsFragment.kt b/app/src/main/java/com/github/libretube/fragments/SubscriptionsFragment.kt index 6abd2b0ad1..2d47e8ad1b 100644 --- a/app/src/main/java/com/github/libretube/fragments/SubscriptionsFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/SubscriptionsFragment.kt @@ -12,11 +12,11 @@ import com.github.libretube.R import com.github.libretube.adapters.LegacySubscriptionAdapter import com.github.libretube.adapters.SubscriptionChannelAdapter import com.github.libretube.adapters.TrendingAdapter +import com.github.libretube.constants.PreferenceKeys import com.github.libretube.databinding.FragmentSubscriptionsBinding import com.github.libretube.extensions.BaseFragment import com.github.libretube.models.SubscriptionsViewModel -import com.github.libretube.preferences.PreferenceHelper -import com.github.libretube.preferences.PreferenceKeys +import com.github.libretube.util.PreferenceHelper import com.google.android.material.dialog.MaterialAlertDialogBuilder class SubscriptionsFragment : BaseFragment() { 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 a1c6c8cfce..4dd633a87c 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.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.PreferenceHelper 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 c5adbfe2ab..1b17b4894d 100644 --- a/app/src/main/java/com/github/libretube/preferences/AdvancedSettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/AdvancedSettings.kt @@ -9,8 +9,10 @@ import androidx.preference.ListPreference import androidx.preference.Preference import com.github.libretube.R import com.github.libretube.activities.SettingsActivity +import com.github.libretube.constants.PreferenceKeys import com.github.libretube.util.BackupHelper import com.github.libretube.util.ImageHelper +import com.github.libretube.util.PreferenceHelper import com.github.libretube.views.MaterialPreferenceFragment import com.google.android.material.dialog.MaterialAlertDialogBuilder diff --git a/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt b/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt index a5dde2c120..4299bcd34a 100644 --- a/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt @@ -10,7 +10,9 @@ import androidx.preference.Preference import androidx.preference.SwitchPreferenceCompat import com.github.libretube.R import com.github.libretube.activities.SettingsActivity +import com.github.libretube.constants.PreferenceKeys import com.github.libretube.dialogs.RequireRestartDialog +import com.github.libretube.util.PreferenceHelper import com.github.libretube.util.ThemeHelper import com.github.libretube.views.MaterialPreferenceFragment import com.google.android.material.color.DynamicColors diff --git a/app/src/main/java/com/github/libretube/preferences/GeneralSettings.kt b/app/src/main/java/com/github/libretube/preferences/GeneralSettings.kt index e519e1b720..6393dff6eb 100644 --- a/app/src/main/java/com/github/libretube/preferences/GeneralSettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/GeneralSettings.kt @@ -6,7 +6,9 @@ import androidx.preference.ListPreference import androidx.preference.SwitchPreferenceCompat import com.github.libretube.R import com.github.libretube.activities.SettingsActivity +import com.github.libretube.constants.PreferenceKeys import com.github.libretube.dialogs.RequireRestartDialog +import com.github.libretube.util.PreferenceHelper import com.github.libretube.views.MaterialPreferenceFragment class GeneralSettings : MaterialPreferenceFragment() { diff --git a/app/src/main/java/com/github/libretube/preferences/HistorySettings.kt b/app/src/main/java/com/github/libretube/preferences/HistorySettings.kt index d871fd24a6..ad3d0895b8 100644 --- a/app/src/main/java/com/github/libretube/preferences/HistorySettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/HistorySettings.kt @@ -4,6 +4,7 @@ import android.os.Bundle import androidx.preference.Preference import com.github.libretube.R import com.github.libretube.activities.SettingsActivity +import com.github.libretube.constants.PreferenceKeys import com.github.libretube.db.DatabaseHolder import com.github.libretube.views.MaterialPreferenceFragment import com.google.android.material.dialog.MaterialAlertDialogBuilder 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 15b966bf25..72d27726a6 100644 --- a/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt @@ -14,6 +14,7 @@ import androidx.preference.SwitchPreferenceCompat import com.github.libretube.R import com.github.libretube.activities.SettingsActivity import com.github.libretube.api.RetrofitInstance +import com.github.libretube.constants.PreferenceKeys import com.github.libretube.db.DatabaseHolder import com.github.libretube.db.obj.CustomInstance import com.github.libretube.dialogs.CustomInstanceDialog @@ -23,6 +24,7 @@ import com.github.libretube.dialogs.LogoutDialog import com.github.libretube.extensions.await import com.github.libretube.util.ImportHelper import com.github.libretube.util.PermissionHelper +import com.github.libretube.util.PreferenceHelper import com.github.libretube.views.MaterialPreferenceFragment class InstanceSettings : MaterialPreferenceFragment() { diff --git a/app/src/main/java/com/github/libretube/preferences/NotificationSettings.kt b/app/src/main/java/com/github/libretube/preferences/NotificationSettings.kt index e3740a0e43..0e12388e82 100644 --- a/app/src/main/java/com/github/libretube/preferences/NotificationSettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/NotificationSettings.kt @@ -6,6 +6,7 @@ import androidx.preference.SwitchPreferenceCompat import androidx.work.ExistingPeriodicWorkPolicy import com.github.libretube.R import com.github.libretube.activities.SettingsActivity +import com.github.libretube.constants.PreferenceKeys import com.github.libretube.util.NotificationHelper import com.github.libretube.views.MaterialPreferenceFragment diff --git a/app/src/main/java/com/github/libretube/preferences/PlayerSettings.kt b/app/src/main/java/com/github/libretube/preferences/PlayerSettings.kt index 3e75a6dea3..90ff99b20e 100644 --- a/app/src/main/java/com/github/libretube/preferences/PlayerSettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/PlayerSettings.kt @@ -6,6 +6,8 @@ import androidx.preference.Preference import androidx.preference.SwitchPreferenceCompat import com.github.libretube.R import com.github.libretube.activities.SettingsActivity +import com.github.libretube.constants.PreferenceKeys +import com.github.libretube.util.PreferenceHelper import com.github.libretube.views.MaterialPreferenceFragment import java.util.* 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 0806ee2dc2..330b3c53db 100644 --- a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt +++ b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt @@ -16,15 +16,15 @@ 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.constants.PreferenceKeys import com.github.libretube.extensions.toID import com.github.libretube.obj.Segment import com.github.libretube.obj.Segments import com.github.libretube.obj.Streams -import com.github.libretube.preferences.PreferenceHelper -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.PreferenceHelper import com.google.android.exoplayer2.C import com.google.android.exoplayer2.ExoPlayer import com.google.android.exoplayer2.MediaItem diff --git a/app/src/main/java/com/github/libretube/services/DownloadService.kt b/app/src/main/java/com/github/libretube/services/DownloadService.kt index 8f00d99719..b405a7bb61 100644 --- a/app/src/main/java/com/github/libretube/services/DownloadService.kt +++ b/app/src/main/java/com/github/libretube/services/DownloadService.kt @@ -23,10 +23,10 @@ import com.github.libretube.DOWNLOAD_PENDING_NOTIFICATION_ID import com.github.libretube.DOWNLOAD_SUCCESS_NOTIFICATION_ID import com.github.libretube.Globals import com.github.libretube.R +import com.github.libretube.constants.PreferenceKeys import com.github.libretube.extensions.TAG import com.github.libretube.obj.DownloadType -import com.github.libretube.preferences.PreferenceHelper -import com.github.libretube.preferences.PreferenceKeys +import com.github.libretube.util.PreferenceHelper import java.io.File class DownloadService : Service() { diff --git a/app/src/main/java/com/github/libretube/util/ExceptionHandler.kt b/app/src/main/java/com/github/libretube/util/ExceptionHandler.kt index af8185c84b..3d790d7c8d 100644 --- a/app/src/main/java/com/github/libretube/util/ExceptionHandler.kt +++ b/app/src/main/java/com/github/libretube/util/ExceptionHandler.kt @@ -1,7 +1,5 @@ package com.github.libretube.util -import com.github.libretube.preferences.PreferenceHelper - class ExceptionHandler( private val defaultExceptionHandler: Thread.UncaughtExceptionHandler? ) : Thread.UncaughtExceptionHandler { diff --git a/app/src/main/java/com/github/libretube/util/ImageHelper.kt b/app/src/main/java/com/github/libretube/util/ImageHelper.kt index 187886649f..8b1bcc2bed 100644 --- a/app/src/main/java/com/github/libretube/util/ImageHelper.kt +++ b/app/src/main/java/com/github/libretube/util/ImageHelper.kt @@ -6,8 +6,7 @@ import coil.ImageLoader import coil.disk.DiskCache import coil.load import com.github.libretube.api.CronetHelper -import com.github.libretube.preferences.PreferenceHelper -import com.github.libretube.preferences.PreferenceKeys +import com.github.libretube.constants.PreferenceKeys object ImageHelper { lateinit var imageLoader: ImageLoader diff --git a/app/src/main/java/com/github/libretube/util/ImportHelper.kt b/app/src/main/java/com/github/libretube/util/ImportHelper.kt index e8d49963e4..b6a6c8e76a 100644 --- a/app/src/main/java/com/github/libretube/util/ImportHelper.kt +++ b/app/src/main/java/com/github/libretube/util/ImportHelper.kt @@ -11,7 +11,6 @@ import com.github.libretube.api.SubscriptionHelper import com.github.libretube.extensions.TAG import com.github.libretube.obj.NewPipeSubscription import com.github.libretube.obj.NewPipeSubscriptions -import com.github.libretube.preferences.PreferenceHelper import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch 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 f0defb1e5f..6ccacf472f 100644 --- a/app/src/main/java/com/github/libretube/util/LocaleHelper.kt +++ b/app/src/main/java/com/github/libretube/util/LocaleHelper.kt @@ -3,8 +3,7 @@ package com.github.libretube.util import android.content.Context import android.os.Build import android.telephony.TelephonyManager -import com.github.libretube.preferences.PreferenceHelper -import com.github.libretube.preferences.PreferenceKeys +import com.github.libretube.constants.PreferenceKeys import java.util.* object LocaleHelper { 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 bda483a0d9..a0c855250e 100644 --- a/app/src/main/java/com/github/libretube/util/NotificationHelper.kt +++ b/app/src/main/java/com/github/libretube/util/NotificationHelper.kt @@ -18,8 +18,7 @@ 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 com.github.libretube.constants.PreferenceKeys import kotlinx.coroutines.async import kotlinx.coroutines.runBlocking import java.util.concurrent.TimeUnit diff --git a/app/src/main/java/com/github/libretube/util/PlayerHelper.kt b/app/src/main/java/com/github/libretube/util/PlayerHelper.kt index 8c9d48f972..a1543bec25 100644 --- a/app/src/main/java/com/github/libretube/util/PlayerHelper.kt +++ b/app/src/main/java/com/github/libretube/util/PlayerHelper.kt @@ -3,8 +3,7 @@ package com.github.libretube.util import android.content.Context import android.view.accessibility.CaptioningManager import com.github.libretube.obj.PipedStream -import com.github.libretube.preferences.PreferenceHelper -import com.github.libretube.preferences.PreferenceKeys +import com.github.libretube.constants.PreferenceKeys import com.google.android.exoplayer2.ui.CaptionStyleCompat object PlayerHelper { diff --git a/app/src/main/java/com/github/libretube/preferences/PreferenceHelper.kt b/app/src/main/java/com/github/libretube/util/PreferenceHelper.kt similarity index 96% rename from app/src/main/java/com/github/libretube/preferences/PreferenceHelper.kt rename to app/src/main/java/com/github/libretube/util/PreferenceHelper.kt index a80148b67f..b63e95210f 100644 --- a/app/src/main/java/com/github/libretube/preferences/PreferenceHelper.kt +++ b/app/src/main/java/com/github/libretube/util/PreferenceHelper.kt @@ -1,9 +1,10 @@ -package com.github.libretube.preferences +package com.github.libretube.util import android.content.Context import android.content.SharedPreferences import androidx.preference.PreferenceManager import com.fasterxml.jackson.databind.ObjectMapper +import com.github.libretube.constants.PreferenceKeys object PreferenceHelper { /** diff --git a/app/src/main/java/com/github/libretube/util/ThemeHelper.kt b/app/src/main/java/com/github/libretube/util/ThemeHelper.kt index a36da50e4f..748e6c3811 100644 --- a/app/src/main/java/com/github/libretube/util/ThemeHelper.kt +++ b/app/src/main/java/com/github/libretube/util/ThemeHelper.kt @@ -12,8 +12,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatDelegate import androidx.core.text.HtmlCompat import com.github.libretube.R -import com.github.libretube.preferences.PreferenceHelper -import com.github.libretube.preferences.PreferenceKeys +import com.github.libretube.constants.PreferenceKeys import com.google.android.material.color.DynamicColors object ThemeHelper { diff --git a/app/src/main/java/com/github/libretube/views/MaterialPreferenceFragment.kt b/app/src/main/java/com/github/libretube/views/MaterialPreferenceFragment.kt index 0aefcd3a63..ce2a88a25f 100644 --- a/app/src/main/java/com/github/libretube/views/MaterialPreferenceFragment.kt +++ b/app/src/main/java/com/github/libretube/views/MaterialPreferenceFragment.kt @@ -7,7 +7,7 @@ import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat import com.github.libretube.R import com.github.libretube.databinding.DialogTextPreferenceBinding -import com.github.libretube.preferences.PreferenceHelper +import com.github.libretube.util.PreferenceHelper import com.google.android.material.dialog.MaterialAlertDialogBuilder /** From 0ab055303d53ccd00ae25dccc81c08e4aa79106b Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 8 Sep 2022 18:31:22 +0200 Subject: [PATCH 2/5] minor code improvements --- .../com/github/libretube/activities/MainActivity.kt | 12 +++++------- .../com/github/libretube/util/NotificationHelper.kt | 2 +- .../java/com/github/libretube/util/PlayerHelper.kt | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) 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 c2b4bbb3c6..a0cbaed354 100644 --- a/app/src/main/java/com/github/libretube/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/activities/MainActivity.kt @@ -167,15 +167,13 @@ class MainActivity : BaseActivity() { if (binding.mainMotionLayout.progress == 0F) { try { minimizePlayer() + return } catch (e: Exception) { - if (navController.currentDestination?.id == startFragmentId) { - // close app - moveTaskToBack(true) - } else { - navController.popBackStack() - } + // current fragment isn't the player fragment } - } else if (navController.currentDestination?.id == startFragmentId) { + } + + if (navController.currentDestination?.id == startFragmentId) { moveTaskToBack(true) } else { navController.popBackStack() 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 a0c855250e..100e84b18b 100644 --- a/app/src/main/java/com/github/libretube/util/NotificationHelper.kt +++ b/app/src/main/java/com/github/libretube/util/NotificationHelper.kt @@ -17,8 +17,8 @@ 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.constants.PreferenceKeys +import com.github.libretube.extensions.toID import kotlinx.coroutines.async import kotlinx.coroutines.runBlocking import java.util.concurrent.TimeUnit diff --git a/app/src/main/java/com/github/libretube/util/PlayerHelper.kt b/app/src/main/java/com/github/libretube/util/PlayerHelper.kt index a1543bec25..fb53e0ac57 100644 --- a/app/src/main/java/com/github/libretube/util/PlayerHelper.kt +++ b/app/src/main/java/com/github/libretube/util/PlayerHelper.kt @@ -2,8 +2,8 @@ package com.github.libretube.util import android.content.Context import android.view.accessibility.CaptioningManager -import com.github.libretube.obj.PipedStream import com.github.libretube.constants.PreferenceKeys +import com.github.libretube.obj.PipedStream import com.google.android.exoplayer2.ui.CaptionStyleCompat object PlayerHelper { From 24e888231735f1b8157dfdec9594b54b40f4d806 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 8 Sep 2022 18:32:20 +0200 Subject: [PATCH 3/5] bump version --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9a5e1cc8ee..ab5cf03131 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,8 +13,8 @@ android { applicationId 'com.github.libretube' minSdk 21 targetSdk 33 - versionCode 17 - versionName '0.5.0' + versionCode 18 + versionName '0.5.1' multiDexEnabled true testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' resValue "string", "app_name", "LibreTube" From 93ceef71cc1e8e02a6cac5d353c8de396361e3d9 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 8 Sep 2022 18:41:57 +0200 Subject: [PATCH 4/5] fix errors and warnings --- app/release/output-metadata.json | 36 +++++++++---------- .../libretube/activities/AboutActivity.kt | 12 +++---- .../libretube/activities/CommunityActivity.kt | 10 +++--- .../github/libretube/constants/Constants.kt | 2 +- .../com/github/libretube/db/DatabaseHolder.kt | 2 +- .../github/libretube/dialogs/ShareDialog.kt | 4 +-- .../libretube/dialogs/VideoOptionsDialog.kt | 2 +- .../libretube/services/BackgroundMode.kt | 4 +-- .../libretube/services/ClosingService.kt | 2 +- .../libretube/services/DownloadService.kt | 20 +++++++---- .../github/libretube/update/UpdateChecker.kt | 4 +-- .../libretube/util/NotificationHelper.kt | 4 +-- .../libretube/util/NowPlayingNotification.kt | 4 +-- 13 files changed, 56 insertions(+), 50 deletions(-) diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json index 07499f0c26..e288a78782 100644 --- a/app/release/output-metadata.json +++ b/app/release/output-metadata.json @@ -11,8 +11,8 @@ "type": "UNIVERSAL", "filters": [], "attributes": [], - "versionCode": 17, - "versionName": "0.5.0", + "versionCode": 18, + "versionName": "0.5.1", "outputFile": "app-universal-release.apk" }, { @@ -20,52 +20,52 @@ "filters": [ { "filterType": "ABI", - "value": "armeabi-v7a" + "value": "x86_64" } ], "attributes": [], - "versionCode": 17, - "versionName": "0.5.0", - "outputFile": "app-armeabi-v7a-release.apk" + "versionCode": 18, + "versionName": "0.5.1", + "outputFile": "app-x86_64-release.apk" }, { "type": "ONE_OF_MANY", "filters": [ { "filterType": "ABI", - "value": "x86" + "value": "armeabi-v7a" } ], "attributes": [], - "versionCode": 17, - "versionName": "0.5.0", - "outputFile": "app-x86-release.apk" + "versionCode": 18, + "versionName": "0.5.1", + "outputFile": "app-armeabi-v7a-release.apk" }, { "type": "ONE_OF_MANY", "filters": [ { "filterType": "ABI", - "value": "arm64-v8a" + "value": "x86" } ], "attributes": [], - "versionCode": 17, - "versionName": "0.5.0", - "outputFile": "app-arm64-v8a-release.apk" + "versionCode": 18, + "versionName": "0.5.1", + "outputFile": "app-x86-release.apk" }, { "type": "ONE_OF_MANY", "filters": [ { "filterType": "ABI", - "value": "x86_64" + "value": "arm64-v8a" } ], "attributes": [], - "versionCode": 17, - "versionName": "0.5.0", - "outputFile": "app-x86_64-release.apk" + "versionCode": 18, + "versionName": "0.5.1", + "outputFile": "app-arm64-v8a-release.apk" } ], "elementType": "File" 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 f2e7a514d6..f88bb349fa 100644 --- a/app/src/main/java/com/github/libretube/activities/AboutActivity.kt +++ b/app/src/main/java/com/github/libretube/activities/AboutActivity.kt @@ -8,13 +8,13 @@ import android.net.Uri import android.os.Build import android.os.Bundle import android.text.Html -import com.github.libretube.DONATE_URL -import com.github.libretube.GITHUB_URL -import com.github.libretube.LICENSE_URL -import com.github.libretube.PIPED_GITHUB_URL +import com.github.libretube.constants.DONATE_URL +import com.github.libretube.constants.GITHUB_URL +import com.github.libretube.constants.LICENSE_URL +import com.github.libretube.constants.PIPED_GITHUB_URL import com.github.libretube.R -import com.github.libretube.WEBLATE_URL -import com.github.libretube.WEBSITE_URL +import com.github.libretube.constants.WEBLATE_URL +import com.github.libretube.constants.WEBSITE_URL import com.github.libretube.databinding.ActivityAboutBinding import com.github.libretube.extensions.BaseActivity import com.github.libretube.extensions.getStyledSnackBar diff --git a/app/src/main/java/com/github/libretube/activities/CommunityActivity.kt b/app/src/main/java/com/github/libretube/activities/CommunityActivity.kt index 7fe9f2211c..d4d1f57e0a 100644 --- a/app/src/main/java/com/github/libretube/activities/CommunityActivity.kt +++ b/app/src/main/java/com/github/libretube/activities/CommunityActivity.kt @@ -3,11 +3,11 @@ package com.github.libretube.activities import android.content.Intent import android.net.Uri import android.os.Bundle -import com.github.libretube.DISCORD_URL -import com.github.libretube.MATRIX_URL -import com.github.libretube.REDDIT_URL -import com.github.libretube.TELEGRAM_URL -import com.github.libretube.TWITTER_URL +import com.github.libretube.constants.DISCORD_URL +import com.github.libretube.constants.MATRIX_URL +import com.github.libretube.constants.REDDIT_URL +import com.github.libretube.constants.TELEGRAM_URL +import com.github.libretube.constants.TWITTER_URL import com.github.libretube.databinding.ActivityCommunityBinding import com.github.libretube.extensions.BaseActivity diff --git a/app/src/main/java/com/github/libretube/constants/Constants.kt b/app/src/main/java/com/github/libretube/constants/Constants.kt index 9cb03468ff..51dde19c28 100644 --- a/app/src/main/java/com/github/libretube/constants/Constants.kt +++ b/app/src/main/java/com/github/libretube/constants/Constants.kt @@ -1,4 +1,4 @@ -package com.github.libretube +package com.github.libretube.constants /** * API link for the update checker diff --git a/app/src/main/java/com/github/libretube/db/DatabaseHolder.kt b/app/src/main/java/com/github/libretube/db/DatabaseHolder.kt index 2d92fdbcca..16e47e1f33 100644 --- a/app/src/main/java/com/github/libretube/db/DatabaseHolder.kt +++ b/app/src/main/java/com/github/libretube/db/DatabaseHolder.kt @@ -2,7 +2,7 @@ package com.github.libretube.db import android.content.Context import androidx.room.Room -import com.github.libretube.DATABASE_NAME +import com.github.libretube.constants.DATABASE_NAME object DatabaseHolder { lateinit var db: AppDatabase diff --git a/app/src/main/java/com/github/libretube/dialogs/ShareDialog.kt b/app/src/main/java/com/github/libretube/dialogs/ShareDialog.kt index 032343b9b2..7db97517f0 100644 --- a/app/src/main/java/com/github/libretube/dialogs/ShareDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/ShareDialog.kt @@ -4,9 +4,9 @@ import android.app.Dialog import android.content.Intent import android.os.Bundle import androidx.fragment.app.DialogFragment -import com.github.libretube.PIPED_FRONTEND_URL +import com.github.libretube.constants.PIPED_FRONTEND_URL import com.github.libretube.R -import com.github.libretube.YOUTUBE_FRONTEND_URL +import com.github.libretube.constants.YOUTUBE_FRONTEND_URL import com.github.libretube.constants.PreferenceKeys import com.github.libretube.databinding.DialogShareBinding import com.github.libretube.db.DatabaseHolder diff --git a/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt b/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt index 4b8700b5a6..f0f65cc7c3 100644 --- a/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt @@ -8,7 +8,7 @@ import android.widget.ArrayAdapter import android.widget.Toast import androidx.fragment.app.DialogFragment import com.github.libretube.Globals -import com.github.libretube.PLAYER_NOTIFICATION_ID +import com.github.libretube.constants.PLAYER_NOTIFICATION_ID import com.github.libretube.R import com.github.libretube.util.BackgroundHelper import com.github.libretube.util.PreferenceHelper 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 330b3c53db..da49f32951 100644 --- a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt +++ b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt @@ -11,9 +11,9 @@ import android.os.IBinder import android.os.Looper import android.widget.Toast import com.fasterxml.jackson.databind.ObjectMapper -import com.github.libretube.BACKGROUND_CHANNEL_ID +import com.github.libretube.constants.BACKGROUND_CHANNEL_ID import com.github.libretube.Globals -import com.github.libretube.PLAYER_NOTIFICATION_ID +import com.github.libretube.constants.PLAYER_NOTIFICATION_ID import com.github.libretube.R import com.github.libretube.api.RetrofitInstance import com.github.libretube.constants.PreferenceKeys diff --git a/app/src/main/java/com/github/libretube/services/ClosingService.kt b/app/src/main/java/com/github/libretube/services/ClosingService.kt index 20382b94a6..ad3f48a148 100644 --- a/app/src/main/java/com/github/libretube/services/ClosingService.kt +++ b/app/src/main/java/com/github/libretube/services/ClosingService.kt @@ -6,7 +6,7 @@ import android.content.Context import android.content.Intent import android.os.IBinder import androidx.annotation.Nullable -import com.github.libretube.PLAYER_NOTIFICATION_ID +import com.github.libretube.constants.PLAYER_NOTIFICATION_ID class ClosingService : Service() { diff --git a/app/src/main/java/com/github/libretube/services/DownloadService.kt b/app/src/main/java/com/github/libretube/services/DownloadService.kt index b405a7bb61..55d4933d7e 100644 --- a/app/src/main/java/com/github/libretube/services/DownloadService.kt +++ b/app/src/main/java/com/github/libretube/services/DownloadService.kt @@ -17,10 +17,10 @@ import android.os.IBinder import android.util.Log import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat -import com.github.libretube.DOWNLOAD_CHANNEL_ID -import com.github.libretube.DOWNLOAD_FAILURE_NOTIFICATION_ID -import com.github.libretube.DOWNLOAD_PENDING_NOTIFICATION_ID -import com.github.libretube.DOWNLOAD_SUCCESS_NOTIFICATION_ID +import com.github.libretube.constants.DOWNLOAD_CHANNEL_ID +import com.github.libretube.constants.DOWNLOAD_FAILURE_NOTIFICATION_ID +import com.github.libretube.constants.DOWNLOAD_PENDING_NOTIFICATION_ID +import com.github.libretube.constants.DOWNLOAD_SUCCESS_NOTIFICATION_ID import com.github.libretube.Globals import com.github.libretube.R import com.github.libretube.constants.PreferenceKeys @@ -180,8 +180,7 @@ class DownloadService : Service() { } private fun downloadNotification(intent: Intent) { - var pendingIntent: PendingIntent? = null - pendingIntent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + val pendingIntent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_MUTABLE) } else { PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT) @@ -234,7 +233,14 @@ class DownloadService : Service() { Globals.IS_DOWNLOAD_RUNNING = false Log.d(TAG(), "dl finished!") - stopForeground(true) + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + stopForeground(STOP_FOREGROUND_REMOVE) + } else { + @Suppress("DEPRECATION") + stopForeground(true) + } + stopService(Intent(this@DownloadService, DownloadService::class.java)) super.onDestroy() } diff --git a/app/src/main/java/com/github/libretube/update/UpdateChecker.kt b/app/src/main/java/com/github/libretube/update/UpdateChecker.kt index a2246d7d9a..693a50d15d 100644 --- a/app/src/main/java/com/github/libretube/update/UpdateChecker.kt +++ b/app/src/main/java/com/github/libretube/update/UpdateChecker.kt @@ -1,7 +1,7 @@ package com.github.libretube.update import com.fasterxml.jackson.databind.ObjectMapper -import com.github.libretube.GITHUB_API_URL +import com.github.libretube.constants.GITHUB_API_URL import com.github.libretube.extensions.await import java.net.URL @@ -9,7 +9,7 @@ object UpdateChecker { fun getLatestReleaseInfo(): UpdateInfo? { var versionInfo: UpdateInfo? = null // run http request as thread to make it async - val thread = Thread { + Thread { // otherwise crashes without internet versionInfo = getUpdateInfo() try { 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 100e84b18b..1d26770a71 100644 --- a/app/src/main/java/com/github/libretube/util/NotificationHelper.kt +++ b/app/src/main/java/com/github/libretube/util/NotificationHelper.kt @@ -11,8 +11,8 @@ import androidx.work.ExistingPeriodicWorkPolicy import androidx.work.NetworkType import androidx.work.PeriodicWorkRequest import androidx.work.WorkManager -import com.github.libretube.NOTIFICATION_WORK_NAME -import com.github.libretube.PUSH_CHANNEL_ID +import com.github.libretube.constants.NOTIFICATION_WORK_NAME +import com.github.libretube.constants.PUSH_CHANNEL_ID import com.github.libretube.R import com.github.libretube.activities.MainActivity import com.github.libretube.api.RetrofitInstance diff --git a/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt b/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt index 8b9ea2a5e5..84180bd2bb 100644 --- a/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt +++ b/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt @@ -7,8 +7,8 @@ import android.content.Intent import android.graphics.Bitmap import android.graphics.BitmapFactory import android.support.v4.media.session.MediaSessionCompat -import com.github.libretube.BACKGROUND_CHANNEL_ID -import com.github.libretube.PLAYER_NOTIFICATION_ID +import com.github.libretube.constants.BACKGROUND_CHANNEL_ID +import com.github.libretube.constants.PLAYER_NOTIFICATION_ID import com.github.libretube.activities.MainActivity import com.github.libretube.extensions.await import com.github.libretube.obj.Streams From 6ea46b8cb551bf0dab3b6287a0f96efdf73be543 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 8 Sep 2022 18:42:52 +0200 Subject: [PATCH 5/5] ktlint --- .../java/com/github/libretube/activities/AboutActivity.kt | 2 +- app/src/main/java/com/github/libretube/dialogs/ShareDialog.kt | 4 ++-- .../java/com/github/libretube/dialogs/VideoOptionsDialog.kt | 2 +- .../main/java/com/github/libretube/services/BackgroundMode.kt | 4 ++-- .../java/com/github/libretube/services/DownloadService.kt | 4 ++-- .../main/java/com/github/libretube/util/NotificationHelper.kt | 4 ++-- .../java/com/github/libretube/util/NowPlayingNotification.kt | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) 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 f88bb349fa..cf7132c673 100644 --- a/app/src/main/java/com/github/libretube/activities/AboutActivity.kt +++ b/app/src/main/java/com/github/libretube/activities/AboutActivity.kt @@ -8,11 +8,11 @@ import android.net.Uri import android.os.Build import android.os.Bundle import android.text.Html +import com.github.libretube.R import com.github.libretube.constants.DONATE_URL import com.github.libretube.constants.GITHUB_URL import com.github.libretube.constants.LICENSE_URL import com.github.libretube.constants.PIPED_GITHUB_URL -import com.github.libretube.R import com.github.libretube.constants.WEBLATE_URL import com.github.libretube.constants.WEBSITE_URL import com.github.libretube.databinding.ActivityAboutBinding diff --git a/app/src/main/java/com/github/libretube/dialogs/ShareDialog.kt b/app/src/main/java/com/github/libretube/dialogs/ShareDialog.kt index 7db97517f0..746aa25977 100644 --- a/app/src/main/java/com/github/libretube/dialogs/ShareDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/ShareDialog.kt @@ -4,10 +4,10 @@ import android.app.Dialog import android.content.Intent import android.os.Bundle import androidx.fragment.app.DialogFragment -import com.github.libretube.constants.PIPED_FRONTEND_URL import com.github.libretube.R -import com.github.libretube.constants.YOUTUBE_FRONTEND_URL +import com.github.libretube.constants.PIPED_FRONTEND_URL import com.github.libretube.constants.PreferenceKeys +import com.github.libretube.constants.YOUTUBE_FRONTEND_URL import com.github.libretube.databinding.DialogShareBinding import com.github.libretube.db.DatabaseHolder import com.github.libretube.db.obj.CustomInstance diff --git a/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt b/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt index f0f65cc7c3..8793146ec5 100644 --- a/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt @@ -8,8 +8,8 @@ import android.widget.ArrayAdapter import android.widget.Toast import androidx.fragment.app.DialogFragment import com.github.libretube.Globals -import com.github.libretube.constants.PLAYER_NOTIFICATION_ID import com.github.libretube.R +import com.github.libretube.constants.PLAYER_NOTIFICATION_ID import com.github.libretube.util.BackgroundHelper import com.github.libretube.util.PreferenceHelper import com.google.android.material.dialog.MaterialAlertDialogBuilder 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 da49f32951..e914b0bab7 100644 --- a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt +++ b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt @@ -11,11 +11,11 @@ import android.os.IBinder import android.os.Looper import android.widget.Toast import com.fasterxml.jackson.databind.ObjectMapper -import com.github.libretube.constants.BACKGROUND_CHANNEL_ID import com.github.libretube.Globals -import com.github.libretube.constants.PLAYER_NOTIFICATION_ID import com.github.libretube.R import com.github.libretube.api.RetrofitInstance +import com.github.libretube.constants.BACKGROUND_CHANNEL_ID +import com.github.libretube.constants.PLAYER_NOTIFICATION_ID import com.github.libretube.constants.PreferenceKeys import com.github.libretube.extensions.toID import com.github.libretube.obj.Segment diff --git a/app/src/main/java/com/github/libretube/services/DownloadService.kt b/app/src/main/java/com/github/libretube/services/DownloadService.kt index 55d4933d7e..8a2b24b264 100644 --- a/app/src/main/java/com/github/libretube/services/DownloadService.kt +++ b/app/src/main/java/com/github/libretube/services/DownloadService.kt @@ -17,12 +17,12 @@ import android.os.IBinder import android.util.Log import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat +import com.github.libretube.Globals +import com.github.libretube.R import com.github.libretube.constants.DOWNLOAD_CHANNEL_ID import com.github.libretube.constants.DOWNLOAD_FAILURE_NOTIFICATION_ID import com.github.libretube.constants.DOWNLOAD_PENDING_NOTIFICATION_ID import com.github.libretube.constants.DOWNLOAD_SUCCESS_NOTIFICATION_ID -import com.github.libretube.Globals -import com.github.libretube.R import com.github.libretube.constants.PreferenceKeys import com.github.libretube.extensions.TAG import com.github.libretube.obj.DownloadType 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 1d26770a71..9795427891 100644 --- a/app/src/main/java/com/github/libretube/util/NotificationHelper.kt +++ b/app/src/main/java/com/github/libretube/util/NotificationHelper.kt @@ -11,12 +11,12 @@ import androidx.work.ExistingPeriodicWorkPolicy import androidx.work.NetworkType import androidx.work.PeriodicWorkRequest import androidx.work.WorkManager -import com.github.libretube.constants.NOTIFICATION_WORK_NAME -import com.github.libretube.constants.PUSH_CHANNEL_ID 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.constants.NOTIFICATION_WORK_NAME +import com.github.libretube.constants.PUSH_CHANNEL_ID import com.github.libretube.constants.PreferenceKeys import com.github.libretube.extensions.toID import kotlinx.coroutines.async diff --git a/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt b/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt index 84180bd2bb..3ba76f9059 100644 --- a/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt +++ b/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt @@ -7,9 +7,9 @@ import android.content.Intent import android.graphics.Bitmap import android.graphics.BitmapFactory import android.support.v4.media.session.MediaSessionCompat +import com.github.libretube.activities.MainActivity import com.github.libretube.constants.BACKGROUND_CHANNEL_ID import com.github.libretube.constants.PLAYER_NOTIFICATION_ID -import com.github.libretube.activities.MainActivity import com.github.libretube.extensions.await import com.github.libretube.obj.Streams import com.google.android.exoplayer2.ExoPlayer