diff --git a/.gradle/7.2/executionHistory/executionHistory.bin b/.gradle/7.2/executionHistory/executionHistory.bin index a97c33b..5554001 100644 Binary files a/.gradle/7.2/executionHistory/executionHistory.bin and b/.gradle/7.2/executionHistory/executionHistory.bin differ diff --git a/.gradle/7.2/executionHistory/executionHistory.lock b/.gradle/7.2/executionHistory/executionHistory.lock index 5ab627c..480fbfb 100644 Binary files a/.gradle/7.2/executionHistory/executionHistory.lock and b/.gradle/7.2/executionHistory/executionHistory.lock differ diff --git a/.gradle/7.2/fileHashes/fileHashes.bin b/.gradle/7.2/fileHashes/fileHashes.bin index 4efe282..4420b95 100644 Binary files a/.gradle/7.2/fileHashes/fileHashes.bin and b/.gradle/7.2/fileHashes/fileHashes.bin differ diff --git a/.gradle/7.2/fileHashes/fileHashes.lock b/.gradle/7.2/fileHashes/fileHashes.lock index f7a5660..bee5ea8 100644 Binary files a/.gradle/7.2/fileHashes/fileHashes.lock and b/.gradle/7.2/fileHashes/fileHashes.lock differ diff --git a/.gradle/7.2/fileHashes/resourceHashesCache.bin b/.gradle/7.2/fileHashes/resourceHashesCache.bin index 9543f71..17e50da 100644 Binary files a/.gradle/7.2/fileHashes/resourceHashesCache.bin and b/.gradle/7.2/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index c132f7c..5201224 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin index 06dc650..32b0e55 100644 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/app/build.gradle b/app/build.gradle index ae2fe15..1cb9d3c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,9 +6,6 @@ plugins { } android { - lintOptions { - baseline file("lint-baseline.xml") - } signingConfigs { debug { storeFile file('keystore\\coldmint_debug.keystore') @@ -63,6 +60,9 @@ android { buildFeatures { viewBinding true } + lint { + baseline file('lint-baseline.xml') + } } diff --git a/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt b/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt index 7285d2c..b64a825 100644 --- a/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt @@ -63,6 +63,7 @@ class LoginActivity : BaseActivity() { } else { viewBinding.root.setBackgroundResource(0) } + setLoginButtonEnable() } }) @@ -79,6 +80,7 @@ class LoginActivity : BaseActivity() { override fun afterTextChanged(s: Editable?) { val passWord = s.toString() checkPassword(passWord) + setLoginButtonEnable() } }) @@ -357,6 +359,7 @@ class LoginActivity : BaseActivity() { val agree = appSettings.getValue(AppSettings.Setting.AgreePolicy, false) viewBinding.checkbox.isChecked = agree viewBinding.checkbox.setOnCheckedChangeListener { p0, p1 -> + setLoginButtonEnable() appSettings.setValue(AppSettings.Setting.AgreePolicy, p1) } @@ -407,38 +410,72 @@ class LoginActivity : BaseActivity() { } } - fun checkAccount(account: String): Boolean { + /** + * 检查账号 + * @param account String + * @param updateView Boolean + * @return Boolean + */ + fun checkAccount(account: String, updateView: Boolean = true): Boolean { return if (account.isBlank()) { - setErrorAndInput( - viewBinding.accountView, - getString(R.string.please_enter_your_account_or_email), - viewBinding.accountInputLayout - ) + if (updateView) { + setErrorAndInput( + viewBinding.accountView, + getString(R.string.please_enter_your_account_or_email), + viewBinding.accountInputLayout + ) + } false } else { - viewBinding.accountInputLayout.isErrorEnabled = false + if (updateView) { + viewBinding.accountInputLayout.isErrorEnabled = false + } true } } - fun checkPassword(passWord: String): Boolean { + /** + * 设置登录按钮 + */ + fun setLoginButtonEnable() { + viewBinding.button.isEnabled = + checkAccount(viewBinding.accountView.text.toString(), false) && checkPassword( + viewBinding.passwordView.text.toString(), + false + ) && viewBinding.checkbox.isChecked + } + + + /** + * 检查密码 + * @param passWord String + * @param updateView Boolean + * @return Boolean + */ + fun checkPassword(passWord: String, updateView: Boolean = true): Boolean { return if (passWord.isBlank()) { - setErrorAndInput( - viewBinding.passwordView, - getString(R.string.please_enter_your_password), - viewBinding.passwordInputLayout - ) + 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}\$"))) { - viewBinding.passwordInputLayout.isErrorEnabled = false + if (updateView) { + viewBinding.passwordInputLayout.isErrorEnabled = false + } true } else { - setErrorAndInput( - viewBinding.passwordView, - getString(R.string.password_error), - viewBinding.passwordInputLayout, false - ) + if (updateView) { + setErrorAndInput( + viewBinding.passwordView, + getString(R.string.password_error), + viewBinding.passwordInputLayout, false + ) + } false } } diff --git a/app/src/main/java/com/coldmint/rust/pro/RegisterActivity.kt b/app/src/main/java/com/coldmint/rust/pro/RegisterActivity.kt index 6db260b..ae02e2e 100644 --- a/app/src/main/java/com/coldmint/rust/pro/RegisterActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/RegisterActivity.kt @@ -6,6 +6,7 @@ import android.text.InputType import android.text.TextWatcher import com.coldmint.rust.pro.base.BaseActivity import android.view.View +import androidx.core.view.isVisible import com.coldmint.rust.pro.tool.AppSettings import com.coldmint.rust.pro.tool.GlobalMethod import com.coldmint.rust.core.interfaces.ApiCallBack @@ -34,7 +35,7 @@ class RegisterActivity : BaseActivity() { override fun afterTextChanged(s: Editable?) { val userName = s.toString() checkUserName(userName) - + setRegisterButtonEnable() } }) @@ -50,6 +51,7 @@ class RegisterActivity : BaseActivity() { override fun afterTextChanged(s: Editable?) { val account = s.toString() checkAccount(account) + setRegisterButtonEnable() } }) @@ -66,6 +68,24 @@ class RegisterActivity : BaseActivity() { 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() } }) @@ -82,6 +102,7 @@ class RegisterActivity : BaseActivity() { override fun afterTextChanged(s: Editable?) { val email = s.toString() checkEmail(email) + setRegisterButtonEnable() } }) @@ -125,6 +146,11 @@ class RegisterActivity : BaseActivity() { 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 @@ -231,49 +257,111 @@ class RegisterActivity : BaseActivity() { } - fun checkEmail(email: String): Boolean { + /** + * 检查邮箱 + * @param email String + * @return Boolean + */ + fun checkEmail(email: String, updateView: Boolean = true): Boolean { return if (email.isBlank()) { - setErrorAndInput( - viewBinding.emailView, - String.format( - getString(R.string.please_input_value), - viewBinding.emailInputLayout.hint.toString() - ), viewBinding.emailInputLayout - ) + if (updateView) { + viewBinding.mailHelpTextView.isVisible = true + 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+)*\$"))) { - viewBinding.emailInputLayout.isErrorEnabled = false + if (updateView) { + viewBinding.emailInputLayout.isErrorEnabled = false + viewBinding.mailHelpTextView.isVisible = false + } true } else { - setErrorAndInput( - viewBinding.emailView, - getString(R.string.email_error), viewBinding.emailInputLayout, false - ) + if (updateView) { + viewBinding.mailHelpTextView.isVisible = true + 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 + } - fun checkPassword(passWord: String): Boolean { + } + } + + /** + * 检查密码 + * @param passWord String + * @return Boolean + */ + fun checkPassword(passWord: String, updateView: Boolean = true): Boolean { return if (passWord.isBlank()) { - setErrorAndInput( - viewBinding.passwordView, - getString(R.string.please_enter_your_password), - viewBinding.passwordInputLayout - ) + 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}\$"))) { - viewBinding.passwordInputLayout.isErrorEnabled = false + if (updateView) { + viewBinding.passwordInputLayout.isErrorEnabled = false + } true } else { - setErrorAndInput( - viewBinding.passwordView, - getString(R.string.password_error), - viewBinding.passwordInputLayout, false - ) + if (updateView) { + setErrorAndInput( + viewBinding.passwordView, + getString(R.string.password_error), + viewBinding.passwordInputLayout, false + ) + } false } } @@ -284,19 +372,23 @@ class RegisterActivity : BaseActivity() { * @param userName String * @return Boolean */ - fun checkUserName(userName: String): Boolean { + fun checkUserName(userName: String, updateView: Boolean = true): Boolean { return if (userName.isBlank()) { - setErrorAndInput( - viewBinding.userNameView, - String.format( - getString(R.string.please_input_value), - viewBinding.userNameInputLayout.hint.toString() - ), - viewBinding.userNameInputLayout - ) + if (updateView) { + setErrorAndInput( + viewBinding.userNameView, + String.format( + getString(R.string.please_input_value), + viewBinding.userNameInputLayout.hint.toString() + ), + viewBinding.userNameInputLayout + ) + } false } else { - viewBinding.userNameInputLayout.isErrorEnabled = false + if (updateView) { + viewBinding.userNameInputLayout.isErrorEnabled = false + } true } } @@ -306,28 +398,52 @@ class RegisterActivity : BaseActivity() { * @param account String * @return Boolean */ - fun checkAccount(account: String): Boolean { + fun checkAccount(account: String, updateView: Boolean = true): Boolean { if (account.isBlank()) { - setErrorAndInput( - viewBinding.accountView, - getString(R.string.please_enter_your_account), viewBinding.accountInputLayout - ) + 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_]+\$"))) { - viewBinding.accountInputLayout.isErrorEnabled = false + if (updateView) { + viewBinding.accountInputLayout.isErrorEnabled = false + } true } else { - setErrorAndInput( - viewBinding.accountView, - getString(R.string.account_error), viewBinding.accountInputLayout, false - ) + 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(): ActivityRegisterBinding { return ActivityRegisterBinding.inflate(layoutInflater) } diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 25c42e3..f2bcf43 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -63,6 +63,7 @@ android:layout_height="wrap_content" android:layout_below="@id/passwordInputLayout" android:layout_marginTop="8dp" + android:enabled="false" android:text="@string/login" /> @@ -75,7 +76,6 @@ android:text="@string/agreement_agreed" /> - + + + + + + + android:textSize="13sp" + android:visibility="gone" /> @@ -135,6 +156,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" + android:enabled="false" android:text="@string/register" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 12c1e44..7871508 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -825,4 +825,6 @@ QQ号 建议您使用QQ邮箱注册,请输入QQ号,我们会自动填充您的QQ邮箱。 邮箱地址填充完成。 + 确认密码 + 两次密码不一致。 \ No newline at end of file diff --git a/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/CodeCompiler2.kt b/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/CodeCompiler2.kt index ee9b7a8..2d1500e 100644 --- a/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/CodeCompiler2.kt +++ b/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/CodeCompiler2.kt @@ -156,7 +156,6 @@ class CodeCompiler2 private constructor(val context: Context) : CodeCompilerInte translatorListener.beforeTranslate() translatorListener.onTranslateComplete(code) } - } else { val tokenizer = StringTokenizer(code, split, true) //缓存翻译数据,以便加速重复数据的翻译 @@ -166,6 +165,8 @@ class CodeCompiler2 private constructor(val context: Context) : CodeCompilerInte //保存完整的翻译结果 val translationResult = StringBuilder() var codeBlockType = CompileConfiguration.CodeBlockType.Key + //保存资源引用值(应该看做整体处理) + val referenceResult = StringBuilder() handler.post { translatorListener.beforeTranslate() } @@ -177,23 +178,46 @@ class CodeCompiler2 private constructor(val context: Context) : CodeCompilerInte codeResult.delete(0, codeResult.length) when (code) { "\n" -> { + if (codeBlockType == CompileConfiguration.CodeBlockType.Reference) { + val referenceValue = referenceResult.toString() + val codeInfo = + codeDataBase.getCodeDao().findCodeByCode(referenceValue) + if (codeInfo == null) { + translationResult.append(referenceResult) + }else{ +// tr + } + } codeBlockType = CompileConfiguration.CodeBlockType.Key codeResult.append(code) } "\r" -> { } - " ", ",", "(", ")", "=", "%", "{", "}", "+", "*", "/" -> codeResult.append( - code - ) - ":" -> { - if (codeBlockType == CompileConfiguration.CodeBlockType.Key) { - codeBlockType = - CompileConfiguration.CodeBlockType.Value + " ", ",", "(", ")", "=", "%", "{", "}", "+", "*", "/" -> { + if (codeBlockType == CompileConfiguration.CodeBlockType.Reference) { + referenceResult.append(code) + } else { + codeResult.append( + code + ) + } + } + ":" -> { + if (codeBlockType == CompileConfiguration.CodeBlockType.Reference) { + referenceResult.append(code) + } else { + if (codeBlockType == CompileConfiguration.CodeBlockType.Key) { + codeBlockType = + CompileConfiguration.CodeBlockType.Value + } + codeResult.append(code) } - codeResult.append(code) } else -> if (codeBlockType == CompileConfiguration.CodeBlockType.Note) { codeResult.append(code) + } else if (codeBlockType == CompileConfiguration.CodeBlockType.Reference) { + //资源引用值应该被整体处理 + referenceResult.append(code) } else { if (code.startsWith("#")) { codeBlockType = CompileConfiguration.CodeBlockType.Note @@ -258,7 +282,7 @@ class CodeCompiler2 private constructor(val context: Context) : CodeCompilerInte if (!tag.isNullOrBlank()) { //如果此类型为特殊标注,那么设置为注释 codeBlockType = - CompileConfiguration.CodeBlockType.Note + CompileConfiguration.CodeBlockType.Reference } } codeResult.append(codeInfo.translate) diff --git a/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/dataBean/CompileConfiguration.kt b/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/dataBean/CompileConfiguration.kt index d770a44..e9f0303 100644 --- a/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/dataBean/CompileConfiguration.kt +++ b/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/dataBean/CompileConfiguration.kt @@ -118,10 +118,11 @@ data class CompileConfiguration( /** * 代码块类 - * 键,值,节,注释,变量名 + * 键,值,节,注释,变量名,引用 + * Reference 引用是一种特殊的数据类型,编译器会尝试编译此值,若无法编译则使用原始值 */ enum class CodeBlockType { - Key, Value, Section, Note, VariableName + Key, Value, Section, Note, VariableName, Reference } /** diff --git a/build.gradle b/build.gradle index 9911159..88f09ba 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { maven { url 'https://repo1.maven.org/maven2/' } } dependencies { - classpath 'com.android.tools.build:gradle:7.1.2' + classpath 'com.android.tools.build:gradle:7.1.3' // classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5" classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10' diff --git a/local.properties b/local.properties index f1710d4..d1253cb 100644 --- a/local.properties +++ b/local.properties @@ -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. -#Sat Mar 26 20:50:56 CST 2022 -sdk.dir=D\:\\Document\\AndroidSdk +#Sat Apr 23 18:41:07 CST 2022 +sdk.dir=D\:\\Android_SDK