Commit a9f96c77 authored by liusheng's avatar liusheng

Merge branch 'cc-dev' into 11a-dev

parents b3f52012 80d67793
...@@ -25,7 +25,16 @@ ...@@ -25,7 +25,16 @@
<package android:name="com.tencent.mobileqq" /> <package android:name="com.tencent.mobileqq" />
<package android:name="com.baidu.browser.apps" /> <package android:name="com.baidu.browser.apps" />
<package android:name="com.ldsanguo.shark" /> <package android:name="com.ldsanguo.shark" />
<package android:name="com.ldsanguomj.shark" />
<package android:name="com.nexon.mdnf.cbt" /> <package android:name="com.nexon.mdnf.cbt" />
<package android:name="com.google.android.gsf" />
<package android:name="com.google.android.gms" />
<package android:name="com.android.vending" />
<package android:name="com.tencent.mobileqq" />
<package android:name="com.tencent.mm" />
<package android:name="com.goplaycn.googleinstall" />
<package android:name="io.kkzs" />
</queries> </queries>
<application <application
......
...@@ -12,7 +12,7 @@ data class GameInfo( ...@@ -12,7 +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 boosterServer:String,
val imgs: String, val imgs: String,
val introduction: String, val introduction: String,
val packageName: String, val packageName: String,
......
package com.ccwangluo.accelerator.model package com.ccwangluo.accelerator.model
data class News( data class News(
val aavatar: String?, val aAvatar: String?,
val aCreatedDate: String?,
val aNickname: String?,
val aUserId: Int?,
val abbrContent: String?, val abbrContent: String?,
val acreatedDate: String?,
val anickname: String?,
val auserId: String?,
val avatar: String?, val avatar: String?,
val createdDate: String?, val createdDate: String?,
val greatNum: Int?, val greatNum: Int?,
val id: Int, val id: Int,
val imgs: String?, val imgs: String?,
var isGreat: Boolean?, var isGreat: Boolean,
val nickname: String?, val nickname: String?,
val pageViews: Int?, val pageViews: Int?,
val qavatar: String?, val qAvatar: String?,
val qcreatedDate: String?, val qCreatedDate: String?,
val qnickname: String?, val qNickname: String?,
val quserId: String?, val qUserId: Int?,
val star: String?, val star: String?,
val title: String?, val title: String?,
val type: Int?, val type: Int,
val userId: Int?,
val videoImg: String?,
val videoUrl: String? val videoUrl: String?
) )
\ No newline at end of file
package com.ccwangluo.accelerator.model
data class Plugin(
val createdDate: String?,
val gameId: Int,
val icon: String?,
val id: Int,
val isOpen: Boolean,
val name: String?,
val type: Int,
val url: String?
)
\ No newline at end of file
package com.ccwangluo.accelerator.model
data class PluginModel(
val list: List<Plugin>,
val total: Int
)
\ No newline at end of file
...@@ -55,7 +55,6 @@ class BottomNavigationFragment : XPageFragment(), ViewPager.OnPageChangeListener ...@@ -55,7 +55,6 @@ class BottomNavigationFragment : XPageFragment(), ViewPager.OnPageChangeListener
binding.viewPager.setOffscreenPageLimit(titles.size - 1); binding.viewPager.setOffscreenPageLimit(titles.size - 1);
binding.viewPager.adapter = adapter binding.viewPager.adapter = adapter
binding.viewPager.setNoScroll(true) binding.viewPager.setNoScroll(true)
AcceleratorUtils.getGameList(this,{})
} }
override fun initListeners() { override fun initListeners() {
......
...@@ -31,6 +31,7 @@ import com.xuexiang.xpage.base.XPageActivity ...@@ -31,6 +31,7 @@ import com.xuexiang.xpage.base.XPageActivity
import com.xuexiang.xpage.core.PageOption import com.xuexiang.xpage.core.PageOption
import android.hardware.SensorManager import android.hardware.SensorManager
import android.hardware.SensorEventListener import android.hardware.SensorEventListener
import android.os.Handler
import com.ccwangluo.accelerator.utils.SysUtils import com.ccwangluo.accelerator.utils.SysUtils
import com.xuexiang.xutil.net.NetworkUtils import com.xuexiang.xutil.net.NetworkUtils
import com.xuexiang.xutil.system.PermissionUtils import com.xuexiang.xutil.system.PermissionUtils
...@@ -61,7 +62,8 @@ class MainActivity() : XPageActivity(), TencentLocationListener { ...@@ -61,7 +62,8 @@ class MainActivity() : XPageActivity(), TencentLocationListener {
Manifest.permission.READ_PHONE_STATE, Manifest.permission.READ_PHONE_STATE,
Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.ACCESS_FINE_LOCATION Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.CAMERA
) )
.withListener(object : MultiplePermissionsListener { .withListener(object : MultiplePermissionsListener {
override fun onPermissionsChecked(p0: MultiplePermissionsReport?) { override fun onPermissionsChecked(p0: MultiplePermissionsReport?) {
...@@ -83,7 +85,7 @@ class MainActivity() : XPageActivity(), TencentLocationListener { ...@@ -83,7 +85,7 @@ class MainActivity() : XPageActivity(), TencentLocationListener {
p0: MutableList<PermissionRequest>?, p0: MutableList<PermissionRequest>?,
p1: PermissionToken? p1: PermissionToken?
) { ) {
PermissionUtils.openAppSettings() // PermissionUtils.openAppSettings()
} }
}).check() }).check()
...@@ -106,7 +108,6 @@ class MainActivity() : XPageActivity(), TencentLocationListener { ...@@ -106,7 +108,6 @@ class MainActivity() : XPageActivity(), TencentLocationListener {
mSensorManager = getSystemService(SENSOR_SERVICE) as SensorManager mSensorManager = getSystemService(SENSOR_SERVICE) as SensorManager
mSensorEventListener = JCVideoPlayer.JCAutoFullscreenListener() mSensorEventListener = JCVideoPlayer.JCAutoFullscreenListener()
} }
private fun initPhoneUtils() { private fun initPhoneUtils() {
...@@ -127,13 +128,16 @@ class MainActivity() : XPageActivity(), TencentLocationListener { ...@@ -127,13 +128,16 @@ class MainActivity() : XPageActivity(), TencentLocationListener {
mSensorEventListener, mSensorEventListener,
mSensor, mSensor,
SensorManager.SENSOR_DELAY_NORMAL SensorManager.SENSOR_DELAY_NORMAL
); )
Handler().postDelayed({
AcceleratorUtils.checkVpn()
}, 1000)
} }
override fun onPause() { override fun onPause() {
super.onPause() super.onPause()
mSensorManager?.unregisterListener(mSensorEventListener); mSensorManager?.unregisterListener(mSensorEventListener);
JCVideoPlayer.releaseAllVideos(); JCVideoPlayer.releaseAllVideos()
} }
override fun onStart() { override fun onStart() {
......
...@@ -28,12 +28,11 @@ class MemberDialog( ...@@ -28,12 +28,11 @@ class MemberDialog(
btn.setOnClickListener { btn.setOnClickListener {
dismiss<MemberDialog>() dismiss<MemberDialog>()
val params = Bundle() val params = Bundle()
params.putString(CommonWebViewFragment.WEBVIEW_URL_KEY, HttpConfig.MEMBER_CENTER) params.putString(CommonWebViewFragment.WEBVIEW_URL_KEY,HttpConfig.UI_MAIN_URL + HttpConfig.MEMBER_CENTER)
fragment.openPage(CommonWebViewFragment::class.java, params) fragment.openPage(CommonWebViewFragment::class.java, params)
} }
} }
init { init {
mDialog.setCancelable(false)
} }
......
...@@ -48,7 +48,6 @@ class AccelertorFragment : XPageFragment() { ...@@ -48,7 +48,6 @@ class AccelertorFragment : XPageFragment() {
return binding.root return binding.root
} }
var isStartAcc = false
override fun initViews() { override fun initViews() {
accelertorViewModel.netState.observe(this, { accelertorViewModel.netState.observe(this, {
...@@ -102,10 +101,6 @@ class AccelertorFragment : XPageFragment() { ...@@ -102,10 +101,6 @@ class AccelertorFragment : XPageFragment() {
state = it state = it
freshData(it) freshData(it)
} }
if (isStartAcc && state == BaseService.State.Stopped) {
isStartAcc = false
ToastUtils.show("加速失败")
}
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))
...@@ -139,7 +134,11 @@ class AccelertorFragment : XPageFragment() { ...@@ -139,7 +134,11 @@ class AccelertorFragment : XPageFragment() {
binding.progressArea.visibility = View.GONE binding.progressArea.visibility = View.GONE
binding.btnQuick.isEnabled = true binding.btnQuick.isEnabled = true
binding.progressViewCircleSmall.progress = 0F binding.progressViewCircleSmall.progress = 0F
isStartAcc = true binding.progressViewCircleSmall.postDelayed({
if(state != BaseService.State.Connected){
ToastUtils.show("加速失败")
}
},3000)
AcceleratorUtils.startAccelerator(this@AccelertorFragment) AcceleratorUtils.startAccelerator(this@AccelertorFragment)
} }
}) })
...@@ -157,7 +156,7 @@ class AccelertorFragment : XPageFragment() { ...@@ -157,7 +156,7 @@ class AccelertorFragment : XPageFragment() {
} }
binding.gamePage.setOnClickListener { binding.gamePage.setOnClickListener {
openToWebview(HttpConfig.UI_GAME_URL) openToWebview(HttpConfig.UI_GAME_URL + "?gameId=${AcceleratorUtils.game?.id}")
} }
binding.smartAccOpen.setOnClickListener { binding.smartAccOpen.setOnClickListener {
...@@ -290,7 +289,6 @@ class AccelertorFragment : XPageFragment() { ...@@ -290,7 +289,6 @@ class AccelertorFragment : XPageFragment() {
fun freshData(state: BaseService.State) { fun freshData(state: BaseService.State) {
if (state == BaseService.State.Connected) { if (state == BaseService.State.Connected) {
isStartAcc = false
binding.gamePicIn1.startAnimation(getDefaultAnim()) binding.gamePicIn1.startAnimation(getDefaultAnim())
binding.accStateTx.visibility = View.VISIBLE binding.accStateTx.visibility = View.VISIBLE
binding.btnQuick.setBackgroundResource(R.mipmap.quick_stop) binding.btnQuick.setBackgroundResource(R.mipmap.quick_stop)
...@@ -302,7 +300,7 @@ class AccelertorFragment : XPageFragment() { ...@@ -302,7 +300,7 @@ class AccelertorFragment : XPageFragment() {
CommonDialog(it).setTitle("防止加速掉线") CommonDialog(it).setTitle("防止加速掉线")
.setContent("为了防止加速进程被手机系统中断,影响游戏加速,请确保完成相关设置") .setContent("为了防止加速进程被手机系统中断,影响游戏加速,请确保完成相关设置")
.setBtnLeft("取消", {}).setBtnRight("去设置", { .setBtnLeft("取消", {}).setBtnRight("去设置", {
openToWebview(HttpConfig.UI_SETTING_URL) openToWebview(HttpConfig.UI_SPEED_URL + "?id=1")
}).show<CommonDialog>() }).show<CommonDialog>()
SettingSPUtils.isFirstAccSuccess = false SettingSPUtils.isFirstAccSuccess = false
} }
......
package com.ccwangluo.accelerator.ui.home package com.ccwangluo.accelerator.ui.home
import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import android.widget.Toast
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.ccwangluo.accelerator.R import com.ccwangluo.accelerator.R
import com.ccwangluo.accelerator.adapter.KotlinDataAdapter import com.ccwangluo.accelerator.adapter.KotlinDataAdapter
import com.ccwangluo.accelerator.databinding.FragmentNewsBinding import com.ccwangluo.accelerator.databinding.FragmentNewsBinding
import com.ccwangluo.accelerator.model.News import com.ccwangluo.accelerator.model.News
import com.ccwangluo.accelerator.model.Plugin
import com.ccwangluo.accelerator.ui.MainActivity
import com.ccwangluo.accelerator.ui.news.NewsCollectionAdapter import com.ccwangluo.accelerator.ui.news.NewsCollectionAdapter
import com.ccwangluo.accelerator.ui.web.CommonWebViewFragment
import com.ccwangluo.accelerator.utils.AcceleratorUtils import com.ccwangluo.accelerator.utils.AcceleratorUtils
import com.ccwangluo.accelerator.utils.LoginUtils
import com.ccwangluo.accelerator.utils.SysUtils
import com.ccwangluo.cc_quickly.utils.XToastUtils
import com.github.shadowsocks.http.HttpConfig
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.tabs.TabLayoutMediator import com.google.android.material.tabs.TabLayoutMediator
import com.hjq.toast.ToastUtils
import com.just.agentweb.download.DownloadTask
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.widget.toast.XToast
import com.xuexiang.xutil.XUtil
import com.xuexiang.xutil.app.AppUtils
class NewsFragment : XPageFragment() { class NewsFragment : XPageFragment() {
private var _binding: FragmentNewsBinding? = null private var _binding: FragmentNewsBinding? = null
...@@ -24,46 +45,109 @@ class NewsFragment : XPageFragment() { ...@@ -24,46 +45,109 @@ class NewsFragment : XPageFragment() {
return null return null
} }
var dataList = arrayListOf<String>() var dataList = arrayListOf<Plugin>()
override fun inflateView(inflater: LayoutInflater?, container: ViewGroup?): View { override fun inflateView(inflater: LayoutInflater?, container: ViewGroup?): View {
_binding = FragmentNewsBinding.inflate(inflater!!, container, false) _binding = FragmentNewsBinding.inflate(inflater!!, container, false)
newsViewModel = ViewModelProvider(this).get(NewsViewModel::class.java) newsViewModel = ViewModelProvider(requireActivity()).get(NewsViewModel::class.java)
return binding.root return binding.root
} }
val titles = arrayOf("全部", "攻略", "视频", "评价", "问答") val titles = arrayOf("全部", "攻略", "视频", "评价", "问答")
var adapter: NewsCollectionAdapter? = null var adapter: NewsCollectionAdapter? = null
override fun initViews() { override fun initViews() {
newsViewModel.notice.observe(this,{ newsViewModel.notice.observe(this, {
it.forEach {
binding.tvMarquee.addDisplayString(it.title) binding.tvMarquee.addDisplayString(it.title)
}
binding.tvMarquee.startRoll() binding.tvMarquee.startRoll()
}) })
binding.refreshNews.setOnClickListener { newsViewModel.isRefresh.observe(this, Observer {
binding.refreshNews.isRefreshing = false
})
binding.appbar.addOnOffsetChangedListener(object : AppBarLayout.OnOffsetChangedListener {
override fun onOffsetChanged(appBarLayout: AppBarLayout?, verticalOffset: Int) {
if (verticalOffset >= 0) {
binding.refreshNews.isEnabled = true
} else {
binding.refreshNews.isEnabled = false
}
}
})
binding.refreshNews.setOnRefreshListener {
adapter?.refresh(binding.viewPager.currentItem) adapter?.refresh(binding.viewPager.currentItem)
binding.refreshNews.postDelayed({ binding.refreshNews.postDelayed({
binding.refreshNews.isRefreshing = false binding.refreshNews.isRefreshing = false
},1000) }, 2000)
} }
binding.gameNewsList.adapter = KotlinDataAdapter.Builder<String>() val layoutManager = LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
binding.gameNewsList?.setLayoutManager(layoutManager)
binding.gameNewsList.adapter = KotlinDataAdapter.Builder<Plugin>()
.setData(dataList) .setData(dataList)
.setLayoutId(R.layout.item_news_game) .setLayoutId(R.layout.item_news_game)
.addBindView{itemView, itemData -> .addBindView { itemView, itemData ->
context?.let {
Glide.with(it).load(itemData.icon)
.into(itemView.findViewById<ImageView>(R.id.plugin_img))
}
itemView.findViewById<TextView>(R.id.plugin_name).setText(itemData.name)
itemView.setOnClickListener {
if (!itemData.isOpen) {
ToastUtils.show("暂不支持${itemData.name}")
return@setOnClickListener
}
}.create() if (itemData.type == 1) {
itemData.url?.let {
context?.let { it1 -> SysUtils.joinQQGroup(it1) }
}
}
if (itemData.type == 2) {
itemData.url?.let {
openToWebview(it)
}
}
if (itemData.type == 3) {
itemData.url?.let {
context?.let { it1 ->
SysUtils.downloadFile(it1, it)
ToastUtils.show("开始下载")
}
}
}
}
}.create()
newsViewModel.pluginList.observe(this, {
dataList.clear()
dataList.addAll(it)
binding.gameNewsList.adapter?.notifyDataSetChanged()
})
adapter = NewsCollectionAdapter(this, titles) adapter = NewsCollectionAdapter(this, titles)
binding.viewPager.adapter = adapter binding.viewPager.adapter = adapter
TabLayoutMediator(binding.tabLayout, binding.viewPager) { tab, position -> TabLayoutMediator(binding.tabLayout, binding.viewPager) { tab, position ->
tab.setCustomView(R.layout.item_tab) tab.setCustomView(R.layout.item_tab)
tab.text = titles[position] tab.text = titles[position]
}.attach() }.attach()
AcceleratorUtils.getGameList(this) {
if (it) {
AcceleratorUtils.game?.let { AcceleratorUtils.game?.let {
newsViewModel.getNotice(it.id) newsViewModel.getNotice(it.id)
newsViewModel.getPlugin(it.id)
}
}
}
} }
fun openToWebview(url: String) {
val params = Bundle()
params.putString(CommonWebViewFragment.WEBVIEW_URL_KEY, url)
openPage(CommonWebViewFragment::class.java, params)
} }
override fun initListeners() { override fun initListeners() {
......
...@@ -3,9 +3,7 @@ package com.ccwangluo.accelerator.ui.home ...@@ -3,9 +3,7 @@ package com.ccwangluo.accelerator.ui.home
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.ccwangluo.accelerator.model.NewsModel import com.ccwangluo.accelerator.model.*
import com.ccwangluo.accelerator.model.Notice
import com.ccwangluo.accelerator.model.NoticeList
import com.ccwangluo.accelerator.utils.http.HttpGo import com.ccwangluo.accelerator.utils.http.HttpGo
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
...@@ -14,30 +12,12 @@ import javax.security.auth.callback.Callback ...@@ -14,30 +12,12 @@ import javax.security.auth.callback.Callback
class NewsViewModel : ViewModel() { class NewsViewModel : ViewModel() {
val newsModel = MutableLiveData<NewsModel>() val isRefresh = MutableLiveData<Boolean>()
val notice = MutableLiveData<Notice>()
fun freshData(position: String, gameId: Int, page: Int) { val notice = MutableLiveData<List<Notice>>()
val type = when (position) {
"1" -> 1 val pluginList = MutableLiveData<List<Plugin>>()
"2" -> 2
"3" -> 4
"4" -> 5
else -> ""
}
viewModelScope.launch(Dispatchers.IO) {
val res =
HttpGo.getSync<NewsModel>("/api/new/all/list?gameId=$gameId&page=$page&size=10&type=$type")
res?.let {
if (it.code == 200) {
it.data?.let {
newsModel.postValue(it)
}
}
}
}
}
fun getNotice(gameId: Int) { fun getNotice(gameId: Int) {
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
...@@ -46,35 +26,24 @@ class NewsViewModel : ViewModel() { ...@@ -46,35 +26,24 @@ class NewsViewModel : ViewModel() {
res?.let { res?.let {
if (it.code == 200) { if (it.code == 200) {
it.data?.list?.let { it.data?.list?.let {
notice.postValue(it.get(0)) notice.postValue(it)
} }
} }
} }
} }
} }
/** fun getPlugin(gameId: Int) {
* 点赞
*/
fun greate(type: Int?,parentId : Int, gameId: Int, callback: () -> Unit) {
val map = mutableMapOf<String, String>()
map.put("gameId", gameId.toString())
map.put("parentId",parentId.toString())
type?.let {
map.put("type", it.toString())
}
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
val res = val res =
HttpGo.postSync<String>("/api/new/great", map) HttpGo.getSync<PluginModel>("/api/plugin/list?gameId=$gameId&page=1&size=10")
res?.let { res?.let {
if (it.code == 200) { if (it.code == 200) {
withContext(Dispatchers.Main) { it.data?.list?.let {
callback() pluginList.postValue(it)
} }
} }
} }
} }
} }
} }
\ No newline at end of file
...@@ -5,6 +5,7 @@ import android.view.View ...@@ -5,6 +5,7 @@ import android.view.View
import androidx.core.widget.addTextChangedListener import androidx.core.widget.addTextChangedListener
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import com.ccwangluo.accelerator.databinding.FragmentLoginPhoneBinding import com.ccwangluo.accelerator.databinding.FragmentLoginPhoneBinding
import com.ccwangluo.accelerator.utils.AcceleratorUtils
import com.ccwangluo.accelerator.utils.LoginUtils import com.ccwangluo.accelerator.utils.LoginUtils
import com.hjq.toast.ToastUtils import com.hjq.toast.ToastUtils
import com.xuexiang.xpage.annotation.Page import com.xuexiang.xpage.annotation.Page
...@@ -13,7 +14,7 @@ import com.xuexiang.xutil.common.StringUtils ...@@ -13,7 +14,7 @@ import com.xuexiang.xutil.common.StringUtils
import java.util.regex.Pattern import java.util.regex.Pattern
@Page(name = "phone_login") @Page(name = "phone_login")
class PhoneLoginActivity:XPageActivity() { class PhoneLoginActivity : XPageActivity() {
private lateinit var loginViewModel: LoginViewModel private lateinit var loginViewModel: LoginViewModel
private lateinit var binding: FragmentLoginPhoneBinding private lateinit var binding: FragmentLoginPhoneBinding
private var mCountTime = 60 private var mCountTime = 60
...@@ -59,7 +60,7 @@ class PhoneLoginActivity:XPageActivity() { ...@@ -59,7 +60,7 @@ class PhoneLoginActivity:XPageActivity() {
loginViewModel.sendCodeState.observe(this, { loginViewModel.sendCodeState.observe(this, {
if (it) { if (it) {
LoginUtils.startTimer() LoginUtils.startTimer(binding.phoneEt.text.toString())
} else { } else {
binding.authCodeBtn.visibility = View.VISIBLE binding.authCodeBtn.visibility = View.VISIBLE
binding.authCodeWait.visibility = View.GONE binding.authCodeWait.visibility = View.GONE
...@@ -69,6 +70,7 @@ class PhoneLoginActivity:XPageActivity() { ...@@ -69,6 +70,7 @@ class PhoneLoginActivity:XPageActivity() {
loginViewModel.loginState.observe(this, { loginViewModel.loginState.observe(this, {
if (it) { if (it) {
LoginUtils.stopTimer()
finish() finish()
} }
}) })
...@@ -79,10 +81,12 @@ class PhoneLoginActivity:XPageActivity() { ...@@ -79,10 +81,12 @@ class PhoneLoginActivity:XPageActivity() {
binding.authCodeBtn.isEnabled = false binding.authCodeBtn.isEnabled = false
binding.authCodeWait.setText("${it}秒后重新获得验证码") binding.authCodeWait.setText("${it}秒后重新获得验证码")
} else { } else {
resetCounter() resetCounter(it)
} }
}) })
loginViewModel.timerNumber.postValue(-1)
binding.phoneEt.setText(LoginUtils._phone)
} }
...@@ -156,11 +160,15 @@ class PhoneLoginActivity:XPageActivity() { ...@@ -156,11 +160,15 @@ class PhoneLoginActivity:XPageActivity() {
} }
//重置按钮状态 //重置按钮状态
fun resetCounter() { fun resetCounter(i: Int) {
mCountTime = 60 mCountTime = 60
binding.authCodeBtn.visibility = View.VISIBLE binding.authCodeBtn.visibility = View.VISIBLE
binding.authCodeWait.visibility = View.GONE binding.authCodeWait.visibility = View.GONE
if (i == -1) {
binding.authCodeBtn.setText("获取验证码")
} else {
binding.authCodeBtn.setText("重新获取验证码") binding.authCodeBtn.setText("重新获取验证码")
}
binding.authCodeBtn.isEnabled = true binding.authCodeBtn.isEnabled = true
} }
......
//package com.ccwangluo.accelerator.ui.login
//
//import android.content.Context
//import android.os.Handler
//import android.os.Looper
//import android.view.LayoutInflater
//import android.view.View
//import android.view.ViewGroup
//import android.view.inputmethod.InputMethodManager
//import androidx.core.widget.addTextChangedListener
//import androidx.fragment.app.Fragment
//import androidx.lifecycle.ViewModelProvider
//import com.ccwangluo.accelerator.databinding.FragmentLoginPhoneBinding
////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.XPageFragment
//import com.xuexiang.xpage.utils.TitleBar
//import com.xuexiang.xutil.common.StringUtils
//import java.util.regex.Pattern
//
//import java.util.*
//import android.widget.EditText
//
//
//
//
//
///**
// * A simple [Fragment] subclass.
// * Use the [PhoneLoginFragment.newInstance] factory method to
// * create an instance of this fragment.
// */
//@Page(name = "login")
//class PhoneLoginFragment : XPageFragment() {
//
// override fun initTitleBar(): TitleBar? {
// return null
// }
//
// override fun hideCurrentPageSoftInput() {
//
// }
//
// private var mCountTime = 60
// private lateinit var loginViewModel: LoginViewModel
//
//
// private lateinit var binding: FragmentLoginPhoneBinding
//
// override fun inflateView(inflater: LayoutInflater?, container: ViewGroup?): View {
// binding = FragmentLoginPhoneBinding.inflate(inflater!!, container, false)
// loginViewModel = ViewModelProvider(requireActivity()).get(LoginViewModel::class.java)
// return binding.root
// }
// fun showKeyboard(editText: EditText?) {
// if (editText != null) {
// //设置可获得焦点
// editText.isFocusable = true
// editText.isFocusableInTouchMode = true
// //请求获得焦点
// editText.requestFocus()
// //调用系统输入法
// val inputManager: InputMethodManager =
// editText.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
// inputManager.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT)
// }
// }
//
// override 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) {
// popToBack()
// }
// })
// 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()
// }
// })
//
//
// }
//
// override fun onHiddenChanged(hidden: Boolean) {
//
// }
//
// override 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 {
// popToBack()
// }
//
// 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)
// }
// showKeyboard(binding.phoneEt)
// showKeyboard(binding.authCodeEt)
// }
//
// 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
...@@ -6,11 +6,10 @@ import android.view.ViewGroup ...@@ -6,11 +6,10 @@ import android.view.ViewGroup
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.ccwangluo.accelerator.databinding.FragmentSplashBinding import com.ccwangluo.accelerator.databinding.FragmentSplashBinding
import com.ccwangluo.accelerator.ui.BottomNavigationFragment import com.ccwangluo.accelerator.ui.BottomNavigationFragment
import com.ccwangluo.accelerator.utils.SysUtils import com.ccwangluo.accelerator.utils.AcceleratorUtils
import com.tencent.map.geolocation.TencentLocationManager import com.tencent.map.geolocation.TencentLocationManager
import com.xuexiang.xpage.annotation.Page import com.xuexiang.xpage.annotation.Page
import com.xuexiang.xpage.base.XPageFragment import com.xuexiang.xpage.base.XPageFragment
import com.xuexiang.xpage.core.PageOption
import com.xuexiang.xpage.utils.TitleBar import com.xuexiang.xpage.utils.TitleBar
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
...@@ -30,10 +29,14 @@ class SplashFragment : XPageFragment() { ...@@ -30,10 +29,14 @@ class SplashFragment : XPageFragment() {
} }
override fun initViews() { override fun initViews() {
AcceleratorUtils.getGameList(this) {
if (it) {
lifecycleScope.launch(Dispatchers.IO) { lifecycleScope.launch(Dispatchers.IO) {
delay(1000) delay(1000)
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
openPage(BottomNavigationFragment::class.java,false) openPage(BottomNavigationFragment::class.java, false)
}
}
} }
} }
TencentLocationManager.getInstance(context) TencentLocationManager.getInstance(context)
......
...@@ -19,9 +19,11 @@ class NewsCollectionAdapter(fragment: Fragment, val titles: Array<String>) : ...@@ -19,9 +19,11 @@ class NewsCollectionAdapter(fragment: Fragment, val titles: Array<String>) :
return fragment return fragment
} }
fun refresh(index:Int) { fun refresh(index: Int) {
if (index < list.size) {
list.get(index).refresh() list.get(index).refresh()
} }
}
companion object { companion object {
val ARG_OBJECT = "object" val ARG_OBJECT = "object"
......
...@@ -6,6 +6,7 @@ import android.view.View ...@@ -6,6 +6,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.fragment.app.viewModels
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
...@@ -23,6 +24,7 @@ import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard ...@@ -23,6 +24,7 @@ import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard
import com.ccwangluo.accelerator.model.NewsModel import com.ccwangluo.accelerator.model.NewsModel
import com.ccwangluo.accelerator.ui.view.RatingBar import com.ccwangluo.accelerator.ui.view.RatingBar
import com.ccwangluo.accelerator.ui.web.CommonWebViewFragment import com.ccwangluo.accelerator.ui.web.CommonWebViewFragment
import com.github.shadowsocks.http.HttpConfig
class NewsObjectFragment : XPageFragment() { class NewsObjectFragment : XPageFragment() {
...@@ -32,14 +34,16 @@ class NewsObjectFragment : XPageFragment() { ...@@ -32,14 +34,16 @@ class NewsObjectFragment : XPageFragment() {
return null return null
} }
private lateinit var newsViewModel: NewsViewModel private var newsViewModel: NewsObjectModel? = null
private lateinit var viewModel: NewsViewModel
private val dataList = arrayListOf<News>() private val dataList = arrayListOf<News>()
private var page = 1 private var page = 1
private lateinit var position: String private lateinit var position: String
private var newsModel: NewsModel? = null private var newsModel: NewsModel? = null
override fun inflateView(inflater: LayoutInflater?, container: ViewGroup?): View { override fun inflateView(inflater: LayoutInflater?, container: ViewGroup?): View {
newsViewModel = ViewModelProvider(this).get(NewsViewModel::class.java) viewModel = ViewModelProvider(requireActivity()).get(NewsViewModel::class.java)
newsViewModel = ViewModelProvider(this).get(NewsObjectModel::class.java)
return inflater!!.inflate(R.layout.fragment_collection_object, container, false) return inflater!!.inflate(R.layout.fragment_collection_object, container, false)
} }
...@@ -56,10 +60,19 @@ class NewsObjectFragment : XPageFragment() { ...@@ -56,10 +60,19 @@ class NewsObjectFragment : XPageFragment() {
.setLayoutId(R.layout.item_dynamic) .setLayoutId(R.layout.item_dynamic)
.addBindView { itemView, itemData -> .addBindView { itemView, itemData ->
val avatar = itemView.findViewById<ImageView>(R.id.avatar) val avatar = itemView.findViewById<ImageView>(R.id.avatar)
Glide.with(this@NewsObjectFragment).load(itemData.avatar).into(avatar) Glide.with(this@NewsObjectFragment)
itemView.findViewById<TextView>(R.id.nickname).setText(itemData.nickname) .load(if (itemData.type == 4) itemData.qAvatar else itemData.avatar)
.into(avatar)
itemView.findViewById<TextView>(R.id.nickname)
.setText(if (itemData.type == 4) itemData.qNickname else itemData.nickname)
itemView.findViewById<TextView>(R.id.createdDate) itemView.findViewById<TextView>(R.id.createdDate)
.setText(itemData.createdDate?.substring(0, 10)) .setText(
(if (itemData.type == 4) itemData.qCreatedDate else itemData.createdDate)?.substring(
0,
10
)
)
itemData.title?.let { itemData.title?.let {
itemView.findViewById<TextView>(R.id.title).visibility = View.VISIBLE itemView.findViewById<TextView>(R.id.title).visibility = View.VISIBLE
itemView.findViewById<TextView>(R.id.title).setText(it) itemView.findViewById<TextView>(R.id.title).setText(it)
...@@ -86,8 +99,11 @@ class NewsObjectFragment : XPageFragment() { ...@@ -86,8 +99,11 @@ class NewsObjectFragment : XPageFragment() {
vedio.setUp( vedio.setUp(
it, JCVideoPlayer.SCREEN_LAYOUT_LIST it, JCVideoPlayer.SCREEN_LAYOUT_LIST
) )
// Glide.with(this@NewsObjectFragment).load(url) itemData.videoImg?.let {
// .into(vedio.thumbImageView) Glide.with(this@NewsObjectFragment).load(it)
.into(vedio.thumbImageView)
}
} }
val star = itemView.findViewById<RatingBar>(R.id.star) val star = itemView.findViewById<RatingBar>(R.id.star)
itemData.star?.let { itemData.star?.let {
...@@ -104,7 +120,7 @@ class NewsObjectFragment : XPageFragment() { ...@@ -104,7 +120,7 @@ class NewsObjectFragment : XPageFragment() {
itemView.findViewById<TextView>(R.id.great_num).setText("${it}") itemView.findViewById<TextView>(R.id.great_num).setText("${it}")
} }
itemData.isGreat?.let { itemData.isGreat?.let {
if(it) { if (it) {
itemView.findViewById<ImageView>(R.id.great_img) itemView.findViewById<ImageView>(R.id.great_img)
.setBackgroundResource(R.mipmap.icon_praise_bu) .setBackgroundResource(R.mipmap.icon_praise_bu)
} else { } else {
...@@ -117,7 +133,7 @@ class NewsObjectFragment : XPageFragment() { ...@@ -117,7 +133,7 @@ class NewsObjectFragment : XPageFragment() {
if (it) { if (it) {
return@setOnClickListener return@setOnClickListener
} }
newsViewModel.greate(itemData.type, gameId, itemData.id,{ newsViewModel?.greate(itemData.type, gameId, itemData.id, {
itemData.isGreat = true itemData.isGreat = true
recycle_view?.adapter?.notifyDataSetChanged() recycle_view?.adapter?.notifyDataSetChanged()
}) })
...@@ -126,20 +142,16 @@ class NewsObjectFragment : XPageFragment() { ...@@ -126,20 +142,16 @@ class NewsObjectFragment : XPageFragment() {
itemView.setOnClickListener { itemView.setOnClickListener {
val params = Bundle() val params = Bundle()
params.putString(CommonWebViewFragment.WEBVIEW_URL_KEY, "/gameDetail?gameId=${gameId}&id=${itemData.id}") params.putString(
CommonWebViewFragment.WEBVIEW_URL_KEY, HttpConfig.UI_MAIN_URL +
"/gameDetail?gameId=${gameId}&id=${itemData.id}"
)
openPage(CommonWebViewFragment::class.java, params) openPage(CommonWebViewFragment::class.java, params)
} }
} }
.create() .create()
recycle_view?.adapter = adapter recycle_view?.adapter = adapter
AcceleratorUtils.getGameList(this@NewsObjectFragment) { refresh()
if (it) {
AcceleratorUtils.game?.let {
gameId = it.id
newsViewModel.freshData(position, it.id, page)
}
}
}
recycle_view?.addOnScrollListener(object : RecyclerView.OnScrollListener() { recycle_view?.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState) super.onScrollStateChanged(recyclerView, newState)
...@@ -151,7 +163,7 @@ class NewsObjectFragment : XPageFragment() { ...@@ -151,7 +163,7 @@ class NewsObjectFragment : XPageFragment() {
newsModel?.let { newsModel?.let {
if (dataList.size < it.total) { if (dataList.size < it.total) {
page++ page++
newsViewModel.freshData(position, gameId, page) newsViewModel?.freshData(position, gameId, page)
} }
} }
...@@ -159,10 +171,11 @@ class NewsObjectFragment : XPageFragment() { ...@@ -159,10 +171,11 @@ class NewsObjectFragment : XPageFragment() {
} }
}) })
} }
newsViewModel.newsModel.observe(this, { newsViewModel?.newsModel?.observe(this, {
newsModel = it newsModel = it
dataList.addAll(it.list) dataList.addAll(it.list)
recycle_view?.adapter?.notifyDataSetChanged() recycle_view?.adapter?.notifyDataSetChanged()
viewModel.isRefresh.postValue(true)
}) })
} }
...@@ -178,9 +191,10 @@ class NewsObjectFragment : XPageFragment() { ...@@ -178,9 +191,10 @@ class NewsObjectFragment : XPageFragment() {
fun refresh() { fun refresh() {
AcceleratorUtils.game?.let { AcceleratorUtils.game?.let {
dataList.clear()
gameId = it.id gameId = it.id
page = 1 page = 1
newsViewModel.freshData(position, it.id, page) newsViewModel?.freshData(position, it.id, page)
} }
} }
......
package com.ccwangluo.accelerator.ui.news
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.ccwangluo.accelerator.model.NewsModel
import com.ccwangluo.accelerator.utils.http.HttpGo
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
class NewsObjectModel : ViewModel() {
val newsModel = MutableLiveData<NewsModel>()
fun freshData(position: String, gameId: Int, page: Int) {
val type = when (position) {
"1" -> 1
"2" -> 2
"3" -> 5
"4" -> 4
else -> ""
}
viewModelScope.launch(Dispatchers.IO) {
val res =
HttpGo.getSync<NewsModel>("/api/new/all/list?gameId=$gameId&page=$page&size=10&type=$type")
res?.let {
if (it.code == 200) {
it.data?.let {
newsModel.postValue(it)
}
}
}
}
}
/**
* 点赞
*/
fun greate(type: Int?,parentId : Int, gameId: Int, callback: () -> Unit) {
val map = mutableMapOf<String, String>()
map.put("gameId", gameId.toString())
map.put("parentId",parentId.toString())
type?.let {
map.put("type", it.toString())
}
viewModelScope.launch(Dispatchers.IO) {
val res =
HttpGo.postSync<String>("/api/new/great", map)
res?.let {
if (it.code == 200) {
withContext(Dispatchers.Main) {
callback()
}
}
}
}
}
}
\ No newline at end of file
...@@ -21,6 +21,8 @@ import com.hjq.toast.ToastUtils ...@@ -21,6 +21,8 @@ import com.hjq.toast.ToastUtils
import java.lang.Exception import java.lang.Exception
import android.util.DisplayMetrics import android.util.DisplayMetrics
import com.ccwangluo.accelerator.utils.SysUtils import com.ccwangluo.accelerator.utils.SysUtils
import com.xuexiang.xutil.net.NetworkUtils
import java.util.*
/** /**
...@@ -63,7 +65,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb) ...@@ -63,7 +65,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
//打开系统设置 //打开系统设置
@JavascriptInterface @JavascriptInterface
fun openSysSetting() { fun openSysSetting() {
PermissionUtils.openAppSettings() NetworkUtils.openWirelessSettings()
} }
@JavascriptInterface @JavascriptInterface
...@@ -127,35 +129,38 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb) ...@@ -127,35 +129,38 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
@JavascriptInterface @JavascriptInterface
fun requirePermissionState(key: String, callback: String) { fun requirePermissionState(key: String, callback: String) {
xPageFragment.context?.let { xPageFragment.context?.let {
//获取权限 PermissionUtils.permission(key).rationale({
Dexter.withContext(it) PermissionUtils.openAppSettings()
.withPermissions(key) }).callback(object : PermissionUtils.FullCallback {
.withListener(object : MultiplePermissionsListener { override fun onGranted(permissionsGranted: MutableList<String>?) {
override fun onPermissionsChecked(p0: MultiplePermissionsReport?) { permissionsGranted?.forEach {
p0?.let { if (it.equals(key)) {
it.grantedPermissionResponses.forEach {
if (it.permissionName.equals(key)) {
agentWeb.getJsAccessEntrace() agentWeb.getJsAccessEntrace()
.quickCallJs(callback, key, "true") .quickCallJs(callback, key, "true")
} }
} }
it.deniedPermissionResponses.forEach {
if (it.permissionName.equals(key)) { }
override fun onDenied(
permissionsDeniedForever: MutableList<String>?,
permissionsDenied: MutableList<String>?
) {
permissionsDenied?.forEach {
if (it.equals(key)) {
agentWeb.getJsAccessEntrace() agentWeb.getJsAccessEntrace()
.quickCallJs(callback, key, "false") .quickCallJs(callback, key, "false")
} }
} }
permissionsDeniedForever?.forEach {
if (it.equals(key)) {
PermissionUtils.openAppSettings()
} }
} }
override fun onPermissionRationaleShouldBeShown(
p0: MutableList<PermissionRequest>?,
p1: PermissionToken?
) {
PermissionUtils.openAppSettings()
} }
}).check() }).request()
} }
} }
...@@ -165,7 +170,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb) ...@@ -165,7 +170,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
@JavascriptInterface @JavascriptInterface
fun getPackageState(packageName: String, callback: String) { fun getPackageState(packageName: String, callback: String) {
xPageFragment.context?.let { xPageFragment.context?.let {
val packageInstall = AppUtils.isInstallApp(packageName) val packageInstall = SysUtils.isPackageInstall(it, packageName)
agentWeb.getJsAccessEntrace() agentWeb.getJsAccessEntrace()
.quickCallJs(callback, packageName, packageInstall.toString()) .quickCallJs(callback, packageName, packageInstall.toString())
} }
...@@ -206,29 +211,21 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb) ...@@ -206,29 +211,21 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
* 调用 joinQQGroup(09Gg-vMtnaIfgr-slk1pOkjVIFmjI79U) * 调用 joinQQGroup(09Gg-vMtnaIfgr-slk1pOkjVIFmjI79U)
*/ */
@JavascriptInterface @JavascriptInterface
fun joinQQGroup(url: String) { fun joinQQGroup() {
val intent = Intent() xPageFragment.context?.let {
intent.data = SysUtils.joinQQGroup(it)
Uri.parse(url)
// 此Flag可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面 //
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
try {
xPageFragment.startActivity(intent)
} catch (e: Exception) {
// 未安装手Q或安装的版本不支持
ToastUtils.show("未安装手Q或安装的版本不支持")
} }
} }
/**
* 获取android版本号
*/
@JavascriptInterface @JavascriptInterface
fun getSystemVersion(callback: String) { fun getSystemVersion(callback: String) {
agentWeb.getJsAccessEntrace() agentWeb.getJsAccessEntrace()
.quickCallJs(callback, android.os.Build.VERSION.RELEASE) .quickCallJs(
callback,
android.os.Build.VERSION.RELEASE,
SysUtils.getDpi(xPageFragment).toString(),android.os.Build.VERSION.SDK_INT.toString()
)
} }
/** /**
...@@ -240,4 +237,10 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb) ...@@ -240,4 +237,10 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
.quickCallJs(callback, SysUtils.getDpi(xPageFragment).toString()) .quickCallJs(callback, SysUtils.getDpi(xPageFragment).toString())
} }
@JavascriptInterface
fun closeApp() {
LoginUtils.clearToken()
System.exit(0)
}
} }
\ No newline at end of file
...@@ -22,6 +22,7 @@ import com.github.shadowsocks.bg.BaseService ...@@ -22,6 +22,7 @@ import com.github.shadowsocks.bg.BaseService
import com.github.shadowsocks.database.Profile import com.github.shadowsocks.database.Profile
import com.github.shadowsocks.database.ProfileManager import com.github.shadowsocks.database.ProfileManager
import com.github.shadowsocks.http.LineConfig import com.github.shadowsocks.http.LineConfig
import com.github.shadowsocks.preference.DataStore
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
...@@ -70,7 +71,9 @@ object AcceleratorUtils { ...@@ -70,7 +71,9 @@ object AcceleratorUtils {
val res = HttpGo.getSync<Game>("/api/new/game/list?id=1&page=1&size=1") val res = HttpGo.getSync<Game>("/api/new/game/list?id=1&page=1&size=1")
res?.let { res?.let {
game = it.data?.list?.get(0) game = it.data?.list?.get(0)
withContext(Dispatchers.Main){
callback(true) callback(true)
}
game?.let { game?.let {
AuthManager.gameId = it.id.toString() AuthManager.gameId = it.id.toString()
} }
...@@ -84,40 +87,35 @@ object AcceleratorUtils { ...@@ -84,40 +87,35 @@ object AcceleratorUtils {
fun initConnect(context: AppCompatActivity, connect: ActivityResultLauncher<Void?>) { fun initConnect(context: AppCompatActivity, connect: ActivityResultLauncher<Void?>) {
this.context = context this.context = context
this.connect = connect this.connect = connect
if (SysUtils.isVpn(context) && state != BaseService.State.Connected){
CommonDialog(context).setTitle("VPN被挤占")
.setContent("请确保已关闭其他加速器,并未开起任何游戏空间等类似功能")
.setBtnLeft("取消", {
context.finish()
}).setBtnRight("我知道了", {
context.finish()
NetworkUtils.openWirelessSettings()
}).show<CommonDialog>()
return
}
connection.connect(context, shadowsocksConnection) connection.connect(context, shadowsocksConnection)
ProfileManager.ensureNotEmpty() ProfileManager.ensureNotEmpty()
context.lifecycleScope.launch(Dispatchers.IO) { context.lifecycleScope.launch(Dispatchers.IO) {
while (true) { while (true) {
game?.let { game?.let {
val net = SysUtils.getNetPing(it.boosterServerIp) val split = it.boosterServer.split(":")
println(net) var net = NetState(-1, -1, -1, "100")
if (state != BaseService.State.Connected) { net.delay = NetUtils.tcpPing(split[0], split[1].toInt()).toInt()
pre_net = net.delay pre_net = net.delay
acc_net = -1 if (state == BaseService.State.Connected) {
} else { val delay = NetUtils.tcpPing(split[0], split[1].toInt(),DataStore.portProxy).toInt()
acc_net = if (net.delay > pre_net) pre_net else net.delay acc_net = (delay * 0.5).toInt()
LoginUtils.getUserHasTimer { LoginUtils.getUserHasTimer {
if (!it) { //没有加速时长关闭服务 if (!it) { //没有加速时长关闭服务
stopAccelerator() stopAccelerator()
} }
} }
net.delay = if (net.delay < delay) net.delay else delay
} else {
acc_net = -1
} }
net.lossRate = if (net.delay == -1) "100" else "0"
net.preNetDelay = pre_net net.preNetDelay = pre_net
net.accNetDelay = acc_net net.accNetDelay = acc_net
withContext(Dispatchers.Main) {
stateListener(state, getAccTime(), net) stateListener(state, getAccTime(), net)
} }
delay(1000) }
delay(2000)
} }
} }
context.lifecycleScope.launch(Dispatchers.IO) { context.lifecycleScope.launch(Dispatchers.IO) {
...@@ -128,6 +126,23 @@ object AcceleratorUtils { ...@@ -128,6 +126,23 @@ object AcceleratorUtils {
} }
} }
fun checkVpn() {
if (AuthManager.Last_ACC_TIme == 0L || System.currentTimeMillis() - AuthManager.Last_ACC_TIme > 2 * 3600 * 1000){
return
}
if (SysUtils.isVpn(context) && state != BaseService.State.Connected) {
AuthManager.Last_ACC_TIme = 0L
CommonDialog(context).setTitle("VPN被挤占")
.setContent("请确保已关闭其他加速器,并未开起任何游戏空间等类似功能")
.setBtnLeft("取消", {
}).setBtnRight("我知道了", {
}).show<CommonDialog>()
return
}
}
fun startAccelerator(xPageFragment: XPageFragment) { fun startAccelerator(xPageFragment: XPageFragment) {
game?.let { game?.let {
initAuthProfile(xPageFragment) initAuthProfile(xPageFragment)
...@@ -155,6 +170,7 @@ object AcceleratorUtils { ...@@ -155,6 +170,7 @@ object AcceleratorUtils {
"com.YoStarJP.Arknights", "com.YoStarJP.Arknights",
"com.riotgames.league.wildrifttw", "com.riotgames.league.wildrifttw",
"com.baidu.browser.apps" "com.baidu.browser.apps"
) )
game?.boosterPackageName?.split(",")?.forEach { game?.boosterPackageName?.split(",")?.forEach {
if (!StringUtils.isEmpty(it)) { if (!StringUtils.isEmpty(it)) {
......
package com.ccwangluo.accelerator.utils package com.ccwangluo.accelerator.utils
import android.content.Context
import android.content.Intent import android.content.Intent
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.ccwangluo.accelerator.model.LoginRes import com.ccwangluo.accelerator.model.LoginRes
...@@ -9,7 +8,6 @@ import com.ccwangluo.accelerator.ui.login.PhoneLoginActivity ...@@ -9,7 +8,6 @@ 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.Core
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
...@@ -41,7 +39,7 @@ object LoginUtils { ...@@ -41,7 +39,7 @@ object LoginUtils {
userProfile = it userProfile = it
} }
} else { } else {
ToastUtils.show(it.error) // ToastUtils.show(it.error)
} }
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
callBack(userProfile) callBack(userProfile)
...@@ -51,15 +49,10 @@ object LoginUtils { ...@@ -51,15 +49,10 @@ object LoginUtils {
} }
fun getUserHasTimer(xPageFragment: XPageFragment, callBack: (Boolean) -> Unit) { fun getUserHasTimer(xPageFragment: XPageFragment, callBack: (Boolean) -> Unit) {
userProfile?.let {
val dateToStamp = TimeUtils.dateToStamp(it.vipExpireTime) + 24 * 60 * 60 * 1000
// && it.vipExpireTime > System.currentTimeMillis()
callBack(it.vip && dateToStamp > System.currentTimeMillis())
return
}
getUserProfile(xPageFragment) { getUserProfile(xPageFragment) {
it?.let { it?.let {
callBack(true) val dateToStamp = TimeUtils.dateToStamp(it.vipExpireTime) + 24 * 60 * 60 * 1000
callBack(it.vip && dateToStamp > System.currentTimeMillis())
} ?: let { } ?: let {
callBack(false) callBack(false)
} }
...@@ -82,15 +75,18 @@ object LoginUtils { ...@@ -82,15 +75,18 @@ object LoginUtils {
timerCallBack = {} timerCallBack = {}
} }
var _phone = ""
fun startTimer() { fun startTimer(phone: String) {
_phone = phone
timeNumber = 60
timer?.cancel() timer?.cancel()
timerTask = object : TimerTask() { timerTask = object : TimerTask() {
override fun run() { override fun run() {
timeNumber-- timeNumber--
timerCallBack(timeNumber) timerCallBack(timeNumber)
if (timeNumber == 0) { if (timeNumber <= 0) {
timer?.cancel() timer?.cancel()
_phone = ""
} }
} }
} }
...@@ -98,6 +94,11 @@ object LoginUtils { ...@@ -98,6 +94,11 @@ object LoginUtils {
timer?.schedule(timerTask, 0, 1000); timer?.schedule(timerTask, 0, 1000);
} }
fun stopTimer(){
_phone = ""
timer?.cancel()
}
fun login(xPageFragment: XPageFragment, callBack: (Boolean) -> Unit) { fun login(xPageFragment: XPageFragment, callBack: (Boolean) -> Unit) {
PhoneUtils.openLoginAuth(xPageFragment) { b, s -> PhoneUtils.openLoginAuth(xPageFragment) { b, s ->
if (b) { if (b) {
...@@ -108,9 +109,9 @@ object LoginUtils { ...@@ -108,9 +109,9 @@ object LoginUtils {
res?.let { res?.let {
if (it.code == 200) { if (it.code == 200) {
token = it.data?.token token = it.data?.token
withContext(Dispatchers.Main) {
ToastUtils.show("登录成功") ToastUtils.show("登录成功")
OneKeyLoginManager.getInstance().finishAuthActivity() OneKeyLoginManager.getInstance().finishAuthActivity()
withContext(Dispatchers.Main) {
callBack(true) callBack(true)
} }
} else { } else {
......
...@@ -49,8 +49,6 @@ object PhoneUtils { ...@@ -49,8 +49,6 @@ object PhoneUtils {
} }
} }
fun openLoginAuth(xPageFragment: XPageFragment, callback: (Boolean, String) -> Unit) { fun openLoginAuth(xPageFragment: XPageFragment, callback: (Boolean, String) -> Unit) {
xPageFragment.context?.let { xPageFragment.context?.let {
OneKeyLoginManager.getInstance().setAuthThemeConfig(getEConfig(it, xPageFragment)) OneKeyLoginManager.getInstance().setAuthThemeConfig(getEConfig(it, xPageFragment))
......
...@@ -2,9 +2,6 @@ package com.ccwangluo.accelerator.utils ...@@ -2,9 +2,6 @@ package com.ccwangluo.accelerator.utils
import android.content.Context import android.content.Context
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.net.ConnectivityManager
import android.net.Network
import android.net.Proxy
import android.os.Build import android.os.Build
import android.text.TextUtils import android.text.TextUtils
import android.util.DisplayMetrics import android.util.DisplayMetrics
...@@ -16,9 +13,11 @@ import java.io.InputStreamReader ...@@ -16,9 +13,11 @@ import java.io.InputStreamReader
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
import android.net.NetworkCapabilities import android.app.DownloadManager
import android.content.Intent
import android.net.*
import com.hjq.toast.ToastUtils
import java.lang.Exception
object SysUtils { object SysUtils {
...@@ -28,7 +27,7 @@ object SysUtils { ...@@ -28,7 +27,7 @@ object SysUtils {
} }
fun getActiveNet(): String { fun getActiveNet(): String {
when(NetworkUtils.getNetStateType()){ when (NetworkUtils.getNetStateType()) {
NetworkUtils.NetState.NET_WIFI -> return "WIFI" NetworkUtils.NetState.NET_WIFI -> return "WIFI"
NetworkUtils.NetState.NET_5G -> return "5G" NetworkUtils.NetState.NET_5G -> return "5G"
NetworkUtils.NetState.NET_4G -> return "4G" NetworkUtils.NetState.NET_4G -> return "4G"
...@@ -73,7 +72,8 @@ object SysUtils { ...@@ -73,7 +72,8 @@ object SysUtils {
* 判断设备 是否使用代理上网 * 判断设备 是否使用代理上网
* */ * */
fun isVpn(context: Context): Boolean { fun isVpn(context: Context): Boolean {
val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager val connectivityManager =
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val activeNetwork = connectivityManager?.getActiveNetwork() val activeNetwork = connectivityManager?.getActiveNetwork()
val caps = connectivityManager.getNetworkCapabilities(activeNetwork) val caps = connectivityManager.getNetworkCapabilities(activeNetwork)
caps?.hasTransport(NetworkCapabilities.TRANSPORT_VPN)?.let { caps?.hasTransport(NetworkCapabilities.TRANSPORT_VPN)?.let {
...@@ -124,7 +124,26 @@ object SysUtils { ...@@ -124,7 +124,26 @@ object SysUtils {
fun getDpi(xPageFragment: XPageFragment): Float { fun getDpi(xPageFragment: XPageFragment): Float {
val dm = DisplayMetrics() val dm = DisplayMetrics()
xPageFragment.activity?.windowManager?.getDefaultDisplay()?.getMetrics(dm) xPageFragment.activity?.windowManager?.getDefaultDisplay()?.getMetrics(dm)
return (dm.density*160) return (dm.density * 160)
}
fun downloadFile(context: Context, url: String) {
val request = DownloadManager.Request(Uri.parse(url))
request.setDestinationInExternalPublicDir("", url.substring(url.lastIndexOf("/") + 1))
val downloadManager = context.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
downloadManager.enqueue(request)
} }
fun joinQQGroup(context: Context) {
val key = "388Tnjzn_jkY7SNKO1ACI6PL5gbhpeYR"
val intent = Intent()
intent.data =
Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26jump_from%3Dwebapi%26k%3D$key")
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
try {
context.startActivity(intent)
} catch (e: Exception) {
ToastUtils.show("没有安装qq")
}
}
} }
\ No newline at end of file
...@@ -51,19 +51,20 @@ object HttpGo { ...@@ -51,19 +51,20 @@ object HttpGo {
LoginUtils.token?.let { LoginUtils.token?.let {
request.addHeader("Authorization", it) request.addHeader("Authorization", it)
} }
Timber.i(request.toString()) Timber.i("%s%s", url, request.toString())
val call = okHttpClient.newCall(request.build()) val call = okHttpClient.newCall(request.build())
val response: Response = call.execute() val response: Response = call.execute()
if (response.isSuccessful) { if (response.isSuccessful) {
val type = object : TypeToken<BaseModel<T>>() {}.type val type = object : TypeToken<BaseModel<T>>() {}.type
val string = response.body?.string() val string = response.body?.string()
Timber.i(string.toString()) Timber.i("%s%s", url, string.toString())
return gson.fromJson(string, type) return gson.fromJson(string, type)
} else { } else {
ToastUtils.show("网络错误") ToastUtils.show("网络错误")
} }
} catch (e: java.lang.Exception) { } catch (e: java.lang.Exception) {
ToastUtils.show("网络错误") ToastUtils.show("网络错误")
} }
return null return null
} }
......
...@@ -10,12 +10,13 @@ ...@@ -10,12 +10,13 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:paddingTop="1.5dp"
android:id="@+id/btn_back"
android:layout_width="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_marginTop="41.5dp" android:layout_marginTop="40dp"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<ImageView <ImageView
android:id="@+id/btn_back"
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_width="10dp" android:layout_width="10dp"
android:layout_height="17dp" android:layout_height="17dp"
...@@ -156,8 +157,10 @@ ...@@ -156,8 +157,10 @@
<CheckBox <CheckBox
android:id="@+id/cb_protocol" android:id="@+id/cb_protocol"
android:layout_width="14dp" android:padding="5dp"
android:layout_height="14dp" android:gravity="center"
android:layout_width="20dp"
android:layout_height="20dp"
style="@style/btn_checkbox" style="@style/btn_checkbox"
/> />
......
...@@ -3,11 +3,13 @@ ...@@ -3,11 +3,13 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/refresh_news" android:id="@+id/refresh_news"
android:paddingTop="30dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/white"> android:background="@color/black">
<androidx.coordinatorlayout.widget.CoordinatorLayout <androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
...@@ -19,18 +21,30 @@ ...@@ -19,18 +21,30 @@
android:background="@color/white" android:background="@color/white"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collap"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="@color/white"
app:layout_scrollFlags="snap|scroll|exitUntilCollapsed">
<LinearLayout
app:layout_collapseMode="parallax"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@mipmap/new_top" android:background="@mipmap/new_top"
android:gravity="center" android:gravity="center"
android:paddingTop="36dp" android:paddingTop="6dp"
android:paddingBottom="16dp" android:paddingBottom="16dp"
android:text="地下城与勇士 韩服" android:text="地下城与勇士 韩服"
android:textColor="#FFFFFFFF" android:textColor="#FFFFFFFF"
android:textSize="16sp" android:textSize="16sp" />
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|exitUntilCollapsed" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/game_news_list" android:id="@+id/game_news_list"
...@@ -38,9 +52,7 @@ ...@@ -38,9 +52,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="21dp" android:layout_marginTop="21dp"
android:background="@color/white" android:background="@color/white"
android:orientation="horizontal" android:orientation="horizontal">
app:layout_collapseMode="parallax"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
</androidx.recyclerview.widget.RecyclerView> </androidx.recyclerview.widget.RecyclerView>
...@@ -51,9 +63,7 @@ ...@@ -51,9 +63,7 @@
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginTop="21dp" android:layout_marginTop="21dp"
android:layout_marginRight="20dp" android:layout_marginRight="20dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp">
app:layout_collapseMode="parallax"
app:layout_scrollFlags="noScroll">
<ImageView <ImageView
android:layout_width="17.95dp" android:layout_width="17.95dp"
...@@ -74,13 +84,16 @@ ...@@ -74,13 +84,16 @@
app:mtv_isAutoFit="true" /> app:mtv_isAutoFit="true" />
</LinearLayout> </LinearLayout>
</LinearLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<androidx.appcompat.widget.LinearLayoutCompat <androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical" android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"> app:layout_behavior="@string/appbar_scrolling_view_behavior">
......
...@@ -46,6 +46,12 @@ ...@@ -46,6 +46,12 @@
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="58.5dp"> android:layout_marginEnd="58.5dp">
<ImageView
android:layout_width="19dp"
android:layout_height="20dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:background="@mipmap/message" />
<com.xuexiang.xui.widget.button.roundbutton.RoundButton <com.xuexiang.xui.widget.button.roundbutton.RoundButton
android:id="@+id/icon_notice_badge" android:id="@+id/icon_notice_badge"
...@@ -56,12 +62,6 @@ ...@@ -56,12 +62,6 @@
app:rb_backgroundColor="@color/red" app:rb_backgroundColor="@color/red"
app:rb_radius="4dp" /> app:rb_radius="4dp" />
<ImageView
android:layout_width="19dp"
android:layout_height="20dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:background="@mipmap/message" />
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
...@@ -262,8 +262,8 @@ ...@@ -262,8 +262,8 @@
<ImageView <ImageView
android:id="@+id/btn_expend_bg" android:id="@+id/btn_expend_bg"
android:layout_width="22dp" android:layout_width="wrap_content"
android:layout_height="11dp" android:layout_height="wrap_content"
android:layout_centerInParent="true" android:layout_centerInParent="true"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:background="@mipmap/quick_arrow_up" /> android:background="@mipmap/quick_arrow_up" />
...@@ -280,7 +280,7 @@ ...@@ -280,7 +280,7 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="433dp"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
...@@ -522,7 +522,7 @@ ...@@ -522,7 +522,7 @@
<com.xuexiang.xui.widget.layout.XUILinearLayout <com.xuexiang.xui.widget.layout.XUILinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="201dp"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:layout_marginRight="10dp" android:layout_marginRight="10dp"
...@@ -641,7 +641,7 @@ ...@@ -641,7 +641,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:layout_marginBottom="24dp" android:layout_marginBottom="15dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal">
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="@color/white" android:background="@color/white"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16.5dp" android:layout_marginTop="16.5dp"
...@@ -50,6 +50,8 @@ ...@@ -50,6 +50,8 @@
</LinearLayout> </LinearLayout>
<com.ccwangluo.accelerator.ui.view.RatingBar <com.ccwangluo.accelerator.ui.view.RatingBar
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:id="@+id/star" android:id="@+id/star"
android:visibility="gone" android:visibility="gone"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
...@@ -64,6 +66,8 @@ ...@@ -64,6 +66,8 @@
app:starStep="0" app:starStep="0"
app:stepSize="Half"/> app:stepSize="Half"/>
<TextView <TextView
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:id="@+id/title" android:id="@+id/title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -74,6 +78,8 @@ ...@@ -74,6 +78,8 @@
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:id="@+id/abbrContent" android:id="@+id/abbrContent"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -84,6 +90,8 @@ ...@@ -84,6 +90,8 @@
android:textSize="14sp" /> android:textSize="14sp" />
<ImageView <ImageView
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:id="@+id/imgs" android:id="@+id/imgs"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="182.5dp" android:layout_height="182.5dp"
...@@ -92,6 +100,8 @@ ...@@ -92,6 +100,8 @@
android:visibility="gone" /> android:visibility="gone" />
<fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard <fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:id="@+id/video_view" android:id="@+id/video_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="182.5dp" android:layout_height="182.5dp"
...@@ -100,6 +110,8 @@ ...@@ -100,6 +110,8 @@
<RelativeLayout <RelativeLayout
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="11dp" android:layout_marginTop="11dp"
...@@ -132,6 +144,10 @@ ...@@ -132,6 +144,10 @@
android:background="@mipmap/icon_praise_ga" /> android:background="@mipmap/icon_praise_ga" />
</RelativeLayout> </RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="#FFEFEFF4"
/>
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -5,16 +5,17 @@ ...@@ -5,16 +5,17 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:orientation="vertical"> android:orientation="vertical">
<ImageView <ImageView
android:id="@+id/plugin_img"
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:background="@mipmap/game_download" /> android:background="@mipmap/game_download" />
<TextView <TextView
android:id="@+id/plugin_name"
android:layout_width="70dp" android:layout_width="70dp"
android:layout_height="20dp" android:layout_height="20dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
......
...@@ -27,6 +27,7 @@ import android.content.ServiceConnection ...@@ -27,6 +27,7 @@ import android.content.ServiceConnection
import android.os.IBinder import android.os.IBinder
import android.os.RemoteException import android.os.RemoteException
import com.github.shadowsocks.bg.AuthManager.ACC_TIME import com.github.shadowsocks.bg.AuthManager.ACC_TIME
import com.github.shadowsocks.bg.AuthManager.Last_ACC_TIme
import com.github.shadowsocks.bg.BaseService import com.github.shadowsocks.bg.BaseService
import com.github.shadowsocks.bg.VpnService import com.github.shadowsocks.bg.VpnService
import com.github.shadowsocks.utils.Action import com.github.shadowsocks.utils.Action
...@@ -73,6 +74,7 @@ class ShadowsocksConnection(private var listenForDeath: Boolean = false) : Servi ...@@ -73,6 +74,7 @@ class ShadowsocksConnection(private var listenForDeath: Boolean = false) : Servi
ACC_TIME = System.currentTimeMillis() ACC_TIME = System.currentTimeMillis()
} else { } else {
ACC_TIME = 0L ACC_TIME = 0L
Last_ACC_TIme = System.currentTimeMillis()
} }
} }
} }
......
...@@ -2,19 +2,16 @@ package com.github.shadowsocks.bg ...@@ -2,19 +2,16 @@ package com.github.shadowsocks.bg
import android.os.Build import android.os.Build
import com.github.shadowsocks.Core import com.github.shadowsocks.Core
import com.github.shadowsocks.http.HttpConfig
import com.github.shadowsocks.acl.Acl
import com.github.shadowsocks.database.Profile import com.github.shadowsocks.database.Profile
import com.github.shadowsocks.database.ProfileManager import com.github.shadowsocks.database.ProfileManager
import com.github.shadowsocks.http.FreshToken import com.github.shadowsocks.http.FreshToken
import com.github.shadowsocks.http.HttpConfig
import com.github.shadowsocks.http.LineConfig import com.github.shadowsocks.http.LineConfig
import com.google.gson.Gson import com.google.gson.Gson
import com.google.gson.JsonStreamParser import com.google.gson.JsonStreamParser
import com.google.gson.reflect.TypeToken import com.google.gson.reflect.TypeToken
import com.tencent.mmkv.MMKV import com.tencent.mmkv.MMKV
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
...@@ -80,18 +77,22 @@ object AuthManager { ...@@ -80,18 +77,22 @@ object AuthManager {
MMKV.defaultMMKV().putLong("ACC_TIME", acc_time) MMKV.defaultMMKV().putLong("ACC_TIME", acc_time)
} }
suspend fun initAuthProfile() { var Last_ACC_TIme:Long
get() = MMKV.defaultMMKV().decodeLong("LAST_ACC_TIME", 0L)
set(last_acc_time) {
MMKV.defaultMMKV().putLong("LAST_ACC_TIME", last_acc_time)
}
suspend fun initAuthProfile(profile: Profile) {
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
getLineConfig()?.let { getLineConfig()?.let {
if (it.code != 200) { if (it.code != 200) {
return@withContext return@withContext
} }
val profileId = 1L
val profile = ProfileManager.getProfile(profileId) ?: Profile()
profile.host = it.data.host profile.host = it.data.host
profile.token = it.data.token profile.token = it.data.token
profile.remotePort = it.data.port profile.remotePort = it.data.port
Timber.d("start vpn with games: ${profile.individual}") Timber.d("start vpn with games: ${profile.individual}, profileId: ${profile.id}, route: ${profile.route}")
ProfileManager.updateProfile(profile) ProfileManager.updateProfile(profile)
} }
} }
...@@ -101,7 +102,7 @@ object AuthManager { ...@@ -101,7 +102,7 @@ object AuthManager {
if (data.state != BaseService.State.Connected) { if (data.state != BaseService.State.Connected) {
return return
} }
scheduleAtFixedRate?.cancel(false)
scheduleAtFixedRate = executor.scheduleAtFixedRate({ scheduleAtFixedRate = executor.scheduleAtFixedRate({
val context = val context =
if (Build.VERSION.SDK_INT < 24 || Core.user.isUserUnlocked) Core.app else Core.deviceStorage if (Build.VERSION.SDK_INT < 24 || Core.user.isUserUnlocked) Core.app else Core.deviceStorage
...@@ -110,13 +111,13 @@ object AuthManager { ...@@ -110,13 +111,13 @@ object AuthManager {
.single().asJsonObject .single().asJsonObject
if (data.state == BaseService.State.Connected) { if (data.state == BaseService.State.Connected) {
data.proxy?.let { proxyInstance ->
getToken()?.let { getToken(proxyInstance.profile.token ?: "")?.let {
if (it.code == 200) { if (it.code == 200) {
proxyInstance.profile.token = it.data.token
configJson.addProperty("token", it.data.token) configJson.addProperty("token", it.data.token)
configFile.writeText(configJson.toString()) configFile.writeText(configJson.toString())
} else { }
Core.stopService()
} }
} }
} }
...@@ -124,19 +125,15 @@ object AuthManager { ...@@ -124,19 +125,15 @@ object AuthManager {
}, 1, 1, TimeUnit.MINUTES) }, 1, 1, TimeUnit.MINUTES)
} }
fun getToken(): FreshToken? { fun getToken(token: String): FreshToken? {
ProfileManager.getProfile(1L)?.let { val map = mapOf(Pair("token", token))
val map = mutableMapOf<String, String>()
it.token?.let { it1 -> map.put("token", it1) }
return postSync<FreshToken>("/api/acc/line/refresh", map) return postSync<FreshToken>("/api/acc/line/refresh", map)
} }
return null
}
val jsonType get() = "application/json; charset=utf-8".toMediaTypeOrNull() val jsonType get() = "application/json; charset=utf-8".toMediaTypeOrNull()
fun getLineConfig( private fun getLineConfig(
): LineConfig? { ): LineConfig? {
val map = mutableMapOf<String, String>() val map = mutableMapOf<String, String>()
area?.let { map.put("area", it) } area?.let { map.put("area", it) }
......
...@@ -348,7 +348,7 @@ object BaseService { ...@@ -348,7 +348,7 @@ object BaseService {
try { try {
Executable.killAll() // clean up old processes Executable.killAll() // clean up old processes
preInit() preInit()
AuthManager.initAuthProfile() AuthManager.initAuthProfile(profile)
if (profile.route == Acl.CUSTOM_RULES) try { if (profile.route == Acl.CUSTOM_RULES) try {
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
Acl.customRules.flatten(10, this@Interface::openConnection).also { Acl.customRules.flatten(10, this@Interface::openConnection).also {
......
...@@ -129,7 +129,7 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro ...@@ -129,7 +129,7 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
} }
fun scheduleUpdate() { fun scheduleUpdate() {
if (route !in arrayOf(Acl.ALL, Acl.CUSTOM_RULES)) AclSyncer.schedule(route) if (route !in arrayOf(Acl.ALL, Acl.CUSTOM_RULES, Acl.BYPASS_LAN)) AclSyncer.schedule(route)
} }
fun shutdown(scope: CoroutineScope) { fun shutdown(scope: CoroutineScope) {
......
...@@ -185,7 +185,7 @@ class VpnService : BaseVpnService(), BaseService.Interface { ...@@ -185,7 +185,7 @@ class VpnService : BaseVpnService(), BaseService.Interface {
Timber.w(ex) Timber.w(ex)
} }
} }
if (!profile.bypass) builder.addAllowedApplication(me) // if (!profile.bypass) builder.addAllowedApplication(me)
} }
when (profile.route) { when (profile.route) {
......
...@@ -3,21 +3,22 @@ package com.github.shadowsocks.http ...@@ -3,21 +3,22 @@ package com.github.shadowsocks.http
object HttpConfig { object HttpConfig {
//app后端 //app后端
val baseUrl = "https://test-cc-tt-api.orangenet.org.cn" val baseUrl = "https://test-cc-tt-api.orangenet.org.cn" //测试
// val baseUrl = "https://cc-tt-front.srccwl.com" //生产
/** /**
* 主页h5 * 主页h5
*/ */
// val UI_MAIN_URL = "https://test-cc-tt-front.orangenet.org.cn/#" val UI_MAIN_URL = "https://test-cc-tt-front.orangenet.org.cn/#" //测试
val UI_MAIN_URL = "http://10.3.0.217:8080/#" // val UI_MAIN_URL = "http://10.3.0.217:8080/#"
// val UI_MAIN_URL = "https://cc-tt-front.srccwl.com/#" //生产
//隐私协议地址 //隐私协议地址
val privacy_url = "http:wwww.baidu.com" val privacy_url = "http:wwww.baidu.com"
val UI_MESSAGE_URL = "/message" val UI_MESSAGE_URL = "/message"
val UI_GAME_URL = "/game" val UI_GAME_URL = "/game"
val UI_SETTING_URL = "/setting" val UI_SETTING_URL = "/setting"
......
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