Commit 09b15c01 authored by sheteng's avatar sheteng

加速器测试1

parent e7c222d9
......@@ -115,4 +115,7 @@ dependencies {
//gps
implementation ("com.tencent.map.geolocation:TencentLocationSdk-openplatform:7.3.0")
implementation("com.github.bumptech.glide:glide:4.11.0")
annotationProcessor("com.github.bumptech.glide:compiler:4.11.0")
}
\ No newline at end of file
......@@ -18,10 +18,12 @@
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- 支持A-GPS辅助定位 -->
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <!-- 用于 log 日志 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<queries>
<package android:name="com.tencent.mm" />
<package android:name="com.tencent.mobileqq" />
<package android:name="com.baidu.browser.apps" />
</queries>
<application
......@@ -42,8 +44,8 @@
<activity
android:name=".ui.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible|adjustPan">
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......
package com.ccwangluo.accelerator.model
data class NewsRes(
data class News (
val abbrContent: String?,
val avatar: String?,
val content: String?,
val createdDate: String?,
val greatNum: Int?,
val id: Int?,
val imgs: String?,
val nickname: String?,
val pageViews: Int?,
val title: String?,
val video: String?,
val videoName: String?
val type: Int,
val videoUrl: String?
)
\ No newline at end of file
package com.ccwangluo.accelerator.model
data class NewsModel(
val list: List<News>,
val total: Int
)
\ No newline at end of file
......@@ -54,8 +54,7 @@ class BottomNavigationFragment : XPageFragment(), ViewPager.OnPageChangeListener
adapter.addFragment(fragments[2], titles[2])
binding.viewPager.setOffscreenPageLimit(titles.size - 1);
binding.viewPager.adapter = adapter
// binding.viewPager
binding.viewPager.setNoScroll(true)
AcceleratorUtils.getGameList(this,{})
}
......
......@@ -25,6 +25,7 @@ import com.hjq.toast.ToastUtils
import com.xuexiang.xpage.base.XPageFragment
import com.xuexiang.xpage.utils.TitleBar
import com.xuexiang.xui.utils.ViewUtils
import com.xuexiang.xui.widget.progress.CircleProgressView
import com.xuexiang.xutil.app.AppUtils
class AccelertorFragment : XPageFragment() {
......@@ -46,6 +47,8 @@ class AccelertorFragment : XPageFragment() {
return binding.root
}
var isStartAcc = false
override fun initViews() {
accelertorViewModel.netState.observe(this, {
if (it.preNetDelay != -1) { //有网络
......@@ -99,11 +102,11 @@ class AccelertorFragment : XPageFragment() {
freshData(it)
}
if (SettingSPUtils.isSmartAccOpen) {
binding.smartAccOpen.setText("已开启 >")
binding.smartAccOpen.setText("已开启")
binding.smartAccOpen.setTextColor(resources.getColor(R.color.open_acc_enable))
binding.smartAccOpenArea.visibility = View.GONE
} else {
binding.smartAccOpen.setText("未开启 ")
binding.smartAccOpen.setText("未开启 >")
binding.smartAccOpen.setTextColor(resources.getColor(R.color.white))
binding.smartAccOpenArea.visibility = View.VISIBLE
}
......@@ -116,7 +119,30 @@ class AccelertorFragment : XPageFragment() {
binding.iconNoticeBadge.visibility = View.GONE
}
})
binding.progressViewCircleSmall.setProgressTextVisibility(false)
binding.progressViewCircleSmall.setProgressViewUpdateListener(object :
CircleProgressView.CircleProgressUpdateListener {
override fun onCircleProgressStart(view: View?) {
binding.progressArea.visibility = View.VISIBLE
}
override fun onCircleProgressUpdate(view: View?, progress: Float) {
binding.progress.setText(progress.toInt().toString())
}
override fun onCircleProgressFinished(view: View?) {
binding.progressArea.visibility = View.GONE
binding.btnQuick.isEnabled = true
binding.progressViewCircleSmall.progress = 0F
isStartAcc = true
AcceleratorUtils.startAccelerator(this@AccelertorFragment)
}
})
if (binding.gamePicOut.background is AnimationDrawable) {
(binding.gamePicOut.background as AnimationDrawable).start()
binding.gamePicOut.startAnimation(getDefaultAnim())
}
}
......@@ -142,10 +168,10 @@ class AccelertorFragment : XPageFragment() {
}
binding.preventAccLost.setOnClickListener {
openToWebview(HttpConfig.UI_QUESTION_URL)
openToWebview(HttpConfig.UI_SPEED_URL + "?id=1")
}
binding.preventAccInvalid.setOnClickListener {
openToWebview(HttpConfig.UI_SPEED_URL)
openToWebview(HttpConfig.UI_SPEED_URL + "?id=2")
}
binding.btnExpend.setOnClickListener {
......@@ -189,7 +215,7 @@ class AccelertorFragment : XPageFragment() {
if (it) {
//
AcceleratorUtils.game?.let {
if (!AppUtils.isInstallApp(it.packageName)) {
if (!SysUtils.isPackageInstall(requireContext(), it.packageName)) {
binding.quickTopToast.visibility = View.VISIBLE
binding.quickTopToastTx.setText("请先安装游戏后加速")
binding.quickTopToastTx.postDelayed({
......@@ -199,13 +225,12 @@ class AccelertorFragment : XPageFragment() {
}
}
//用户是否有使用时长
LoginUtils.getUserHasTimer(this) {
LoginUtils.getUserHasTimer(this@AccelertorFragment) {
if (it) {
binding.btnQuick.isEnabled = false
AcceleratorUtils.startAccelerator(this)
startAnim()
} else {
MemberDialog(this).show<MemberDialog>()
MemberDialog(this@AccelertorFragment).show<MemberDialog>()
}
}
} else {
......@@ -229,8 +254,6 @@ class AccelertorFragment : XPageFragment() {
}
})
}
}
override fun onResume() {
......@@ -246,14 +269,11 @@ class AccelertorFragment : XPageFragment() {
fun freshData(state: BaseService.State) {
if (state == BaseService.State.Connected) {
stopAnim()
binding.gamePicIn1.startAnimation(getDefaultAnim())
binding.progressViewCircleSmall.progress = 100F
binding.accStateTx.visibility = View.VISIBLE
binding.btnQuick.setBackgroundResource(R.mipmap.quick_stop)
if (binding.gamePicOut.background is AnimationDrawable) {
(binding.gamePicOut.background as AnimationDrawable).stop()
binding.gamePicOut.clearAnimation()
}
if (SettingSPUtils.isFirstAccSuccess) {
CommonDialog(this).setTitle("防止加速掉线")
......@@ -263,16 +283,12 @@ class AccelertorFragment : XPageFragment() {
}).show<CommonDialog>()
SettingSPUtils.isFirstAccSuccess = false
}
} else if (state == BaseService.State.Stopped) {
} else {
binding.gamePicIn1.clearAnimation()
if (binding.gamePicOut.background is AnimationDrawable) {
(binding.gamePicOut.background as AnimationDrawable).start()
binding.gamePicOut.startAnimation(getDefaultAnim())
}
binding.gamePicIn1.clearAnimation()
stopAnim()
binding.accStateTx.visibility = View.GONE
binding.progressViewCircleSmall.progress = 0F
binding.btnQuick.setBackgroundResource(R.mipmap.quick_start)
}
}
......@@ -292,14 +308,7 @@ class AccelertorFragment : XPageFragment() {
AcceleratorUtils.unRegisterStateListener()
}
fun stopAnim() {
binding.btnQuick.isEnabled = true
binding.progressViewCircleSmall.stopProgressAnimation()
binding.progressViewCircleSmall.setProgressTextVisibility(false)
}
fun startAnim() {
binding.progressViewCircleSmall.setProgressTextVisibility(true)
binding.progressViewCircleSmall.startProgressAnimation()
}
......
......@@ -17,7 +17,5 @@ class AccelertorViewModel : ViewModel() {
//用户状态
var userProfile = MutableLiveData<UserProfile>()
//加速配置
// var gameConfig = MutableLiveData<GameConfig>()
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ import android.view.ViewGroup
import androidx.lifecycle.ViewModelProvider
import com.ccwangluo.accelerator.R
import com.ccwangluo.accelerator.databinding.FragmentNewsBinding
import com.ccwangluo.accelerator.ui.news.DemoCollectionAdapter
import com.ccwangluo.accelerator.ui.news.NewsCollectionAdapter
import com.google.android.material.tabs.TabLayoutMediator
import com.xuexiang.xpage.base.XPageFragment
import com.xuexiang.xpage.utils.TitleBar
......@@ -27,7 +27,7 @@ class NewsFragment : XPageFragment() {
}
val titles = arrayOf("全部", "攻略", "视频", "评价", "问答")
var adapter: DemoCollectionAdapter? = null
var adapter: NewsCollectionAdapter? = null
override fun initViews() {
newsViewModel.refreshState.observe(this, {
if (!it) {
......@@ -38,7 +38,7 @@ class NewsFragment : XPageFragment() {
binding.tvMarquee.addDisplayString("【公告】韩服 DNF已经开启预约啦,小伙伴…")
binding.tvMarquee.startRoll()
adapter = DemoCollectionAdapter(this, titles)
adapter = NewsCollectionAdapter(this, titles)
binding.viewPager.adapter = adapter
TabLayoutMediator(binding.tabLayout, binding.viewPager) { tab, position ->
tab.setCustomView(R.layout.item_tab)
......
......@@ -2,13 +2,39 @@ 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.utils.http.HttpGo
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class NewsViewModel : ViewModel() {
/**
* 刷新状态
*/
val refreshState = MutableLiveData<Boolean>()
val newsModel = MutableLiveData<NewsModel>()
fun freshData(position: String, gameId: Int, page: Int) {
val type = when (position) {
"0" -> ""
"1" -> "0"
"2" -> "1"
else -> 3
}
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)
}
}
}
}
}
}
\ No newline at end of file
package com.ccwangluo.accelerator.ui.news
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.RecyclerView
import com.ccwangluo.accelerator.R
import com.ccwangluo.accelerator.adapter.KotlinDataAdapter
import com.ccwangluo.accelerator.model.NewsRes
import com.ccwangluo.accelerator.ui.home.NewsViewModel
import com.ccwangluo.accelerator.ui.news.DemoCollectionAdapter.Companion.ARG_OBJECT
class DemoObjectFragment : Fragment() {
var recycle_view: RecyclerView? = null
private lateinit var newsViewModel: NewsViewModel
private val deviceList = arrayListOf<NewsRes>()
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
newsViewModel = ViewModelProvider(requireActivity()).get(NewsViewModel::class.java)
return inflater.inflate(R.layout.fragment_collection_object, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
arguments?.takeIf { it.containsKey(ARG_OBJECT) }?.apply {
val position = getInt(ARG_OBJECT).toString()
recycle_view = view.findViewById(R.id.recycle_view)
val adapter = KotlinDataAdapter.Builder<NewsRes>()
.setData(deviceList)
.setLayoutId(R.layout.item_dynamic)
.addBindView { itemView, itemData ->
}
.create()
recycle_view?.adapter = adapter
}
}
fun refresh() {
recycle_view?.postDelayed({
newsViewModel.refreshState.postValue(false)
}, 1000)
}
}
\ No newline at end of file
......@@ -4,15 +4,15 @@ import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
class DemoCollectionAdapter(fragment: Fragment, val titles: Array<String>) :
class NewsCollectionAdapter(fragment: Fragment, val titles: Array<String>) :
FragmentStateAdapter(fragment) {
override fun getItemCount(): Int = titles.size
var list = mutableListOf<DemoObjectFragment>()
var list = mutableListOf<NewsObjectFragment>()
override fun createFragment(position: Int): Fragment {
val fragment = DemoObjectFragment()
val fragment = NewsObjectFragment()
fragment.arguments = Bundle().apply {
// Our object is just an integer :-P
putInt(ARG_OBJECT, position)
......
package com.ccwangluo.accelerator.ui.news
import android.net.Uri
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import android.widget.VideoView
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.model.News
import com.ccwangluo.accelerator.ui.home.NewsViewModel
import com.ccwangluo.accelerator.ui.news.NewsCollectionAdapter.Companion.ARG_OBJECT
import com.ccwangluo.accelerator.utils.AcceleratorUtils
import com.xuexiang.xpage.base.XPageFragment
import com.xuexiang.xpage.utils.TitleBar
import com.xuexiang.xutil.app.AppUtils
class NewsObjectFragment : XPageFragment() {
var recycle_view: RecyclerView? = null
override fun initTitleBar(): TitleBar? {
//不使用@Page标注的一定要注意覆盖这个方法
return null
}
private lateinit var newsViewModel: NewsViewModel
private val deviceList = arrayListOf<News>()
private val page = 1
private lateinit var position: String
override fun inflateView(inflater: LayoutInflater?, container: ViewGroup?): View {
newsViewModel = ViewModelProvider(this).get(NewsViewModel::class.java)
return inflater!!.inflate(R.layout.fragment_collection_object, container, false)
}
override fun initViews() {
arguments?.takeIf { it.containsKey(ARG_OBJECT) }?.apply {
position = getInt(ARG_OBJECT).toString()
recycle_view = findViewById(R.id.recycle_view)
val layoutManager = LinearLayoutManager(context)
recycle_view?.setLayoutManager(layoutManager)
val adapter = KotlinDataAdapter.Builder<News>()
.setData(deviceList)
.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)
itemView.findViewById<TextView>(R.id.createdDate).setText(itemData.createdDate)
itemData.title?.let {
itemView.findViewById<TextView>(R.id.title).visibility = View.VISIBLE
itemView.findViewById<TextView>(R.id.title).setText(it)
} ?: let { itemView.findViewById<TextView>(R.id.title).visibility = View.GONE }
itemData.abbrContent?.let {
itemView.findViewById<TextView>(R.id.abbrContent).visibility = View.VISIBLE
itemView.findViewById<TextView>(R.id.abbrContent).setText(it)
} ?: let {
itemView.findViewById<TextView>(R.id.abbrContent).visibility = View.GONE
}
// 资讯类型:0攻略 1视频
val imgs = itemView.findViewById<ImageView>(R.id.imgs)
val vedio = itemView.findViewById<VideoView>(R.id.video_view)
if (itemData.type == 0) {
itemData.imgs?.let {
imgs.visibility = View.VISIBLE
vedio.visibility = View.GONE
Glide.with(this@NewsObjectFragment).load(itemData.imgs).into(imgs)
}
} else if (itemData.type == 1) {
itemData.videoUrl?.let {
imgs.visibility = View.GONE
vedio.visibility = View.VISIBLE
vedio.setVideoURI(Uri.parse(it))
}
}
}
.create()
recycle_view?.adapter = adapter
AcceleratorUtils.getGameList(this@NewsObjectFragment) {
if (it) {
AcceleratorUtils.game?.let {
newsViewModel.freshData(position, it.id, page)
}
}
}
}
newsViewModel.newsModel.observe(this, {
deviceList.addAll(it.list)
recycle_view?.adapter?.notifyDataSetChanged()
})
}
override fun initListeners() {
}
fun refresh() {
recycle_view?.postDelayed({
AcceleratorUtils.game?.let {
newsViewModel.freshData(position, it.id, page)
}
}, 1000)
}
}
\ No newline at end of file
package com.ccwangluo.accelerator.ui.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import androidx.viewpager.widget.ViewPager;
public class NoScrollViewPager extends ViewPager {
private boolean noScroll = false;
public NoScrollViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NoScrollViewPager(Context context) {
super(context);
}
public void setNoScroll(boolean noScroll) {
this.noScroll = noScroll;
}
@Override
public void scrollTo(int x, int y) {
super.scrollTo(x, y);
}
@Override
public boolean onTouchEvent(MotionEvent arg0) {
if (noScroll)
return false;
else
return super.onTouchEvent(arg0);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent arg0) {
if (noScroll)
return false;
else
return super.onInterceptTouchEvent(arg0);
}
@Override
public void setCurrentItem(int item, boolean smoothScroll) {
super.setCurrentItem(item, smoothScroll);
}
@Override
public void setCurrentItem(int item) {
super.setCurrentItem(item);
}
}
......@@ -169,6 +169,14 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
AppUtils.uninstallApp(pageName)
}
/**
* 安装
*/
@JavascriptInterface
fun installPackge(pageName: String) {
// AppUtils.installApp(pageName)
}
/**
* 版本号
*/
......
......@@ -154,7 +154,7 @@ object AcceleratorUtils {
profile.route = Acl.BYPASS_LAN
profile.password = "barfoo!"
profile.method = "none"
profile.beatsInterval = 60
profile.beatsInterval = 10
withContext(Dispatchers.Main) {
ProfileManager.updateProfile(profile)
connect.launch(null)
......
......@@ -108,7 +108,6 @@ object LoginUtils {
res?.let {
if (it.code == 200) {
token = it.data?.token
AuthManager.authToken = token
ToastUtils.show("登录成功")
OneKeyLoginManager.getInstance().finishAuthActivity()
withContext(Dispatchers.Main) {
......
......@@ -87,7 +87,7 @@ object PhoneUtils {
val mOtherTv = TextView(context)
mOtherTv.text = "其他方式登录"
mOtherTv.setTextColor(Color.parseColor("#FF408DFF"))
mOtherTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12f)
mOtherTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f)
val otherLayoutParams = RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT
......
......@@ -7,7 +7,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.viewpager.widget.ViewPager
<com.ccwangluo.accelerator.ui.view.NoScrollViewPager
android:id="@+id/view_pager"
android:layout_weight="1"
android:layout_width="match_parent"
......
......@@ -32,8 +32,8 @@
android:textSize="16sp" />
<ImageView
android:layout_width="16dp"
android:layout_height="22dp"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="22.15dp"
......@@ -49,8 +49,8 @@
<com.xuexiang.xui.widget.button.roundbutton.RoundButton
android:id="@+id/icon_notice_badge"
android:layout_width="4dp"
android:layout_height="4dp"
android:layout_width="8dp"
android:layout_height="8dp"
android:layout_alignParentEnd="true"
android:visibility="gone"
app:rb_backgroundColor="@color/red"
......@@ -58,7 +58,7 @@
<ImageView
android:layout_width="19dp"
android:layout_height="21dp"
android:layout_height="20dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:background="@mipmap/message" />
......@@ -90,8 +90,8 @@
android:background="@mipmap/circle_in1" />
<com.xuexiang.xui.widget.imageview.RadiusImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_width="190dp"
android:layout_height="190dp"
android:layout_centerInParent="true"
android:clickable="true"
app:riv_border_width="1px"
......@@ -106,18 +106,56 @@
app:cpv_animate_type="AccelerateDecelerateInterpolator"
app:cpv_circle_broken="false"
app:cpv_end_color="#8BE7FA"
app:cpv_end_progress="78"
app:cpv_end_progress="99"
app:cpv_isFilled="false"
app:cpv_isTracked="true"
app:cpv_progress_duration="2000"
app:cpv_progress_textColor="#8BE7FA"
app:cpv_progress_textSize="50sp"
app:cpv_progress_textVisibility="true"
app:cpv_progress_textVisibility="false"
app:cpv_progress_width="4dp"
app:cpv_start_color="#8BE7FA"
app:cpv_start_progress="0"
app:cpv_track_color="#57595B"
app:cpv_track_width="4dp" />
<com.xuexiang.xui.widget.layout.XUILinearLayout
android:id="@+id/progress_area"
android:layout_width="190dp"
android:layout_height="190dp"
android:layout_centerInParent="true"
android:background="#77000000"
android:gravity="center"
android:visibility="gone"
android:orientation="horizontal"
app:xui_borderColor="@color/transparent"
app:xui_outerNormalColor="@color/transparent"
app:xui_radius="190dp"
app:xui_showBorderOnlyBeforeL="false">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/progress"
android:text="0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#8BE7FA"
android:textSize="70sp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#8BE7FA"
android:text="%"
android:textSize="25sp"
/>
</LinearLayout>
</com.xuexiang.xui.widget.layout.XUILinearLayout>
<com.xuexiang.xui.widget.layout.XUILinearLayout
android:id="@+id/quick_top_toast"
android:layout_width="320dp"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:background="@color/white"
android:layout_marginRight="20dp"
android:background="@color/white"
android:orientation="vertical">
<LinearLayout
android:layout_marginTop="16.5dp"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_marginTop="16.5dp"
android:orientation="horizontal">
<com.xuexiang.xui.widget.layout.XUIFrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:xui_radius="36dp">
<ImageView
android:id="@+id/avatar"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_vertical" />
</com.xuexiang.xui.widget.layout.XUIFrameLayout>
<ImageView
android:layout_width="36dp"
android:layout_gravity="center_vertical"
android:layout_height="36dp"/>
<LinearLayout
android:layout_marginLeft="10dp"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="vertical">
<TextView
android:id="@+id/nickname"
android:layout_width="70.5dp"
android:layout_height="20dp"
android:text="DNF小管家"
android:textColor="#FF000000"
android:textSize="14sp"
/>
android:textSize="14sp" />
<TextView
android:id="@+id/createdDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2020-12-12"
android:textColor="#FFB4B4B4"
android:textSize="11sp"
/>
android:textSize="11sp" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_marginTop="8dp"
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="DNF合金战士怎么还没出?智慧的引导和奥兹玛怎么进?"
android:textColor="#FF000000"
android:textSize="14sp"/>
android:textSize="14sp" />
<TextView
android:visibility="gone"
android:layout_marginTop="6dp"
android:id="@+id/abbrContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="DNF合金战士怎么还没出?智慧的引导和奥兹玛怎么进?智慧的引导和奥兹玛怎么进?智慧的引导和奥兹玛怎么进…"
android:textColor="#FF4A4A4A"
android:textSize="14sp"
/>
android:textSize="14sp" />
<ImageView
android:visibility="gone"
android:layout_marginTop="12.65dp"
android:id="@+id/imgs"
android:layout_width="match_parent"
android:layout_height="182.5dp"/>
<VideoView
android:layout_height="182.5dp"
android:layout_marginTop="12.65dp"
android:visibility="gone" />
<VideoView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="182.5dp"/>
android:layout_height="182.5dp"
android:layout_marginTop="12.65dp" />
<RelativeLayout
android:layout_marginTop="11dp"
android:layout_width="match_parent"
android:layout_marginBottom="11dp"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_marginTop="11dp"
android:layout_marginBottom="11dp">
<TextView
android:layout_width="57.5dp"
android:layout_height="15dp"
android:text="1502次浏览"
android:textColor="#FFB4B4B4"
android:textSize="11sp"
/>
android:textSize="11sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="16"
android:gravity="center_vertical"
android:layout_alignParentRight="true"
android:layout_marginRight="18.5dp"
android:gravity="center_vertical"
android:text="16"
android:textColor="#FFBBBBBB"
android:textSize="14sp"
/>
android:textSize="14sp" />
<ImageView
android:layout_alignParentRight="true"
android:layout_width="14dp"
android:layout_centerVertical="true"
android:layout_height="14dp"
android:background="@mipmap/icon_praise_ga"
/>
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@mipmap/icon_praise_ga" />
</RelativeLayout>
......
......@@ -41,6 +41,9 @@ object AuthManager {
val okHttpClient: OkHttpClient
val gson: Gson
private const val KEY_TOKEN = "com.ccwangluo.KEY_TOKEN"
init {
okHttpClient = OkHttpClient().newBuilder()
.readTimeout(60, TimeUnit.SECONDS)//设置读取超时时间
......@@ -65,56 +68,29 @@ object AuthManager {
}
var authToken: String?
get() = MMKV.defaultMMKV().decodeString("CONFIG_AUTHTOKEN", null)
get() = MMKV.defaultMMKV().decodeString(KEY_TOKEN, null)
set(token) {
MMKV.defaultMMKV().putString("CONFIG_AUTHTOKEN", token)
MMKV.defaultMMKV().putString(KEY_TOKEN, token)
}
// 加速时长
var ACC_TIME :Long
var ACC_TIME: Long
get() = MMKV.defaultMMKV().decodeLong("ACC_TIME", 0L)
set(acc_time) {
MMKV.defaultMMKV().putLong("ACC_TIME", acc_time)
}
fun initAuthProfile() {
GlobalScope.launch(Dispatchers.Main) {
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
profile.proxyApps = true
// val proxyGames = mutableSetOf(
// "com.sec.android.app.sbrowser",
// "com.nexon.maplem.global",
// "jp.co.cygames.umamusume",
// "com.ea.gp.apexlegendsmobilefps",
// "jp.konami.duellinks",
// "com.riotgames.league.wildrift",
// "com.garena.game.codm",
// "com.google.android.configupdater",
// "com.miHoYo.GenshinImpact",
// "com.rekoo.pubgm",
// "com.pubg.krmobile",
// "com.tgc.sky.android",
// "com.YoStarJP.Arknights",
// "com.riotgames.league.wildrifttw"
// )
// proxyGames.addAll(profile.individual.split("\n"))
Timber.d("start vpn with games: ${profile.individual}")
// profile.individual = proxyGames.joinToString("\n")
profile.route = Acl.BYPASS_LAN
profile.password = "barfoo!"
profile.method = "none"
profile.beatsInterval = 60
ProfileManager.updateProfile(profile)
suspend fun initAuthProfile() {
withContext(Dispatchers.IO) {
getLineConfig()?.let {
if (it.code != 200) {
return@withContext
}
val profileId = 1L
val profile = ProfileManager.getProfile(profileId) ?: Profile()
profile.token = it.data.token
Timber.d("start vpn with games: ${profile.individual}")
ProfileManager.updateProfile(profile)
}
}
}
......
......@@ -348,6 +348,7 @@ object BaseService {
try {
Executable.killAll() // clean up old processes
preInit()
AuthManager.initAuthProfile()
if (profile.route == Acl.CUSTOM_RULES) try {
withContext(Dispatchers.IO) {
Acl.customRules.flatten(10, this@Interface::openConnection).also {
......
......@@ -140,7 +140,6 @@ class VpnService : BaseVpnService(), BaseService.Interface {
if (prepare(this) != null) {
startActivity(Intent(this, VpnRequestActivity::class.java).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
} else {
AuthManager.initAuthProfile()
return super<BaseService.Interface>.onStartCommand(intent, flags, startId)
}
}
......
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