Lets try with tags :)

This commit is contained in:
Blatzar 2022-08-18 19:21:50 +02:00
parent 4726f99f37
commit ca915ebc7e
3 changed files with 26 additions and 34 deletions

View file

@ -5,7 +5,7 @@ dependencies {
}
// use an integer for version numbers
version = 4
version = 5
cloudstream {
@ -30,8 +30,3 @@ cloudstream {
)
requiresResources = true
}
android {
buildFeatures {
viewBinding = true
}
}

View file

@ -4,6 +4,9 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.lagradost.cloudstream3.AcraApplication.Companion.openBrowser
import com.lagradost.cloudstream3.R.drawable.nginx
@ -12,13 +15,10 @@ import com.lagradost.cloudstream3.R.string.*
import com.lagradost.cloudstream3.plugins.Plugin
import com.lagradost.cloudstream3.ui.settings.SettingsAccount.Companion.showLoginInfo
import com.lagradost.cloudstream3.ui.settings.SettingsAccount.Companion.addAccount
import com.lagradost.databinding.NginxSettingsBinding
class NginxSettingsFragment(private val plugin: Plugin, val nginxApi: NginxApi) :
BottomSheetDialogFragment() {
private lateinit var binding: NginxSettingsBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
@ -30,34 +30,31 @@ class NginxSettingsFragment(private val plugin: Plugin, val nginxApi: NginxApi)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
binding = NginxSettingsBinding.inflate(layoutInflater)
super.onViewCreated(view, savedInstanceState)
// val infoView = view.findViewById<LinearLayout>(R.id.nginx_info)
// val infoTextView = view.findViewById<TextView>(R.id.info_main_text)
// val infoSubTextView = view.findViewById<TextView>(R.id.info_sub_text)
// val infoImageView = view.findViewById<ImageView>(R.id.nginx_info_imageview)
val infoView = view.findViewWithTag<LinearLayout>("nginx_info")
val infoTextView = view.findViewWithTag<TextView>("info_main_text")
val infoSubTextView = view.findViewWithTag<TextView>("info_sub_text")
val infoImageView = view.findViewWithTag<ImageView>("nginx_info_imageview")
binding.infoMainText.text = getString(nginx_info_title)
binding.infoSubText.text = getString(nginx_info_summary)
binding.nginxInfoImageview.setImageResource(nginx_question)
infoTextView.text = getString(nginx_info_title)
infoSubTextView.text = getString(nginx_info_summary)
infoImageView.setImageResource(nginx_question)
// val loginView = view.findViewById<LinearLayout>(R.id.nginx_login)
// val loginTextView = view.findViewById<TextView>(R.id.main_text)
// val loginImageView = view.findViewById<ImageView>(R.id.nginx_login_imageview)
binding.nginxLoginImageview.setImageResource(nginx)
val loginView = view.findViewWithTag<LinearLayout>("nginx_login")
val loginTextView = view.findViewWithTag<TextView>("main_text")
val loginImageView = view.findViewWithTag<ImageView>("nginx_login_imageview")
loginImageView.setImageResource(nginx)
// object : View.OnClickListener is required to make it compile because otherwise it used invoke-customs
binding.nginxInfo.setOnClickListener(object : View.OnClickListener {
infoView.setOnClickListener(object : View.OnClickListener {
override fun onClick(v: View?) {
openBrowser(nginxApi.createAccountUrl)
}
})
binding.mainText.text = getString(login_format).format(nginxApi.name, getString(account))
binding.nginxLogin.setOnClickListener(object : View.OnClickListener {
loginTextView.text = getString(login_format).format(nginxApi.name, getString(account))
loginView.setOnClickListener(object : View.OnClickListener {
override fun onClick(v: View?) {
val info = nginxApi.loginInfo()
if (info != null) {

View file

@ -2,20 +2,20 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/settings_root"
android:tag="@+id/settings_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/nginx_login"
android:tag="@+id/nginx_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="20dp">
<ImageView
android:id="@+id/nginx_login_imageview"
android:tag="@+id/nginx_login_imageview"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="start|center_vertical"
@ -34,7 +34,7 @@
<!-- android:orientation="horizontal">-->
<TextView
android:id="@+id/main_text"
android:tag="@+id/main_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp" />
@ -51,14 +51,14 @@
<LinearLayout
android:id="@+id/nginx_info"
android:tag="@+id/nginx_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="20dp">
<ImageView
android:id="@+id/nginx_info_imageview"
android:tag="@+id/nginx_info_imageview"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="start|center_vertical"
@ -77,14 +77,14 @@
android:orientation="horizontal">
<TextView
android:id="@+id/info_main_text"
android:tag="@+id/info_main_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp" />
</LinearLayout>
<TextView
android:id="@+id/info_sub_text"
android:tag="@+id/info_sub_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp" />