Commit 03eb164d authored by zhaopengxiang's avatar zhaopengxiang

密码设置界面处理

parent eb4097d7
...@@ -55,6 +55,9 @@ ...@@ -55,6 +55,9 @@
<activity <activity
android:name=".ui.SettingActivity" android:name=".ui.SettingActivity"
android:exported="true" /> android:exported="true" />
<activity
android:name=".ui.ResetAuthorizePasswordActivity"
android:exported="true" />
</application> </application>
</manifest> </manifest>
\ No newline at end of file
package com.miya.fastcashier.ui package com.miya.fastcashier.ui
import android.Manifest import android.Manifest
import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.text.Editable import android.text.Editable
...@@ -28,6 +29,14 @@ class LoginActivity : AppCompatActivity() { ...@@ -28,6 +29,14 @@ class LoginActivity : AppCompatActivity() {
private lateinit var loginViewModel: LoginViewModel private lateinit var loginViewModel: LoginViewModel
private lateinit var binding: ActivityLoginBinding private lateinit var binding: ActivityLoginBinding
companion object{
fun start(context: Context, flags: Int) {
val intent = Intent(context, LoginActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or flags
context.startActivity(intent)
}
}
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
binding = ActivityLoginBinding.inflate(layoutInflater) binding = ActivityLoginBinding.inflate(layoutInflater)
......
package com.miya.fastcashier.ui
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.view.Gravity
import com.blankj.utilcode.util.ToastUtils
import com.miya.fastcashier.R
import com.miya.fastcashier.databinding.ActivityResetAuthorizePasswordBinding
import com.miya.fastcashier.databinding.ActivitySettingBinding
import com.miya.fastcashier.service.AccountService
import com.miya.fastcashier.ui.dialog.CommonDialog
import com.miya.fastcashier.utils.CenterToasty
import com.miya.fastcashier.utils.clickWithTrigger
import com.miya.fastcashier.utils.manage.AccountPasswordManageKit
import com.tencent.mmkv.MMKV
class ResetAuthorizePasswordActivity : BaseActivity() {
private lateinit var viewBinding: ActivityResetAuthorizePasswordBinding
companion object {
@JvmStatic
fun start(context: Context) {
val intent = Intent(context, ResetAuthorizePasswordActivity::class.java)
context.startActivity(intent)
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
viewBinding = ActivityResetAuthorizePasswordBinding.inflate(layoutInflater)
setContentView(viewBinding.root)
init()
}
private fun init() {
viewBinding.llBack.clickWithTrigger { finish() }
viewBinding.tvConfirm.clickWithTrigger { updateAuthorizePassword() }
}
private fun updateAuthorizePassword() {
val originPassword = viewBinding.etOriginPassword.text.toString()
val newPassword = viewBinding.etNewPassword.text.toString()
val newConfirmPassword = viewBinding.etNewPasswordConfirm.text.toString()
if (TextUtils.isEmpty(originPassword) or
TextUtils.isEmpty(newPassword) or
TextUtils.isEmpty(newConfirmPassword)
) {
when {
TextUtils.isEmpty(originPassword) -> CenterToasty.error(this, "请输入原始密码!").show()
TextUtils.isEmpty(newPassword) -> CenterToasty.error(this, "请输入新密码!").show()
TextUtils.isEmpty(newConfirmPassword) -> CenterToasty.error(this, "请输入确认密码!").show()
}
return
}
if (originPassword.length != 6) {
CenterToasty.error(this, "请输入6位原始密码!").show()
return
}
if (newPassword.length != 6) {
CenterToasty.error(this, "请输入6位新密码!").show()
return
}
if (newConfirmPassword.length != 6) {
CenterToasty.error(this, "请输入6位确认密码!").show()
return
}
if (!newPassword.equals(newConfirmPassword)) {
CenterToasty.error(this, "新密码两次输入不一致!").show()
return
}
val accountAuthorizePassword = AccountPasswordManageKit.getInstance().accountPassword
if (TextUtils.isEmpty(accountAuthorizePassword)) {
AccountPasswordManageKit.getInstance()
.loadAccountPassword(this, AccountPasswordManageKit.AccountPasswordManageCallback {
if (!it.equals(originPassword)) {
CenterToasty.error(this, "原始密码输入错误!").show()
}else{
updateAuthorizePasswordSucced(newPassword)
}
})
} else {
if (!accountAuthorizePassword.equals(originPassword)) {
CenterToasty.error(this, "原始密码输入错误!").show()
}else{
updateAuthorizePasswordSucced(newPassword)
}
}
}
private fun updateAuthorizePasswordSucced(newPassword: String) {
CenterToasty.success(this, "修改成功!", 1).show()
AccountPasswordManageKit.getInstance().updateAccountPassword(newPassword)
finish()
}
}
\ No newline at end of file
...@@ -37,7 +37,7 @@ class SettingActivity : BaseActivity() { ...@@ -37,7 +37,7 @@ class SettingActivity : BaseActivity() {
private fun init(){ private fun init(){
viewBinding.llBack.clickWithTrigger { finish() } viewBinding.llBack.clickWithTrigger { finish() }
viewBinding.vLoginOut.clickWithTrigger { loginOut() } viewBinding.vLoginOut.clickWithTrigger { loginOut() }
viewBinding.vUpdatePassword.clickWithTrigger { ToastUtils.showLong("点击修改密码") } viewBinding.vUpdatePassword.clickWithTrigger { ResetAuthorizePasswordActivity.start(this) }
} }
private fun loginOut() { private fun loginOut() {
...@@ -59,8 +59,7 @@ class SettingActivity : BaseActivity() { ...@@ -59,8 +59,7 @@ class SettingActivity : BaseActivity() {
run { run {
MMKV.defaultMMKV().clearAll() MMKV.defaultMMKV().clearAll()
AccountService.clear() AccountService.clear()
val intent = Intent(this@SettingActivity, LoginActivity::class.java) LoginActivity.start(this@SettingActivity, Intent.FLAG_ACTIVITY_CLEAR_TASK)
startActivity(intent)
finish() finish()
} }
} }
......
...@@ -121,6 +121,10 @@ public class AccountPasswordManageKit { ...@@ -121,6 +121,10 @@ public class AccountPasswordManageKit {
} }
} }
public String getAccountPassword() {
return AccountService.INSTANCE.getAccountPassword();
}
public void updateAccountPassword(String password) { public void updateAccountPassword(String password) {
if (TextUtils.isEmpty(password))return; if (TextUtils.isEmpty(password))return;
AccountService.INSTANCE.setAccountPassword(password); AccountService.INSTANCE.setAccountPassword(password);
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/color_111235" />
<corners
android:radius="8dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_E5E5E5"
tools:context=".ui.SettingActivity">
<View
android:id="@+id/v_top"
android:layout_width="match_parent"
android:layout_height="87dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="@color/colorPrimary"/>
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/ll_back"
android:layout_width="200dp"
android:layout_height="87dp"
android:orientation="horizontal"
android:gravity="center_vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatImageView
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/tvBack"
app:layout_constraintTop_toTopOf="@+id/tvBack"
app:layout_constraintBottom_toBottomOf="@+id/tvBack"
android:layout_width="24dp"
android:layout_height="48dp"
android:layout_marginLeft="32dp"
android:padding="6dp"
android:src="@mipmap/ic_left_arrow"
android:contentDescription="@string/back" />
<androidx.appcompat.widget.AppCompatTextView
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:textColor="@color/white"
android:text="@string/back"
android:textSize="24sp"/>
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="195dp"
android:layout_height="20dp"
android:layout_marginEnd="32dp"
android:layout_marginRight="32dp"
android:src="@mipmap/ic_logo_white"
app:layout_constraintBottom_toBottomOf="@+id/ll_back"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/ll_back" />
<View
android:id="@+id/v_origin_password"
android:layout_width="match_parent"
android:layout_height="103dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/v_top"
android:background="@color/white"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_origin_password_text"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:textSize="28sp"
android:gravity="left"
android:textColor="@color/color_333333"
app:layout_constraintStart_toStartOf="@id/v_origin_password"
app:layout_constraintTop_toTopOf="@id/v_origin_password"
app:layout_constraintBottom_toBottomOf="@id/v_origin_password"
android:text="@string/app_setting_origin_password"/>
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/et_origin_password"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:singleLine="true"
android:inputType="numberPassword"
android:layout_marginEnd="32dp"
android:gravity="center_vertical|left"
android:textSize="28sp"
android:textColor="@color/color_333333"
android:textColorHint="@color/color_CCCCCC"
android:hint="请输入原始密码"
android:maxLength="6"
app:layout_constraintLeft_toRightOf="@+id/tv_origin_password_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/v_origin_password"
app:layout_constraintBottom_toBottomOf="@id/v_origin_password" />
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/color_E9E9E9"
android:layout_marginStart="25dp"
android:layout_marginRight="25dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="@id/v_origin_password"/>
<View
android:id="@+id/v_new_password"
android:layout_width="match_parent"
android:layout_height="103dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/v_origin_password"
android:background="@color/white"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_new_password_text"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:text="@string/app_setting_new_password"
android:textColor="@color/color_333333"
android:textSize="28sp"
android:gravity="left"
app:layout_constraintBottom_toBottomOf="@id/v_new_password"
app:layout_constraintStart_toStartOf="@id/v_new_password"
app:layout_constraintTop_toTopOf="@id/v_new_password" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/et_new_password"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:singleLine="true"
android:inputType="numberPassword"
android:layout_marginEnd="32dp"
android:gravity="center_vertical|left"
android:textSize="28sp"
android:textColor="@color/color_333333"
android:textColorHint="@color/color_CCCCCC"
android:hint="请输入新密码"
android:maxLength="6"
app:layout_constraintLeft_toRightOf="@+id/tv_new_password_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/v_new_password"
app:layout_constraintBottom_toBottomOf="@id/v_new_password" />
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/color_E9E9E9"
android:layout_marginStart="25dp"
android:layout_marginRight="25dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="@id/v_new_password"/>
<View
android:id="@+id/v_new_password_confirm"
android:layout_width="match_parent"
android:layout_height="103dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/v_new_password"
android:background="@color/white"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_new_password_confirm_text"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginStart="32dp"
android:textSize="28sp"
android:gravity="left"
android:textColor="@color/color_333333"
app:layout_constraintStart_toStartOf="@id/v_new_password_confirm"
app:layout_constraintTop_toTopOf="@id/v_new_password_confirm"
app:layout_constraintBottom_toBottomOf="@id/v_new_password_confirm"
android:text="@string/app_setting_confirm_password"/>
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/et_new_password_confirm"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:singleLine="true"
android:inputType="numberPassword"
android:layout_marginEnd="32dp"
android:gravity="center_vertical|left"
android:textSize="28sp"
android:textColor="@color/color_333333"
android:textColorHint="@color/color_CCCCCC"
android:hint="请再次输入密码"
android:maxLength="6"
app:layout_constraintLeft_toRightOf="@+id/tv_new_password_confirm_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/v_new_password_confirm"
app:layout_constraintBottom_toBottomOf="@id/v_new_password_confirm" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_confirm"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:textSize="32sp"
android:gravity="center"
android:textColor="@color/white"
android:layout_marginBottom="65dp"
android:background="@drawable/shape_111235_radius8"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:text="@string/app_confirm_update"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -18,4 +18,6 @@ ...@@ -18,4 +18,6 @@
<color name="color_E5E5E5">#E5E5E5</color> <color name="color_E5E5E5">#E5E5E5</color>
<color name="color_E9E9E9">#E9E9E9</color> <color name="color_E9E9E9">#E9E9E9</color>
<color name="color_D83773">#D83773</color> <color name="color_D83773">#D83773</color>
<color name="color_CCCCCC">#CCCCCC</color>
<color name="color_111235">#111235</color>
</resources> </resources>
\ No newline at end of file
...@@ -26,5 +26,9 @@ ...@@ -26,5 +26,9 @@
<string name="app_login_out">退出登录</string> <string name="app_login_out">退出登录</string>
<string name="text_refund_amount">退款金额¥%s,是否确认退款</string> <string name="text_refund_amount">退款金额¥%s,是否确认退款</string>
<string name="text_update_account_password">修改授权密码</string> <string name="text_update_account_password">修改授权密码</string>
<string name="app_setting_origin_password">原始密码</string>
<string name="app_setting_new_password">新密码</string>
<string name="app_setting_confirm_password">确认密码</string>
<string name="app_confirm_update">确认修改</string>
</resources> </resources>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment