From 7cb4d327fdce743493898ad8fa4250cc32185755 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Tue, 7 Jun 2022 15:52:10 +0200 Subject: [PATCH 1/3] new about section in settings --- .../dialogs/UpdateAvailableDialog.kt | 35 +-- .../libretube/preferences/AboutFragment.kt | 70 ++++++ .../libretube/preferences/MainSettings.kt | 43 +--- .../github/libretube/util/UpdateChecker.kt | 11 +- app/src/main/res/layout/fragment_about.xml | 205 ++++++++++++++++++ app/src/main/res/values/strings.xml | 10 + app/src/main/res/xml/settings.xml | 11 +- 7 files changed, 328 insertions(+), 57 deletions(-) create mode 100644 app/src/main/java/com/github/libretube/preferences/AboutFragment.kt create mode 100644 app/src/main/res/layout/fragment_about.xml diff --git a/app/src/main/java/com/github/libretube/dialogs/UpdateAvailableDialog.kt b/app/src/main/java/com/github/libretube/dialogs/UpdateAvailableDialog.kt index aab997947..e5fe2cde5 100644 --- a/app/src/main/java/com/github/libretube/dialogs/UpdateAvailableDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/UpdateAvailableDialog.kt @@ -10,23 +10,32 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder class UpdateAvailableDialog( private val versionTag: String, - private val updateLink: String + private val updateLink: String, + private val updateAvailable: Boolean ) : DialogFragment() { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { return activity?.let { - MaterialAlertDialogBuilder(requireContext()) - .setTitle(context?.getString(R.string.update_available, versionTag)) - .setMessage(context?.getString(R.string.update_available_text)) - .setNegativeButton(context?.getString(R.string.cancel)) { _, _ -> - dismiss() - } - .setPositiveButton(context?.getString(R.string.okay)) { _, _ -> - val uri = Uri.parse(updateLink) - val intent = Intent(Intent.ACTION_VIEW).setData(uri) - startActivity(intent) - } - .show() + if (updateAvailable) { + MaterialAlertDialogBuilder(requireContext()) + .setTitle(context?.getString(R.string.update_available, versionTag)) + .setMessage(context?.getString(R.string.update_available_text)) + .setNegativeButton(context?.getString(R.string.cancel)) { _, _ -> + dismiss() + } + .setPositiveButton(context?.getString(R.string.okay)) { _, _ -> + val uri = Uri.parse(updateLink) + val intent = Intent(Intent.ACTION_VIEW).setData(uri) + startActivity(intent) + } + .show() + } else { + MaterialAlertDialogBuilder(requireContext()) + .setTitle(context?.getString(R.string.app_uptodate)) + .setMessage(context?.getString(R.string.no_update_available)) + .setPositiveButton(context?.getString(R.string.okay)) { _, _ -> } + .show() + } } ?: throw IllegalStateException("Activity cannot be null") } } diff --git a/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt b/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt new file mode 100644 index 000000000..d0560e7ee --- /dev/null +++ b/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt @@ -0,0 +1,70 @@ +package com.github.libretube.preferences + +import android.content.Intent +import android.net.Uri +import android.os.Build +import android.os.Bundle +import android.text.Html +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import androidx.fragment.app.Fragment +import com.github.libretube.BuildConfig +import com.github.libretube.R +import com.github.libretube.util.checkUpdate +import com.google.android.material.card.MaterialCardView +import com.google.android.material.dialog.MaterialAlertDialogBuilder + +class AboutFragment : Fragment() { + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + return inflater.inflate(R.layout.fragment_about, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + val appVersion = view?.findViewById(R.id.app_version) + appVersion.text = BuildConfig.VERSION_NAME + val website = view?.findViewById(R.id.website) + website?.setOnClickListener { + openLink("https://libre-tube.github.io/") + } + val donate = view?.findViewById(R.id.donate) + donate?.setOnClickListener { + openLink("https://libre-tube.github.io/#donate") + } + val contributing = view?.findViewById(R.id.contributing) + contributing?.setOnClickListener { + openLink("https://github.com/libre-tube/LibreTube") + } + val license = view.findViewById(R.id.license) + license?.setOnClickListener { + val licenseString = view?.context?.assets!! + .open("gpl3.html").bufferedReader().use { + it.readText() + } + val licenseHtml = if (Build.VERSION.SDK_INT >= 24) Html.fromHtml(licenseString, 1) + else Html.fromHtml(licenseString) + + MaterialAlertDialogBuilder(view?.context!!) + .setPositiveButton(getString(R.string.okay)) { _, _ -> } + .setMessage(licenseHtml) + .create() + .show() + true + } + val update = view.findViewById(R.id.update) + update?.setOnClickListener { + checkUpdate(childFragmentManager) + } + } + private fun openLink(link: String) { + val uri = Uri.parse(link) + val intent = Intent(Intent.ACTION_VIEW).setData(uri) + startActivity(intent) + } +} diff --git a/app/src/main/java/com/github/libretube/preferences/MainSettings.kt b/app/src/main/java/com/github/libretube/preferences/MainSettings.kt index 2bf372416..8ab101257 100644 --- a/app/src/main/java/com/github/libretube/preferences/MainSettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/MainSettings.kt @@ -3,12 +3,10 @@ package com.github.libretube.preferences import android.Manifest import android.content.ContentResolver import android.content.Context -import android.content.Intent import android.content.pm.PackageManager import android.net.Uri import android.os.Build import android.os.Bundle -import android.text.Html import android.text.TextUtils import android.util.Log import android.widget.Toast @@ -27,8 +25,6 @@ import com.github.libretube.isCurrentViewMainSettings import com.github.libretube.requireMainActivityRestart import com.github.libretube.util.RetrofitInstance import com.github.libretube.util.ThemeHelper -import com.github.libretube.util.checkUpdate -import com.google.android.material.dialog.MaterialAlertDialogBuilder import java.io.IOException import java.io.InputStream import java.util.zip.ZipEntry @@ -112,11 +108,6 @@ class MainSettings : PreferenceFragmentCompat() { } } super.onCreate(savedInstanceState) - try { - checkUpdate(childFragmentManager) - } catch (e: Exception) { - e.printStackTrace() - } } override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { @@ -186,6 +177,13 @@ class MainSettings : PreferenceFragmentCompat() { true } + val about = findPreference("about") + about?.setOnPreferenceClickListener { + val newFragment = AboutFragment() + navigateSettings(newFragment) + true + } + val importFromYt = findPreference("import_from_yt") importFromYt?.setOnPreferenceClickListener { val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE) @@ -238,34 +236,9 @@ class MainSettings : PreferenceFragmentCompat() { } true } - - val about = findPreference("about") - about?.setOnPreferenceClickListener { - val uri = Uri.parse("https://libre-tube.github.io/") - val intent = Intent(Intent.ACTION_VIEW).setData(uri) - startActivity(intent) - true - } - - val license = findPreference("license") - license?.setOnPreferenceClickListener { - val licenseString = view?.context?.assets!! - .open("gpl3.html").bufferedReader().use { - it.readText() - } - val licenseHtml = if (Build.VERSION.SDK_INT >= 24) Html.fromHtml(licenseString, 1) - else Html.fromHtml(licenseString) - - MaterialAlertDialogBuilder(view?.context!!) - .setPositiveButton(getString(R.string.okay)) { _, _ -> } - .setMessage(licenseHtml) - .create() - .show() - true - } } - private fun navigateSettings(newFragment: PreferenceFragmentCompat) { + private fun navigateSettings(newFragment: Fragment) { isCurrentViewMainSettings = false parentFragmentManager.beginTransaction() .replace(R.id.settings, newFragment) diff --git a/app/src/main/java/com/github/libretube/util/UpdateChecker.kt b/app/src/main/java/com/github/libretube/util/UpdateChecker.kt index 8b7b6f6b0..7f4db01f3 100644 --- a/app/src/main/java/com/github/libretube/util/UpdateChecker.kt +++ b/app/src/main/java/com/github/libretube/util/UpdateChecker.kt @@ -28,7 +28,16 @@ fun checkUpdate(childFragmentManager: FragmentManager) { if (updateInfo?.tagName != "" && BuildConfig.VERSION_NAME != updateInfo?.tagName) { val updateAvailableDialog = UpdateAvailableDialog( updateInfo?.tagName!!, - updateInfo?.updateUrl!! + updateInfo?.updateUrl!!, + true + ) + updateAvailableDialog.show(childFragmentManager, "UpdateDialog") + } else { + // otherwise show the no update available dialog + val updateAvailableDialog = UpdateAvailableDialog( + updateInfo?.tagName!!, + updateInfo?.updateUrl!!, + false ) updateAvailableDialog.show(childFragmentManager, "UpdateAvailableDialog") } diff --git a/app/src/main/res/layout/fragment_about.xml b/app/src/main/res/layout/fragment_about.xml new file mode 100644 index 000000000..d3e02c735 --- /dev/null +++ b/app/src/main/res/layout/fragment_about.xml @@ -0,0 +1,205 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ae1373aa6..f73990d14 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -125,4 +125,14 @@ The video format downloaded videos get converted to (only applies if both, audio and video, are downloaded). Download directory The directory where your downloaded media gets stored. + Visit our website to learn more about the app and its features. + Contributing + Whether you have ideas, translations, design changes, code cleaning, or real heavy code changes, help is always welcome. The more is done the better it gets! + The GNU General Public License is a free, copyleft license for software and other kinds of works. + Donate + If you like the app and appreciate our work we\'d be happy about a donation. + App update + Click here to check whether there\'s a new app update available. + App up to date + There\'s currently no new update available. Stay tuned! \ No newline at end of file diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml index d9ef825ac..50651364e 100644 --- a/app/src/main/res/xml/settings.xml +++ b/app/src/main/res/xml/settings.xml @@ -79,17 +79,12 @@ - + - - + android:icon="@drawable/ic_info" /> From 00a33bc5251e0bb33f344d56f6c0887589ed34de Mon Sep 17 00:00:00 2001 From: Bnyro Date: Tue, 7 Jun 2022 15:59:02 +0200 Subject: [PATCH 2/3] lint --- .../com/github/libretube/DownloadService.kt | 1 - .../main/java/com/github/libretube/Home.kt | 2 +- .../main/java/com/github/libretube/Library.kt | 2 +- .../com/github/libretube/Subscriptions.kt | 2 +- .../libretube/adapters/PlaylistAdapter.kt | 2 +- .../libretube/adapters/PlaylistsAdapter.kt | 2 +- .../adapters/SubscriptionChannelAdapter.kt | 2 +- .../libretube/dialogs/AddtoPlaylistDialog.kt | 2 +- .../libretube/dialogs/CreatePlaylistDialog.kt | 2 +- .../github/libretube/dialogs/LoginDialog.kt | 2 +- .../libretube/fragments/ChannelFragment.kt | 2 +- .../libretube/fragments/PlayerFragment.kt | 4 +- .../libretube/fragments/PlaylistFragment.kt | 2 +- .../libretube/fragments/SearchFragment.kt | 2 +- .../libretube/preferences/AboutFragment.kt | 1 + .../libretube/preferences/MainSettings.kt | 6 +- .../github/libretube/util/UpdateChecker.kt | 4 +- .../main/res/drawable/ic_file_download.xml | 2 +- app/src/main/res/layout/fragment_about.xml | 288 +++++++++--------- 19 files changed, 165 insertions(+), 165 deletions(-) diff --git a/app/src/main/java/com/github/libretube/DownloadService.kt b/app/src/main/java/com/github/libretube/DownloadService.kt index 04d221be0..ca659b718 100644 --- a/app/src/main/java/com/github/libretube/DownloadService.kt +++ b/app/src/main/java/com/github/libretube/DownloadService.kt @@ -5,7 +5,6 @@ import android.app.PendingIntent import android.app.Service import android.content.BroadcastReceiver import android.content.Context -import android.content.Context.DOWNLOAD_SERVICE import android.content.Intent import android.content.IntentFilter import android.net.Uri diff --git a/app/src/main/java/com/github/libretube/Home.kt b/app/src/main/java/com/github/libretube/Home.kt index aeea5434f..7493daf9c 100644 --- a/app/src/main/java/com/github/libretube/Home.kt +++ b/app/src/main/java/com/github/libretube/Home.kt @@ -16,8 +16,8 @@ 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 +import java.io.IOException class Home : Fragment() { diff --git a/app/src/main/java/com/github/libretube/Library.kt b/app/src/main/java/com/github/libretube/Library.kt index dd9029832..ed79ff73d 100644 --- a/app/src/main/java/com/github/libretube/Library.kt +++ b/app/src/main/java/com/github/libretube/Library.kt @@ -17,8 +17,8 @@ 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 +import java.io.IOException class Library : Fragment() { diff --git a/app/src/main/java/com/github/libretube/Subscriptions.kt b/app/src/main/java/com/github/libretube/Subscriptions.kt index 56ee74638..c8b853a7f 100644 --- a/app/src/main/java/com/github/libretube/Subscriptions.kt +++ b/app/src/main/java/com/github/libretube/Subscriptions.kt @@ -26,8 +26,8 @@ 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 +import java.io.IOException class Subscriptions : Fragment() { val TAG = "SubFragment" 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 3938ae50d..4397101cb 100644 --- a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt @@ -20,10 +20,10 @@ 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 import kotlinx.coroutines.launch import retrofit2.HttpException +import java.io.IOException class PlaylistAdapter( private val videoFeed: MutableList, 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 9aa860f27..049e6565b 100644 --- a/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt @@ -17,10 +17,10 @@ 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 import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import retrofit2.HttpException +import java.io.IOException class PlaylistsAdapter( private val playlists: MutableList, diff --git a/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt index ca8c24bef..fb06eda1b 100644 --- a/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt @@ -15,11 +15,11 @@ import com.github.libretube.obj.Subscribe import com.github.libretube.obj.Subscription import com.github.libretube.util.RetrofitInstance import com.squareup.picasso.Picasso -import java.io.IOException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import retrofit2.HttpException +import java.io.IOException class SubscriptionChannelAdapter(private val subscriptions: MutableList) : RecyclerView.Adapter() { 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 80453c14b..126bdd7e0 100644 --- a/app/src/main/java/com/github/libretube/dialogs/AddtoPlaylistDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/AddtoPlaylistDialog.kt @@ -19,8 +19,8 @@ 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 +import java.io.IOException class AddtoPlaylistDialog : DialogFragment() { private val TAG = "AddToPlaylistDialog" 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 d33cf90ee..000bf1897 100644 --- a/app/src/main/java/com/github/libretube/dialogs/CreatePlaylistDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/CreatePlaylistDialog.kt @@ -19,8 +19,8 @@ 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 import retrofit2.HttpException +import java.io.IOException class CreatePlaylistDialog : DialogFragment() { val TAG = "CreatePlaylistDialog" 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 ae27c5ca2..8d1cc33f8 100644 --- a/app/src/main/java/com/github/libretube/dialogs/LoginDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/LoginDialog.kt @@ -17,8 +17,8 @@ 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 +import java.io.IOException class LoginDialog : DialogFragment() { private val TAG = "LoginDialog" diff --git a/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt b/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt index bf33cecf6..61ea05aa1 100644 --- a/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt @@ -22,8 +22,8 @@ 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 import retrofit2.HttpException +import java.io.IOException class ChannelFragment : Fragment() { 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 d3130372c..ae254af78 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -82,11 +82,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 diff --git a/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt index d40038aaa..efdebacaf 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt @@ -15,8 +15,8 @@ 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 +import java.io.IOException class PlaylistFragment : Fragment() { private var playlist_id: String? = null diff --git a/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt b/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt index fd7a36619..3c23723ac 100644 --- a/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt @@ -30,11 +30,11 @@ 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 import kotlinx.coroutines.delay import kotlinx.coroutines.launch import retrofit2.HttpException +import java.io.IOException class SearchFragment : Fragment() { private val TAG = "SearchFragment" diff --git a/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt b/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt index d0560e7ee..33d205b51 100644 --- a/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt +++ b/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt @@ -62,6 +62,7 @@ class AboutFragment : Fragment() { checkUpdate(childFragmentManager) } } + private fun openLink(link: String) { val uri = Uri.parse(link) val intent = Intent(Intent.ACTION_VIEW).setData(uri) diff --git a/app/src/main/java/com/github/libretube/preferences/MainSettings.kt b/app/src/main/java/com/github/libretube/preferences/MainSettings.kt index 8ab101257..3b1eea437 100644 --- a/app/src/main/java/com/github/libretube/preferences/MainSettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/MainSettings.kt @@ -25,13 +25,13 @@ import com.github.libretube.isCurrentViewMainSettings import com.github.libretube.requireMainActivityRestart import com.github.libretube.util.RetrofitInstance import com.github.libretube.util.ThemeHelper +import org.json.JSONObject +import org.json.JSONTokener +import retrofit2.HttpException import java.io.IOException import java.io.InputStream import java.util.zip.ZipEntry import java.util.zip.ZipInputStream -import org.json.JSONObject -import org.json.JSONTokener -import retrofit2.HttpException class MainSettings : PreferenceFragmentCompat() { val TAG = "SettingsFragment" diff --git a/app/src/main/java/com/github/libretube/util/UpdateChecker.kt b/app/src/main/java/com/github/libretube/util/UpdateChecker.kt index 7f4db01f3..127e65e3b 100644 --- a/app/src/main/java/com/github/libretube/util/UpdateChecker.kt +++ b/app/src/main/java/com/github/libretube/util/UpdateChecker.kt @@ -4,12 +4,12 @@ import android.util.Log import androidx.fragment.app.FragmentManager import com.github.libretube.BuildConfig import com.github.libretube.dialogs.UpdateAvailableDialog +import org.json.JSONArray +import org.json.JSONObject import java.io.BufferedReader import java.io.InputStreamReader import java.net.URL import javax.net.ssl.HttpsURLConnection -import org.json.JSONArray -import org.json.JSONObject fun checkUpdate(childFragmentManager: FragmentManager) { var updateInfo: UpdateInfo? = UpdateInfo("", "") diff --git a/app/src/main/res/drawable/ic_file_download.xml b/app/src/main/res/drawable/ic_file_download.xml index 9c298875d..abbd2ec20 100644 --- a/app/src/main/res/drawable/ic_file_download.xml +++ b/app/src/main/res/drawable/ic_file_download.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" - android:tint="?attr/colorControlNormal" > + android:tint="?attr/colorControlNormal"> diff --git a/app/src/main/res/layout/fragment_about.xml b/app/src/main/res/layout/fragment_about.xml index d3e02c735..a89a526d2 100644 --- a/app/src/main/res/layout/fragment_about.xml +++ b/app/src/main/res/layout/fragment_about.xml @@ -9,196 +9,196 @@ android:layout_height="match_parent" android:orientation="vertical"> - + - + - + - - - + android:layout_marginHorizontal="10dp" + android:layout_marginBottom="16dp" + android:padding="20dp" + app:cardCornerRadius="16dp"> - + android:layout_height="wrap_content" + android:orientation="vertical"> - + - + - + - + - + android:layout_marginHorizontal="10dp" + android:layout_marginBottom="16dp" + android:padding="20dp" + app:cardCornerRadius="16dp"> - + android:layout_height="wrap_content" + android:orientation="vertical"> - + - + - + - + - + android:layout_marginHorizontal="10dp" + android:layout_marginBottom="16dp" + android:padding="20dp" + app:cardCornerRadius="16dp"> - + android:layout_height="wrap_content" + android:orientation="vertical"> - + - + - + - + - + android:layout_marginHorizontal="10dp" + android:layout_marginBottom="16dp" + android:padding="20dp" + app:cardCornerRadius="16dp"> - + android:layout_height="wrap_content" + android:orientation="vertical"> - + - + - + - + - + android:layout_marginHorizontal="10dp" + android:layout_marginBottom="20dp" + android:padding="20dp" + app:cardCornerRadius="16dp"> - + android:layout_height="wrap_content" + android:orientation="vertical"> - + - + - + + + From f870cc765cded09ad61931be327a447b8462c7b4 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Tue, 7 Jun 2022 16:00:51 +0200 Subject: [PATCH 3/3] ktlint --- app/src/main/java/com/github/libretube/Home.kt | 2 +- app/src/main/java/com/github/libretube/Library.kt | 2 +- app/src/main/java/com/github/libretube/Subscriptions.kt | 2 +- .../java/com/github/libretube/adapters/PlaylistAdapter.kt | 2 +- .../java/com/github/libretube/adapters/PlaylistsAdapter.kt | 2 +- .../github/libretube/adapters/SubscriptionChannelAdapter.kt | 2 +- .../com/github/libretube/dialogs/AddtoPlaylistDialog.kt | 2 +- .../com/github/libretube/dialogs/CreatePlaylistDialog.kt | 2 +- .../main/java/com/github/libretube/dialogs/LoginDialog.kt | 2 +- .../java/com/github/libretube/fragments/ChannelFragment.kt | 2 +- .../java/com/github/libretube/fragments/PlayerFragment.kt | 4 ++-- .../java/com/github/libretube/fragments/PlaylistFragment.kt | 2 +- .../java/com/github/libretube/fragments/SearchFragment.kt | 2 +- .../java/com/github/libretube/preferences/MainSettings.kt | 6 +++--- .../main/java/com/github/libretube/util/UpdateChecker.kt | 4 ++-- 15 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/github/libretube/Home.kt b/app/src/main/java/com/github/libretube/Home.kt index 7493daf9c..aeea5434f 100644 --- a/app/src/main/java/com/github/libretube/Home.kt +++ b/app/src/main/java/com/github/libretube/Home.kt @@ -16,8 +16,8 @@ import androidx.recyclerview.widget.RecyclerView import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.github.libretube.adapters.TrendingAdapter import com.github.libretube.util.RetrofitInstance -import retrofit2.HttpException import java.io.IOException +import retrofit2.HttpException class Home : Fragment() { diff --git a/app/src/main/java/com/github/libretube/Library.kt b/app/src/main/java/com/github/libretube/Library.kt index ed79ff73d..dd9029832 100644 --- a/app/src/main/java/com/github/libretube/Library.kt +++ b/app/src/main/java/com/github/libretube/Library.kt @@ -17,8 +17,8 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.github.libretube.adapters.PlaylistsAdapter import com.github.libretube.dialogs.CreatePlaylistDialog import com.github.libretube.util.RetrofitInstance -import retrofit2.HttpException import java.io.IOException +import retrofit2.HttpException class Library : Fragment() { diff --git a/app/src/main/java/com/github/libretube/Subscriptions.kt b/app/src/main/java/com/github/libretube/Subscriptions.kt index c8b853a7f..56ee74638 100644 --- a/app/src/main/java/com/github/libretube/Subscriptions.kt +++ b/app/src/main/java/com/github/libretube/Subscriptions.kt @@ -26,8 +26,8 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.github.libretube.adapters.SubscriptionAdapter import com.github.libretube.adapters.SubscriptionChannelAdapter import com.github.libretube.util.RetrofitInstance -import retrofit2.HttpException import java.io.IOException +import retrofit2.HttpException class Subscriptions : Fragment() { val TAG = "SubFragment" 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 4397101cb..3938ae50d 100644 --- a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt @@ -20,10 +20,10 @@ 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 import kotlinx.coroutines.launch import retrofit2.HttpException -import java.io.IOException class PlaylistAdapter( private val videoFeed: MutableList, 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 049e6565b..9aa860f27 100644 --- a/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt @@ -17,10 +17,10 @@ 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 import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import retrofit2.HttpException -import java.io.IOException class PlaylistsAdapter( private val playlists: MutableList, diff --git a/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt index fb06eda1b..ca8c24bef 100644 --- a/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt @@ -15,11 +15,11 @@ import com.github.libretube.obj.Subscribe import com.github.libretube.obj.Subscription import com.github.libretube.util.RetrofitInstance import com.squareup.picasso.Picasso +import java.io.IOException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import retrofit2.HttpException -import java.io.IOException class SubscriptionChannelAdapter(private val subscriptions: MutableList) : RecyclerView.Adapter() { 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 126bdd7e0..80453c14b 100644 --- a/app/src/main/java/com/github/libretube/dialogs/AddtoPlaylistDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/AddtoPlaylistDialog.kt @@ -19,8 +19,8 @@ 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 retrofit2.HttpException import java.io.IOException +import retrofit2.HttpException class AddtoPlaylistDialog : DialogFragment() { private val TAG = "AddToPlaylistDialog" 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 000bf1897..d33cf90ee 100644 --- a/app/src/main/java/com/github/libretube/dialogs/CreatePlaylistDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/CreatePlaylistDialog.kt @@ -19,8 +19,8 @@ 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 retrofit2.HttpException import java.io.IOException +import retrofit2.HttpException class CreatePlaylistDialog : DialogFragment() { val TAG = "CreatePlaylistDialog" 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 8d1cc33f8..ae27c5ca2 100644 --- a/app/src/main/java/com/github/libretube/dialogs/LoginDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/LoginDialog.kt @@ -17,8 +17,8 @@ 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 retrofit2.HttpException import java.io.IOException +import retrofit2.HttpException class LoginDialog : DialogFragment() { private val TAG = "LoginDialog" diff --git a/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt b/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt index 61ea05aa1..bf33cecf6 100644 --- a/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt @@ -22,8 +22,8 @@ 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 retrofit2.HttpException import java.io.IOException +import retrofit2.HttpException class ChannelFragment : Fragment() { 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 ae254af78..d3130372c 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -82,11 +82,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 diff --git a/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt index efdebacaf..d40038aaa 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt @@ -15,8 +15,8 @@ import androidx.recyclerview.widget.RecyclerView import com.github.libretube.R import com.github.libretube.adapters.PlaylistAdapter import com.github.libretube.util.RetrofitInstance -import retrofit2.HttpException import java.io.IOException +import retrofit2.HttpException class PlaylistFragment : Fragment() { private var playlist_id: String? = null diff --git a/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt b/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt index 3c23723ac..fd7a36619 100644 --- a/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt @@ -30,11 +30,11 @@ 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 import kotlinx.coroutines.delay import kotlinx.coroutines.launch import retrofit2.HttpException -import java.io.IOException class SearchFragment : Fragment() { private val TAG = "SearchFragment" diff --git a/app/src/main/java/com/github/libretube/preferences/MainSettings.kt b/app/src/main/java/com/github/libretube/preferences/MainSettings.kt index 3b1eea437..8ab101257 100644 --- a/app/src/main/java/com/github/libretube/preferences/MainSettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/MainSettings.kt @@ -25,13 +25,13 @@ import com.github.libretube.isCurrentViewMainSettings import com.github.libretube.requireMainActivityRestart import com.github.libretube.util.RetrofitInstance import com.github.libretube.util.ThemeHelper -import org.json.JSONObject -import org.json.JSONTokener -import retrofit2.HttpException import java.io.IOException import java.io.InputStream import java.util.zip.ZipEntry import java.util.zip.ZipInputStream +import org.json.JSONObject +import org.json.JSONTokener +import retrofit2.HttpException class MainSettings : PreferenceFragmentCompat() { val TAG = "SettingsFragment" diff --git a/app/src/main/java/com/github/libretube/util/UpdateChecker.kt b/app/src/main/java/com/github/libretube/util/UpdateChecker.kt index 127e65e3b..7f4db01f3 100644 --- a/app/src/main/java/com/github/libretube/util/UpdateChecker.kt +++ b/app/src/main/java/com/github/libretube/util/UpdateChecker.kt @@ -4,12 +4,12 @@ import android.util.Log import androidx.fragment.app.FragmentManager import com.github.libretube.BuildConfig import com.github.libretube.dialogs.UpdateAvailableDialog -import org.json.JSONArray -import org.json.JSONObject import java.io.BufferedReader import java.io.InputStreamReader import java.net.URL import javax.net.ssl.HttpsURLConnection +import org.json.JSONArray +import org.json.JSONObject fun checkUpdate(childFragmentManager: FragmentManager) { var updateInfo: UpdateInfo? = UpdateInfo("", "")