启动clash弹窗更改

This commit is contained in:
level 2025-07-15 14:14:36 +08:00
parent 5ab6aa4ac4
commit 9e8f99a1ff
5 changed files with 52 additions and 4 deletions

View File

@ -21,6 +21,9 @@ import androidx.appcompat.widget.AppCompatImageView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView
import com.afollestad.materialdialogs.customview.getCustomView
import com.cncat.vpn.common.constants.Intents
import com.cncat.vpn.common.log.Log
import com.cncat.vpn.core.Clash
@ -33,6 +36,7 @@ import com.yingmao.clash.act.NewMainActivity.Companion.clashBinder
import com.yingmao.clash.act.NewMainActivity.Companion.newUuid
import com.yingmao.clash.act.NewMainActivity.Companion.isSubbed
import com.yingmao.clash.act.NewMainActivity.Companion.profileBinder
import com.yingmao.clash.act.UIMainActivity
import com.yingmao.clash.conf.BZYConstants
import com.yingmao.clash.conf.Conf
import com.yingmao.clash.entity.ClashNodebBean
@ -84,6 +88,8 @@ class NewAccFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatch
private lateinit var clickOnLink: ConstraintLayout
private lateinit var InTheLink: AppCompatImageView
private lateinit var ClickTheLink: TextView
private var baseLoading: RxDialogShapeLoading? = null
override fun init(
titleBarRl: RelativeLayout,
backIv: ImageView,
@ -168,10 +174,10 @@ class NewAccFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatch
}
return@setOnClickListener
}else{
if(isSubbed){
showLoading(resources.getString(R.string.Starting), requireContext())
launch {
delay(2000)
startClash()
}else{
RxToast.success(resources.getString(R.string.tooFast))
}
}
@ -199,7 +205,21 @@ class NewAccFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatch
private fun startClash() {
if (checkExpire()) {
if (isAdded) {
RxToast.info(resources.getString(R.string.AccountExpired))
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
}
@ -245,6 +265,7 @@ class NewAccFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatch
clickOnLink.setBackgroundResource(R.drawable.home_circle_select)
InTheLink.setImageResource(R.mipmap.ic_click)
ClickTheLink.text=resources.getString(R.string.CloseConnection)
hideLoading()
}
accelerateViewModel.appStartupStatus()
}
@ -254,6 +275,7 @@ class NewAccFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatch
clickOnLink.setBackgroundResource(R.drawable.home_circle_connecting)
InTheLink.setImageResource(R.mipmap.ic_click)
ClickTheLink.text=resources.getString(R.string.CloseConnection)
hideLoading()
}
accelerateViewModel.appStartupStatus()
@ -638,4 +660,26 @@ class NewAccFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatch
requireContext().stopService(serviceIntent)
}
}
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 goNewRecharge() {
if (activity != null) {
val uiMainActivity = activity as UIMainActivity
uiMainActivity.goBackupRechargeWeb()
}
}
}

View File

@ -384,4 +384,5 @@ Service Description\n
<string name="SwitchingSource">Please turn off acceleration before switching sources</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

@ -374,4 +374,5 @@
<string name="SwitchingSource">請關閉加速後在進行源切換</string>
<string name="LoginOut">檢測到當前賬號在其他設備登錄,如非本人操作,請立即修改密碼並退出陌生設備。</string>
<string name="tooFast">應用初始化中,請等待1~2秒後重試</string>
<string name="Starting">啟動中</string>
</resources>

View File

@ -372,4 +372,5 @@
<string name="SwitchingSource">請關閉加速後在進行源切換</string>
<string name="LoginOut">檢測到當前賬號在其他設備登錄,如非本人操作,請立即修改密碼並退出陌生設備。</string>
<string name="tooFast">應用初始化中,請等待1~2秒後重試</string>
<string name="Starting">啟動中</string>
</resources>

View File

@ -398,4 +398,5 @@
<string name="SwitchingSource">请关闭加速后在进行源切换</string>
<string name="LoginOut">检测到当前账号在其他设备登录,如非本人操作,请立即修改密码并退出陌生设备。</string>
<string name="tooFast">应用初始化中,请等待1~2秒后重试</string>
<string name="Starting">启动中</string>
</resources>