mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -20,8 +20,8 @@ import io.legado.app.ui.document.HandleFileContract
|
||||
import io.legado.app.ui.login.SourceLoginActivity
|
||||
import io.legado.app.ui.qrcode.QrCodeResult
|
||||
import io.legado.app.ui.rss.source.debug.RssSourceDebugActivity
|
||||
import io.legado.app.ui.widget.UrlOptionDialog
|
||||
import io.legado.app.ui.widget.dialog.TextDialog
|
||||
import io.legado.app.ui.widget.dialog.UrlOptionDialog
|
||||
import io.legado.app.ui.widget.keyboard.KeyboardToolPop
|
||||
import io.legado.app.utils.*
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
@@ -254,7 +254,7 @@ class RssSourceEditActivity :
|
||||
|
||||
override fun onHelpActionSelect(action: String) {
|
||||
when (action) {
|
||||
"urlOption" -> urlOptionDialogState.value = true
|
||||
"urlOption" -> UrlOptionDialog(this).show()
|
||||
"ruleHelp" -> showHelp("ruleHelp")
|
||||
"jsHelp" -> showHelp("jsHelp")
|
||||
"regexHelp" -> showHelp("regexHelp")
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package io.legado.app.ui.widget
|
||||
package io.legado.app.ui.widget.dialog
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.wrapContentSize
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
@@ -12,17 +14,37 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import io.legado.app.R
|
||||
import io.legado.app.databinding.DialogUrlOptionEditBinding
|
||||
import io.legado.app.model.analyzeRule.AnalyzeUrl
|
||||
import io.legado.app.ui.theme.AppTheme
|
||||
import io.legado.app.ui.widget.checkbox.LabelledCheckBox
|
||||
import io.legado.app.utils.GSON
|
||||
import io.legado.app.utils.setLayout
|
||||
import splitties.init.appCtx
|
||||
|
||||
class UrlOptionDialog(context: Context) : AlertDialog(context) {
|
||||
|
||||
val binding = DialogUrlOptionEditBinding.inflate(layoutInflater)
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
setLayout(1f, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(binding.root)
|
||||
binding.tvOk.setOnClickListener {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
fun UrlOptionDialog(openState: MutableState<Boolean>, confirm: (String) -> Unit) {
|
||||
@@ -50,12 +72,7 @@ fun UrlOptionDialog(openState: MutableState<Boolean>, confirm: (String) -> Unit)
|
||||
Text(text = "url参数")
|
||||
},
|
||||
text = {
|
||||
Surface(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.wrapContentSize(align = Alignment.Center),
|
||||
color = MaterialTheme.colors.background
|
||||
) {
|
||||
Surface() {
|
||||
UrlOptionView(urlOption = urlOption)
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
package io.legado.app.utils
|
||||
|
||||
import android.app.Dialog
|
||||
import android.view.WindowManager
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import io.legado.app.lib.theme.Selector
|
||||
import io.legado.app.lib.theme.ThemeStore
|
||||
import io.legado.app.lib.theme.filletBackground
|
||||
import splitties.systemservices.windowManager
|
||||
|
||||
fun AlertDialog.applyTint(): AlertDialog {
|
||||
window?.setBackgroundDrawable(context.filletBackground)
|
||||
@@ -30,29 +32,45 @@ fun AlertDialog.requestInputMethod() {
|
||||
}
|
||||
|
||||
fun DialogFragment.setLayout(widthMix: Float, heightMix: Float) {
|
||||
val dm = requireActivity().windowManager.windowSize
|
||||
dialog?.window?.setLayout(
|
||||
dialog?.setLayout(widthMix, heightMix)
|
||||
}
|
||||
|
||||
fun Dialog.setLayout(widthMix: Float, heightMix: Float) {
|
||||
val dm = context.windowManager.windowSize
|
||||
window?.setLayout(
|
||||
(dm.widthPixels * widthMix).toInt(),
|
||||
(dm.heightPixels * heightMix).toInt()
|
||||
)
|
||||
}
|
||||
|
||||
fun DialogFragment.setLayout(width: Int, heightMix: Float) {
|
||||
val dm = requireActivity().windowManager.windowSize
|
||||
dialog?.window?.setLayout(
|
||||
dialog?.setLayout(width, heightMix)
|
||||
}
|
||||
|
||||
fun Dialog.setLayout(width: Int, heightMix: Float) {
|
||||
val dm = context.windowManager.windowSize
|
||||
window?.setLayout(
|
||||
width,
|
||||
(dm.heightPixels * heightMix).toInt()
|
||||
)
|
||||
}
|
||||
|
||||
fun DialogFragment.setLayout(widthMix: Float, height: Int) {
|
||||
val dm = requireActivity().windowManager.windowSize
|
||||
dialog?.window?.setLayout(
|
||||
dialog?.setLayout(widthMix, height)
|
||||
}
|
||||
|
||||
fun Dialog.setLayout(widthMix: Float, height: Int) {
|
||||
val dm = context.windowManager.windowSize
|
||||
window?.setLayout(
|
||||
(dm.widthPixels * widthMix).toInt(),
|
||||
height
|
||||
)
|
||||
}
|
||||
|
||||
fun DialogFragment.setLayout(width: Int, height: Int) {
|
||||
dialog?.window?.setLayout(width, height)
|
||||
dialog?.setLayout(width, height)
|
||||
}
|
||||
|
||||
fun Dialog.setLayout(width: Int, height: Int) {
|
||||
window?.setLayout(width, height)
|
||||
}
|
||||
158
app/src/main/res/layout/dialog_url_option_edit.xml
Normal file
158
app/src/main/res/layout/dialog_url_option_edit.xml
Normal file
@@ -0,0 +1,158 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="10dp"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Url参数"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_ok"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="12dp"
|
||||
android:text="@string/ok"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:overScrollMode="ifContentScrolls">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<io.legado.app.lib.theme.view.ThemeCheckBox
|
||||
android:id="@+id/cb_use_web_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="useWebView"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<io.legado.app.ui.widget.text.TextInputLayout
|
||||
android:id="@+id/layout_method"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<io.legado.app.ui.widget.text.AutoCompleteTextView
|
||||
android:id="@+id/edit_method"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="method"
|
||||
tools:ignore="HardcodedText,SpeakableTextPresentCheck,TouchTargetSizeCheck" />
|
||||
|
||||
</io.legado.app.ui.widget.text.TextInputLayout>
|
||||
|
||||
<io.legado.app.ui.widget.text.TextInputLayout
|
||||
android:id="@+id/layout_charset"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<io.legado.app.ui.widget.text.AutoCompleteTextView
|
||||
android:id="@+id/edit_charset"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="charset"
|
||||
tools:ignore="HardcodedText,SpeakableTextPresentCheck,TouchTargetSizeCheck" />
|
||||
|
||||
</io.legado.app.ui.widget.text.TextInputLayout>
|
||||
|
||||
<io.legado.app.ui.widget.text.TextInputLayout
|
||||
android:id="@+id/layout_headers"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<io.legado.app.ui.widget.text.AutoCompleteTextView
|
||||
android:id="@+id/edit_headers"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="headers"
|
||||
tools:ignore="HardcodedText,SpeakableTextPresentCheck,TouchTargetSizeCheck" />
|
||||
|
||||
</io.legado.app.ui.widget.text.TextInputLayout>
|
||||
|
||||
<io.legado.app.ui.widget.text.TextInputLayout
|
||||
android:id="@+id/layout_body"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<io.legado.app.ui.widget.text.AutoCompleteTextView
|
||||
android:id="@+id/edit_body"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="body"
|
||||
tools:ignore="HardcodedText,SpeakableTextPresentCheck,TouchTargetSizeCheck" />
|
||||
|
||||
</io.legado.app.ui.widget.text.TextInputLayout>
|
||||
|
||||
<io.legado.app.ui.widget.text.TextInputLayout
|
||||
android:id="@+id/layout_retry"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<io.legado.app.ui.widget.text.AutoCompleteTextView
|
||||
android:id="@+id/edit_retry"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="retry"
|
||||
android:inputType="number"
|
||||
tools:ignore="HardcodedText,SpeakableTextPresentCheck,TouchTargetSizeCheck" />
|
||||
|
||||
</io.legado.app.ui.widget.text.TextInputLayout>
|
||||
|
||||
<io.legado.app.ui.widget.text.TextInputLayout
|
||||
android:id="@+id/layout_web_js"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<io.legado.app.ui.widget.text.AutoCompleteTextView
|
||||
android:id="@+id/edit_web_js"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="webJs"
|
||||
tools:ignore="HardcodedText,SpeakableTextPresentCheck,TouchTargetSizeCheck" />
|
||||
|
||||
</io.legado.app.ui.widget.text.TextInputLayout>
|
||||
|
||||
<io.legado.app.ui.widget.text.TextInputLayout
|
||||
android:id="@+id/layout_js"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<io.legado.app.ui.widget.text.AutoCompleteTextView
|
||||
android:id="@+id/edit_js"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="js"
|
||||
tools:ignore="HardcodedText,SpeakableTextPresentCheck,TouchTargetSizeCheck" />
|
||||
|
||||
</io.legado.app.ui.widget.text.TextInputLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
Reference in New Issue
Block a user