一键连

1.去除流量显示功能
2.去除冗余代码
3.修改启动时多次获取节点导致返回码异常的问题
This commit is contained in:
level 2025-12-12 15:42:21 +08:00
parent b130f2e92f
commit dc8cc818f8
8 changed files with 8 additions and 288 deletions

View File

@ -136,10 +136,6 @@
android:process=":background"
android:screenOrientation="portrait"
/>
<activity android:name=".act.MineInfoActivity"
android:process=":background"
android:screenOrientation="portrait"
/>
<activity
android:name=".act.NodeGroupActivity"
android:process=":background"

View File

@ -60,6 +60,7 @@ import com.yingmao.clash.remote.Remote
import com.yingmao.clash.util.AESUtil
import com.yingmao.clash.util.CommonUtils
import com.yingmao.clash.util.Utils
import com.yingmao.clash.util.stopClashService
import com.yingmao.clash.view.RxToast
import com.yingmao.clash.view.dialog.ActivityViewDialog
import com.yingmao.clash.view.dialog.ActivityViewDialog.OnDialogClickListener
@ -249,7 +250,9 @@ class MainActivity : BaseActivity() {
val u = jo.get("upload").asLong
val trafficUsedInGB = String.format("%.2f", (d + u) / 1024.0 / 1024.0 / 1024.0)
val trafficTolTelInGB = String.format("%.2f", t / 1024.0 / 1024.0 / 1024.0)
trafficStatisticsData.value = "流量统计:${trafficUsedInGB}GB / ${trafficTolTelInGB}GB"
val userTrafficStr = "流量统计:${trafficUsedInGB}GB / ${trafficTolTelInGB}GB"
trafficStatisticsData.value =userTrafficStr
Log.i("userTrafficMethod::${userTrafficStr}")
}
private fun initData() {
clashBinder = MainApplication.getApp()?.let { ClashManager(it).wrap() as IClashManager }
@ -536,7 +539,7 @@ class MainActivity : BaseActivity() {
payResultLoading!!.show()
}
public fun cleanUserInfo() {
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)
@ -549,7 +552,7 @@ class MainActivity : BaseActivity() {
//清除源切换记录
if (clashRunning) {
fragments.filterIsInstance<HomeFragment>().forEach { it.stopClash() }
stopClashService()
}
isSubed=false
stopUploadTimer()

View File

@ -1,90 +0,0 @@
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")
}
}
}
}

View File

@ -131,11 +131,8 @@ open class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispa
val serStore by lazy { ServiceStore(requireActivity()) }
private var currentNode: MutableList<NodeGroupItem> = mutableListOf()
private val mPageInfo = ExpensesRecordActivity.PageInfo()
private var reConnection = false
private var connectId = -1
var proList: MutableList<ClashNodebBean>? = null
private var baseLoadingView: RxDialogShapeLoading? = null
override fun init(
@ -254,10 +251,6 @@ open class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispa
startActivityForResult(intent, 2)
}
tvIntelligentMode.setOnClickListener {
// if(clashRunning){
// RxToast.info(resources.getString(R.string.SwitchingSourceModel))
// return@setOnClickListener
// }
val getIsGlo= MMKV.defaultMMKV().decodeBool(BZYConstants.MMKV_KEY_GLOBAL_MODEL, false)
Log.d("clIntelligentMode ==>${getIsGlo}")
if(getIsGlo){
@ -417,7 +410,6 @@ open class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispa
}
delay(500)
}
refreshNode()
val vpnRequest = context?.startClashService()
try {
startUTimer()

View File

@ -107,9 +107,6 @@ class SettingFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatc
private var baseLoad: RxDialogShapeLoading? = null
private lateinit var mainAtyVM: MainAtyVM
private lateinit var tvUseNet: TextView
private var settingPageList = mutableListOf<SettingPageBean>()
@RequiresApi(Build.VERSION_CODES.O)
override fun init(
@ -386,18 +383,7 @@ class SettingFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatc
clVipCard =view.findViewById(R.id.clVipCard)
shareCard =view.findViewById(R.id.shareCard)
tvVersion=view.findViewById(R.id.tvVersion)
rvSettingTab=view.findViewById(R.id.rvSettingTab)
tvUseNet=view.findViewById(R.id.tvUseNet)
trafficStatisticsData.observe(requireActivity()){
it.let {
tvUseNet.text=it
}
}
clVipCard.setOnClickListener {
goNewRecharge()
}

View File

@ -1,154 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/oc_index_bg"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/clTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="43dp"
>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/aiBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_mode_back"
android:padding="5dp"
android:layout_marginStart="15dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#B36C1B"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:text="@string/myAccount"
android:textSize="18sp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="13dp"
android:layout_marginEnd="13dp"
android:layout_marginTop="31dp"
android:background="@drawable/oc_setting_lo_bg"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/clChanPsw"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginStart="21dp"
android:layout_marginEnd="21dp"
android:layout_marginTop="22dp"
>
<TextView
android:id="@+id/tvServiceTerms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="@string/change_password"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:textColor="#5A2B31"
android:textSize="16sp"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/aiServiceTerms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/oc_xy"
app:layout_constraintBottom_toBottomOf="@+id/clChanPsw"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/clChanPsw" />
</androidx.constraintlayout.widget.ConstraintLayout>
<View
android:id="@+id/LineView"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#E59E4D"
android:layout_marginStart="21dp"
android:layout_marginEnd="21dp"
android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/clChanPsw"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/clFowdPsw"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/LineView"
android:layout_marginStart="21dp"
android:layout_marginEnd="21dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="20dp"
app:layout_constraintBottom_toBottomOf="parent"
>
<TextView
android:id="@+id/tvFowdPsw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="@string/forget_pwd"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:textColor="#5A2B31"
android:textSize="16sp"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/aiyszc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/oc_xy"
app:layout_constraintBottom_toBottomOf="@+id/clFowdPsw"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/clFowdPsw" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/tvChange"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/layout_login_tv_login_start_margin"
android:layout_marginTop="21dp"
android:layout_marginEnd="@dimen/layout_login_tv_login_end_margin"
android:background="@drawable/oc_ming_change_bg"
android:gravity="center"
android:paddingTop="@dimen/layout_login_tv_login_top_padding"
android:paddingBottom="@dimen/layout_login_tv_login_bottom_padding"
android:elevation="10dp"
android:translationZ="1dp"
android:text="@string/ChangeAccount"
android:textColor="#B36C1B"
android:textSize="@dimen/layout_login_tv_login_textsize"
android:textStyle="bold"
app:layout_constraintTop_toBottomOf="@+id/ll_user_agreement" />
</LinearLayout>

View File

@ -287,19 +287,6 @@
android:textStyle="bold"
app:layout_constraintStart_toStartOf="@+id/shareCard"
app:layout_constraintTop_toBottomOf="@+id/shareCard" />
<TextView
android:id="@+id/tvUseNet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#FF000000"
android:layout_marginTop="10dp"
android:textSize="13sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="@+id/shareCard"
app:layout_constraintTop_toBottomOf="@+id/shareCard" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvSettingTab"
android:layout_width="match_parent"

View File

@ -109,7 +109,7 @@ subprojects {
)
)
}
create("1111") {
create("0000") {
isDefault = true
dimension = flavorDimensionList[0]
buildConfigField("boolean", "PREMIUM", "Boolean.parseBoolean(\"false\")")
@ -117,7 +117,7 @@ subprojects {
buildConfigField("boolean", "is_back_cn", "false")
buildConfigField("String", "applicationId", "\"com.jsq.wufu\"")
buildConfigField("String", "service_url", "\"https://api.yijianlianjsq.com/\"")
buildConfigField("String", "productId", "\"1111\"")
buildConfigField("String", "productId", "\"0000\"")
manifestPlaceholders(
mapOf(
"APP_NAME" to "@string/wf",