Commit a9f96c77 authored by liusheng's avatar liusheng

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

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