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/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/VideoOptionsDialog.kt b/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt similarity index 54% 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..aa557fbf3 100644 --- a/app/src/main/java/com/github/libretube/VideoOptionsDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt @@ -1,12 +1,13 @@ -package com.github.libretube +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 import androidx.fragment.app.DialogFragment +import com.github.libretube.BackgroundMode +import com.github.libretube.R import com.google.android.material.dialog.MaterialAlertDialogBuilder /** @@ -44,8 +45,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 @@ -66,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/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 96% rename from app/src/main/java/com/github/libretube/PlayerFragment.kt rename to app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt index 801adf9e7..b0a529f3f 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,24 @@ 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 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 @@ -76,7 +86,6 @@ 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 @@ -423,6 +432,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!!) { @@ -438,16 +457,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", "")!! @@ -713,37 +722,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) { 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 @@