refactor(app): 删除无用的布局文件和活动代码
- 删除了 ErrorActivity、RegisterActivity 和 ReportActivity 的布局文件 - 删除了 CreateModActivity、RecyclingStationActivity、WarehouseFragment 中的无用代码 - 优化了 TabLayout 的配置 - 添加了新的字符串资源
This commit is contained in:
parent
91961754e0
commit
f392dc98b7
|
@ -7220,7 +7220,7 @@ androidx.media.R$style
|
|||
kotlin.UNumbersKt
|
||||
kotlin.reflect.TypeVariableImpl
|
||||
androidx.appcompat.widget.TooltipCompatHandler$1
|
||||
com.coldmint.rust.pro.CreateModActivity
|
||||
com.coldmint.rust.pro.Activity
|
||||
kotlin.collections.MapsKt__MapsJVMKt
|
||||
androidx.appcompat.widget.ToolbarWidgetWrapper$1
|
||||
com.bumptech.glide.load.model.ByteArrayLoader$StreamFactory
|
||||
|
|
|
@ -114,29 +114,23 @@ class CreateModActivity : BaseActivity<ActivityCreateModBinding>() {
|
|||
stringBuilder.append("\nminVersion: ")
|
||||
stringBuilder.append(minVersion)
|
||||
}
|
||||
GlobalMethod.requestStoragePermissions(this@CreateModActivity) {
|
||||
if (!it) {
|
||||
return@requestStoragePermissions
|
||||
}
|
||||
val mod_directory =
|
||||
val modDirectory =
|
||||
File(Environment.getExternalStorageDirectory().absolutePath + "/rustedWarfare/units/" + name)
|
||||
if (mod_directory.exists()) {
|
||||
if (modDirectory.exists()) {
|
||||
setErrorAndInput(
|
||||
viewBinding.modNameEdit,
|
||||
getString(R.string.directory_error),
|
||||
viewBinding.modNameInputLayout
|
||||
)
|
||||
} else {
|
||||
if (mod_directory.mkdirs()) {
|
||||
val fileWriter = FileWriter(mod_directory.absolutePath + "/mod-info.txt")
|
||||
if (modDirectory.mkdirs()) {
|
||||
val fileWriter = FileWriter(modDirectory.absolutePath + "/mod-info.txt")
|
||||
fileWriter.write(stringBuilder.toString())
|
||||
fileWriter.close()
|
||||
setResult(RESULT_OK)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.view.KeyEvent
|
|||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import cat.ereza.customactivityoncrash.CustomActivityOnCrash
|
||||
import com.coldmint.rust.core.debug.LogCat
|
||||
import com.coldmint.rust.core.tool.FileOperator
|
||||
import com.coldmint.rust.pro.base.BaseActivity
|
||||
import com.coldmint.rust.pro.databean.ErrorInfo
|
||||
|
@ -19,7 +18,6 @@ class ErrorActivity : BaseActivity<ActivityErrorBinding>() {
|
|||
ErrorInfo()
|
||||
}
|
||||
|
||||
|
||||
private fun initView() {
|
||||
setTitle(R.string.collapse_info)
|
||||
val title = String.format(getString(R.string.error_title), getString(R.string.app_name))
|
||||
|
@ -37,7 +35,6 @@ class ErrorActivity : BaseActivity<ActivityErrorBinding>() {
|
|||
errorInfo.activityLog = CustomActivityOnCrash.getActivityLogFromIntent(intent)
|
||||
}
|
||||
viewBinding.errorInfo.text = errorInfo.allErrorDetails
|
||||
LogCat.e("错误日志", errorInfo.allErrorDetails)
|
||||
saveLog()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.coldmint.rust.pro.adapters.FileAdapter
|
|||
import com.coldmint.rust.pro.databinding.ActivityRecyclingStationBinding
|
||||
import com.coldmint.rust.pro.tool.GlobalMethod
|
||||
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import java.io.File
|
||||
import java.util.ArrayList
|
||||
|
||||
|
@ -81,6 +82,10 @@ class RecyclingStationActivity : BaseActivity<ActivityRecyclingStationBinding>()
|
|||
}
|
||||
val title = item.title.toString()
|
||||
if (title == getString(R.string.delete_title)) {
|
||||
MaterialAlertDialogBuilder(this@RecyclingStationActivity)
|
||||
.setTitle(R.string.delete_title).setCancelable(false)
|
||||
.setMessage(R.string.delete_confirm)
|
||||
.setPositiveButton(R.string.dialog_ok) { _, _ ->
|
||||
Thread {
|
||||
working = true
|
||||
FileOperator.delete_files(file)
|
||||
|
@ -89,6 +94,9 @@ class RecyclingStationActivity : BaseActivity<ActivityRecyclingStationBinding>()
|
|||
loadFiles()
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
.setNegativeButton(R.string.dialog_cancel) { _, _ -> }
|
||||
.show()
|
||||
} else if (title == getString(R.string.recovery_file)) {
|
||||
Thread {
|
||||
working = true
|
||||
|
@ -139,6 +147,10 @@ class RecyclingStationActivity : BaseActivity<ActivityRecyclingStationBinding>()
|
|||
val id = item.itemId
|
||||
when (id) {
|
||||
R.id.clear_recovery_station -> {
|
||||
MaterialAlertDialogBuilder(this)
|
||||
.setTitle(R.string.clear_recovery_station)
|
||||
.setMessage(R.string.clear_recovery_station_message).setCancelable(false)
|
||||
.setPositiveButton(R.string.dialog_ok) { _, _ ->
|
||||
Thread {
|
||||
runOnUiThread {
|
||||
viewBinding.progressBar.isVisible = true
|
||||
|
@ -154,8 +166,12 @@ class RecyclingStationActivity : BaseActivity<ActivityRecyclingStationBinding>()
|
|||
viewBinding.backupError.setText(R.string.not_find_mod)
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
.setNegativeButton(R.string.dialog_cancel, null)
|
||||
.show()
|
||||
return true
|
||||
}
|
||||
|
||||
R.id.restore_all -> {
|
||||
Thread {
|
||||
runOnUiThread {
|
||||
|
|
|
@ -1,425 +0,0 @@
|
|||
package com.coldmint.rust.pro
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.InputType
|
||||
import android.text.TextWatcher
|
||||
import android.view.LayoutInflater
|
||||
import com.coldmint.rust.pro.base.BaseActivity
|
||||
import android.view.View
|
||||
import androidx.core.view.isVisible
|
||||
import com.coldmint.dialog.CoreDialog
|
||||
import com.coldmint.rust.pro.tool.AppSettings
|
||||
import com.coldmint.rust.pro.tool.GlobalMethod
|
||||
import com.coldmint.rust.core.interfaces.ApiCallBack
|
||||
import com.coldmint.rust.core.web.ServerConfiguration
|
||||
import com.coldmint.rust.core.dataBean.ApiResponse
|
||||
import com.coldmint.rust.core.dataBean.RegisterRequestData
|
||||
import com.coldmint.rust.core.web.User
|
||||
import com.coldmint.rust.pro.databinding.ActivityRegisterBinding
|
||||
import com.coldmint.rust.pro.tool.EmailAutoCompleteHelper
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
|
||||
class RegisterActivity : BaseActivity<ActivityRegisterBinding>() {
|
||||
private var isRegister = false
|
||||
|
||||
private fun initAction() {
|
||||
viewBinding.userNameView.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
val userName = s.toString()
|
||||
checkUserName(userName)
|
||||
setRegisterButtonEnable()
|
||||
}
|
||||
})
|
||||
|
||||
viewBinding.accountView.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
val account = s.toString()
|
||||
checkAccount(account)
|
||||
setRegisterButtonEnable()
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
viewBinding.passwordView.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
val passWord = s.toString()
|
||||
checkPassword(passWord)
|
||||
setRegisterButtonEnable()
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
viewBinding.confirmPasswordView.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 confirmPassword = p0.toString()
|
||||
checkConfirmPassword(confirmPassword)
|
||||
setRegisterButtonEnable()
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
viewBinding.emailView.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
val email = s.toString()
|
||||
checkEmail(email)
|
||||
setRegisterButtonEnable()
|
||||
}
|
||||
|
||||
})
|
||||
val emailAutoCompleteHelper = EmailAutoCompleteHelper(this)
|
||||
emailAutoCompleteHelper.onBindAutoCompleteTextView(viewBinding.emailView)
|
||||
|
||||
viewBinding.registerButton.setOnClickListener(View.OnClickListener { v ->
|
||||
inputMethodManager.hideSoftInputFromWindow(v.windowToken, 0)
|
||||
if (!isRegister) {
|
||||
val account = viewBinding.accountView.text.toString()
|
||||
val passWord = viewBinding.passwordView.text.toString()
|
||||
val userName = viewBinding.userNameView.text.toString()
|
||||
val email = viewBinding.emailView.text.toString()
|
||||
val confirmPassword = viewBinding.confirmPasswordView.text.toString()
|
||||
|
||||
if (!checkConfirmPassword(confirmPassword)) {
|
||||
return@OnClickListener
|
||||
}
|
||||
|
||||
if (!checkAccount(account)) {
|
||||
return@OnClickListener
|
||||
}
|
||||
|
||||
if (!checkUserName(userName)) {
|
||||
return@OnClickListener
|
||||
}
|
||||
|
||||
if (!checkPassword(passWord)) {
|
||||
return@OnClickListener
|
||||
}
|
||||
|
||||
if (!checkEmail(email)) {
|
||||
return@OnClickListener
|
||||
}
|
||||
|
||||
isRegister = true
|
||||
viewBinding.registerButton.setBackgroundColor(
|
||||
GlobalMethod.getThemeColor(
|
||||
this@RegisterActivity,
|
||||
com.google.android.material.R.attr.colorPrimaryVariant
|
||||
)
|
||||
)
|
||||
viewBinding.registerButton.setText(R.string.request_data)
|
||||
val appID = AppSettings.getValue(AppSettings.Setting.AppID, "")
|
||||
User.register(
|
||||
RegisterRequestData(account, passWord, userName, email, appID),
|
||||
object : ApiCallBack<ApiResponse> {
|
||||
override fun onResponse(apiResponse: ApiResponse) {
|
||||
isRegister = false
|
||||
viewBinding.registerButton.setBackgroundColor(
|
||||
GlobalMethod.getColorPrimary(
|
||||
this@RegisterActivity
|
||||
)
|
||||
)
|
||||
viewBinding.registerButton.setText(R.string.register)
|
||||
if (apiResponse.code == ServerConfiguration.Success_Code) {
|
||||
AppSettings.forceSetValue(AppSettings.Setting.Account, account)
|
||||
AppSettings.forceSetValue(AppSettings.Setting.PassWord, passWord)
|
||||
AppSettings.forceSetValue(AppSettings.Setting.UserName, userName)
|
||||
CoreDialog(this@RegisterActivity).setTitle(R.string.register_successed)
|
||||
.setMessage(R.string.registration_success_message)
|
||||
.setCancelable(false).setPositiveButton(R.string.close) {
|
||||
finish()
|
||||
}.show()
|
||||
} else {
|
||||
val data = apiResponse.data
|
||||
if (data != null && ServerConfiguration.isEvent(data)) {
|
||||
when (data) {
|
||||
"@event:账号占用" -> {
|
||||
setErrorAndInput(
|
||||
viewBinding.accountView,
|
||||
getString(R.string.account_error2),
|
||||
viewBinding.accountInputLayout
|
||||
)
|
||||
}
|
||||
"@event:用户名占用" -> {
|
||||
setErrorAndInput(
|
||||
viewBinding.userNameView,
|
||||
getString(R.string.user_name_error),
|
||||
viewBinding.userNameInputLayout
|
||||
)
|
||||
}
|
||||
"@event:邮箱占用" -> {
|
||||
setErrorAndInput(
|
||||
viewBinding.emailView,
|
||||
getString(R.string.email_error2),
|
||||
viewBinding.emailInputLayout
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
Snackbar.make(
|
||||
viewBinding.registerButton,
|
||||
apiResponse.message,
|
||||
Snackbar.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Snackbar.make(
|
||||
viewBinding.registerButton,
|
||||
apiResponse.message,
|
||||
Snackbar.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(e: Exception) {
|
||||
isRegister = false
|
||||
viewBinding.registerButton.setBackgroundColor(
|
||||
GlobalMethod.getColorPrimary(
|
||||
this@RegisterActivity
|
||||
)
|
||||
)
|
||||
viewBinding.registerButton.setText(R.string.register)
|
||||
showInternetError(viewBinding.registerButton, e)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查邮箱
|
||||
* @param email String
|
||||
* @return Boolean
|
||||
*/
|
||||
fun checkEmail(email: String, updateView: Boolean = true): Boolean {
|
||||
return if (email.isBlank()) {
|
||||
if (updateView) {
|
||||
setErrorAndInput(
|
||||
viewBinding.emailView,
|
||||
String.format(
|
||||
getString(R.string.please_input_value),
|
||||
viewBinding.emailInputLayout.hint.toString()
|
||||
), viewBinding.emailInputLayout
|
||||
)
|
||||
}
|
||||
false
|
||||
} else {
|
||||
if (email.matches(Regex("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$"))) {
|
||||
if (updateView) {
|
||||
viewBinding.emailInputLayout.isErrorEnabled = false
|
||||
}
|
||||
true
|
||||
} else {
|
||||
if (updateView) {
|
||||
setErrorAndInput(
|
||||
viewBinding.emailView,
|
||||
getString(R.string.email_error), viewBinding.emailInputLayout, false
|
||||
)
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查确认密码
|
||||
* @param confirmPassword String
|
||||
* @return Boolean
|
||||
*/
|
||||
fun checkConfirmPassword(confirmPassword: String, updateView: Boolean = true): Boolean {
|
||||
return if (confirmPassword.isBlank()) {
|
||||
if (updateView) {
|
||||
setErrorAndInput(
|
||||
viewBinding.confirmPasswordView, String.format(
|
||||
getString(R.string.please_input_value),
|
||||
viewBinding.confirmPasswordInputLayout.hint.toString()
|
||||
), viewBinding.confirmPasswordInputLayout
|
||||
)
|
||||
}
|
||||
false
|
||||
} else {
|
||||
val passWord = viewBinding.passwordView.text.toString()
|
||||
if (passWord == confirmPassword) {
|
||||
if (updateView) {
|
||||
viewBinding.confirmPasswordInputLayout.isErrorEnabled = false
|
||||
}
|
||||
true
|
||||
} else {
|
||||
if (updateView) {
|
||||
setErrorAndInput(
|
||||
viewBinding.confirmPasswordView,
|
||||
getString(R.string.confirm_password_error),
|
||||
viewBinding.confirmPasswordInputLayout,
|
||||
false
|
||||
)
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查密码
|
||||
* @param passWord String
|
||||
* @return Boolean
|
||||
*/
|
||||
fun checkPassword(passWord: String, updateView: Boolean = true): Boolean {
|
||||
return if (passWord.isBlank()) {
|
||||
if (updateView) {
|
||||
setErrorAndInput(
|
||||
viewBinding.passwordView,
|
||||
getString(R.string.please_enter_your_password),
|
||||
viewBinding.passwordInputLayout
|
||||
)
|
||||
}
|
||||
false
|
||||
} else {
|
||||
if (passWord.matches(Regex("^[a-zA-Z0-9_]{6,20}\$"))) {
|
||||
if (updateView) {
|
||||
viewBinding.passwordInputLayout.isErrorEnabled = false
|
||||
}
|
||||
true
|
||||
} else {
|
||||
if (updateView) {
|
||||
setErrorAndInput(
|
||||
viewBinding.passwordView,
|
||||
getString(R.string.password_error),
|
||||
viewBinding.passwordInputLayout, false
|
||||
)
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查用户名
|
||||
* @param userName String
|
||||
* @return Boolean
|
||||
*/
|
||||
fun checkUserName(userName: String, updateView: Boolean = true): Boolean {
|
||||
return if (userName.isBlank()) {
|
||||
if (updateView) {
|
||||
setErrorAndInput(
|
||||
viewBinding.userNameView,
|
||||
String.format(
|
||||
getString(R.string.please_input_value),
|
||||
viewBinding.userNameInputLayout.hint.toString()
|
||||
),
|
||||
viewBinding.userNameInputLayout
|
||||
)
|
||||
}
|
||||
false
|
||||
} else {
|
||||
if (updateView) {
|
||||
viewBinding.userNameInputLayout.isErrorEnabled = false
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查账号是否合法
|
||||
* @param account String
|
||||
* @return Boolean
|
||||
*/
|
||||
fun checkAccount(account: String, updateView: Boolean = true): Boolean {
|
||||
if (account.isBlank()) {
|
||||
if (updateView) {
|
||||
setErrorAndInput(
|
||||
viewBinding.accountView,
|
||||
getString(R.string.please_enter_your_account), viewBinding.accountInputLayout
|
||||
)
|
||||
}
|
||||
return false
|
||||
} else {
|
||||
return if (account.matches(Regex("^[A-Za-z0-9_]+\$"))) {
|
||||
if (updateView) {
|
||||
viewBinding.accountInputLayout.isErrorEnabled = false
|
||||
}
|
||||
true
|
||||
} else {
|
||||
if (updateView) {
|
||||
setErrorAndInput(
|
||||
viewBinding.accountView,
|
||||
getString(R.string.account_error), viewBinding.accountInputLayout, false
|
||||
)
|
||||
}
|
||||
false
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置注册按钮启用状态
|
||||
*/
|
||||
fun setRegisterButtonEnable() {
|
||||
val account = viewBinding.accountView.text.toString()
|
||||
val passWord = viewBinding.passwordView.text.toString()
|
||||
val userName = viewBinding.userNameView.text.toString()
|
||||
val email = viewBinding.emailView.text.toString()
|
||||
val confirmPassword = viewBinding.confirmPasswordView.text.toString()
|
||||
viewBinding.registerButton.isEnabled =
|
||||
checkConfirmPassword(confirmPassword, false) && checkAccount(
|
||||
account,
|
||||
false
|
||||
) && checkUserName(userName, false) && checkPassword(
|
||||
passWord
|
||||
) && checkEmail(email, false)
|
||||
}
|
||||
|
||||
override fun getViewBindingObject(layoutInflater: LayoutInflater): ActivityRegisterBinding {
|
||||
return ActivityRegisterBinding.inflate(layoutInflater)
|
||||
}
|
||||
|
||||
override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) {
|
||||
if (canUseView) {
|
||||
title = getString(R.string.register)
|
||||
setReturnButton()
|
||||
initAction()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,202 +0,0 @@
|
|||
package com.coldmint.rust.pro
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.ArrayAdapter
|
||||
import com.coldmint.rust.core.dataBean.ApiResponse
|
||||
import com.coldmint.rust.core.interfaces.ApiCallBack
|
||||
import com.coldmint.rust.core.web.Report
|
||||
import com.coldmint.rust.core.web.ServerConfiguration
|
||||
import com.coldmint.rust.pro.base.BaseActivity
|
||||
import com.coldmint.rust.pro.databinding.ActivityReportBinding
|
||||
import com.coldmint.rust.pro.tool.AppSettings
|
||||
import com.coldmint.rust.pro.tool.GlobalMethod
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
|
||||
/**
|
||||
* 举报活动
|
||||
* @author Cold Mint
|
||||
* @date 2022/1/6 15:38
|
||||
*/
|
||||
class ReportActivity : BaseActivity<ActivityReportBinding>() {
|
||||
lateinit var type: String
|
||||
lateinit var target: String
|
||||
|
||||
override fun getViewBindingObject(layoutInflater: LayoutInflater): ActivityReportBinding {
|
||||
return ActivityReportBinding.inflate(layoutInflater)
|
||||
}
|
||||
|
||||
override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) {
|
||||
if (canUseView) {
|
||||
title = getText(R.string.report)
|
||||
setReturnButton()
|
||||
val bundle = intent.getBundleExtra("data")
|
||||
if (bundle == null) {
|
||||
showError("无效的启动方式")
|
||||
return
|
||||
}
|
||||
val temType = bundle.getString("type")
|
||||
if (temType == null) {
|
||||
showError("请设置启动类型")
|
||||
return
|
||||
}
|
||||
if (temType != "mod" && temType != "user") {
|
||||
showError("type只能是mod或user")
|
||||
return
|
||||
}
|
||||
type = temType
|
||||
val temTarget = bundle.getString("target")
|
||||
if (temTarget == null) {
|
||||
showError("请输入目标")
|
||||
return
|
||||
}
|
||||
val name = bundle.getString("name")
|
||||
if (name == null) {
|
||||
showError("请输入名称")
|
||||
return
|
||||
}
|
||||
|
||||
val account = AppSettings.getValue(AppSettings.Setting.Account, "")
|
||||
if (account.isBlank()) {
|
||||
showError(getString(R.string.please_login_first))
|
||||
return
|
||||
}
|
||||
val newTitle = String.format(getString(R.string.report_t), name)
|
||||
viewBinding.toolbar.title = newTitle
|
||||
|
||||
target = temTarget
|
||||
viewBinding.describeEdit.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(
|
||||
s: CharSequence?,
|
||||
start: Int,
|
||||
count: Int,
|
||||
after: Int
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
val describe = s.toString()
|
||||
checkDescribe(describe)
|
||||
enableButton()
|
||||
}
|
||||
|
||||
})
|
||||
viewBinding.whyEditText.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(
|
||||
s: CharSequence?,
|
||||
start: Int,
|
||||
count: Int,
|
||||
after: Int
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
val describe = s.toString()
|
||||
checkWhy(describe)
|
||||
enableButton()
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
viewBinding.reportButton.setOnClickListener {
|
||||
val actionType = viewBinding.reportButton.text.toString()
|
||||
if (actionType == getString(R.string.submit)) {
|
||||
val describe = viewBinding.describeEdit.text.toString()
|
||||
if (checkDescribe(describe)) {
|
||||
inputMethodManager.hideSoftInputFromWindow(it.windowToken, 0)
|
||||
viewBinding.reportButton.setText(R.string.request_data)
|
||||
Report.instance.send(
|
||||
account,
|
||||
type,
|
||||
target,
|
||||
viewBinding.whyEditText.text.toString(),
|
||||
describe,
|
||||
object : ApiCallBack<ApiResponse> {
|
||||
override fun onResponse(t: ApiResponse) {
|
||||
if (t.code == ServerConfiguration.Success_Code) {
|
||||
viewBinding.reportButton.setText(R.string.submit_complete)
|
||||
} else {
|
||||
Snackbar.make(
|
||||
viewBinding.reportButton,
|
||||
t.message,
|
||||
Snackbar.LENGTH_SHORT
|
||||
).show()
|
||||
viewBinding.reportButton.setText(R.string.submit_failure)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(e: Exception) {
|
||||
viewBinding.reportButton.setText(R.string.submit_failure)
|
||||
showInternetError(viewBinding.reportButton, e)
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun enableButton() {
|
||||
val why = checkWhy(viewBinding.whyEditText.text.toString(), false)
|
||||
val describe = checkDescribe(viewBinding.describeEdit.text.toString(), false)
|
||||
viewBinding.reportButton.isEnabled = why && describe
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查描述
|
||||
*/
|
||||
fun checkDescribe(describe: String, updateUi: Boolean = true): Boolean {
|
||||
return if (describe.isBlank()) {
|
||||
if (updateUi) {
|
||||
setErrorAndInput(
|
||||
viewBinding.describeEdit,
|
||||
getString(R.string.describe_error), viewBinding.describeInputLayout
|
||||
)
|
||||
}
|
||||
false
|
||||
} else {
|
||||
if (updateUi) {
|
||||
viewBinding.describeInputLayout.isErrorEnabled = false
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查描述
|
||||
*/
|
||||
fun checkWhy(describe: String, updateUi: Boolean = true): Boolean {
|
||||
return if (describe.isBlank()) {
|
||||
if (updateUi) {
|
||||
setErrorAndInput(
|
||||
viewBinding.whyEditText,
|
||||
String.format(
|
||||
getString(R.string.please_input_value),
|
||||
viewBinding.whyLayout.hint
|
||||
), viewBinding.whyLayout
|
||||
)
|
||||
}
|
||||
false
|
||||
} else {
|
||||
if (updateUi) {
|
||||
viewBinding.whyLayout.isErrorEnabled = false
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +1,14 @@
|
|||
package com.coldmint.rust.pro.fragments
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.coldmint.rust.pro.CreationWizardActivity
|
||||
import com.coldmint.rust.pro.R
|
||||
import com.coldmint.rust.pro.adapters.WarehouseAdapter
|
||||
import com.coldmint.rust.pro.base.BaseFragment
|
||||
import com.coldmint.rust.pro.databinding.FragmentWarehouseBinding
|
||||
import com.coldmint.rust.pro.tool.GlobalMethod
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
import com.hjq.permissions.OnPermissionCallback
|
||||
import com.hjq.permissions.XXPermissions
|
||||
|
||||
|
||||
/**
|
||||
|
@ -22,12 +16,7 @@ import com.hjq.permissions.XXPermissions
|
|||
* @date 2022/1/5 10:18
|
||||
*/
|
||||
class WarehouseFragment : BaseFragment<FragmentWarehouseBinding>() {
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
private fun loadTab() {
|
||||
// 在需要申请权限的地方调用如下方法
|
||||
GlobalMethod.requestStoragePermissions(requireActivity()) {
|
||||
|
||||
}
|
||||
if (isAdded) {
|
||||
TabLayoutMediator(viewBinding.tabLayout, viewBinding.pager) { tab, position ->
|
||||
when (position) {
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:card_view="http://schemas.android.com/tools"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -46,27 +45,6 @@
|
|||
style="@style/TextAppearance.Material3.BodyMedium"
|
||||
android:text="@string/error_content" />
|
||||
|
||||
<!-- <com.google.android.material.textfield.TextInputLayout-->
|
||||
<!-- android:id="@+id/inputLayout"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_below="@id/subTitleView"-->
|
||||
<!-- android:layout_marginTop="8dp"-->
|
||||
<!-- app:counterEnabled="true"-->
|
||||
<!-- app:counterMaxLength="1500">-->
|
||||
|
||||
<!-- <com.google.android.material.textfield.TextInputEditText-->
|
||||
<!-- android:id="@+id/inputEditView"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:hint="@string/error_description"-->
|
||||
<!-- android:imeOptions="actionDone"-->
|
||||
<!-- android:inputType="textMultiLine"-->
|
||||
<!-- android:maxLength="1500"-->
|
||||
<!-- android:maxLines="5" />-->
|
||||
|
||||
<!-- </com.google.android.material.textfield.TextInputLayout>-->
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="@style/Widget.Material3.CardView.Filled"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -1,147 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/accountInputLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:counterEnabled="true"
|
||||
app:counterMaxLength="20"
|
||||
app:helperText="@string/account_tip">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/accountView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/account"
|
||||
android:imeOptions="actionNext"
|
||||
android:inputType="text"
|
||||
android:maxLength="20"
|
||||
android:maxLines="1" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/userNameInputLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
app:counterEnabled="true"
|
||||
app:counterMaxLength="20">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/userNameView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/user_name"
|
||||
android:imeOptions="actionNext"
|
||||
android:inputType="text"
|
||||
android:maxLength="20" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/passwordInputLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
app:counterEnabled="true"
|
||||
app:counterMaxLength="20"
|
||||
app:passwordToggleEnabled="true">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/passwordView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/password"
|
||||
android:imeOptions="actionNext"
|
||||
android:inputType="textPassword"
|
||||
android:maxLength="20" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/confirmPasswordInputLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
app:counterEnabled="true"
|
||||
app:counterMaxLength="20"
|
||||
app:passwordToggleEnabled="true">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/confirmPasswordView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/confirm_password"
|
||||
android:imeOptions="actionNext"
|
||||
android:inputType="textPassword"
|
||||
android:maxLength="20" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/Widget.Material3.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
||||
android:id="@+id/emailInputLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:counterEnabled="true"
|
||||
app:counterMaxLength="30">
|
||||
|
||||
<com.google.android.material.textfield.MaterialAutoCompleteTextView
|
||||
android:id="@+id/emailView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/email"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="textEmailAddress"
|
||||
android:maxLength="30"
|
||||
android:maxLines="1" />
|
||||
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/registerButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:enabled="false"
|
||||
android:text="@string/register" />
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -1,87 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:card_view="http://schemas.android.com/tools"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".ActivateActivity">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginRight="16dp"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:hint="@string/why"
|
||||
android:id="@+id/whyLayout"
|
||||
style="@style/Widget.Material3.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.textfield.MaterialAutoCompleteTextView
|
||||
android:layout_width="match_parent"
|
||||
android:inputType="none"
|
||||
android:id="@+id/whyEditText"
|
||||
app:simpleItems="@array/report_entries"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/describeInputLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="8dp"
|
||||
app:counterEnabled="true"
|
||||
app:counterMaxLength="255">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/describeEdit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/describe"
|
||||
android:imeOptions="actionNext"
|
||||
android:minLines="3"
|
||||
android:gravity="top"
|
||||
android:inputType="textMultiLine"
|
||||
android:maxLength="255"
|
||||
android:maxLines="10" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<Button
|
||||
android:enabled="false"
|
||||
android:layout_marginTop="16dp"
|
||||
android:id="@+id/reportButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/submit" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -2,8 +2,8 @@
|
|||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -17,12 +17,10 @@
|
|||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/tabLayout"
|
||||
android:background="@android:color/transparent"
|
||||
android:layout_width="match_parent"
|
||||
app:tabGravity="center"
|
||||
app:tabMode="auto"
|
||||
app:tabMaxWidth="300dp"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
app:tabTextAppearance="@style/TabLayoutTextStyle" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
|
|
|
@ -4,20 +4,25 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/tabLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent" />
|
||||
android:background="@android:color/transparent"
|
||||
app:tabTextAppearance="@style/TabLayoutTextStyle" />
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/mainButton"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -618,4 +618,6 @@
|
|||
<string name="variable_name">变量名</string>
|
||||
<string name="permission_request_title">请求权限</string>
|
||||
<string name="permission_request_message">我们需要存储权限以访问您的模组。</string>
|
||||
<string name="clear_recovery_station_message">清空回收站,被删除的文件将无法恢复。</string>
|
||||
<string name="delete_confirm">删除后将无法恢复。</string>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user