From 9e8f99a1ff0ce360910e77c700a981f4f2e857c4 Mon Sep 17 00:00:00 2001 From: level <1364007522@qq.com> Date: Tue, 15 Jul 2025 14:14:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=AF=E5=8A=A8clash=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yingmao/clash/fragment/NewAccFragment.kt | 52 +++++++++++++++++-- app/src/main/res/values-en/strings.xml | 1 + app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 5 files changed, 52 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/yingmao/clash/fragment/NewAccFragment.kt b/app/src/main/java/com/yingmao/clash/fragment/NewAccFragment.kt index e528698..2fcad16 100644 --- a/app/src/main/java/com/yingmao/clash/fragment/NewAccFragment.kt +++ b/app/src/main/java/com/yingmao/clash/fragment/NewAccFragment.kt @@ -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(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() + } + } } \ No newline at end of file diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index 5f2b8eb..689b98d 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -384,4 +384,5 @@ Service Description\n Please turn off acceleration before switching sources 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. The application is initializing. Please wait for 1~2 seconds and try again. + Starting \ No newline at end of file diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 06a1b6c..b9eea79 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -374,4 +374,5 @@ 請關閉加速後在進行源切換 檢測到當前賬號在其他設備登錄,如非本人操作,請立即修改密碼並退出陌生設備。 應用初始化中,請等待1~2秒後重試 + 啟動中 \ No newline at end of file diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 7cfa334..95fd7a5 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -372,4 +372,5 @@ 請關閉加速後在進行源切換 檢測到當前賬號在其他設備登錄,如非本人操作,請立即修改密碼並退出陌生設備。 應用初始化中,請等待1~2秒後重試 + 啟動中 \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 284a9d6..b66764a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -398,4 +398,5 @@ 请关闭加速后在进行源切换 检测到当前账号在其他设备登录,如非本人操作,请立即修改密码并退出陌生设备。 应用初始化中,请等待1~2秒后重试 + 启动中 \ No newline at end of file