mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -6,10 +6,10 @@ import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.widget.EditText
|
||||
import androidx.activity.viewModels
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel
|
||||
import io.legado.app.R
|
||||
import io.legado.app.base.VMBaseActivity
|
||||
import io.legado.app.constant.AppConst
|
||||
import io.legado.app.data.entities.RssSource
|
||||
import io.legado.app.databinding.ActivityRssSourceEditBinding
|
||||
import io.legado.app.help.config.LocalConfig
|
||||
@@ -20,6 +20,7 @@ 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.keyboard.KeyboardToolPop
|
||||
import io.legado.app.utils.*
|
||||
@@ -31,6 +32,7 @@ class RssSourceEditActivity :
|
||||
|
||||
override val binding by viewBinding(ActivityRssSourceEditBinding::inflate)
|
||||
override val viewModel by viewModels<RssSourceEditViewModel>()
|
||||
private val urlOptionDialogState = mutableStateOf(false)
|
||||
private val softKeyboardTool by lazy {
|
||||
KeyboardToolPop(this, this, binding.root, this)
|
||||
}
|
||||
@@ -148,13 +150,11 @@ class RssSourceEditActivity :
|
||||
private fun initView() {
|
||||
binding.recyclerView.setEdgeEffectColor(primaryColor)
|
||||
binding.recyclerView.adapter = adapter
|
||||
// binding.composeView.setContent {
|
||||
// AppTheme {
|
||||
// UrlOptionDialog {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
binding.composeView.setContent {
|
||||
UrlOptionDialog(openState = urlOptionDialogState) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun upRecyclerView(source: RssSource? = viewModel.rssSource) {
|
||||
@@ -254,7 +254,7 @@ class RssSourceEditActivity :
|
||||
|
||||
override fun onHelpActionSelect(action: String) {
|
||||
when (action) {
|
||||
"urlOption" -> sendText(AppConst.urlOption)
|
||||
"urlOption" -> urlOptionDialogState.value = true
|
||||
"ruleHelp" -> showHelp("ruleHelp")
|
||||
"jsHelp" -> showHelp("jsHelp")
|
||||
"regexHelp" -> showHelp("regexHelp")
|
||||
|
||||
@@ -1,27 +1,46 @@
|
||||
package io.legado.app.ui.widget
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.AlertDialog
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import io.legado.app.ui.theme.AppTheme
|
||||
|
||||
|
||||
@Composable
|
||||
fun UrlOptionDialog(confirm: (String) -> Unit) {
|
||||
AlertDialog(
|
||||
onDismissRequest = {},
|
||||
confirmButton = {
|
||||
TextButton(onClick = {
|
||||
confirm.invoke("")
|
||||
}) {
|
||||
Text(text = "OK")
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = {}) { Text(text = "Cancel") }
|
||||
},
|
||||
title = {
|
||||
Text(text = "url参数")
|
||||
fun UrlOptionDialog(openState: MutableState<Boolean>, confirm: (String) -> Unit) {
|
||||
AppTheme {
|
||||
if (openState.value) {
|
||||
AlertDialog(
|
||||
onDismissRequest = {
|
||||
openState.value = false
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(onClick = {
|
||||
confirm.invoke("")
|
||||
}) {
|
||||
Text(text = "OK")
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = {
|
||||
openState.value = false
|
||||
}) { Text(text = "Cancel") }
|
||||
},
|
||||
title = {
|
||||
Text(text = "url参数")
|
||||
},
|
||||
text = {
|
||||
Column(Modifier.padding(12.dp)) {
|
||||
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package io.legado.app.utils
|
||||
|
||||
import android.content.res.Resources
|
||||
@@ -113,18 +115,21 @@ object ConvertUtils {
|
||||
}
|
||||
|
||||
val Int.dp: Int
|
||||
get() = android.util.TypedValue.applyDimension(
|
||||
android.util.TypedValue.COMPLEX_UNIT_DIP,
|
||||
this.toFloat(),
|
||||
Resources.getSystem().displayMetrics
|
||||
).toInt()
|
||||
get() = this.toFloat().dp.toInt()
|
||||
|
||||
val Int.sp: Int
|
||||
get() = android.util.TypedValue.applyDimension(
|
||||
android.util.TypedValue.COMPLEX_UNIT_SP,
|
||||
this.toFloat(),
|
||||
Resources.getSystem().displayMetrics
|
||||
).toInt()
|
||||
get() = this.toFloat().sp.toInt()
|
||||
|
||||
val Int.hexString: String
|
||||
get() = Integer.toHexString(this)
|
||||
get() = Integer.toHexString(this)
|
||||
|
||||
|
||||
val Float.dp: Float
|
||||
get() = android.util.TypedValue.applyDimension(
|
||||
android.util.TypedValue.COMPLEX_UNIT_DIP, this, Resources.getSystem().displayMetrics
|
||||
)
|
||||
|
||||
val Float.sp: Float
|
||||
get() = android.util.TypedValue.applyDimension(
|
||||
android.util.TypedValue.COMPLEX_UNIT_SP, this, Resources.getSystem().displayMetrics
|
||||
)
|
||||
@@ -1,16 +0,0 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package io.legado.app.utils
|
||||
|
||||
import android.content.res.Resources
|
||||
|
||||
val Float.dp: Float
|
||||
get() = android.util.TypedValue.applyDimension(
|
||||
android.util.TypedValue.COMPLEX_UNIT_DIP, this, Resources.getSystem().displayMetrics
|
||||
)
|
||||
|
||||
val Float.sp: Float
|
||||
get() = android.util.TypedValue.applyDimension(
|
||||
android.util.TypedValue.COMPLEX_UNIT_SP, this, Resources.getSystem().displayMetrics
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user