From b345dff6986b6de4f55f87ad9265c1da812854b4 Mon Sep 17 00:00:00 2001 From: kraptor123 Date: Sun, 12 Jul 2026 20:45:22 +0300 Subject: [PATCH] feat: add settings button to provider selection in home --- .../cloudstream3/ui/home/HomeFragment.kt | 24 ++++++++++++- .../sort_bottom_single_provider_choice.xml | 34 ++++++++++++++----- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt index b68ef59625c..68e6ffe120b 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt @@ -24,6 +24,8 @@ import androidx.core.view.isVisible import androidx.fragment.app.activityViewModels import androidx.preference.PreferenceManager import androidx.recyclerview.widget.RecyclerView +import com.lagradost.cloudstream3.plugins.PluginManager +import com.lagradost.cloudstream3.CloudStreamApp.Companion.getActivity import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.chip.Chip @@ -43,6 +45,7 @@ import com.lagradost.cloudstream3.mvvm.Resource import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.mvvm.observe import com.lagradost.cloudstream3.mvvm.observeNullable +import com.lagradost.cloudstream3.plugins.Plugin import com.lagradost.cloudstream3.ui.APIRepository.Companion.noneApi import com.lagradost.cloudstream3.ui.APIRepository.Companion.randomApi import com.lagradost.cloudstream3.ui.BaseFragment @@ -424,11 +427,30 @@ class HomeFragment : BaseFragment( .inflate(R.layout.sort_bottom_single_provider_choice, parent, false) val titleText = view.findViewById(R.id.text1) val pinIcon = view.findViewById(R.id.pinicon) + val settingsIcon = view.findViewById(R.id.action_settings) + val name = getItem(position) titleText?.text = name + val providerApi = currentValidApis[position] val isPinned = - pinnedphashset.contains(currentValidApis[position].name) + pinnedphashset.contains(providerApi.name) pinIcon.visibility = if (isPinned) View.VISIBLE else View.GONE + + val pluginInstance = providerApi.sourcePlugin?.let { PluginManager.plugins[it] } as? Plugin + val isDownloadedPluginWithSettings = pluginInstance?.openSettings != null && !isLayout(TV) + + settingsIcon.visibility = if (isDownloadedPluginWithSettings) View.VISIBLE else View.GONE + if (isDownloadedPluginWithSettings) { + settingsIcon.setOnClickListener { + try { + val activityContext = it.context.getActivity() ?: it.context + pluginInstance.openSettings?.invoke(activityContext) + } catch (e: Throwable) { + logError(e) + } + } + } + return view } } diff --git a/app/src/main/res/layout/sort_bottom_single_provider_choice.xml b/app/src/main/res/layout/sort_bottom_single_provider_choice.xml index 657e2f2b87c..ea778c48860 100644 --- a/app/src/main/res/layout/sort_bottom_single_provider_choice.xml +++ b/app/src/main/res/layout/sort_bottom_single_provider_choice.xml @@ -10,13 +10,31 @@ style="@style/CheckLabel" android:layout_gravity="center" tools:text="hello" /> - + android:orientation="horizontal"> + + + + + \ No newline at end of file