优化部分对话框
This commit is contained in:
parent
ec39947f58
commit
09562490d7
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.
|
@ -24,11 +24,11 @@ android {
|
||||||
buildToolsVersion "30.0.3"
|
buildToolsVersion "30.0.3"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.coldmint.rust.pro"
|
applicationId "com.coldmint.rust.beta"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 32
|
targetSdkVersion 32
|
||||||
versionCode 18
|
versionCode 18
|
||||||
versionName "2.0 release8 p3(2022-4-26)"
|
versionName "2.1 alpha(2022-7-6)"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,6 @@ import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
|
||||||
import com.afollestad.materialdialogs.list.listItems
|
|
||||||
import com.coldmint.rust.core.dataBean.ApiResponse
|
import com.coldmint.rust.core.dataBean.ApiResponse
|
||||||
import com.coldmint.rust.core.dataBean.CouponListDataBean
|
import com.coldmint.rust.core.dataBean.CouponListDataBean
|
||||||
import com.coldmint.rust.core.dataBean.PlanDataBean
|
import com.coldmint.rust.core.dataBean.PlanDataBean
|
||||||
|
@ -33,6 +31,7 @@ import com.coldmint.rust.pro.databean.FunctionInfo
|
||||||
import com.coldmint.rust.pro.databinding.ActivityActivateBinding
|
import com.coldmint.rust.pro.databinding.ActivityActivateBinding
|
||||||
import com.coldmint.rust.pro.tool.AppSettings
|
import com.coldmint.rust.pro.tool.AppSettings
|
||||||
import com.coldmint.rust.pro.tool.GlobalMethod
|
import com.coldmint.rust.pro.tool.GlobalMethod
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
|
||||||
class ActivateActivity : BaseActivity<ActivityActivateBinding>() {
|
class ActivateActivity : BaseActivity<ActivityActivateBinding>() {
|
||||||
|
@ -283,10 +282,12 @@ class ActivateActivity : BaseActivity<ActivityActivateBinding>() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (finalCouponId != null) {
|
if (finalCouponId != null) {
|
||||||
MaterialDialog(this).title(R.string.coupon).message(R.string.use_coupon)
|
MaterialAlertDialogBuilder(this).setTitle(R.string.coupon)
|
||||||
.positiveButton(R.string.dialog_ok).positiveButton {
|
.setMessage(R.string.use_coupon)
|
||||||
|
.setPositiveButton(R.string.dialog_ok) { i, i2 ->
|
||||||
func.invoke()
|
func.invoke()
|
||||||
}.negativeButton(R.string.dialog_cancel).show()
|
}.setNegativeButton(R.string.dialog_cancel) { i, i2 ->
|
||||||
|
}.show()
|
||||||
} else {
|
} else {
|
||||||
func.invoke()
|
func.invoke()
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,14 +11,14 @@ import android.content.Intent
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
|
||||||
import com.afollestad.materialdialogs.customview.customView
|
|
||||||
import com.coldmint.rust.pro.adapters.BookmarkAdapter
|
import com.coldmint.rust.pro.adapters.BookmarkAdapter
|
||||||
import com.coldmint.rust.pro.base.BaseActivity
|
import com.coldmint.rust.pro.base.BaseActivity
|
||||||
import com.coldmint.rust.pro.databean.Bookmark
|
import com.coldmint.rust.pro.databean.Bookmark
|
||||||
import com.coldmint.rust.pro.databinding.ActivityBookmarkManagerBinding
|
import com.coldmint.rust.pro.databinding.ActivityBookmarkManagerBinding
|
||||||
import com.coldmint.rust.pro.databinding.EditBookmarkBinding
|
import com.coldmint.rust.pro.databinding.EditBookmarkBinding
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
|
@ -46,7 +46,7 @@ class BookmarkManagerActivity : BaseActivity<ActivityBookmarkManagerBinding>() {
|
||||||
attachFileItemBinding.root.setOnLongClickListener {
|
attachFileItemBinding.root.setOnLongClickListener {
|
||||||
bookmarkAdapter.showDeleteItemDialog(
|
bookmarkAdapter.showDeleteItemDialog(
|
||||||
bookmark.name,
|
bookmark.name,
|
||||||
viewHolder.adapterPosition, onClickPositiveButton = { d, b ->
|
viewHolder.adapterPosition, onClickPositiveButton = { i:Int, b ->
|
||||||
bookmarkManager.removeBookmark(bookmark)
|
bookmarkManager.removeBookmark(bookmark)
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
showNoBookmarkToView()
|
showNoBookmarkToView()
|
||||||
|
@ -113,64 +113,65 @@ class BookmarkManagerActivity : BaseActivity<ActivityBookmarkManagerBinding>() {
|
||||||
startActivityForResult(intent, 1)
|
startActivityForResult(intent, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
val materialDialog =
|
var dialog: AlertDialog? = null
|
||||||
MaterialDialog(this).title(text = title).customView(view = editBookmarkBinding.root)
|
val materialAlertDialogBuilder = MaterialAlertDialogBuilder(this)
|
||||||
.positiveButton(R.string.dialog_ok).negativeButton(R.string.dialog_close)
|
.setView(editBookmarkBinding.root)
|
||||||
.noAutoDismiss().cancelable(false)
|
.setTitle(title)
|
||||||
materialDialog.positiveButton {
|
.setPositiveButton(R.string.dialog_ok)
|
||||||
val newPath = pathView.text.toString()
|
{ i, i2 ->
|
||||||
val newName = nameView.text.toString()
|
val newPath = pathView.text.toString()
|
||||||
if (newName.isEmpty()) {
|
val newName = nameView.text.toString()
|
||||||
setErrorAndInput(nameView, getString(R.string.enter_bookmark_name))
|
if (newName.isEmpty()) {
|
||||||
return@positiveButton
|
setErrorAndInput(nameView, getString(R.string.enter_bookmark_name))
|
||||||
}
|
return@setPositiveButton
|
||||||
if (newPath.isEmpty()) {
|
|
||||||
setErrorAndInput(pathView, getString(R.string.enter_file_path))
|
|
||||||
return@positiveButton
|
|
||||||
}
|
|
||||||
val file = File(newPath)
|
|
||||||
if (!file.exists()) {
|
|
||||||
setErrorAndInput(pathView, getString(R.string.bookmark_jump_failed))
|
|
||||||
return@positiveButton
|
|
||||||
}
|
|
||||||
if (name == null) {
|
|
||||||
val addBookmark = bookmarkManager.addBookmark(newPath, newName)
|
|
||||||
if (addBookmark) {
|
|
||||||
updateView(bookmarkManager.list())
|
|
||||||
|
|
||||||
} else {
|
|
||||||
setErrorAndInput(
|
|
||||||
pathView,
|
|
||||||
getString(R.string.bookmark_already_exists)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} else {
|
if (newPath.isEmpty()) {
|
||||||
if (name == newName && path == newPath) {
|
setErrorAndInput(pathView, getString(R.string.enter_file_path))
|
||||||
materialDialog.dismiss()
|
return@setPositiveButton
|
||||||
|
}
|
||||||
|
val file = File(newPath)
|
||||||
|
if (!file.exists()) {
|
||||||
|
setErrorAndInput(pathView, getString(R.string.bookmark_jump_failed))
|
||||||
|
return@setPositiveButton
|
||||||
|
}
|
||||||
|
if (name == null) {
|
||||||
|
val addBookmark = bookmarkManager.addBookmark(newPath, newName)
|
||||||
|
if (addBookmark) {
|
||||||
|
updateView(bookmarkManager.list())
|
||||||
|
|
||||||
|
} else {
|
||||||
|
setErrorAndInput(
|
||||||
|
pathView,
|
||||||
|
getString(R.string.bookmark_already_exists)
|
||||||
|
)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (path != null) {
|
if (name == newName && path == newPath) {
|
||||||
val oldBookmark = Bookmark(path, name)
|
dialog?.dismiss()
|
||||||
val newBookmark = Bookmark(newPath, newName)
|
} else {
|
||||||
val addBookmark =
|
if (path != null) {
|
||||||
bookmarkManager.replaceBookmark(oldBookmark, newBookmark)
|
val oldBookmark = Bookmark(path, name)
|
||||||
if (addBookmark) {
|
val newBookmark = Bookmark(newPath, newName)
|
||||||
updateView(bookmarkManager.list())
|
val addBookmark =
|
||||||
materialDialog.dismiss()
|
bookmarkManager.replaceBookmark(oldBookmark, newBookmark)
|
||||||
} else {
|
if (addBookmark) {
|
||||||
setErrorAndInput(
|
updateView(bookmarkManager.list())
|
||||||
pathView,
|
dialog?.dismiss()
|
||||||
getString(R.string.bookmark_already_exists)
|
} else {
|
||||||
)
|
setErrorAndInput(
|
||||||
|
pathView,
|
||||||
|
getString(R.string.bookmark_already_exists)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
materialDialog.dismiss()
|
.setNegativeButton(R.string.dialog_close) { i, i2 ->
|
||||||
}
|
dialog?.dismiss()
|
||||||
materialDialog.negativeButton {
|
}
|
||||||
materialDialog.dismiss()
|
.setCancelable(false)
|
||||||
}
|
dialog = materialAlertDialogBuilder.show()
|
||||||
materialDialog.show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,82 +27,137 @@ class CreationWizardActivity : BaseActivity<ActivityCreationWizardBinding>() {
|
||||||
viewBinding.recyclerView.layoutManager = LinearLayoutManager(this)
|
viewBinding.recyclerView.layoutManager = LinearLayoutManager(this)
|
||||||
when (temType) {
|
when (temType) {
|
||||||
"mod" -> {
|
"mod" -> {
|
||||||
val dataList = ArrayList<GuideData>()
|
loadMod()
|
||||||
dataList.add(
|
}
|
||||||
GuideData(
|
"template" -> {
|
||||||
R.string.create_mod_lable,
|
loadTemplate()
|
||||||
R.string.create_mod_describe,
|
|
||||||
R.drawable.ic_outline_create_24
|
|
||||||
)
|
|
||||||
)
|
|
||||||
dataList.add(
|
|
||||||
GuideData(
|
|
||||||
R.string.import_mod,
|
|
||||||
R.string.import_mod_from_file_manager_describe,
|
|
||||||
R.drawable.folder
|
|
||||||
)
|
|
||||||
)
|
|
||||||
dataList.add(
|
|
||||||
GuideData(
|
|
||||||
R.string.import_mod_from_package_directory,
|
|
||||||
R.string.import_mod_from_package_directory_describe,
|
|
||||||
R.drawable.zip
|
|
||||||
)
|
|
||||||
)
|
|
||||||
dataList.add(
|
|
||||||
GuideData(
|
|
||||||
R.string.import_mod_from_recycle_bin,
|
|
||||||
R.string.import_mod_from_recycle_bin_describe,
|
|
||||||
R.drawable.auto_delete
|
|
||||||
)
|
|
||||||
)
|
|
||||||
val adapter = GuideAdapter(this, dataList)
|
|
||||||
adapter.setItemEvent { i, itemGuideBinding, viewHolder, guideData ->
|
|
||||||
itemGuideBinding.root.setOnClickListener {
|
|
||||||
finish()
|
|
||||||
when (guideData.titleRes) {
|
|
||||||
R.string.create_mod_lable -> {
|
|
||||||
startActivity(
|
|
||||||
Intent(
|
|
||||||
this,
|
|
||||||
CreateModActivity::class.java
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
R.string.import_mod -> {
|
|
||||||
val startIntent =
|
|
||||||
Intent(this, FileManagerActivity::class.java)
|
|
||||||
val fileBundle = Bundle()
|
|
||||||
fileBundle.putString("type", "selectFile")
|
|
||||||
startIntent.putExtra("data", fileBundle)
|
|
||||||
startActivity(startIntent)
|
|
||||||
}
|
|
||||||
R.string.import_mod_from_package_directory -> {
|
|
||||||
val startIntent =
|
|
||||||
Intent(this, FileManagerActivity::class.java)
|
|
||||||
val fileBundle = Bundle()
|
|
||||||
fileBundle.putString("type", "selectFile")
|
|
||||||
val packDirectory = appSettings.getValue(
|
|
||||||
AppSettings.Setting.PackDirectory,
|
|
||||||
AppSettings.dataRootDirectory + "/bin/"
|
|
||||||
)
|
|
||||||
fileBundle.putString("path", packDirectory)
|
|
||||||
fileBundle.putString("rootpath", packDirectory)
|
|
||||||
startIntent.putExtra("data", fileBundle)
|
|
||||||
startActivity(startIntent)
|
|
||||||
}
|
|
||||||
R.string.import_mod_from_recycle_bin -> {
|
|
||||||
startActivity(Intent(this, RecyclingStationActivity::class.java))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
viewBinding.recyclerView.adapter = adapter
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载模板活动
|
||||||
|
*/
|
||||||
|
fun loadTemplate() {
|
||||||
|
val dataList = ArrayList<GuideData>()
|
||||||
|
dataList.add(
|
||||||
|
GuideData(
|
||||||
|
R.string.create_template,
|
||||||
|
R.string.create_template_describe,
|
||||||
|
R.drawable.ic_outline_create_24
|
||||||
|
)
|
||||||
|
)
|
||||||
|
dataList.add(
|
||||||
|
GuideData(
|
||||||
|
R.string.import_template,
|
||||||
|
R.string.import_template_describe,
|
||||||
|
R.drawable.folder
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val adapter = GuideAdapter(this, dataList)
|
||||||
|
adapter.setItemEvent { i, itemGuideBinding, viewHolder, guideData ->
|
||||||
|
itemGuideBinding.root.setOnClickListener {
|
||||||
|
finish()
|
||||||
|
when (guideData.titleRes) {
|
||||||
|
R.string.create_template -> {
|
||||||
|
startActivity(
|
||||||
|
Intent(
|
||||||
|
this,
|
||||||
|
CreateTemplateActivity::class.java
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
R.string.import_template -> {
|
||||||
|
val startIntent =
|
||||||
|
Intent(this, FileManagerActivity::class.java)
|
||||||
|
val fileBundle = Bundle()
|
||||||
|
fileBundle.putString("type", "selectFile")
|
||||||
|
startIntent.putExtra("data", fileBundle)
|
||||||
|
startActivity(startIntent )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
viewBinding.recyclerView.adapter = adapter
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载模组活动
|
||||||
|
*/
|
||||||
|
fun loadMod() {
|
||||||
|
val dataList = ArrayList<GuideData>()
|
||||||
|
dataList.add(
|
||||||
|
GuideData(
|
||||||
|
R.string.create_mod_lable,
|
||||||
|
R.string.create_mod_describe,
|
||||||
|
R.drawable.ic_outline_create_24
|
||||||
|
)
|
||||||
|
)
|
||||||
|
dataList.add(
|
||||||
|
GuideData(
|
||||||
|
R.string.import_mod,
|
||||||
|
R.string.import_mod_from_file_manager_describe,
|
||||||
|
R.drawable.folder
|
||||||
|
)
|
||||||
|
)
|
||||||
|
dataList.add(
|
||||||
|
GuideData(
|
||||||
|
R.string.import_mod_from_package_directory,
|
||||||
|
R.string.import_mod_from_package_directory_describe,
|
||||||
|
R.drawable.zip
|
||||||
|
)
|
||||||
|
)
|
||||||
|
dataList.add(
|
||||||
|
GuideData(
|
||||||
|
R.string.import_mod_from_recycle_bin,
|
||||||
|
R.string.import_mod_from_recycle_bin_describe,
|
||||||
|
R.drawable.auto_delete
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val adapter = GuideAdapter(this, dataList)
|
||||||
|
adapter.setItemEvent { i, itemGuideBinding, viewHolder, guideData ->
|
||||||
|
itemGuideBinding.root.setOnClickListener {
|
||||||
|
finish()
|
||||||
|
when (guideData.titleRes) {
|
||||||
|
R.string.create_mod_lable -> {
|
||||||
|
startActivity(
|
||||||
|
Intent(
|
||||||
|
this,
|
||||||
|
CreateModActivity::class.java
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
R.string.import_mod -> {
|
||||||
|
val startIntent =
|
||||||
|
Intent(this, FileManagerActivity::class.java)
|
||||||
|
val fileBundle = Bundle()
|
||||||
|
fileBundle.putString("type", "selectFile")
|
||||||
|
startIntent.putExtra("data", fileBundle)
|
||||||
|
startActivity(startIntent)
|
||||||
|
}
|
||||||
|
R.string.import_mod_from_package_directory -> {
|
||||||
|
val startIntent =
|
||||||
|
Intent(this, FileManagerActivity::class.java)
|
||||||
|
val fileBundle = Bundle()
|
||||||
|
fileBundle.putString("type", "selectFile")
|
||||||
|
val packDirectory = appSettings.getValue(
|
||||||
|
AppSettings.Setting.PackDirectory,
|
||||||
|
AppSettings.dataRootDirectory + "/bin/"
|
||||||
|
)
|
||||||
|
fileBundle.putString("path", packDirectory)
|
||||||
|
fileBundle.putString("rootpath", packDirectory)
|
||||||
|
startIntent.putExtra("data", fileBundle)
|
||||||
|
startActivity(startIntent)
|
||||||
|
}
|
||||||
|
R.string.import_mod_from_recycle_bin -> {
|
||||||
|
startActivity(Intent(this, RecyclingStationActivity::class.java))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
viewBinding.recyclerView.adapter = adapter
|
||||||
|
}
|
||||||
|
|
||||||
override fun getViewBindingObject(): ActivityCreationWizardBinding {
|
override fun getViewBindingObject(): ActivityCreationWizardBinding {
|
||||||
return ActivityCreationWizardBinding.inflate(layoutInflater)
|
return ActivityCreationWizardBinding.inflate(layoutInflater)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,11 @@ package com.coldmint.rust.pro
|
||||||
|
|
||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
|
import android.content.DialogInterface
|
||||||
import com.coldmint.rust.pro.base.BaseActivity
|
import com.coldmint.rust.pro.base.BaseActivity
|
||||||
import com.coldmint.rust.pro.tool.GlobalMethod
|
import com.coldmint.rust.pro.tool.GlobalMethod
|
||||||
import com.coldmint.rust.core.iflynote.SquareBracketData
|
|
||||||
import android.content.pm.PackageInfo
|
import android.content.pm.PackageInfo
|
||||||
import com.coldmint.rust.pro.tool.AppSettings
|
import com.coldmint.rust.pro.tool.AppSettings
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
|
||||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
@ -25,6 +23,7 @@ import androidx.core.view.isVisible
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
import androidx.navigation.ui.*
|
import androidx.navigation.ui.*
|
||||||
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.coldmint.rust.core.CompressionManager
|
import com.coldmint.rust.core.CompressionManager
|
||||||
import com.coldmint.rust.core.TemplatePackage
|
import com.coldmint.rust.core.TemplatePackage
|
||||||
|
@ -42,6 +41,8 @@ import com.coldmint.rust.core.web.ServerConfiguration
|
||||||
import com.coldmint.rust.pro.databinding.ActivityMainBinding
|
import com.coldmint.rust.pro.databinding.ActivityMainBinding
|
||||||
import com.coldmint.rust.pro.databinding.HeadLayoutBinding
|
import com.coldmint.rust.pro.databinding.HeadLayoutBinding
|
||||||
import com.coldmint.rust.pro.viewmodel.StartViewModel
|
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.android.material.tabs.TabLayout
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.permissionx.guolindev.PermissionX
|
import com.permissionx.guolindev.PermissionX
|
||||||
|
@ -188,23 +189,23 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||||
}
|
}
|
||||||
//显示对话框
|
//显示对话框
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
val materialDialog = MaterialDialog(this@MainActivity, BottomSheet())
|
val materialAlertDialogBuilder =
|
||||||
materialDialog.title(text = data.title).message(text = data.content)
|
MaterialAlertDialogBuilder(this).setTitle(data.title).setMessage(data.content)
|
||||||
if (data.forced) {
|
if (data.forced) {
|
||||||
materialDialog.noAutoDismiss()
|
|
||||||
//禁用点击空白关闭
|
//禁用点击空白关闭
|
||||||
materialDialog.cancelable(false)
|
materialAlertDialogBuilder.setCancelable(false)
|
||||||
} else {
|
} else {
|
||||||
materialDialog.negativeButton(
|
materialAlertDialogBuilder.setNegativeButton(
|
||||||
R.string.dialog_cancel
|
R.string.dialog_cancel
|
||||||
)
|
) { i, i2 ->
|
||||||
|
}
|
||||||
}
|
}
|
||||||
materialDialog.positiveButton(
|
materialAlertDialogBuilder.setPositiveButton(
|
||||||
R.string.downlod
|
R.string.downlod
|
||||||
) {
|
) { i, i2 ->
|
||||||
AppOperator.useBrowserAccessWebPage(this, data.link)
|
AppOperator.useBrowserAccessWebPage(this, data.link)
|
||||||
}
|
}
|
||||||
materialDialog.show()
|
materialAlertDialogBuilder.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,20 +224,19 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||||
val versionCode = packageInfo.versionCode
|
val versionCode = packageInfo.versionCode
|
||||||
//如果在1.15 p3及以上 (159)
|
//如果在1.15 p3及以上 (159)
|
||||||
if (versionCode >= 159) {
|
if (versionCode >= 159) {
|
||||||
MaterialDialog(this).show {
|
MaterialAlertDialogBuilder(this).setTitle(R.string.game_configured)
|
||||||
title(R.string.game_configured).message(R.string.unable_to_detect)
|
.setMessage(R.string.unable_to_detect)
|
||||||
.positiveButton(R.string.show_details)
|
.setPositiveButton(R.string.show_details) { i, i2 ->
|
||||||
.positiveButton {
|
startActivity(
|
||||||
startActivity(
|
Intent(
|
||||||
Intent(
|
this@MainActivity,
|
||||||
this@MainActivity,
|
GameCheckActivity::class.java
|
||||||
GameCheckActivity::class.java
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}.neutralButton(R.string.no_longer_prompt).neutralButton {
|
)
|
||||||
appSettings.setValue(AppSettings.Setting.SetGameStorage, true)
|
}.setNeutralButton(R.string.no_longer_prompt) { i, i2 ->
|
||||||
}.negativeButton(R.string.dialog_cancel).cancelable(false)
|
appSettings.setValue(AppSettings.Setting.SetGameStorage, true)
|
||||||
}
|
}.setNeutralButton(R.string.dialog_cancel) { i, i2 ->
|
||||||
|
}.setCancelable(false).show()
|
||||||
} else {
|
} else {
|
||||||
appSettings.setValue(AppSettings.Setting.SetGameStorage, true)
|
appSettings.setValue(AppSettings.Setting.SetGameStorage, true)
|
||||||
}
|
}
|
||||||
|
@ -319,29 +319,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
templateItem -> {
|
templateItem -> {
|
||||||
val popupMenu = PopupMenu(this@MainActivity, viewBinding.mainButton)
|
val intent = Intent(this, CreationWizardActivity::class.java)
|
||||||
popupMenu.menu.add(R.string.create_template)
|
intent.putExtra("type", "template")
|
||||||
popupMenu.menu.add(R.string.import_template)
|
startActivity(intent)
|
||||||
popupMenu.setOnMenuItemClickListener { item ->
|
|
||||||
val title = item.title.toString()
|
|
||||||
if (title == getString(R.string.create_template)) {
|
|
||||||
startActivity(
|
|
||||||
Intent(
|
|
||||||
this@MainActivity,
|
|
||||||
CreateTemplateActivity::class.java
|
|
||||||
)
|
|
||||||
)
|
|
||||||
} else if (title == getString(R.string.import_template)) {
|
|
||||||
val startIntent =
|
|
||||||
Intent(this@MainActivity, FileManagerActivity::class.java)
|
|
||||||
val fileBundle = Bundle()
|
|
||||||
fileBundle.putString("type", "selectFile")
|
|
||||||
startIntent.putExtra("data", fileBundle)
|
|
||||||
startActivityForResult(startIntent, 2)
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
|
||||||
popupMenu.show()
|
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
Toast.makeText(this@MainActivity, "请设置事件", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this@MainActivity, "请设置事件", Toast.LENGTH_SHORT).show()
|
||||||
|
@ -581,17 +561,16 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||||
}
|
}
|
||||||
if (newInfo.versionNum < oldInfo.versionNum) {
|
if (newInfo.versionNum < oldInfo.versionNum) {
|
||||||
handler.post {
|
handler.post {
|
||||||
MaterialDialog(this).show {
|
MaterialAlertDialogBuilder(this).setTitle(oldInfo.name).setMessage(
|
||||||
title(text = oldInfo.name).cancelable(false).message(
|
String.format(
|
||||||
text = String.format(
|
getString(R.string.covers_the_import),
|
||||||
getString(R.string.covers_the_import),
|
newInfo.versionName, oldInfo.versionName
|
||||||
newInfo.versionName, oldInfo.versionName
|
)
|
||||||
)
|
).setPositiveButton(R.string.dialog_ok) { i, i2 ->
|
||||||
).positiveButton(R.string.dialog_ok).positiveButton {
|
FileOperator.delete_files(templateDirectory)
|
||||||
FileOperator.delete_files(templateDirectory)
|
importTemplate(formFile, templateDirectory)
|
||||||
importTemplate(formFile, templateDirectory)
|
}.setNegativeButton(R.string.dialog_cancel) { i, i2 ->
|
||||||
}.negativeButton(R.string.dialog_cancel)
|
}.show()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return@Runnable
|
return@Runnable
|
||||||
} else {
|
} else {
|
||||||
|
@ -663,16 +642,15 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||||
|
|
||||||
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
|
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.action == KeyEvent.ACTION_DOWN) {
|
if (keyCode == KeyEvent.KEYCODE_BACK && event.action == KeyEvent.ACTION_DOWN) {
|
||||||
MaterialDialog(this).show {
|
MaterialAlertDialogBuilder(this).setTitle(R.string.dialog_close).setMessage(
|
||||||
title(R.string.dialog_close).message(
|
String.format(
|
||||||
text = String.format(
|
getString(R.string.exit_tip),
|
||||||
getString(R.string.exit_tip),
|
getString(R.string.app_name)
|
||||||
getString(R.string.app_name)
|
)
|
||||||
)
|
).setPositiveButton(R.string.dialog_ok) { i, i2 ->
|
||||||
).cancelable(false).positiveButton(R.string.dialog_ok) {
|
finish()
|
||||||
finish()
|
}.setNegativeButton(R.string.dialog_cancel) { i, i2 ->
|
||||||
}.negativeButton(R.string.dialog_cancel)
|
}.show()
|
||||||
}
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return super.onKeyDown(keyCode, event)
|
return super.onKeyDown(keyCode, event)
|
||||||
|
@ -722,19 +700,17 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||||
|
|
||||||
startViewModel.needLoginLiveData.observe(this) {
|
startViewModel.needLoginLiveData.observe(this) {
|
||||||
if (it) {
|
if (it) {
|
||||||
MaterialDialog(this, BottomSheet()).show {
|
MaterialAlertDialogBuilder(this).setTitle(R.string.login)
|
||||||
title(R.string.login).message(R.string.login_tip).cancelable(false)
|
.setMessage(R.string.login_tip).setPositiveButton(R.string.login) { i, i2 ->
|
||||||
.positiveButton(R.string.login) {
|
startActivity(
|
||||||
startActivity(
|
Intent(
|
||||||
Intent(
|
this,
|
||||||
context,
|
LoginActivity::class.java
|
||||||
LoginActivity::class.java
|
)
|
||||||
)
|
)
|
||||||
)
|
}.setNegativeButton(R.string.dialog_close) { i, i2 ->
|
||||||
}.negativeButton(R.string.dialog_close).negativeButton {
|
finish()
|
||||||
finish()
|
}.show()
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
showGameConfiguredDialog()
|
showGameConfiguredDialog()
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,15 +14,15 @@ import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
|
||||||
import com.afollestad.materialdialogs.checkbox.checkBoxPrompt
|
|
||||||
import com.coldmint.rust.pro.R
|
import com.coldmint.rust.pro.R
|
||||||
import com.coldmint.rust.pro.databinding.ActivityWebModInfoBinding
|
import com.coldmint.rust.pro.databinding.ActivityWebModInfoBinding
|
||||||
import com.coldmint.rust.pro.interfaces.ItemChangeEvent
|
import com.coldmint.rust.pro.interfaces.ItemChangeEvent
|
||||||
import com.coldmint.rust.pro.interfaces.ItemEvent
|
import com.coldmint.rust.pro.interfaces.ItemEvent
|
||||||
import android.text.style.ForegroundColorSpan
|
import android.text.style.ForegroundColorSpan
|
||||||
import android.text.style.StyleSpan
|
import android.text.style.StyleSpan
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.core.text.toSpannable
|
import androidx.core.text.toSpannable
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
|
||||||
|
|
||||||
abstract class BaseAdapter<ViewBindingType : ViewBinding, DataType>(
|
abstract class BaseAdapter<ViewBindingType : ViewBinding, DataType>(
|
||||||
|
@ -147,38 +147,39 @@ abstract class BaseAdapter<ViewBindingType : ViewBinding, DataType>(
|
||||||
* @param cancelable Boolean 是否可取消
|
* @param cancelable Boolean 是否可取消
|
||||||
* @param checkBoxPrompt 选择框显示的文本
|
* @param checkBoxPrompt 选择框显示的文本
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("已废弃")
|
||||||
fun showDeleteItemDialog(
|
fun showDeleteItemDialog(
|
||||||
name: String,
|
name: String,
|
||||||
index: Int,
|
index: Int,
|
||||||
onClickPositiveButton: ((MaterialDialog, Boolean) -> Boolean)? = null,
|
onClickPositiveButton: ((Int, Boolean) -> Boolean)? = null,
|
||||||
cancelable: Boolean = false,
|
cancelable: Boolean = false,
|
||||||
checkBoxPrompt: String? = null
|
checkBoxPrompt: String? = null
|
||||||
): MaterialDialog {
|
) {
|
||||||
var checked = false
|
// var checked = false
|
||||||
val dialog = MaterialDialog(context)
|
// val dialog = MaterialAlertDialogBuilder(context)
|
||||||
if (checkBoxPrompt != null) {
|
// if (checkBoxPrompt != null) {
|
||||||
dialog.checkBoxPrompt(text = checkBoxPrompt, onToggle = {
|
// dialog.checkBoxPrompt(text = checkBoxPrompt, onToggle = {
|
||||||
checked = it
|
// checked = it
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
dialog.title(R.string.delete_title).message(
|
// dialog.title(R.string.delete_title).message(
|
||||||
text = String.format(
|
// text = String.format(
|
||||||
context.getString(R.string.delete_prompt),
|
// context.getString(R.string.delete_prompt),
|
||||||
name
|
// name
|
||||||
)
|
// )
|
||||||
).positiveButton(R.string.dialog_ok).positiveButton {
|
// ).positiveButton(R.string.dialog_ok).positiveButton {
|
||||||
if (onClickPositiveButton == null) {
|
// if (onClickPositiveButton == null) {
|
||||||
removeItem(index)
|
// removeItem(index)
|
||||||
} else {
|
// } else {
|
||||||
if (onClickPositiveButton.invoke(dialog, checked)) {
|
// if (onClickPositiveButton.invoke(dialog, checked)) {
|
||||||
removeItem(index)
|
// removeItem(index)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}.negativeButton(R.string.dialog_cancel).cancelable(cancelable)
|
// }.negativeButton(R.string.dialog_cancel).cancelable(cancelable)
|
||||||
handler.post {
|
// handler.post {
|
||||||
dialog.show()
|
// dialog.show()
|
||||||
}
|
// }
|
||||||
return dialog
|
// return dialog
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -119,6 +119,7 @@
|
||||||
<string name="open_action1">编辑文本</string>
|
<string name="open_action1">编辑文本</string>
|
||||||
|
|
||||||
<string name="import_template">导入模板包</string>
|
<string name="import_template">导入模板包</string>
|
||||||
|
<string name="import_template_describe">从文件管理导入模板包。</string>
|
||||||
<string name="import_mod">导入模组</string>
|
<string name="import_mod">导入模组</string>
|
||||||
<string name="import_mod_from_file_manager_describe">从文件管理导入模组。</string>
|
<string name="import_mod_from_file_manager_describe">从文件管理导入模组。</string>
|
||||||
<string name="import_mod_from_recycle_bin">回收站</string>
|
<string name="import_mod_from_recycle_bin">回收站</string>
|
||||||
|
@ -193,6 +194,7 @@
|
||||||
<string name="attach">附加</string>
|
<string name="attach">附加</string>
|
||||||
<string name="template_name">模板名称</string>
|
<string name="template_name">模板名称</string>
|
||||||
<string name="create_template">创建模板包</string>
|
<string name="create_template">创建模板包</string>
|
||||||
|
<string name="create_template_describe">创建一个模板包,用于存放单位动态模板。</string>
|
||||||
<string name="template_name_error">请输入模板名称。</string>
|
<string name="template_name_error">请输入模板名称。</string>
|
||||||
<string name="template_developer_error">请输入开发者。</string>
|
<string name="template_developer_error">请输入开发者。</string>
|
||||||
<string name="template_description_error">请输入描述。</string>
|
<string name="template_description_error">请输入描述。</string>
|
||||||
|
|
|
@ -4,5 +4,5 @@
|
||||||
# Location of the SDK. This is only used by Gradle.
|
# Location of the SDK. This is only used by Gradle.
|
||||||
# For customization when using a Version Control System, please read the
|
# For customization when using a Version Control System, please read the
|
||||||
# header note.
|
# header note.
|
||||||
#Wed Jul 06 10:56:35 CST 2022
|
#Wed Jul 06 21:08:32 CST 2022
|
||||||
sdk.dir=D\:\\Android_SDK
|
sdk.dir=D\:\\Document\\AndroidSdk
|
||||||
|
|
Loading…
Reference in New Issue
Block a user