From f860c7d3e2e8375e414d04be13db13cfd8a86d3a Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 6 Sep 2021 21:15:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/data/entities/rule/RowUi.kt | 1 + .../legado/app/ui/login/RuleUiLoginDialog.kt | 21 ++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/entities/rule/RowUi.kt b/app/src/main/java/io/legado/app/data/entities/rule/RowUi.kt index c61658594..85258c754 100644 --- a/app/src/main/java/io/legado/app/data/entities/rule/RowUi.kt +++ b/app/src/main/java/io/legado/app/data/entities/rule/RowUi.kt @@ -7,4 +7,5 @@ import kotlinx.parcelize.Parcelize data class RowUi( var name: String, var type: String, + var action: String? ) : Parcelable \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/login/RuleUiLoginDialog.kt b/app/src/main/java/io/legado/app/ui/login/RuleUiLoginDialog.kt index 5485ca07f..469bde7af 100644 --- a/app/src/main/java/io/legado/app/ui/login/RuleUiLoginDialog.kt +++ b/app/src/main/java/io/legado/app/ui/login/RuleUiLoginDialog.kt @@ -6,6 +6,8 @@ import android.text.InputType import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.TextView +import androidx.core.view.setPadding import androidx.fragment.app.activityViewModels import io.legado.app.R import io.legado.app.base.BaseDialogFragment @@ -13,10 +15,9 @@ import io.legado.app.databinding.DialogLoginBinding import io.legado.app.lib.theme.primaryColor import io.legado.app.ui.widget.text.EditText import io.legado.app.ui.widget.text.TextInputLayout -import io.legado.app.utils.GSON -import io.legado.app.utils.applyTint -import io.legado.app.utils.toastOnUi +import io.legado.app.utils.* import io.legado.app.utils.viewbindingdelegate.viewBinding +import splitties.views.onClick class RuleUiLoginDialog : BaseDialogFragment() { @@ -67,6 +68,20 @@ class RuleUiLoginDialog : BaseDialogFragment() { setText(loginInfo?.get(rowUi.name)) } } + "button" -> layoutInflater.inflate(R.layout.item_fillet_text, binding.root, false) + .let { + binding.listView.addView(it) + it.id = index + (it as TextView).let { textView -> + textView.text = rowUi.name + textView.setPadding(16.dp) + } + it.onClick { + if (rowUi.action.isAbsUrl()) { + context?.openUrl(rowUi.action!!) + } + } + } } } binding.toolBar.inflateMenu(R.menu.source_login)