diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ce4fe97..292e822 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -136,6 +136,7 @@ android:screenOrientation="portrait" /> ${MainApplication.getUserInfo()?.userCommand}") } private fun initView() { @@ -79,11 +82,10 @@ class ActivityActivity : BaseActivity() { } private fun showActDialog(bean: Activity_) { - - if (bean.vipRule == 1) { - checkExpire(); - } var command = MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_VPN_UserCommand, "")!! + if (TextUtils.isEmpty(command)){ + command=NewMainActivity.userCommand!! + } command = "领会员${command}" copyToClipboard(command) var act_dialog = MaterialDialog(this@ActivityActivity).show { @@ -134,7 +136,7 @@ class ActivityActivity : BaseActivity() { val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager val clip = ClipData.newPlainText("label", text) clipboard.setPrimaryClip(clip) - + RxToast.info("口令已复制,加群后请手动发送.") } private fun initRefreshLayout() { diff --git a/app/src/main/java/com/yingmao/clash/act/LoginActivity.kt b/app/src/main/java/com/yingmao/clash/act/LoginActivity.kt index 9d07aa5..d15510a 100644 --- a/app/src/main/java/com/yingmao/clash/act/LoginActivity.kt +++ b/app/src/main/java/com/yingmao/clash/act/LoginActivity.kt @@ -20,6 +20,7 @@ import com.yingmao.clash.net.http.entity.LoginRsp import com.tencent.mmkv.MMKV import com.yingmao.clash.BuildConfig import com.yingmao.clash.R +import com.yingmao.clash.app.MainApplication import com.yingmao.clash.base.BaseActivity import com.yingmao.clash.conf.BZYConstants import com.yingmao.clash.entity.CheckLoginRsp @@ -56,10 +57,8 @@ class LoginActivity : BaseActivity(), View.OnClickListener { setContentView(R.layout.layout_activity_login) //点击输入框外边隐藏输入法 必须在setContentView之后调用 setupUI(findViewById(android.R.id.content).getChildAt(0)) - loginViewMode = ViewModelProvider(this).get(LoginAtyVM::class.java) observe(this, loginViewMode) - initViews() } @@ -102,7 +101,6 @@ class LoginActivity : BaseActivity(), View.OnClickListener { mmkv.encode(BZYConstants.MMKV_KEY_USER_ID, rsp.data?.userId) mmkv.encode(BZYConstants.MMKV_KEY_REMEMBER_USERNAME, loginUserName) mmkv.encode(BZYConstants.MMKV_KEY_IS_REGISTER, true) //如果登录过一次也算注册过 - loginViewMode.checkLogin() } else { hideLoadingDialog() @@ -118,8 +116,10 @@ class LoginActivity : BaseActivity(), View.OnClickListener { val rsp = httpStatus.rsp if (rsp is CheckLoginRsp) { if (rsp.code == 0) { + rsp.data?.let { MainApplication.setUserInfo(it) } val expired = rsp.data?.expired val isPerfect = rsp.data?.isPerfect + val userCommand = rsp.data?.userCommand val mmkv = MMKV.defaultMMKV() mmkv.encode(BZYConstants.MMKV_KEY_VPN_EXPIRED, expired ?: true) mmkv.encode( @@ -127,6 +127,7 @@ class LoginActivity : BaseActivity(), View.OnClickListener { rsp.data?.vpnExpireTime ?: 0 ) mmkv.encode(BZYConstants.MMKV_KEY_IS_PERFECT, isPerfect ?: true) + mmkv.encode(BZYConstants.MMKV_KEY_VPN_UserCommand, userCommand ?: "") toMain() // loginViewMode.getServiceAclAndSet() } else { diff --git a/app/src/main/java/com/yingmao/clash/act/NewMainActivity.kt b/app/src/main/java/com/yingmao/clash/act/NewMainActivity.kt index fa2793b..3cf388d 100644 --- a/app/src/main/java/com/yingmao/clash/act/NewMainActivity.kt +++ b/app/src/main/java/com/yingmao/clash/act/NewMainActivity.kt @@ -117,6 +117,8 @@ class NewMainActivity : BaseActivity() { var newMainActGlo: Boolean = false var isUpload: Boolean = false var hostsMem: ArrayList = ArrayList() + + } val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") @@ -246,8 +248,10 @@ class NewMainActivity : BaseActivity() { // }) val isGlobal = MMKV.defaultMMKV().decodeBool(BZYConstants.MMKV_KEY_GLOBAL_MODEL, false) - Log.i("newMainActGlo isGlobal==>${isGlobal}") + val uc = MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_VPN_UserCommand, "") + Log.i("newMainActGlo isGlobal==>${isGlobal}, uc==>${uc}") newMainActGlo = isGlobal + startLog() showBindAccount() } diff --git a/app/src/main/java/com/yingmao/clash/act/RegisterActivity.kt b/app/src/main/java/com/yingmao/clash/act/RegisterActivity.kt index 64c6026..fc521ad 100644 --- a/app/src/main/java/com/yingmao/clash/act/RegisterActivity.kt +++ b/app/src/main/java/com/yingmao/clash/act/RegisterActivity.kt @@ -1,5 +1,6 @@ package com.yingmao.clash.act +import android.annotation.SuppressLint import android.content.Intent import android.os.Bundle import android.text.method.HideReturnsTransformationMethod @@ -16,6 +17,7 @@ import com.tencent.mmkv.MMKV import com.yingmao.clash.BuildConfig import com.yingmao.clash.R import com.yingmao.clash.base.BaseActivity +import com.yingmao.clash.common.log.Log import com.yingmao.clash.conf.BZYConstants import com.yingmao.clash.net.http.HttpStatus import com.yingmao.clash.net.http.entity.RegisterRsp @@ -34,8 +36,8 @@ class RegisterActivity : BaseActivity(), View.OnClickListener { private lateinit var usernameErrorTv: TextView private lateinit var passwordErrorTv: TextView -// private lateinit var verificationTipTv: TextView -// private lateinit var verificationSv: SlidingVerification + private lateinit var verificationTipTv: TextView + private lateinit var verificationSv: SlidingVerification private lateinit var username: String private lateinit var password: String @@ -111,10 +113,10 @@ class RegisterActivity : BaseActivity(), View.OnClickListener { val passwordHideCb2 = findViewById(R.id.cb_password_hide_check) passwordHideCb2.setOnCheckedChangeListener(IOnCheckedChangeListener()) -// verificationSv = findViewById(R.id.sv_verification) -// verificationSv.setOnSeekBarChangeListener(IOnSeekBarChangeListener()) + verificationSv = findViewById(R.id.sv_verification) + verificationSv.setOnSeekBarChangeListener(IOnSeekBarChangeListener()) // -// verificationTipTv = findViewById(R.id.tv_verification_tip) + verificationTipTv = findViewById(R.id.tv_verification_tip) val registerTv = findViewById(R.id.tv_register) registerTv.setOnClickListener(this) @@ -178,14 +180,22 @@ class RegisterActivity : BaseActivity(), View.OnClickListener { override fun onStartTrackingTouch(seekBar: SeekBar?) { } + @SuppressLint("ResourceAsColor") override fun onStopTrackingTouch(seekBar: SeekBar?) { seekBar?.let { + + Log.d("it.progress==>${it.progress}") if (it.progress >= it.max) { - if (!checkInput()) - it.progress = 0 - else { -// verificationTipTv.text = getString(R.string.verification_success) - it.isEnabled = false + it.isEnabled = false + verificationSv.progress=it.max + verificationTipTv.text = getString(R.string.verification_success) + verificationTipTv.setTextColor(R.color.black) + verificationSv.setProgressDrawableTiled(getDrawable(R.drawable.login_btn_bg_selector)) + + if (!checkInput()) { + + }else { + } } else it.progress = 0 } diff --git a/app/src/main/java/com/yingmao/clash/act/SplashActivity.kt b/app/src/main/java/com/yingmao/clash/act/SplashActivity.kt index 289c71e..324ee03 100644 --- a/app/src/main/java/com/yingmao/clash/act/SplashActivity.kt +++ b/app/src/main/java/com/yingmao/clash/act/SplashActivity.kt @@ -27,6 +27,7 @@ import com.orhanobut.logger.Logger import com.tencent.mmkv.MMKV import com.yingmao.clash.BuildConfig import com.yingmao.clash.R +import com.yingmao.clash.app.MainApplication import com.yingmao.clash.base.BaseActivity import com.yingmao.clash.conf.BZYConstants import com.yingmao.clash.conf.BZYConstants.Companion.MMKV_KEY_IS_REGISTER @@ -49,6 +50,7 @@ import com.yingmao.clash.util.withProfile import com.yingmao.clash.view.RxToast import com.yingmao.clash.vm.SplashAtyVM import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.MainScope import kotlinx.coroutines.delay import kotlinx.coroutines.launch @@ -381,6 +383,8 @@ class SplashActivity : BaseActivity() { HttpReqType.CHECK_LOGIN -> { (httpStatus.rsp as CheckLoginRsp).let { checkLoginRsp -> if (checkLoginRsp.code == 0) { + com.yingmao.clash.common.log.Log.d("splash CHECK_LOGIN==>") + checkLoginRsp.data?.let { MainApplication.setUserInfo(it) } val expired = checkLoginRsp.data?.expired val isPerfect = checkLoginRsp.data?.isPerfect val userCommand = checkLoginRsp.data?.userCommand @@ -392,7 +396,11 @@ class SplashActivity : BaseActivity() { ) mmkv.encode(BZYConstants.MMKV_KEY_IS_PERFECT, isPerfect ?: true) mmkv.encode(BZYConstants.MMKV_KEY_VPN_UserCommand, userCommand ?: "") + + toMainPage() + + } else { toLoginPage() } diff --git a/app/src/main/java/com/yingmao/clash/app/MainApplication.kt b/app/src/main/java/com/yingmao/clash/app/MainApplication.kt index 8eb9b55..d0e37bd 100644 --- a/app/src/main/java/com/yingmao/clash/app/MainApplication.kt +++ b/app/src/main/java/com/yingmao/clash/app/MainApplication.kt @@ -17,6 +17,8 @@ import com.yingmao.clash.R import com.yingmao.clash.common.Global import com.yingmao.clash.common.compat.currentProcessName import com.yingmao.clash.common.log.Log +import com.yingmao.clash.entity.CheckLoginRsp +import com.yingmao.clash.entity.UserData import com.yingmao.clash.util.clashDir import java.io.File @@ -25,6 +27,7 @@ import java.io.FileOutputStream class MainApplication : Application() { companion object { private lateinit var mApp: MainApplication + private var userBean: UserData?=null fun getApp(): MainApplication? { return mApp @@ -34,6 +37,14 @@ class MainApplication : Application() { private const val STATUS_CHANNEL = "profile_status_channel" private const val RESULT_CHANNEL = "profile_result_channel" + fun getUserInfo(): UserData? { + return userBean + } + + fun setUserInfo(bean: UserData) { + Log.d("setUserInfo") + userBean = bean + } } override fun attachBaseContext(base: Context?) { @@ -92,16 +103,18 @@ class MainApplication : Application() { nm.createNotificationChannels( listOf( NotificationChannel( - SERVICE_CHANNEL, getApp()?.getText(R.string.service_vpn), + SERVICE_CHANNEL, + getApp()?.getText(R.string.service_vpn), if (Build.VERSION.SDK_INT >= 28) NotificationManager.IMPORTANCE_MIN else NotificationManager.IMPORTANCE_LOW ), // #1355 NotificationChannel( - STATUS_CHANNEL, getApp()?.getText(R.string.service_proxy), + STATUS_CHANNEL, + getApp()?.getText(R.string.service_proxy), NotificationManager.IMPORTANCE_LOW - ), - NotificationChannel( - RESULT_CHANNEL, getApp()?.getText(R.string.service_transproxy), + ), NotificationChannel( + RESULT_CHANNEL, + getApp()?.getText(R.string.service_transproxy), NotificationManager.IMPORTANCE_DEFAULT ) ) diff --git a/app/src/main/java/com/yingmao/clash/webview/BZYWebViewKeFu.kt b/app/src/main/java/com/yingmao/clash/webview/BZYWebViewKeFu.kt index 983963a..e825a59 100644 --- a/app/src/main/java/com/yingmao/clash/webview/BZYWebViewKeFu.kt +++ b/app/src/main/java/com/yingmao/clash/webview/BZYWebViewKeFu.kt @@ -10,7 +10,13 @@ import android.webkit.WebViewClient import androidx.appcompat.app.AppCompatActivity import com.yingmao.clash.BuildConfig import com.yingmao.clash.R +import com.yingmao.clash.common.log.Log import com.yingmao.clash.util.StatusBarUtils +import com.yingmao.clash.view.RxToast +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Job +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch class BZYWebViewKeFu : AppCompatActivity() { private lateinit var webView: WebView @@ -28,13 +34,13 @@ class BZYWebViewKeFu : AppCompatActivity() { setWebView() countDown() } - private fun countDown() { - val timer = object : CountDownTimer(10000, 1000) { + val timer = object : CountDownTimer(5000, 1000) { override fun onTick(millisUntilFinished: Long) { } override fun onFinish() { + Log.d("onFinish") webView.evaluateJavascript("updateStatus()", null) } } diff --git a/app/src/main/res/layout/activity_register.xml b/app/src/main/res/layout/activity_register.xml index ef21b8a..793a055 100644 --- a/app/src/main/res/layout/activity_register.xml +++ b/app/src/main/res/layout/activity_register.xml @@ -154,7 +154,7 @@ app:layout_constraintStart_toStartOf="@+id/iv_icon" app:layout_constraintTop_toBottomOf="@+id/et_password_check" /> -