Merge remote-tracking branch 'refs/remotes/origin/master'

This commit is contained in:
cyh 2025-07-17 18:05:40 +08:00
commit 53ffd91b84
6 changed files with 71 additions and 42 deletions

View File

@ -2,7 +2,6 @@ package com.yingmao.clash.fragment.home
import android.annotation.SuppressLint
import android.app.Activity
import android.app.ActivityManager
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
@ -45,7 +44,6 @@ import com.yingmao.clash.act.ConnectionModeActivity
import com.yingmao.clash.act.LoginActivity
import com.yingmao.clash.act.UIMainActivity
import com.yingmao.clash.act.UIMainActivity.Companion.clashBinder
import com.yingmao.clash.act.UIMainActivity.Companion.isSubbed
import com.yingmao.clash.act.UIMainActivity.Companion.newMainActGlo
import com.yingmao.clash.act.UIMainActivity.Companion.newUuid
import com.yingmao.clash.act.UIMainActivity.Companion.profileBinder
@ -53,13 +51,11 @@ import com.yingmao.clash.act.UIMainActivity.Companion.subUrl
import com.yingmao.clash.conf.BZYConstants
import com.yingmao.clash.conf.Conf
import com.yingmao.clash.entity.ClashNodebBean
import com.yingmao.clash.fragment.AccelerateViewModel
import com.yingmao.clash.fragment.BaseFragment
import com.yingmao.clash.listener.AsyncCallBackListener
import com.yingmao.clash.net.http.HttpReqType
import com.yingmao.clash.net.http.HttpStatus
import com.yingmao.clash.net.http.entity.AppStartupStatus
import com.yingmao.clash.net.http.entity.AppStopStatus
import com.yingmao.clash.net.http.entity.PhDownloadUrlRsp
import com.yingmao.clash.service.ConnectionService
import com.yingmao.clash.util.ActivityResultLifecycle
@ -107,12 +103,12 @@ class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatcher
private lateinit var llLine: ConstraintLayout
private lateinit var clActivity: ConstraintLayout
private lateinit var clMember: ConstraintLayout
private val fragments = arrayListOf<Fragment>()
var proList: MutableList<ClashNodebBean>? = null
private val nextRequestKey = AtomicInteger(0)
private var reConnection = false
private var connectId = -1
private var baseLoading: RxDialogShapeLoading? = null
companion object {
const val REQUEST_CONNECT = 1
@ -187,8 +183,8 @@ class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatcher
llLine = view.findViewById(R.id.llLine)
clActivity = view.findViewById(R.id.clActivity)
clMember = view.findViewById(R.id.clMember)
if (BuildConfig.productId=="182269"&&BuildConfig.is_tz){
clActivity.visibility=View.INVISIBLE
if (BuildConfig.productId == "182269" && BuildConfig.is_tz) {
clActivity.visibility = View.INVISIBLE
}
llLine.setOnClickListener {
@ -213,7 +209,7 @@ class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatcher
return@setOnClickListener
}
var intent: Intent? = null
if (BuildConfig.is_tz&&BuildConfig.productId=="182269") {
if (BuildConfig.is_tz && BuildConfig.productId == "182269") {
intent = Intent(CommonUtils.getApp(), ChangeNodeTzActivity::class.java)
} else {
intent = Intent(CommonUtils.getApp(), ChangeNodeActivity::class.java)
@ -261,13 +257,28 @@ class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatcher
}
rxDialogSureCancel.show()
} else {
android.util.Log.i("AAAAAAAAAAAAA::","data isSubbed::: "+isSubbed)
if(isSubbed){
startClash()
}else{
RxToast.success(resources.getString(R.string.tooFast))
if (checkExpire()) {
if (isAdded) {
hideLoading()
MaterialDialog(requireContext()).show {
this.cancelable(false)
cornerRadius(res = R.dimen.dp_10)
customView(
R.layout.expired_recharge__layout,
scrollable = false,
noVerticalPadding = true,
horizontalPadding = false
)
getCustomView().findViewById<TextView>(R.id.tv_pay_finish).setOnClickListener {
goNewRecharge()
dismiss()
}
}
}
return@setOnClickListener
}
showLoading(resources.getString(R.string.Starting), requireContext())
startClash(true)
}
}
clActivity.setOnClickListener {
@ -285,12 +296,29 @@ class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatcher
var selected_name =
MMKV.defaultMMKV().decodeString(BZYConstants.NODE_SELECTED_NAME_KEY, "")
if (!TextUtils.isEmpty(selected_name)) {
if (!BuildConfig.is_tz){
if (!BuildConfig.is_tz) {
setNodeNameAndImg(selected_name!!)
}
}
}
fun showLoading(str: String, context: Context) {
val message = if (TextUtils.isEmpty(str)) "进行中..." else str
if (baseLoading == null) {
baseLoading = RxDialogShapeLoading(context)
}
baseLoading?.setMessage(message)
if (baseLoading?.isShowing == false) {
baseLoading?.show()
}
}
fun hideLoading() {
if (baseLoading != null && baseLoading?.isShowing == true) {
baseLoading?.cancel()
}
}
private fun updateUserInfo() {
if (activity != null) {
val mact = activity as UIMainActivity
@ -393,8 +421,8 @@ class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatcher
serviceIntent.putExtra("receiver", resultReceiver)
val serviceRunning =
Utils.isServiceRunning(requireContext(), ConnectionService::class.java)
android.util.Log.i("AppStartupStatus","data::"+serviceRunning)
if(!serviceRunning){
android.util.Log.i("AppStartupStatus", "data::" + serviceRunning)
if (!serviceRunning) {
requireContext().startService(serviceIntent)
}
}
@ -469,7 +497,7 @@ class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatcher
if (clashRunning) {
Log.d("clashRunning $clashRunning")
} else {
startClash()
startClash(false)
}
} else {
if (::rxDialogShapeLoading.isInitialized || rxDialogShapeLoading.isShowing) {
@ -485,12 +513,12 @@ class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatcher
if (clashRunning) {
Log.d("clashRunning $clashRunning")
} else {
startClash()
startClash(false)
}
checkGlo()
}?.run {
if (isRunNing == true && !clashRunning) {
startClash()
startClash(false)
}
}
} else if (requestCode == Proxy_Mode_REQUEST_CODE) {
@ -498,27 +526,11 @@ class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatcher
}
}
private fun startClash() {
if (checkExpire()) {
if (isAdded) {
MaterialDialog(requireContext()).show {
this.cancelable(false)
cornerRadius(res = R.dimen.dp_10)
customView(
R.layout.expired_recharge__layout,
scrollable = false,
noVerticalPadding = true,
horizontalPadding = false
)
getCustomView().findViewById<TextView>(R.id.tv_pay_finish).setOnClickListener {
goNewRecharge()
dismiss()
}
}
}
return
}
private fun startClash(isStart:Boolean) {
launch {
if(isStart){
delay(2000)
}
profileBinder?.let { pm ->
val active = pm.queryActive()
if (active == null) {
@ -557,9 +569,15 @@ class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatcher
stateChanged(Clash_Starting, true)
context?.startClashService()
mainAtyVM.appStartupStatus()
withContext(Dispatchers.Main) {
hideLoading()
}
}
} else {
mainAtyVM.appStartupStatus()
withContext(Dispatchers.Main) {
hideLoading()
}
}
} catch (e: Exception) {
stopUpLoadTimer()
@ -1004,12 +1022,13 @@ class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatcher
})
dialog.show()
}
override fun onDestroy() {
super.onDestroy()
val serviceRunning =
Utils.isServiceRunning(requireContext(), ConnectionService::class.java)
if(serviceRunning){
val serviceIntent= Intent(requireContext(), ConnectionService::class.java)
if (serviceRunning) {
val serviceIntent = Intent(requireContext(), ConnectionService::class.java)
requireContext().stopService(serviceIntent)
}
}

View File

@ -329,7 +329,12 @@ class SettingFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatc
startActivity(intent)
}
initializationRepair.setOnClickListener {
if (checkExpire()) {
RxToast.info(resources.getString(R.string.AccountExpired))
return@setOnClickListener
}
if (TextUtils.isEmpty(subUrl)) {
RxToast.success(resources.getString(R.string.tooFast))
return@setOnClickListener
}
cleanNodeMmkv()

View File

@ -360,4 +360,6 @@ Service Description\n
<string name="CZHY">Recharge Membership</string>
<string name="LoginOut">It is detected that the current account is logged in on other devices. If it is not your own operation, please change the password immediately and log out of the unfamiliar device.</string>
<string name="tooFast">The application is initializing. Please wait for 1~2 seconds and try again.</string>
<string name="Starting">Starting</string>
</resources>

View File

@ -351,4 +351,5 @@
<string name="CZHY">充值會員</string>
<string name="LoginOut">檢測到當前賬號在其他設備登錄,如非本人操作,請立即修改密碼並退出陌生設備。</string>
<string name="tooFast">應用初始化中,請等待1~2秒後重試</string>
<string name="Starting">啟動中</string>
</resources>

View File

@ -349,4 +349,5 @@
<string name="CZHY">充值會員</string>
<string name="LoginOut">檢測到當前賬號在其他設備登錄,如非本人操作,請立即修改密碼並退出陌生設備。</string>
<string name="tooFast">應用初始化中,請等待1~2秒後重試</string>
<string name="Starting">啟動中</string>
</resources>

View File

@ -371,4 +371,5 @@
<string name="CZHY">充值会员</string>
<string name="LoginOut">检测到当前账号在其他设备登录,如非本人操作,请立即修改密码并退出陌生设备。</string>
<string name="tooFast">应用初始化中,请等待1~2秒后重试</string>
<string name="Starting">启动中</string>
</resources>