适配中英文切换

This commit is contained in:
2026-05-08 16:39:15 +08:00
parent 428b5e507f
commit 5ee50d3785
38 changed files with 1248 additions and 191 deletions

View File

@@ -114,24 +114,24 @@ class LoginActivity : AppCompatActivity() {
binding.loginBtn.setOnClickListener {
val phone = binding.etPhone.text.toString()
if (phone.isEmpty()) {
Toast.makeText(this, "请输入手机号", Toast.LENGTH_SHORT).show()
Toast.makeText(this, R.string.enter_phone_number, Toast.LENGTH_SHORT).show()
return@setOnClickListener
}
when (currentLoginMode) {
LoginMode.SMS -> {
val code = binding.etSmsCode.text.toString()
if (code.isEmpty()) {
Toast.makeText(this, "请输入验证码", Toast.LENGTH_SHORT).show()
Toast.makeText(this, R.string.enter_verification_code_pls, Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(this, "验证码登录成功\n手机号:$phone\n验证码:$code", Toast.LENGTH_SHORT).show()
Toast.makeText(this, getString(R.string.sms_login_success, phone, code), Toast.LENGTH_SHORT).show()
}
}
LoginMode.PASSWORD -> {
val pwd = binding.etPassword.text.toString()
if (pwd.isEmpty()) {
Toast.makeText(this, "请输入密码", Toast.LENGTH_SHORT).show()
Toast.makeText(this, R.string.password_hint, Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(this, "密码登录成功\n手机号:$phone\n密码:$pwd", Toast.LENGTH_SHORT).show()
Toast.makeText(this, getString(R.string.password_login_success, phone, pwd), Toast.LENGTH_SHORT).show()
}
}
}
@@ -140,23 +140,23 @@ class LoginActivity : AppCompatActivity() {
binding.sendCodeBtn.setOnClickListener {
val phone = binding.etPhone.text.toString()
if (phone.isEmpty()) {
Toast.makeText(this, "请先输入手机号", Toast.LENGTH_SHORT).show()
Toast.makeText(this, R.string.phone_hint, Toast.LENGTH_SHORT).show()
return@setOnClickListener
}
Toast.makeText(this, "验证码已发送至 $phone", Toast.LENGTH_SHORT).show()
Toast.makeText(this, getString(R.string.code_sent_to, phone), Toast.LENGTH_SHORT).show()
startCountDown()
}
binding.registerText.setOnClickListener {
val intent= Intent(this, RegisterActivity::class.java)
startActivity(intent)
Toast.makeText(this, "跳转到注册页面", Toast.LENGTH_SHORT).show()
Toast.makeText(this, R.string.redirect_register_page, Toast.LENGTH_SHORT).show()
}
binding.forgetText.setOnClickListener {
val intent= Intent(this, ForgetPasswordActivity::class.java)
startActivity(intent)
Toast.makeText(this, "找回密码", Toast.LENGTH_SHORT).show()
Toast.makeText(this, R.string.forgot_password_page, Toast.LENGTH_SHORT).show()
}
}
@@ -164,10 +164,10 @@ class LoginActivity : AppCompatActivity() {
binding.sendCodeBtn.isEnabled = false
object : CountDownTimer(60000, 1000) {
override fun onTick(millisUntilFinished: Long) {
binding.sendCodeBtn.text = "${millisUntilFinished / 1000}秒后重试"
binding.sendCodeBtn.text = getString(R.string.countdown_retry, millisUntilFinished / 1000)
}
override fun onFinish() {
binding.sendCodeBtn.text = "发送验证码"
binding.sendCodeBtn.text = getString(R.string.send_code)
binding.sendCodeBtn.isEnabled = true
}
}.start()