Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
7a1afc91
Commit
7a1afc91
authored
Mar 25, 2022
by
sheteng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
游戏更新 美团打包
parent
34c09abb
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
416 additions
and
91 deletions
+416
-91
README.md
README.md
+10
-0
app/build.gradle.kts
app/build.gradle.kts
+33
-8
app/src/main/java/com/ccwangluo/accelerator/App.kt
app/src/main/java/com/ccwangluo/accelerator/App.kt
+3
-0
app/src/main/java/com/ccwangluo/accelerator/receiver/AppDownloadReceiver.java
...m/ccwangluo/accelerator/receiver/AppDownloadReceiver.java
+69
-0
app/src/main/java/com/ccwangluo/accelerator/ui/MainActivity.kt
...rc/main/java/com/ccwangluo/accelerator/ui/MainActivity.kt
+18
-12
app/src/main/java/com/ccwangluo/accelerator/ui/dialog/DownloadDialog.kt
...ava/com/ccwangluo/accelerator/ui/dialog/DownloadDialog.kt
+67
-0
app/src/main/java/com/ccwangluo/accelerator/ui/home/MineFragment.kt
...in/java/com/ccwangluo/accelerator/ui/home/MineFragment.kt
+3
-2
app/src/main/java/com/ccwangluo/accelerator/ui/home/NewsFragment.kt
...in/java/com/ccwangluo/accelerator/ui/home/NewsFragment.kt
+22
-2
app/src/main/java/com/ccwangluo/accelerator/ui/home/NewsViewModel.kt
...n/java/com/ccwangluo/accelerator/ui/home/NewsViewModel.kt
+2
-1
app/src/main/java/com/ccwangluo/accelerator/ui/login/LoginViewModel.kt
...java/com/ccwangluo/accelerator/ui/login/LoginViewModel.kt
+2
-2
app/src/main/java/com/ccwangluo/accelerator/ui/web/AndroidInterface.kt
...java/com/ccwangluo/accelerator/ui/web/AndroidInterface.kt
+46
-34
app/src/main/java/com/ccwangluo/accelerator/ui/web/CommonWebViewFragment.kt
...com/ccwangluo/accelerator/ui/web/CommonWebViewFragment.kt
+10
-5
app/src/main/java/com/ccwangluo/accelerator/utils/LoginUtils.kt
...c/main/java/com/ccwangluo/accelerator/utils/LoginUtils.kt
+1
-1
app/src/main/java/com/ccwangluo/accelerator/utils/SettingSPUtils.kt
...in/java/com/ccwangluo/accelerator/utils/SettingSPUtils.kt
+8
-1
app/src/main/java/com/ccwangluo/accelerator/utils/SysUtils.kt
...src/main/java/com/ccwangluo/accelerator/utils/SysUtils.kt
+82
-17
app/src/main/java/com/ccwangluo/accelerator/utils/datareport/BaseData.kt
...va/com/ccwangluo/accelerator/utils/datareport/BaseData.kt
+1
-1
app/src/main/java/com/ccwangluo/accelerator/utils/http/HttpGo.kt
.../main/java/com/ccwangluo/accelerator/utils/http/HttpGo.kt
+9
-1
app/src/main/res/values/styles.xml
app/src/main/res/values/styles.xml
+15
-3
app/src/main/res/values/themes.xml
app/src/main/res/values/themes.xml
+4
-1
app/src/main/res/xml/filepaths.xml
app/src/main/res/xml/filepaths.xml
+1
-0
build.gradle.kts
build.gradle.kts
+2
-0
buildSrc/src/main/kotlin/Helpers.kt
buildSrc/src/main/kotlin/Helpers.kt
+1
-0
channels.txt
channels.txt
+7
-0
tools/packer-ng-2.0.1.jar
tools/packer-ng-2.0.1.jar
+0
-0
No files found.
README.md
View file @
7a1afc91
...
@@ -74,3 +74,13 @@ GNU General Public License for more details.
...
@@ -74,3 +74,13 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this program. If not, see
<http://www.gnu.org/licenses/>
.
along with this program. If not, see
<http://www.gnu.org/licenses/>
.
多渠道打包命令
gradlew clean apkRelease -Poutput=build/apks
java -jar tools/packer-ng-2.0.1.jar generate --channels=@channels.txt --output=build/apks app/release/app-universal-release.apk
app/build.gradle.kts
View file @
7a1afc91
...
@@ -3,9 +3,11 @@ plugins {
...
@@ -3,9 +3,11 @@ plugins {
id
(
"kotlin-android"
)
id
(
"kotlin-android"
)
id
(
"kotlin-kapt"
)
id
(
"kotlin-kapt"
)
id
(
"kotlin-parcelize"
)
id
(
"kotlin-parcelize"
)
id
(
"packer"
)
}
}
android
{
android
{
compileOptions
{
compileOptions
{
sourceCompatibility
=
JavaVersion
.
VERSION_1_8
sourceCompatibility
=
JavaVersion
.
VERSION_1_8
targetCompatibility
=
JavaVersion
.
VERSION_1_8
targetCompatibility
=
JavaVersion
.
VERSION_1_8
...
@@ -26,25 +28,46 @@ android {
...
@@ -26,25 +28,46 @@ android {
applicationId
=
"com.ccwangluo.accelerator"
applicationId
=
"com.ccwangluo.accelerator"
testInstrumentationRunner
=
"androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner
=
"androidx.test.runner.AndroidJUnitRunner"
manifestPlaceholders
.
put
(
"XG_ACCESS_ID"
,
"1580009634"
)
manifestPlaceholders
.
put
(
"XG_ACCESS_ID"
,
"1580009634"
)
manifestPlaceholders
.
put
(
"XG_ACCESS_KEY"
,
"AIJKAIYR3WPS"
)
manifestPlaceholders
.
put
(
"XG_ACCESS_KEY"
,
"AIJKAIYR3WPS"
)
manifestPlaceholders
.
put
(
"qqappid"
,
"101994779"
)
manifestPlaceholders
.
put
(
"qqappid"
,
"101994779"
)
flavorDimensions
.
add
(
"1.0"
)
ndk
{
abiFilters
.
add
(
"armeabi-v7a"
)
abiFilters
.
add
(
"arm64-v8a"
)
}
}
}
buildTypes
{
buildTypes
{
named
(
"release"
){
named
(
"release"
)
{
signingConfig
?.
enableV2Signing
=
true
signingConfig
=
signingConfigs
.
getByName
(
"config"
)
signingConfig
=
signingConfigs
.
getByName
(
"config"
)
isMinifyEnabled
=
false
isMinifyEnabled
=
false
setProguardFiles
(
listOf
(
getDefaultProguardFile
(
"proguard-android.txt"
),
"proguard-rules.pro"
))
setProguardFiles
(
listOf
(
getDefaultProguardFile
(
"proguard-android.txt"
),
"proguard-rules.pro"
)
)
}
}
named
(
"debug"
){
named
(
"debug"
)
{
signingConfig
=
signingConfigs
.
getByName
(
"config"
)
signingConfig
=
signingConfigs
.
getByName
(
"config"
)
isMinifyEnabled
=
false
isMinifyEnabled
=
false
}
}
}
}
buildFeatures
.
viewBinding
=
true
buildFeatures
.
viewBinding
=
true
packer
{
// archiveNameFormat = "${appPkg}-${buildType}-v${versionName}-${channel}"
archiveOutput
=
File
(
project
.
rootProject
.
buildDir
,
"apks"
)
channelFile
=
project
.
rootProject
.
file
(
"channels.txt"
)
}
}
}
setupApp
()
setupApp
()
android
.
defaultConfig
.
applicationId
=
"com.ccwangluo.accelerator"
android
.
defaultConfig
.
applicationId
=
"com.ccwangluo.accelerator"
...
@@ -78,6 +101,8 @@ dependencies {
...
@@ -78,6 +101,8 @@ dependencies {
implementation
(
"com.github.xuexiangjys.XUtil:xutil-core:2.0.0"
)
implementation
(
"com.github.xuexiangjys.XUtil:xutil-core:2.0.0"
)
implementation
(
"com.github.xuexiangjys.XUtil:xutil-sub:2.0.0"
)
implementation
(
"com.github.xuexiangjys.XUtil:xutil-sub:2.0.0"
)
implementation
(
"com.tencent:mmkv:1.2.10"
)
implementation
(
"com.tencent:mmkv:1.2.10"
)
//美团多渠道打包
implementation
(
"com.mcxiaoke.packer-ng:helper:2.0.1"
)
//XPage
//XPage
implementation
(
"com.github.xuexiangjys.XPage:xpage-lib:3.3.0"
)
implementation
(
"com.github.xuexiangjys.XPage:xpage-lib:3.3.0"
)
...
@@ -107,7 +132,7 @@ dependencies {
...
@@ -107,7 +132,7 @@ dependencies {
// implementation("com.squareup.okhttp3:okhttp:3.14.9")//QQ官方sdk 3.53及之后版本需要集成okhttp3.x,必选)
// implementation("com.squareup.okhttp3:okhttp:3.14.9")//QQ官方sdk 3.53及之后版本需要集成okhttp3.x,必选)
//gps
//gps
implementation
(
"com.tencent.map.geolocation:TencentLocationSdk-openplatform:7.3.0"
)
implementation
(
"com.tencent.map.geolocation:TencentLocationSdk-openplatform:7.3.0"
)
implementation
(
"com.github.bumptech.glide:glide:4.11.0"
)
implementation
(
"com.github.bumptech.glide:glide:4.11.0"
)
annotationProcessor
(
"com.github.bumptech.glide:compiler:4.11.0"
)
annotationProcessor
(
"com.github.bumptech.glide:compiler:4.11.0"
)
...
@@ -115,6 +140,6 @@ dependencies {
...
@@ -115,6 +140,6 @@ dependencies {
implementation
(
"com.github.open-android:JieCaoVideoPlayer:0.1.0"
)
implementation
(
"com.github.open-android:JieCaoVideoPlayer:0.1.0"
)
implementation
(
"com.tencent.bugly:crashreport_upgrade:1.5.23"
)
//其中latest.release指代最新版本号,也可以指定明确的版本号,例如1.2.0
implementation
(
"com.tencent.bugly:crashreport_upgrade:1.5.23"
)
//其中latest.release指代最新版本号,也可以指定明确的版本号,例如1.2.0
implementation
(
"com.tencent.bugly:nativecrashreport:3.9.2"
)
//其中latest.release指代最新版本号,也可以指定明确的版本号,例如2.2.0
implementation
(
"com.tencent.bugly:nativecrashreport:3.9.2"
)
//其中latest.release指代最新版本号,也可以指定明确的版本号,例如2.2.0
implementation
(
"com.tencent.tpns:tpns:1.3.2.0-release"
)
implementation
(
"com.tencent.tpns:tpns:1.3.2.0-release"
)
}
}
\ No newline at end of file
app/src/main/java/com/ccwangluo/accelerator/App.kt
View file @
7a1afc91
...
@@ -6,6 +6,7 @@ import android.os.Environment
...
@@ -6,6 +6,7 @@ import android.os.Environment
import
androidx.multidex.MultiDex
import
androidx.multidex.MultiDex
import
com.ccwangluo.accelerator.ui.MainActivity
import
com.ccwangluo.accelerator.ui.MainActivity
import
com.ccwangluo.accelerator.utils.PhoneUtils
import
com.ccwangluo.accelerator.utils.PhoneUtils
import
com.ccwangluo.accelerator.utils.SysUtils
import
com.github.shadowsocks.Core
import
com.github.shadowsocks.Core
import
com.hjq.toast.ToastUtils
import
com.hjq.toast.ToastUtils
import
com.tencent.bugly.Bugly
import
com.tencent.bugly.Bugly
...
@@ -38,6 +39,8 @@ class App : Application(), androidx.work.Configuration.Provider by Core {
...
@@ -38,6 +39,8 @@ class App : Application(), androidx.work.Configuration.Provider by Core {
XGPushConfig
.
enableDebug
(
this
,
true
);
XGPushConfig
.
enableDebug
(
this
,
true
);
XUtil
.
init
(
this
)
XUtil
.
init
(
this
)
SysUtils
.
initChannel
(
this
)
UMConfigure
.
init
(
this
,
"61f0aa7fe014255fcb06a0bd"
UMConfigure
.
init
(
this
,
"61f0aa7fe014255fcb06a0bd"
,
"umeng"
,
UMConfigure
.
DEVICE_TYPE_PHONE
,
""
)
,
"umeng"
,
UMConfigure
.
DEVICE_TYPE_PHONE
,
""
)
...
...
app/src/main/java/com/ccwangluo/accelerator/receiver/AppDownloadReceiver.java
0 → 100644
View file @
7a1afc91
package
com.ccwangluo.accelerator.receiver
;
import
static
com
.
tencent
.
bugly
.
beta
.
tinker
.
TinkerManager
.
getApplication
;
import
android.app.DownloadManager
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.database.Cursor
;
import
android.net.Uri
;
import
android.text.TextUtils
;
public
class
AppDownloadReceiver
extends
BroadcastReceiver
{
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
String
action
=
intent
.
getAction
();
if
(!
TextUtils
.
equals
(
action
,
DownloadManager
.
ACTION_DOWNLOAD_COMPLETE
))
{
return
;
}
long
downloadId
=
intent
.
getLongExtra
(
DownloadManager
.
EXTRA_DOWNLOAD_ID
,
-
1
);
if
(
downloadId
==
-
1
)
{
return
;
}
DownloadManager
downloadManager
=
(
DownloadManager
)
context
.
getApplicationContext
().
getSystemService
(
Context
.
DOWNLOAD_SERVICE
);
int
status
=
getDownloadStatus
(
downloadManager
,
downloadId
);
if
(
status
!=
DownloadManager
.
STATUS_SUCCESSFUL
)
{
//下载状态不等于成功就跳出
return
;
}
Uri
uri
=
downloadManager
.
getUriForDownloadedFile
(
downloadId
);
//获取下载完成文件uri
if
(
uri
==
null
)
{
return
;
}
installApk
(
context
,
uri
);
}
/**
* 安装apk
*/
private
void
installApk
(
Context
context
,
Uri
uri
)
{
Intent
install
=
new
Intent
(
Intent
.
ACTION_VIEW
);
install
.
setDataAndType
(
uri
,
"application/vnd.android.package-archive"
);
install
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
|
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
);
context
.
startActivity
(
install
);
}
/**
* 获取下载状态
*
* @param downloadManager
* @param downloadId
* @return
*/
private
int
getDownloadStatus
(
DownloadManager
downloadManager
,
long
downloadId
)
{
DownloadManager
.
Query
query
=
new
DownloadManager
.
Query
().
setFilterById
(
downloadId
);
Cursor
c
=
downloadManager
.
query
(
query
);
if
(
c
!=
null
)
{
try
{
if
(
c
.
moveToFirst
())
{
return
c
.
getInt
(
c
.
getColumnIndexOrThrow
(
DownloadManager
.
COLUMN_STATUS
));
}
}
finally
{
c
.
close
();
}
}
return
-
1
;
}
}
\ No newline at end of file
app/src/main/java/com/ccwangluo/accelerator/ui/MainActivity.kt
View file @
7a1afc91
package
com.ccwangluo.accelerator.ui
package
com.ccwangluo.accelerator.ui
import
android.Manifest
import
android.Manifest
import
android.app.DownloadManager
import
android.content.Intent
import
android.content.Intent
import
android.content.IntentFilter
import
android.hardware.Sensor
import
android.hardware.Sensor
import
android.hardware.SensorEventListener
import
android.hardware.SensorManager
import
android.os.Bundle
import
android.os.Bundle
import
android.os.Looper
import
android.os.Looper
import
android.util.Log
import
android.view.KeyEvent
import
android.view.KeyEvent
import
androidx.appcompat.app.AlertDialog
import
androidx.lifecycle.ViewModelProvider
import
androidx.lifecycle.ViewModelProvider
import
com.ccwangluo.accelerator.R
import
com.ccwangluo.accelerator.receiver.AppDownloadReceiver
import
com.ccwangluo.accelerator.ui.dialog.PermissionDialog
import
com.ccwangluo.accelerator.ui.dialog.PrivacyDialog
import
com.ccwangluo.accelerator.ui.dialog.PrivacyDialog
import
com.ccwangluo.accelerator.ui.home.AccelertorViewModel
import
com.ccwangluo.accelerator.ui.home.AccelertorViewModel
import
com.ccwangluo.accelerator.ui.login.SplashFragment
import
com.ccwangluo.accelerator.ui.login.SplashFragment
import
com.ccwangluo.accelerator.utils.AcceleratorUtils
import
com.ccwangluo.accelerator.utils.AcceleratorUtils
import
com.ccwangluo.accelerator.utils.PhoneUtils
import
com.ccwangluo.accelerator.utils.PhoneUtils
import
com.
github.shadowsocks.http.HttpConfig
import
com.
ccwangluo.accelerator.utils.datareport.DataRePortUtils
import
com.ccwangluo.cc_quickly.utils.SettingSPUtils
import
com.ccwangluo.cc_quickly.utils.SettingSPUtils
import
com.github.shadowsocks.bg.AuthManager
import
com.github.shadowsocks.bg.AuthManager
import
com.github.shadowsocks.http.HttpConfig
import
com.github.shadowsocks.utils.StartService
import
com.github.shadowsocks.utils.StartService
import
com.hjq.toast.ToastUtils
import
com.hjq.toast.ToastUtils
import
com.tencent.android.tpush.XGIOperateCallback
import
com.tencent.android.tpush.XGPushManager
import
com.tencent.map.geolocation.TencentLocation
import
com.tencent.map.geolocation.TencentLocation
import
com.tencent.map.geolocation.TencentLocationListener
import
com.tencent.map.geolocation.TencentLocationListener
import
com.tencent.map.geolocation.TencentLocationManager
import
com.tencent.map.geolocation.TencentLocationManager
...
@@ -24,17 +36,9 @@ import com.tencent.tauth.Tencent
...
@@ -24,17 +36,9 @@ import com.tencent.tauth.Tencent
import
com.umeng.socialize.UMShareAPI
import
com.umeng.socialize.UMShareAPI
import
com.xuexiang.xpage.base.XPageActivity
import
com.xuexiang.xpage.base.XPageActivity
import
com.xuexiang.xpage.core.PageOption
import
com.xuexiang.xpage.core.PageOption
import
android.hardware.SensorManager
import
com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog
import
android.hardware.SensorEventListener
import
android.os.Handler
import
android.util.Log
import
com.ccwangluo.accelerator.ui.dialog.PermissionDialog
import
com.ccwangluo.accelerator.ui.home.AcceleratorFragment
import
com.ccwangluo.accelerator.utils.datareport.DataRePortUtils
import
fm.jiecao.jcvideoplayer_lib.JCVideoPlayer
import
com.tencent.android.tpush.XGIOperateCallback
import
com.tencent.android.tpush.XGPushManager
import
com.xuexiang.xutil.system.PermissionUtils
import
com.xuexiang.xutil.system.PermissionUtils
import
fm.jiecao.jcvideoplayer_lib.JCVideoPlayer
class
MainActivity
()
:
XPageActivity
(),
TencentLocationListener
{
class
MainActivity
()
:
XPageActivity
(),
TencentLocationListener
{
...
@@ -50,6 +54,7 @@ class MainActivity() : XPageActivity(), TencentLocationListener {
...
@@ -50,6 +54,7 @@ class MainActivity() : XPageActivity(), TencentLocationListener {
private
var
mSensorEventListener
:
SensorEventListener
?
=
null
private
var
mSensorEventListener
:
SensorEventListener
?
=
null
private
var
mSensorManager
:
SensorManager
?
=
null
private
var
mSensorManager
:
SensorManager
?
=
null
private
val
appDownReceiver
=
AppDownloadReceiver
()
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
...
@@ -90,7 +95,7 @@ class MainActivity() : XPageActivity(), TencentLocationListener {
...
@@ -90,7 +95,7 @@ class MainActivity() : XPageActivity(), TencentLocationListener {
DataRePortUtils
.
report
(
"st_app_open"
)
DataRePortUtils
.
report
(
"st_app_open"
)
AcceleratorUtils
.
initConnect
(
this
)
AcceleratorUtils
.
initConnect
(
this
)
registerReceiver
(
appDownReceiver
,
IntentFilter
(
DownloadManager
.
ACTION_DOWNLOAD_COMPLETE
))
}
}
private
fun
getPermission
()
{
private
fun
getPermission
()
{
...
@@ -180,6 +185,7 @@ class MainActivity() : XPageActivity(), TencentLocationListener {
...
@@ -180,6 +185,7 @@ class MainActivity() : XPageActivity(), TencentLocationListener {
override
fun
onDestroy
()
{
override
fun
onDestroy
()
{
super
.
onDestroy
()
super
.
onDestroy
()
unregisterReceiver
(
appDownReceiver
)
AcceleratorUtils
.
onDestroy
(
this
)
AcceleratorUtils
.
onDestroy
(
this
)
}
}
...
...
app/src/main/java/com/ccwangluo/accelerator/ui/dialog/DownloadDialog.kt
0 → 100644
View file @
7a1afc91
package
com.ccwangluo.accelerator.ui.dialog
import
android.app.DownloadManager
import
android.content.DialogInterface
import
android.database.Cursor
import
androidx.fragment.app.FragmentActivity
import
androidx.lifecycle.lifecycleScope
import
com.xuexiang.xui.widget.dialog.materialdialog.GravityEnum
import
com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.withContext
class
DownloadDialog
(
val
context
:
FragmentActivity
,
val
downloadManager
:
DownloadManager
,
var
downloadId
:
Long
)
{
fun
show
()
{
val
dialog
=
MaterialDialog
.
Builder
(
context
)
.
content
(
"下载中"
)
.
contentGravity
(
GravityEnum
.
CENTER
)
.
progress
(
false
,
100
,
true
)
.
cancelListener
(
{
})
.
cancelable
(
false
)
.
showListener
({})
.
show
()
context
.
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
while
(
dialog
.
progressBar
.
progress
<
100
)
{
val
progress
=
getDownloadProgress
()
withContext
(
Dispatchers
.
Main
)
{
dialog
.
setProgress
(
progress
.
toInt
())
}
delay
(
500
)
}
withContext
(
Dispatchers
.
Main
)
{
dialog
.
dismiss
()
}
}
}
fun
getDownloadProgress
():
Float
{
val
query
=
DownloadManager
.
Query
().
setFilterById
(
downloadId
)
val
c
:
Cursor
=
downloadManager
.
query
(
query
)
if
(
c
!=
null
)
{
try
{
if
(
c
.
moveToFirst
())
{
val
mDownload_so_far
=
c
.
getInt
(
c
.
getColumnIndex
(
DownloadManager
.
COLUMN_BYTES_DOWNLOADED_SO_FAR
))
val
mDownload_all
=
c
.
getInt
(
c
.
getColumnIndex
(
DownloadManager
.
COLUMN_TOTAL_SIZE_BYTES
))
println
(
"mDownload_so_far = $mDownload_so_far &&& mDownload_all = ${mDownload_all} &&& ${mDownload_so_far * 100 / mDownload_all} "
)
return
(
mDownload_so_far
.
toFloat
()
/
mDownload_all
)
*
100
}
}
finally
{
c
.
close
()
}
}
return
-
1F
}
}
\ No newline at end of file
app/src/main/java/com/ccwangluo/accelerator/ui/home/MineFragment.kt
View file @
7a1afc91
...
@@ -9,6 +9,7 @@ import androidx.fragment.app.Fragment
...
@@ -9,6 +9,7 @@ import androidx.fragment.app.Fragment
import
com.ccwangluo.accelerator.databinding.FragmentMineBinding
import
com.ccwangluo.accelerator.databinding.FragmentMineBinding
import
com.ccwangluo.accelerator.ui.web.AndroidInterface
import
com.ccwangluo.accelerator.ui.web.AndroidInterface
import
com.ccwangluo.accelerator.utils.LoginUtils
import
com.ccwangluo.accelerator.utils.LoginUtils
import
com.ccwangluo.accelerator.utils.SysUtils
import
com.github.shadowsocks.http.HttpConfig
import
com.github.shadowsocks.http.HttpConfig
import
com.just.agentweb.core.AgentWeb
import
com.just.agentweb.core.AgentWeb
import
com.just.agentweb.core.client.DefaultWebClient
import
com.just.agentweb.core.client.DefaultWebClient
...
@@ -32,9 +33,9 @@ class MineFragment : XPageFragment() {
...
@@ -32,9 +33,9 @@ class MineFragment : XPageFragment() {
}
}
override
fun
initViews
()
{
override
fun
initViews
()
{
var
weburl
=
HttpConfig
.
UI_MAIN_URL
var
weburl
=
HttpConfig
.
UI_MAIN_URL
+
"?channel=${SysUtils.getChannel()}"
LoginUtils
.
token
?.
let
{
LoginUtils
.
token
?.
let
{
weburl
=
weburl
+
"
?token=$it
"
weburl
=
weburl
+
"
&token=${it}
"
}
}
agentWeb
=
agentWeb
=
createAgentWeb
(
this
,
binding
.
mineWebview
,
weburl
)
createAgentWeb
(
this
,
binding
.
mineWebview
,
weburl
)
...
...
app/src/main/java/com/ccwangluo/accelerator/ui/home/NewsFragment.kt
View file @
7a1afc91
package
com.ccwangluo.accelerator.ui.home
package
com.ccwangluo.accelerator.ui.home
import
android.graphics.Color
import
android.os.Bundle
import
android.os.Bundle
import
android.view.LayoutInflater
import
android.view.LayoutInflater
import
android.view.View
import
android.view.View
...
@@ -29,6 +30,7 @@ import com.google.android.material.tabs.TabLayoutMediator
...
@@ -29,6 +30,7 @@ import com.google.android.material.tabs.TabLayoutMediator
import
com.hjq.toast.ToastUtils
import
com.hjq.toast.ToastUtils
import
com.xuexiang.xpage.base.XPageFragment
import
com.xuexiang.xpage.base.XPageFragment
import
com.xuexiang.xpage.utils.TitleBar
import
com.xuexiang.xpage.utils.TitleBar
import
com.xuexiang.xutil.app.AppUtils
class
NewsFragment
:
XPageFragment
()
{
class
NewsFragment
:
XPageFragment
()
{
private
var
_binding
:
FragmentNewsBinding
?
=
null
private
var
_binding
:
FragmentNewsBinding
?
=
null
...
@@ -95,6 +97,25 @@ class NewsFragment : XPageFragment() {
...
@@ -95,6 +97,25 @@ class NewsFragment : XPageFragment() {
.
into
(
itemView
.
findViewById
<
ImageView
>(
R
.
id
.
plugin_img
))
.
into
(
itemView
.
findViewById
<
ImageView
>(
R
.
id
.
plugin_img
))
}
}
itemView
.
findViewById
<
TextView
>(
R
.
id
.
plugin_name
).
setText
(
itemData
.
name
)
itemView
.
findViewById
<
TextView
>(
R
.
id
.
plugin_name
).
setText
(
itemData
.
name
)
if
(
itemData
.
type
==
3
)
{
AcceleratorUtils
.
game
?.
let
{
val
version
=
AppUtils
.
getAppVersionCode
(
it
.
packageName
)
itemData
.
url
?.
let
{
var
newversion
=
it
.
split
(
"/"
).
let
{
it1-
>
it1
.
get
(
it1
.
lastIndex
-
1
).
toInt
()
}
if
(
newversion
>
version
)
{
itemView
.
findViewById
<
TextView
>(
R
.
id
.
plugin_name
).
setText
(
"游戏更新"
)
itemView
.
findViewById
<
TextView
>(
R
.
id
.
plugin_name
)
.
setTextColor
(
Color
.
parseColor
(
"#329CF3"
))
}
}
}
}
itemView
.
setOnClickListener
{
itemView
.
setOnClickListener
{
if
(
itemData
.
type
==
3
)
{
if
(
itemData
.
type
==
3
)
{
DataRePortUtils
.
report
(
"st_game_down_clk"
,
mapOf
(
"scene"
to
"3"
))
DataRePortUtils
.
report
(
"st_game_down_clk"
,
mapOf
(
"scene"
to
"3"
))
...
@@ -121,9 +142,8 @@ class NewsFragment : XPageFragment() {
...
@@ -121,9 +142,8 @@ class NewsFragment : XPageFragment() {
if
(
itemData
.
type
==
3
)
{
if
(
itemData
.
type
==
3
)
{
itemData
.
url
?.
let
{
itemData
.
url
?.
let
{
DataRePortUtils
.
report
(
"st_game_down_clk"
,
mapOf
(
"scene"
to
"3"
))
DataRePortUtils
.
report
(
"st_game_down_clk"
,
mapOf
(
"scene"
to
"3"
))
context
?.
let
{
it1
->
activity
?.
let
{
it1
->
SysUtils
.
downloadFile
(
it1
,
it
)
SysUtils
.
downloadFile
(
it1
,
it
)
ToastUtils
.
show
(
"开始下载"
)
}
}
}
}
}
}
...
...
app/src/main/java/com/ccwangluo/accelerator/ui/home/NewsViewModel.kt
View file @
7a1afc91
...
@@ -4,6 +4,7 @@ import androidx.lifecycle.MutableLiveData
...
@@ -4,6 +4,7 @@ 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.*
import
com.ccwangluo.accelerator.model.*
import
com.ccwangluo.accelerator.utils.SysUtils
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
...
@@ -38,7 +39,7 @@ class NewsViewModel : ViewModel() {
...
@@ -38,7 +39,7 @@ class NewsViewModel : ViewModel() {
fun
getPlugin
(
gameId
:
Int
)
{
fun
getPlugin
(
gameId
:
Int
)
{
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
val
res
=
val
res
=
HttpGo
.
getSync
<
PluginModel
>(
"/api/plugin/list?gameId=$gameId&page=1&size=10"
)
HttpGo
.
getSync
<
PluginModel
>(
"/api/plugin/list?gameId=$gameId&page=1&size=10
&channelId=${SysUtils.getChannel()}
"
)
res
?.
let
{
res
?.
let
{
if
(
it
.
code
==
200
)
{
if
(
it
.
code
==
200
)
{
it
.
data
?.
list
?.
let
{
it
.
data
?.
list
?.
let
{
...
...
app/src/main/java/com/ccwangluo/accelerator/ui/login/LoginViewModel.kt
View file @
7a1afc91
...
@@ -20,7 +20,7 @@ class LoginViewModel : ViewModel() {
...
@@ -20,7 +20,7 @@ class LoginViewModel : ViewModel() {
val
timerNumber
=
MutableLiveData
<
Int
>()
val
timerNumber
=
MutableLiveData
<
Int
>()
fun
login
(
phone
:
String
,
authCdoe
:
String
)
{
fun
login
(
phone
:
String
,
authCdoe
:
String
)
{
val
map
=
mutableMapOf
<
String
,
String
>()
val
map
=
mutableMapOf
<
String
,
Any
>()
map
.
put
(
"phone"
,
phone
)
map
.
put
(
"phone"
,
phone
)
map
.
put
(
"verifyCode"
,
authCdoe
)
map
.
put
(
"verifyCode"
,
authCdoe
)
SysUtils
.
getDeviceUUID
()
?.
let
{
map
.
put
(
"did"
,
it
)
}
SysUtils
.
getDeviceUUID
()
?.
let
{
map
.
put
(
"did"
,
it
)
}
...
@@ -48,7 +48,7 @@ class LoginViewModel : ViewModel() {
...
@@ -48,7 +48,7 @@ class LoginViewModel : ViewModel() {
}
}
fun
getAuthCode
(
phone
:
String
)
{
fun
getAuthCode
(
phone
:
String
)
{
val
map
=
mutableMapOf
<
String
,
String
>()
val
map
=
mutableMapOf
<
String
,
Any
>()
map
.
put
(
"phone"
,
phone
)
map
.
put
(
"phone"
,
phone
)
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
val
res
=
HttpGo
.
postSync
<
Boolean
>(
"/api/user/sendSms"
,
map
)
val
res
=
HttpGo
.
postSync
<
Boolean
>(
"/api/user/sendSms"
,
map
)
...
...
app/src/main/java/com/ccwangluo/accelerator/ui/web/AndroidInterface.kt
View file @
7a1afc91
...
@@ -45,16 +45,22 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
...
@@ -45,16 +45,22 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
@JavascriptInterface
@JavascriptInterface
fun
openWebview
(
url
:
String
)
{
fun
openWebview
(
url
:
String
)
{
openWebview
(
url
,
false
)
}
@JavascriptInterface
fun
openWebview
(
url
:
String
,
noNeedToken
:
Boolean
)
{
LoginUtils
.
token
?.
let
{
LoginUtils
.
token
?.
let
{
val
params
=
Bundle
()
val
params
=
Bundle
()
params
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
HttpConfig
.
UI_MAIN_URL
+
url
)
params
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
HttpConfig
.
UI_MAIN_URL
+
url
)
params
.
putBoolean
(
CommonWebViewFragment
.
NOEEDTOKEN
,
noNeedToken
)
xPageFragment
.
openPage
(
CommonWebViewFragment
::
class
.
java
,
params
)
xPageFragment
.
openPage
(
CommonWebViewFragment
::
class
.
java
,
params
)
}
?:
let
{
}
?:
let
{
xPageFragment
.
context
?.
let
{
it1
->
xPageFragment
.
context
?.
let
{
it1
->
LoginUtils
.
login
(
it1
)
{
LoginUtils
.
login
(
it1
)
{
LoginUtils
.
token
?.
let
{
LoginUtils
.
token
?.
let
{
agentWeb
.
getJsAccessEntrace
()
agentWeb
.
getJsAccessEntrace
()
.
quickCallJs
(
"userToken"
,
it
)
.
quickCallJs
(
"userToken"
,
it
)
}
}
}
}
}
}
...
@@ -81,11 +87,10 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
...
@@ -81,11 +87,10 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
params
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
url
)
params
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
url
)
}
else
{
}
else
{
params
.
putString
(
params
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
HttpConfig
.
HTML_HOST_PRIVACY
+
url
HttpConfig
.
HTML_HOST_PRIVACY
+
url
)
)
}
}
xPageFragment
.
openPage
(
CommonWebViewFragment
::
class
.
java
,
params
)
xPageFragment
.
openPage
(
CommonWebViewFragment
::
class
.
java
,
params
)
}
}
...
@@ -108,7 +113,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
...
@@ -108,7 +113,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
LoginUtils
.
login
(
it1
)
{
LoginUtils
.
login
(
it1
)
{
LoginUtils
.
token
?.
let
{
LoginUtils
.
token
?.
let
{
agentWeb
.
getJsAccessEntrace
()
agentWeb
.
getJsAccessEntrace
()
.
quickCallJs
(
callback
,
it
)
.
quickCallJs
(
callback
,
it
)
}
}
}
}
}
}
...
@@ -120,7 +125,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
...
@@ -120,7 +125,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
@JavascriptInterface
@JavascriptInterface
fun
getToken
(
callback
:
String
)
{
fun
getToken
(
callback
:
String
)
{
agentWeb
.
getJsAccessEntrace
()
agentWeb
.
getJsAccessEntrace
()
.
quickCallJs
(
callback
,
LoginUtils
.
token
)
.
quickCallJs
(
callback
,
LoginUtils
.
token
)
}
}
/**
/**
...
@@ -132,16 +137,16 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
...
@@ -132,16 +137,16 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
//是否有更新:1有 0没有
//是否有更新:1有 0没有
//最新安装包的版本名称
//最新安装包的版本名称
agentWeb
.
jsAccessEntrace
agentWeb
.
jsAccessEntrace
.
quickCallJs
(
callback
,
"1"
,
AppUtils
.
getAppVersionName
(),
it
.
versionName
)
.
quickCallJs
(
callback
,
"1"
,
AppUtils
.
getAppVersionName
(),
it
.
versionName
)
}
?:
let
{
}
?:
let
{
agentWeb
.
jsAccessEntrace
agentWeb
.
jsAccessEntrace
.
quickCallJs
(
.
quickCallJs
(
callback
,
callback
,
"0"
,
"0"
,
AppUtils
.
getAppVersionName
(),
AppUtils
.
getAppVersionName
(),
AppUtils
.
getAppVersionName
()
AppUtils
.
getAppVersionName
()
)
)
}
}
}
}
...
@@ -152,10 +157,10 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
...
@@ -152,10 +157,10 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
fun
getAccelerateState
(
callback
:
String
)
{
fun
getAccelerateState
(
callback
:
String
)
{
if
(
BaseService
.
State
.
Connected
==
AcceleratorUtils
.
state
)
{
if
(
BaseService
.
State
.
Connected
==
AcceleratorUtils
.
state
)
{
agentWeb
.
jsAccessEntrace
agentWeb
.
jsAccessEntrace
.
quickCallJs
(
callback
,
"1"
)
.
quickCallJs
(
callback
,
"1"
)
}
else
{
}
else
{
agentWeb
.
jsAccessEntrace
agentWeb
.
jsAccessEntrace
.
quickCallJs
(
callback
,
"0"
)
.
quickCallJs
(
callback
,
"0"
)
}
}
}
}
...
@@ -195,7 +200,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
...
@@ -195,7 +200,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
@JavascriptInterface
@JavascriptInterface
fun
getSmartAccStatus
(
callback
:
String
)
{
fun
getSmartAccStatus
(
callback
:
String
)
{
agentWeb
.
getJsAccessEntrace
()
agentWeb
.
getJsAccessEntrace
()
.
quickCallJs
(
callback
,
AuthManager
.
isSmartAccOpen
.
toString
())
.
quickCallJs
(
callback
,
AuthManager
.
isSmartAccOpen
.
toString
())
}
}
/**
/**
...
@@ -215,7 +220,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
...
@@ -215,7 +220,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
xPageFragment
.
context
?.
let
{
xPageFragment
.
context
?.
let
{
val
hasPermission
:
Boolean
=
PermissionUtils
.
isGranted
(
key
)
val
hasPermission
:
Boolean
=
PermissionUtils
.
isGranted
(
key
)
agentWeb
.
getJsAccessEntrace
()
agentWeb
.
getJsAccessEntrace
()
.
quickCallJs
(
callback
,
key
,
hasPermission
.
toString
())
.
quickCallJs
(
callback
,
key
,
hasPermission
.
toString
())
}
}
}
}
...
@@ -232,20 +237,20 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
...
@@ -232,20 +237,20 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
permissionsGranted
?.
forEach
{
permissionsGranted
?.
forEach
{
if
(
it
.
equals
(
key
))
{
if
(
it
.
equals
(
key
))
{
agentWeb
.
getJsAccessEntrace
()
agentWeb
.
getJsAccessEntrace
()
.
quickCallJs
(
callback
,
key
,
"true"
)
.
quickCallJs
(
callback
,
key
,
"true"
)
}
}
}
}
}
}
override
fun
onDenied
(
override
fun
onDenied
(
permissionsDeniedForever
:
MutableList
<
String
>?,
permissionsDeniedForever
:
MutableList
<
String
>?,
permissionsDenied
:
MutableList
<
String
>?
permissionsDenied
:
MutableList
<
String
>?
)
{
)
{
permissionsDenied
?.
forEach
{
permissionsDenied
?.
forEach
{
if
(
it
.
equals
(
key
))
{
if
(
it
.
equals
(
key
))
{
agentWeb
.
getJsAccessEntrace
()
agentWeb
.
getJsAccessEntrace
()
.
quickCallJs
(
callback
,
key
,
"false"
)
.
quickCallJs
(
callback
,
key
,
"false"
)
}
}
}
}
permissionsDeniedForever
?.
forEach
{
permissionsDeniedForever
?.
forEach
{
...
@@ -268,7 +273,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
...
@@ -268,7 +273,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
xPageFragment
.
context
?.
let
{
xPageFragment
.
context
?.
let
{
val
packageInstall
=
SysUtils
.
isPackageInstall
(
it
,
packageName
)
val
packageInstall
=
SysUtils
.
isPackageInstall
(
it
,
packageName
)
agentWeb
.
getJsAccessEntrace
()
agentWeb
.
getJsAccessEntrace
()
.
quickCallJs
(
callback
,
packageName
,
packageInstall
.
toString
())
.
quickCallJs
(
callback
,
packageName
,
packageInstall
.
toString
())
}
}
}
}
...
@@ -294,11 +299,11 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
...
@@ -294,11 +299,11 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
@JavascriptInterface
@JavascriptInterface
fun
getVersion
(
callback
:
String
)
{
fun
getVersion
(
callback
:
String
)
{
agentWeb
.
getJsAccessEntrace
()
agentWeb
.
getJsAccessEntrace
()
.
quickCallJs
(
.
quickCallJs
(
callback
,
callback
,
AppUtils
.
getAppVersionName
(),
AppUtils
.
getAppVersionName
(),
AppUtils
.
getAppVersionCode
().
toString
()
AppUtils
.
getAppVersionCode
().
toString
()
)
)
}
}
/****************
/****************
...
@@ -317,12 +322,12 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
...
@@ -317,12 +322,12 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
@JavascriptInterface
@JavascriptInterface
fun
getSystemVersion
(
callback
:
String
)
{
fun
getSystemVersion
(
callback
:
String
)
{
agentWeb
.
getJsAccessEntrace
()
agentWeb
.
getJsAccessEntrace
()
.
quickCallJs
(
.
quickCallJs
(
callback
,
callback
,
android
.
os
.
Build
.
VERSION
.
RELEASE
,
android
.
os
.
Build
.
VERSION
.
RELEASE
,
SysUtils
.
getDpi
(
xPageFragment
).
toString
(),
SysUtils
.
getDpi
(
xPageFragment
).
toString
(),
android
.
os
.
Build
.
VERSION
.
SDK_INT
.
toString
()
android
.
os
.
Build
.
VERSION
.
SDK_INT
.
toString
()
)
)
}
}
/**
/**
...
@@ -331,7 +336,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
...
@@ -331,7 +336,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
@JavascriptInterface
@JavascriptInterface
fun
getDpi
(
callback
:
String
)
{
fun
getDpi
(
callback
:
String
)
{
agentWeb
.
getJsAccessEntrace
()
agentWeb
.
getJsAccessEntrace
()
.
quickCallJs
(
callback
,
SysUtils
.
getDpi
(
xPageFragment
).
toString
())
.
quickCallJs
(
callback
,
SysUtils
.
getDpi
(
xPageFragment
).
toString
())
}
}
@JavascriptInterface
@JavascriptInterface
...
@@ -353,5 +358,12 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
...
@@ -353,5 +358,12 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
}
}
}
}
@JavascriptInterface
fun
downloadFile
(
url
:
String
)
{
xPageFragment
.
activity
?.
let
{
SysUtils
.
downloadFile
(
it
,
url
)
}
}
}
}
\ No newline at end of file
app/src/main/java/com/ccwangluo/accelerator/ui/web/CommonWebViewFragment.kt
View file @
7a1afc91
...
@@ -10,6 +10,7 @@ import android.widget.FrameLayout
...
@@ -10,6 +10,7 @@ import android.widget.FrameLayout
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.Fragment
import
com.ccwangluo.accelerator.databinding.FragmentWebviewBinding
import
com.ccwangluo.accelerator.databinding.FragmentWebviewBinding
import
com.ccwangluo.accelerator.utils.LoginUtils
import
com.ccwangluo.accelerator.utils.LoginUtils
import
com.ccwangluo.accelerator.utils.SysUtils
import
com.github.shadowsocks.http.HttpConfig
import
com.github.shadowsocks.http.HttpConfig
import
com.just.agentweb.core.AgentWeb
import
com.just.agentweb.core.AgentWeb
import
com.just.agentweb.core.client.DefaultWebClient
import
com.just.agentweb.core.client.DefaultWebClient
...
@@ -34,15 +35,18 @@ class CommonWebViewFragment : XPageFragment() {
...
@@ -34,15 +35,18 @@ class CommonWebViewFragment : XPageFragment() {
override
fun
initViews
()
{
override
fun
initViews
()
{
val
url
=
arguments
?.
getString
(
WEBVIEW_URL_KEY
)
val
url
=
arguments
?.
getString
(
WEBVIEW_URL_KEY
)
val
noNeedToken
=
arguments
?.
getBoolean
(
NOEEDTOKEN
)
?:
false
agentWeb
=
agentWeb
=
url
?.
let
{
url
?.
let
{
var
weburl
=
it
var
weburl
=
it
LoginUtils
.
token
?.
let
{
if
(!
noNeedToken
)
{
if
(
weburl
.
contains
(
"?"
))
{
if
(
weburl
.
contains
(
"?"
))
{
weburl
=
weburl
+
"&
token=$it
"
weburl
=
weburl
+
"&
channel=${SysUtils.getChannel()}
"
}
else
{
}
else
{
weburl
=
weburl
+
"?token=$it"
weburl
=
weburl
+
"?channel=${SysUtils.getChannel()}"
}
LoginUtils
.
token
?.
let
{
weburl
=
weburl
+
"&token=${it}"
}
}
}
}
createAgentWeb
(
this
,
binding
.
commonWebview
,
weburl
)
createAgentWeb
(
this
,
binding
.
commonWebview
,
weburl
)
...
@@ -131,6 +135,7 @@ class CommonWebViewFragment : XPageFragment() {
...
@@ -131,6 +135,7 @@ class CommonWebViewFragment : XPageFragment() {
companion
object
{
companion
object
{
var
WEBVIEW_URL_KEY
=
"WEBVIEW_URL_KEY"
val
WEBVIEW_URL_KEY
=
"WEBVIEW_URL_KEY"
val
NOEEDTOKEN
=
"NOEEDTOKEN"
}
}
}
}
\ No newline at end of file
app/src/main/java/com/ccwangluo/accelerator/utils/LoginUtils.kt
View file @
7a1afc91
...
@@ -107,7 +107,7 @@ object LoginUtils {
...
@@ -107,7 +107,7 @@ object LoginUtils {
fun
login
(
context
:
Context
,
callBack
:
(
Boolean
)
->
Unit
)
{
fun
login
(
context
:
Context
,
callBack
:
(
Boolean
)
->
Unit
)
{
PhoneUtils
.
openLoginAuth
(
context
)
{
b
,
s
->
PhoneUtils
.
openLoginAuth
(
context
)
{
b
,
s
->
if
(
b
)
{
if
(
b
)
{
val
map
=
mutableMapOf
<
String
,
String
>()
val
map
=
mutableMapOf
<
String
,
Any
>()
map
.
put
(
"token"
,
s
)
map
.
put
(
"token"
,
s
)
SysUtils
.
getDeviceUUID
()
?.
let
{
map
.
put
(
"did"
,
it
)
}
SysUtils
.
getDeviceUUID
()
?.
let
{
map
.
put
(
"did"
,
it
)
}
GlobalScope
.
launch
(
Dispatchers
.
IO
)
{
GlobalScope
.
launch
(
Dispatchers
.
IO
)
{
...
...
app/src/main/java/com/ccwangluo/accelerator/utils/SettingSPUtils.kt
View file @
7a1afc91
...
@@ -13,6 +13,13 @@ object SettingSPUtils {
...
@@ -13,6 +13,13 @@ object SettingSPUtils {
private
val
IS_AGREE_PRIVACY_KEY
=
"is_agree_privacy_key"
private
val
IS_AGREE_PRIVACY_KEY
=
"is_agree_privacy_key"
private
val
IS_SMART_ACC_OPEN
=
"is_smart_acc_open"
private
val
IS_SMART_ACC_OPEN
=
"is_smart_acc_open"
private
val
LAST_APP_SRART_TIME
=
"LAST_APP_SRART_TIME"
private
val
LAST_APP_SRART_TIME
=
"LAST_APP_SRART_TIME"
private
val
CHANNEL_KEY
=
"CHANNEL_KEY"
var
channel
:
Int
get
()
=
MMKV
.
defaultMMKV
().
decodeInt
(
CHANNEL_KEY
,
0
)
set
(
channel
)
{
MMKV
.
defaultMMKV
().
putInt
(
CHANNEL_KEY
,
channel
)
}
/**
/**
...
@@ -34,7 +41,7 @@ object SettingSPUtils {
...
@@ -34,7 +41,7 @@ object SettingSPUtils {
}
}
var
lastAPPOpenReportTime
:
Long
var
lastAPPOpenReportTime
:
Long
get
()
=
MMKV
.
defaultMMKV
().
decodeLong
(
LAST_APP_SRART_TIME
,
0L
)
get
()
=
MMKV
.
defaultMMKV
().
decodeLong
(
LAST_APP_SRART_TIME
,
0L
)
set
(
lastAPPOpenReportTime
)
{
set
(
lastAPPOpenReportTime
)
{
MMKV
.
defaultMMKV
().
putLong
(
LAST_APP_SRART_TIME
,
lastAPPOpenReportTime
)
MMKV
.
defaultMMKV
().
putLong
(
LAST_APP_SRART_TIME
,
lastAPPOpenReportTime
)
}
}
...
...
app/src/main/java/com/ccwangluo/accelerator/utils/SysUtils.kt
View file @
7a1afc91
package
com.ccwangluo.accelerator.utils
package
com.ccwangluo.accelerator.utils
import
android.content.Context
import
android.content.pm.PackageManager
import
android.text.TextUtils
import
android.util.DisplayMetrics
import
com.xuexiang.xpage.base.XPageFragment
import
com.xuexiang.xutil.net.NetworkUtils
import
java.text.SimpleDateFormat
import
java.util.*
import
kotlin.collections.ArrayList
import
android.app.DownloadManager
import
android.app.DownloadManager
import
android.content.Context
import
android.content.Context.DOWNLOAD_SERVICE
import
android.content.Intent
import
android.content.Intent
import
android.net.*
import
android.content.pm.PackageInfo
import
android.net.ConnectivityManager
import
android.net.NetworkCapabilities
import
android.net.Uri
import
android.os.Build
import
android.os.Build
import
android.os.Environment
import
android.text.TextUtils
import
android.util.DisplayMetrics
import
androidx.fragment.app.FragmentActivity
import
com.ccwangluo.accelerator.ui.dialog.DownloadDialog
import
com.ccwangluo.cc_quickly.utils.SettingSPUtils
import
com.hjq.toast.ToastUtils
import
com.hjq.toast.ToastUtils
import
com.mcxiaoke.packer.helper.PackerNg
import
com.sdk.base.framework.bean.PInfo
import
com.tencent.mmkv.MMKV
import
com.tencent.mmkv.MMKV
import
com.xuexiang.xpage.base.XPageActivity
import
com.xuexiang.xpage.base.XPageActivity
import
com.xuexiang.xpage.base.XPageFragment
import
com.xuexiang.xutil.app.AppUtils
import
com.xuexiang.xutil.app.AppUtils
import
com.xuexiang.xutil.net.NetworkUtils
import
com.xuexiang.xutil.system.DeviceUtils
import
com.xuexiang.xutil.system.DeviceUtils
import
java.lang.Exception
import
java.text.SimpleDateFormat
import
java.util.*
object
SysUtils
{
object
SysUtils
{
...
@@ -59,7 +66,7 @@ object SysUtils {
...
@@ -59,7 +66,7 @@ object SysUtils {
* 判断包是否安装
* 判断包是否安装
*/
*/
fun
isPackageInstall
(
context
:
Context
,
packageName
:
String
):
Boolean
{
fun
isPackageInstall
(
context
:
Context
,
packageName
:
String
):
Boolean
{
return
AppUtils
.
isInstallApp
(
packageName
)
return
AppUtils
.
isInstallApp
(
packageName
)
}
}
fun
getnetQuality
(
delay
:
Int
):
String
{
fun
getnetQuality
(
delay
:
Int
):
String
{
...
@@ -100,13 +107,54 @@ object SysUtils {
...
@@ -100,13 +107,54 @@ object SysUtils {
return
(
dm
.
density
*
160
)
return
(
dm
.
density
*
160
)
}
}
fun
downloadFile
(
context
:
Context
,
url
:
String
)
{
fun
getChannel
():
Int
{
val
request
=
DownloadManager
.
Request
(
Uri
.
parse
(
url
))
return
SettingSPUtils
.
channel
request
.
setDestinationInExternalPublicDir
(
""
,
url
.
substring
(
url
.
lastIndexOf
(
"/"
)
+
1
))
// return 4
val
downloadManager
=
context
.
getSystemService
(
Context
.
DOWNLOAD_SERVICE
)
as
DownloadManager
}
downloadManager
.
enqueue
(
request
)
fun
initChannel
(
context
:
Context
)
{
val
channel
=
PackerNg
.
getChannel
(
context
)
if
(!
channel
.
isNullOrBlank
())
{
SettingSPUtils
.
channel
=
when
(
channel
)
{
"guanwang"
->
1
"huawei"
->
2
"xiaomi"
->
3
"vivo"
->
4
"yingyongbao"
->
5
"OPPO"
->
6
"baiduzhushou"
->
7
else
->
0
}
}
}
}
fun
downloadFile
(
activity
:
FragmentActivity
,
url
:
String
)
{
val
downloadManager
=
activity
.
getSystemService
(
DOWNLOAD_SERVICE
)
as
DownloadManager
val
request
=
DownloadManager
.
Request
(
Uri
.
parse
(
url
))
//添加下载文件的网络路径
var
filename
=
url
.
split
(
"/"
).
last
()
ToastUtils
.
show
(
"开始下载"
)
request
.
setDestinationInExternalPublicDir
(
Environment
.
DIRECTORY_DOWNLOADS
,
filename
)
//添加保存文件路径与名称
request
.
setTitle
(
"下载中"
)
//添加在通知栏里显示的标题
// request.setDescription("下载中") //添加在通知栏里显示的描述
request
.
setAllowedNetworkTypes
(
DownloadManager
.
Request
.
NETWORK_MOBILE
or
DownloadManager
.
Request
.
NETWORK_WIFI
)
//设置下载的网络类型
request
.
setVisibleInDownloadsUi
(
false
)
//是否显示下载 从Android Q开始会被忽略
request
.
setNotificationVisibility
(
DownloadManager
.
Request
.
VISIBILITY_VISIBLE_NOTIFY_COMPLETED
)
//下载中与下载完成后都会在通知中显示| 另外可以选 DownloadManager.Request.VISIBILITY_VISIBLE 仅在下载中时显示在通知中,完成后会自动隐藏
val
id
=
downloadManager
.
enqueue
(
request
)
//加入队列,会返回一个唯一下载id
DownloadDialog
(
activity
,
downloadManager
,
id
).
show
()
}
fun
joinQQGroup
(
context
:
Context
)
{
fun
joinQQGroup
(
context
:
Context
)
{
val
key
=
"5CmyFzMWyucgmmLTM7JLG_sSArmaFQxT"
val
key
=
"5CmyFzMWyucgmmLTM7JLG_sSArmaFQxT"
...
@@ -164,4 +212,21 @@ object SysUtils {
...
@@ -164,4 +212,21 @@ object SysUtils {
private
fun
loadDeviceUUID
():
String
?
{
private
fun
loadDeviceUUID
():
String
?
{
return
MMKV
.
defaultMMKV
().
decodeString
(
"device_uuid"
,
null
)
return
MMKV
.
defaultMMKV
().
decodeString
(
"device_uuid"
,
null
)
}
}
fun
getInstalledApps
(
context
:
Context
,
packageName
:
String
):
Int
{
val
packs
:
List
<
PackageInfo
>
=
context
.
getPackageManager
().
getInstalledPackages
(
0
)
for
(
i
in
packs
.
indices
)
{
val
p
=
packs
[
i
]
if
(
p
.
versionName
==
null
)
{
continue
}
if
(
packageName
.
equals
(
p
.
packageName
)){
return
p
.
versionCode
}
}
return
-
1
}
}
}
\ No newline at end of file
app/src/main/java/com/ccwangluo/accelerator/utils/datareport/BaseData.kt
View file @
7a1afc91
...
@@ -6,7 +6,7 @@ import com.google.gson.JsonObject
...
@@ -6,7 +6,7 @@ import com.google.gson.JsonObject
import
java.time.LocalDateTime
import
java.time.LocalDateTime
data class
BaseData
(
data class
BaseData
(
var
channel
:
Int
=
0
,
var
channel
:
Int
=
SysUtils
.
getChannel
()
,
var
client_ip
:
String
=
"127.0.0.1"
,
var
client_ip
:
String
=
"127.0.0.1"
,
var
did
:
String
?
=
SysUtils
.
getDeviceUUID
(),
var
did
:
String
?
=
SysUtils
.
getDeviceUUID
(),
var
ds
:
String
=
LocalDateTime
.
now
().
toString
(),
var
ds
:
String
=
LocalDateTime
.
now
().
toString
(),
...
...
app/src/main/java/com/ccwangluo/accelerator/utils/http/HttpGo.kt
View file @
7a1afc91
...
@@ -2,6 +2,7 @@ package com.ccwangluo.accelerator.utils.http
...
@@ -2,6 +2,7 @@ package com.ccwangluo.accelerator.utils.http
import
com.ccwangluo.accelerator.model.BaseModel
import
com.ccwangluo.accelerator.model.BaseModel
import
com.ccwangluo.accelerator.utils.LoginUtils
import
com.ccwangluo.accelerator.utils.LoginUtils
import
com.ccwangluo.accelerator.utils.SysUtils
import
com.ccwangluo.accelerator.utils.datareport.BaseData
import
com.ccwangluo.accelerator.utils.datareport.BaseData
import
com.github.shadowsocks.http.HttpConfig
import
com.github.shadowsocks.http.HttpConfig
import
com.google.gson.Gson
import
com.google.gson.Gson
...
@@ -87,9 +88,10 @@ object HttpGo {
...
@@ -87,9 +88,10 @@ object HttpGo {
*/
*/
inline
fun
<
reified
T
>
postSync
(
inline
fun
<
reified
T
>
postSync
(
url
:
String
,
url
:
String
,
param
:
MutableMap
<
String
,
out
Any
>
param
:
MutableMap
<
String
,
Any
>
):
BaseModel
<
T
>?
{
):
BaseModel
<
T
>?
{
try
{
try
{
addCommonParams
(
param
)
val
body
:
RequestBody
=
gson
.
toJson
(
param
).
toString
().
toRequestBody
(
jsonType
)
val
body
:
RequestBody
=
gson
.
toJson
(
param
).
toString
().
toRequestBody
(
jsonType
)
val
request
=
Request
.
Builder
()
val
request
=
Request
.
Builder
()
.
url
(
HttpConfig
.
baseUrl
+
url
)
.
url
(
HttpConfig
.
baseUrl
+
url
)
...
@@ -120,6 +122,10 @@ object HttpGo {
...
@@ -120,6 +122,10 @@ object HttpGo {
return
null
return
null
}
}
fun
addCommonParams
(
param
:
MutableMap
<
String
,
Any
>){
param
.
put
(
"channel"
,
SysUtils
.
getChannel
().
toString
())
}
/**
/**
* 异步请求 (专用于数据上报)
* 异步请求 (专用于数据上报)
*/
*/
...
@@ -150,6 +156,8 @@ object HttpGo {
...
@@ -150,6 +156,8 @@ object HttpGo {
}
}
private
fun
initSSLSocketFactory
():
SSLSocketFactory
{
private
fun
initSSLSocketFactory
():
SSLSocketFactory
{
var
sslContext
:
SSLContext
?
=
null
var
sslContext
:
SSLContext
?
=
null
try
{
try
{
...
...
app/src/main/res/values/styles.xml
View file @
7a1afc91
...
@@ -6,12 +6,24 @@
...
@@ -6,12 +6,24 @@
<item
name=
"android:windowIsFloating"
>
true
</item>
<item
name=
"android:windowIsFloating"
>
true
</item>
<item
name=
"android:windowIsTranslucent"
>
false
</item>
<item
name=
"android:windowIsTranslucent"
>
false
</item>
<item
name=
"android:windowNoTitle"
>
true
</item>
<!--隐藏标题栏-->
<item
name=
"android:windowNoTitle"
>
true
</item>
<!--隐藏标题栏-->
<item
name=
"android:background"
>
@color/transparent
</item>
<item
name=
"android:background"
>
@color/white
</item>
<item
name=
"android:windowBackground"
>
@color/transparent
<item
name=
"android:textColor"
>
@color/black
</item>
</item>
<!--这儿也很重要啊,我这儿用了一张透明的.9.png的图,当然用#00000000也是可以的,否则的话这儿出来后有一个黑色的背景-->
<item
name=
"colorPrimary"
>
@color/black
</item>
<item
name=
"buttonBarButtonStyle"
>
@style/ButtonStyle
</item>
<item
name=
"android:textColorPrimary"
>
@color/black
</item>
<item
name=
"android:windowBackground"
>
#00000000
</item>
<!--这儿也很重要啊,我这儿用了一张透明的.9.png的图,当然用#00000000也是可以的,否则的话这儿出来后有一个黑色的背景-->
<item
name=
"android:backgroundDimEnabled"
>
false
</item>
<item
name=
"android:backgroundDimEnabled"
>
false
</item>
</style>
</style>
<style
name=
"ButtonStyle"
>
<item
name=
"android:layout_width"
>
?attr/xui_btn_view_width
</item>
<item
name=
"android:layout_height"
>
?attr/xui_btn_view_height
</item>
<item
name=
"android:textSize"
>
?attr/xui_btn_view_text_size
</item>
<item
name=
"android:textColor"
>
@color/black
</item>
<item
name=
"android:gravity"
>
center
</item>
<item
name=
"android:background"
>
@color/white
</item>
</style>
<style
name=
"MyTablayoutstyle"
parent=
"Base.Widget.Design.TabLayout"
>
<style
name=
"MyTablayoutstyle"
parent=
"Base.Widget.Design.TabLayout"
>
<item
name=
"tabIndicatorHeight"
>
0dp
</item>
<item
name=
"tabIndicatorHeight"
>
0dp
</item>
<item
name=
"tabSelectedTextColor"
>
@color/black
</item>
<item
name=
"tabSelectedTextColor"
>
@color/black
</item>
...
...
app/src/main/res/values/themes.xml
View file @
7a1afc91
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
<style
name=
"Theme.Cc_quickly"
parent=
"Theme.AppCompat.Light.NoActionBar"
>
<style
name=
"Theme.Cc_quickly"
parent=
"Theme.AppCompat.Light.NoActionBar"
>
<!-- Primary brand color. -->
<!-- Primary brand color. -->
<item
name=
"colorPrimaryVariant"
>
@color/purple_700
</item>
<item
name=
"colorPrimaryVariant"
>
@color/purple_700
</item>
<item
name=
"colorOnPrimary"
>
@color/
white
</item>
<item
name=
"colorOnPrimary"
>
@color/
black
</item>
<!-- Secondary brand color. -->
>
<!-- Secondary brand color. -->
>
<item
name=
"colorOnSecondary"
>
@color/black
</item>
<item
name=
"colorOnSecondary"
>
@color/black
</item>
<!-- Status bar color. -->
<!-- Status bar color. -->
...
@@ -49,12 +49,15 @@
...
@@ -49,12 +49,15 @@
<item
name=
"xpage_actionbar_side_text_padding"
>
16dp
</item>
<item
name=
"xpage_actionbar_side_text_padding"
>
16dp
</item>
<item
name=
"XPageTitleBarStyle"
>
@style/XPageTitleBar.Custom
</item>
<item
name=
"XPageTitleBarStyle"
>
@style/XPageTitleBar.Custom
</item>
<item
name=
"alertDialogTheme"
>
@style/DialogTheme
</item>
</style>
</style>
<style
name=
"XPageTitleBar.Custom"
>
<style
name=
"XPageTitleBar.Custom"
>
<item
name=
"tb_immersive"
>
false
</item>
<item
name=
"tb_immersive"
>
false
</item>
<item
name=
"tb_centerGravity"
>
center
</item>
<item
name=
"tb_centerGravity"
>
center
</item>
</style>
</style>
<style
name=
"btn_checkbox"
parent=
"@android:style/Widget.CompoundButton.CheckBox"
>
<style
name=
"btn_checkbox"
parent=
"@android:style/Widget.CompoundButton.CheckBox"
>
...
...
app/src/main/res/xml/filepaths.xml
View file @
7a1afc91
...
@@ -4,4 +4,5 @@
...
@@ -4,4 +4,5 @@
<!-- QQ 官方分享SDK 共享路径 -->
<!-- QQ 官方分享SDK 共享路径 -->
<root-path
name=
"opensdk_root"
path=
""
/>
<root-path
name=
"opensdk_root"
path=
""
/>
<external-files-path
name=
"opensdk_external"
path=
"Images/tmp"
/>
<external-files-path
name=
"opensdk_external"
path=
"Images/tmp"
/>
<external-path
name=
"external_storage_root"
path=
"."
/>
</paths>
</paths>
\ No newline at end of file
build.gradle.kts
View file @
7a1afc91
...
@@ -23,6 +23,7 @@ buildscript {
...
@@ -23,6 +23,7 @@ buildscript {
classpath
(
"com.vanniktech:gradle-maven-publish-plugin:0.14.2"
)
classpath
(
"com.vanniktech:gradle-maven-publish-plugin:0.14.2"
)
classpath
(
"org.jetbrains.dokka:dokka-gradle-plugin:1.4.32"
)
classpath
(
"org.jetbrains.dokka:dokka-gradle-plugin:1.4.32"
)
classpath
(
"org.mozilla.rust-android-gradle:plugin:0.8.6"
)
classpath
(
"org.mozilla.rust-android-gradle:plugin:0.8.6"
)
classpath
(
"com.mcxiaoke.packer-ng:plugin:2.0.1"
)
}
}
}
}
...
@@ -40,3 +41,4 @@ subprojects {
...
@@ -40,3 +41,4 @@ subprojects {
if
(
name
.
contains
(
"uploadCrashlyticsMappingFile"
))
enabled
=
false
if
(
name
.
contains
(
"uploadCrashlyticsMappingFile"
))
enabled
=
false
}
}
}
}
buildSrc/src/main/kotlin/Helpers.kt
View file @
7a1afc91
...
@@ -94,6 +94,7 @@ fun Project.setupApp() {
...
@@ -94,6 +94,7 @@ fun Project.setupApp() {
splits
.
abi
{
splits
.
abi
{
isEnable
=
true
isEnable
=
true
isUniversalApk
=
true
isUniversalApk
=
true
include
(
"armeabi-v7a"
,
"arm64-v8a"
)
}
}
}
}
...
...
channels.txt
0 → 100644
View file @
7a1afc91
guanwang
huawei
xiaomi
vivo
yingyongbao
OPPO
baiduzhushou
\ No newline at end of file
tools/packer-ng-2.0.1.jar
0 → 100644
View file @
7a1afc91
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment