From e71ea43a6edc6e3dcc98be84cafb12580d9de26f Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 2 Jun 2022 21:10:16 +0200 Subject: [PATCH 1/5] some folders --- .../main/java/com/github/libretube/BackgroundMode.kt | 1 + app/src/main/java/com/github/libretube/Home.kt | 1 + app/src/main/java/com/github/libretube/Library.kt | 2 ++ .../main/java/com/github/libretube/MainActivity.kt | 3 +++ .../java/com/github/libretube/SettingsActivity.kt | 2 ++ .../main/java/com/github/libretube/Subscriptions.kt | 1 + .../com/github/libretube/adapters/ChannelAdapter.kt | 2 +- .../com/github/libretube/adapters/PlaylistAdapter.kt | 6 +++--- .../com/github/libretube/adapters/PlaylistsAdapter.kt | 2 +- .../com/github/libretube/adapters/SearchAdapter.kt | 4 ++-- .../github/libretube/adapters/SubscriptionAdapter.kt | 4 ++-- .../com/github/libretube/adapters/TrendingAdapter.kt | 4 ++-- .../libretube/{ => dialogs}/AddtoPlaylistDialog.kt | 4 +++- .../libretube/{ => dialogs}/CreatePlaylistDialog.kt | 4 +++- .../github/libretube/{ => dialogs}/DownloadDialog.kt | 4 +++- .../com/github/libretube/{ => dialogs}/LoginDialog.kt | 4 +++- .../libretube/{ => dialogs}/VideoOptionsDialog.kt | 7 ++++--- .../libretube/{ => fragments}/ChannelFragment.kt | 5 ++++- .../libretube/{ => fragments}/PlayerFragment.kt | 11 ++++++++++- .../libretube/{ => fragments}/PlaylistFragment.kt | 4 +++- .../libretube/{ => fragments}/SearchFragment.kt | 5 ++++- .../libretube/{ => util}/CustomExoPlayerView.kt | 2 +- .../libretube/{ => util}/CustomSwipeToRefresh.kt | 2 +- .../java/com/github/libretube/{ => util}/PipedApi.kt | 2 +- .../com/github/libretube/{ => util}/ResettableLazy.kt | 2 +- .../github/libretube/{ => util}/RetrofitInstance.kt | 4 +++- .../{ => util}/SingleViewTouchableMotionLayout.kt | 3 ++- .../com/github/libretube/{ => util}/ThemeChanger.kt | 0 .../com/github/libretube/{ => util}/VideoViews.kt | 0 app/src/main/res/layout/activity_player.xml | 2 +- app/src/main/res/layout/fragment_channel.xml | 6 +++--- app/src/main/res/layout/fragment_library.xml | 4 ++-- app/src/main/res/layout/fragment_player.xml | 6 +++--- app/src/main/res/layout/fragment_playlist.xml | 2 +- app/src/main/res/layout/fragment_search.xml | 2 +- app/src/main/res/layout/fragment_subscriptions.xml | 4 ++-- app/src/main/res/navigation/nav.xml | 6 +++--- 37 files changed, 83 insertions(+), 44 deletions(-) rename app/src/main/java/com/github/libretube/{ => dialogs}/AddtoPlaylistDialog.kt (97%) rename app/src/main/java/com/github/libretube/{ => dialogs}/CreatePlaylistDialog.kt (97%) rename app/src/main/java/com/github/libretube/{ => dialogs}/DownloadDialog.kt (97%) rename app/src/main/java/com/github/libretube/{ => dialogs}/LoginDialog.kt (98%) rename app/src/main/java/com/github/libretube/{ => dialogs}/VideoOptionsDialog.kt (96%) rename app/src/main/java/com/github/libretube/{ => fragments}/ChannelFragment.kt (98%) rename app/src/main/java/com/github/libretube/{ => fragments}/PlayerFragment.kt (99%) rename app/src/main/java/com/github/libretube/{ => fragments}/PlaylistFragment.kt (97%) rename app/src/main/java/com/github/libretube/{ => fragments}/SearchFragment.kt (98%) rename app/src/main/java/com/github/libretube/{ => util}/CustomExoPlayerView.kt (95%) rename app/src/main/java/com/github/libretube/{ => util}/CustomSwipeToRefresh.kt (96%) rename app/src/main/java/com/github/libretube/{ => util}/PipedApi.kt (99%) rename app/src/main/java/com/github/libretube/{ => util}/ResettableLazy.kt (97%) rename app/src/main/java/com/github/libretube/{ => util}/RetrofitInstance.kt (77%) rename app/src/main/java/com/github/libretube/{ => util}/SingleViewTouchableMotionLayout.kt (98%) rename app/src/main/java/com/github/libretube/{ => util}/ThemeChanger.kt (100%) rename app/src/main/java/com/github/libretube/{ => util}/VideoViews.kt (100%) diff --git a/app/src/main/java/com/github/libretube/BackgroundMode.kt b/app/src/main/java/com/github/libretube/BackgroundMode.kt index 788d322e1..c85e4fd06 100644 --- a/app/src/main/java/com/github/libretube/BackgroundMode.kt +++ b/app/src/main/java/com/github/libretube/BackgroundMode.kt @@ -3,6 +3,7 @@ package com.github.libretube import android.content.Context import android.support.v4.media.session.MediaSessionCompat import com.github.libretube.obj.Streams +import com.github.libretube.util.RetrofitInstance 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/Home.kt b/app/src/main/java/com/github/libretube/Home.kt index 1d4fe93ab..9c78c562a 100644 --- a/app/src/main/java/com/github/libretube/Home.kt +++ b/app/src/main/java/com/github/libretube/Home.kt @@ -14,6 +14,7 @@ import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.github.libretube.adapters.TrendingAdapter +import com.github.libretube.util.RetrofitInstance import java.io.IOException import retrofit2.HttpException diff --git a/app/src/main/java/com/github/libretube/Library.kt b/app/src/main/java/com/github/libretube/Library.kt index df19f86f4..696dae7d0 100644 --- a/app/src/main/java/com/github/libretube/Library.kt +++ b/app/src/main/java/com/github/libretube/Library.kt @@ -16,6 +16,8 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.github.libretube.adapters.PlaylistsAdapter +import com.github.libretube.dialogs.CreatePlaylistDialog +import com.github.libretube.util.RetrofitInstance import java.io.IOException import retrofit2.HttpException diff --git a/app/src/main/java/com/github/libretube/MainActivity.kt b/app/src/main/java/com/github/libretube/MainActivity.kt index 4dea68660..791a23e86 100644 --- a/app/src/main/java/com/github/libretube/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/MainActivity.kt @@ -30,7 +30,10 @@ import androidx.navigation.NavController import androidx.navigation.findNavController import androidx.navigation.ui.setupWithNavController import androidx.preference.PreferenceManager +import com.github.libretube.fragments.PlayerFragment +import com.github.libretube.fragments.isFullScreen import com.github.libretube.util.CronetHelper +import com.github.libretube.util.RetrofitInstance import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.color.DynamicColors diff --git a/app/src/main/java/com/github/libretube/SettingsActivity.kt b/app/src/main/java/com/github/libretube/SettingsActivity.kt index a86d72fd6..8ac5f602e 100644 --- a/app/src/main/java/com/github/libretube/SettingsActivity.kt +++ b/app/src/main/java/com/github/libretube/SettingsActivity.kt @@ -27,6 +27,8 @@ import androidx.preference.ListPreference import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceManager +import com.github.libretube.dialogs.LoginDialog +import com.github.libretube.util.RetrofitInstance import com.google.android.material.color.DynamicColors import com.google.android.material.dialog.MaterialAlertDialogBuilder import java.io.IOException diff --git a/app/src/main/java/com/github/libretube/Subscriptions.kt b/app/src/main/java/com/github/libretube/Subscriptions.kt index e3111650e..bc26e717a 100644 --- a/app/src/main/java/com/github/libretube/Subscriptions.kt +++ b/app/src/main/java/com/github/libretube/Subscriptions.kt @@ -24,6 +24,7 @@ import androidx.recyclerview.widget.RecyclerView import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.github.libretube.adapters.SubscriptionAdapter import com.github.libretube.adapters.SubscriptionChannelAdapter +import com.github.libretube.util.RetrofitInstance import java.io.IOException import retrofit2.HttpException 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 e10853486..5b8f70bc8 100644 --- a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt @@ -9,9 +9,9 @@ import android.widget.ImageView import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.RecyclerView -import com.github.libretube.PlayerFragment import com.github.libretube.R import com.github.libretube.formatShort +import com.github.libretube.fragments.PlayerFragment import com.github.libretube.obj.StreamItem import com.squareup.picasso.Picasso 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 002aea271..3938ae50d 100644 --- a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt @@ -13,12 +13,12 @@ import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.FragmentManager import androidx.recyclerview.widget.RecyclerView -import com.github.libretube.PlayerFragment import com.github.libretube.R -import com.github.libretube.RetrofitInstance -import com.github.libretube.VideoOptionsDialog +import com.github.libretube.dialogs.VideoOptionsDialog +import com.github.libretube.fragments.PlayerFragment import com.github.libretube.obj.PlaylistId import com.github.libretube.obj.StreamItem +import com.github.libretube.util.RetrofitInstance import com.squareup.picasso.Picasso import java.io.IOException import kotlinx.coroutines.GlobalScope 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 d491d4c8a..9aa860f27 100644 --- a/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt @@ -12,9 +12,9 @@ import androidx.core.os.bundleOf import androidx.recyclerview.widget.RecyclerView import com.github.libretube.MainActivity import com.github.libretube.R -import com.github.libretube.RetrofitInstance import com.github.libretube.obj.PlaylistId import com.github.libretube.obj.Playlists +import com.github.libretube.util.RetrofitInstance import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.squareup.picasso.Picasso import java.io.IOException 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 45abc649f..ced50de1d 100644 --- a/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt @@ -12,10 +12,10 @@ import androidx.core.os.bundleOf import androidx.fragment.app.FragmentManager import androidx.recyclerview.widget.RecyclerView import com.github.libretube.MainActivity -import com.github.libretube.PlayerFragment import com.github.libretube.R -import com.github.libretube.VideoOptionsDialog +import com.github.libretube.dialogs.VideoOptionsDialog import com.github.libretube.formatShort +import com.github.libretube.fragments.PlayerFragment import com.github.libretube.obj.SearchItem import com.squareup.picasso.Picasso diff --git a/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt index 7bbbbc015..2d9e3b264 100644 --- a/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt @@ -13,10 +13,10 @@ import androidx.core.os.bundleOf import androidx.fragment.app.FragmentManager import androidx.recyclerview.widget.RecyclerView import com.github.libretube.MainActivity -import com.github.libretube.PlayerFragment import com.github.libretube.R -import com.github.libretube.VideoOptionsDialog +import com.github.libretube.dialogs.VideoOptionsDialog import com.github.libretube.formatShort +import com.github.libretube.fragments.PlayerFragment import com.github.libretube.obj.StreamItem import com.squareup.picasso.Picasso 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 62adbeb60..6845eeca5 100644 --- a/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt @@ -13,10 +13,10 @@ import androidx.core.os.bundleOf import androidx.fragment.app.FragmentManager import androidx.recyclerview.widget.RecyclerView import com.github.libretube.MainActivity -import com.github.libretube.PlayerFragment import com.github.libretube.R -import com.github.libretube.VideoOptionsDialog +import com.github.libretube.dialogs.VideoOptionsDialog import com.github.libretube.formatShort +import com.github.libretube.fragments.PlayerFragment import com.github.libretube.obj.StreamItem import com.squareup.picasso.Picasso diff --git a/app/src/main/java/com/github/libretube/AddtoPlaylistDialog.kt b/app/src/main/java/com/github/libretube/dialogs/AddtoPlaylistDialog.kt similarity index 97% rename from app/src/main/java/com/github/libretube/AddtoPlaylistDialog.kt rename to app/src/main/java/com/github/libretube/dialogs/AddtoPlaylistDialog.kt index 580087318..80453c14b 100644 --- a/app/src/main/java/com/github/libretube/AddtoPlaylistDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/AddtoPlaylistDialog.kt @@ -1,4 +1,4 @@ -package com.github.libretube +package com.github.libretube.dialogs import android.app.Dialog import android.content.Context @@ -15,7 +15,9 @@ import androidx.core.text.HtmlCompat import androidx.fragment.app.DialogFragment import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope +import com.github.libretube.R import com.github.libretube.obj.PlaylistId +import com.github.libretube.util.RetrofitInstance import com.google.android.material.dialog.MaterialAlertDialogBuilder import java.io.IOException import retrofit2.HttpException diff --git a/app/src/main/java/com/github/libretube/CreatePlaylistDialog.kt b/app/src/main/java/com/github/libretube/dialogs/CreatePlaylistDialog.kt similarity index 97% rename from app/src/main/java/com/github/libretube/CreatePlaylistDialog.kt rename to app/src/main/java/com/github/libretube/dialogs/CreatePlaylistDialog.kt index d355ddbce..6ebd8cd63 100644 --- a/app/src/main/java/com/github/libretube/CreatePlaylistDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/CreatePlaylistDialog.kt @@ -1,4 +1,4 @@ -package com.github.libretube +package com.github.libretube.dialogs import android.app.Dialog import android.content.Context @@ -14,7 +14,9 @@ import androidx.core.text.HtmlCompat import androidx.fragment.app.DialogFragment import androidx.fragment.app.setFragmentResult import androidx.lifecycle.lifecycleScope +import com.github.libretube.R import com.github.libretube.obj.Playlists +import com.github.libretube.util.RetrofitInstance import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.textfield.TextInputEditText import java.io.IOException diff --git a/app/src/main/java/com/github/libretube/DownloadDialog.kt b/app/src/main/java/com/github/libretube/dialogs/DownloadDialog.kt similarity index 97% rename from app/src/main/java/com/github/libretube/DownloadDialog.kt rename to app/src/main/java/com/github/libretube/dialogs/DownloadDialog.kt index 4d85e863d..99bf915a9 100644 --- a/app/src/main/java/com/github/libretube/DownloadDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/DownloadDialog.kt @@ -1,4 +1,4 @@ -package com.github.libretube +package com.github.libretube.dialogs import android.app.Dialog import android.content.Intent @@ -15,6 +15,8 @@ import android.widget.Spinner import android.widget.TextView import androidx.core.text.HtmlCompat import androidx.fragment.app.DialogFragment +import com.github.libretube.DownloadService +import com.github.libretube.R import com.google.android.material.dialog.MaterialAlertDialogBuilder class DownloadDialog : DialogFragment() { diff --git a/app/src/main/java/com/github/libretube/LoginDialog.kt b/app/src/main/java/com/github/libretube/dialogs/LoginDialog.kt similarity index 98% rename from app/src/main/java/com/github/libretube/LoginDialog.kt rename to app/src/main/java/com/github/libretube/dialogs/LoginDialog.kt index 8974c1511..ae27c5ca2 100644 --- a/app/src/main/java/com/github/libretube/LoginDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/LoginDialog.kt @@ -1,4 +1,4 @@ -package com.github.libretube +package com.github.libretube.dialogs import android.app.Dialog import android.content.Context @@ -13,7 +13,9 @@ import android.widget.Toast import androidx.core.text.HtmlCompat import androidx.fragment.app.DialogFragment import androidx.lifecycle.lifecycleScope +import com.github.libretube.R import com.github.libretube.obj.Login +import com.github.libretube.util.RetrofitInstance import com.google.android.material.dialog.MaterialAlertDialogBuilder import java.io.IOException import retrofit2.HttpException diff --git a/app/src/main/java/com/github/libretube/VideoOptionsDialog.kt b/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt similarity index 96% rename from app/src/main/java/com/github/libretube/VideoOptionsDialog.kt rename to app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt index 51e57fabc..95096c3d4 100644 --- a/app/src/main/java/com/github/libretube/VideoOptionsDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt @@ -1,4 +1,4 @@ -package com.github.libretube +package com.github.libretube.dialogs import android.app.Dialog import android.content.Context @@ -7,6 +7,8 @@ import android.os.Bundle import android.widget.ArrayAdapter import android.widget.Toast import androidx.fragment.app.DialogFragment +import com.github.libretube.BackgroundMode +import com.github.libretube.R import com.google.android.material.dialog.MaterialAlertDialogBuilder /** @@ -44,8 +46,7 @@ class VideoOptionsDialog(private val videoId: String, context: Context) : Dialog when (which) { // This for example will be the "Background mode" option 0 -> { - BackgroundMode - .getInstance() + BackgroundMode.getInstance() .playOnBackgroundMode(requireContext(), videoId, 0) } // Add Video to Playlist Dialog diff --git a/app/src/main/java/com/github/libretube/ChannelFragment.kt b/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt similarity index 98% rename from app/src/main/java/com/github/libretube/ChannelFragment.kt rename to app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt index 8d4e191cb..bf33cecf6 100644 --- a/app/src/main/java/com/github/libretube/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt @@ -1,4 +1,4 @@ -package com.github.libretube +package com.github.libretube.fragments import android.annotation.SuppressLint import android.content.Context @@ -15,8 +15,11 @@ import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.swiperefreshlayout.widget.SwipeRefreshLayout +import com.github.libretube.R import com.github.libretube.adapters.ChannelAdapter +import com.github.libretube.formatShort import com.github.libretube.obj.Subscribe +import com.github.libretube.util.RetrofitInstance import com.google.android.material.button.MaterialButton import com.squareup.picasso.Picasso import java.io.IOException diff --git a/app/src/main/java/com/github/libretube/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt similarity index 99% rename from app/src/main/java/com/github/libretube/PlayerFragment.kt rename to app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt index 4f86f9c53..6dde763d9 100644 --- a/app/src/main/java/com/github/libretube/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -1,4 +1,4 @@ -package com.github.libretube +package com.github.libretube.fragments import android.Manifest import android.annotation.SuppressLint @@ -44,14 +44,23 @@ import androidx.preference.PreferenceManager import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import com.github.libretube.IS_DOWNLOAD_RUNNING +import com.github.libretube.MainActivity +import com.github.libretube.R +import com.github.libretube.SponsorBlockSettings import com.github.libretube.adapters.CommentsAdapter import com.github.libretube.adapters.TrendingAdapter +import com.github.libretube.dialogs.AddtoPlaylistDialog +import com.github.libretube.dialogs.DownloadDialog +import com.github.libretube.formatShort +import com.github.libretube.hideKeyboard import com.github.libretube.obj.PipedStream import com.github.libretube.obj.Segment import com.github.libretube.obj.Segments import com.github.libretube.obj.Streams import com.github.libretube.obj.Subscribe import com.github.libretube.util.CronetHelper +import com.github.libretube.util.RetrofitInstance 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/PlaylistFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt similarity index 97% rename from app/src/main/java/com/github/libretube/PlaylistFragment.kt rename to app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt index 28f575e17..d40038aaa 100644 --- a/app/src/main/java/com/github/libretube/PlaylistFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt @@ -1,4 +1,4 @@ -package com.github.libretube +package com.github.libretube.fragments import android.content.Context import android.os.Bundle @@ -12,7 +12,9 @@ import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import com.github.libretube.R import com.github.libretube.adapters.PlaylistAdapter +import com.github.libretube.util.RetrofitInstance import java.io.IOException import retrofit2.HttpException diff --git a/app/src/main/java/com/github/libretube/SearchFragment.kt b/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt similarity index 98% rename from app/src/main/java/com/github/libretube/SearchFragment.kt rename to app/src/main/java/com/github/libretube/fragments/SearchFragment.kt index d2228beac..a5a2e6475 100644 --- a/app/src/main/java/com/github/libretube/SearchFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt @@ -1,4 +1,4 @@ -package com.github.libretube +package com.github.libretube.fragments import android.content.Context import android.content.DialogInterface @@ -24,8 +24,11 @@ import androidx.preference.PreferenceManager import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import com.github.libretube.R import com.github.libretube.adapters.SearchAdapter import com.github.libretube.adapters.SearchHistoryAdapter +import com.github.libretube.hideKeyboard +import com.github.libretube.util.RetrofitInstance import com.google.android.material.dialog.MaterialAlertDialogBuilder import java.io.IOException import kotlinx.coroutines.GlobalScope diff --git a/app/src/main/java/com/github/libretube/CustomExoPlayerView.kt b/app/src/main/java/com/github/libretube/util/CustomExoPlayerView.kt similarity index 95% rename from app/src/main/java/com/github/libretube/CustomExoPlayerView.kt rename to app/src/main/java/com/github/libretube/util/CustomExoPlayerView.kt index f51614bee..25ba13df8 100644 --- a/app/src/main/java/com/github/libretube/CustomExoPlayerView.kt +++ b/app/src/main/java/com/github/libretube/util/CustomExoPlayerView.kt @@ -1,4 +1,4 @@ -package com.github.libretube +package com.github.libretube.util import android.annotation.SuppressLint import android.content.Context diff --git a/app/src/main/java/com/github/libretube/CustomSwipeToRefresh.kt b/app/src/main/java/com/github/libretube/util/CustomSwipeToRefresh.kt similarity index 96% rename from app/src/main/java/com/github/libretube/CustomSwipeToRefresh.kt rename to app/src/main/java/com/github/libretube/util/CustomSwipeToRefresh.kt index c1402ab25..b71f587e3 100644 --- a/app/src/main/java/com/github/libretube/CustomSwipeToRefresh.kt +++ b/app/src/main/java/com/github/libretube/util/CustomSwipeToRefresh.kt @@ -1,4 +1,4 @@ -package com.github.libretube +package com.github.libretube.util import android.content.Context import android.util.AttributeSet diff --git a/app/src/main/java/com/github/libretube/PipedApi.kt b/app/src/main/java/com/github/libretube/util/PipedApi.kt similarity index 99% rename from app/src/main/java/com/github/libretube/PipedApi.kt rename to app/src/main/java/com/github/libretube/util/PipedApi.kt index 3576bd307..5a32e9d47 100644 --- a/app/src/main/java/com/github/libretube/PipedApi.kt +++ b/app/src/main/java/com/github/libretube/util/PipedApi.kt @@ -1,4 +1,4 @@ -package com.github.libretube +package com.github.libretube.util import com.github.libretube.obj.Channel import com.github.libretube.obj.CommentsPage diff --git a/app/src/main/java/com/github/libretube/ResettableLazy.kt b/app/src/main/java/com/github/libretube/util/ResettableLazy.kt similarity index 97% rename from app/src/main/java/com/github/libretube/ResettableLazy.kt rename to app/src/main/java/com/github/libretube/util/ResettableLazy.kt index dee0933a6..c4cabec62 100644 --- a/app/src/main/java/com/github/libretube/ResettableLazy.kt +++ b/app/src/main/java/com/github/libretube/util/ResettableLazy.kt @@ -1,6 +1,6 @@ package com.github.libretube -import java.util.LinkedList +import java.util.* import kotlin.reflect.KProperty class ResettableLazyManager { diff --git a/app/src/main/java/com/github/libretube/RetrofitInstance.kt b/app/src/main/java/com/github/libretube/util/RetrofitInstance.kt similarity index 77% rename from app/src/main/java/com/github/libretube/RetrofitInstance.kt rename to app/src/main/java/com/github/libretube/util/RetrofitInstance.kt index ae5f99931..ebc6b9f7c 100644 --- a/app/src/main/java/com/github/libretube/RetrofitInstance.kt +++ b/app/src/main/java/com/github/libretube/util/RetrofitInstance.kt @@ -1,5 +1,7 @@ -package com.github.libretube +package com.github.libretube.util +import com.github.libretube.resettableLazy +import com.github.libretube.resettableManager import retrofit2.Retrofit import retrofit2.converter.jackson.JacksonConverterFactory diff --git a/app/src/main/java/com/github/libretube/SingleViewTouchableMotionLayout.kt b/app/src/main/java/com/github/libretube/util/SingleViewTouchableMotionLayout.kt similarity index 98% rename from app/src/main/java/com/github/libretube/SingleViewTouchableMotionLayout.kt rename to app/src/main/java/com/github/libretube/util/SingleViewTouchableMotionLayout.kt index c3483f8b2..8ec436fd0 100644 --- a/app/src/main/java/com/github/libretube/SingleViewTouchableMotionLayout.kt +++ b/app/src/main/java/com/github/libretube/util/SingleViewTouchableMotionLayout.kt @@ -1,4 +1,4 @@ -package com.github.libretube +package com.github.libretube.util import android.content.Context import android.graphics.Rect @@ -7,6 +7,7 @@ import android.view.GestureDetector import android.view.MotionEvent import android.view.View import androidx.constraintlayout.motion.widget.MotionLayout +import com.github.libretube.R /** * diff --git a/app/src/main/java/com/github/libretube/ThemeChanger.kt b/app/src/main/java/com/github/libretube/util/ThemeChanger.kt similarity index 100% rename from app/src/main/java/com/github/libretube/ThemeChanger.kt rename to app/src/main/java/com/github/libretube/util/ThemeChanger.kt diff --git a/app/src/main/java/com/github/libretube/VideoViews.kt b/app/src/main/java/com/github/libretube/util/VideoViews.kt similarity index 100% rename from app/src/main/java/com/github/libretube/VideoViews.kt rename to app/src/main/java/com/github/libretube/util/VideoViews.kt diff --git a/app/src/main/res/layout/activity_player.xml b/app/src/main/res/layout/activity_player.xml index 1d61fdda8..aeddf4375 100644 --- a/app/src/main/res/layout/activity_player.xml +++ b/app/src/main/res/layout/activity_player.xml @@ -8,7 +8,7 @@ android:background="@color/black" > - - - + diff --git a/app/src/main/res/layout/fragment_library.xml b/app/src/main/res/layout/fragment_library.xml index d205de1a2..854d37966 100644 --- a/app/src/main/res/layout/fragment_library.xml +++ b/app/src/main/res/layout/fragment_library.xml @@ -33,7 +33,7 @@ android:textStyle="bold" /> - @@ -62,7 +62,7 @@ - + - - - + diff --git a/app/src/main/res/layout/fragment_playlist.xml b/app/src/main/res/layout/fragment_playlist.xml index a3dc253d3..c46a5178a 100644 --- a/app/src/main/res/layout/fragment_playlist.xml +++ b/app/src/main/res/layout/fragment_playlist.xml @@ -3,7 +3,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".PlaylistFragment" + tools:context=".fragments.PlaylistFragment" android:id="@+id/playlist_scrollview"> + tools:context=".fragments.SearchFragment"> - @@ -103,5 +103,5 @@ - + diff --git a/app/src/main/res/navigation/nav.xml b/app/src/main/res/navigation/nav.xml index eabf2f9bc..8ae1af75e 100644 --- a/app/src/main/res/navigation/nav.xml +++ b/app/src/main/res/navigation/nav.xml @@ -23,12 +23,12 @@ Date: Thu, 2 Jun 2022 21:40:36 +0200 Subject: [PATCH 2/5] seperated sharedialog --- .../github/libretube/dialogs/ShareDialog.kt | 41 +++++++++++++ .../libretube/dialogs/VideoOptionsDialog.kt | 43 +------------ .../libretube/fragments/PlayerFragment.kt | 60 +++++-------------- 3 files changed, 57 insertions(+), 87 deletions(-) create mode 100644 app/src/main/java/com/github/libretube/dialogs/ShareDialog.kt diff --git a/app/src/main/java/com/github/libretube/dialogs/ShareDialog.kt b/app/src/main/java/com/github/libretube/dialogs/ShareDialog.kt new file mode 100644 index 000000000..327eff80c --- /dev/null +++ b/app/src/main/java/com/github/libretube/dialogs/ShareDialog.kt @@ -0,0 +1,41 @@ +package com.github.libretube.dialogs + +import android.content.Context +import android.content.Intent +import androidx.preference.PreferenceManager +import com.github.libretube.R +import com.google.android.material.dialog.MaterialAlertDialogBuilder +import java.net.URLEncoder + +fun showShareDialog(context: Context, videoId: String) { + val sharedPreferences = + PreferenceManager.getDefaultSharedPreferences(context) + val instancePref = sharedPreferences.getString( + "instance", + "https://pipedapi.kavin.rocks" + )!! + val instance = "&instance=${URLEncoder.encode(instancePref, "UTF-8")}" + val shareOptions = arrayOf( + context.getString(R.string.piped), + context.getString(R.string.instance), + context.getString(R.string.youtube) + ) + MaterialAlertDialogBuilder(context) + .setTitle(context.getString(R.string.share)) + .setItems( + shareOptions + ) { _, id -> + val url = when (id) { + 0 -> "https://piped.kavin.rocks/watch?v=$videoId" + 1 -> "https://piped.kavin.rocks/watch?v=$videoId$instance" + 2 -> "https://youtu.be/$videoId" + else -> "https://piped.kavin.rocks/watch?v=$videoId" + } + val intent = Intent() + intent.action = Intent.ACTION_SEND + intent.putExtra(Intent.EXTRA_TEXT, url) + intent.type = "text/plain" + context.startActivity(Intent.createChooser(intent, "Share Url To:")) + } + .show() +} 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 95096c3d4..aa557fbf3 100644 --- a/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt @@ -2,7 +2,6 @@ package com.github.libretube.dialogs import android.app.Dialog import android.content.Context -import android.content.Intent import android.os.Bundle import android.widget.ArrayAdapter import android.widget.Toast @@ -67,47 +66,7 @@ class VideoOptionsDialog(private val videoId: String, context: Context) : Dialog } } 2 -> { - /* crashes - val sharedPreferences = - PreferenceManager.getDefaultSharedPreferences(requireContext()) - val instancePref = sharedPreferences.getString( - "instance", - "https://pipedapi.kavin.rocks" - )!! - val instance = "&instance=${URLEncoder.encode(instancePref, "UTF-8")}" - val shareOptions = arrayOf( - getString(R.string.piped), - getString(R.string.instance), - getString(R.string.youtube) - ) - MaterialAlertDialogBuilder(requireContext()) - .setTitle(getString(R.string.share)) - .setItems( - shareOptions - ) { _, id -> - val url = when (id) { - 0 -> "https://piped.kavin.rocks/watch?v=$videoId" - 1 -> "https://piped.kavin.rocks/watch?v=$videoId$instance" - 2 -> "https://youtu.be/$videoId" - else -> "https://piped.kavin.rocks/watch?v=$videoId" - } - dismiss() - val intent = Intent() - intent.action = Intent.ACTION_SEND - intent.putExtra(Intent.EXTRA_TEXT, url) - intent.type = "text/plain" - startActivity(Intent.createChooser(intent, "Share Url To:")) - } - .show() - */ - val intent = Intent() - intent.action = Intent.ACTION_SEND - intent.putExtra( - Intent.EXTRA_TEXT, - "https://piped.kavin.rocks/watch?v=$videoId" - ) - intent.type = "text/plain" - startActivity(Intent.createChooser(intent, "Share Url To:")) + showShareDialog(requireContext(), videoId) } else -> { dialog.dismiss() 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 6dde763d9..7d0c3ea00 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -52,6 +52,7 @@ import com.github.libretube.adapters.CommentsAdapter import com.github.libretube.adapters.TrendingAdapter import com.github.libretube.dialogs.AddtoPlaylistDialog import com.github.libretube.dialogs.DownloadDialog +import com.github.libretube.dialogs.showShareDialog import com.github.libretube.formatShort import com.github.libretube.hideKeyboard import com.github.libretube.obj.PipedStream @@ -83,12 +84,11 @@ import com.google.android.exoplayer2.util.RepeatModeUtil import com.google.android.material.button.MaterialButton import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.squareup.picasso.Picasso -import java.io.IOException -import java.net.URLEncoder -import java.util.concurrent.Executors -import kotlin.math.abs import org.chromium.net.CronetEngine import retrofit2.HttpException +import java.io.IOException +import java.util.concurrent.Executors +import kotlin.math.abs var isFullScreen = false @@ -419,6 +419,16 @@ class PlayerFragment : Fragment() { private fun initializePlayerView(view: View, response: Streams) { isLoading = false runOnUiThread { + createExoPlayer(view) + + exoPlayerView.setShowSubtitleButton(true) + exoPlayerView.setShowNextButton(false) + exoPlayerView.setShowPreviousButton(false) + exoPlayerView.setRepeatToggleModes(RepeatModeUtil.REPEAT_TOGGLE_MODE_ALL) + // exoPlayerView.controllerShowTimeoutMs = 1500 + exoPlayerView.controllerHideOnTouch = true + exoPlayerView.player = exoPlayer + var videosNameArray: Array = arrayOf() videosNameArray += "HLS" for (vid in response.videoStreams!!) { @@ -434,16 +444,6 @@ class PlayerFragment : Fragment() { .build() ) } - - createExoPlayer(view) - - exoPlayerView.setShowSubtitleButton(true) - exoPlayerView.setShowNextButton(false) - exoPlayerView.setShowPreviousButton(false) - exoPlayerView.setRepeatToggleModes(RepeatModeUtil.REPEAT_TOGGLE_MODE_ALL) - // exoPlayerView.controllerShowTimeoutMs = 1500 - exoPlayerView.controllerHideOnTouch = true - exoPlayerView.player = exoPlayer val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext()) val defres = sharedPreferences.getString("default_res", "")!! @@ -709,37 +709,7 @@ class PlayerFragment : Fragment() { } // share button view.findViewById(R.id.relPlayer_share).setOnClickListener { - val sharedPreferences = - PreferenceManager.getDefaultSharedPreferences(requireContext()) - val instancePref = sharedPreferences.getString( - "instance", - "https://pipedapi.kavin.rocks" - )!! - val instance = "&instance=${URLEncoder.encode(instancePref, "UTF-8")}" - val shareOptions = arrayOf( - getString(R.string.piped), - getString(R.string.instance), - getString(R.string.youtube) - ) - MaterialAlertDialogBuilder(requireContext()) - .setTitle(getString(R.string.share)) - .setItems( - shareOptions, - DialogInterface.OnClickListener { _, id -> - val url = when (id) { - 0 -> "https://piped.kavin.rocks/watch?v=$videoId" - 1 -> "https://piped.kavin.rocks/watch?v=$videoId$instance" - 2 -> "https://youtu.be/$videoId" - else -> "https://piped.kavin.rocks/watch?v=$videoId" - } - val intent = Intent() - intent.action = Intent.ACTION_SEND - intent.putExtra(Intent.EXTRA_TEXT, url) - intent.type = "text/plain" - startActivity(Intent.createChooser(intent, "Share Url To:")) - } - ) - .show() + showShareDialog(requireContext(), videoId!!) } // check if livestream if (response.duration!! > 0) { From c42fe30c1c9d734bace3f20ee28eb713bf4a1a1c Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 2 Jun 2022 21:58:36 +0200 Subject: [PATCH 3/5] for the merge --- .../github/libretube/{fragments => }/PlayerFragment.kt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) rename app/src/main/java/com/github/libretube/{fragments => }/PlayerFragment.kt (99%) diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/PlayerFragment.kt similarity index 99% rename from app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt rename to app/src/main/java/com/github/libretube/PlayerFragment.kt index 7d0c3ea00..11bd15353 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/PlayerFragment.kt @@ -1,4 +1,4 @@ -package com.github.libretube.fragments +package com.github.libretube import android.Manifest import android.annotation.SuppressLint @@ -44,17 +44,11 @@ import androidx.preference.PreferenceManager import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import com.github.libretube.IS_DOWNLOAD_RUNNING -import com.github.libretube.MainActivity -import com.github.libretube.R -import com.github.libretube.SponsorBlockSettings import com.github.libretube.adapters.CommentsAdapter import com.github.libretube.adapters.TrendingAdapter import com.github.libretube.dialogs.AddtoPlaylistDialog import com.github.libretube.dialogs.DownloadDialog import com.github.libretube.dialogs.showShareDialog -import com.github.libretube.formatShort -import com.github.libretube.hideKeyboard import com.github.libretube.obj.PipedStream import com.github.libretube.obj.Segment import com.github.libretube.obj.Segments From 82891432ec558d6b87ffe0fc095304233c3aa8a5 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 2 Jun 2022 22:03:36 +0200 Subject: [PATCH 4/5] merge master --- .../github/libretube/{ => fragments}/PlayerFragment.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) rename app/src/main/java/com/github/libretube/{ => fragments}/PlayerFragment.kt (99%) diff --git a/app/src/main/java/com/github/libretube/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt similarity index 99% rename from app/src/main/java/com/github/libretube/PlayerFragment.kt rename to app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt index 9b0db4c40..973b0f36b 100644 --- a/app/src/main/java/com/github/libretube/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -1,4 +1,4 @@ -package com.github.libretube +package com.github.libretube.fragments import android.Manifest import android.annotation.SuppressLint @@ -44,11 +44,17 @@ import androidx.preference.PreferenceManager import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import com.github.libretube.IS_DOWNLOAD_RUNNING +import com.github.libretube.MainActivity +import com.github.libretube.R +import com.github.libretube.SponsorBlockSettings import com.github.libretube.adapters.CommentsAdapter import com.github.libretube.adapters.TrendingAdapter import com.github.libretube.dialogs.AddtoPlaylistDialog import com.github.libretube.dialogs.DownloadDialog import com.github.libretube.dialogs.showShareDialog +import com.github.libretube.formatShort +import com.github.libretube.hideKeyboard import com.github.libretube.obj.PipedStream import com.github.libretube.obj.Segment import com.github.libretube.obj.Segments From 73276894f043f63f481fe9eef9ea6c631052b3ea Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 2 Jun 2022 22:06:09 +0200 Subject: [PATCH 5/5] ktlint --- .../java/com/github/libretube/fragments/PlayerFragment.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 973b0f36b..b0a529f3f 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -85,11 +85,11 @@ import com.google.android.exoplayer2.util.RepeatModeUtil import com.google.android.material.button.MaterialButton import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.squareup.picasso.Picasso -import org.chromium.net.CronetEngine -import retrofit2.HttpException import java.io.IOException import java.util.concurrent.Executors import kotlin.math.abs +import org.chromium.net.CronetEngine +import retrofit2.HttpException var isFullScreen = false