90 lines
3.5 KiB
Kotlin
90 lines
3.5 KiB
Kotlin
package com.yingmao.clash.act
|
|
|
|
import android.content.Intent
|
|
import android.os.Bundle
|
|
import android.widget.TextView
|
|
import androidx.appcompat.widget.AppCompatImageView
|
|
import androidx.constraintlayout.widget.ConstraintLayout
|
|
import androidx.lifecycle.ViewModelProvider
|
|
import com.cncat.vpn.common.log.Log
|
|
import com.tencent.mmkv.MMKV
|
|
import com.yingmao.clash.R
|
|
import com.yingmao.clash.act.MainActivity.Companion.isSubbed
|
|
import com.yingmao.clash.act.MainActivity.Companion.profileBinder
|
|
import com.yingmao.clash.base.BaseActivity
|
|
import com.yingmao.clash.conf.BZYConstants
|
|
import com.yingmao.clash.util.CommonUtils
|
|
import com.yingmao.clash.vm.MainAtyVM
|
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
|
import kotlinx.coroutines.Dispatchers
|
|
import kotlinx.coroutines.GlobalScope
|
|
import kotlinx.coroutines.launch
|
|
|
|
class MineInfoActivity: BaseActivity() {
|
|
private lateinit var clChanPsw:ConstraintLayout
|
|
private lateinit var clFoodPsw:ConstraintLayout
|
|
private lateinit var tvChange: TextView
|
|
private lateinit var mainAtyVM: MainAtyVM
|
|
private lateinit var aiBack:AppCompatImageView
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
setContentView(R.layout.mine_layout)
|
|
mainAtyVM = ViewModelProvider(this).get(MainAtyVM::class.java)
|
|
observe(this, mainAtyVM)
|
|
initView()
|
|
}
|
|
|
|
private fun initView() {
|
|
aiBack=findViewById(R.id.aiBack)
|
|
clChanPsw=findViewById(R.id.clChanPsw)
|
|
clFoodPsw=findViewById(R.id.clFowdPsw)
|
|
tvChange=findViewById(R.id.tvChange)
|
|
aiBack.setOnClickListener {
|
|
finish()
|
|
}
|
|
tvChange.setOnClickListener {
|
|
cleanUserInfo()
|
|
}
|
|
clChanPsw.setOnClickListener {
|
|
val intent = Intent(this, ChangePwdActivity::class.java)
|
|
startActivity(intent)
|
|
}
|
|
clFoodPsw.setOnClickListener {
|
|
val intent = Intent(this, ForGetPwdActivity::class.java)
|
|
startActivity(intent)
|
|
}
|
|
|
|
}
|
|
private fun cleanUserInfo() {
|
|
MMKV.defaultMMKV().removeValueForKey(BZYConstants.MMKV_KEY_PH_TOKEN)
|
|
MMKV.defaultMMKV().removeValueForKey(BZYConstants.MMKV_KEY_TOKEN)
|
|
MMKV.defaultMMKV().removeValueForKey(BZYConstants.MMKV_KEY_CURRENT_NODE)
|
|
MMKV.defaultMMKV().removeValueForKey(BZYConstants.NODE_SELECTED_NAME_KEY)
|
|
MMKV.defaultMMKV().removeValueForKey(BZYConstants.MMKV_KEY_VPN_UserCommand)
|
|
MMKV.defaultMMKV().removeValueForKey(BZYConstants.NODE_All_ITEM_NAME_KEY)
|
|
MMKV.defaultMMKV().removeValueForKey(BZYConstants.PROFILE_SUB_URL)
|
|
MMKV.defaultMMKV().removeValueForKey(BZYConstants.MMKV_KEY_Switch_Finsh_Set)
|
|
isSubbed =false
|
|
MainActivity().stopUploadTimer()
|
|
mainAtyVM.stopHeartBeat()
|
|
cleanProfile()
|
|
val intent=Intent(CommonUtils.getApp(), LoginActivity::class.java)
|
|
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK
|
|
startActivity(intent)
|
|
finish()
|
|
}
|
|
@OptIn(DelicateCoroutinesApi::class)
|
|
private fun cleanProfile() {
|
|
Log.d("cleanProfile start")
|
|
GlobalScope.launch(Dispatchers.IO) {
|
|
profileBinder?.let { pm ->
|
|
pm.queryAll().forEach { profile ->
|
|
Log.d("cleanProfile go delete name==>${profile.name}, uuid==>${profile.uuid}")
|
|
pm.delete(profile.uuid)
|
|
}
|
|
} ?: let {
|
|
Log.d("profileBinder is null")
|
|
}
|
|
}
|
|
}
|
|
} |