Commit e7c222d9 authored by sheteng's avatar sheteng

加速器

parent c9921bec
...@@ -6,6 +6,13 @@ plugins { ...@@ -6,6 +6,13 @@ plugins {
} }
android { android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
signingConfigs { signingConfigs {
register("config") { register("config") {
keyAlias = "ccim" keyAlias = "ccim"
......
...@@ -5,8 +5,7 @@ ...@@ -5,8 +5,7 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" /> <uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" /> <!-- 通过GPS得到精确位置 -->
<!-- 通过GPS得到精确位置 -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 通过网络得到粗略位置 --> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 通过网络得到粗略位置 -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- 访问网络. 某些位置信息需要从网络服务器获取 --> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- 访问网络. 某些位置信息需要从网络服务器获取 -->
<uses-permission android:name="android.permission.INTERNET" /> <!-- 访问WiFi状态. 需要WiFi信息用于网络定位 --> <uses-permission android:name="android.permission.INTERNET" /> <!-- 访问WiFi状态. 需要WiFi信息用于网络定位 -->
...@@ -34,10 +33,17 @@ ...@@ -34,10 +33,17 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"> android:usesCleartextTraffic="true">
<activity
android:name=".ui.login.PhoneLoginActivity"
android:exported="false"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar" >
</activity>
<activity <activity
android:name=".ui.MainActivity" android:name=".ui.MainActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:screenOrientation="portrait"> android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible|adjustPan">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
......
...@@ -12,6 +12,7 @@ data class GameInfo( ...@@ -12,6 +12,7 @@ data class GameInfo(
val greatNum: Int, val greatNum: Int,
val icon: String, val icon: String,
val id: Int, val id: Int,
val boosterServerIp:String,
val imgs: String, val imgs: String,
val introduction: String, val introduction: String,
val packageName: String val packageName: String
......
...@@ -54,6 +54,7 @@ class BottomNavigationFragment : XPageFragment(), ViewPager.OnPageChangeListener ...@@ -54,6 +54,7 @@ class BottomNavigationFragment : XPageFragment(), ViewPager.OnPageChangeListener
adapter.addFragment(fragments[2], titles[2]) adapter.addFragment(fragments[2], titles[2])
binding.viewPager.setOffscreenPageLimit(titles.size - 1); binding.viewPager.setOffscreenPageLimit(titles.size - 1);
binding.viewPager.adapter = adapter binding.viewPager.adapter = adapter
// binding.viewPager
AcceleratorUtils.getGameList(this,{}) AcceleratorUtils.getGameList(this,{})
} }
......
package com.ccwangluo.accelerator.ui.home package com.ccwangluo.accelerator.ui.home
import android.graphics.drawable.AnimationDrawable
import android.os.Bundle import android.os.Bundle
import android.support.v4.media.session.PlaybackStateCompat
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
...@@ -22,6 +24,7 @@ import com.github.shadowsocks.bg.BaseService ...@@ -22,6 +24,7 @@ import com.github.shadowsocks.bg.BaseService
import com.hjq.toast.ToastUtils import com.hjq.toast.ToastUtils
import com.xuexiang.xpage.base.XPageFragment import com.xuexiang.xpage.base.XPageFragment
import com.xuexiang.xpage.utils.TitleBar import com.xuexiang.xpage.utils.TitleBar
import com.xuexiang.xui.utils.ViewUtils
import com.xuexiang.xutil.app.AppUtils import com.xuexiang.xutil.app.AppUtils
class AccelertorFragment : XPageFragment() { class AccelertorFragment : XPageFragment() {
...@@ -34,6 +37,8 @@ class AccelertorFragment : XPageFragment() { ...@@ -34,6 +37,8 @@ class AccelertorFragment : XPageFragment() {
return null return null
} }
var state: BaseService.State? = null
override fun inflateView(inflater: LayoutInflater?, container: ViewGroup?): View { override fun inflateView(inflater: LayoutInflater?, container: ViewGroup?): View {
binding = FragmentQuickBinding.inflate(inflater!!, container, false) binding = FragmentQuickBinding.inflate(inflater!!, container, false)
accelertorViewModel = accelertorViewModel =
...@@ -85,21 +90,25 @@ class AccelertorFragment : XPageFragment() { ...@@ -85,21 +90,25 @@ class AccelertorFragment : XPageFragment() {
binding.netQuality.setText(SysUtils.getnetQuality(it.delay)) binding.netQuality.setText(SysUtils.getnetQuality(it.delay))
} }
binding.activeNetwork.setText(SysUtils.getActiveNet()) binding.activeNetwork.setText(SysUtils.getActiveNet())
})
accelertorViewModel.accState.observe(this, {
binding.accStateTx.setText(SysUtils.getAccTimeString(acc_timer))
if (it != state) {
state = it
freshData(it)
}
if (SettingSPUtils.isSmartAccOpen) { if (SettingSPUtils.isSmartAccOpen) {
binding.smartAccOpen.setText("已开启 >") binding.smartAccOpen.setText("已开启 >")
binding.smartAccOpen.setTextColor(resources.getColor(R.color.open_acc_enable)) binding.smartAccOpen.setTextColor(resources.getColor(R.color.open_acc_enable))
binding.smartAccOpenArea.visibility = View.GONE binding.smartAccOpenArea.visibility = View.GONE
} else { } else {
binding.smartAccOpen.setText("未开启 >") binding.smartAccOpen.setText("未开启 ")
binding.smartAccOpen.setTextColor(resources.getColor(R.color.white)) binding.smartAccOpen.setTextColor(resources.getColor(R.color.white))
binding.smartAccOpenArea.visibility = View.VISIBLE binding.smartAccOpenArea.visibility = View.VISIBLE
} }
}) })
accelertorViewModel.accState.observe(this, {
freshData(it, acc_timer)
})
accelertorViewModel.userProfile.observe(this, { accelertorViewModel.userProfile.observe(this, {
if (it.hasUnreadNotice) { if (it.hasUnreadNotice) {
binding.iconNoticeBadge.visibility = View.VISIBLE binding.iconNoticeBadge.visibility = View.VISIBLE
...@@ -108,6 +117,7 @@ class AccelertorFragment : XPageFragment() { ...@@ -108,6 +117,7 @@ class AccelertorFragment : XPageFragment() {
} }
}) })
binding.progressViewCircleSmall.setProgressTextVisibility(false) binding.progressViewCircleSmall.setProgressTextVisibility(false)
} }
override fun initListeners() { override fun initListeners() {
...@@ -171,7 +181,7 @@ class AccelertorFragment : XPageFragment() { ...@@ -171,7 +181,7 @@ class AccelertorFragment : XPageFragment() {
binding.quickTopToast.visibility = View.VISIBLE binding.quickTopToast.visibility = View.VISIBLE
binding.quickTopToastTx.setText("网络异常,请检查网络后重试") binding.quickTopToastTx.setText("网络异常,请检查网络后重试")
binding.quickTopToastTx.postDelayed({ binding.quickTopToastTx.postDelayed({
binding.quickTopToastTx.visibility = View.GONE binding.quickTopToast.visibility = View.GONE
}, 2000) }, 2000)
return@setOnClickListener return@setOnClickListener
} }
...@@ -179,10 +189,11 @@ class AccelertorFragment : XPageFragment() { ...@@ -179,10 +189,11 @@ class AccelertorFragment : XPageFragment() {
if (it) { if (it) {
// //
AcceleratorUtils.game?.let { AcceleratorUtils.game?.let {
if (AppUtils.isInstallApp(it.packageName)) { if (!AppUtils.isInstallApp(it.packageName)) {
binding.quickTopToast.visibility = View.VISIBLE
binding.quickTopToastTx.setText("请先安装游戏后加速") binding.quickTopToastTx.setText("请先安装游戏后加速")
binding.quickTopToastTx.postDelayed({ binding.quickTopToastTx.postDelayed({
binding.quickTopToastTx.visibility = View.GONE binding.quickTopToast.visibility = View.GONE
}, 2000) }, 2000)
return@getGameList return@getGameList
} }
...@@ -233,13 +244,17 @@ class AccelertorFragment : XPageFragment() { ...@@ -233,13 +244,17 @@ class AccelertorFragment : XPageFragment() {
} }
} }
fun freshData(state: BaseService.State, time: Long) { fun freshData(state: BaseService.State) {
if (state == BaseService.State.Connected) { if (state == BaseService.State.Connected) {
stopAnim() stopAnim()
binding.gamePicIn1.startAnimation(getDefaultAnim())
binding.progressViewCircleSmall.progress = 100F binding.progressViewCircleSmall.progress = 100F
binding.accStateTx.setText(SysUtils.getAccTimeString(time))
binding.accStateTx.visibility = View.VISIBLE binding.accStateTx.visibility = View.VISIBLE
binding.btnQuick.setBackgroundResource(R.mipmap.quick_stop) binding.btnQuick.setBackgroundResource(R.mipmap.quick_stop)
if (binding.gamePicOut.background is AnimationDrawable) {
(binding.gamePicOut.background as AnimationDrawable).stop()
binding.gamePicOut.clearAnimation()
}
if (SettingSPUtils.isFirstAccSuccess) { if (SettingSPUtils.isFirstAccSuccess) {
CommonDialog(this).setTitle("防止加速掉线") CommonDialog(this).setTitle("防止加速掉线")
.setContent("为了防止加速进程被手机系统中断,影响游戏加速,请确保完成相关设置") .setContent("为了防止加速进程被手机系统中断,影响游戏加速,请确保完成相关设置")
...@@ -249,13 +264,17 @@ class AccelertorFragment : XPageFragment() { ...@@ -249,13 +264,17 @@ class AccelertorFragment : XPageFragment() {
SettingSPUtils.isFirstAccSuccess = false SettingSPUtils.isFirstAccSuccess = false
} }
} else if (state == BaseService.State.Stopped) { } else if (state == BaseService.State.Stopped) {
if (binding.gamePicOut.background is AnimationDrawable) {
(binding.gamePicOut.background as AnimationDrawable).start()
binding.gamePicOut.startAnimation(getDefaultAnim())
}
binding.gamePicIn1.clearAnimation()
stopAnim() stopAnim()
binding.accStateTx.visibility = View.GONE binding.accStateTx.visibility = View.GONE
binding.progressViewCircleSmall.progress = 0F binding.progressViewCircleSmall.progress = 0F
binding.btnQuick.setBackgroundResource(R.mipmap.quick_start) binding.btnQuick.setBackgroundResource(R.mipmap.quick_start)
} }
} }
fun getUserProfile() { fun getUserProfile() {
...@@ -277,21 +296,19 @@ class AccelertorFragment : XPageFragment() { ...@@ -277,21 +296,19 @@ class AccelertorFragment : XPageFragment() {
binding.btnQuick.isEnabled = true binding.btnQuick.isEnabled = true
binding.progressViewCircleSmall.stopProgressAnimation() binding.progressViewCircleSmall.stopProgressAnimation()
binding.progressViewCircleSmall.setProgressTextVisibility(false) binding.progressViewCircleSmall.setProgressTextVisibility(false)
binding.gamePicOut.clearAnimation()
binding.gamePicIn1.clearAnimation()
} }
fun startAnim() { fun startAnim() {
binding.progressViewCircleSmall.setProgressTextVisibility(true) binding.progressViewCircleSmall.setProgressTextVisibility(true)
binding.progressViewCircleSmall.startProgressAnimation() binding.progressViewCircleSmall.startProgressAnimation()
binding.gamePicOut.startAnimation(getDefaultAnim())
binding.gamePicIn1.startAnimation(getDefaultAnim())
} }
fun getDefaultAnim(): RotateAnimation { fun getDefaultAnim(): RotateAnimation {
val multiple = 1000
val rotate = RotateAnimation( val rotate = RotateAnimation(
0f, 0f,
360f, 360f * multiple,
Animation.RELATIVE_TO_SELF, Animation.RELATIVE_TO_SELF,
0.5f, 0.5f,
Animation.RELATIVE_TO_SELF, Animation.RELATIVE_TO_SELF,
...@@ -299,13 +316,10 @@ class AccelertorFragment : XPageFragment() { ...@@ -299,13 +316,10 @@ class AccelertorFragment : XPageFragment() {
) )
val lin = LinearInterpolator() val lin = LinearInterpolator()
rotate.interpolator = lin rotate.interpolator = lin
rotate.duration = 2000 //设置动画持续周期 rotate.duration = 2000L * multiple //设置动画持续周期
rotate.repeatCount = -1 //设置重复次数 rotate.repeatCount = -1 //设置重复次数
rotate.fillAfter = true //动画执行完后是否停留在执行完的状态
rotate.startOffset = 10 //执行前的等待时间
return rotate return rotate
} }
......
package com.ccwangluo.accelerator.ui.login
import android.os.Bundle
import android.view.View
import androidx.core.widget.addTextChangedListener
import androidx.lifecycle.ViewModelProvider
import com.ccwangluo.accelerator.databinding.FragmentLoginPhoneBinding
import com.ccwangluo.accelerator.utils.LoginUtils
import com.hjq.toast.ToastUtils
import com.xuexiang.xpage.annotation.Page
import com.xuexiang.xpage.base.XPageActivity
import com.xuexiang.xutil.common.StringUtils
import java.util.regex.Pattern
@Page(name = "phone_login")
class PhoneLoginActivity:XPageActivity() {
private lateinit var loginViewModel: LoginViewModel
private lateinit var binding: FragmentLoginPhoneBinding
private var mCountTime = 60
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = FragmentLoginPhoneBinding.inflate(layoutInflater)
loginViewModel = ViewModelProvider(this).get(LoginViewModel::class.java)
setContentView(binding.root)
initViews()
initListeners()
}
fun initViews() {
binding.phoneEt.addTextChangedListener {
val phone = it.toString().trim()
val authCdoe = binding.authCodeEt.text.toString()
if (phone.length > 0) {
binding.authCodeBtn.isEnabled = true
} else {
binding.authCodeBtn.isEnabled = false
}
if (isPhone(phone) && authCdoe.length > 0) {
binding.login.isEnabled = true
} else {
binding.login.isEnabled = false
}
}
binding.authCodeEt.addTextChangedListener {
val authCdoe = it.toString().trim()
val phone = binding.phoneEt.text.toString()
if (isPhone(phone) && authCdoe.length > 0) {
binding.login.isEnabled = true
} else {
binding.login.isEnabled = false
}
if (isPhone(phone) && authCdoe.length == 6 && binding.cbProtocol.isChecked) {
loginViewModel.login(phone, authCdoe)
}
}
loginViewModel.sendCodeState.observe(this, {
if (it) {
LoginUtils.startTimer()
} else {
binding.authCodeBtn.visibility = View.VISIBLE
binding.authCodeWait.visibility = View.GONE
binding.authCodeBtn.isEnabled = true
}
})
loginViewModel.loginState.observe(this, {
if (it) {
finish()
}
})
loginViewModel.timerNumber.observe(this, {
if (it > 0) {
binding.authCodeBtn.visibility = View.GONE
binding.authCodeWait.visibility = View.VISIBLE
binding.authCodeBtn.isEnabled = false
binding.authCodeWait.setText("${it}秒后重新获得验证码")
} else {
resetCounter()
}
})
}
fun initListeners() {
binding.privacyAggreement.setOnClickListener({
})
binding.userAggreement.setOnClickListener {
}
binding.phoneClear.setOnClickListener {
binding.phoneEt.setText("")
}
binding.authCodeBtn.setOnClickListener {
val phone = binding.phoneEt.text.toString()
if (StringUtils.isEmpty(phone) || !isPhone(phone)) {
ToastUtils.show("输入正确的手机号")
return@setOnClickListener
}
binding.authCodeBtn.isEnabled = false
loginViewModel.getAuthCode(phone)
}
binding.btnBack.setOnClickListener {
finish()
}
binding.login.setOnClickListener {
//检查验证码,手机号格式
val phone = binding.phoneEt.text.toString()
val authCdoe = binding.authCodeEt.text.toString()
if (StringUtils.isEmpty(phone) || !isPhone(phone)) {
ToastUtils.show("输入正确的手机号")
return@setOnClickListener
}
if (StringUtils.isEmpty(authCdoe) || authCdoe.length < 6) {
ToastUtils.show("请输入验证码")
return@setOnClickListener
}
//检查ck
if (!binding.cbProtocol.isChecked) {
ToastUtils.show("先勾选协议哦")
return@setOnClickListener
}
loginViewModel.login(phone, authCdoe)
}
}
fun isPhone(phone: String): Boolean {
// 开头的"1"代表第一位为数字1,"[3-9]"代表第二位可以为3、4、5、6、7、8、9其中之一,"\\d{9}"代表后面是9位数字
val regex = "1[3-9]\\d{9}"
return Pattern.matches(regex, phone)
}
override fun onResume() {
super.onResume()
LoginUtils.registerTimerCallBack {
loginViewModel.timerNumber.postValue(it)
}
}
override fun onPause() {
super.onPause()
LoginUtils.unRegisterTimerCallBack()
}
//重置按钮状态
fun resetCounter() {
mCountTime = 60
binding.authCodeBtn.visibility = View.VISIBLE
binding.authCodeWait.visibility = View.GONE
binding.authCodeBtn.setText("重新获取验证码")
binding.authCodeBtn.isEnabled = true
}
}
\ No newline at end of file
...@@ -169,4 +169,13 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb) ...@@ -169,4 +169,13 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
AppUtils.uninstallApp(pageName) AppUtils.uninstallApp(pageName)
} }
/**
* 版本号
*/
@JavascriptInterface
fun getVersion(callback: String) {
agentWeb.getJsAccessEntrace()
.quickCallJs(callback, AppUtils.getAppVersionName(), AppUtils.getAppVersionCode().toString())
}
} }
\ No newline at end of file
...@@ -85,23 +85,23 @@ object AcceleratorUtils { ...@@ -85,23 +85,23 @@ object AcceleratorUtils {
ProfileManager.ensureNotEmpty() ProfileManager.ensureNotEmpty()
context.lifecycleScope.launch(Dispatchers.IO) { context.lifecycleScope.launch(Dispatchers.IO) {
while (true) { while (true) {
val net = SysUtils.getNetPing("10.3.0.229") game?.let {
if (state != BaseService.State.Connected) { val net = SysUtils.getNetPing(it.boosterServerIp)
pre_net = net.delay if (state != BaseService.State.Connected) {
acc_net = -1 pre_net = net.delay
} else { acc_net = -1
acc_net = if (net.delay > pre_net) pre_net else net.delay } else {
LoginUtils.getUserHasTimer { acc_net = if (net.delay > pre_net) pre_net else net.delay
if (!it) { //没有加速时长关闭服务 LoginUtils.getUserHasTimer {
stopAccelerator() if (!it) { //没有加速时长关闭服务
stopAccelerator()
}
} }
} }
net.preNetDelay = pre_net
net.accNetDelay = acc_net
stateListener(state, getAccTime(), net)
} }
net.preNetDelay = pre_net
net.accNetDelay = acc_net
stateListener(state, getAccTime(), net)
delay(1000) delay(1000)
} }
} }
...@@ -122,7 +122,7 @@ object AcceleratorUtils { ...@@ -122,7 +122,7 @@ object AcceleratorUtils {
fun initAuthProfile(xPageFragment: XPageFragment) { fun initAuthProfile(xPageFragment: XPageFragment) {
xPageFragment.lifecycleScope.launch(Dispatchers.IO) { xPageFragment.lifecycleScope.launch(Dispatchers.IO) {
AuthManager.getLineConfig()?.let { AuthManager.getLineConfig()?.let {
if (it.code != 200){ if (it.code != 200) {
return@let return@let
} }
val profileId = 1L val profileId = 1L
...@@ -145,7 +145,8 @@ object AcceleratorUtils { ...@@ -145,7 +145,8 @@ object AcceleratorUtils {
"com.pubg.krmobile", "com.pubg.krmobile",
"com.tgc.sky.android", "com.tgc.sky.android",
"com.YoStarJP.Arknights", "com.YoStarJP.Arknights",
"com.riotgames.league.wildrifttw" "com.riotgames.league.wildrifttw",
game?.packageName
) )
proxyGames.addAll(profile.individual.split("\n")) proxyGames.addAll(profile.individual.split("\n"))
Timber.d("start vpn with games: $proxyGames") Timber.d("start vpn with games: $proxyGames")
...@@ -154,7 +155,7 @@ object AcceleratorUtils { ...@@ -154,7 +155,7 @@ object AcceleratorUtils {
profile.password = "barfoo!" profile.password = "barfoo!"
profile.method = "none" profile.method = "none"
profile.beatsInterval = 60 profile.beatsInterval = 60
withContext(Dispatchers.Main){ withContext(Dispatchers.Main) {
ProfileManager.updateProfile(profile) ProfileManager.updateProfile(profile)
connect.launch(null) connect.launch(null)
} }
......
package com.ccwangluo.accelerator.utils package com.ccwangluo.accelerator.utils
import android.content.Context import android.content.Context
import android.content.Intent
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.viewModelScope
import com.ccwangluo.accelerator.model.LoginRes import com.ccwangluo.accelerator.model.LoginRes
import com.ccwangluo.accelerator.model.UserProfile import com.ccwangluo.accelerator.model.UserProfile
import com.ccwangluo.accelerator.ui.login.PhoneLoginFragment import com.ccwangluo.accelerator.ui.login.PhoneLoginActivity
import com.ccwangluo.accelerator.utils.http.HttpGo import com.ccwangluo.accelerator.utils.http.HttpGo
import com.chuanglan.shanyan_sdk.OneKeyLoginManager import com.chuanglan.shanyan_sdk.OneKeyLoginManager
import com.github.shadowsocks.Core
import com.github.shadowsocks.bg.AuthManager import com.github.shadowsocks.bg.AuthManager
import com.hjq.toast.ToastUtils import com.hjq.toast.ToastUtils
import com.tencent.mmkv.MMKV import com.tencent.mmkv.MMKV
import com.xuexiang.xpage.base.XPageFragment import com.xuexiang.xpage.base.XPageFragment
import com.xuexiang.xpage.core.PageOption
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
...@@ -125,7 +125,12 @@ object LoginUtils { ...@@ -125,7 +125,12 @@ object LoginUtils {
} }
} }
} else { } else {
PageOption.to(PhoneLoginFragment::class.java).open(xPageFragment) xPageFragment.startActivity(
Intent(
xPageFragment.context,
PhoneLoginActivity::class.java
)
)
} }
} }
} }
...@@ -133,6 +138,7 @@ object LoginUtils { ...@@ -133,6 +138,7 @@ object LoginUtils {
private const val KEY_TOKEN = "com.ccwangluo.KEY_TOKEN" private const val KEY_TOKEN = "com.ccwangluo.KEY_TOKEN"
fun clearToken() { fun clearToken() {
Core.stopService()
MMKV.defaultMMKV().remove(KEY_TOKEN) MMKV.defaultMMKV().remove(KEY_TOKEN)
} }
......
...@@ -2,6 +2,7 @@ package com.ccwangluo.accelerator.utils ...@@ -2,6 +2,7 @@ package com.ccwangluo.accelerator.utils
import android.app.Application import android.app.Application
import android.content.Context import android.content.Context
import android.content.Intent
import android.graphics.Color import android.graphics.Color
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.util.Log import android.util.Log
...@@ -9,7 +10,7 @@ import android.util.TypedValue ...@@ -9,7 +10,7 @@ import android.util.TypedValue
import android.widget.RelativeLayout import android.widget.RelativeLayout
import android.widget.TextView import android.widget.TextView
import com.ccwangluo.accelerator.R import com.ccwangluo.accelerator.R
import com.ccwangluo.accelerator.ui.login.PhoneLoginFragment import com.ccwangluo.accelerator.ui.login.PhoneLoginActivity
import com.chuanglan.shanyan_sdk.OneKeyLoginManager import com.chuanglan.shanyan_sdk.OneKeyLoginManager
import com.chuanglan.shanyan_sdk.tool.ShanYanUIConfig import com.chuanglan.shanyan_sdk.tool.ShanYanUIConfig
...@@ -138,7 +139,10 @@ object PhoneUtils { ...@@ -138,7 +139,10 @@ object PhoneUtils {
.setLogBtnImgPath(context.resources.getDrawable(R.mipmap.login_btn_onekey)) .setLogBtnImgPath(context.resources.getDrawable(R.mipmap.login_btn_onekey))
.addCustomView( .addCustomView(
mOtherTv, true, false mOtherTv, true, false
) { context, view -> PageOption.to(PhoneLoginFragment::class.java).open(xPageFragment) } ) { context, view -> xPageFragment.startActivity(
Intent(xPageFragment.context,
PhoneLoginActivity::class.java)
) }
.setPrivacyState(false) .setPrivacyState(false)
.setCheckedImgPath(mCheckedImg) .setCheckedImgPath(mCheckedImg)
.setUncheckedImgPath(mCunheckedImg) .setUncheckedImgPath(mCunheckedImg)
......
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:fromDegrees="0"
android:toDegrees="359"
android:pivotX="50%"
android:pivotY="50%"
android:duration="2000"
android:repeatCount="-1">
</rotate>
</rotate>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/circle_out_1" android:duration="1000"/>
<item android:drawable="@drawable/circle_out_2" android:duration="1000"/>
<item android:drawable="@drawable/circle_out_3" android:duration="1000"/>
</animation-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#F9F9F9" />
<corners android:radius="10dp" />
</shape>
\ No newline at end of file
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
android:textSize="13sp" android:textSize="13sp"
/> />
<com.xuexiang.xui.widget.layout.XUILinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="49dp" android:layout_height="49dp"
android:layout_marginLeft="30dp" android:layout_marginLeft="30dp"
...@@ -52,17 +52,17 @@ ...@@ -52,17 +52,17 @@
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
android:background="#F9F9F9" android:background="@drawable/edittext_shape"
android:orientation="horizontal" android:orientation="horizontal">
app:xui_radius="10dp">
<EditText <EditText
android:focusable="true"
android:id="@+id/phone_et" android:id="@+id/phone_et"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="30dp" android:layout_height="30dp"
android:inputType="number" android:inputType="number"
android:background="@null" android:background="@null"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:textColor="#FF000000" android:textColor="#FF000000"
android:layout_weight="1" android:layout_weight="1"
...@@ -78,22 +78,21 @@ ...@@ -78,22 +78,21 @@
android:background="@mipmap/edit_del" android:background="@mipmap/edit_del"
/> />
</com.xuexiang.xui.widget.layout.XUILinearLayout> </LinearLayout>
<com.xuexiang.xui.widget.layout.XUILinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="49dp" android:layout_height="49dp"
android:layout_marginLeft="30dp" android:layout_marginLeft="30dp"
android:layout_marginRight="30dp" android:layout_marginRight="30dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
android:background="#F9F9F9" android:background="@drawable/edittext_shape"
android:orientation="horizontal" android:orientation="horizontal"
app:xui_radius="10dp"> >
<EditText <EditText
android:focusable="true"
android:id="@+id/auth_code_et" android:id="@+id/auth_code_et"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="30dp" android:layout_height="30dp"
...@@ -102,6 +101,8 @@ ...@@ -102,6 +101,8 @@
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:textColor="#FF000000" android:textColor="#FF000000"
android:layout_weight="1" android:layout_weight="1"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="请输入验证码" android:hint="请输入验证码"
android:maxLength="6" android:maxLength="6"
android:textSize="15sp"/> android:textSize="15sp"/>
...@@ -128,7 +129,7 @@ ...@@ -128,7 +129,7 @@
android:textSize="13sp" android:textSize="13sp"
/> />
</com.xuexiang.xui.widget.layout.XUILinearLayout> </LinearLayout>
<com.xuexiang.xui.widget.button.roundbutton.RoundButton <com.xuexiang.xui.widget.button.roundbutton.RoundButton
android:id="@+id/login" android:id="@+id/login"
......
...@@ -136,7 +136,9 @@ ...@@ -136,7 +136,9 @@
style="@style/MyTablayoutstyle" style="@style/MyTablayoutstyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp" /> android:layout_marginTop="5dp"
app:tabBackground="@null"
app:tabRippleColor="@null"/>
<androidx.viewpager2.widget.ViewPager2 <androidx.viewpager2.widget.ViewPager2
android:id="@+id/view_pager" android:id="@+id/view_pager"
......
...@@ -69,33 +69,7 @@ ...@@ -69,33 +69,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<com.xuexiang.xui.widget.layout.XUILinearLayout
android:id="@+id/quick_top_toast"
android:layout_width="320dp"
android:layout_height="34dp"
android:layout_centerHorizontal="true"
android:background="#FF151721"
android:gravity="center"
android:orientation="horizontal"
android:visibility="gone"
app:xui_radius="10dp">
<ImageView
android:layout_width="14dp"
android:layout_height="14dp"
android:background="@mipmap/icon_error" />
<TextView
android:id="@+id/quick_top_toast_tx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:text="请先安装游戏后加速"
android:textColor="#FFD5D7DF"
android:textSize="14sp" />
</com.xuexiang.xui.widget.layout.XUILinearLayout>
<ImageView <ImageView
android:id="@+id/game_pic_out" android:id="@+id/game_pic_out"
...@@ -106,7 +80,7 @@ ...@@ -106,7 +80,7 @@
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginEnd="5dp" android:layout_marginEnd="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:background="@mipmap/circle_out" /> android:background="@drawable/animati_cricle" />
<ImageView <ImageView
android:id="@+id/game_pic_in1" android:id="@+id/game_pic_in1"
...@@ -144,6 +118,33 @@ ...@@ -144,6 +118,33 @@
app:cpv_start_progress="0" app:cpv_start_progress="0"
app:cpv_track_color="#57595B" app:cpv_track_color="#57595B"
app:cpv_track_width="4dp" /> app:cpv_track_width="4dp" />
<com.xuexiang.xui.widget.layout.XUILinearLayout
android:id="@+id/quick_top_toast"
android:layout_width="320dp"
android:layout_height="34dp"
android:layout_centerHorizontal="true"
android:background="#FF151721"
android:gravity="center"
android:visibility="gone"
android:orientation="horizontal"
app:xui_radius="10dp">
<ImageView
android:layout_width="14dp"
android:layout_height="14dp"
android:background="@mipmap/icon_error" />
<TextView
android:id="@+id/quick_top_toast_tx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:text="请先安装游戏后加速"
android:textColor="#FFD5D7DF"
android:textSize="14sp" />
</com.xuexiang.xui.widget.layout.XUILinearLayout>
</RelativeLayout> </RelativeLayout>
...@@ -406,7 +407,7 @@ ...@@ -406,7 +407,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text="2" android:text="__"
android:textColor="#FFFFFFFF" android:textColor="#FFFFFFFF"
android:textSize="16sp" /> android:textSize="16sp" />
......
...@@ -6,4 +6,5 @@ ...@@ -6,4 +6,5 @@
<dimen name="textsize_middle">18sp</dimen> <dimen name="textsize_middle">18sp</dimen>
<dimen name="textsize_little">12sp</dimen> <dimen name="textsize_little">12sp</dimen>
<dimen name="textsize_lit_mid">15sp</dimen> <dimen name="textsize_lit_mid">15sp</dimen>
<dimen name="fab_margin">16dp</dimen>
</resources> </resources>
\ No newline at end of file
...@@ -7,4 +7,13 @@ ...@@ -7,4 +7,13 @@
<string name="title_activity_main2">Main2Activity</string> <string name="title_activity_main2">Main2Activity</string>
<!-- TODO: Remove or change this placeholder text --> <!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string> <string name="hello_blank_fragment">Hello blank fragment</string>
<string name="title_activity_phone_login">PhoneLoginActivity</string>
<!-- Strings used for fragments for navigation -->
<string name="first_fragment_label">First Fragment</string>
<string name="second_fragment_label">Second Fragment</string>
<string name="next">Next</string>
<string name="previous">Previous</string>
<string name="hello_first_fragment">Hello first fragment</string>
<string name="hello_second_fragment">Hello second fragment. Arg: %1$s</string>
</resources> </resources>
\ No newline at end of file
...@@ -24,10 +24,10 @@ ...@@ -24,10 +24,10 @@
<item name="colorAccent">@color/black</item> <item name="colorAccent">@color/black</item>
<item name="android:windowTranslucentStatus">true</item> <item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item> <item name="android:windowTranslucentNavigation">true</item>
<!-- <item name="android:background">@mipmap/splash</item>--> <!-- <item name="android:background">@mipmap/splash</item>-->
<item name="android:windowBackground">@mipmap/win_bg</item> <item name="android:windowBackground">@mipmap/win_bg</item>
<item name="android:windowDisablePreview">true</item> <item name="android:windowDisablePreview">true</item>
<!-- <item name="xui_config_splash_app_logo">@mipmap/tt_logo</item>--> <!-- <item name="xui_config_splash_app_logo">@mipmap/tt_logo</item>-->
<item name="xpage_actionbar_background">@null</item> <item name="xpage_actionbar_background">@null</item>
<!--标题栏的背景颜色--> <!--标题栏的背景颜色-->
<item name="xpage_actionbar_color">@color/white</item> <item name="xpage_actionbar_color">@color/white</item>
...@@ -52,7 +52,6 @@ ...@@ -52,7 +52,6 @@
</style> </style>
<style name="XPageTitleBar.Custom"> <style name="XPageTitleBar.Custom">
<item name="tb_immersive">false</item> <item name="tb_immersive">false</item>
<item name="tb_centerGravity">center</item> <item name="tb_centerGravity">center</item>
...@@ -62,4 +61,13 @@ ...@@ -62,4 +61,13 @@
<item name="android:button">@drawable/btn_check</item> <item name="android:button">@drawable/btn_check</item>
</style> </style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources> </resources>
\ No newline at end of file
...@@ -90,25 +90,25 @@ object AuthManager { ...@@ -90,25 +90,25 @@ object AuthManager {
profile.token = it.data.token profile.token = it.data.token
profile.remotePort = it.data.port profile.remotePort = it.data.port
profile.proxyApps = true profile.proxyApps = true
val proxyGames = mutableSetOf( // val proxyGames = mutableSetOf(
"com.sec.android.app.sbrowser", // "com.sec.android.app.sbrowser",
"com.nexon.maplem.global", // "com.nexon.maplem.global",
"jp.co.cygames.umamusume", // "jp.co.cygames.umamusume",
"com.ea.gp.apexlegendsmobilefps", // "com.ea.gp.apexlegendsmobilefps",
"jp.konami.duellinks", // "jp.konami.duellinks",
"com.riotgames.league.wildrift", // "com.riotgames.league.wildrift",
"com.garena.game.codm", // "com.garena.game.codm",
"com.google.android.configupdater", // "com.google.android.configupdater",
"com.miHoYo.GenshinImpact", // "com.miHoYo.GenshinImpact",
"com.rekoo.pubgm", // "com.rekoo.pubgm",
"com.pubg.krmobile", // "com.pubg.krmobile",
"com.tgc.sky.android", // "com.tgc.sky.android",
"com.YoStarJP.Arknights", // "com.YoStarJP.Arknights",
"com.riotgames.league.wildrifttw" // "com.riotgames.league.wildrifttw"
) // )
proxyGames.addAll(profile.individual.split("\n")) // proxyGames.addAll(profile.individual.split("\n"))
Timber.d("start vpn with games: $proxyGames") Timber.d("start vpn with games: ${profile.individual}")
profile.individual = proxyGames.joinToString("\n") // profile.individual = proxyGames.joinToString("\n")
profile.route = Acl.BYPASS_LAN profile.route = Acl.BYPASS_LAN
profile.password = "barfoo!" profile.password = "barfoo!"
profile.method = "none" profile.method = "none"
...@@ -134,10 +134,13 @@ object AuthManager { ...@@ -134,10 +134,13 @@ object AuthManager {
if (data.state == BaseService.State.Connected) { if (data.state == BaseService.State.Connected) {
getToken()?.let { getToken()?.let {
configJson.addProperty("token", it.data.token) if (it.code == 200) {
configFile.writeText(configJson.toString()) configJson.addProperty("token", it.data.token)
configFile.writeText(configJson.toString())
} else {
Core.stopService()
}
} }
} }
}, 3, 3, TimeUnit.MINUTES) }, 3, 3, TimeUnit.MINUTES)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment