统一验证码按钮的效果
This commit is contained in:
@@ -108,11 +108,10 @@ class ForgetPasswordActivity : AppCompatActivity() {
|
|||||||
* 开始验证码按钮倒计时
|
* 开始验证码按钮倒计时
|
||||||
*/
|
*/
|
||||||
private fun startCountDown() {
|
private fun startCountDown() {
|
||||||
|
binding.sendCodeBtn.isEnabled = false
|
||||||
countDownTimer = object : CountDownTimer(COUNTDOWN_DURATION, COUNTDOWN_INTERVAL) {
|
countDownTimer = object : CountDownTimer(COUNTDOWN_DURATION, COUNTDOWN_INTERVAL) {
|
||||||
override fun onTick(millisUntilFinished: Long) {
|
override fun onTick(millisUntilFinished: Long) {
|
||||||
val secondsRemaining = (millisUntilFinished / 1000).toInt()
|
binding.sendCodeBtn.text = getString(R.string.countdown_retry, millisUntilFinished / 1000)
|
||||||
binding.sendCodeBtn.text = "${secondsRemaining}秒后重试"
|
|
||||||
binding.sendCodeBtn.isEnabled = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFinish() {
|
override fun onFinish() {
|
||||||
|
|||||||
@@ -100,11 +100,10 @@ class RegisterActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun startCountDown() {
|
private fun startCountDown() {
|
||||||
|
binding.sendCodeBtn.isEnabled = false
|
||||||
countDownTimer = object : CountDownTimer(COUNTDOWN_DURATION, COUNTDOWN_INTERVAL) {
|
countDownTimer = object : CountDownTimer(COUNTDOWN_DURATION, COUNTDOWN_INTERVAL) {
|
||||||
override fun onTick(millisUntilFinished: Long) {
|
override fun onTick(millisUntilFinished: Long) {
|
||||||
val secondsRemaining = (millisUntilFinished / 1000).toInt()
|
binding.sendCodeBtn.text = getString(R.string.countdown_retry, millisUntilFinished / 1000)
|
||||||
binding.sendCodeBtn.text = "${secondsRemaining}秒后重试"
|
|
||||||
binding.sendCodeBtn.isEnabled = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFinish() {
|
override fun onFinish() {
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ class RetrievePasswordActivity : AppCompatActivity() {
|
|||||||
override fun onFinish() {
|
override fun onFinish() {
|
||||||
isCountingDown = false
|
isCountingDown = false
|
||||||
binding.btnGetCode.isEnabled = true
|
binding.btnGetCode.isEnabled = true
|
||||||
binding.btnGetCode.text = getString(R.string.get_verification_code)
|
binding.btnGetCode.text = getString(R.string.resend_code)
|
||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,19 +140,20 @@
|
|||||||
<!-- 发送验证码按钮 -->
|
<!-- 发送验证码按钮 -->
|
||||||
<android.widget.Button
|
<android.widget.Button
|
||||||
android:id="@+id/sendCodeBtn"
|
android:id="@+id/sendCodeBtn"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="110dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="36dp"
|
||||||
android:text="@string/send_code"
|
android:minWidth="0dp"
|
||||||
android:textSize="16sp"
|
android:minHeight="0dp"
|
||||||
|
android:text="@string/send_sms_code"
|
||||||
|
android:textSize="14sp"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:background="@drawable/rounded_blue_bg"
|
android:background="@drawable/send_code_btn_selector"
|
||||||
android:paddingHorizontal="12dp"
|
android:elevation="0dp"
|
||||||
android:maxWidth="120dp"
|
android:stateListAnimator="@null"
|
||||||
|
android:gravity="center"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:elevation="0dp"
|
|
||||||
android:stateListAnimator="@null"
|
|
||||||
android:layout_marginStart="12dp" />
|
android:layout_marginStart="12dp" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|||||||
@@ -140,16 +140,17 @@
|
|||||||
<!-- 发送验证码按钮 -->
|
<!-- 发送验证码按钮 -->
|
||||||
<android.widget.Button
|
<android.widget.Button
|
||||||
android:id="@+id/sendCodeBtn"
|
android:id="@+id/sendCodeBtn"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="110dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="36dp"
|
||||||
|
android:minWidth="0dp"
|
||||||
|
android:minHeight="0dp"
|
||||||
android:text="@string/send_sms_code"
|
android:text="@string/send_sms_code"
|
||||||
android:textSize="16sp"
|
android:textSize="14sp"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:background="@drawable/rounded_blue_bg"
|
android:background="@drawable/send_code_btn_selector"
|
||||||
android:paddingHorizontal="12dp"
|
|
||||||
android:maxWidth="120dp"
|
|
||||||
android:elevation="0dp"
|
android:elevation="0dp"
|
||||||
android:stateListAnimator="@null"
|
android:stateListAnimator="@null"
|
||||||
|
android:gravity="center"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
|||||||
@@ -82,17 +82,19 @@
|
|||||||
|
|
||||||
<android.widget.Button
|
<android.widget.Button
|
||||||
android:id="@+id/btnGetCode"
|
android:id="@+id/btnGetCode"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="110dp"
|
||||||
android:layout_height="36dp"
|
android:layout_height="36dp"
|
||||||
|
android:minWidth="0dp"
|
||||||
|
android:minHeight="0dp"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginRight="8dp"
|
android:layout_marginRight="8dp"
|
||||||
android:background="@drawable/rounded_blue_bg"
|
android:background="@drawable/send_code_btn_selector"
|
||||||
android:paddingHorizontal="16dp"
|
android:text="@string/send_sms_code"
|
||||||
android:text="@string/get_verification_code"
|
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:elevation="0dp"
|
android:elevation="0dp"
|
||||||
android:stateListAnimator="@null"
|
android:stateListAnimator="@null"
|
||||||
|
android:gravity="center"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user