TV navigation improvements

This commit is contained in:
Blatzar 2022-08-16 00:24:27 +02:00
parent e68fda7d82
commit 309c2b828c
2 changed files with 16 additions and 0 deletions

View file

@ -1,5 +1,6 @@
package com.lagradost.cloudstream3.ui.settings.extensions package com.lagradost.cloudstream3.ui.settings.extensions
import android.content.ClipData
import android.content.ClipboardManager import android.content.ClipboardManager
import android.content.Context import android.content.Context
import android.content.DialogInterface import android.content.DialogInterface
@ -22,6 +23,7 @@ import com.lagradost.cloudstream3.mvvm.Some
import com.lagradost.cloudstream3.mvvm.observe import com.lagradost.cloudstream3.mvvm.observe
import com.lagradost.cloudstream3.plugins.RepositoryManager import com.lagradost.cloudstream3.plugins.RepositoryManager
import com.lagradost.cloudstream3.ui.result.setText import com.lagradost.cloudstream3.ui.result.setText
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
import com.lagradost.cloudstream3.utils.Coroutines.main import com.lagradost.cloudstream3.utils.Coroutines.main
@ -118,6 +120,15 @@ class ExtensionsFragment : Fragment() {
list_repositories?.setOnClickListener { list_repositories?.setOnClickListener {
openBrowser(PUBLIC_REPOSITORIES_LIST) openBrowser(PUBLIC_REPOSITORIES_LIST)
// Set clipboard on TV because the browser might not exist or work properly
if (it.context.isTvSettings()) {
val serviceClipboard =
(activity?.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager?)
?: return@setOnClickListener
val clip = ClipData.newPlainText("Repository url", PUBLIC_REPOSITORIES_LIST)
serviceClipboard.setPrimaryClip(clip)
}
} }
observe(extensionViewModel.pluginStats) { observe(extensionViewModel.pluginStats) {

View file

@ -47,12 +47,15 @@
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/list_repositories" android:id="@+id/list_repositories"
android:nextFocusDown="@id/add_repo_button"
style="@style/WhiteButton" style="@style/WhiteButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:text="@string/view_public_repositories_button" /> android:text="@string/view_public_repositories_button" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:foreground="@drawable/outline_drawable"
android:nextFocusUp="@id/add_repo_button"
android:id="@+id/plugin_storage_appbar" android:id="@+id/plugin_storage_appbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="80dp" android:layout_height="80dp"
@ -160,6 +163,8 @@
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/add_repo_button" android:id="@+id/add_repo_button"
android:nextFocusUp="@id/list_repositories"
android:nextFocusDown="@id/plugin_storage_appbar"
style="@style/ExtendedFloatingActionButton" style="@style/ExtendedFloatingActionButton"
android:text="@string/add_repository" android:text="@string/add_repository"
android:textColor="?attr/textColor" android:textColor="?attr/textColor"