自定义对话框中
This commit is contained in:
parent
a83ede0073
commit
15ace14a26
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -93,6 +93,7 @@ dependencies {
|
|||
implementation 'com.kongzue.stacklabel:stacklabelview:1.1.9'
|
||||
implementation files('libs/editor_0.8.aar')
|
||||
implementation project(path: ':assistantCoreLibrary')
|
||||
implementation project(path: ':dialog')
|
||||
implementation 'com.afollestad.material-dialogs:bottomsheets:3.3.0'
|
||||
implementation 'com.afollestad.material-dialogs:input:3.3.0'
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package com.coldmint.rust.pro
|
||||
|
||||
|
||||
import android.Manifest
|
||||
import android.content.DialogInterface
|
||||
import com.coldmint.rust.pro.base.BaseActivity
|
||||
import com.coldmint.rust.pro.tool.GlobalMethod
|
||||
import android.content.pm.PackageInfo
|
||||
|
@ -11,11 +9,9 @@ import android.content.Intent
|
|||
import android.content.pm.PackageManager
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import android.widget.Toast
|
||||
import android.net.Uri
|
||||
import android.os.*
|
||||
import android.util.Log
|
||||
import android.view.*
|
||||
import android.widget.PopupMenu
|
||||
import android.widget.SearchView
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.core.view.isVisible
|
||||
|
@ -24,39 +20,25 @@ import androidx.navigation.findNavController
|
|||
import androidx.navigation.ui.*
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.bumptech.glide.Glide
|
||||
import com.coldmint.dialog.CoreDialog
|
||||
import com.coldmint.dialog.InputDialog
|
||||
import com.coldmint.rust.core.CompressionManager
|
||||
import com.coldmint.rust.core.TemplatePackage
|
||||
import com.coldmint.rust.core.dataBean.AppUpdateData
|
||||
import com.coldmint.rust.core.dataBean.iflynote.NoteData
|
||||
import com.coldmint.rust.core.dataBean.template.TemplateInfo
|
||||
import com.coldmint.rust.core.database.code.CodeDataBase
|
||||
import com.coldmint.rust.core.iflynote.IFlyNoteAPi
|
||||
import com.coldmint.rust.core.interfaces.ApiCallBack
|
||||
import com.coldmint.rust.core.interfaces.LineParserEvent
|
||||
import com.coldmint.rust.core.interfaces.UnzipListener
|
||||
import com.coldmint.rust.core.tool.*
|
||||
import com.coldmint.rust.core.web.AppUpdate
|
||||
import com.coldmint.rust.core.web.ServerConfiguration
|
||||
import com.coldmint.rust.pro.databinding.ActivityMainBinding
|
||||
import com.coldmint.rust.pro.databinding.HeadLayoutBinding
|
||||
import com.coldmint.rust.pro.dialog.DialogManager
|
||||
import com.coldmint.rust.pro.dialog.InputDialog
|
||||
import com.coldmint.rust.pro.dialog.RustDialog
|
||||
import com.coldmint.rust.pro.viewmodel.StartViewModel
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.gson.Gson
|
||||
import com.permissionx.guolindev.PermissionX
|
||||
import com.permissionx.guolindev.callback.ExplainReasonCallback
|
||||
import com.permissionx.guolindev.callback.ForwardToSettingsCallback
|
||||
import com.permissionx.guolindev.callback.RequestCallback
|
||||
import com.permissionx.guolindev.dialog.RationaleDialog
|
||||
import com.permissionx.guolindev.request.ExplainScope
|
||||
import com.permissionx.guolindev.request.ForwardScope
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
import java.util.ArrayList
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.zip.ZipEntry
|
||||
|
||||
|
@ -744,7 +726,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||
|
||||
startViewModel.verifyErrorMsgLiveData.observe(this) {
|
||||
if (it.isNotBlank()) {
|
||||
RustDialog(this).setTitle(R.string.login).setMessage(it)
|
||||
CoreDialog(this).setTitle(R.string.login).setMessage(it)
|
||||
.setCancelable(false).setPositiveButton(R.string.login) {
|
||||
startActivity(
|
||||
Intent(
|
||||
|
@ -760,6 +742,17 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||
|
||||
}
|
||||
|
||||
fun inputName() {
|
||||
|
||||
InputDialog(this).setInputCanBeEmpty(false).setTitle("姓名")
|
||||
.setPositiveButton("确定") {
|
||||
|
||||
}.setNegativeButton("取消") {
|
||||
|
||||
}.setCancelable(false).show()
|
||||
}
|
||||
|
||||
|
||||
override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) {
|
||||
if (canUseView) {
|
||||
oldLanguage = appSettings.getValue(AppSettings.Setting.AppLanguage, "en")
|
||||
|
@ -767,6 +760,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||
initNav()
|
||||
observeStartViewModel()
|
||||
checkAppUpdate()
|
||||
inputName()
|
||||
} else {
|
||||
startViewModel.initAllData()
|
||||
}
|
||||
|
|
|
@ -837,6 +837,7 @@ class ReleaseModActivity : BaseActivity<ActivityReleaseModBinding>() {
|
|||
)
|
||||
}
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,14 @@ class RustApplication : Application() {
|
|||
super.onCreate()
|
||||
|
||||
//动态颜色
|
||||
val options = DynamicColorsOptions.Builder().setPrecondition { activity, theme ->
|
||||
AppSettings.getInstance(this)
|
||||
.getValue(AppSettings.Setting.DynamicColor, DynamicColors.isDynamicColorAvailable())
|
||||
}.build()
|
||||
val options = DynamicColorsOptions.Builder()
|
||||
.setPrecondition { activity, theme ->
|
||||
AppSettings.getInstance(this)
|
||||
.getValue(
|
||||
AppSettings.Setting.DynamicColor,
|
||||
DynamicColors.isDynamicColorAvailable()
|
||||
)
|
||||
}.build()
|
||||
DynamicColors.applyToActivitiesIfAvailable(this, options)
|
||||
//程序崩溃
|
||||
CaocConfig.Builder.create()
|
||||
|
|
|
@ -270,6 +270,7 @@ class WebModInfoActivity : BaseActivity<ActivityWebModInfoBinding>() {
|
|||
AppOperator.NetWorkType.NetWorkType_Wifi -> {
|
||||
downloadWork(fileLink)
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -101,6 +101,7 @@ class FileAdapter(private val context: Context, private var dataList: MutableLis
|
|||
}
|
||||
})
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
package com.coldmint.rust.pro.dialog
|
||||
|
||||
import android.content.Context
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
|
||||
/**
|
||||
* 对话框管理器
|
||||
*/
|
||||
object DialogManager {
|
||||
|
||||
enum class DialogType {
|
||||
Default, Input
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对话框
|
||||
* @param context Context
|
||||
* @param dialogType DialogType
|
||||
* @return AppDialog
|
||||
*/
|
||||
fun getDialog(context: Context, dialogType: DialogType = DialogType.Default): AppDialog {
|
||||
return when (dialogType) {
|
||||
DialogType.Default -> {
|
||||
RustDialog(context)
|
||||
}
|
||||
DialogType.Input -> {
|
||||
InputDialog(context)
|
||||
}
|
||||
else -> {
|
||||
RustDialog(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package com.coldmint.rust.pro.dialog
|
||||
|
||||
import android.content.Context
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.LayoutInflater
|
||||
import com.coldmint.rust.pro.databinding.DialogInputBinding
|
||||
|
||||
/**
|
||||
* 输入对话框
|
||||
* @property dialogInputBinding [@androidx.annotation.NonNull] DialogInputBinding
|
||||
* @constructor
|
||||
*/
|
||||
class InputDialog(context: Context) : BaseAppDialog(context) {
|
||||
|
||||
val dialogInputBinding by lazy {
|
||||
DialogInputBinding.inflate(LayoutInflater.from(context))
|
||||
}
|
||||
|
||||
init {
|
||||
setView(dialogInputBinding.root)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package com.coldmint.rust.pro.dialog
|
||||
|
||||
import android.content.Context
|
||||
|
||||
/**
|
||||
* 默认对话框
|
||||
* @constructor
|
||||
*/
|
||||
class RustDialog(context: Context) : BaseAppDialog(context) {
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?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"
|
||||
android:padding="16dp">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/textInputLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/title">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/textInputEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -10,12 +10,15 @@
|
|||
|
||||
|
||||
<!--概念主题 -->
|
||||
<style name="Theme.rust.Concept" parent="Base.rust.Concept" />
|
||||
|
||||
<style name="Theme.rust.Concept" parent="Base.rust.Concept"/>
|
||||
|
||||
<style name="Base.rust.Concept" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- <item name="windowActionBar">false</item>-->
|
||||
<!-- <item name="windowNoTitle">true</item>-->
|
||||
<item name="md_corner_radius">28dp</item>
|
||||
<item name="md_background_color">?attr/colorSurface</item>
|
||||
<!-- <item name="md_background_color">@color/material_on_surface_emphasis_medium</item>-->
|
||||
|
||||
</style>
|
||||
|
||||
<!--设置标签为小写-->
|
||||
|
|
|
@ -435,6 +435,9 @@ class CodeCompiler2 private constructor(val context: Context) : CodeCompilerInte
|
|||
referenceResult.append(translation)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> if (compileConfiguration.codeBlockType == CompileConfiguration.CodeBlockType.Note) {
|
||||
|
|
|
@ -255,6 +255,7 @@ data class CompileConfiguration(
|
|||
analysisResult.icon = warningIcon
|
||||
warningNumber++
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
if (errorRecordMap == null) {
|
||||
throw NullPointerException("错误记录表未同步。")
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.coldmint.rust.core.database.code
|
|||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Ignore
|
||||
import androidx.room.PrimaryKey
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
|
@ -16,4 +17,7 @@ data class SectionInfo(
|
|||
@ColumnInfo(name = "need_name") val needName: Boolean = false,
|
||||
@ColumnInfo(name = "is_visible") val isVisible: Boolean = true,
|
||||
@ColumnInfo(name = "is_available") val isAvailable: Boolean = true
|
||||
)
|
||||
) {
|
||||
@Ignore
|
||||
constructor() : this("")
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ buildscript {
|
|||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.2.0'
|
||||
// classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5"
|
||||
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21'
|
||||
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
|
1
dialog/.gitignore
vendored
Normal file
1
dialog/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/build
|
44
dialog/build.gradle
Normal file
44
dialog/build.gradle
Normal file
|
@ -0,0 +1,44 @@
|
|||
plugins {
|
||||
id 'com.android.library'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk 32
|
||||
|
||||
defaultConfig {
|
||||
minSdk 21
|
||||
targetSdk 32
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '1.8'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation 'com.google.android.material:material:1.6.1'
|
||||
|
||||
implementation 'androidx.core:core-ktx:1.7.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.4.2'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
}
|
0
dialog/consumer-rules.pro
Normal file
0
dialog/consumer-rules.pro
Normal file
21
dialog/proguard-rules.pro
vendored
Normal file
21
dialog/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
|
@ -0,0 +1,24 @@
|
|||
package com.coldmint.dialog
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.coldmint.dialog.test", appContext.packageName)
|
||||
}
|
||||
}
|
5
dialog/src/main/AndroidManifest.xml
Normal file
5
dialog/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.coldmint.dialog">
|
||||
|
||||
</manifest>
|
|
@ -1,4 +1,4 @@
|
|||
package com.coldmint.rust.pro.dialog
|
||||
package com.coldmint.dialog
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
|
@ -1,8 +1,9 @@
|
|||
package com.coldmint.rust.pro.dialog
|
||||
package com.coldmint.dialog
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
/**
|
||||
|
@ -14,6 +15,8 @@ abstract class BaseAppDialog(context: Context) : AppDialog {
|
|||
MaterialAlertDialogBuilder(context)
|
||||
}
|
||||
|
||||
protected lateinit var dialog: AlertDialog
|
||||
|
||||
|
||||
override fun setTitle(string: String): AppDialog {
|
||||
materialAlertDialogBuilder.setTitle(string)
|
||||
|
@ -36,7 +39,7 @@ abstract class BaseAppDialog(context: Context) : AppDialog {
|
|||
}
|
||||
|
||||
override fun show(): AppDialog {
|
||||
materialAlertDialogBuilder.show()
|
||||
dialog = materialAlertDialogBuilder.show()
|
||||
return this
|
||||
}
|
||||
|
11
dialog/src/main/java/com/coldmint/dialog/CoreDialog.kt
Normal file
11
dialog/src/main/java/com/coldmint/dialog/CoreDialog.kt
Normal file
|
@ -0,0 +1,11 @@
|
|||
package com.coldmint.dialog
|
||||
|
||||
import android.content.Context
|
||||
import com.coldmint.dialog.BaseAppDialog
|
||||
|
||||
/**
|
||||
* 核心对话框
|
||||
* @constructor
|
||||
*/
|
||||
class CoreDialog(context: Context) : BaseAppDialog(context) {
|
||||
}
|
161
dialog/src/main/java/com/coldmint/dialog/InputDialog.kt
Normal file
161
dialog/src/main/java/com/coldmint/dialog/InputDialog.kt
Normal file
|
@ -0,0 +1,161 @@
|
|||
package com.coldmint.dialog
|
||||
|
||||
import android.content.Context
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.core.view.isVisible
|
||||
import com.coldmint.dialog.databinding.DialogInputBinding
|
||||
|
||||
/**
|
||||
* 输入对话框
|
||||
* @property dialogInputBinding [@androidx.annotation.NonNull] DialogInputBinding
|
||||
* @constructor
|
||||
*/
|
||||
class InputDialog(context: Context) : BaseAppDialog(context) {
|
||||
|
||||
val dialogInputBinding by lazy {
|
||||
DialogInputBinding.inflate(LayoutInflater.from(context))
|
||||
}
|
||||
|
||||
private var autoDismiss: Boolean = true
|
||||
private var inputCanBeEmpty: Boolean = true
|
||||
|
||||
/**
|
||||
* 设置是否自动关闭
|
||||
* @param enable Boolean
|
||||
*/
|
||||
fun setAutoDismiss(enable: Boolean): InputDialog {
|
||||
autoDismiss = enable
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否输入可空,若为true,则在空状态禁用确定按钮
|
||||
* @param can Boolean
|
||||
*/
|
||||
fun setInputCanBeEmpty(can: Boolean): InputDialog {
|
||||
inputCanBeEmpty = can
|
||||
val text = dialogInputBinding.textInputEditText.text.toString()
|
||||
dialogInputBinding.positiveButton.isEnabled = text.isNotBlank()
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
init {
|
||||
setView(dialogInputBinding.root)
|
||||
dialogInputBinding.textInputEditText.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun afterTextChanged(p0: Editable?) {
|
||||
val text = p0.toString()
|
||||
dialogInputBinding.positiveButton.isEnabled = !(text.isBlank() && !inputCanBeEmpty)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
override fun setTitle(string: String): AppDialog {
|
||||
dialogInputBinding.titleView.isVisible = true
|
||||
dialogInputBinding.titleView.text = string
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setTitle(stringRes: Int): AppDialog {
|
||||
dialogInputBinding.titleView.isVisible = true
|
||||
dialogInputBinding.titleView.setText(stringRes)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setMessage(stringRes: Int): AppDialog {
|
||||
dialogInputBinding.messageView.isVisible = true
|
||||
dialogInputBinding.messageView.setText(stringRes)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setMessage(string: String): AppDialog {
|
||||
dialogInputBinding.messageView.isVisible = true
|
||||
dialogInputBinding.messageView.text = string
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setPositiveButton(text: String, func: () -> Unit): AppDialog {
|
||||
dialogInputBinding.buttonContainer.isVisible = true
|
||||
dialogInputBinding.positiveButton.isVisible = true
|
||||
dialogInputBinding.positiveButton.text = text
|
||||
dialogInputBinding.positiveButton.setOnClickListener {
|
||||
func.invoke()
|
||||
if (autoDismiss) {
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setPositiveButton(textRes: Int, func: () -> Unit): AppDialog {
|
||||
dialogInputBinding.buttonContainer.isVisible = true
|
||||
dialogInputBinding.positiveButton.isVisible = true
|
||||
dialogInputBinding.positiveButton.setText(textRes)
|
||||
dialogInputBinding.positiveButton.setOnClickListener {
|
||||
func.invoke()
|
||||
if (autoDismiss) {
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setNegativeButton(text: String, func: () -> Unit): AppDialog {
|
||||
dialogInputBinding.buttonContainer.isVisible = true
|
||||
dialogInputBinding.negativeButton.isVisible = true
|
||||
dialogInputBinding.negativeButton.text = text
|
||||
dialogInputBinding.negativeButton.setOnClickListener {
|
||||
func.invoke()
|
||||
if (autoDismiss) {
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setNegativeButton(textRes: Int, func: () -> Unit): AppDialog {
|
||||
dialogInputBinding.buttonContainer.isVisible = true
|
||||
dialogInputBinding.negativeButton.isVisible = true
|
||||
dialogInputBinding.negativeButton.setText(textRes)
|
||||
dialogInputBinding.negativeButton.setOnClickListener {
|
||||
func.invoke()
|
||||
if (autoDismiss) {
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
@Deprecated("输入对话框无法使用。")
|
||||
override fun setIcon(iconRes: Int): AppDialog {
|
||||
return super.setIcon(iconRes)
|
||||
}
|
||||
|
||||
@Deprecated("输入对话框无法使用。")
|
||||
override fun setView(view: View): AppDialog {
|
||||
return super.setView(view)
|
||||
}
|
||||
|
||||
@Deprecated("输入对话框无法使用。")
|
||||
override fun setSingleChoiceItems(
|
||||
singleItems: Array<CharSequence>,
|
||||
func: (Int, CharSequence) -> Unit,
|
||||
checkedItem: Int
|
||||
): AppDialog {
|
||||
return super.setSingleChoiceItems(singleItems, func, checkedItem)
|
||||
}
|
||||
}
|
73
dialog/src/main/res/layout/dialog_input.xml
Normal file
73
dialog/src/main/res/layout/dialog_input.xml
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?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/TextAppearance.Material3.HeadlineSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/messageView"
|
||||
style="@style/TextAppearance.Material3.BodyMedium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/title"
|
||||
android:visibility="gone" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/textInputLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:hint="@string/title">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/textInputEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/buttonContainer"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/negativeButton"
|
||||
style="@style/Widget.Material3.Button.TextButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:text="@string/title"
|
||||
android:visibility="gone" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/positiveButton"
|
||||
style="@style/Widget.Material3.Button.TextButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:text="@string/title"
|
||||
android:visibility="gone" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
4
dialog/src/main/res/values/strings.xml
Normal file
4
dialog/src/main/res/values/strings.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="title">标题</string>
|
||||
</resources>
|
17
dialog/src/test/java/com/coldmint/dialog/ExampleUnitTest.kt
Normal file
17
dialog/src/test/java/com/coldmint/dialog/ExampleUnitTest.kt
Normal file
|
@ -0,0 +1,17 @@
|
|||
package com.coldmint.dialog
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
|
@ -4,5 +4,5 @@
|
|||
# Location of the SDK. This is only used by Gradle.
|
||||
# For customization when using a Version Control System, please read the
|
||||
# header note.
|
||||
#Fri Jul 08 17:17:59 CST 2022
|
||||
sdk.dir=D\:\\Android_SDK
|
||||
#Fri Jul 08 20:18:44 CST 2022
|
||||
sdk.dir=D\:\\Document\\AndroidSdk
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
include ':app'
|
||||
rootProject.name = "铁锈助手"
|
||||
include ':assistantCoreLibrary'
|
||||
include ':dialog'
|
||||
|
|
Loading…
Reference in New Issue
Block a user