@@ -11,6 +11,7 @@ import android.widget.ScrollView
1111import android.widget.Switch
1212import android.widget.TextView
1313import com.lagradost.cloudstream3.APIHolder
14+ import com.lagradost.cloudstream3.MainAPI
1415
1516class GuardSettingsDialog (
1617 private val context : Context ,
@@ -41,7 +42,7 @@ class GuardSettingsDialog(
4142
4243 var isGlobalStrict = current.blockAllUnknown
4344
44- val masterRow = createRow(" Global Strict Mode" , " Block ALL unknown external intents across the entire app. " , isGlobalStrict) { checked ->
45+ val masterRow = createRow(" Global Strict Mode ( Block All Unknown) " , isGlobalStrict) { checked ->
4546 isGlobalStrict = checked
4647 }
4748 container.addView(masterRow)
@@ -57,7 +58,16 @@ class GuardSettingsDialog(
5758 val blockedSet = AllowlistStore .blockedProviders().toMutableSet()
5859
5960 val providers = try {
60- APIHolder .allProviders.sortedBy { it.name }
61+ val getApisMethod = APIHolder ::class .java.methods.find {
62+ it.name == " getAllProviders" || it.name == " getApis" || it.name == " apis"
63+ }
64+ val apis = if (getApisMethod != null ) {
65+ getApisMethod.isAccessible = true
66+ getApisMethod.invoke(APIHolder ) as ? List <MainAPI > ? : emptyList()
67+ } else {
68+ APIHolder .allProviders
69+ }
70+ apis.sortedBy { it.name }
6171 } catch (_: Throwable ) { emptyList() }
6272
6373 if (providers.isEmpty()) {
@@ -67,7 +77,7 @@ class GuardSettingsDialog(
6777 })
6878 } else {
6979 providers.forEach { provider ->
70- val row = createRow(provider.name, " Plugin: ${provider.javaClass.simpleName} " , blockedSet.contains(provider.name)) { checked ->
80+ val row = createRow(provider.name, blockedSet.contains(provider.name)) { checked ->
7181 if (checked) blockedSet.add(provider.name) else blockedSet.remove(provider.name)
7282 }
7383 container.addView(row)
@@ -98,7 +108,7 @@ class GuardSettingsDialog(
98108 .show()
99109 }
100110
101- private fun createRow (title : String , subtitle : String , isChecked : Boolean , onToggle : (Boolean ) -> Unit ): LinearLayout {
111+ private fun createRow (title : String , isChecked : Boolean , onToggle : (Boolean ) -> Unit ): LinearLayout {
102112 val row = LinearLayout (context).apply {
103113 orientation = LinearLayout .HORIZONTAL
104114 gravity = Gravity .CENTER_VERTICAL
@@ -121,6 +131,7 @@ class GuardSettingsDialog(
121131 val textLayout = LinearLayout (context).apply {
122132 orientation = LinearLayout .VERTICAL
123133 layoutParams = LinearLayout .LayoutParams (0 , LinearLayout .LayoutParams .WRAP_CONTENT , 1f )
134+ gravity = Gravity .CENTER_VERTICAL
124135 }
125136
126137 val titleView = TextView (context).apply {
@@ -129,16 +140,8 @@ class GuardSettingsDialog(
129140 setTextColor(Color .WHITE )
130141 typeface = Typeface .DEFAULT_BOLD
131142 }
132-
133- val subtitleView = TextView (context).apply {
134- text = subtitle
135- textSize = 12f
136- setTextColor(Color .parseColor(" #888888" ))
137- setPadding(0 , 4 , 0 , 0 )
138- }
139143
140144 textLayout.addView(titleView)
141- textLayout.addView(subtitleView)
142145
143146 val toggle = Switch (context).apply {
144147 this .isChecked = isChecked
0 commit comments