多语言机翻

This commit is contained in:
coldmint 2022-07-09 19:26:28 +08:00
parent 15ace14a26
commit 0d153622cb
21 changed files with 2762 additions and 787 deletions

Binary file not shown.

View File

@ -20,6 +20,7 @@ import com.afollestad.materialdialogs.WhichButton
import com.afollestad.materialdialogs.actions.setActionButtonEnabled import com.afollestad.materialdialogs.actions.setActionButtonEnabled
import com.afollestad.materialdialogs.input.getInputField import com.afollestad.materialdialogs.input.getInputField
import com.afollestad.materialdialogs.input.input import com.afollestad.materialdialogs.input.input
import com.coldmint.dialog.InputDialog
import com.coldmint.rust.core.dataBean.ApiResponse import com.coldmint.rust.core.dataBean.ApiResponse
import com.coldmint.rust.core.dataBean.LoginRequestData import com.coldmint.rust.core.dataBean.LoginRequestData
import com.coldmint.rust.core.dataBean.user.UserData import com.coldmint.rust.core.dataBean.user.UserData
@ -132,7 +133,7 @@ class LoginActivity : BaseActivity<ActivityLoginBinding>() {
val expirationTime = userData.data.expirationTime val expirationTime = userData.data.expirationTime
val time = ServerConfiguration.toLongTime(expirationTime) val time = ServerConfiguration.toLongTime(expirationTime)
appSettings.forceSetValue(AppSettings.Setting.ExpirationTime, time) appSettings.forceSetValue(AppSettings.Setting.ExpirationTime, time)
appSettings.forceSetValue(AppSettings.Setting.LoginStatus,true) appSettings.forceSetValue(AppSettings.Setting.LoginStatus, true)
startActivity(Intent(this@LoginActivity, MainActivity::class.java)) startActivity(Intent(this@LoginActivity, MainActivity::class.java))
finish() finish()
} else { } else {
@ -371,30 +372,16 @@ class LoginActivity : BaseActivity<ActivityLoginBinding>() {
) )
} }
viewBinding.changeServerView.setOnClickListener { viewBinding.changeServerView.setOnClickListener {
MaterialDialog(this@LoginActivity).show { InputDialog(this).setTitle(R.string.changing_the_server)
title(R.string.changing_the_server).message(R.string.changing_the_server_tip) .setMessage(R.string.changing_the_server_tip).setMaxNumber(255).setText(
.cancelable(false) appSettings.getValue(
input(
maxLength = 255,
waitForPositiveButton = false,
prefill = appSettings.getValue(
AppSettings.Setting.ServerAddress, AppSettings.Setting.ServerAddress,
ServerConfiguration.website ServerConfiguration.website
) )
) { dialog, text -> ).setHint(R.string.server_address_configuration).setErrorTip { s, textInputLayout ->
if (text.startsWith("http://") || text.startsWith("https://")) { textInputLayout.isErrorEnabled =
dialog.setActionButtonEnabled( !(s.startsWith("http://") || s.startsWith("https://"))
WhichButton.POSITIVE, }.setPositiveButton(R.string.dialog_ok) { input ->
true
)
} else {
dialog.setActionButtonEnabled(
WhichButton.POSITIVE,
false
)
}
}.positiveButton(R.string.dialog_ok, null) { dialog ->
val input = dialog.getInputField().text.toString()
if (input.isNotBlank()) { if (input.isNotBlank()) {
appSettings.setValue(AppSettings.Setting.ServerAddress, input) appSettings.setValue(AppSettings.Setting.ServerAddress, input)
ServerConfiguration.website = input ServerConfiguration.website = input
@ -403,9 +390,12 @@ class LoginActivity : BaseActivity<ActivityLoginBinding>() {
R.string.change_server_complete, R.string.change_server_complete,
Snackbar.LENGTH_SHORT Snackbar.LENGTH_SHORT
).show() ).show()
return@setPositiveButton true
} else {
return@setPositiveButton false
} }
}.negativeButton(R.string.dialog_close) }.setNegativeButton(R.string.dialog_close) {
} }.show()
} }
} }

View File

@ -684,17 +684,17 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
startViewModel.needLoginLiveData.observe(this) { startViewModel.needLoginLiveData.observe(this) {
if (it) { if (it) {
MaterialAlertDialogBuilder(this).setTitle(R.string.login) CoreDialog(this).setTitle(R.string.login).setMessage(R.string.login_tip)
.setMessage(R.string.login_tip).setPositiveButton(R.string.login) { i, i2 -> .setPositiveButton(R.string.login) {
startActivity( startActivity(
Intent( Intent(
this, this,
LoginActivity::class.java LoginActivity::class.java
) )
) )
}.setNegativeButton(R.string.dialog_close) { i, i2 -> }.setNegativeButton(R.string.dialog_close) {
finish() finish()
}.show() }.setCancelable(false).show()
} else { } else {
showGameConfiguredDialog() showGameConfiguredDialog()
} }
@ -742,16 +742,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
} }
fun inputName() {
InputDialog(this).setInputCanBeEmpty(false).setTitle("姓名")
.setPositiveButton("确定") {
}.setNegativeButton("取消") {
}.setCancelable(false).show()
}
override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) { override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) {
if (canUseView) { if (canUseView) {
@ -760,7 +750,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
initNav() initNav()
observeStartViewModel() observeStartViewModel()
checkAppUpdate() checkAppUpdate()
inputName()
} else { } else {
startViewModel.initAllData() startViewModel.initAllData()
} }

View File

@ -217,7 +217,7 @@ class SettingsActivity : BaseActivity<ActivitySettingsBinding>() {
override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) { override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) {
if (canUseView) { if (canUseView) {
viewBinding.toolbar.setTitle(R.string.set_up) title = getString(R.string.set_up)
setReturnButton() setReturnButton()
val settingsFragment = SettingsFragment() val settingsFragment = SettingsFragment()
supportFragmentManager supportFragmentManager

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
<!-- 语言条目 --> <!-- 语言条目 -->
<string-array name="language_entries"> <string-array name="language_entries">
<item>简体中文</item> <item>简体中文</item>
<item>繁體中文</item> <!-- <item>繁體中文</item>-->
<item>English</item> <item>English</item>
<item>日本語</item> <item>日本語</item>
<item>Россия</item> <item>Россия</item>
@ -10,7 +10,7 @@
<string-array name="language_values"> <string-array name="language_values">
<item>zh</item> <item>zh</item>
<item>zh_TW</item> <!-- <item>zh_TW</item>-->
<item>en</item> <item>en</item>
<item>ja</item> <item>ja</item>
<item>ru</item> <item>ru</item>

View File

@ -18,6 +18,7 @@ interface AppDialog {
fun setTitle(string: String): AppDialog fun setTitle(string: String): AppDialog
fun setTitle(stringRes: Int): AppDialog fun setTitle(stringRes: Int): AppDialog
fun dismiss()
/** /**
* 设置消息 * 设置消息
@ -101,4 +102,10 @@ interface AppDialog {
*/ */
fun setView(view: View): AppDialog fun setView(view: View): AppDialog
/**
* 设置是否可以自动关闭
* @param enable Boolean
* @return AppDialog
*/
fun setAutoDismiss(enable: Boolean): AppDialog
} }

View File

@ -9,7 +9,8 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
/** /**
* 基础App对话框 * 基础App对话框
*/ */
abstract class BaseAppDialog(context: Context) : AppDialog { abstract class BaseAppDialog<DialogType : AppDialog>(context: Context) :
AppDialog {
protected val materialAlertDialogBuilder: MaterialAlertDialogBuilder by lazy { protected val materialAlertDialogBuilder: MaterialAlertDialogBuilder by lazy {
MaterialAlertDialogBuilder(context) MaterialAlertDialogBuilder(context)
@ -18,97 +19,101 @@ abstract class BaseAppDialog(context: Context) : AppDialog {
protected lateinit var dialog: AlertDialog protected lateinit var dialog: AlertDialog
override fun setTitle(string: String): AppDialog { override fun dismiss() {
dialog.dismiss()
}
override fun setTitle(string: String): DialogType {
materialAlertDialogBuilder.setTitle(string) materialAlertDialogBuilder.setTitle(string)
return this return this as DialogType
} }
override fun setTitle(stringRes: Int): AppDialog { override fun setTitle(stringRes: Int): DialogType {
materialAlertDialogBuilder.setTitle(stringRes) materialAlertDialogBuilder.setTitle(stringRes)
return this return this as DialogType
} }
override fun setMessage(stringRes: Int): AppDialog { override fun setMessage(stringRes: Int): DialogType {
materialAlertDialogBuilder.setMessage(stringRes) materialAlertDialogBuilder.setMessage(stringRes)
return this return this as DialogType
} }
override fun setMessage(string: String): AppDialog { override fun setMessage(string: String): DialogType {
materialAlertDialogBuilder.setMessage(string) materialAlertDialogBuilder.setMessage(string)
return this return this as DialogType
} }
override fun show(): AppDialog { override fun show(): DialogType {
dialog = materialAlertDialogBuilder.show() dialog = materialAlertDialogBuilder.show()
return this return this as DialogType
} }
override fun setPositiveButton(text: String, func: () -> Unit): AppDialog { override fun setPositiveButton(text: String, func: () -> Unit): DialogType {
materialAlertDialogBuilder.setPositiveButton(text) { i, i2 -> materialAlertDialogBuilder.setPositiveButton(text) { i, i2 ->
func.invoke() func.invoke()
} }
return this return this as DialogType
} }
override fun setPositiveButton(textRes: Int, func: () -> Unit): AppDialog { override fun setPositiveButton(textRes: Int, func: () -> Unit): DialogType {
materialAlertDialogBuilder.setPositiveButton(textRes) { i, i2 -> materialAlertDialogBuilder.setPositiveButton(textRes) { i, i2 ->
func.invoke() func.invoke()
} }
return this return this as DialogType
} }
override fun setNegativeButton(text: String, func: () -> Unit): AppDialog { override fun setNegativeButton(text: String, func: () -> Unit): DialogType {
materialAlertDialogBuilder.setNegativeButton(text) { i, i2 -> materialAlertDialogBuilder.setNegativeButton(text) { i, i2 ->
func.invoke() func.invoke()
} }
return this return this as DialogType
} }
override fun setNegativeButton(textRes: Int, func: () -> Unit): AppDialog { override fun setNegativeButton(textRes: Int, func: () -> Unit): DialogType {
materialAlertDialogBuilder.setNegativeButton(textRes) { i, i2 -> materialAlertDialogBuilder.setNegativeButton(textRes) { i, i2 ->
func.invoke() func.invoke()
} }
return this return this as DialogType
} }
override fun setNeutralButton(text: String, func: () -> Unit): AppDialog { override fun setNeutralButton(text: String, func: () -> Unit): DialogType {
materialAlertDialogBuilder.setNeutralButton(text) { i, i2 -> materialAlertDialogBuilder.setNeutralButton(text) { i, i2 ->
func.invoke() func.invoke()
} }
return this return this as DialogType
} }
override fun setNeutralButton(textRes: Int, func: () -> Unit): AppDialog { override fun setNeutralButton(textRes: Int, func: () -> Unit): DialogType {
materialAlertDialogBuilder.setNeutralButton(textRes) { i, i2 -> materialAlertDialogBuilder.setNeutralButton(textRes) { i, i2 ->
func.invoke() func.invoke()
} }
return this return this as DialogType
} }
override fun setCancelable(cancelable: Boolean): AppDialog { override fun setCancelable(cancelable: Boolean): DialogType {
materialAlertDialogBuilder.setCancelable(cancelable) materialAlertDialogBuilder.setCancelable(cancelable)
return this return this as DialogType
} }
override fun setIcon(iconRes: Int): AppDialog { override fun setIcon(iconRes: Int): DialogType {
materialAlertDialogBuilder.setIcon(iconRes) materialAlertDialogBuilder.setIcon(iconRes)
return this return this as DialogType
} }
override fun setSingleChoiceItems( override fun setSingleChoiceItems(
singleItems: Array<CharSequence>, singleItems: Array<CharSequence>,
func: (Int, CharSequence) -> Unit, func: (Int, CharSequence) -> Unit,
checkedItem: Int checkedItem: Int
): AppDialog { ): DialogType {
materialAlertDialogBuilder.setSingleChoiceItems(singleItems, checkedItem) { dialog, which -> materialAlertDialogBuilder.setSingleChoiceItems(singleItems, checkedItem) { dialog, which ->
func.invoke(which, singleItems[which]) func.invoke(which, singleItems[which])
} }
return this return this as DialogType
} }
override fun setView(view: View): AppDialog { override fun setView(view: View): DialogType {
materialAlertDialogBuilder.setView(view) materialAlertDialogBuilder.setView(view)
return this return this as DialogType
} }
} }

View File

@ -1,11 +1,131 @@
package com.coldmint.dialog package com.coldmint.dialog
import android.content.Context import android.content.Context
import android.view.LayoutInflater
import android.view.View
import androidx.core.view.isVisible
import com.coldmint.dialog.BaseAppDialog import com.coldmint.dialog.BaseAppDialog
import com.coldmint.dialog.databinding.DialogCoreBinding
/** /**
* 核心对话框 * 核心对话框
* @constructor * @constructor
*/ */
class CoreDialog(context: Context) : BaseAppDialog(context) { class CoreDialog(context: Context) : BaseAppDialog<CoreDialog>(context) {
val dialogCoreBinding by lazy {
DialogCoreBinding.inflate(LayoutInflater.from(context))
}
private var autoDismiss: Boolean = true
init {
setView(dialogCoreBinding.root)
}
/**
* 设置是否自动关闭
* @param enable Boolean
*/
override fun setAutoDismiss(enable: Boolean): CoreDialog {
autoDismiss = enable
return this
}
override fun setTitle(string: String): CoreDialog {
dialogCoreBinding.titleView.isVisible = true
dialogCoreBinding.titleView.text = string
return this
}
override fun setTitle(stringRes: Int): CoreDialog {
dialogCoreBinding.titleView.isVisible = true
dialogCoreBinding.titleView.setText(stringRes)
return this
}
override fun setMessage(stringRes: Int): CoreDialog {
dialogCoreBinding.messageView.isVisible = true
dialogCoreBinding.messageView.setText(stringRes)
return this
}
override fun setMessage(string: String): CoreDialog {
dialogCoreBinding.messageView.isVisible = true
dialogCoreBinding.messageView.text = string
return this
}
override fun setPositiveButton(text: String, func: () -> Unit): CoreDialog {
dialogCoreBinding.buttonContainer.isVisible = true
dialogCoreBinding.positiveButton.isVisible = true
dialogCoreBinding.positiveButton.text = text
dialogCoreBinding.positiveButton.setOnClickListener {
func.invoke()
if (autoDismiss) {
dialog.dismiss()
}
}
return this
}
override fun setPositiveButton(textRes: Int, func: () -> Unit): CoreDialog {
dialogCoreBinding.buttonContainer.isVisible = true
dialogCoreBinding.positiveButton.isVisible = true
dialogCoreBinding.positiveButton.setText(textRes)
dialogCoreBinding.positiveButton.setOnClickListener {
func.invoke()
if (autoDismiss) {
dialog.dismiss()
}
}
return this
}
override fun setNegativeButton(text: String, func: () -> Unit): CoreDialog {
dialogCoreBinding.buttonContainer.isVisible = true
dialogCoreBinding.negativeButton.isVisible = true
dialogCoreBinding.negativeButton.text = text
dialogCoreBinding.negativeButton.setOnClickListener {
func.invoke()
if (autoDismiss) {
dialog.dismiss()
}
}
return this
}
override fun setNegativeButton(textRes: Int, func: () -> Unit): CoreDialog {
dialogCoreBinding.buttonContainer.isVisible = true
dialogCoreBinding.negativeButton.isVisible = true
dialogCoreBinding.negativeButton.setText(textRes)
dialogCoreBinding.negativeButton.setOnClickListener {
func.invoke()
if (autoDismiss) {
dialog.dismiss()
}
}
return this
}
@Deprecated("无法使用。")
override fun setIcon(iconRes: Int): CoreDialog {
return super.setIcon(iconRes)
}
@Deprecated("无法使用。")
override fun setView(view: View): CoreDialog {
return super.setView(view)
}
@Deprecated("无法使用。")
override fun setSingleChoiceItems(
singleItems: Array<CharSequence>,
func: (Int, CharSequence) -> Unit,
checkedItem: Int
): CoreDialog {
return super.setSingleChoiceItems(singleItems, func, checkedItem)
}
} }

View File

@ -7,26 +7,63 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import androidx.core.view.isVisible import androidx.core.view.isVisible
import com.coldmint.dialog.databinding.DialogInputBinding import com.coldmint.dialog.databinding.DialogInputBinding
import com.google.android.material.textfield.TextInputLayout
/** /**
* 输入对话框 * 输入对话框
* @property dialogInputBinding [@androidx.annotation.NonNull] DialogInputBinding * @property dialogInputBinding [@androidx.annotation.NonNull] DialogInputBinding
* @constructor * @constructor
*/ */
class InputDialog(context: Context) : BaseAppDialog(context) { class InputDialog(context: Context) : BaseAppDialog<InputDialog>(context) {
val dialogInputBinding by lazy { private val dialogInputBinding by lazy {
DialogInputBinding.inflate(LayoutInflater.from(context)) DialogInputBinding.inflate(LayoutInflater.from(context))
} }
private var autoDismiss: Boolean = true private var autoDismiss: Boolean = true
private var inputCanBeEmpty: Boolean = true private var inputCanBeEmpty: Boolean = true
private var errorTipFunction: ((String, TextInputLayout) -> Unit)? = null
/**
* 设置错误提示若设置了错误提示按钮空检查将失效
* @param func Function2<String, TextInputLayout, Boolean>?
*/
fun setErrorTip(func: ((String, TextInputLayout) -> Unit)?): InputDialog {
errorTipFunction = func
dialogInputBinding.positiveButton.isEnabled = func == null
return this
}
/**
* 设置编辑框文本
* @param string String
* @return InputDialog
*/
fun setText(string: String):InputDialog{
dialogInputBinding.textInputEditText.setText(string)
return this
}
/**
* 设置最大输入数量
* @param number Int 小于0禁用
* @return InputDialog
*/
fun setMaxNumber(number: Int): InputDialog {
if (number > 0) {
dialogInputBinding.textInputLayout.counterMaxLength = number
dialogInputBinding.textInputLayout.isCounterEnabled = true
} else {
dialogInputBinding.textInputLayout.isCounterEnabled = false
}
return this
}
/** /**
* 设置是否自动关闭 * 设置是否自动关闭
* @param enable Boolean * @param enable Boolean
*/ */
fun setAutoDismiss(enable: Boolean): InputDialog { override fun setAutoDismiss(enable: Boolean): InputDialog {
autoDismiss = enable autoDismiss = enable
return this return this
} }
@ -56,38 +93,61 @@ class InputDialog(context: Context) : BaseAppDialog(context) {
override fun afterTextChanged(p0: Editable?) { override fun afterTextChanged(p0: Editable?) {
val text = p0.toString() val text = p0.toString()
dialogInputBinding.positiveButton.isEnabled = !(text.isBlank() && !inputCanBeEmpty) if (errorTipFunction != null) {
errorTipFunction!!.invoke(text, dialogInputBinding.textInputLayout)
} else {
dialogInputBinding.positiveButton.isEnabled =
!(text.isBlank() && !inputCanBeEmpty)
}
//如果启用计数并且,超过最大字数
if (dialogInputBinding.textInputLayout.isCounterEnabled && text.length > dialogInputBinding.textInputLayout.counterMaxLength) {
dialogInputBinding.textInputLayout.isErrorEnabled = true
}
//如果处于错误状态禁用按钮
dialogInputBinding.positiveButton.isEnabled =
!dialogInputBinding.textInputLayout.isErrorEnabled
} }
}) })
} }
override fun setTitle(string: String): AppDialog { fun setHint(string: String): InputDialog {
dialogInputBinding.textInputLayout.hint = string
return this
}
fun setHint(stringRes: Int): InputDialog {
dialogInputBinding.textInputLayout.setHint(stringRes)
return this
}
override fun setTitle(string: String): InputDialog {
dialogInputBinding.titleView.isVisible = true dialogInputBinding.titleView.isVisible = true
dialogInputBinding.titleView.text = string dialogInputBinding.titleView.text = string
return this return this
} }
override fun setTitle(stringRes: Int): AppDialog { override fun setTitle(stringRes: Int): InputDialog {
dialogInputBinding.titleView.isVisible = true dialogInputBinding.titleView.isVisible = true
dialogInputBinding.titleView.setText(stringRes) dialogInputBinding.titleView.setText(stringRes)
return this return this
} }
override fun setMessage(stringRes: Int): AppDialog { override fun setMessage(stringRes: Int): InputDialog {
dialogInputBinding.messageView.isVisible = true dialogInputBinding.messageView.isVisible = true
dialogInputBinding.messageView.setText(stringRes) dialogInputBinding.messageView.setText(stringRes)
return this return this
} }
override fun setMessage(string: String): AppDialog { override fun setMessage(string: String): InputDialog {
dialogInputBinding.messageView.isVisible = true dialogInputBinding.messageView.isVisible = true
dialogInputBinding.messageView.text = string dialogInputBinding.messageView.text = string
return this return this
} }
override fun setPositiveButton(text: String, func: () -> Unit): AppDialog { @Deprecated("已废弃")
override fun setPositiveButton(text: String, func: () -> Unit): InputDialog {
dialogInputBinding.buttonContainer.isVisible = true dialogInputBinding.buttonContainer.isVisible = true
dialogInputBinding.positiveButton.isVisible = true dialogInputBinding.positiveButton.isVisible = true
dialogInputBinding.positiveButton.text = text dialogInputBinding.positiveButton.text = text
@ -100,7 +160,8 @@ class InputDialog(context: Context) : BaseAppDialog(context) {
return this return this
} }
override fun setPositiveButton(textRes: Int, func: () -> Unit): AppDialog { @Deprecated("已废弃")
override fun setPositiveButton(textRes: Int, func: () -> Unit): InputDialog {
dialogInputBinding.buttonContainer.isVisible = true dialogInputBinding.buttonContainer.isVisible = true
dialogInputBinding.positiveButton.isVisible = true dialogInputBinding.positiveButton.isVisible = true
dialogInputBinding.positiveButton.setText(textRes) dialogInputBinding.positiveButton.setText(textRes)
@ -113,7 +174,45 @@ class InputDialog(context: Context) : BaseAppDialog(context) {
return this return this
} }
override fun setNegativeButton(text: String, func: () -> Unit): AppDialog { fun setPositiveButton(text: String, func: (String) -> Boolean): InputDialog {
dialogInputBinding.buttonContainer.isVisible = true
dialogInputBinding.positiveButton.isVisible = true
dialogInputBinding.positiveButton.text = text
dialogInputBinding.positiveButton.setOnClickListener {
val d = func.invoke(
dialogInputBinding.textInputEditText.text.toString()
)
if (d) {
dialog.dismiss()
return@setOnClickListener
}
if (autoDismiss) {
dialog.dismiss()
}
}
return this
}
fun setPositiveButton(textRes: Int, func: (String) -> Boolean): InputDialog {
dialogInputBinding.buttonContainer.isVisible = true
dialogInputBinding.positiveButton.isVisible = true
dialogInputBinding.positiveButton.setText(textRes)
dialogInputBinding.positiveButton.setOnClickListener {
val d = func.invoke(
dialogInputBinding.textInputEditText.text.toString()
)
if (d) {
dialog.dismiss()
return@setOnClickListener
}
if (autoDismiss) {
dialog.dismiss()
}
}
return this
}
override fun setNegativeButton(text: String, func: () -> Unit): InputDialog {
dialogInputBinding.buttonContainer.isVisible = true dialogInputBinding.buttonContainer.isVisible = true
dialogInputBinding.negativeButton.isVisible = true dialogInputBinding.negativeButton.isVisible = true
dialogInputBinding.negativeButton.text = text dialogInputBinding.negativeButton.text = text
@ -126,7 +225,7 @@ class InputDialog(context: Context) : BaseAppDialog(context) {
return this return this
} }
override fun setNegativeButton(textRes: Int, func: () -> Unit): AppDialog { override fun setNegativeButton(textRes: Int, func: () -> Unit): InputDialog {
dialogInputBinding.buttonContainer.isVisible = true dialogInputBinding.buttonContainer.isVisible = true
dialogInputBinding.negativeButton.isVisible = true dialogInputBinding.negativeButton.isVisible = true
dialogInputBinding.negativeButton.setText(textRes) dialogInputBinding.negativeButton.setText(textRes)
@ -140,22 +239,22 @@ class InputDialog(context: Context) : BaseAppDialog(context) {
} }
@Deprecated("输入对话框无法使用。") @Deprecated("无法使用。")
override fun setIcon(iconRes: Int): AppDialog { override fun setIcon(iconRes: Int): InputDialog {
return super.setIcon(iconRes) return super.setIcon(iconRes)
} }
@Deprecated("输入对话框无法使用。") @Deprecated("无法使用。")
override fun setView(view: View): AppDialog { override fun setView(view: View): InputDialog {
return super.setView(view) return super.setView(view)
} }
@Deprecated("输入对话框无法使用。") @Deprecated("无法使用。")
override fun setSingleChoiceItems( override fun setSingleChoiceItems(
singleItems: Array<CharSequence>, singleItems: Array<CharSequence>,
func: (Int, CharSequence) -> Unit, func: (Int, CharSequence) -> Unit,
checkedItem: Int checkedItem: Int
): AppDialog { ): InputDialog {
return super.setSingleChoiceItems(singleItems, func, checkedItem) return super.setSingleChoiceItems(singleItems, func, checkedItem)
} }
} }

View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="24dp"
android:orientation="vertical">
<TextView
android:id="@+id/titleView"
style="@style/MaterialAlertDialog.Material3.Title.Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title"
android:visibility="gone" />
<TextView
android:id="@+id/messageView"
style="@style/MaterialAlertDialog.Material3.Body.Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/title"
android:visibility="gone" />
<RelativeLayout
android:id="@+id/buttonContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:visibility="gone">
<Button
android:id="@+id/negativeButton"
style="@style/Widget.Material3.Button.TextButton.Dialog.Flush"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/positiveButton"
android:text="@string/title"
android:visibility="gone" />
<Button
android:layout_marginLeft="8dp"
android:id="@+id/positiveButton"
style="@style/Widget.Material3.Button.TextButton.Dialog.Flush"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:text="@string/title"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>

View File

@ -11,7 +11,7 @@
<TextView <TextView
android:id="@+id/titleView" android:id="@+id/titleView"
style="@style/TextAppearance.Material3.HeadlineSmall" style="@style/MaterialAlertDialog.Material3.Title.Text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/title" android:text="@string/title"
@ -19,7 +19,7 @@
<TextView <TextView
android:id="@+id/messageView" android:id="@+id/messageView"
style="@style/TextAppearance.Material3.BodyMedium" style="@style/MaterialAlertDialog.Material3.Body.Text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
@ -30,7 +30,7 @@
android:id="@+id/textInputLayout" android:id="@+id/textInputLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="24dp"
android:hint="@string/title"> android:hint="@string/title">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
@ -42,23 +42,24 @@
<RelativeLayout <RelativeLayout
android:id="@+id/buttonContainer" android:id="@+id/buttonContainer"
android:visibility="gone"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="24dp"> android:layout_marginTop="24dp"
android:visibility="gone">
<Button <Button
android:id="@+id/negativeButton" android:id="@+id/negativeButton"
style="@style/Widget.Material3.Button.TextButton" style="@style/Widget.Material3.Button.TextButton.Dialog.Flush"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentStart="true" android:layout_toLeftOf="@id/positiveButton"
android:text="@string/title" android:text="@string/title"
android:visibility="gone" /> android:visibility="gone" />
<Button <Button
android:layout_marginLeft="8dp"
android:id="@+id/positiveButton" android:id="@+id/positiveButton"
style="@style/Widget.Material3.Button.TextButton" style="@style/Widget.Material3.Button.TextButton.Dialog.Flush"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"