Compare commits
207 Commits
pack/v5.35
...
revert-a02
| Author | SHA1 | Date | |
|---|---|---|---|
| 28c4935c59 | |||
| a027442ae6 | |||
| ba1584f642 | |||
| 4124d571b7 | |||
| a545401ca3 | |||
| 4b7f2401dd | |||
| daa1e4fc64 | |||
| 064135a057 | |||
| b56946d6f0 | |||
| 1a46d371e4 | |||
| d2a062907a | |||
| 56e945eb43 | |||
| 91579194a4 | |||
| c42a7d5963 | |||
| d2293bd881 | |||
| 24d95b8e95 | |||
| 435dac11a1 | |||
| bffa2dab7f | |||
| 136975c067 | |||
| f389fcc206 | |||
| 9c5ef246a4 | |||
| 5f71f52fe1 | |||
| 2bfa0c1031 | |||
| 97c9dd9923 | |||
| cc3733e6fe | |||
| cacdc13b9a | |||
| ab3ebd7b37 | |||
| 08879b63da | |||
| ca8d41bac2 | |||
| 31c54b8f3b | |||
| 038da5dae2 | |||
| 3bcf332dfa | |||
| ee7723a4d8 | |||
| aed68e3268 | |||
| 6902e748e4 | |||
| fa9186cb54 | |||
| 119a684112 | |||
| 72d8016c4b | |||
| 6569eecbb1 | |||
| 83cb925be2 | |||
| a98b54269a | |||
| 570cf800e5 | |||
| 83ec4414f9 | |||
| 004bd3421a | |||
| f365a80a84 | |||
| ff078ab2a1 | |||
| 0ba49550b3 | |||
| 251e867833 | |||
| ca20d7e2a3 | |||
| 8fb4b373d3 | |||
| 58fa40fe08 | |||
| cd4f2783b5 | |||
| 4ee735b8cd | |||
| 605b886315 | |||
| 54eb44d072 | |||
| 5866b0d28a | |||
| 9f47f30f38 | |||
| dcb3fa3910 | |||
| 12bbd008d8 | |||
| 49b35b2837 | |||
| 1269560541 | |||
| a788b7b485 | |||
| f47a2db92b | |||
| aa41551c4e | |||
| 813634379a | |||
| e884e9b45a | |||
| e86a301d10 | |||
| 89bdafe7ed | |||
| 8dc4b86790 | |||
| 989d1578ef | |||
| ba3b86a00e | |||
| 2a279762e1 | |||
| 574ae0eece | |||
| 9412c255eb | |||
| c2c6901b04 | |||
| e8cca4b491 | |||
| b4e2685f19 | |||
| 8f9c5fac95 | |||
| e28a4a8fed | |||
| 45b4d1214e | |||
| a7dc78b969 | |||
| 11a0d55d12 | |||
| 398ff16f76 | |||
| 5d7056735a | |||
| 3bd0444dde | |||
| 4d2d3d24ee | |||
| 7310056d2e | |||
| 5cf8b80ea4 | |||
| bf5b7ced89 | |||
| b1e44ea89b | |||
| 1f5b9bde3e | |||
| c57063bcfe | |||
| 5fd7d0bb62 | |||
| a45d6ce0b4 | |||
| dcff648d37 | |||
| 513938da99 | |||
| 6490111940 | |||
| 56437855d8 | |||
| 29facb49df | |||
| f023a315b9 | |||
| b9d217d773 | |||
| cbdab7cd50 | |||
| 5b2f710be8 | |||
| b15dafb852 | |||
| 37b36a9632 | |||
| 17495e3699 | |||
| d9ee277e82 | |||
| bb6bdb1351 | |||
| 204300ca98 | |||
| 24815cd398 | |||
| b963281eb6 | |||
| 95721268f7 | |||
| dfd542f5df | |||
| 14522e5d07 | |||
| 71efe3b69a | |||
| b8cbbc0301 | |||
| 2fe8051280 | |||
| 0d4a893552 | |||
| e07216365a | |||
| 1c04e966d9 | |||
| ba0ad10f61 | |||
| 9592731033 | |||
| 0dc9fb1aa3 | |||
| fd450f0d67 | |||
| 57984d160f | |||
| 165ca21926 | |||
| e19c091532 | |||
| 5db6b3511f | |||
| 8557b230ac | |||
| 44a817be12 | |||
| c76e0b8bfa | |||
| bbbd77b8ab | |||
| 08ab5ec727 | |||
| 39afbecce8 | |||
| 4229f0e335 | |||
| efae6cb459 | |||
| 8f8cfb757f | |||
| 1e894e1158 | |||
| 96b479b8f0 | |||
| 342eefe7ba | |||
| e9c9f6f66b | |||
| 7da90ffb0b | |||
| c71f8676dd | |||
| 50555cb217 | |||
| 766e4fc3ab | |||
| c091e496e7 | |||
| ecd81ea353 | |||
| 21e7198589 | |||
| d6c97bc215 | |||
| 321e9b6ee6 | |||
| 7cc3e7ec67 | |||
| 08dac2eb42 | |||
| 85c7746206 | |||
| a35700e2f7 | |||
| 6a44294338 | |||
| b8c275d8fc | |||
| 638bf86d1e | |||
| 158c46f210 | |||
| a28ef7d20b | |||
| bae20a4e7d | |||
| 4a2f0896bb | |||
| 51ccc532d5 | |||
| 1bf977f3e4 | |||
| da2aeeeaf2 | |||
| 52d160a0e0 | |||
| cbba9c09b5 | |||
| 3c877ada98 | |||
| 9b95e01d33 | |||
| 567576fc04 | |||
| 1b7913a00e | |||
| 05e2719e1c | |||
| 8ed10c411a | |||
| f9f4bb84b4 | |||
| 44a2e616ab | |||
| fffd3ef789 | |||
| d53782b8de | |||
| b16c5d723b | |||
| 1dfd636283 | |||
| 65feed01f4 | |||
| 2a596bd2a0 | |||
| 16c4f1016c | |||
| 1ced82c1f6 | |||
| 078c9204af | |||
| 68818b3409 | |||
| 7d4aa34d12 | |||
| 209c3d7d30 | |||
| 2a27e0f467 | |||
| 155ec08280 | |||
| 43eb4c88c9 | |||
| 195247a5c3 | |||
| dd65bc8bc2 | |||
| b1c267b179 | |||
| a2679c8dbd | |||
| c9e1816be0 | |||
| a1f0455d5a | |||
| 5b3f4b6104 | |||
| fe4e9d9d3b | |||
| 9488837e9e | |||
| ccc0140bba | |||
| 2c044d0ee4 | |||
| 5201637326 | |||
| 417c41c8a0 | |||
| af67894d4e | |||
| f8c9c41eb0 | |||
| 40ac173389 | |||
| c6bc7ca6cc | |||
| bdccbc4c28 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -9,4 +9,6 @@ build/
|
||||
release-app/
|
||||
test-app/
|
||||
scripts/apk-channel/
|
||||
app/src/test/java/com/gh/gamecenter
|
||||
app/src/test/java/com/gh/gamecenter
|
||||
app/src/main/assets-debug/
|
||||
app/src/main/assets-release/
|
||||
@ -72,6 +72,7 @@ android_build:
|
||||
only:
|
||||
- dev
|
||||
- release
|
||||
- feature-GHZS-5816
|
||||
|
||||
# 代码检查
|
||||
sonarqube_analysis:
|
||||
@ -152,4 +153,5 @@ oss-upload&send-email:
|
||||
- /usr/local/bin/python /ci-android-mail-jira-comment.py
|
||||
only:
|
||||
- dev
|
||||
- release
|
||||
- release
|
||||
- feature-GHZS-5816
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -8,3 +8,6 @@
|
||||
[submodule "ndownload"]
|
||||
path = ndownload
|
||||
url = ../../../android/ndownload.git
|
||||
[submodule "vasdk"]
|
||||
path = vasdk
|
||||
url = ../../../sdg/android/vasdk.git
|
||||
|
||||
@ -44,5 +44,4 @@
|
||||
|
||||
### 混淆配置
|
||||
|
||||
* 本项目使用了微信的 [AndResGuard](https://github.com/shwenzhang/AndResGuard) 作为资源混淆压缩方案,新增需要使用 `getIdentifier` 获取的资源文件时需要添加至白名单
|
||||
* 本项目默认使用 R8 作为混淆工具,往 proguard-rules.txt 添加 proguard 新配置项时请检查可用性(如语法等)
|
||||
|
||||
233
app/build.gradle
233
app/build.gradle
@ -3,7 +3,6 @@ apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android' // kotlin
|
||||
apply plugin: 'kotlin-parcelize'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'AndResGuard'
|
||||
|
||||
import groovy.xml.XmlUtil
|
||||
|
||||
@ -75,7 +74,7 @@ android {
|
||||
versionName rootProject.ext.versionName
|
||||
applicationId rootProject.ext.applicationId
|
||||
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt', 'proguard-fresco.txt'
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt', 'proguard-fresco.txt', rootProject.ext.va_proguard_rules
|
||||
|
||||
String CORE_EVENT_GAME_CATEGORY = ""
|
||||
|
||||
@ -106,6 +105,9 @@ android {
|
||||
buildConfigField "String", "WECHAT_SECRET", "\"${WECHAT_SECRET}\""
|
||||
buildConfigField "String", "TENCENT_APPID", "\"${TENCENT_APPID}\""
|
||||
buildConfigField "String", "WEIBO_APPKEY", "\"${WEIBO_APPKEY}\""
|
||||
// 一体包的32位畅玩游戏助手包名
|
||||
buildConfigField "String", "EXT_PACKAGE_NAME", "\"${rootProject.ext.EXT_PACKAGE_NAME}\""
|
||||
buildConfigField "String", "VA_VERSION_NAME", "\"${rootProject.ext.VA_VERSION}\""
|
||||
}
|
||||
|
||||
// gradle 2.2以上默认同时启用v1和v2(优先用于Android N)
|
||||
@ -126,6 +128,10 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
exclude 'META-INF/gradle/incremental.annotation.processors'
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
debuggable true
|
||||
@ -164,6 +170,15 @@ android {
|
||||
flavorDimensions("env", "region")
|
||||
|
||||
sourceSets {
|
||||
|
||||
debug {
|
||||
assets.srcDirs += 'src/main/assets-debug'
|
||||
}
|
||||
|
||||
release {
|
||||
assets.srcDirs += 'src/main/assets-release'
|
||||
}
|
||||
|
||||
publish {
|
||||
java.srcDirs = ['src/main/java', "src/default/java"]
|
||||
}
|
||||
@ -303,7 +318,6 @@ dependencies {
|
||||
kuaishouImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/kuaishou/libs')
|
||||
gdtImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/gdt/libs')
|
||||
smImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/sm/libs')
|
||||
testImplementation 'junit:junit:4.12'
|
||||
|
||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:${leakcanary}"
|
||||
debugImplementation "com.squareup.leakcanary:leakcanary-android-process:${leakcanary}"
|
||||
@ -348,7 +362,7 @@ dependencies {
|
||||
implementation "com.llew.huawei:verifier:${verifier}"
|
||||
|
||||
teaImplementation "com.bytedance.applog:RangersAppLog-Lite-cn:${bytedanceApplog}"
|
||||
teaImplementation "com.bytedance.applog:RangersAppLog-All-convert:${bytedanceApplog}"
|
||||
teaImplementation "com.bytedance.ads:AppConvert:${bytedanceAppConvert}"
|
||||
|
||||
implementation "net.lingala.zip4j:zip4j:${zip4j}"
|
||||
|
||||
@ -357,7 +371,9 @@ dependencies {
|
||||
|
||||
implementation "com.lg:easyfloat:${easyFloat}"
|
||||
|
||||
implementation "com.lg:apksig:${apksig}"
|
||||
implementation ("com.lg:apksig:${apksig}") {
|
||||
exclude group: 'com.google.protobuf'
|
||||
}
|
||||
|
||||
implementation "com.lg:gid:${gid}"
|
||||
|
||||
@ -369,53 +385,93 @@ dependencies {
|
||||
|
||||
implementation project(':ndownload')
|
||||
implementation project(':vspace-bridge:vspace')
|
||||
implementation(project(':feature:xapk-installer'))
|
||||
|
||||
implementation (project(':module_common')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
|
||||
implementation(project(':module_login')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
implementation(project(':module_setting')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
// implementation(project(':module_setting_compose')) {
|
||||
// exclude group: 'androidx.swiperefreshlayout'
|
||||
// }
|
||||
|
||||
implementation(project(':module_core_feature')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
// implementation(project(':module_feedback')) {
|
||||
// exclude group: 'androidx.swiperefreshlayout'
|
||||
// }
|
||||
implementation(project(':feature:new_feedback',)) {
|
||||
|
||||
implementation(project(':module_setting')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
implementation(project(':module_sensors_data')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
|
||||
// implementation(project(':module_setting_compose')) {
|
||||
// exclude group: 'androidx.swiperefreshlayout'
|
||||
// }
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enablePkg) {
|
||||
implementation(project(':feature:pkg'))
|
||||
}
|
||||
implementation(project(':module_message')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableFeedback) {
|
||||
implementation(project(':feature:new_feedback')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
}
|
||||
// implementation(project(':feature:vpn'))
|
||||
implementation(project(':feature:pkg'))
|
||||
implementation(project(':feature:oaid'))
|
||||
implementation(project(':feature:floating-window'))
|
||||
// implementation(project(':feature:csj_ad'))
|
||||
// implementation(project(':feature:beizi_startup_ad'))
|
||||
implementation(project(':feature:xapk-installer'))
|
||||
implementation(project(':feature:qq_game')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableMessage) {
|
||||
implementation(project(':module_message')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
}
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableOaid) {
|
||||
implementation(project(':feature:oaid'))
|
||||
}
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableFloatingWindow) {
|
||||
implementation(project(':feature:floating-window'))
|
||||
}
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableSensorData) {
|
||||
implementation(project(':module_sensors_data')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
}
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableCsjAd) {
|
||||
implementation(project(':feature:csj_ad'))
|
||||
}
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableQQGame) {
|
||||
implementation(project(':feature:qq_game')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
}
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enablePush) {
|
||||
def pushProperty = findProperty('BUILD_PUSH_TYPE')
|
||||
// 根据BUILD_PUSH_TYPE决定使用哪个推送SDK,目前默认使用极光推送
|
||||
def pushProject = (pushProperty == null || pushProperty == 'jg')
|
||||
? project(':feature:jg_push') : project(':feature:acloud_push')
|
||||
|
||||
implementation(pushProject) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
}
|
||||
|
||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableSentry) {
|
||||
implementation(project(':feature:sentry'))
|
||||
}
|
||||
|
||||
implementation(project(":module_va_api"))
|
||||
implementation(project(":va-archive-common"))
|
||||
if(!gradle.ext.excludeOptionalModules || gradle.ext.enableVa) {
|
||||
implementation(project(":module_va_impl"))
|
||||
}
|
||||
debugImplementation "com.bytedance.tools.codelocator:codelocator-core:2.0.3"
|
||||
internalImplementation(project(':module_internal_test'))
|
||||
|
||||
// def pushProperty = findProperty('BUILD_PUSH_TYPE')
|
||||
// // 根据BUILD_PUSH_TYPE决定使用哪个推送SDK,目前默认使用极光推送
|
||||
// def pushProject = (pushProperty == null || pushProperty == 'jg')
|
||||
// ? project(':feature:jg_push') : project(':feature:acloud_push')
|
||||
// implementation(pushProject) {
|
||||
// exclude group: 'androidx.swiperefreshlayout'
|
||||
// }
|
||||
debugImplementation 'com.bytedance.android:shadowhook:1.0.9'
|
||||
debugImplementation 'io.github.shiqos:wytrace:1.0.1'
|
||||
}
|
||||
|
||||
File propFile = file('sign.properties')
|
||||
@ -475,113 +531,6 @@ if (propFile.exists()) {
|
||||
// }.each { t -> t.dependsOn generateMetaJson }
|
||||
//}
|
||||
|
||||
andResGuard {
|
||||
mappingFile = null
|
||||
use7zip = true
|
||||
useSign = true
|
||||
// 打开这个开关,会keep住所有资源的原始路径,只混淆资源的名字
|
||||
keepRoot = false
|
||||
// 设置这个值,会把arsc name列混淆成相同的名字,减少string常量池的大小
|
||||
fixedResName = "arg"
|
||||
// 打开这个开关会合并所有哈希值相同的资源,但请不要过度依赖这个功能去除去冗余资源
|
||||
mergeDuplicatedRes = true
|
||||
whiteList = [
|
||||
"R.xml.jpush*",
|
||||
"R.drawable.jpush*",
|
||||
"R.layout.jpush*",
|
||||
"R.layout.push*",
|
||||
"R.string.jg*",
|
||||
"R.style.MyDialogStyle",
|
||||
"R.style.JPushTheme",
|
||||
"R.drawable.icon",
|
||||
"R.drawable.ic_bar_back",
|
||||
"R.drawable.toolbar_search_icon",
|
||||
"R.drawable.bg_notification_answer_style_1",
|
||||
"R.drawable.bg_notification_answer_style_2",
|
||||
"R.drawable.bg_notification_article_style_1",
|
||||
"R.drawable.bg_notification_article_style_2",
|
||||
"R.drawable.bg_notification_feedback_style_1",
|
||||
"R.drawable.bg_notification_feedback_style_2",
|
||||
"R.drawable.bg_notification_gift_style_1",
|
||||
"R.drawable.bg_notification_gift_style_2",
|
||||
"R.drawable.bg_notification_login_style_1",
|
||||
"R.drawable.bg_notification_login_style_2",
|
||||
"R.drawable.bg_notification_question_style_1",
|
||||
"R.drawable.bg_notification_question_style_2",
|
||||
"R.drawable.bg_notification_rating_style_1",
|
||||
"R.drawable.bg_notification_rating_style_2",
|
||||
"R.drawable.bg_notification_reserve_game_style_1",
|
||||
"R.drawable.bg_notification_reserve_game_style_2",
|
||||
"R.drawable.bg_notification_video_style_1",
|
||||
"R.drawable.bg_notification_video_style_2",
|
||||
"R.drawable.ic_recommend_activity",
|
||||
"R.drawable.ic_recommend_discount",
|
||||
"R.drawable.ic_recommend_function",
|
||||
"R.drawable.ic_recommend_gift",
|
||||
"R.drawable.ic_recommend_role",
|
||||
"R.drawable.download_button_normal_style",
|
||||
"R.drawable.ic_selector_selected",
|
||||
"R.drawable.ic_selector_default",
|
||||
"R.id.download_speed",
|
||||
"R.id.download_percentage",
|
||||
"R.id.comment",
|
||||
"R.id.vote",
|
||||
"R.id.watermark_hint",
|
||||
"R.id.watermark_sb",
|
||||
"R.id.bottomShareIv",
|
||||
"R.id.bottomShareTv",
|
||||
"R.id.recommendStarPref",
|
||||
"R.id.recommendStar",
|
||||
"R.id.iv_vmode_badge",
|
||||
"R.id.tv_vmode",
|
||||
"R.id.iv_vmode",
|
||||
"R.drawable.help_search_delete",
|
||||
"R.drawable.suggest_type_normal",
|
||||
"R.drawable.suggest_type_crash",
|
||||
"R.drawable.suggest_type_game_question",
|
||||
"R.drawable.suggest_type_game_collect",
|
||||
"R.drawable.suggest_type_function_suggest",
|
||||
"R.drawable.suggest_type_article_collect",
|
||||
"R.drawable.suggest_type_copyright",
|
||||
"R.drawable.news_comment_detail_read",
|
||||
"R.drawable.news_comment_detail_comment",
|
||||
"R.drawable.news_comment_detail_share",
|
||||
"R.drawable.ic_libao",
|
||||
"R.drawable.ic_link",
|
||||
"R.drawable.concern_message_icon",
|
||||
"R.drawable.reuse_blank_hint",
|
||||
"R.drawable.ic_concern",
|
||||
"R.drawable.concern_down",
|
||||
"R.drawable.concern_up",
|
||||
"R.drawable.ic_libao_more",
|
||||
"R.drawable.ic_libao_delete",
|
||||
"R.drawable.ic_dialog_close",
|
||||
"R.drawable.occupy2",
|
||||
"R.drawable.kc_checkbox_unselect",
|
||||
"R.drawable.kc_checkbox_select",
|
||||
"R.drawable.ic_type_unselect",
|
||||
"R.drawable.ic_type_selected",
|
||||
"R.drawable.suggest_add_pic_icon",
|
||||
"R.drawable.icon_pic_add",
|
||||
"R.drawable.ask_search_input_delete",
|
||||
"R.drawable.suggest_pic_delete",
|
||||
"R.id.cardIv",
|
||||
"R.id.cardMask",
|
||||
"R.id.cardGradientMask",
|
||||
"R.id.gameIconIv",
|
||||
"R.id.titleContainer"
|
||||
]
|
||||
compressFilePattern = [
|
||||
"*.png",
|
||||
"*.jpg",
|
||||
"*.jpeg",
|
||||
"*.gif",
|
||||
]
|
||||
sevenzip {
|
||||
artifact = 'io.github.leon406:SevenZip:1.2.22.5'
|
||||
}
|
||||
}
|
||||
|
||||
project.afterEvaluate {
|
||||
def variants = null
|
||||
try {
|
||||
|
||||
@ -28,6 +28,9 @@ object GdtHelper {
|
||||
} else {
|
||||
GDTAction.init(application, USER_ACTION_SET_ID, APP_SECRET_ID, channel)
|
||||
}
|
||||
|
||||
GDTAction.start()
|
||||
|
||||
Utils.log("init GdtHelper")
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
BIN
app/src/gdt/libs/GDTActionSDK.min.1.8.9.aar
Normal file
BIN
app/src/gdt/libs/GDTActionSDK.min.1.8.9.aar
Normal file
Binary file not shown.
@ -6,27 +6,69 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.Keep
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.databinding.LayoutPersonalOtherItemBinding
|
||||
import com.gh.vspace.installexternalgames.InstallExternalGameActivity
|
||||
import com.lightgame.utils.Utils
|
||||
import java.io.File
|
||||
|
||||
@Keep
|
||||
class ExternalGameUsage : IExternalGamesUsage {
|
||||
override fun addInstallExternalGameButton(viewParent: ViewGroup) {
|
||||
class ExternalGameUsage : ITestCase {
|
||||
|
||||
private fun buttonTemplate(viewParent: ViewGroup, id: Int, fn: (LayoutPersonalOtherItemBinding) -> Unit) {
|
||||
val context = viewParent.context
|
||||
viewParent.findViewById<View>(R.id.install_game_from_external) ?: run {
|
||||
viewParent.findViewById<View>(id) ?: run {
|
||||
val binding = LayoutPersonalOtherItemBinding.inflate(LayoutInflater.from(context)).apply {
|
||||
root.id = R.id.install_game_from_external
|
||||
titleTv.text = context.getString(R.string.title_install_external_game)
|
||||
iconIv.setImageResource(R.drawable.ic_personal_my_game)
|
||||
root.setOnClickListener {
|
||||
VHelper.connectService {
|
||||
context.startActivity(
|
||||
InstallExternalGameActivity.getIntent(context)
|
||||
.apply { flags = flags or Intent.FLAG_ACTIVITY_NEW_TASK })
|
||||
}
|
||||
}
|
||||
root.id = id
|
||||
fn(this)
|
||||
}
|
||||
viewParent.addView(binding.root, 0)
|
||||
}
|
||||
}
|
||||
|
||||
override fun addInstallExternalGameButton(viewParent: ViewGroup) {
|
||||
val context = viewParent.context
|
||||
buttonTemplate(viewParent, R.id.install_game_from_external) {
|
||||
it.titleTv.text = context.getString(R.string.title_install_external_game)
|
||||
it.iconIv.setImageResource(R.drawable.ic_personal_my_game)
|
||||
it.root.setOnClickListener {
|
||||
VHelper.connectService {
|
||||
context.startActivity(
|
||||
InstallExternalGameActivity.getIntent(context)
|
||||
.apply { flags = flags or Intent.FLAG_ACTIVITY_NEW_TASK })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun addInstallPluginButton(viewParent: ViewGroup) {
|
||||
buttonTemplate(viewParent, R.id.install_plugin) {
|
||||
it.titleTv.text = "安装64位插件"
|
||||
it.root.setOnClickListener {
|
||||
val file = File("/data/local/tmp/gh-plugins/artifacts.zip")
|
||||
if (file.exists()) {
|
||||
Utils.log(VHelper.LOG_TAG, "有本地更新文件: 64位插件")
|
||||
// TODO: 补充debug插件更新
|
||||
ToastUtils.showToast("暂未实现debug功能")
|
||||
} else {
|
||||
ToastUtils.showToast("data/local/tmp没有push文件")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun addInstallPlugin32Button(viewParent: ViewGroup) {
|
||||
buttonTemplate(viewParent, R.id.install_plugin_32) {
|
||||
it.titleTv.text = "安装32位插件"
|
||||
it.root.setOnClickListener {
|
||||
val file = File("/data/local/tmp/gh-plugins/artifacts32.zip")
|
||||
if (file.exists()) {
|
||||
// TODO: 补充debug插件更新
|
||||
ToastUtils.showToast("暂未实现debug功能")
|
||||
} else {
|
||||
ToastUtils.showToast("data/local/tmp没有push文件")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -25,6 +25,11 @@ class ExternalGameAdapter(private val games: List<ExternalGameUiState>, private
|
||||
路径:${item.apkPath}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
holder.update.setOnClickListener {
|
||||
onItemClickListener.onItemClick(item, OnItemClickListener.ClickType.CLICK_INSTALL)
|
||||
}
|
||||
|
||||
holder.install.goneIf(item.isInstalled) {
|
||||
holder.install.setOnClickListener {
|
||||
onItemClickListener.onItemClick(item, OnItemClickListener.ClickType.CLICK_INSTALL)
|
||||
|
||||
@ -8,4 +8,5 @@ class ExternalGameViewHolder(binding: LayoutExternalGameItemBinding) : RecyclerV
|
||||
val install = binding.btnInstall
|
||||
val uninstall = binding.btnUninstall
|
||||
val start = binding.btnStart
|
||||
val update = binding.btnUpdate
|
||||
}
|
||||
@ -16,6 +16,7 @@ import com.gh.gamecenter.databinding.FragmentInstallExternalGamesBinding
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lg.vspace.VirtualAppManager
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import io.reactivex.Single
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
@ -105,6 +106,15 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
|
||||
private fun install(externalGameUiState: ExternalGameUiState) {
|
||||
val bit =
|
||||
externalGameUiState.externalGameEntity.cpuAbi.let { if (it.size == 1 && it.contains("armeabi-v7a")) "32" else "64" }
|
||||
|
||||
VHelper.install(requireContext(), DownloadEntity().apply {
|
||||
externalGameUiState.externalGameEntity.apply {
|
||||
packageName = apkPackageName
|
||||
path = apkPath
|
||||
}
|
||||
}, true)
|
||||
|
||||
|
||||
if (VHelper.showDialogIfVSpaceIsNeeded(
|
||||
requireContext(),
|
||||
"",
|
||||
@ -144,7 +154,9 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
|
||||
com.gh.gamecenter.BuildConfig.VERSION_NAME,
|
||||
HaloApp.getInstance().channel,
|
||||
"",
|
||||
""
|
||||
"",
|
||||
com.gh.gamecenter.BuildConfig.VA_VERSION_NAME,
|
||||
HaloApp.getInstance().oaid
|
||||
)
|
||||
requireActivity().startActivity(intent)
|
||||
}
|
||||
|
||||
@ -24,6 +24,14 @@
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_update"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/text_update"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_uninstall"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<item name="install_game_from_external" type="id" />
|
||||
<item name="install_plugin" type="id" />
|
||||
<item name="install_plugin_32" type="id" />
|
||||
</resources>
|
||||
@ -2,6 +2,7 @@
|
||||
<resources>
|
||||
<string name="title_install_external_game">从SD卡安装</string>
|
||||
<string name="text_install">安装</string>
|
||||
<string name="text_update">更新</string>
|
||||
<string name="text_uninstall">卸载</string>
|
||||
<string name="text_start">启动</string>
|
||||
</resources>
|
||||
Binary file not shown.
BIN
app/src/kuaishou/libs/channelsdk-0.2.3.aar
Normal file
BIN
app/src/kuaishou/libs/channelsdk-0.2.3.aar
Normal file
Binary file not shown.
@ -12,12 +12,13 @@
|
||||
</queries>
|
||||
|
||||
<!-- 华为/荣耀角标 -->
|
||||
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE "/>
|
||||
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE " />
|
||||
<uses-permission android:name="com.hihonor.android.launcher.permission.CHANGE_BADGE" />
|
||||
<!-- vivo角标 -->
|
||||
<uses-permission android:name="com.vivo.notification.permission.BADGE_ICON" />
|
||||
|
||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
|
||||
<uses-permission
|
||||
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
|
||||
tools:ignore="ScopedStorage" />
|
||||
<!-- 允许应用程序访问网络连接 -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
@ -39,7 +40,7 @@
|
||||
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
||||
<!-- 应用安装相关 -->
|
||||
<uses-permission android:name="com.android.permission.GET_INSTALLED_APPS" />
|
||||
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
|
||||
<!-- 前台服务权限-->
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
|
||||
@ -92,7 +93,33 @@
|
||||
com.tencent.qqmini,
|
||||
com.tencent.qqmini.minigame.external,
|
||||
com.tencent.qqmini.minigame.opensdk,
|
||||
com.tencent.qqmini.union.ad" />
|
||||
com.tencent.qqmini.union.ad,
|
||||
com.lg.vspace,
|
||||
io.lg.va.common,
|
||||
com.va.floating,
|
||||
com.lg.cloud,
|
||||
com.lg.archive,
|
||||
com.lg.vclient,
|
||||
com.va.realname,
|
||||
com.lg.vspace.flavor,
|
||||
com.lg.update,
|
||||
com.lg.login,
|
||||
com.lg.accelerator,
|
||||
com.lody.virtual,
|
||||
com.lg.core,
|
||||
com.lg.ads,
|
||||
com.lg.common,
|
||||
com.lg.vspace.network,
|
||||
com.lody.virtual.lib.res,
|
||||
com.va.host,
|
||||
com.lg.vspace.plugin.host,
|
||||
com.lg.plugin.constant,
|
||||
com.bytedance.tools.codelocator,
|
||||
org.chickenhook.restrictionbypass,
|
||||
com.lody.virtual.sandhook,
|
||||
com.lg.vspace.common,
|
||||
com.lg.vspace.archive.common,
|
||||
com.wy.lib.wytrace" />
|
||||
|
||||
<!-- 去掉 SDK 一些流氓权限 -->
|
||||
<uses-permission
|
||||
@ -111,6 +138,14 @@
|
||||
android:name="android.permission.ACCESS_COARSE_LOCATION"
|
||||
tools:node="remove" />
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.ACCESS_BACKGROUND_LOCATION"
|
||||
tools:node="remove" />
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.ACCESS_FINE_LOCATION"
|
||||
tools:node="remove" />
|
||||
|
||||
<supports-screens
|
||||
android:anyDensity="true"
|
||||
android:largeScreens="true"
|
||||
@ -747,11 +782,11 @@
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.qgame.QGameHomeWrapperActivity"
|
||||
android:name="com.gh.gamecenter.minigame.qq.QGameHomeWrapperActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.qgame.QGameSearchActivity"
|
||||
android:name="com.gh.gamecenter.minigame.MiniGameSearchActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
@ -770,8 +805,18 @@
|
||||
android:name="com.gh.gamecenter.wrapper.ToolbarWrapperActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity android:name=".forum.home.CommunityActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
<activity
|
||||
android:name=".forum.home.CommunityActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".forum.home.follow.FollowDynamicActivity"
|
||||
android:theme="@style/Theme.Transparent" />
|
||||
|
||||
<activity
|
||||
android:name=".forum.home.follow.AllFollowedActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppCompatTheme.APP" />
|
||||
|
||||
<!-- <activity-->
|
||||
<!-- android:name="${applicationId}.douyinapi.DouYinEntryActivity"-->
|
||||
@ -783,7 +828,8 @@
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
android:grantUriPermissions="true"
|
||||
tools:replace="android:authorities">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/provider_paths" />
|
||||
|
||||
@ -28,7 +28,6 @@ import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.exposure.ExposureSource
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.provider.IBeiziAdProvider
|
||||
import com.gh.gamecenter.core.provider.ICsjAdProvider
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
@ -46,14 +45,11 @@ import io.reactivex.schedulers.Schedulers
|
||||
*
|
||||
* 由它来分发功能实现到具体的实现
|
||||
*
|
||||
* 以最复杂的开屏广告为例,有三种实现(1. 自有的广告实现 2. 穿山甲的开屏广告实现 3. Beizi 的开屏广告实现)
|
||||
*
|
||||
* 由于两个广告 SDK 有可能在一次启动中都被使用,所以会根据获取到的广告配置 config 来决定是否需要出是很好两个 SDK
|
||||
* 以开屏广告为例,有两种实现(1. 自有的广告实现 2. 穿山甲的开屏广告实现 )
|
||||
*/
|
||||
object AdDelegateHelper {
|
||||
|
||||
private var mCsjAdImpl: ICsjAdProvider? = null
|
||||
private var mBeiziAdImpl: IBeiziAdProvider? = null
|
||||
|
||||
private val mAdConfigList: ArrayList<AdConfig> by lazy { arrayListOf() }
|
||||
|
||||
@ -66,7 +62,6 @@ object AdDelegateHelper {
|
||||
get() = mVGameLaunchAd
|
||||
|
||||
private const val AD_SDK_CSJ = "穿山甲"
|
||||
private const val AD_SDK_BEIZI = "倍孜"
|
||||
const val AD_TYPE_SDK = "third_party_ads" // 第三方 SDK 广告
|
||||
const val AD_TYPE_OWNER = "owner_ads" // 自有广告
|
||||
|
||||
@ -80,13 +75,6 @@ object AdDelegateHelper {
|
||||
var gameSearchKeyword = ""
|
||||
|
||||
fun initAdSdk(context: Context) {
|
||||
// 初始化 Beizi
|
||||
if (mBeiziAdImpl == null) {
|
||||
mBeiziAdImpl =
|
||||
ARouter.getInstance().build(RouteConsts.provider.beiziAd).navigation() as? IBeiziAdProvider
|
||||
mBeiziAdImpl?.initSDK(context)
|
||||
}
|
||||
|
||||
// 初始化穿山甲
|
||||
if (mCsjAdImpl == null) {
|
||||
mCsjAdImpl =
|
||||
@ -193,7 +181,7 @@ object AdDelegateHelper {
|
||||
/**
|
||||
* 热启动是否需要显示开屏广告(目前只展示第三方广告)
|
||||
*/
|
||||
private fun shouldShowStartUpAdWhenHotLaunch() = (mCsjAdImpl != null || mBeiziAdImpl != null)
|
||||
private fun shouldShowStartUpAdWhenHotLaunch() = (mCsjAdImpl != null)
|
||||
&& mSplashAd?.displayRule?.hotStartSplashAd?.type == AD_TYPE_SDK
|
||||
&& mSplashAd?.hotStartThirdPartyAd != null
|
||||
|
||||
@ -204,6 +192,10 @@ object AdDelegateHelper {
|
||||
return mDownloadManagerAd != null && !isMatchAdFreeRule(mDownloadManagerAd) && isMatchDownloadManagerAdDisplayRule()
|
||||
}
|
||||
|
||||
fun shouldShowHelperLaunchAd(): Boolean {
|
||||
return mVGameLaunchAd != null && !isMatchAdFreeRule(mVGameLaunchAd) && isMatchAdDisplayRule(mVGameLaunchAd, Constants.SP_LAST_HELPER_LAUNCH_AD_SHOW_TIME)
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否需要显示游戏搜索广告
|
||||
*/
|
||||
@ -248,10 +240,11 @@ object AdDelegateHelper {
|
||||
/**
|
||||
* 是否大于广告管理展示间隔时长
|
||||
*/
|
||||
private fun isMatchDownloadManagerAdDisplayRule(): Boolean {
|
||||
mDownloadManagerAd?.displayRule?.run {
|
||||
private fun isMatchDownloadManagerAdDisplayRule(): Boolean = isMatchAdDisplayRule(mDownloadManagerAd, Constants.SP_LAST_DOWNLOAD_MANAGER_AD_SHOW_TIME)
|
||||
private fun isMatchAdDisplayRule(adConfig: AdConfig?, spKey: String): Boolean {
|
||||
adConfig?.displayRule?.run {
|
||||
if (adDisplayInterval > 0) {
|
||||
val lastShowTime = SPUtils.getLong(Constants.SP_LAST_DOWNLOAD_MANAGER_AD_SHOW_TIME, 0L)
|
||||
val lastShowTime = SPUtils.getLong(spKey, 0L)
|
||||
val durationInMinutes = (System.currentTimeMillis() - lastShowTime).toFloat() / 1000 / 60
|
||||
return durationInMinutes > adDisplayInterval
|
||||
} else {
|
||||
@ -403,10 +396,7 @@ object AdDelegateHelper {
|
||||
((mSplashAd?.displayRule?.timeout ?: 3.5F) * 1000).toInt()
|
||||
}
|
||||
|
||||
if (thirdPartyAd.sourceName == AD_SDK_BEIZI) {
|
||||
sdkStartAdContainer.visibility = View.VISIBLE
|
||||
requestBeiziSplashAd(sdkStartAdContainer, adsViewGroup, adViewWidthInPx, adViewHeightInPx, timeout.toLong(), sdkSplashCallback)
|
||||
} else if (thirdPartyAd.sourceName == AD_SDK_CSJ) {
|
||||
if (thirdPartyAd.sourceName == AD_SDK_CSJ) {
|
||||
sdkStartAdContainer.visibility = View.VISIBLE
|
||||
requestCsjSplashAd(
|
||||
activity,
|
||||
@ -453,24 +443,6 @@ object AdDelegateHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Beizi 的开屏广告
|
||||
*/
|
||||
private fun requestBeiziSplashAd(
|
||||
startAdContainer: View,
|
||||
adsFl: FrameLayout,
|
||||
adViewWidthInPx: Int,
|
||||
adViewHeightInPx: Int,
|
||||
timeout: Long,
|
||||
callback: (isSuccess: Boolean) -> Unit,
|
||||
) {
|
||||
if (mBeiziAdImpl == null) {
|
||||
callback.invoke(false)
|
||||
} else {
|
||||
mBeiziAdImpl?.requestSplashAd(startAdContainer, adsFl, adViewWidthInPx, adViewHeightInPx, timeout, callback)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示自有的开屏广告
|
||||
*/
|
||||
@ -677,7 +649,6 @@ object AdDelegateHelper {
|
||||
* 取消开屏广告
|
||||
*/
|
||||
fun cancelSplashAd(context: Context) {
|
||||
mBeiziAdImpl?.cancelSplashAd(context)
|
||||
mCsjAdImpl?.cancelSplashAd(context)
|
||||
}
|
||||
|
||||
|
||||
44
app/src/main/java/com/gh/ad/LaunchAdImpl.kt
Normal file
44
app/src/main/java/com/gh/ad/LaunchAdImpl.kt
Normal file
@ -0,0 +1,44 @@
|
||||
package com.gh.ad
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.provider.ILaunchAd
|
||||
import com.gh.gamecenter.common.utils.goneIf
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
|
||||
@Route(path = RouteConsts.provider.vaAd, name = "畅玩启动页广告")
|
||||
class LaunchAdImpl : ILaunchAd {
|
||||
override fun init(context: Context?) {
|
||||
}
|
||||
|
||||
override fun requestAd(fragment: Fragment, container: ViewGroup, maskView: View) {
|
||||
if (AdDelegateHelper.shouldShowHelperLaunchAd()) {
|
||||
val launchAd = AdDelegateHelper.vGameLaunchAd
|
||||
val showThirdPartyAd = launchAd?.displayRule?.adSource == AdDelegateHelper.AD_TYPE_SDK
|
||||
val thirdPartyAd = launchAd?.thirdPartyAd
|
||||
if (showThirdPartyAd && thirdPartyAd != null) {
|
||||
AdDelegateHelper.requestThirdPartyBannerAd(
|
||||
fragment,
|
||||
container,
|
||||
thirdPartyAd,
|
||||
DisplayUtils.getScreenWidthInDp(fragment.requireActivity()),
|
||||
) { isSuccess ->
|
||||
maskView.goneIf(!isSuccess)
|
||||
if (isSuccess) {
|
||||
SPUtils.setLong(Constants.SP_LAST_HELPER_LAUNCH_AD_SHOW_TIME, System.currentTimeMillis())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -16,8 +16,11 @@ import com.gh.gamecenter.SplashScreenActivity
|
||||
import com.gh.gamecenter.authorization.AuthorizationActivity
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.provider.IHelpAndFeedbackProvider
|
||||
import com.gh.gamecenter.common.utils.PackageFlavorHelper
|
||||
import com.gh.gamecenter.core.provider.IPushProvider
|
||||
import com.gh.gamecenter.login.view.LoginActivity
|
||||
import com.gh.gamecenter.va.VCore
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
@ -32,14 +35,15 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
|
||||
override fun onActivityStarted(activity: Activity) {
|
||||
GlobalActivityManager.currentActivity = activity
|
||||
activityCount ++
|
||||
activityCount++
|
||||
if (activityCount == 1 && isFromBackgroundToForeground) {
|
||||
if (AdDelegateHelper.shouldShowStartUpAd(true)
|
||||
&& !HaloApp.getInstance().isSkippingThirdParty
|
||||
&& !HaloApp.getInstance().isDisableSplashAdTemporarily
|
||||
&& activity !is SplashScreenActivity
|
||||
&& activity !is SkipActivity
|
||||
&& activity !is AuthorizationActivity
|
||||
&& activity !is SplashAdActivity
|
||||
&& !isSuggestionActivity(activity)
|
||||
) {
|
||||
activity.startActivity(SplashAdActivity.getIntent(activity))
|
||||
}
|
||||
@ -84,6 +88,8 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
}
|
||||
|
||||
if (activity is AppCompatActivity
|
||||
&& !VCore.getInstance().isLaunchActivity(activity)
|
||||
&& activity !is LoginActivity
|
||||
&& activity !is SplashScreenActivity
|
||||
&& activity !is SkipActivity
|
||||
&& activity !is AuthorizationActivity
|
||||
@ -102,7 +108,7 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
}
|
||||
|
||||
override fun onActivityStopped(activity: Activity) {
|
||||
activityCount --
|
||||
activityCount--
|
||||
isFromBackgroundToForeground = activityCount <= 0
|
||||
}
|
||||
|
||||
@ -114,4 +120,11 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
private fun isSuggestionActivity(activity: Activity): Boolean {
|
||||
val helpAndFeedbackProvider =
|
||||
ARouter.getInstance().build(RouteConsts.provider.helpAndFeedback)
|
||||
.navigation() as? IHelpAndFeedbackProvider
|
||||
return helpAndFeedbackProvider?.isSuggestionActivity(activity) ?: false
|
||||
}
|
||||
|
||||
}
|
||||
@ -32,9 +32,13 @@ import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.utils.NewFlatLogUtils
|
||||
import com.gh.gamecenter.common.view.dsbridge.CompletionHandler
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.provider.IPushProvider
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.entity.SensorsEvent
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
@ -69,7 +73,7 @@ class DefaultJsApi(
|
||||
private var mFragment: Fragment? = null,
|
||||
private var mBbsId: String? = "",
|
||||
private var mOriginUrl: String? = "",
|
||||
private val mForumName: String? = ""
|
||||
private val mForumName: String? = "",
|
||||
) {
|
||||
|
||||
companion object {
|
||||
@ -89,6 +93,11 @@ class DefaultJsApi(
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun isEnableForceDark(msg: Any): Boolean {
|
||||
return DarkModeUtils.isWebViewForceDarkEnabled
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun isGhzs(msg: Any): String {
|
||||
return "true"
|
||||
@ -219,7 +228,7 @@ class DefaultJsApi(
|
||||
runOnUiThread {
|
||||
// 若畅玩列表中安装了,优先启动畅玩游戏
|
||||
if (VHelper.isInstalled(packageName)) {
|
||||
if (!VHelper.showDialogIfVSpaceIsNeeded(context, "", "", "", "")) {
|
||||
VHelper.validateVSpaceBeforeAction(context, packageName, null) {
|
||||
VHelper.launch(context, packageName)
|
||||
}
|
||||
} else {
|
||||
@ -333,6 +342,12 @@ class DefaultJsApi(
|
||||
return HaloApp.getInstance().oaid
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun getPushId(): String {
|
||||
val pushProvider = ARouter.getInstance().build(RouteConsts.provider.push).navigation() as? IPushProvider
|
||||
return pushProvider?.getRegistrationId(HaloApp.getInstance()) ?: "unknown"
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun showIncompatibleVersionDialog(msg: Any) {
|
||||
DialogHelper.showUpgradeDialog(context)
|
||||
|
||||
@ -16,7 +16,7 @@ class ValidateVSpaceHandler : DownloadChainHandler() {
|
||||
}
|
||||
|
||||
if (asVGame) {
|
||||
VHelper.validateVSpaceBeforeAction(context, gameEntity) {
|
||||
VHelper.validateVSpaceBeforeAction(context,gameEntity.getUniquePackageName(), gameEntity) {
|
||||
closure.invoke()
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -15,6 +15,7 @@ import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.common.constant.CommonConsts;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil;
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse;
|
||||
import com.gh.gamecenter.common.retrofit.Response;
|
||||
import com.gh.gamecenter.common.utils.DarkModeUtils;
|
||||
@ -22,15 +23,18 @@ import com.gh.gamecenter.common.utils.EnvHelper;
|
||||
import com.gh.gamecenter.core.utils.GsonUtils;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
import com.gh.gamecenter.core.utils.UrlFilterUtils;
|
||||
import com.gh.gamecenter.entity.AppEntity;
|
||||
import com.gh.gamecenter.entity.GameGuidePopupEntity;
|
||||
import com.gh.gamecenter.entity.NewApiSettingsEntity;
|
||||
import com.gh.gamecenter.entity.NewSettingsEntity;
|
||||
import com.gh.gamecenter.entity.VNewSetting;
|
||||
import com.gh.gamecenter.entity.VSetting;
|
||||
import com.gh.gamecenter.feature.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.feature.entity.SimulatorEntity;
|
||||
import com.gh.gamecenter.feature.utils.ContentBlockedHelper;
|
||||
import com.gh.gamecenter.receiver.PackageChangeBroadcastReceiver;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.gh.gamecenter.retrofit.service.VApiService;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.halo.assistant.HaloApp;
|
||||
|
||||
@ -41,8 +45,12 @@ import org.json.JSONObject;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleSource;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.reactivex.subjects.BehaviorSubject;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
public class Config {
|
||||
@ -70,6 +78,10 @@ public class Config {
|
||||
private static NewApiSettingsEntity.NightMode mNightModeSetting;
|
||||
private static SimulatorEntity mNewSimulatorEntity;
|
||||
private static VSetting mVSetting;
|
||||
private static VNewSetting mVNewSetting;
|
||||
|
||||
private static AppEntity mNew32UpdateEntity;
|
||||
public static BehaviorSubject<VNewSetting> vNewSettingSubject = BehaviorSubject.create();
|
||||
private static GameGuidePopupEntity mGameGuidePopupEntity;
|
||||
private static SharedPreferences mDefaultSharedPreferences;
|
||||
|
||||
@ -79,24 +91,11 @@ public class Config {
|
||||
return !SPUtils.getBoolean(Constants.SP_TEENAGER_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* VPN 开关选项是否开启
|
||||
*/
|
||||
public static boolean isVpnOptionEnabled() {
|
||||
if (mNewApiSettingsEntity == null
|
||||
|| mNewApiSettingsEntity.getInstall() == null
|
||||
|| mNewApiSettingsEntity.getInstall().getVpnRequired() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mNewApiSettingsEntity.getInstall().getVpnRequired().getShouldShowVpnOption();
|
||||
}
|
||||
|
||||
public static void setSettings(SettingsEntity settingsEntity) {
|
||||
getPreferences().edit().putString(SETTINGS_KEY, GsonUtils.toJson(settingsEntity)).apply();
|
||||
mSettingsEntity = settingsEntity;
|
||||
|
||||
PackageHelper.refreshList();
|
||||
PackageHelper.refreshPackageNameList();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -197,6 +196,27 @@ public class Config {
|
||||
return mVSetting;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static VNewSetting getVNewSettingEntity() {
|
||||
if (mVNewSetting == null) {
|
||||
try {
|
||||
String json = SPUtils.getString(Constants.SP_V_NEW_SETTINGS);
|
||||
if (!TextUtils.isEmpty(json)) {
|
||||
mVNewSetting = GsonUtils.fromJson(json, VNewSetting.class);
|
||||
vNewSettingSubject.onNext(mVNewSetting);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return mVNewSetting;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static AppEntity getNew32UpdateEntity() {
|
||||
return mNew32UpdateEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求网络数据,尝试刷新畅玩相关配置
|
||||
*/
|
||||
@ -217,6 +237,36 @@ public class Config {
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public static void getNewSetting() {
|
||||
VApiService vApi = RetrofitManager.getInstance().getVApi();
|
||||
vApi.getNewSettings(BuildConfig.VERSION_NAME, Build.VERSION.SDK_INT).flatMap(new Function<VNewSetting, SingleSource<AppEntity>>() {
|
||||
@Override
|
||||
public SingleSource<AppEntity> apply(VNewSetting data) throws Exception {
|
||||
mVNewSetting = data;
|
||||
vNewSettingSubject.onNext(mVNewSetting);
|
||||
SPUtils.setString(Constants.SP_V_NEW_SETTINGS, GsonUtils.toJson(data));
|
||||
if (data.getVa() != null && data.getVa().getArch32() != null) {
|
||||
String versionNameByPackageName = PackageUtils.getVersionNameByPackageName(data.getVa().getArch32().getPackageName());
|
||||
return vApi.getNewPackageUpdate(
|
||||
BuildConfig.VERSION_NAME,
|
||||
versionNameByPackageName != null ? versionNameByPackageName : "",
|
||||
HaloApp.getInstance().getChannel()
|
||||
);
|
||||
}
|
||||
return Single.error(new IllegalStateException("VNewSetting entity is not expected"));
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BiResponse<AppEntity>() {
|
||||
@Override
|
||||
public void onSuccess(AppEntity data) {
|
||||
mNew32UpdateEntity = data;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static GameGuidePopupEntity getGameGuidePopupEntity() {
|
||||
return mGameGuidePopupEntity;
|
||||
@ -271,6 +321,7 @@ public class Config {
|
||||
});
|
||||
|
||||
refreshVSettingEntity();
|
||||
getNewSetting();
|
||||
|
||||
RetrofitManager.getInstance()
|
||||
.getApi().getGameGuidePopup(Build.MANUFACTURER, Build.VERSION.RELEASE, Build.MODEL, channel, BuildConfig.VERSION_NAME)
|
||||
@ -311,7 +362,9 @@ public class Config {
|
||||
String filterString = UrlFilterUtils.getFilterQuery(
|
||||
"manufacturer", Build.MANUFACTURER,
|
||||
"model", Build.MODEL,
|
||||
"android_sdk_version", String.valueOf(Build.VERSION.SDK_INT));
|
||||
"android_sdk_version", String.valueOf(Build.VERSION.SDK_INT),
|
||||
"rom", MetaUtil.INSTANCE.getRom().name() + " " + MetaUtil.INSTANCE.getRom().getVersionName()
|
||||
);
|
||||
|
||||
RetrofitManager.getInstance()
|
||||
.getNewApi().getNewSettings(PackageUtils.getGhVersionName(), channel, filterString)
|
||||
@ -335,11 +388,11 @@ public class Config {
|
||||
}
|
||||
|
||||
// 更新安装列表是否开启的配置
|
||||
// if (mNewApiSettingsEntity.getInstalledComplianceSwitch() != null) {
|
||||
// PackageHelper.INSTANCE.updateIsGetInstalledPackagesApiAgreedRequired(mNewApiSettingsEntity.getInstalledComplianceSwitch());
|
||||
// } else {
|
||||
// PackageHelper.INSTANCE.updateIsGetInstalledPackagesApiAgreedRequired(false);
|
||||
// }
|
||||
if (mNewApiSettingsEntity.getInstalledComplianceSwitch() != null) {
|
||||
PackageHelper.INSTANCE.updateIsGetInstalledPackagesApiAgreedRequired(mNewApiSettingsEntity.getInstalledComplianceSwitch());
|
||||
} else {
|
||||
PackageHelper.INSTANCE.updateIsGetInstalledPackagesApiAgreedRequired(false);
|
||||
}
|
||||
|
||||
// 更新包名监听是否开启
|
||||
if (mNewApiSettingsEntity.isPackageObserveEnable()) {
|
||||
|
||||
@ -60,7 +60,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
private val mDuration = 3000
|
||||
private var mDisposable: Disposable? = null
|
||||
private var mAdapter: PackageCheckAdapter? = null
|
||||
private var mAllInstalledPackages = PackageHelper.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
private var mAllInstalledPackages = PackageHelper.getInstalledPackageNameList(HaloApp.getInstance().application, 0)
|
||||
var gameEntity: GameEntity? = null
|
||||
var callBack: ConfirmListener? = null
|
||||
|
||||
@ -326,7 +326,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mAllInstalledPackages = PackageHelper.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
mAllInstalledPackages = PackageHelper.getInstalledPackageNameList(HaloApp.getInstance().application, 0)
|
||||
gameEntity?.packageDialog?.let {
|
||||
if (isAllPackageInstalled(mAllInstalledPackages, it)) {
|
||||
callBack?.onConfirm()
|
||||
@ -364,7 +364,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(busFour: EBPackage) {
|
||||
if (busFour.isInstalledOrUninstalled()) {
|
||||
mAllInstalledPackages = PackageHelper.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
mAllInstalledPackages = PackageHelper.getInstalledPackageNameList(HaloApp.getInstance().application, 0)
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
@ -417,7 +417,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
return
|
||||
}
|
||||
|
||||
val allInstalledPackages = PackageHelper.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
val allInstalledPackages = PackageHelper.getInstalledPackageNameList(HaloApp.getInstance().application, 0)
|
||||
if (isAllPackageInstalled(allInstalledPackages, packageDialogEntity)) {
|
||||
callBack.onConfirm()
|
||||
return
|
||||
@ -454,12 +454,12 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
|
||||
private fun checkDetectionsInstalled(
|
||||
allInstalledPackages: List<PackageInfo>,
|
||||
allInstalledPackages: List<String>,
|
||||
packages: ArrayList<String>
|
||||
): Boolean {
|
||||
var isPackagesInstalled = false
|
||||
packages.forEach { packageName ->
|
||||
val isInstalled = allInstalledPackages.find { it.packageName == packageName } != null
|
||||
val isInstalled = allInstalledPackages.find { it == packageName } != null
|
||||
if (isInstalled) {
|
||||
isPackagesInstalled = true
|
||||
return@forEach
|
||||
@ -470,7 +470,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
|
||||
|
||||
fun isAllPackageInstalled(
|
||||
allInstalledPackages: List<PackageInfo>,
|
||||
allInstalledPackages: List<String>,
|
||||
packageDialogEntity: PackageDialogEntity
|
||||
): Boolean {
|
||||
var isAllInstalled = true
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import com.aliyun.sls.android.producer.Log
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.common.loghub.LoghubHelper
|
||||
import com.gh.gamecenter.common.loghub.TLogHubHelper
|
||||
import com.gh.gamecenter.common.utils.FixedSizeLinkedHashSet
|
||||
import com.gh.gamecenter.common.utils.toJson
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.lightgame.utils.Utils
|
||||
import com.volcengine.model.tls.LogItem
|
||||
|
||||
/**
|
||||
* A handful tool for committing logs to aliyun loghub.
|
||||
@ -78,19 +78,20 @@ object ExposureManager {
|
||||
|
||||
private fun uploadExposures(eventSet: HashSet<ExposureEvent>, forced: Boolean) {
|
||||
eventSet.forEach {
|
||||
LoghubHelper.uploadLog(buildLog(it), LOG_STORE, forced)
|
||||
TLogHubHelper.sendLog(buildLog(it), LOG_STORE)
|
||||
// LoghubHelper.uploadLog(buildLog(it), LOG_STORE, forced)
|
||||
// it.recycle()
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildLog(event: ExposureEvent) = Log().apply {
|
||||
putContent("id", event.id)
|
||||
putContent("payload", event.payload.toJson())
|
||||
putContent("event", event.event.toString())
|
||||
putContent("source", eliminateMultipleBrackets(event.source.toJson()))
|
||||
putContent("meta", event.meta.toJson())
|
||||
putContent("real_millisecond", event.timeInMillisecond.toString())
|
||||
putContent(
|
||||
private fun buildLog(event: ExposureEvent) = LogItem(System.currentTimeMillis()).apply {
|
||||
addContent("__id", event.id)
|
||||
addContent("payload", event.payload.toJson())
|
||||
addContent("event", event.event.toString())
|
||||
addContent("source", eliminateMultipleBrackets(event.source.toJson()))
|
||||
addContent("meta", event.meta.toJson())
|
||||
addContent("real_millisecond", event.timeInMillisecond.toString())
|
||||
addContent(
|
||||
"e-traces", if (event.eTrace != null) {
|
||||
eliminateMultipleBrackets(event.eTrace?.toJson() ?: "")
|
||||
} else ""
|
||||
|
||||
@ -2,7 +2,7 @@ package com.gh.common.prioritychain
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.gh.gamecenter.floatingwindow.FloatingWindowEntity
|
||||
import com.gh.gamecenter.feature.entity.FloatingWindowEntity
|
||||
import com.gh.gamecenter.livedata.Event
|
||||
|
||||
class CustomFloatingWindowHandler(priority: Int) : PriorityChainHandler(priority) {
|
||||
|
||||
@ -7,6 +7,7 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IAppProvider
|
||||
import com.gh.gamecenter.core.provider.IFlavorProvider
|
||||
import com.gh.gamecenter.va.VCore
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
@Route(path = RouteConsts.provider.app, name = "Application暴露服务")
|
||||
@ -83,7 +84,9 @@ class AppProviderImpl : IAppProvider {
|
||||
return HaloApp.getInstance().isBrandNewInstall
|
||||
}
|
||||
|
||||
override fun setSkippingThirdParty(isSkippingThirdParty: Boolean) {
|
||||
HaloApp.getInstance().isSkippingThirdParty = isSkippingThirdParty
|
||||
override fun setDisableSplashAdTemporarily(isDisable: Boolean) {
|
||||
HaloApp.getInstance().isDisableSplashAdTemporarily = isDisable
|
||||
}
|
||||
|
||||
override fun getPluginVersion(): String = VCore.getInstance().getPluginVersion()
|
||||
}
|
||||
@ -32,5 +32,6 @@ class BuildConfigImpl : IBuildConfigProvider {
|
||||
override fun getVApiHost(): String = BuildConfig.VAPI_HOST
|
||||
|
||||
override fun getVDevApiHost(): String = BuildConfig.DEV_VAPI_HOST
|
||||
|
||||
override fun getLogProducerProject(): String = BuildConfig.LOG_HUB_PROJECT
|
||||
}
|
||||
@ -0,0 +1,103 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.gh.common.util.ConcernContentUtils
|
||||
import com.gh.common.view.ImageContainerView
|
||||
import com.gh.gamecenter.ImageViewerActivity.Companion.getIntent
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.utils.toArrayList
|
||||
import com.gh.gamecenter.core.provider.IConcernArticleUtilsProvider
|
||||
import com.gh.gamecenter.databinding.RecyclerGameArticleBinding
|
||||
import com.gh.gamecenter.R
|
||||
|
||||
@Route(path = RouteConsts.provider.concernContentUtils, name = "ConcernContentUtils暴露服务")
|
||||
class ConcernArticleUtilsProviderImpl : IConcernArticleUtilsProvider {
|
||||
override fun addContentPic(
|
||||
context: Context,
|
||||
linearLayout: LinearLayout,
|
||||
list: List<String>,
|
||||
entrance: String,
|
||||
width: Int
|
||||
) {
|
||||
ConcernContentUtils.addContentPic(context, linearLayout, list, entrance, width)
|
||||
}
|
||||
|
||||
override fun createArticleBinding(parent: ViewGroup): ViewBinding {
|
||||
val inflater = LayoutInflater.from(parent.context)
|
||||
return RecyclerGameArticleBinding.inflate(inflater, parent, false)
|
||||
}
|
||||
|
||||
override fun initArticleStyle(binding: ViewBinding) {
|
||||
if (binding is RecyclerGameArticleBinding) {
|
||||
val context = binding.root.context
|
||||
binding.root
|
||||
.setBackground(ContextCompat.getDrawable(context, R.drawable.reuse_listview_item_style))
|
||||
binding.tvGameName.setTextColor(ContextCompat.getColor(context, R.color.text_primary))
|
||||
binding.tvTime.setTextColor(ContextCompat.getColor(context, R.color.text_tertiary))
|
||||
binding.tvTitle.setTextColor(ContextCompat.getColor(context, R.color.text_primary))
|
||||
binding.tvDescription.setTextColor(ContextCompat.getColor(context, R.color.text_secondary))
|
||||
binding.tvComment.setTextColor(ContextCompat.getColor(context, R.color.text_tertiary))
|
||||
binding.tvShare.setTextColor(ContextCompat.getColor(context, R.color.text_tertiary))
|
||||
}
|
||||
}
|
||||
|
||||
override fun getIvIcon(binding: ViewBinding): View =
|
||||
(binding as RecyclerGameArticleBinding).ivIcon
|
||||
|
||||
override fun getTvGameName(binding: ViewBinding): TextView =
|
||||
(binding as RecyclerGameArticleBinding).tvGameName
|
||||
|
||||
override fun getTvTime(binding: ViewBinding): TextView = (binding as RecyclerGameArticleBinding).tvTime
|
||||
|
||||
override fun getTvTitle(binding: ViewBinding): TextView = (binding as RecyclerGameArticleBinding).tvTitle
|
||||
|
||||
override fun getTvDescription(binding: ViewBinding): TextView =
|
||||
(binding as RecyclerGameArticleBinding).tvDescription
|
||||
|
||||
override fun bindImgs(binding: ViewBinding, img: List<String>) {
|
||||
if (binding is RecyclerGameArticleBinding) {
|
||||
val images = img.map {
|
||||
ImageContainerView.ImageContainerData.ImageInfo(it, 3, 2)
|
||||
}
|
||||
val imageContainerData =
|
||||
ImageContainerView.ImageContainerData("", false, images, show = images.isNotEmpty())
|
||||
binding.ivImagesContainer.bindData(imageContainerData,
|
||||
object : ImageContainerView.OnImageContainerEventListener {
|
||||
override fun onImageClick(
|
||||
images: List<String>,
|
||||
position: Int,
|
||||
imageViewList: ArrayList<SimpleDraweeView>
|
||||
) {
|
||||
val checkIntent = getIntent(
|
||||
binding.root.context,
|
||||
images.toArrayList(),
|
||||
position,
|
||||
imageViewList,
|
||||
""
|
||||
)
|
||||
binding.root.context.startActivity(checkIntent)
|
||||
}
|
||||
|
||||
override fun onVideoCLick(videoId: String) = Unit
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override fun getTvComment(binding: ViewBinding): TextView = (binding as RecyclerGameArticleBinding).tvComment
|
||||
|
||||
override fun getTvShare(binding: ViewBinding): TextView = (binding as RecyclerGameArticleBinding).tvShare
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import android.widget.LinearLayout
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.common.util.ConcernContentUtils
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IConcernContentUtilsProvider
|
||||
|
||||
@Route(path = RouteConsts.provider.concernContentUtils, name = "ConcernContentUtils暴露服务")
|
||||
class ConcernContentUtilsProviderImpl : IConcernContentUtilsProvider {
|
||||
override fun addContentPic(
|
||||
context: Context,
|
||||
linearLayout: LinearLayout,
|
||||
list: List<String>,
|
||||
entrance: String,
|
||||
width: Int
|
||||
) {
|
||||
ConcernContentUtils.addContentPic(context, linearLayout, list, entrance, width)
|
||||
}
|
||||
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.utils.goneIf
|
||||
import com.gh.gamecenter.common.utils.toColor
|
||||
import com.gh.gamecenter.core.provider.IConcernGiftPackUtilsProvider
|
||||
import com.gh.gamecenter.databinding.RecyclerGiftPackBinding
|
||||
|
||||
@Route(path = RouteConsts.provider.concernGiftPackUtils, name = "ConcernGiftPackUtils暴露服务")
|
||||
class ConcernGiftPackUtilsProviderImpl : IConcernGiftPackUtilsProvider {
|
||||
override fun createBinding(parent: ViewGroup): ViewBinding {
|
||||
val inflater = LayoutInflater.from(parent.context)
|
||||
return RecyclerGiftPackBinding.inflate(inflater, parent, false)
|
||||
.also {
|
||||
it.gCode.goneIf(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun initStyle(viewBinding: ViewBinding) {
|
||||
with(viewBinding as RecyclerGiftPackBinding) {
|
||||
val context = root.context
|
||||
tvGameName.setTextColor(R.color.text_primary.toColor(context))
|
||||
tvTime.setTextColor(R.color.text_tertiary.toColor(context))
|
||||
tvGiftPackName.setTextColor(R.color.text_primary.toColor(context))
|
||||
tvGiftPackContent.setTextColor(R.color.text_secondary.toColor(context))
|
||||
}
|
||||
}
|
||||
|
||||
override fun getIvGameIcon(viewBinding: ViewBinding) =
|
||||
(viewBinding as RecyclerGiftPackBinding).ivIcon
|
||||
|
||||
override fun getTvGameName(viewBinding: ViewBinding) =
|
||||
(viewBinding as RecyclerGiftPackBinding).tvGameName
|
||||
|
||||
override fun getTvTime(viewBinding: ViewBinding) =
|
||||
(viewBinding as RecyclerGiftPackBinding).tvTime
|
||||
|
||||
override fun getTvGiftPackName(viewBinding: ViewBinding) =
|
||||
(viewBinding as RecyclerGiftPackBinding).tvGiftPackName
|
||||
|
||||
override fun getTvGiftPackContent(viewBinding: ViewBinding) =
|
||||
(viewBinding as RecyclerGiftPackBinding).tvGiftPackContent
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do Nothing
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IConcernShareNewsProvider
|
||||
import com.gh.gamecenter.newsdetail.NewsShareDialog
|
||||
|
||||
@Route(path = RouteConsts.provider.concernShareNews, name = "ConcernShareNews暴露服务")
|
||||
class ConcernShareNewsProviderImpl : IConcernShareNewsProvider {
|
||||
override fun share(activity: AppCompatActivity, shortId: String?, id: String?, gameIcon: String?, title: String?) {
|
||||
NewsShareDialog.show(activity, shortId, id, gameIcon, title)
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do Nothing
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
@ -69,10 +70,18 @@ class DirectProviderImpl : IDirectProvider {
|
||||
DirectUtils.directToAmway(context, fixedTopAmwayCommentId, entrance, path)
|
||||
}
|
||||
|
||||
override fun directToQGame(context: Context) {
|
||||
override fun directToQQGameHome(context: Context) {
|
||||
return DirectUtils.directToQGameHome(context)
|
||||
}
|
||||
|
||||
override fun directToQQGameById(activity: Activity, qqAppId: String) {
|
||||
DirectUtils.directToQQGameById(activity, qqAppId)
|
||||
}
|
||||
|
||||
override fun directToWechatGameById(activity: Activity, qqAppId: String) {
|
||||
DirectUtils.directToWechatGameById(activity, qqAppId)
|
||||
}
|
||||
|
||||
override fun directToExternalBrowser(context: Context, url: String) {
|
||||
DirectUtils.directToExternalBrowser(context, url)
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ class PackageUtilsProviderImpl : IPackageUtilsProvider {
|
||||
}
|
||||
|
||||
override fun getInstalledPackages(context: Context, flag: Int): List<PackageInfo> {
|
||||
return PackageHelper.getInstalledPackages(context, flag)
|
||||
return PackageHelper.getInstalledPackageInfoList(context, flag)
|
||||
}
|
||||
|
||||
override fun getApkSignatureByPackageName(context: Context, packageName: String): Array<String> {
|
||||
|
||||
@ -19,8 +19,10 @@ import com.gh.gamecenter.databinding.DialogArchiveLoadingBinding
|
||||
import com.gh.gamecenter.entity.ArchiveEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.va.VCore
|
||||
import com.gh.vspace.VArchiveHelper
|
||||
import com.gh.vspace.VHelper
|
||||
import com.gh.vspace.VHelper.is32
|
||||
import com.lg.download.DownloadError
|
||||
import com.lg.download.DownloadStatus
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
@ -50,8 +52,6 @@ object ArchiveDownloadButtonHelper {
|
||||
}
|
||||
downloadBtn.setOnClickListener {
|
||||
when {
|
||||
// 检查是否已安装畅玩助手
|
||||
!VHelper.isVSpaceInstalled(context) -> showVSpaceTipDialog(context, gameEntity)
|
||||
// 检查是否已安装游戏
|
||||
!VHelper.isInstalled(packageName) -> {
|
||||
// 检查游戏是否在安装中
|
||||
@ -273,14 +273,19 @@ object ArchiveDownloadButtonHelper {
|
||||
R.string.archive_apply.toResString(),
|
||||
R.string.cancel.toResString(),
|
||||
{
|
||||
applyArchive(context, entrance, packageName, config, archiveEntity, gameEntity)
|
||||
NewFlatLogUtils.logCloudArchiveApplyDialogRelated("cloud_save_overwrite_dialog_click", "使用")
|
||||
SensorsBridge.trackEvent(
|
||||
"CloudSaveOverwriteDialogClick",
|
||||
"game_id", gameEntity?.id ?: "",
|
||||
"game_name", gameEntity?.name ?: "",
|
||||
"button_name", "使用"
|
||||
)
|
||||
if(gameEntity.is32() && VHelper.isInnerInstalled(packageName) && !VCore.getInstance().isExtPackageInstalled()) {
|
||||
// 32位的游戏 并且 32位畅玩没有安装 并且 一体化
|
||||
VHelper.newCwValidateVspaceBeforeAction(context, gameEntity) {}
|
||||
} else {
|
||||
applyArchive(context, entrance, packageName, config, archiveEntity, gameEntity)
|
||||
NewFlatLogUtils.logCloudArchiveApplyDialogRelated("cloud_save_overwrite_dialog_click", "使用")
|
||||
SensorsBridge.trackEvent(
|
||||
"CloudSaveOverwriteDialogClick",
|
||||
"game_id", gameEntity?.id ?: "",
|
||||
"game_name", gameEntity?.name ?: "",
|
||||
"button_name", "使用"
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
NewFlatLogUtils.logCloudArchiveApplyDialogRelated("cloud_save_overwrite_dialog_click", "取消")
|
||||
|
||||
@ -7,8 +7,8 @@ import android.widget.LinearLayout;
|
||||
import com.facebook.drawee.drawable.ScalingUtils;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.gamecenter.ImageViewerActivity;
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils;
|
||||
import com.gh.gamecenter.common.utils.ImageUtils;
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -121,5 +121,4 @@ public class ConcernContentUtils {
|
||||
}
|
||||
return imageView;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,17 +1,14 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts;
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil;
|
||||
import com.gh.gamecenter.common.utils.NetworkUtils;
|
||||
import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.NewsDetailEntity;
|
||||
import com.gh.gamecenter.feature.utils.PlatformUtils;
|
||||
import com.gh.gamecenter.manager.DataCollectionManager;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -32,7 +29,7 @@ public class DataCollectionUtils {
|
||||
map.put("type", android.os.Build.MODEL);
|
||||
map.put("system", android.os.Build.VERSION.SDK_INT + "=" + android.os.Build.VERSION.RELEASE);
|
||||
// WIFI实时
|
||||
DataCollectionManager.onEvent(context, "error", map, NetworkUtils.isWifiConnected(context));
|
||||
DataCollectionManager.onEvent(context, "error", map, true);
|
||||
}
|
||||
|
||||
// 上传下载数据(开始、完成)
|
||||
|
||||
@ -9,17 +9,18 @@ import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.gh.ad.AdDelegateHelper;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager;
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.constant.RouteConsts;
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil;
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse;
|
||||
import com.gh.gamecenter.core.AppExecutor;
|
||||
import com.gh.gamecenter.core.provider.ISentryProvider;
|
||||
import com.gh.gamecenter.core.utils.GsonUtils;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
import com.gh.gamecenter.core.utils.SentryHelper;
|
||||
import com.gh.gamecenter.feature.utils.SentryHelper;
|
||||
import com.gh.gamecenter.login.entity.IdCardEntity;
|
||||
import com.gh.gamecenter.login.entity.UserInfoEntity;
|
||||
import com.gh.gamecenter.provider.GhContentProvider;
|
||||
@ -31,9 +32,6 @@ import com.lightgame.config.CommonDebug;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.sentry.Sentry;
|
||||
import io.sentry.android.core.SentryAndroid;
|
||||
import kotlin.Pair;
|
||||
|
||||
/**
|
||||
* Created by LGT on 2016/6/15.
|
||||
@ -57,50 +55,10 @@ public class DataUtils {
|
||||
}
|
||||
|
||||
private static void initSentry(Context context, String channel) {
|
||||
SentryAndroid.init(context, options -> {
|
||||
// Sentry 疯狂报 ANR (很大一部分还是莫名奇妙的 ANR)严重影响到其它闪退日志的收集
|
||||
// 这里将它局限到只有官网渠道的包才统计 ANR
|
||||
if ("GH_206".equals(channel) || "GH_BETA".equals(channel) || com.gh.gamecenter.common.BuildConfig.BUILD_TIME != 0) {
|
||||
options.setAnrEnabled(true);
|
||||
options.setAnrTimeoutIntervalMillis(6000);
|
||||
} else {
|
||||
options.setAnrEnabled(false);
|
||||
}
|
||||
|
||||
options.setDebug(BuildConfig.DEBUG);
|
||||
options.setEnableAutoSessionTracking(true);
|
||||
options.setEnvironment(BuildConfig.FLAVOR);
|
||||
options.setEnableSystemEventBreadcrumbs(false);
|
||||
options.setDsn("https://6b1caf0d17c1408e8680f3f73ff80bd0@sentry.shanqu.cc/22");
|
||||
|
||||
options.setBeforeSend((event, hint) -> {
|
||||
if (BuildConfig.DEBUG) {
|
||||
return null;
|
||||
} else {
|
||||
return event;
|
||||
}
|
||||
});
|
||||
|
||||
options.setBeforeBreadcrumb(((breadcrumb, hint) -> {
|
||||
if ("ui.lifecycle".equals(breadcrumb.getCategory()) && "started".equals(breadcrumb.getData("state")) && GlobalActivityManager.INSTANCE.getCurrentActivity() instanceof BaseActivity) {
|
||||
Pair<String, String> businessId = ((BaseActivity) GlobalActivityManager.INSTANCE.getCurrentActivity()).getBusinessId();
|
||||
if (businessId != null) {
|
||||
breadcrumb.setData("businessId1", businessId.component1());
|
||||
breadcrumb.setData("businessId2", businessId.component2());
|
||||
}
|
||||
}
|
||||
return breadcrumb;
|
||||
}));
|
||||
});
|
||||
|
||||
Sentry.configureScope(scope -> {
|
||||
if (com.gh.gamecenter.common.BuildConfig.BUILD_TIME != 0L) {
|
||||
scope.setTag("alias", "内测版" + BuildConfig.VERSION_NAME);
|
||||
} else {
|
||||
scope.setTag("alias", "正式版" + BuildConfig.VERSION_NAME);
|
||||
scope.setTag("channel", channel);
|
||||
}
|
||||
});
|
||||
ISentryProvider sentryProvider = (ISentryProvider) ARouter.getInstance().build(RouteConsts.provider.sentry).navigation();
|
||||
if (sentryProvider != null) {
|
||||
sentryProvider.init(context, channel, BuildConfig.FLAVOR, BuildConfig.VERSION_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
public static void getGid() {
|
||||
|
||||
@ -633,7 +633,19 @@ public class DialogUtils {
|
||||
|
||||
binding.gameIcon.displayGameIcon(gameEntity);
|
||||
binding.gameNameTv.setText(context.getString(R.string.dialog_land_page_address_hint, gameEntity.getName()));
|
||||
binding.closeIv.setOnClickListener(v -> dialog.dismiss());
|
||||
|
||||
AtomicBoolean dismissByButton = new AtomicBoolean(false);
|
||||
|
||||
binding.closeIv.setOnClickListener(v -> {
|
||||
dismissByButton.set(true);
|
||||
SensorsBridge.INSTANCE.trackJumpLandPageAddressDialogClick(
|
||||
"取消",
|
||||
gameEntity.getId(),
|
||||
gameEntity.getName() != null ? gameEntity.getName() : "",
|
||||
gameEntity.getCategoryChinese()
|
||||
);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
binding.urlTv.setText(gameEntity.getLandPageAddressDialog().getLink());
|
||||
|
||||
@ -643,10 +655,28 @@ public class DialogUtils {
|
||||
|
||||
binding.downloadBtn.setText(downloadText);
|
||||
binding.downloadBtn.setOnClickListener(v -> {
|
||||
dismissByButton.set(true);
|
||||
SensorsBridge.INSTANCE.trackJumpLandPageAddressDialogClick(
|
||||
"前往第三方网站下载游戏",
|
||||
gameEntity.getId(),
|
||||
gameEntity.getName() != null ? gameEntity.getName() : "",
|
||||
gameEntity.getCategoryChinese()
|
||||
);
|
||||
listener.onConfirm();
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.setOnDismissListener(dialog1 -> {
|
||||
if (!dismissByButton.get()) {
|
||||
SensorsBridge.INSTANCE.trackJumpLandPageAddressDialogClick(
|
||||
"关闭弹窗",
|
||||
gameEntity.getId(),
|
||||
gameEntity.getName() != null ? gameEntity.getName() : "",
|
||||
gameEntity.getCategoryChinese()
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null) {
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
@ -655,6 +685,12 @@ public class DialogUtils {
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
|
||||
SensorsBridge.INSTANCE.trackJumpLandPageAddressDialogShow(
|
||||
gameEntity.getId(),
|
||||
gameEntity.getName() != null ? gameEntity.getName() : "",
|
||||
gameEntity.getCategoryChinese()
|
||||
);
|
||||
}
|
||||
|
||||
public static void showGameH5DownloadDialog(Context context, GameEntity gameEntity, RegionSetting.GameH5Download gameH5Download) {
|
||||
|
||||
@ -10,6 +10,7 @@ import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.os.bundleOf
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.exposure.ExposureManager.log
|
||||
@ -43,11 +44,13 @@ import com.gh.gamecenter.feature.entity.MeEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent.Companion.createEvent
|
||||
import com.gh.gamecenter.feature.exposure.ExposureType
|
||||
import com.gh.gamecenter.feature.minigame.MiniGameItemHelper
|
||||
import com.gh.gamecenter.feature.provider.IConcernInfoProvider
|
||||
import com.gh.gamecenter.forum.detail.ForumDetailActivity
|
||||
import com.gh.gamecenter.forum.home.CommunityActivity
|
||||
import com.gh.gamecenter.forum.search.ForumOrUserSearchActivity
|
||||
import com.gh.gamecenter.game.columncollection.detail.ColumnCollectionDetailActivity
|
||||
import com.gh.gamecenter.game.columncollection.detail.ColumnCollectionDetailFragment
|
||||
import com.gh.gamecenter.game.commoncollection.detail.CustomCommonCollectionDetailActivity
|
||||
import com.gh.gamecenter.game.upload.GameSubmissionActivity
|
||||
import com.gh.gamecenter.gamecollection.detail.GameCollectionDetailActivity
|
||||
@ -63,6 +66,9 @@ import com.gh.gamecenter.gamedetail.rating.RatingReplyActivity
|
||||
import com.gh.gamecenter.help.HelpAndFeedbackBridge
|
||||
import com.gh.gamecenter.libao.LibaoDetailActivity
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.minigame.MiniGameRecentlyPlayUseCase
|
||||
import com.gh.gamecenter.minigame.MiniGameSearchActivity
|
||||
import com.gh.gamecenter.minigame.qq.QGameHomeWrapperActivity
|
||||
import com.gh.gamecenter.newsdetail.NewsDetailActivity
|
||||
import com.gh.gamecenter.personalhome.UserHomeActivity
|
||||
import com.gh.gamecenter.personalhome.background.PersonalityBackgroundActivity
|
||||
@ -73,9 +79,6 @@ import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity
|
||||
import com.gh.gamecenter.qa.questions.newdetail.NewQuestionDetailActivity
|
||||
import com.gh.gamecenter.qa.subject.CommunitySubjectActivity
|
||||
import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity
|
||||
import com.gh.gamecenter.qgame.QGameHomeWrapperActivity
|
||||
import com.gh.gamecenter.qgame.QGameSearchActivity
|
||||
import com.gh.gamecenter.qgame.QGameViewModel
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.servers.GameServerTestActivity
|
||||
import com.gh.gamecenter.servers.GameServersActivity
|
||||
@ -95,6 +98,8 @@ import com.gh.vspace.VDownloadManagerActivity
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.halo.assistant.fragment.WebFragment
|
||||
import com.lightgame.utils.Utils
|
||||
import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import retrofit2.HttpException
|
||||
@ -108,8 +113,14 @@ import kotlin.math.roundToInt
|
||||
object DirectUtils {
|
||||
|
||||
@JvmStatic
|
||||
fun directToLinkPage(context: Context, linkEntity: LinkEntity, entrance: String, path: String, sourceEntrance: String = "") {
|
||||
directToLinkPage(context, linkEntity, entrance, path, null, sourceEntrance)
|
||||
fun directToLinkPage(
|
||||
context: Context,
|
||||
linkEntity: LinkEntity,
|
||||
entrance: String,
|
||||
path: String,
|
||||
sourceEntrance: String = ""
|
||||
) {
|
||||
directToLinkPage(context, linkEntity, entrance, path, null, sourceEntrance)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@ -243,7 +254,7 @@ object DirectUtils {
|
||||
path
|
||||
)
|
||||
|
||||
HOST_WEB, HOST_WEB_INURL, HOST_WEB_AL -> {
|
||||
HOST_WEB, HOST_WEB_INURL, HOST_WEB_AL, HOST_QA_CONTENT -> {
|
||||
when {
|
||||
linkEntity.link!!.contains("v.douyin") && PackageHelper.localPackageNameSet.contains("com.ss.android.ugc.aweme") -> {
|
||||
directDouyin(context, "1402577827140941")
|
||||
@ -343,9 +354,9 @@ object DirectUtils {
|
||||
|
||||
"feedback" -> directToFeedback(context, linkEntity.name, false, "", false, false, entrance)
|
||||
|
||||
"qa", "qa_content", "Q&A" -> directToQa(context, linkEntity.text ?: "", linkEntity.link ?: "")
|
||||
"qa", "Q&A" -> directToQa(context, linkEntity.text ?: "", linkEntity.link ?: "")
|
||||
|
||||
"qa_list" -> directToHelpAndFeedback(context)
|
||||
"qa_list" -> directToHelpAndFeedback(context, bundleOf(KEY_ENTRANCE to entrance))
|
||||
|
||||
"qa_collection", "Q&A合集" -> directToQaCollection(
|
||||
context, linkEntity.text
|
||||
@ -475,17 +486,22 @@ object DirectUtils {
|
||||
)
|
||||
)
|
||||
|
||||
"qq_mini_game_column" -> directToQGameHome(context)
|
||||
ColumnCollectionDetailFragment.TYPE_QQ_MINI_GAME_COLUMN -> directToQGameHome(context)
|
||||
|
||||
// QQ游戏专题详情页
|
||||
"qq_mini_game_column_detail" -> {
|
||||
ViewPagerFragmentHelper.TYPE_QQ_MINI_GAME_COLUMN, ViewPagerFragmentHelper.TYPE_WECHAT_GAME_COLUMN -> {
|
||||
val subjectType = if (linkEntity.type == ViewPagerFragmentHelper.TYPE_QQ_MINI_GAME_COLUMN) {
|
||||
SubjectData.SubjectType.QQ_GAME
|
||||
} else {
|
||||
SubjectData.SubjectType.WECHAT_GAME
|
||||
}
|
||||
directToSubject(
|
||||
context = context,
|
||||
id = linkEntity.link ?: "",
|
||||
subjectName = linkEntity.text,
|
||||
entrance = BaseActivity.mergeEntranceAndPath(entrance, path),
|
||||
exposureEvent = exposureEvent,
|
||||
isQQMiniGame = true
|
||||
subjectType = subjectType
|
||||
)
|
||||
}
|
||||
|
||||
@ -536,6 +552,10 @@ object DirectUtils {
|
||||
}
|
||||
}
|
||||
|
||||
"wechat_game" -> linkEntity.link?.let {
|
||||
MiniGameItemHelper.launchMiniGame(it, Constants.WECHAT_MINI_GAME)
|
||||
}
|
||||
|
||||
"" -> {
|
||||
// do nothing
|
||||
}
|
||||
@ -774,7 +794,12 @@ object DirectUtils {
|
||||
}
|
||||
}
|
||||
if (traceEvent != null) {
|
||||
val clickEvent = createEvent(GameEntity(id = id, name = name), traceEvent.source, appendTrace(traceEvent), ExposureType.CLICK)
|
||||
val clickEvent = createEvent(
|
||||
GameEntity(id = id, name = name),
|
||||
traceEvent.source,
|
||||
appendTrace(traceEvent),
|
||||
ExposureType.CLICK
|
||||
)
|
||||
log(clickEvent)
|
||||
bundle.putParcelable(KEY_TRACE_EVENT, clickEvent)
|
||||
}
|
||||
@ -837,12 +862,12 @@ object DirectUtils {
|
||||
subjectName: String? = "",
|
||||
entrance: String? = null,
|
||||
exposureEvent: ExposureEvent? = null,
|
||||
isQQMiniGame: Boolean = false,
|
||||
subjectType: SubjectData.SubjectType = SubjectData.SubjectType.NORMAL
|
||||
) {
|
||||
if (id.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
val subjectData =
|
||||
SubjectData(subjectId = id, subjectName = subjectName, isOrder = false, isQQMiniGame = isQQMiniGame)
|
||||
SubjectData(subjectId = id, subjectName = subjectName, isOrder = false, subjectType = subjectType)
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_TO, SubjectActivity::class.java.name)
|
||||
bundle.putParcelable(EntranceConsts.KEY_SUBJECT_DATA, subjectData)
|
||||
@ -899,12 +924,16 @@ object DirectUtils {
|
||||
qaContentId: String? = "",
|
||||
isPlugin: Boolean = false,
|
||||
isSmoothGame: Boolean = false,
|
||||
gameId: String? = "",
|
||||
gameName: String? = "",
|
||||
entrance: String? = null
|
||||
) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putBoolean(KEY_PLUGIN, isPlugin)
|
||||
bundle.putBoolean(KEY_SMOOTH_GAME, isSmoothGame)
|
||||
bundle.putString(KEY_GAME_ID, gameId)
|
||||
bundle.putString(KEY_GAME_NAME, gameName)
|
||||
if (isPlugin) {
|
||||
bundle.putString(KEY_HIDE_SUGGEST_HINT, "【插件问题】")
|
||||
}
|
||||
@ -991,7 +1020,13 @@ object DirectUtils {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToQuestionDetail(context: Context, id: String, entrance: String? = null, path: String? = null, sourceEntrance: String = "") {
|
||||
fun directToQuestionDetail(
|
||||
context: Context,
|
||||
id: String,
|
||||
entrance: String? = null,
|
||||
path: String? = null,
|
||||
sourceEntrance: String = ""
|
||||
) {
|
||||
if (id.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
@ -1935,7 +1970,7 @@ object DirectUtils {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToQGameSearch(
|
||||
fun directToMiniGameSearch(
|
||||
context: Context,
|
||||
hint: String,
|
||||
sourceEntrance: String,
|
||||
@ -1947,7 +1982,7 @@ object DirectUtils {
|
||||
searchBoxPattern: String = ""
|
||||
) {
|
||||
context.startActivity(
|
||||
QGameSearchActivity.getIntent(
|
||||
MiniGameSearchActivity.getIntent(
|
||||
context,
|
||||
hint,
|
||||
sourceEntrance,
|
||||
@ -1963,11 +1998,10 @@ object DirectUtils {
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@JvmStatic
|
||||
fun directToQGameById(
|
||||
fun directToQQGameById(
|
||||
activity: Activity,
|
||||
qqGameId: String
|
||||
qqAppId: String
|
||||
) {
|
||||
|
||||
if (activity !is AppCompatActivity || activity.supportFragmentManager.isDestroyed) {
|
||||
ToastUtils.toast("启动QQ小游戏失败,请稍后再试")
|
||||
return
|
||||
@ -1988,25 +2022,40 @@ object DirectUtils {
|
||||
val qGameProvider = ARouter
|
||||
.getInstance()
|
||||
.build(RouteConsts.provider.qGame)
|
||||
.navigation() as IQGameProvider<*>
|
||||
qGameProvider.setLoginInfo(activity, userId, userName, userToken)
|
||||
qGameProvider.launchGame(activity, qqGameId) { _, _ ->
|
||||
RetrofitManager
|
||||
.getInstance()
|
||||
.newApi
|
||||
.postQGamePlay(qqGameId, userId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{
|
||||
QGameViewModel.notifyQGameSubjectUpdate() // 通知QQ小游戏首页列表刷新
|
||||
},
|
||||
{}
|
||||
) // 秒玩记录上报
|
||||
.navigation() as? IQGameProvider
|
||||
qGameProvider?.setLoginInfo(activity, userId, userName, userToken)
|
||||
qGameProvider?.launchGame(activity, qqAppId) { _, _ ->
|
||||
MiniGameRecentlyPlayUseCase.submitRecentPlayedQGame(qqAppId, userId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun directToWechatGameById(
|
||||
activity: Activity,
|
||||
wechatAppId: String,
|
||||
) {
|
||||
|
||||
val wxApiProxy = WXAPIFactory.createWXAPI(
|
||||
activity,
|
||||
Config.WECHAT_APPID
|
||||
)
|
||||
if (!wxApiProxy.isWXAppInstalled) {
|
||||
ToastUtils.toast("请安装微信客户端")
|
||||
return
|
||||
}
|
||||
|
||||
wxApiProxy.sendReq(
|
||||
WXLaunchMiniProgram.Req().apply {
|
||||
userName = wechatAppId
|
||||
path = Constants.WECHAT_MINI_GAME_PCS
|
||||
miniprogramType = WXLaunchMiniProgram.Req.MINIPTOGRAM_TYPE_RELEASE;
|
||||
}
|
||||
)
|
||||
|
||||
MiniGameRecentlyPlayUseCase.submitRecentPlayedWGame(wechatAppId, HaloApp.getInstance().gid)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToMessageCenter(defaultTabIndex: Int) {
|
||||
ARouter.getInstance().build(RouteConsts.activity.messageWrapperActivity)
|
||||
@ -2082,7 +2131,7 @@ object DirectUtils {
|
||||
)
|
||||
)
|
||||
|
||||
BottomTab.SearchStyle.TYPE_QQ_MINI_GAME -> directToQGameSearch(
|
||||
BottomTab.SearchStyle.TYPE_MINI_GAME -> directToMiniGameSearch(
|
||||
context,
|
||||
"请输入小游戏关键词",
|
||||
sourceEntrance,
|
||||
|
||||
@ -27,7 +27,6 @@ import com.gh.download.server.BrowserInstallHelper
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.adapter.viewholder.GameViewHolder
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager
|
||||
import com.gh.gamecenter.common.callback.CancelListener
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
@ -41,6 +40,7 @@ import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.view.DownloadButton
|
||||
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
import com.gh.gamecenter.feature.minigame.MiniGameItemHelper
|
||||
import com.gh.gamecenter.teenagermode.TeenagerModeActivity
|
||||
import com.gh.vspace.VHelper
|
||||
import com.lightgame.download.DownloadConfig
|
||||
@ -247,9 +247,8 @@ object DownloadItemUtils {
|
||||
}
|
||||
return
|
||||
}
|
||||
if (gameEntity.isQQMiniGame()) {
|
||||
val isQQMiniGameOffShelve = gameEntity.qqMiniGameAppStatus == 1 // QQ小游戏是否下架
|
||||
if (isQQMiniGameOffShelve) {
|
||||
if (gameEntity.isMiniGame()) {
|
||||
if (gameEntity.isMiniGameOffShelve()) {
|
||||
downloadBtn.apply {
|
||||
isClickable = false
|
||||
text = context.getString(R.string.off_shelve)
|
||||
@ -844,12 +843,11 @@ object DownloadItemUtils {
|
||||
}
|
||||
return
|
||||
}
|
||||
if (gameEntity.isQQMiniGame()) {
|
||||
if (gameEntity.isMiniGame()) {
|
||||
downloadBtn.setOnClickListener {
|
||||
NewFlatLogUtils.logQGameClick(gameEntity.qqMiniGameAppId, gameEntity.name)
|
||||
GlobalActivityManager.currentActivity?.let { activity ->
|
||||
DirectUtils.directToQGameById(activity, gameEntity.qqMiniGameAppId)
|
||||
}
|
||||
MiniGameItemHelper.launchMiniGame(gameEntity.miniGameAppId, gameEntity.miniGameType)
|
||||
clickCallback?.onCallback()
|
||||
allStateClickCallback?.onCallback()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -508,11 +508,18 @@ object DownloadObserver {
|
||||
"space_schema_type",
|
||||
if (downloadEntity.packageName == VHelper.VSPACE_32BIT_PACKAGENAME) "32位" else "64位"
|
||||
)
|
||||
} else if(downloadEntity.gameId == Constants.HALO_FUN_NEW_32_GAME_ID) {
|
||||
SensorsBridge.trackEvent(
|
||||
"HaloFunDownloadDone",
|
||||
"space_schema_type",
|
||||
"32位(新)"
|
||||
)
|
||||
}
|
||||
|
||||
if (downloadEntity.gameId != Constants.GHZS_GAME_ID
|
||||
&& downloadEntity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE) != Constants.SIMULATOR_DOWNLOAD
|
||||
&& downloadEntity.gameId != Constants.HALO_FUN_GAME_ID
|
||||
&& downloadEntity.gameId != Constants.HALO_FUN_NEW_32_GAME_ID
|
||||
) {
|
||||
val trackJson = downloadEntity.customPageTrackDataJson
|
||||
val kvs = if (!trackJson.isNullOrBlank()) {
|
||||
|
||||
@ -282,7 +282,7 @@ object GameActivityDownloadHelper {
|
||||
location: String,
|
||||
traceEvent: ExposureEvent
|
||||
) {
|
||||
VHelper.validateVSpaceBeforeAction(context, gameEntity) {
|
||||
VHelper.validateVSpaceBeforeAction(context,gameEntity.getUniquePackageName(), gameEntity) {
|
||||
GamePermissionDialogFragment.show((context as AppCompatActivity), gameEntity, gameEntity.info) {
|
||||
DialogUtils.checkDownload(
|
||||
context,
|
||||
|
||||
@ -49,13 +49,8 @@ public class InstallUtils {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == INSTALL_WHAT && packageManager != null) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
List<PackageInfo> packageInfos = PackageHelper.INSTANCE.getInstalledPackages(context, 0);
|
||||
for (PackageInfo packageInfo : packageInfos) {
|
||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
list.add(packageInfo.packageName);
|
||||
}
|
||||
}
|
||||
List<String> packageNameList = PackageHelper.INSTANCE.getInstalledPackageNameList(context, 0);
|
||||
ArrayList<String> list = new ArrayList<>(packageNameList);
|
||||
if (installMap != null && installMap.size() != 0) {
|
||||
ArrayList<String> keys = new ArrayList<>();
|
||||
for (String packageName : installMap.keySet()) {
|
||||
|
||||
@ -768,10 +768,10 @@ public class LibaoUtils {
|
||||
}
|
||||
|
||||
public static boolean isAppInstalled(Context context, String packageName) {
|
||||
List<PackageInfo> pinfo = PackageHelper.INSTANCE.getInstalledPackages(context, 0);
|
||||
if (pinfo != null) {
|
||||
for (int i = 0; i < pinfo.size(); i++) {
|
||||
String pn = pinfo.get(i).packageName;
|
||||
List<String> packageNameList = PackageHelper.INSTANCE.getInstalledPackageNameList(context, 0);
|
||||
if (packageNameList != null) {
|
||||
for (int i = 0; i < packageNameList.size(); i++) {
|
||||
String pn = packageNameList.get(i);
|
||||
if (pn.equals(packageName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -93,12 +93,13 @@ object NewFlatLogUtils {
|
||||
|
||||
// 畅玩助手更新弹窗展示事件
|
||||
@JvmStatic
|
||||
fun logHaloFunUpdateDialogShow(gameId: String, gameName: String, gameArchitecture: String) {
|
||||
fun logHaloFunUpdateDialogShow(gameId: String, gameName: String, gameArchitecture: String, targetVaVersion: String) {
|
||||
val json = json {
|
||||
KEY_EVENT to "halo_fun_update_dialog_show"
|
||||
"game_id" to gameId
|
||||
"game_name" to gameName
|
||||
"game_architecture" to gameArchitecture
|
||||
"target_va_version" to targetVaVersion
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
@ -142,12 +143,13 @@ object NewFlatLogUtils {
|
||||
|
||||
// 畅玩助手更新弹窗点击事件
|
||||
@JvmStatic
|
||||
fun logHaloFunUpdateDialogClick(dialogType: String, buttonType: String, architecture: String) {
|
||||
fun logHaloFunUpdateDialogClick(dialogType: String, buttonType: String, architecture: String, targetVaVersion: String) {
|
||||
val json = json {
|
||||
KEY_EVENT to "halo_fun_update_dialog_click"
|
||||
"dialog_type" to dialogType
|
||||
KEY_BUTTON_TYPE to buttonType
|
||||
"architecture" to architecture
|
||||
"target_va_version" to targetVaVersion
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
@ -2007,29 +2009,6 @@ object NewFlatLogUtils {
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// vpn 弹窗显示
|
||||
fun logVpnHintDialogShow(gameId: String, gameName: String) {
|
||||
val json = json {
|
||||
KEY_EVENT to "vpn_pre_access_dialog_show"
|
||||
KEY_GAME_ID to gameId
|
||||
KEY_GAME_NAME to gameName
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// vpn 弹窗点击
|
||||
fun logVpnHintDialogClick(gameId: String, gameName: String, button: String) {
|
||||
val json = json {
|
||||
KEY_EVENT to "vpn_pre_access_dialog_click"
|
||||
KEY_GAME_ID to gameId
|
||||
KEY_GAME_NAME to gameName
|
||||
"button" to button
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 谷歌框架弹窗显示
|
||||
fun logGAppsDialogShowed(gameId: String, gameName: String) {
|
||||
val json = json {
|
||||
@ -2600,17 +2579,6 @@ object NewFlatLogUtils {
|
||||
log(json)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun logQGameClick(qqGameId: String, qqGameName: String?) {
|
||||
val json = json {
|
||||
KEY_EVENT to "qq_game_click"
|
||||
"qq_game_id" to qqGameId
|
||||
"qq_game_name" to qqGameName ?: ""
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
}
|
||||
|
||||
// 点击个人主页的认证文案事件
|
||||
@JvmStatic
|
||||
fun logClickAuthText(linkType: String, linkId: String, linkText: String, userId: String, text: String) {
|
||||
|
||||
@ -7,6 +7,7 @@ import com.gh.download.PackageObserver
|
||||
import com.gh.gamecenter.common.utils.NewFlatLogUtils
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository
|
||||
import com.lightgame.utils.Utils
|
||||
@ -75,11 +76,17 @@ object PackageChangeHelper : DefaultLifecycleObserver {
|
||||
|
||||
PackageRepository.addInstalledGame(packageName)
|
||||
|
||||
// 添加到额外的包名白名单,下次启动同时查询此包的安装情况
|
||||
PackageHelper.updateAdditionalWhiteListPackageName(packageName = packageName, isAdd = true)
|
||||
|
||||
performInstallSuccessAction(packageName)
|
||||
} else if (isUninstallPending && !isInstalled) {
|
||||
pendingPackagePair = null
|
||||
pendingGhId = null
|
||||
|
||||
// 从额外的包名白名单移除,下次启动时不再查询此包的安装情况
|
||||
PackageHelper.updateAdditionalWhiteListPackageName(packageName = packageName, isAdd = false)
|
||||
|
||||
performUninstallSuccessAction(packageName)
|
||||
} else if (isUpdatePending) {
|
||||
val isUpdateValid = if (installedVersionName != pendingVersion) {
|
||||
@ -95,23 +102,41 @@ object PackageChangeHelper : DefaultLifecycleObserver {
|
||||
performUninstallSuccessAction(packageName)
|
||||
performInstallSuccessAction(packageName)
|
||||
}
|
||||
|
||||
// 添加到额外的包名白名单,下次启动同时查询此包的安装情况
|
||||
PackageHelper.updateAdditionalWhiteListPackageName(packageName = packageName, isAdd = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun addInstall(packageName: String) {
|
||||
performInstallSuccessAction(packageName)
|
||||
/**
|
||||
* 对外暴露的方法,用于添加一个安装成功的应用
|
||||
* @param packageName 包名
|
||||
* @param cachedGameEntity 缓存的 GameEntity,用于快速更新状态
|
||||
*/
|
||||
fun addInstall(packageName: String, cachedGameEntity: GameEntity? = null) {
|
||||
performInstallSuccessAction(packageName, cachedGameEntity)
|
||||
}
|
||||
|
||||
fun addUpdate(packageName: String) {
|
||||
/**
|
||||
* 对外暴露的方法,用于添加一个卸载成功的应用
|
||||
* @param packageName 包名
|
||||
* @param cachedGameEntity 缓存的 GameEntity,用于快速更新状态
|
||||
*/
|
||||
fun addUpdate(packageName: String, cachedGameEntity: GameEntity? = null) {
|
||||
performUninstallSuccessAction(packageName)
|
||||
performInstallSuccessAction(packageName)
|
||||
performInstallSuccessAction(packageName, cachedGameEntity)
|
||||
}
|
||||
|
||||
/**
|
||||
* 对应包名安装成功后的操作,继承至 PackageChangeBroadcastObserver
|
||||
* @param packageName 包名
|
||||
* @param cachedGameEntity 缓存的 GameEntity,用于快速更新状态
|
||||
* @param withLog 是否需要记录日志
|
||||
*/
|
||||
private fun performInstallSuccessAction(packageName: String, withLog: Boolean = true) {
|
||||
private fun performInstallSuccessAction(packageName: String,
|
||||
cachedGameEntity: GameEntity? = null,
|
||||
withLog: Boolean = true) {
|
||||
Utils.log(TAG, "安装了: $packageName 包名的程序")
|
||||
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshotByPackageName(packageName)
|
||||
val gameId = if (downloadEntity != null && downloadEntity.gameId != null) downloadEntity.gameId else ""
|
||||
@ -128,7 +153,7 @@ object PackageChangeHelper : DefaultLifecycleObserver {
|
||||
val versionName = PackageUtils.getVersionNameByPackageName(packageName)
|
||||
val installEb = EBPackage(EBPackage.TYPE_INSTALLED, packageName, versionName)
|
||||
|
||||
PackageObserver.onPackageChanged(installEb)
|
||||
PackageObserver.onPackageChanged(installEb, cachedGameEntity)
|
||||
EventBus.getDefault().post(installEb)
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@ package com.gh.common.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.content.pm.PackageInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.pm.PermissionInfo
|
||||
@ -12,18 +11,19 @@ import androidx.fragment.app.FragmentActivity
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.prioritychain.GlobalPriorityChainHelper
|
||||
import com.gh.common.prioritychain.RequestInstalledListPermissionHandler
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.PermissionHelper
|
||||
import com.gh.gamecenter.common.utils.PermissionHelper.isGetInstalledListPermissionDisabled
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.gamecenter.common.utils.toJson
|
||||
import com.gh.gamecenter.common.utils.toObject
|
||||
import com.gh.gamecenter.core.GHThreadFactory
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.entity.WhitePackageListEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.SettingsEntity
|
||||
import com.gh.gamecenter.feature.utils.SentryHelper
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
@ -31,9 +31,8 @@ import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.coroutines.*
|
||||
import java.io.BufferedReader
|
||||
import java.io.IOException
|
||||
import java.io.InputStreamReader
|
||||
import java.util.HashMap
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.collections.HashSet
|
||||
|
||||
@ -41,7 +40,16 @@ object PackageHelper {
|
||||
|
||||
private const val TAG = "PackageHelper"
|
||||
|
||||
private const val SP_GET_INSTALLED_API_AGREED = "get_installed_api_agreed"
|
||||
private const val SP_GET_INSTALLED_PACKAGES_AGREED = "get_installed_packages_agreed" // 用户是否同意使用已安装应用列表 API
|
||||
|
||||
private const val SP_GET_INSTALLED_PACKAGES_BY_ALTERNATIVE_API =
|
||||
"get_installed_packages_by_alternative_api" // 是否使用另类方式获取已安装应用列表
|
||||
|
||||
private const val SP_USER_USED_GET_INSTALLED_API_SWITCH_PACKAGE =
|
||||
"user_used_get_installed_api_switch_package" // 用户是否使用过含有已安装应用列表获取开关的包
|
||||
|
||||
private const val SP_ADDITIONAL_WHITELIST_PACKAGE_NAME_LIST =
|
||||
"additional_whitelist_package_name_list" // 额外的白名单包名列表 (曾经更正为已安装的包名列表)
|
||||
|
||||
private const val UNKNOWN = -1
|
||||
private const val UNSUPPORTED = 0
|
||||
@ -50,13 +58,23 @@ object PackageHelper {
|
||||
private const val ENABLED = 2
|
||||
private const val DISABLED = 3
|
||||
|
||||
private var lastInstalledPackageListTime = 0L
|
||||
private var cachedInstalledPackagesList: List<PackageInfo> = arrayListOf()
|
||||
private var lastSuccessfullyGetInstalledPackagesTimeMills = 0L
|
||||
private var cachedInstalledPackageInfoList: List<PackageInfo> = arrayListOf() // 缓存的已安装应用列表
|
||||
private var cachedInstalledPackageNameList: List<String> = arrayListOf() // 缓存的已安装应用包名列表
|
||||
private var additionalWhiteListPackageNameSet: HashSet<String> = hashSetOf()
|
||||
|
||||
private var isGetInstalledPackagesApiAgreed = true // 用户是否已经同意使用已安装应用列表 API
|
||||
private var isGetInstalledPackagesApiAgreedRequired = DISABLED // 需要用户手动授权才获取已安装应用列表的功能的开关
|
||||
private var isGetInstalledPackagesAgreed = false // 用户是否已经同意使用已安装应用列表
|
||||
private var isGetInstalledPackagesAgreedRequired = UNKNOWN // 需要用户手动授权才获取已安装应用列表的功能的开关
|
||||
private var isGetInstalledPackagesPermissionSupported = UNKNOWN // 设备是否支持禁用获取已安装应用列表
|
||||
|
||||
private var useAlternativeWayToGetInstalledPackages = false
|
||||
|
||||
private var cachedPkgNameAndGameEntityMap = HashMap<String, GameEntity>() // 缓存的状态异常包名和游戏实体的映射 (用于免接口请求更新状态)
|
||||
|
||||
private val packageExecutor by lazy { Executors.newSingleThreadExecutor(GHThreadFactory("GH_PACKAGE_THREAD")) }
|
||||
|
||||
private var uploadUIDGapLog = true
|
||||
|
||||
// 评论黑名单包名列表,避免用户安装了 Xposed Installer 这样的工具,也能在包含该安装包的游戏详情页评论
|
||||
private var _commentPackageNameBlackList = arrayListOf<String>()
|
||||
val commentPackageNameBlackList: ArrayList<String> = _commentPackageNameBlackList
|
||||
@ -89,16 +107,57 @@ object PackageHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已安装的白名单列表(为了在没有已安装应用列表获取能力的时候也能正常判断更新、插件化)
|
||||
* 检查是否需要忽略接口控制的已安装应用列表获取开关
|
||||
* 用于覆盖安装首次启动时的检查 https://jira.shanqu.cc/browse/GHZSCY-5694
|
||||
*/
|
||||
fun checkIfGetInstalledApiSwitchShouldBeIgnored(context: Context) {
|
||||
val userHasUsedGetInstalledApiSwitchPackage =
|
||||
SPUtils.getBoolean(SP_USER_USED_GET_INSTALLED_API_SWITCH_PACKAGE, false)
|
||||
if (!userHasUsedGetInstalledApiSwitchPackage) {
|
||||
val isSupportGetInstalledAppsPermission = isSupportGetInstalledAppsPermission(context)
|
||||
|
||||
if (!isSupportGetInstalledAppsPermission) {
|
||||
// 设备不支持动态管理获取已安装应用列表,忽略接口控制,使用另类方式获取已安装应用列表
|
||||
updateUseAlternativeWayToGetInstalledPackages()
|
||||
onGetInstalledPackagesAgreed()
|
||||
} else if (!PermissionHelper.isGetInstalledListPermissionDisabled(context)) {
|
||||
// 设备支持动态管理获取已安装应用列表但已经授权,忽略接口控制,使用另类方式获取已安装应用列表
|
||||
updateUseAlternativeWayToGetInstalledPackages()
|
||||
onGetInstalledPackagesAgreed()
|
||||
}
|
||||
|
||||
SPUtils.getBoolean(SP_USER_USED_GET_INSTALLED_API_SWITCH_PACKAGE, true)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取包名白名单列表(为了在没有已安装应用列表获取能力的时候也能正常判断更新、插件化)
|
||||
* @param additionalWhiteList 额外的已安装白名单
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
fun getInstalledWhiteList() {
|
||||
fun getPackagesWhiteList(additionalWhiteList: HashSet<String>) {
|
||||
RetrofitManager.getInstance().newApi.installWhitelist
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<WhitePackageListEntity>() {
|
||||
override fun onSuccess(data: WhitePackageListEntity) {
|
||||
val installedWhiteList = hashSetOf<String>()
|
||||
|
||||
if (additionalWhiteList.isNotEmpty()) {
|
||||
installedWhiteList.addAll(additionalWhiteList)
|
||||
}
|
||||
|
||||
data.data?.let {
|
||||
addInstalledButMissingPackages(it)
|
||||
installedWhiteList.addAll(it)
|
||||
}
|
||||
|
||||
addInstalledButMissingPackages(installedWhiteList)
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
|
||||
if (additionalWhiteList.isNotEmpty()) {
|
||||
addInstalledButMissingPackages(additionalWhiteList)
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -111,7 +170,7 @@ object PackageHelper {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun refreshList() {
|
||||
fun refreshPackageNameList() {
|
||||
Config.getSettings()?.gameCommentBlackList?.let { _commentPackageNameBlackList = ArrayList(it) }
|
||||
Config.getSettings()?.gameDownloadBlackList?.let { _downloadPackageNameBlackList = ArrayList(it) }
|
||||
Config.getSettings()?.gamePackageMatch?.let { _relatedPackageList = ArrayList(it) }
|
||||
@ -130,12 +189,10 @@ object PackageHelper {
|
||||
private fun getAllPackageName(context: Context): HashSet<String> {
|
||||
val set = HashSet<String>()
|
||||
return try {
|
||||
val packageInfos = getInstalledPackages(context, 0)
|
||||
for (packageInfo in packageInfos) {
|
||||
if (packageInfo.applicationInfo.flags and ApplicationInfo.FLAG_SYSTEM == 0) {
|
||||
if (context.packageName != packageInfo.packageName) {
|
||||
set.add(packageInfo.packageName)
|
||||
}
|
||||
val packageNameList = getInstalledPackageNameList(context, 0)
|
||||
for (packageName in packageNameList) {
|
||||
if (context.packageName != packageName) {
|
||||
set.add(packageName)
|
||||
}
|
||||
}
|
||||
set
|
||||
@ -149,17 +206,17 @@ object PackageHelper {
|
||||
* 弃用已安装列表缓存
|
||||
*/
|
||||
fun dumpInstalledListCache() {
|
||||
lastInstalledPackageListTime = 0
|
||||
lastSuccessfullyGetInstalledPackagesTimeMills = 0
|
||||
}
|
||||
|
||||
/**
|
||||
* 在超时后,若后台没有开启获取已安装应用列表的功能,默认以接口不控制的方式获取已安装应用列表
|
||||
* 在超时后,若后台没有开启获取已安装应用列表的功能,回落到以接口不控制的方式获取已安装应用列表
|
||||
*/
|
||||
fun fallbackInstalledPackageApiSwitchAfterTimeout(timeout: Long) {
|
||||
fun ignoreInstalledPackageApiSwitchAfterTimeout(timeout: Long) {
|
||||
CoroutineScope(SupervisorJob()).launch {
|
||||
delay(timeout)
|
||||
if (isGetInstalledPackagesApiAgreedRequired == UNKNOWN) {
|
||||
Utils.log(TAG, "后台没有开启获取已安装应用列表的功能,超时后默认以接口不控制的方式获取已安装应用列表")
|
||||
if (isGetInstalledPackagesAgreedRequired == UNKNOWN && !isGetInstalledPackagesAgreed()) {
|
||||
Utils.log(TAG, "后台没有开启获取已安装应用列表的功能,超时后回落到以接口不控制的方式获取已安装应用列表")
|
||||
updateIsGetInstalledPackagesApiAgreedRequired(false)
|
||||
}
|
||||
}
|
||||
@ -169,24 +226,42 @@ object PackageHelper {
|
||||
* 更新已安装应用列表获取开关状态
|
||||
*/
|
||||
fun updateIsGetInstalledPackagesApiAgreedRequired(isEnabled: Boolean) {
|
||||
// 若状态不为 unknown 或者用户已经同意使用了,无需再更新
|
||||
if (isGetInstalledPackagesApiAgreedRequired != UNKNOWN || isGetInstalledPackagesApiAgreed()) {
|
||||
Utils.log(TAG, "installedPackageApiSwitchStatus 不为 UNKNOWN,无需再更新")
|
||||
Utils.log(TAG, "updateIsGetInstalledPackagesApiAgreedRequired 入参为 $isEnabled")
|
||||
|
||||
// 状态不变,无需更新
|
||||
if ((isEnabled == true && isGetInstalledPackagesAgreedRequired == ENABLED)
|
||||
|| (isEnabled == false && isGetInstalledPackagesAgreedRequired == DISABLED)
|
||||
) {
|
||||
Utils.log(TAG, "isGetInstalledPackagesApiAgreedRequired 状态不变,无需更新")
|
||||
return
|
||||
}
|
||||
|
||||
// 若用户已经同意使用了,无需更新
|
||||
if (isGetInstalledPackagesAgreed()) {
|
||||
Utils.log(TAG, "用户已经同意使用了,无需再更新已安装应用列表获取开关状态")
|
||||
return
|
||||
}
|
||||
|
||||
if (isEnabled) {
|
||||
getInstalledWhiteList()
|
||||
_installedPackageApiSwitchStatusLiveData.postValue(true)
|
||||
isGetInstalledPackagesApiAgreedRequired = ENABLED
|
||||
} else {
|
||||
isGetInstalledPackagesApiAgreedRequired = DISABLED
|
||||
Utils.log(TAG, "开启获取已安装应用列表限制")
|
||||
|
||||
if (isSupportGetInstalledAppsPermission(HaloApp.getInstance())) {
|
||||
GlobalPriorityChainHelper.queueNewHandler(RequestInstalledListPermissionHandler())
|
||||
} else {
|
||||
agreeOnGetInstalledPackagesApi()
|
||||
}
|
||||
additionalWhiteListPackageNameSet =
|
||||
SPUtils.getString(SP_ADDITIONAL_WHITELIST_PACKAGE_NAME_LIST).toObject() ?: hashSetOf()
|
||||
|
||||
Utils.log(TAG, "额外的白名单为 $additionalWhiteListPackageNameSet")
|
||||
|
||||
getPackagesWhiteList(additionalWhiteListPackageNameSet)
|
||||
_installedPackageApiSwitchStatusLiveData.postValue(true)
|
||||
isGetInstalledPackagesAgreedRequired = ENABLED
|
||||
} else {
|
||||
Utils.log(TAG, "不开启获取已安装应用列表限制")
|
||||
|
||||
isGetInstalledPackagesAgreedRequired = DISABLED
|
||||
|
||||
// 启用另类获取已安装应用列表的 API
|
||||
updateUseAlternativeWayToGetInstalledPackages()
|
||||
|
||||
onGetInstalledPackagesAgreed()
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,66 +269,96 @@ object PackageHelper {
|
||||
* 用户是否已经允许了调用获取已安装应用列表接口
|
||||
* 优先用内存的值,没有再从 SP 中获取并更新
|
||||
*/
|
||||
fun isGetInstalledPackagesApiAgreed(): Boolean {
|
||||
return isGetInstalledPackagesApiAgreed
|
||||
|| (SPUtils.getBoolean(SP_GET_INSTALLED_API_AGREED).also { isGetInstalledPackagesApiAgreed = it })
|
||||
}
|
||||
|
||||
fun isGetInstalledPackagesApiAgreedRequired(): Boolean {
|
||||
return isGetInstalledPackagesApiAgreedRequired == ENABLED
|
||||
fun isGetInstalledPackagesAgreed(): Boolean {
|
||||
return isGetInstalledPackagesAgreed
|
||||
|| (SPUtils.getBoolean(SP_GET_INSTALLED_PACKAGES_AGREED).also { isGetInstalledPackagesAgreed = it })
|
||||
}
|
||||
|
||||
/**
|
||||
* 同意使用已安装应用列表 API
|
||||
* 用户是否已经使用另类方式获取已安装应用列表
|
||||
*/
|
||||
private fun agreeOnGetInstalledPackagesApi() {
|
||||
isGetInstalledPackagesApiAgreed = true
|
||||
SPUtils.setBoolean(SP_GET_INSTALLED_API_AGREED, true)
|
||||
private fun isUseAlternativeWayToGetInstalledPackages(): Boolean {
|
||||
return useAlternativeWayToGetInstalledPackages
|
||||
|| (SPUtils.getBoolean(SP_GET_INSTALLED_PACKAGES_BY_ALTERNATIVE_API)
|
||||
.also { useAlternativeWayToGetInstalledPackages = it })
|
||||
}
|
||||
|
||||
_installedPackageApiSwitchStatusLiveData.postValue(false)
|
||||
private fun updateUseAlternativeWayToGetInstalledPackages() {
|
||||
// 启用另类获取已安装应用列表的 API
|
||||
useAlternativeWayToGetInstalledPackages = true
|
||||
SPUtils.setBoolean(SP_GET_INSTALLED_PACKAGES_BY_ALTERNATIVE_API, true)
|
||||
}
|
||||
|
||||
fun isGetInstalledPackagesAgreedRequired(): Boolean {
|
||||
return isGetInstalledPackagesAgreedRequired == ENABLED
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已安装应用列表
|
||||
*/
|
||||
fun getInstalledPackages(context: Context?, flags: Int): List<PackageInfo> {
|
||||
Utils.log(TAG, "即将获取已安装应用列表")
|
||||
fun getInstalledPackageInfoList(context: Context?, flags: Int): List<PackageInfo> {
|
||||
return getInstalledListInternal(context, flags, false).first
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已安装应用包名列表
|
||||
*/
|
||||
fun getInstalledPackageNameList(context: Context?, flags: Int): List<String> {
|
||||
return getInstalledListInternal(context, flags, true).second
|
||||
}
|
||||
|
||||
private fun getInstalledListInternal(context: Context?,
|
||||
flags: Int,
|
||||
packageNameOnly: Boolean): Pair<List<PackageInfo>, List<String>> {
|
||||
Utils.log(TAG, "即将获取已安装应用列表,仅获取包名 $packageNameOnly")
|
||||
|
||||
// 用户未同意使用已安装应用列表 API,返回空列表
|
||||
if (!isGetInstalledPackagesApiAgreed()) {
|
||||
if (!isGetInstalledPackagesAgreed()) {
|
||||
Utils.log(TAG, "用户未同意使用已安装应用列表 API,返回空列表")
|
||||
return cachedInstalledPackagesList
|
||||
return Pair(cachedInstalledPackageInfoList, cachedInstalledPackageNameList)
|
||||
}
|
||||
|
||||
// 简单 debounce 过于频繁的获取已安装应用列表调用
|
||||
if (System.currentTimeMillis() - lastInstalledPackageListTime < 3000 && cachedInstalledPackagesList.isNotEmpty()) {
|
||||
Utils.log(TAG, "使用了缓存的已安装应用列表")
|
||||
return cachedInstalledPackagesList
|
||||
if (System.currentTimeMillis() - lastSuccessfullyGetInstalledPackagesTimeMills < 20 * 1000) {
|
||||
// 时间间隔合适且对应的列表不为空,直接返回对应的缓存列表数据
|
||||
if ((packageNameOnly && cachedInstalledPackageNameList.isNotEmpty())
|
||||
|| (!packageNameOnly && cachedInstalledPackageInfoList.isNotEmpty())
|
||||
) {
|
||||
Utils.log(TAG, "使用了缓存的已安装应用列表")
|
||||
return Pair(cachedInstalledPackageInfoList, cachedInstalledPackageNameList)
|
||||
}
|
||||
}
|
||||
|
||||
var shouldGetNewInstalledPackagedList = false
|
||||
|
||||
// 当前设备是否支持限制获取已安装应用列表的功能
|
||||
if (isSupportGetInstalledAppsPermission(context!!)) {
|
||||
Utils.log(TAG, "当前设备支持限制获取已安装应用列表的功能")
|
||||
Utils.log(TAG, "当前设备支持动态管理获取已安装应用列表的功能")
|
||||
// 当前设备是否支持禁用了获取已安装应用列表
|
||||
if (!isGetInstalledListPermissionDisabled(context)) {
|
||||
Utils.log(TAG, "当前设备没有限制获取已安装应用列表的功能")
|
||||
if (!PermissionHelper.isGetInstalledListPermissionDisabled(context)) {
|
||||
Utils.log(TAG, "当前设备支持动态管理但没有限制获取已安装应用列表的功能")
|
||||
shouldGetNewInstalledPackagedList = true
|
||||
} else {
|
||||
Utils.log(TAG, "当前设备已限制获取已安装应用列表的功能")
|
||||
Utils.log(TAG, "当前设备支持动态管理且已限制获取已安装应用列表的功能")
|
||||
}
|
||||
} else {
|
||||
Utils.log(TAG, "当前设备不支持限制获取已安装应用列表的功能")
|
||||
Utils.log(TAG, "当前设备不支持动态管理获取已安装应用列表的功能")
|
||||
shouldGetNewInstalledPackagedList = true
|
||||
}
|
||||
|
||||
if (shouldGetNewInstalledPackagedList) {
|
||||
lastInstalledPackageListTime = System.currentTimeMillis()
|
||||
cachedInstalledPackagesList = getInstalledPackagesInternal(context, flags)
|
||||
lastSuccessfullyGetInstalledPackagesTimeMills = System.currentTimeMillis()
|
||||
|
||||
if (packageNameOnly) {
|
||||
cachedInstalledPackageNameList = getInstalledPackageNameListInternal(context, flags)
|
||||
Utils.log(TAG, "获取已安装应用列表成功,数量为 ${cachedInstalledPackageNameList.size}")
|
||||
} else {
|
||||
cachedInstalledPackageInfoList = getInstalledPackageInfoListInternal(context, flags)
|
||||
Utils.log(TAG, "获取已安装应用列表成功,数量为 ${cachedInstalledPackageInfoList.size}")
|
||||
}
|
||||
}
|
||||
|
||||
return cachedInstalledPackagesList
|
||||
return Pair(cachedInstalledPackageInfoList, cachedInstalledPackageNameList)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -265,18 +370,10 @@ object PackageHelper {
|
||||
resultClosure: (Boolean) -> Unit
|
||||
) {
|
||||
|
||||
val globalOnPermissionGrantedClosure = {
|
||||
agreeOnGetInstalledPackagesApi()
|
||||
// 进行包名初始化相关的操作
|
||||
PackageRepository.initData()
|
||||
refreshLocalPackageList()
|
||||
refreshList()
|
||||
}
|
||||
|
||||
if (isSupportGetInstalledAppsPermission(activity)) {
|
||||
// 若系统已经授予了获取应用列表的权限,直接进行授权成功回调
|
||||
if (!isGetInstalledListPermissionDisabled(activity)) {
|
||||
globalOnPermissionGrantedClosure.invoke()
|
||||
// 若系统已经授予了获取应用列表的权限,直接执行授权成功回调
|
||||
if (!PermissionHelper.isGetInstalledListPermissionDisabled(activity)) {
|
||||
onGetInstalledPackagesAgreed()
|
||||
resultClosure.invoke(true)
|
||||
return
|
||||
}
|
||||
@ -288,7 +385,7 @@ object PackageHelper {
|
||||
) { isGranted ->
|
||||
if (isGranted) {
|
||||
SensorsBridge.trackInstalledListPermissionsResult("成功")
|
||||
globalOnPermissionGrantedClosure.invoke()
|
||||
onGetInstalledPackagesAgreed()
|
||||
resultClosure.invoke(true)
|
||||
|
||||
trackInstalledListAfterDelay()
|
||||
@ -315,7 +412,7 @@ object PackageHelper {
|
||||
cancelText = "拒绝",
|
||||
confirmClickCallback = {
|
||||
SensorsBridge.trackInstalledListPermissionsCustomClick("开启")
|
||||
globalOnPermissionGrantedClosure.invoke()
|
||||
onGetInstalledPackagesAgreed()
|
||||
resultClosure.invoke(true)
|
||||
|
||||
trackInstalledListAfterDelay()
|
||||
@ -332,6 +429,28 @@ object PackageHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行用户授权获取已安装应用列表的操作
|
||||
*/
|
||||
private fun onGetInstalledPackagesAgreed() {
|
||||
isGetInstalledPackagesAgreed = true
|
||||
SPUtils.setBoolean(SP_GET_INSTALLED_PACKAGES_AGREED, true)
|
||||
|
||||
_installedPackageApiSwitchStatusLiveData.postValue(false)
|
||||
|
||||
// 进行包名初始化相关的操作
|
||||
initPackageRelatedData()
|
||||
}
|
||||
|
||||
/**
|
||||
* 进行包名初始化相关的操作
|
||||
*/
|
||||
fun initPackageRelatedData() {
|
||||
PackageRepository.initData()
|
||||
refreshLocalPackageList()
|
||||
refreshPackageNameList()
|
||||
}
|
||||
|
||||
/**
|
||||
* 延迟5秒后上报已安装应用列表
|
||||
*/
|
||||
@ -346,6 +465,11 @@ object PackageHelper {
|
||||
* 是否支持动态获取已安装应用列表权限
|
||||
*/
|
||||
fun isSupportGetInstalledAppsPermission(context: Context): Boolean {
|
||||
if (isUseAlternativeWayToGetInstalledPackages()) {
|
||||
// 已经使用另类获取已安装应用列表形式,强制判定为不支持动态获取已安装应用列表权限
|
||||
return false
|
||||
}
|
||||
|
||||
// 若存在缓存,直接返回缓存结果。
|
||||
if (isGetInstalledPackagesPermissionSupported != UNKNOWN) {
|
||||
return isGetInstalledPackagesPermissionSupported != UNSUPPORTED
|
||||
@ -390,13 +514,20 @@ object PackageHelper {
|
||||
val installedPackageNameSet: HashSet<String> = hashSetOf()
|
||||
|
||||
for (packageName in packageNameSet) {
|
||||
if (!PackagesManager.isInstalled(packageName)
|
||||
&& PackageUtils.getVersionNameByPackageName(packageName) != null
|
||||
) {
|
||||
val installedPkgNameExistInMemory = PackagesManager.isInstalled(packageName)
|
||||
val packageNameInstalledOnDevice = PackageUtils.getVersionNameByPackageName(packageName) != null
|
||||
|
||||
if (!installedPkgNameExistInMemory && packageNameInstalledOnDevice) {
|
||||
installedPackageNameSet.add(packageName)
|
||||
}
|
||||
|
||||
if (!packageNameInstalledOnDevice) {
|
||||
additionalWhiteListPackageNameSet.remove(packageName)
|
||||
}
|
||||
}
|
||||
|
||||
SPUtils.setString(SP_ADDITIONAL_WHITELIST_PACKAGE_NAME_LIST, additionalWhiteListPackageNameSet.toJson())
|
||||
|
||||
Utils.log(TAG, "addInstalledButMissingPackages 需要请求接口获取的包数量为 ${installedPackageNameSet.size}")
|
||||
|
||||
PackageRepository.addInstalledGames(
|
||||
@ -405,46 +536,73 @@ object PackageHelper {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新额外的白名单包名列表
|
||||
* @param packageName 包名
|
||||
* @param isAdd 是否添加
|
||||
*/
|
||||
fun updateAdditionalWhiteListPackageName(packageName: String, isAdd: Boolean) {
|
||||
val isUpdated = if (isAdd) {
|
||||
additionalWhiteListPackageNameSet.add(packageName)
|
||||
} else {
|
||||
additionalWhiteListPackageNameSet.remove(packageName)
|
||||
}
|
||||
|
||||
Utils.log(
|
||||
TAG,
|
||||
"updateAdditionalWhiteListPackageName 更新额外的白名单包名列表 $isAdd $packageName ,结果是 $isUpdated"
|
||||
)
|
||||
|
||||
if (isUpdated) {
|
||||
SPUtils.setString(SP_ADDITIONAL_WHITELIST_PACKAGE_NAME_LIST, additionalWhiteListPackageNameSet.toJson())
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新安装状态异常 (适用于仅存在包名信息的列表)
|
||||
*/
|
||||
fun refreshWrongInstallStatus(packageNameSet: MutableSet<String>) {
|
||||
runOnIoThread {
|
||||
packageExecutor.execute {
|
||||
Utils.log(TAG, "refreshWrongInstallStatus 检查安装状态异常的应用")
|
||||
|
||||
val installedButKeepingWrongStatusPackageNameSet: HashSet<String> = hashSetOf()
|
||||
val uninstalledButKeepingWrongStatusPackageNameSet: HashSet<String> = hashSetOf()
|
||||
val updatedButKeepingWrongStatusPackageNameSet: HashSet<String> = hashSetOf()
|
||||
|
||||
for (packageName in packageNameSet) {
|
||||
val installedVersionName = PackageUtils.getVersionNameByPackageName(packageName)
|
||||
|
||||
if (!PackagesManager.isInstalled(packageName)
|
||||
&& installedVersionName != null
|
||||
if (PackagesManager.isInstalled(packageName)
|
||||
&& installedVersionName == null
|
||||
) {
|
||||
installedButKeepingWrongStatusPackageNameSet.add(packageName)
|
||||
} else if (PackagesManager.isInstalled(packageName)
|
||||
&& installedVersionName == null) {
|
||||
uninstalledButKeepingWrongStatusPackageNameSet.add(packageName)
|
||||
} else if (PackagesManager.isInstalled(packageName)
|
||||
&& installedVersionName != null
|
||||
&& !PackagesManager.isInstalledWithSpecificVersion(packageName, installedVersionName)) {
|
||||
&& !PackagesManager.isInstalledWithSpecificVersion(packageName, installedVersionName)
|
||||
) {
|
||||
updatedButKeepingWrongStatusPackageNameSet.add(packageName)
|
||||
}
|
||||
}
|
||||
|
||||
Utils.log(TAG, "refreshWrongInstallStatus 需要更新已安装状态的包数量为 ${installedButKeepingWrongStatusPackageNameSet.size}")
|
||||
Utils.log(TAG, "refreshWrongInstallStatus 需要更新已更新状态的包数量为 ${updatedButKeepingWrongStatusPackageNameSet.size}")
|
||||
Utils.log(TAG, "refreshWrongInstallStatus 需要移除已安装的包数量为 ${uninstalledButKeepingWrongStatusPackageNameSet.size}")
|
||||
Utils.log(
|
||||
TAG,
|
||||
"refreshWrongInstallStatus 需要更新已更新状态的包数量为 ${updatedButKeepingWrongStatusPackageNameSet.size}"
|
||||
)
|
||||
Utils.log(
|
||||
TAG,
|
||||
"refreshWrongInstallStatus 需要移除已安装的包数量为 ${uninstalledButKeepingWrongStatusPackageNameSet.size}"
|
||||
)
|
||||
|
||||
runOnUiThread {
|
||||
if (installedButKeepingWrongStatusPackageNameSet.isNotEmpty()) {
|
||||
for (packageName in installedButKeepingWrongStatusPackageNameSet) {
|
||||
PackageChangeHelper.addInstall(packageName)
|
||||
}
|
||||
}
|
||||
|
||||
if (uninstalledButKeepingWrongStatusPackageNameSet.isNotEmpty()) {
|
||||
for (packageName in uninstalledButKeepingWrongStatusPackageNameSet) {
|
||||
PackageChangeHelper.addUninstall(packageName)
|
||||
additionalWhiteListPackageNameSet.remove(packageName)
|
||||
}
|
||||
|
||||
SPUtils.setString(
|
||||
SP_ADDITIONAL_WHITELIST_PACKAGE_NAME_LIST,
|
||||
additionalWhiteListPackageNameSet.toString()
|
||||
)
|
||||
}
|
||||
|
||||
if (updatedButKeepingWrongStatusPackageNameSet.isNotEmpty()) {
|
||||
@ -457,45 +615,197 @@ object PackageHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* 在5.1系统手机使用PackageManager获取已安装应用容易发生Package manager has died异常
|
||||
* https://stackoverflow.com/questions/13235793/transactiontoolargeeception-when-trying-tÏo-get-a-list-of-applications-installed/30062632#30062632
|
||||
* 刷新安装状态异常 (适用于存在游戏信息的列表)
|
||||
*/
|
||||
private fun getInstalledPackagesInternal(context: Context, flags: Int): List<PackageInfo> {
|
||||
Utils.log(TAG, "调用系统 API 获取已安装应用列表")
|
||||
fun refreshWrongInstallStatus(gameEntityList: ArrayList<GameEntity>) {
|
||||
packageExecutor.execute {
|
||||
Utils.log(TAG, "refreshWrongInstallStatus 检查安装状态异常的应用")
|
||||
|
||||
val installedButKeepingWrongStatusPackageNameSet: HashSet<String> = hashSetOf()
|
||||
val uninstalledButKeepingWrongStatusPackageNameSet: HashSet<String> = hashSetOf()
|
||||
val updatedButKeepingWrongStatusPackageNameSet: HashSet<String> = hashSetOf()
|
||||
|
||||
for (game in gameEntityList) {
|
||||
for (apk in game.getApk()) {
|
||||
val packageName = apk.packageName
|
||||
val installedVersionName = PackageUtils.getVersionNameByPackageName(packageName)
|
||||
|
||||
if (!PackagesManager.isInstalled(packageName)
|
||||
&& installedVersionName != null
|
||||
) {
|
||||
cachedPkgNameAndGameEntityMap.put(packageName, game)
|
||||
installedButKeepingWrongStatusPackageNameSet.add(packageName)
|
||||
} else if (PackagesManager.isInstalled(packageName)
|
||||
&& installedVersionName == null
|
||||
) {
|
||||
uninstalledButKeepingWrongStatusPackageNameSet.add(packageName)
|
||||
} else if (PackagesManager.isInstalled(packageName)
|
||||
&& installedVersionName != null
|
||||
&& !PackagesManager.isInstalledWithSpecificVersion(packageName, installedVersionName)
|
||||
&& !PackagesManager.isCanUpdate(game.id, packageName, false)
|
||||
) {
|
||||
cachedPkgNameAndGameEntityMap.put(packageName, game)
|
||||
updatedButKeepingWrongStatusPackageNameSet.add(packageName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Utils.log(
|
||||
TAG,
|
||||
"refreshWrongInstallStatus 需要更新已安装状态的包数量为 ${installedButKeepingWrongStatusPackageNameSet.size}"
|
||||
)
|
||||
Utils.log(
|
||||
TAG,
|
||||
"refreshWrongInstallStatus 需要更新已更新状态的包数量为 ${updatedButKeepingWrongStatusPackageNameSet.size}"
|
||||
)
|
||||
Utils.log(
|
||||
TAG,
|
||||
"refreshWrongInstallStatus 需要移除已安装的包数量为 ${uninstalledButKeepingWrongStatusPackageNameSet.size}"
|
||||
)
|
||||
|
||||
runOnUiThread {
|
||||
if (installedButKeepingWrongStatusPackageNameSet.isNotEmpty()) {
|
||||
for (packageName in installedButKeepingWrongStatusPackageNameSet) {
|
||||
PackageChangeHelper.addInstall(packageName, cachedPkgNameAndGameEntityMap.remove(packageName))
|
||||
additionalWhiteListPackageNameSet.add(packageName)
|
||||
}
|
||||
|
||||
SPUtils.setString(
|
||||
SP_ADDITIONAL_WHITELIST_PACKAGE_NAME_LIST,
|
||||
additionalWhiteListPackageNameSet.toString()
|
||||
)
|
||||
}
|
||||
|
||||
if (uninstalledButKeepingWrongStatusPackageNameSet.isNotEmpty()) {
|
||||
for (packageName in uninstalledButKeepingWrongStatusPackageNameSet) {
|
||||
PackageChangeHelper.addUninstall(packageName)
|
||||
additionalWhiteListPackageNameSet.remove(packageName)
|
||||
}
|
||||
|
||||
SPUtils.setString(
|
||||
SP_ADDITIONAL_WHITELIST_PACKAGE_NAME_LIST,
|
||||
additionalWhiteListPackageNameSet.toString()
|
||||
)
|
||||
}
|
||||
|
||||
if (updatedButKeepingWrongStatusPackageNameSet.isNotEmpty()) {
|
||||
for (packageName in updatedButKeepingWrongStatusPackageNameSet) {
|
||||
PackageChangeHelper.addUpdate(packageName, cachedPkgNameAndGameEntityMap.remove(packageName))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getInstalledPackageInfoListInternal(
|
||||
context: Context,
|
||||
flags: Int
|
||||
): List<PackageInfo> {
|
||||
return if (isUseAlternativeWayToGetInstalledPackages()) {
|
||||
Utils.log(TAG, "调用另类系统 API 获取已安装应用列表")
|
||||
getInstalledPackageByAlternative(context)
|
||||
} else {
|
||||
Utils.log(TAG, "调用默认系统 API 获取已安装应用列表")
|
||||
getInstalledPackageByDefault(context, flags)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getInstalledPackageNameListInternal(
|
||||
context: Context,
|
||||
flags: Int
|
||||
): List<String> {
|
||||
if (isUseAlternativeWayToGetInstalledPackages()) {
|
||||
Utils.log(TAG, "调用另类系统 API 获取已安装应用包名列表")
|
||||
return getInstalledPackageNameByAlternative(context)
|
||||
} else {
|
||||
Utils.log(TAG, "调用默认系统 API 获取已安装应用包名列表")
|
||||
val packageInfoList = getInstalledPackageByDefault(context, flags)
|
||||
val packageList = arrayListOf<String>()
|
||||
for (packageInfo in packageInfoList) {
|
||||
if (context.packageName != packageInfo.packageName) {
|
||||
packageList.add(packageInfo.packageName)
|
||||
}
|
||||
}
|
||||
return packageList
|
||||
}
|
||||
}
|
||||
|
||||
private fun getInstalledPackageByDefault(context: Context, flags: Int): List<PackageInfo> {
|
||||
val pm = context.packageManager
|
||||
try {
|
||||
return pm.getInstalledPackages(flags)
|
||||
} catch (ignored: java.lang.Exception) {
|
||||
//we don't care why it didn't succeed. We'll do it using an alternative way instead
|
||||
}
|
||||
// use fallback:
|
||||
val process: Process
|
||||
val result: MutableList<PackageInfo> = java.util.ArrayList()
|
||||
var bufferedReader: BufferedReader? = null
|
||||
try {
|
||||
process = Runtime.getRuntime().exec("pm list packages")
|
||||
bufferedReader = BufferedReader(InputStreamReader(process.inputStream))
|
||||
var line: String
|
||||
while ((bufferedReader.readLine().also { line = it }) != null) {
|
||||
val packageName = line.substring(line.indexOf(':') + 1)
|
||||
val packageInfo = pm.getPackageInfo(packageName, flags)
|
||||
result.add(packageInfo)
|
||||
}
|
||||
process.waitFor()
|
||||
} catch (e: java.lang.Exception) {
|
||||
e.printStackTrace()
|
||||
if (e is InterruptedException) {
|
||||
Thread.currentThread().interrupt()
|
||||
}
|
||||
} finally {
|
||||
if (bufferedReader != null) try {
|
||||
bufferedReader.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
return result
|
||||
|
||||
return arrayListOf()
|
||||
}
|
||||
|
||||
private fun getInstalledPackageByAlternative(context: Context): ArrayList<PackageInfo> {
|
||||
val packageManager = context.getPackageManager()
|
||||
val packageList = arrayListOf<PackageInfo>()
|
||||
var packagesArray: Array<String>? = null
|
||||
var uid = android.os.Process.FIRST_APPLICATION_UID
|
||||
|
||||
while (uid <= android.os.Process.LAST_APPLICATION_UID) {
|
||||
try {
|
||||
packagesArray = packageManager.getPackagesForUid(uid)
|
||||
if (packagesArray != null && packagesArray.isNotEmpty()) {
|
||||
for (packageName in packagesArray) {
|
||||
try {
|
||||
val packageInfo = packageManager.getPackageInfo(packageName, 0)
|
||||
if (packageInfo == null) {
|
||||
break
|
||||
}
|
||||
|
||||
packageList.add(packageInfo)
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (securityException: SecurityException) {
|
||||
securityException.printStackTrace()
|
||||
}
|
||||
uid++
|
||||
}
|
||||
|
||||
return packageList
|
||||
}
|
||||
|
||||
private fun getInstalledPackageNameByAlternative(context: Context): ArrayList<String> {
|
||||
val packageManager = context.getPackageManager()
|
||||
val packageList = arrayListOf<String>()
|
||||
var packagesArray: Array<String>? = null
|
||||
var uid = android.os.Process.FIRST_APPLICATION_UID
|
||||
|
||||
var lastValidUid = 0
|
||||
|
||||
while (uid <= android.os.Process.LAST_APPLICATION_UID) {
|
||||
try {
|
||||
packagesArray = packageManager.getPackagesForUid(uid)
|
||||
if (packagesArray != null && packagesArray.isNotEmpty()) {
|
||||
lastValidUid = uid
|
||||
|
||||
for (packageName in packagesArray) {
|
||||
packageList.add(packageName)
|
||||
}
|
||||
}
|
||||
} catch (securityException: SecurityException) {
|
||||
securityException.printStackTrace()
|
||||
}
|
||||
uid++
|
||||
}
|
||||
|
||||
if (HaloApp.getInstance().isNewForThisVersion && uploadUIDGapLog) {
|
||||
// 仅应用该版本第一次启动的第一次方法调用上报日志
|
||||
uploadUIDGapLog = false
|
||||
|
||||
val uidGap = (android.os.Process.LAST_APPLICATION_UID - lastValidUid) / 100 * 100
|
||||
SentryHelper.onEvent("UID_GAP", "gap", uidGap.toString())
|
||||
}
|
||||
|
||||
return packageList
|
||||
}
|
||||
|
||||
}
|
||||
@ -6,7 +6,6 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.FileProvider
|
||||
import com.gh.common.dialog.InstallPermissionDialogFragment
|
||||
@ -20,13 +19,13 @@ import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.core.utils.MD5Utils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.install.InstallService
|
||||
import com.gh.gamecenter.vpn.VpnHelper
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.utils.Utils
|
||||
import java.io.File
|
||||
|
||||
// TODO 将弹窗改成以责任链模式来处理
|
||||
object PackageInstaller {
|
||||
|
||||
/**
|
||||
@ -124,13 +123,13 @@ object PackageInstaller {
|
||||
}
|
||||
|
||||
if (PackageUtils.isCanLaunchSetup(context, pkgPath)) {
|
||||
val currentActivity = CurrentActivityHolder.getCurrentActivity()
|
||||
|
||||
if (VpnHelper.shouldUseVpn() && currentActivity is AppCompatActivity) {
|
||||
turnOnVpnThenInstall(currentActivity, pkgPath, downloadEntity)
|
||||
} else {
|
||||
install(context, pkgPath)
|
||||
}
|
||||
installWithPureModeHandled(
|
||||
context,
|
||||
pkgPath,
|
||||
downloadEntity?.gameId ?: "unknown",
|
||||
downloadEntity?.name ?: "unknown",
|
||||
downloadEntity?.categoryChinese ?: "unknown"
|
||||
)
|
||||
} else {
|
||||
if (isPluggin) {
|
||||
DialogHelper.showPluginDialog(
|
||||
@ -160,6 +159,21 @@ object PackageInstaller {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理纯净模式后的安装
|
||||
*/
|
||||
private fun installWithPureModeHandled(
|
||||
context: Context,
|
||||
pkgPath: String,
|
||||
gameId: String,
|
||||
gameName: String,
|
||||
gameType: String,
|
||||
) {
|
||||
PureModeHelper.handlePureModeIfNeeded(context, gameId, gameName, gameType) {
|
||||
install(context, pkgPath)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 最终执行安装的方法
|
||||
*/
|
||||
@ -291,82 +305,4 @@ object PackageInstaller {
|
||||
return MD5Utils.getContentMD5(gameName + "_" + System.currentTimeMillis())
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动 VPN 然后安装应用 (若没有授权会先提醒授权 VPN ,若拒绝授权会回落到直接执行安装)
|
||||
*/
|
||||
private fun turnOnVpnThenInstall(currentActivity: AppCompatActivity,
|
||||
pkgPath: String,
|
||||
downloadEntity: DownloadEntity?) {
|
||||
if (VpnHelper.isVpnPermissionGranted(currentActivity) == true) {
|
||||
VpnHelper.startVpn(currentActivity) { shouldShowVpnError ->
|
||||
if (shouldShowVpnError) {
|
||||
ToastUtils.toast("安装防护功能启动失败")
|
||||
}
|
||||
install(currentActivity, pkgPath)
|
||||
}
|
||||
} else {
|
||||
val isTheFirstTimeToShowVpnHintDialog = VpnHelper.isTheFistTimeToShowVpnHintDialog()
|
||||
|
||||
downloadEntity?.let {
|
||||
NewFlatLogUtils.logVpnHintDialogShow(it.gameId, it.name)
|
||||
}
|
||||
|
||||
// 将 VPN 提示弹窗标记为已读(已读后的下一次显示"不再提醒"按钮)
|
||||
VpnHelper.setVpnHintDialogShowed()
|
||||
if (!VpnHelper.shouldShowVpnHintDialog()) {
|
||||
VpnHelper.startVpn(currentActivity) { shouldShowVpnError ->
|
||||
if (shouldShowVpnError) {
|
||||
ToastUtils.toast("安装防护功能启动失败")
|
||||
}
|
||||
install(currentActivity, pkgPath)
|
||||
}
|
||||
} else {
|
||||
DialogHelper.showGuideDialog(
|
||||
context = currentActivity,
|
||||
title = "开启安装防护",
|
||||
content = "建议您开启安装防护功能,该功能有助于帮助您更快的完成安装,避免因提示和置换导致的重复下载等问题,安装防护功能需要获取您的VPN权限",
|
||||
confirmText = "立即授权开启防护",
|
||||
cancelText = "不再提醒",
|
||||
confirmClickCallback = {
|
||||
VpnHelper.ignoreVpnHintDialog()
|
||||
VpnHelper.startVpn(currentActivity) { shouldShowVpnError ->
|
||||
if (shouldShowVpnError) {
|
||||
ToastUtils.toast("安装防护功能启动失败")
|
||||
}
|
||||
install(currentActivity, pkgPath)
|
||||
}
|
||||
|
||||
downloadEntity?.let {
|
||||
NewFlatLogUtils.logVpnHintDialogClick(it.gameId, it.name, "立即授权")
|
||||
}
|
||||
},
|
||||
cancelClickCallback = {
|
||||
VpnHelper.ignoreVpnFunction()
|
||||
install(currentActivity, pkgPath)
|
||||
downloadEntity?.let {
|
||||
NewFlatLogUtils.logVpnHintDialogClick(it.gameId, it.name, "不再提醒")
|
||||
}
|
||||
},
|
||||
extraConfig = DialogHelper.Config(
|
||||
showCloseIcon = true,
|
||||
showAlternativeCancelStyle = !isTheFirstTimeToShowVpnHintDialog
|
||||
),
|
||||
uiModificationCallback = { binding ->
|
||||
binding.cancelTv.visibility = View.GONE
|
||||
binding.closeContainer.setOnClickListener {
|
||||
binding.markDismissByTouchInside()
|
||||
|
||||
install(currentActivity, pkgPath)
|
||||
binding.dismiss()
|
||||
|
||||
downloadEntity?.let {
|
||||
NewFlatLogUtils.logVpnHintDialogClick(it.gameId, it.name, "关闭按钮")
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -28,10 +28,10 @@ import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.core.utils.MD5Utils;
|
||||
import com.gh.gamecenter.core.utils.SentryHelper;
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity;
|
||||
import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity;
|
||||
import com.gh.gamecenter.feature.utils.SentryHelper;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.gh.vspace.db.VGameEntity;
|
||||
@ -661,64 +661,32 @@ public class PackageUtils {
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取所有已安装的软件的包名、版本(非系统应用)
|
||||
* 获取所有已安装的软件的包名(包括系统应用)
|
||||
*/
|
||||
public static ArrayList<String> getAllPackageName(Context context) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
List<PackageInfo> packageInfos = PackageHelper.INSTANCE.getInstalledPackages(context, 0);
|
||||
for (PackageInfo packageInfo : packageInfos) {
|
||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
if (!context.getPackageName().equals(packageInfo.packageName)) {
|
||||
list.add(packageInfo.packageName);
|
||||
}
|
||||
List<String> packageNameList = PackageHelper.INSTANCE.getInstalledPackageNameList(context, 0);
|
||||
for (String packageName : packageNameList) {
|
||||
if (!context.getPackageName().equals(packageName)) {
|
||||
list.add(packageName);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static ArrayList<String> getAllPackageNameIncludeGh(Context context) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
List<PackageInfo> packageInfos = PackageHelper.INSTANCE.getInstalledPackages(context, 0);
|
||||
for (PackageInfo packageInfo : packageInfos) {
|
||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
list.add(packageInfo.packageName);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取所有已安装的软件的包名(包括系统应用)
|
||||
*/
|
||||
public static ArrayList<String> getAllPackageNameIncludeSystemApps(Context context) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
List<PackageInfo> packageInfos = PackageHelper.INSTANCE.getInstalledPackages(context, 0);
|
||||
for (PackageInfo packageInfo : packageInfos) {
|
||||
list.add(packageInfo.packageName);
|
||||
}
|
||||
return list;
|
||||
List<String> packageNameList = PackageHelper.INSTANCE.getInstalledPackageNameList(context, 0);
|
||||
return new ArrayList<>(packageNameList);
|
||||
}
|
||||
|
||||
public static JSONArray getAppList(Context context) {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
try {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
List<PackageInfo> packageInfos = PackageHelper.INSTANCE.getInstalledPackages(context, 0);
|
||||
for (PackageInfo packageInfo : packageInfos) {
|
||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
// 这里的 pm.getApplicationLabel 有极小机率会返回 null 值 (明明方法标示了返回值 nonnull)
|
||||
// Attempt to invoke interface method 'java.lang.String java.lang.CharSequence.toString()' on a null object reference
|
||||
// 所以要是为空就 continue,忽略掉它
|
||||
if (pm.getApplicationLabel(packageInfo.applicationInfo) == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
jsonObject.put("name", pm.getApplicationLabel(packageInfo.applicationInfo).toString());
|
||||
jsonObject.put("package", packageInfo.packageName);
|
||||
jsonObject.put("version", packageInfo.versionName);
|
||||
jsonArray.put(jsonObject);
|
||||
}
|
||||
List<String> packageNameList = PackageHelper.INSTANCE.getInstalledPackageNameList(context, 0);
|
||||
for (String packageName : packageNameList) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("package", packageName);
|
||||
jsonArray.put(jsonObject);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@ -5,12 +5,12 @@ import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil;
|
||||
import com.gh.gamecenter.common.retrofit.JSONObjectResponse;
|
||||
import com.gh.gamecenter.common.retrofit.Response;
|
||||
import com.gh.gamecenter.feature.entity.CommentEntity;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.lightgame.utils.Utils;
|
||||
import com.walkud.rom.checker.RomIdentifier;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
@ -37,7 +37,7 @@ public class PostCommentUtils {
|
||||
device.put("model", Build.MODEL);
|
||||
device.put("manufacturer", Build.MANUFACTURER);
|
||||
device.put("android_version", android.os.Build.VERSION.RELEASE);
|
||||
device.put("rom", RomIdentifier.getRom().name() + " " + RomIdentifier.getRom().getVersionName());
|
||||
device.put("rom", MetaUtil.INSTANCE.getRom().name() + " " + MetaUtil.INSTANCE.getRom().getVersionName());
|
||||
content.put("device", device);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
342
app/src/main/java/com/gh/common/util/PureModeHelper.kt
Normal file
342
app/src/main/java/com/gh/common/util/PureModeHelper.kt
Normal file
@ -0,0 +1,342 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.provider.Settings
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.DefaultLifecycleObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.entity.NewApiSettingsEntity
|
||||
import com.lightgame.utils.Utils
|
||||
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge
|
||||
import com.gh.gamecenter.common.utils.enlargeTouchArea
|
||||
import com.gh.gamecenter.common.utils.setDrawableEnd
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
|
||||
/**
|
||||
* 处理厂商纯净/安全模式的辅助类
|
||||
*/
|
||||
object PureModeHelper {
|
||||
|
||||
private const val TAG = "PureModeHelper"
|
||||
|
||||
private const val HW = "HUAWEI"
|
||||
|
||||
private const val HW_PURE_MODE_STATE = "pure_mode_state"
|
||||
private const val HW_PURE_ENHANCED_MODE_STATE = "pure_enhanced_mode_state"
|
||||
|
||||
private const val HW_PURE_MODE = "harmony_os_pure_mode"
|
||||
private const val HW_PURE_ENHANCED_MODE = "harmony_os_pure_enhanced_mode"
|
||||
|
||||
private const val SP_USER_IGNORE_GUIDE = "user_ignore_guide"
|
||||
|
||||
private const val SWITCH_EXIST = 1
|
||||
private const val SWITCH_ON = 0
|
||||
private const val SWITCH_OFF = -1
|
||||
|
||||
private var isThisDeviceUsingEnhancedMode = false // 当前设备是否是增强纯净模式
|
||||
|
||||
fun handlePureModeIfNeeded(
|
||||
context: Context,
|
||||
gameId: String,
|
||||
gameName: String,
|
||||
gameType: String,
|
||||
callback: () -> Unit
|
||||
) {
|
||||
// 用户忽略提醒,不再走下面的逻辑
|
||||
if (SPUtils.getBoolean(SP_USER_IGNORE_GUIDE, false)) {
|
||||
callback()
|
||||
return
|
||||
}
|
||||
|
||||
// 仅适用于华为手机
|
||||
val manufacturer = android.os.Build.MANUFACTURER
|
||||
if (manufacturer != HW) {
|
||||
callback.invoke()
|
||||
return
|
||||
}
|
||||
|
||||
val solidContext = DialogHelper.checkDialogContext(context)
|
||||
|
||||
if (solidContext == null) {
|
||||
callback.invoke()
|
||||
return
|
||||
}
|
||||
|
||||
if (readState(solidContext, HW_PURE_ENHANCED_MODE_STATE) == SWITCH_ON) {
|
||||
Utils.log(TAG, "增强纯净模式开启!")
|
||||
isThisDeviceUsingEnhancedMode = true
|
||||
|
||||
val pureModeGuide =
|
||||
Config.getNewApiSettingsEntity()?.install?.guides?.firstOrNull { it.type == HW_PURE_ENHANCED_MODE }
|
||||
|
||||
if (pureModeGuide != null) {
|
||||
showHWHintDialog(solidContext, pureModeGuide, gameId, gameName, gameType, true, callback)
|
||||
} else {
|
||||
callback.invoke()
|
||||
}
|
||||
} else if (readState(solidContext, HW_PURE_ENHANCED_MODE_STATE) != SWITCH_EXIST
|
||||
&& readState(solidContext, HW_PURE_MODE_STATE) == SWITCH_ON
|
||||
) {
|
||||
Utils.log(TAG, "纯净模式开启!")
|
||||
isThisDeviceUsingEnhancedMode = false
|
||||
|
||||
val pureModeGuide =
|
||||
Config.getNewApiSettingsEntity()?.install?.guides?.firstOrNull { it.type == HW_PURE_MODE }
|
||||
|
||||
if (pureModeGuide != null) {
|
||||
showHWHintDialog(solidContext, pureModeGuide, gameId, gameName, gameType, false, callback)
|
||||
} else {
|
||||
callback.invoke()
|
||||
}
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showHWHintDialog(
|
||||
context: Context,
|
||||
guide: NewApiSettingsEntity.Guide,
|
||||
gameId: String,
|
||||
gameName: String,
|
||||
gameType: String,
|
||||
isEnhancedMode: Boolean,
|
||||
callback: () -> Unit
|
||||
) {
|
||||
var isIgnored = false
|
||||
|
||||
if (context is Activity) {
|
||||
if (context.isFinishing) {
|
||||
callback.invoke()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
trackDialogShow(isEnhancedMode, gameId, gameName, gameType)
|
||||
|
||||
DialogHelper.showGuideDialog(
|
||||
context = context,
|
||||
title = guide.title,
|
||||
content = guide.content,
|
||||
confirmText = guide.buttonTextSettingJump,
|
||||
cancelText = guide.buttonTextClose,
|
||||
uiModificationCallback = { binding ->
|
||||
binding.hintTv.buildSpannableString {
|
||||
addText(guide.linkTextPrefix)
|
||||
addText(guide.linkText) {
|
||||
setColor(ColorResId(R.color.text_theme))
|
||||
onClick(false) {
|
||||
binding.extraHintIv.performClick()
|
||||
}
|
||||
}
|
||||
}
|
||||
binding.extraHintIv.setImageResource(R.drawable.ic_home_head_arrow)
|
||||
binding.extraHintIv.setOnClickListener {
|
||||
directToLink(
|
||||
context,
|
||||
guide,
|
||||
gameId,
|
||||
gameName,
|
||||
gameType,
|
||||
isEnhancedMode,
|
||||
isIgnored
|
||||
)
|
||||
}
|
||||
binding.extraHintIv.enlargeTouchArea()
|
||||
binding.extraHintIv.visibility = View.VISIBLE
|
||||
binding.hintTv.visibility = View.VISIBLE
|
||||
binding.selectorContainer.visibility = if (guide.dialogFrequency == "once") View.VISIBLE else View.GONE
|
||||
binding.selectorContainer.setOnClickListener {
|
||||
binding.selectorContainer.isChecked = !binding.selectorContainer.isChecked
|
||||
isIgnored = binding.selectorContainer.isChecked
|
||||
}
|
||||
|
||||
binding.confirmTv.setOnClickListener {
|
||||
toHWPureModeSetting(context)
|
||||
trackDialogClicked(
|
||||
isEnhancedMode = isEnhancedMode,
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameType,
|
||||
buttonName = guide.buttonTextSettingJump,
|
||||
isIgnored = isIgnored
|
||||
)
|
||||
}
|
||||
|
||||
// 监听是否已授权,授权后自动调起安装并 dismiss dialog
|
||||
if (context is AppCompatActivity) {
|
||||
val lifecycle = context.lifecycle
|
||||
lifecycle.addObserver(object : DefaultLifecycleObserver {
|
||||
override fun onResume(owner: LifecycleOwner) {
|
||||
val granted = (isThisDeviceUsingEnhancedMode && readState(context, HW_PURE_ENHANCED_MODE_STATE) != SWITCH_ON)
|
||||
|| (!isThisDeviceUsingEnhancedMode && readState(context, HW_PURE_MODE_STATE) != SWITCH_ON)
|
||||
|
||||
if (granted) {
|
||||
binding.dialog.dismiss()
|
||||
callback.invoke()
|
||||
lifecycle.removeObserver(this)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy(owner: LifecycleOwner) {
|
||||
super.onDestroy(owner)
|
||||
|
||||
lifecycle.removeObserver(this)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
confirmClickCallback = {
|
||||
// do nothing, 上面 setOnClickListener 处理了
|
||||
},
|
||||
cancelClickCallback = {
|
||||
if (guide.dialogFrequency == "once" && isIgnored) {
|
||||
SPUtils.setBoolean(SP_USER_IGNORE_GUIDE, true)
|
||||
}
|
||||
trackDialogClicked(
|
||||
isEnhancedMode = isEnhancedMode,
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameType,
|
||||
buttonName = guide.buttonTextClose,
|
||||
isIgnored = isIgnored
|
||||
)
|
||||
callback()
|
||||
},
|
||||
touchOutsideCallback = {
|
||||
if (guide.dialogFrequency == "once" && isIgnored) {
|
||||
SPUtils.setBoolean(SP_USER_IGNORE_GUIDE, true)
|
||||
}
|
||||
trackDialogClicked(
|
||||
isEnhancedMode = isEnhancedMode,
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameType,
|
||||
buttonName = "关闭弹窗",
|
||||
isIgnored = isIgnored
|
||||
)
|
||||
callback()
|
||||
},
|
||||
extraConfig = DialogHelper.Config(centerTitle = true)
|
||||
)
|
||||
}
|
||||
|
||||
private fun directToLink(
|
||||
context: Context,
|
||||
guide: NewApiSettingsEntity.Guide,
|
||||
gameId: String,
|
||||
gameName: String,
|
||||
gameType: String,
|
||||
isEnhancedMode: Boolean,
|
||||
isIgnored: Boolean
|
||||
) {
|
||||
DirectUtils.directToLinkPage(context, guide.link, "纯净模式弹窗", "")
|
||||
trackDialogClicked(
|
||||
isEnhancedMode,
|
||||
gameId,
|
||||
gameName,
|
||||
gameType,
|
||||
"跳转链接",
|
||||
isIgnored,
|
||||
guide.link.link ?: "",
|
||||
guide.link.type ?: "",
|
||||
guide.link.text ?: ""
|
||||
)
|
||||
}
|
||||
|
||||
private fun trackDialogShow(
|
||||
isEnhancedMode: Boolean,
|
||||
gameId: String,
|
||||
gameName: String,
|
||||
gameType: String
|
||||
) {
|
||||
if (isEnhancedMode) {
|
||||
SensorsBridge.trackAddedProtectionDialogShow(
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameType
|
||||
)
|
||||
} else {
|
||||
SensorsBridge.trackPureModeDialogShow(
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameType
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun trackDialogClicked(
|
||||
isEnhancedMode: Boolean,
|
||||
gameId: String,
|
||||
gameName: String,
|
||||
gameType: String,
|
||||
buttonName: String,
|
||||
isIgnored: Boolean,
|
||||
linkId: String? = null,
|
||||
linkType: String? = null,
|
||||
linkText: String? = null
|
||||
) {
|
||||
if (isEnhancedMode) {
|
||||
SensorsBridge.trackAddedProtectionDialogClick(
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameType,
|
||||
buttonName = buttonName,
|
||||
isIgnored = isIgnored,
|
||||
linkId = linkId ?: "",
|
||||
linkType = linkType ?: "",
|
||||
linkText = linkText ?: ""
|
||||
)
|
||||
} else {
|
||||
SensorsBridge.trackPureModeDialogClick(
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameType,
|
||||
buttonName = buttonName,
|
||||
isIgnored = isIgnored,
|
||||
linkId = linkId ?: "",
|
||||
linkType = linkType ?: "",
|
||||
linkText = linkText ?: ""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun toHWPureModeSetting(context: Context) {
|
||||
try {
|
||||
val intent = Intent()
|
||||
intent.setPackage("com.huawei.security.privacycenter")
|
||||
intent.setAction("com.huawei.securitycenter.PURE_MODE_ACTIVITY")
|
||||
intent.putExtra("intent_from_settings", true)
|
||||
context.startActivity(intent)
|
||||
} catch (_: Exception) {
|
||||
toSystemSettings(context)
|
||||
}
|
||||
}
|
||||
|
||||
private fun toSystemSettings(context: Context) {
|
||||
try {
|
||||
val intent = Intent(Settings.ACTION_SETTINGS)
|
||||
context.startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun readState(context: Context, key: String): Int {
|
||||
try {
|
||||
val result = Settings.Secure.getInt(context.getContentResolver(), key, SWITCH_OFF)
|
||||
Utils.log(TAG, "readState $key state >>> $result")
|
||||
return result
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return SWITCH_OFF
|
||||
}
|
||||
|
||||
}
|
||||
@ -27,8 +27,8 @@ import com.gh.gamecenter.gamedetail.rating.RatingReplyActivity
|
||||
|
||||
object SyncDataBetweenPageHelper {
|
||||
|
||||
private const val REQUEST_CODE_TAG = "REQUEST_CODE_TAG"
|
||||
private const val DATA_POSITION_TAG = "DATA_POSITION_TAG"
|
||||
const val REQUEST_CODE_TAG = "REQUEST_CODE_TAG"
|
||||
const val DATA_POSITION_TAG = "DATA_POSITION_TAG"
|
||||
private const val DEFAULT_NUMBER = -1111
|
||||
|
||||
fun startActivityForResult(context: Context, intent: Intent, requestCode: Int, dataPosition: Int) {
|
||||
|
||||
@ -2,15 +2,16 @@ package com.gh.common.util
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.gh.common.iinterface.ISuperiorChain
|
||||
import com.gh.gamecenter.amway.AmwayFragment
|
||||
import com.gh.gamecenter.category2.CategoryV2Fragment
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.common.provider.IHelpAndFeedbackProvider
|
||||
import com.gh.gamecenter.discovery.DiscoveryFragment
|
||||
import com.gh.gamecenter.entity.SubjectData
|
||||
import com.gh.gamecenter.feedback.view.help.HelpAndFeedbackFragment
|
||||
import com.gh.gamecenter.feedback.view.qa.HelpContainerFragment
|
||||
import com.gh.gamecenter.forum.detail.ForumDetailFragment
|
||||
import com.gh.gamecenter.forum.home.CommunityHomeFragment
|
||||
import com.gh.gamecenter.fragment.ReloadFragment
|
||||
@ -62,7 +63,8 @@ object ViewPagerFragmentHelper {
|
||||
const val TYPE_GAME_LIST = "game_list" // 游戏单广场
|
||||
const val TYPE_FEEDBACK = "feedback" // 帮助与反馈
|
||||
const val TYPE_COLUMN = "column" // 游戏专题详情页
|
||||
const val TYPE_QQ_MINI_GAME_COLUMN = "qq_mini_game_column_detail" // QQ游戏专题详情页
|
||||
const val TYPE_QQ_MINI_GAME_COLUMN = "qq_mini_game_column_detail" // QQ小游戏专题详情页
|
||||
const val TYPE_WECHAT_GAME_COLUMN = "wechat_game_column_detail" // 微信小游戏专题详情页
|
||||
const val TYPE_COLUMN_COLLECTION = "column_collection" // 专题合集详情页
|
||||
const val TYPE_SERVER = "server" // 开服表
|
||||
const val TYPE_COLUMN_TEST = "column_test_v2" // 新游开测
|
||||
@ -124,7 +126,15 @@ object ViewPagerFragmentHelper {
|
||||
}
|
||||
// 帮助与反馈
|
||||
TYPE_FEEDBACK -> {
|
||||
HelpAndFeedbackFragment().with(bundle)
|
||||
val helpAndFeedbackProvider =
|
||||
ARouter.getInstance().build(RouteConsts.provider.helpAndFeedback)
|
||||
.navigation() as? IHelpAndFeedbackProvider
|
||||
if (helpAndFeedbackProvider != null) {
|
||||
helpAndFeedbackProvider.getHelpAndFeedbackFragment().with(bundle)
|
||||
} else {
|
||||
// 纯粹是占位用的 fragment
|
||||
AmwayFragment().with(bundle)
|
||||
}
|
||||
}
|
||||
// 帖子
|
||||
TYPE_COMMUNITY_ARTICLE -> {
|
||||
@ -151,11 +161,16 @@ object ViewPagerFragmentHelper {
|
||||
className = GameCollectionSquareFragment::class.java.name
|
||||
}
|
||||
// 游戏专题详情页/QQ游戏专题详情页
|
||||
TYPE_COLUMN, TYPE_QQ_MINI_GAME_COLUMN -> {
|
||||
TYPE_COLUMN, TYPE_QQ_MINI_GAME_COLUMN, TYPE_WECHAT_GAME_COLUMN -> {
|
||||
val subjectType = when(entity.type) {
|
||||
TYPE_QQ_MINI_GAME_COLUMN -> SubjectData.SubjectType.QQ_GAME
|
||||
TYPE_WECHAT_GAME_COLUMN -> SubjectData.SubjectType.WECHAT_GAME
|
||||
else -> SubjectData.SubjectType.NORMAL
|
||||
}
|
||||
className = SubjectFragment::class.java.name
|
||||
bundle.putParcelable(
|
||||
EntranceConsts.KEY_SUBJECT_DATA,
|
||||
SubjectData(entity.link, entity.text, false, isQQMiniGame = entity.type == "qq_mini_game_column_detail")
|
||||
SubjectData(entity.link, entity.text, false, subjectType = subjectType)
|
||||
)
|
||||
bundle.putBoolean(EntranceConsts.KEY_SHOW_DOWNLOAD_MENU, !isTabWrapper)
|
||||
}
|
||||
@ -227,9 +242,15 @@ object ViewPagerFragmentHelper {
|
||||
}
|
||||
// QA
|
||||
TYPE_QA -> {
|
||||
className = HelpContainerFragment::class.java.name
|
||||
bundle.putString(EntranceConsts.KEY_QA_ID, entity.link)
|
||||
bundle.putString(EntranceConsts.KEY_NAVIGATION_TITLE, entity.text)
|
||||
val helpAndFeedbackProvider =
|
||||
ARouter.getInstance().build(RouteConsts.provider.helpAndFeedback)
|
||||
.navigation() as? IHelpAndFeedbackProvider
|
||||
|
||||
helpAndFeedbackProvider?.let {
|
||||
className = it.getHelpContainerFragmentClass()
|
||||
bundle.putString(EntranceConsts.KEY_QA_ID, entity.link)
|
||||
bundle.putString(EntranceConsts.KEY_NAVIGATION_TITLE, entity.text)
|
||||
}
|
||||
}
|
||||
// 资讯中心
|
||||
TYPE_ARTICLE_CENTER -> {
|
||||
|
||||
@ -31,7 +31,7 @@ class CustomExoPlayerCacheManager : ICacheManager {
|
||||
mediaPlayer.setDataSource(context, Uri.parse(url), header)
|
||||
}
|
||||
|
||||
override fun clearCache(context: Context, cachePath: File, url: String) {
|
||||
override fun clearCache(context: Context, cachePath: File?, url: String) {
|
||||
ExoSourceManager.clearCache(context, cachePath, url)
|
||||
}
|
||||
|
||||
|
||||
@ -156,8 +156,8 @@ class CustomIjkExo2MediaPlayer : AbstractMediaPlayer(), Player.EventListener, An
|
||||
|
||||
override fun setDataSource(context: Context?, uri: Uri) {
|
||||
dataSource = uri.toString()
|
||||
// mediaSource = exoHelper?.getMediaSource(dataSource, isPreview, isCache, isLooping, cacheDir, overrideExtension)
|
||||
mediaSource = DefaultMediaSourceFactory(context!!).createMediaSource(MediaItem.fromUri(uri))
|
||||
mediaSource = exoHelper?.getMediaSource(dataSource, isPreview, isCache, isLooping, cacheDir, overrideExtension)
|
||||
// mediaSource = DefaultMediaSourceFactory(context!!).createMediaSource(MediaItem.fromUri(uri))
|
||||
}
|
||||
|
||||
override fun setDataSource(fd: FileDescriptor?) {
|
||||
@ -265,7 +265,9 @@ class CustomIjkExo2MediaPlayer : AbstractMediaPlayer(), Player.EventListener, An
|
||||
internalPlayer?.release()
|
||||
internalPlayer = null
|
||||
|
||||
exoHelper?.release()
|
||||
// exoHelper?.release() 调用的是 ExoSourceManager 的 release 方法,会废弃掉全局唯一的 SimpleCache 实例
|
||||
// 导致其他地方使用 SimpleCache 时会出现异常,无法正常播放
|
||||
// exoHelper?.release()
|
||||
|
||||
surface = null
|
||||
dataSource = null
|
||||
|
||||
@ -6,25 +6,21 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.get
|
||||
import com.facebook.drawee.drawable.ScalingUtils
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.gamecenter.ImageViewerActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.ImageUtils
|
||||
import com.gh.gamecenter.common.utils.debounceActionWithInterval
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.utils.toResString
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.TopCutProcess
|
||||
import com.gh.gamecenter.databinding.ItemCommunityImageBinding
|
||||
import com.gh.gamecenter.feature.entity.AnswerEntity
|
||||
import com.gh.gamecenter.feature.entity.CommunityVideoEntity
|
||||
import com.gh.gamecenter.feature.entity.ImageInfo
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel
|
||||
|
||||
class ImageContainerView : LinearLayout {
|
||||
private var mAnswerEntity: AnswerEntity? = null
|
||||
|
||||
private var data: ImageContainerData? = null
|
||||
|
||||
//三图默认宽度
|
||||
private var mDefaultWidth = 0f
|
||||
@ -41,9 +37,6 @@ class ImageContainerView : LinearLayout {
|
||||
//长图比例
|
||||
private var mLongPictureRatio = 9 / 18f
|
||||
|
||||
private var mEntrance = ""
|
||||
private var mPath = ""
|
||||
|
||||
//图片之间的间距
|
||||
private val mItemSpace = 4f.dip2px()
|
||||
private var mOffset = 0
|
||||
@ -51,6 +44,8 @@ class ImageContainerView : LinearLayout {
|
||||
|
||||
private val imageViewList = arrayListOf<SimpleDraweeView>()
|
||||
|
||||
private var onImageContainerEventListener: OnImageContainerEventListener? = null
|
||||
|
||||
constructor(context: Context) : this(context, null)
|
||||
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
@ -75,40 +70,34 @@ class ImageContainerView : LinearLayout {
|
||||
calculateWidth()
|
||||
}
|
||||
|
||||
fun bindData(entity: AnswerEntity, entrance: String = "", path: String = "", imageClick: (() -> Unit)? = null) {
|
||||
fun bindData(
|
||||
data: ImageContainerData,
|
||||
listener: OnImageContainerEventListener? = null
|
||||
) {
|
||||
this.data = data
|
||||
onImageContainerEventListener = listener
|
||||
imageViewList.clear()
|
||||
if (entity.id != mAnswerEntity?.id) {
|
||||
removeAllViews()
|
||||
}
|
||||
mAnswerEntity = entity
|
||||
mEntrance = entrance
|
||||
mPath = path
|
||||
removeAllViews()
|
||||
index = 0
|
||||
if ((entity.user.id == UserManager.getInstance().userId && entity.videos.isNotEmpty()) ||
|
||||
(entity.user.id != UserManager.getInstance().userId && entity.getPassVideos().isNotEmpty()) ||
|
||||
entity.images.isNullOrEmpty()
|
||||
) {
|
||||
if (!data.show) {
|
||||
visibility = View.GONE
|
||||
return
|
||||
}
|
||||
visibility = View.VISIBLE
|
||||
if (mAnswerEntity?.type == "community_article") {
|
||||
if (data.isPostCard) {
|
||||
//若文章内容含有图片及视频,则信息流卡片,仅展示图片,且标题后带有‘有视频’标签
|
||||
//若文章内容仅含有图片,则信息流卡片,仅展示图片,无标签
|
||||
//若文章内容仅含有视频,则信息流卡片,仅展示视频,无标签
|
||||
when {
|
||||
entity.images.isNotEmpty() -> {
|
||||
val imagesInfo = entity.imagesInfo
|
||||
val images = entity.images.take(3)
|
||||
images.forEachIndexed { index, url ->
|
||||
val width = if (index <= entity.imagesInfo.size - 1) imagesInfo[index].width else 0
|
||||
val height = if (index <= entity.imagesInfo.size - 1) imagesInfo[index].height else 0
|
||||
bindImage(url, width, height, images.size == 1, imageClick)
|
||||
}
|
||||
data.images.isNotEmpty() -> {
|
||||
data.images.take(3)
|
||||
.forEach {
|
||||
bindImage(it.url, it.width, it.height, data.images.size == 1)
|
||||
}
|
||||
}
|
||||
|
||||
entity.getPassVideos().isNotEmpty() -> {
|
||||
val video = entity.getPassVideos()[0]
|
||||
data.video != null -> {
|
||||
val video = data.video
|
||||
bindVideo(video, video.width, video.height, true)
|
||||
}
|
||||
|
||||
@ -120,28 +109,22 @@ class ImageContainerView : LinearLayout {
|
||||
//若问答内容含有图片及视频,则信息流卡片,同时展示图片及视频,且参考以往排序逻辑(视频优先放置第一位),无标签
|
||||
//若问答内容仅含有图片,则信息流卡片,仅展示图片,无标签
|
||||
//若问答内容仅含有视频,则信息流卡片,仅展示视频,无标签
|
||||
if (entity.getPassVideos().isNotEmpty()) {
|
||||
val video = entity.getPassVideos()[0]
|
||||
bindVideo(video, video.width, video.height, mAnswerEntity?.images.isNullOrEmpty())
|
||||
entity.images.take(2).forEachIndexed { index, url ->
|
||||
val imagesInfo = entity.imagesInfo
|
||||
val width = if (index <= entity.imagesInfo.size - 1) imagesInfo[index].width else 0
|
||||
val height = if (index <= entity.imagesInfo.size - 1) imagesInfo[index].height else 0
|
||||
bindImage(url, width, height, false, imageClick)
|
||||
if (data.video != null) {
|
||||
val video = data.video
|
||||
bindVideo(video, video.width, video.height, data.images.isNullOrEmpty())
|
||||
data.images.take(2).forEach {
|
||||
bindImage(it.url, it.width, it.height, false)
|
||||
}
|
||||
} else {
|
||||
val images = entity.images.take(3)
|
||||
images.forEachIndexed { index, url ->
|
||||
val imagesInfo = entity.imagesInfo
|
||||
val width = if (index <= entity.imagesInfo.size - 1) imagesInfo[index].width else 0
|
||||
val height = if (index <= entity.imagesInfo.size - 1) imagesInfo[index].height else 0
|
||||
bindImage(url, width, height, images.size == 1, imageClick)
|
||||
}
|
||||
data.images.take(3)
|
||||
.forEach {
|
||||
bindImage(it.url, it.width, it.height, data.images.size == 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindVideo(video: CommunityVideoEntity, width: Int, height: Int, isChangeRatio: Boolean) {
|
||||
private fun bindVideo(video: ImageContainerData.VideoInfo, width: Int, height: Int, isChangeRatio: Boolean) {
|
||||
val oldView = if (childCount == 0 || index >= childCount) null else getChildAt(index)
|
||||
val binding = if (oldView != null) {
|
||||
ItemCommunityImageBinding.bind(oldView)
|
||||
@ -158,16 +141,7 @@ class ImageContainerView : LinearLayout {
|
||||
displayImage(binding, video.poster, width.toFloat(), height.toFloat(), isChangeRatio, true)
|
||||
binding.root.setOnClickListener {
|
||||
debounceActionWithInterval(it.id, 1000) {
|
||||
if (mAnswerEntity == null) return@debounceActionWithInterval
|
||||
val videoEntity = mAnswerEntity!!.getPassVideos().firstOrNull()
|
||||
DirectUtils.directToVideoDetail(
|
||||
context,
|
||||
videoEntity?.id ?: "",
|
||||
VideoDetailContainerViewModel.Location.VIDEO_HOT.value,
|
||||
showComment = false,
|
||||
entrance = mEntrance,
|
||||
path = mPath
|
||||
)
|
||||
onImageContainerEventListener?.onVideoCLick(video.id)
|
||||
}
|
||||
}
|
||||
index++
|
||||
@ -177,8 +151,7 @@ class ImageContainerView : LinearLayout {
|
||||
url: String,
|
||||
width: Int,
|
||||
height: Int,
|
||||
isChangeRatio: Boolean,
|
||||
imageClick: (() -> Unit)?
|
||||
isChangeRatio: Boolean
|
||||
) {
|
||||
val oldView = if (childCount == 0 || index >= childCount) null else getChildAt(index)
|
||||
val binding = if (oldView != null) {
|
||||
@ -195,25 +168,21 @@ class ImageContainerView : LinearLayout {
|
||||
binding.videoPlay.visibility = View.GONE
|
||||
displayImage(binding, url, width.toFloat(), height.toFloat(), isChangeRatio)
|
||||
binding.root.setOnClickListener {
|
||||
if (mAnswerEntity?.status == "pending" || mAnswerEntity?.status == "fail") return@setOnClickListener
|
||||
imageClick?.invoke()
|
||||
if (data?.status == "pending" || data?.status == "fail") return@setOnClickListener
|
||||
debounceActionWithInterval(it.id, 1000) {
|
||||
if (mAnswerEntity == null) return@debounceActionWithInterval
|
||||
val position = if (mAnswerEntity?.type == "community_article") {
|
||||
binding.root.tag as Int
|
||||
} else {
|
||||
if (mAnswerEntity!!.getPassVideos()
|
||||
.isNullOrEmpty()
|
||||
) binding.root.tag as Int else (binding.root.tag as Int) - 1
|
||||
data?.run {
|
||||
val position = if (isPostCard) {
|
||||
binding.root.tag as Int
|
||||
} else {
|
||||
if (video == null) binding.root.tag as Int else (binding.root.tag as Int) - 1
|
||||
}
|
||||
onImageContainerEventListener?.onImageClick(
|
||||
images.map(ImageContainerData.ImageInfo::url),
|
||||
position,
|
||||
imageViewList
|
||||
)
|
||||
}
|
||||
if (mAnswerEntity?.communityId.isNullOrEmpty()) {
|
||||
mAnswerEntity?.communityId = mAnswerEntity?.bbs?.id
|
||||
}
|
||||
val intent = ImageViewerActivity.getIntent(
|
||||
context, mAnswerEntity!!.images as ArrayList<String>, position, imageViewList,
|
||||
if (mAnswerEntity?.type == "community_article") mAnswerEntity else null, mEntrance, true
|
||||
)
|
||||
context.startActivity(intent)
|
||||
|
||||
}
|
||||
}
|
||||
index++
|
||||
@ -279,7 +248,7 @@ class ImageContainerView : LinearLayout {
|
||||
}
|
||||
|
||||
binding.pendingView.run {
|
||||
when (mAnswerEntity?.status) {
|
||||
when (data?.status) {
|
||||
"pending" -> {
|
||||
visibility = View.VISIBLE
|
||||
text = R.string.pending_status.toResString()
|
||||
@ -297,7 +266,7 @@ class ImageContainerView : LinearLayout {
|
||||
}
|
||||
|
||||
|
||||
val imageCount = mAnswerEntity?.images?.size ?: 0
|
||||
val imageCount = data?.images?.size ?: 0
|
||||
if (!isVideo && index == 2 && imageCount > 3) {
|
||||
binding.labelIcon.visibility = View.GONE
|
||||
binding.durationOrNumTv.visibility = View.VISIBLE
|
||||
@ -308,4 +277,80 @@ class ImageContainerView : LinearLayout {
|
||||
if (index != 0) params.leftMargin = mItemSpace
|
||||
binding.root.layoutParams = params
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
private const val COMMUNITY_ARTICLE = "community_article"
|
||||
|
||||
fun AnswerEntity.toImageContainerData(): ImageContainerData {
|
||||
val imageInfoList = arrayListOf<ImageContainerData.ImageInfo>()
|
||||
images.forEachIndexed { index, url ->
|
||||
if (index < 3) {
|
||||
imageInfoList.add(ImageContainerData.ImageInfo(url))
|
||||
}
|
||||
}
|
||||
imageInfoList.forEachIndexed { index, imageInfo ->
|
||||
val item = imagesInfo.getOrNull(index)
|
||||
if (item != null) {
|
||||
imageInfo.width = item.width
|
||||
imageInfo.height = item.height
|
||||
}
|
||||
}
|
||||
val video =
|
||||
getPassVideos().firstOrNull()?.let {
|
||||
ImageContainerData.VideoInfo(
|
||||
it.id,
|
||||
it.duration,
|
||||
it.poster,
|
||||
it.width,
|
||||
it.height
|
||||
)
|
||||
}
|
||||
val show = !((user.id == UserManager.getInstance().userId && videos.isNotEmpty())
|
||||
|| (user.id != UserManager.getInstance().userId && getPassVideos().isNotEmpty())
|
||||
|| images.isNullOrEmpty())
|
||||
return ImageContainerData(
|
||||
status = status,
|
||||
isPostCard = type == COMMUNITY_ARTICLE,
|
||||
images = imageInfoList,
|
||||
video = video,
|
||||
show
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
data class ImageContainerData(
|
||||
val status: String,
|
||||
val isPostCard: Boolean, // 是否是帖子卡片
|
||||
val images: List<ImageInfo>,
|
||||
val video: VideoInfo? = null,
|
||||
val show: Boolean
|
||||
) {
|
||||
|
||||
data class ImageInfo(
|
||||
val url: String,
|
||||
var width: Int = 0,
|
||||
var height: Int = 0
|
||||
)
|
||||
|
||||
data class VideoInfo(
|
||||
val id: String,
|
||||
val duration: String,
|
||||
val poster: String,
|
||||
var width: Int = 0,
|
||||
var height: Int = 0,
|
||||
)
|
||||
}
|
||||
|
||||
interface OnImageContainerEventListener {
|
||||
|
||||
fun onImageClick(
|
||||
images: List<String>,
|
||||
position: Int,
|
||||
imageViewList: ArrayList<SimpleDraweeView>
|
||||
)
|
||||
|
||||
fun onVideoCLick(videoId: String)
|
||||
}
|
||||
}
|
||||
@ -6,8 +6,12 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.text.underline
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.activityresult.ActResultRequest
|
||||
@ -37,6 +41,14 @@ object XapkDialogHelper {
|
||||
|
||||
val previousShowedDialog = mUnzipFailureDialogRef?.get()
|
||||
|
||||
val useRebootStyle = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
||||
|
||||
val content = if (useRebootStyle) {
|
||||
"未授权允许未知来源安装、数据包格式、设备兼容性…等均可能导致解压失败。"
|
||||
} else {
|
||||
"未授权允许未知来源安装、数据包格式、设备兼容性…等均可能导致解压失败。\n如果开启权限后仍未能解决,请提交反馈帮助我们改进。"
|
||||
}
|
||||
|
||||
if (previousShowedDialog != null
|
||||
&& previousShowedDialog.isShowing
|
||||
&& context == previousShowedDialog.ownerActivity
|
||||
@ -48,9 +60,9 @@ object XapkDialogHelper {
|
||||
val dialog = DialogHelper.showGuideDialog(
|
||||
context = context,
|
||||
title = "",
|
||||
content = "未授权允许未知来源安装、数据包格式、设备兼容性…等均可能导致解压失败。\n如果开启权限后仍未能解决,请提交反馈帮助我们改进。",
|
||||
content = content,
|
||||
confirmText = "开启权限",
|
||||
cancelText = "提交反馈",
|
||||
cancelText = if (useRebootStyle) "重启助手" else "提交反馈",
|
||||
confirmClickCallback = {
|
||||
if (context is AppCompatActivity) {
|
||||
val intent = PermissionHelper.getToInstallPermissionSettingIntent(context)
|
||||
@ -83,11 +95,7 @@ object XapkDialogHelper {
|
||||
)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
val pm = context.packageManager
|
||||
val restartIntent = pm.getLaunchIntentForPackage(context.packageName)
|
||||
val mainIntent = Intent.makeRestartActivityTask(restartIntent!!.component)
|
||||
context.startActivity(mainIntent)
|
||||
Runtime.getRuntime().exit(0)
|
||||
restart(context)
|
||||
} else {
|
||||
XapkInstaller.install(context, downloadEntity, true)
|
||||
}
|
||||
@ -100,27 +108,22 @@ object XapkDialogHelper {
|
||||
}
|
||||
},
|
||||
cancelClickCallback = {
|
||||
val hint = "游戏安装包解压失败,问题反馈:"
|
||||
HelpAndFeedbackBridge.startSuggestionActivity(
|
||||
context,
|
||||
SuggestType.GAME,
|
||||
null,
|
||||
hint,
|
||||
SimpleGameEntity(downloadEntity.gameId, downloadEntity.name, downloadEntity.icon)
|
||||
)
|
||||
NewFlatLogUtils.logXApkUnzipFailedDialogClick(
|
||||
"提交反馈",
|
||||
false,
|
||||
downloadEntity.gameId,
|
||||
downloadEntity.name
|
||||
)
|
||||
if (useRebootStyle) {
|
||||
// 记录应用重启前需要重解压的信息
|
||||
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, context.javaClass.name)
|
||||
SPUtils.setString(Constants.SP_XAPK_URL, downloadEntity.url)
|
||||
|
||||
SensorsBridge.trackGameDecompressionFailedDialogClick(
|
||||
buttonName = "提交反馈",
|
||||
downloadEntity.gameId,
|
||||
downloadEntity.name,
|
||||
downloadEntity.categoryChinese
|
||||
)
|
||||
SensorsBridge.trackGameDecompressionFailedDialogClick(
|
||||
buttonName = "重启助手",
|
||||
downloadEntity.gameId,
|
||||
downloadEntity.name,
|
||||
downloadEntity.categoryChinese
|
||||
)
|
||||
|
||||
restart(context)
|
||||
} else {
|
||||
doFeedback(context, downloadEntity)
|
||||
}
|
||||
},
|
||||
uiModificationCallback = { binding ->
|
||||
binding.headIv.setBackgroundResource(R.drawable.dialog_unzip_failure_head_background)
|
||||
@ -146,6 +149,30 @@ object XapkDialogHelper {
|
||||
)
|
||||
binding.dismiss()
|
||||
}
|
||||
if (useRebootStyle) {
|
||||
val spannableString = SpannableStringBuilder()
|
||||
.append("未能解决问题?点击 ")
|
||||
.underline { append("提交反馈") }
|
||||
.append(" ")
|
||||
binding.alternativeCancelTv.visibility = View.VISIBLE
|
||||
binding.alternativeCancelTv.text = spannableString
|
||||
binding.alternativeCancelTv.setTextColor(R.color.text_secondary.toColor(context))
|
||||
binding.alternativeCancelTv.setDrawableEnd(R.drawable.ic_right_arrow_xapk)
|
||||
binding.alternativeCancelTv.setOnClickListener {
|
||||
doFeedback(context, downloadEntity)
|
||||
}
|
||||
|
||||
binding.hintTv.text = "开启权限后请务必重启光环助手,再进行安装"
|
||||
binding.hintTv.setTextColor(R.color.text_theme.toColor(context))
|
||||
binding.hintTv.setTextAppearance(R.style.TextCaption1)
|
||||
binding.hintTv.visibility = View.VISIBLE
|
||||
binding.hintTv.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
topMargin = 8F.dip2px()
|
||||
}
|
||||
binding.confirmTv.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
topMargin = 16F.dip2px()
|
||||
}
|
||||
}
|
||||
},
|
||||
touchOutsideCallback = {
|
||||
SensorsBridge.trackGameDecompressionFailedDialogClick(
|
||||
@ -164,4 +191,37 @@ object XapkDialogHelper {
|
||||
mUnzipFailureDialogRef = WeakReference(dialog)
|
||||
}
|
||||
|
||||
private fun restart(context: Context) {
|
||||
val pm = context.packageManager
|
||||
val restartIntent = pm.getLaunchIntentForPackage(context.packageName)
|
||||
val mainIntent = Intent.makeRestartActivityTask(restartIntent!!.component)
|
||||
context.startActivity(mainIntent)
|
||||
Runtime.getRuntime().exit(0)
|
||||
}
|
||||
|
||||
private fun doFeedback(context: Context, downloadEntity: DownloadEntity) {
|
||||
val hint = "游戏安装包解压失败,问题反馈:"
|
||||
|
||||
HelpAndFeedbackBridge.startSuggestionActivity(
|
||||
context,
|
||||
SuggestType.GAME,
|
||||
null,
|
||||
hint,
|
||||
SimpleGameEntity(downloadEntity.gameId, downloadEntity.name, downloadEntity.icon)
|
||||
)
|
||||
NewFlatLogUtils.logXApkUnzipFailedDialogClick(
|
||||
"提交反馈",
|
||||
false,
|
||||
downloadEntity.gameId,
|
||||
downloadEntity.name
|
||||
)
|
||||
|
||||
SensorsBridge.trackGameDecompressionFailedDialogClick(
|
||||
buttonName = "提交反馈",
|
||||
downloadEntity.gameId,
|
||||
downloadEntity.name,
|
||||
downloadEntity.categoryChinese
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
@ -4,12 +4,8 @@ import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.provider.Settings
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.dialog.ManagerAllFilesPermissionDialogFragment
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.common.util.DownloadNotificationHelper
|
||||
import com.gh.common.util.PackageInstaller
|
||||
@ -19,15 +15,17 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.core.utils.SentryHelper
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.feature.utils.SentryHelper
|
||||
import com.gh.gamecenter.xapk.XApkUnZipper
|
||||
import com.gh.gamecenter.xapk.core.XApkFile
|
||||
import com.gh.gamecenter.xapk.core.XApkUnZipCallback
|
||||
import com.gh.gamecenter.xapk.core.XApkUnZipEntry
|
||||
import com.gh.gamecenter.xapk.core.XApkUnZipOutputFactory
|
||||
import com.gh.gamecenter.xapk.io.*
|
||||
import com.gh.gamecenter.xapk.io.NonSplitApksOutput
|
||||
import com.gh.gamecenter.xapk.io.OBBFileOutput
|
||||
import com.gh.gamecenter.xapk.io.SplitApksOutput
|
||||
import com.gh.gamecenter.xapk.io.XApkFileOutput
|
||||
import com.gh.gamecenter.xapk.pi.IPackageInstaller
|
||||
import com.gh.ndownload.NDataChanger
|
||||
import com.halo.assistant.HaloApp
|
||||
@ -114,7 +112,7 @@ object XapkInstaller : XApkUnZipCallback, XApkUnZipOutputFactory {
|
||||
return
|
||||
}
|
||||
|
||||
if (checkPermission(downloadEntity, showUnzipToast)) {
|
||||
PermissionHelper.checkManageAllFilesOrStoragePermissionBeforeAction(context) {
|
||||
DownloadManager.getInstance().getDownloadEntitySnapshot(downloadEntity.url, downloadEntity.gameId)
|
||||
?.let {
|
||||
unzipXapkFile(it)
|
||||
@ -129,23 +127,6 @@ object XapkInstaller : XApkUnZipCallback, XApkUnZipOutputFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkPermission(downloadEntity: DownloadEntity, showUnzipToast: Boolean = false): Boolean {
|
||||
// 安卓11以上系统需要开启所有文件访问权限
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
|
||||
&& !Environment.isExternalStorageManager()) {
|
||||
CurrentActivityHolder.getCurrentActivity()?.let {
|
||||
ManagerAllFilesPermissionDialogFragment.show(it as AppCompatActivity) {
|
||||
unzipXapkFile(downloadEntity)
|
||||
if (showUnzipToast) {
|
||||
Utils.toast(mContext, "解压过程请勿退出光环助手!")
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun unzipXapkFile(downloadEntity: DownloadEntity) {
|
||||
mXApkUnZipper.unzip(
|
||||
XApkUnZipEntry(
|
||||
|
||||
@ -10,8 +10,8 @@ import com.gh.gamecenter.common.exposure.meta.MetaUtil
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil.getMeta
|
||||
import com.gh.gamecenter.common.loghub.LoghubUtils
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.utils.SentryHelper
|
||||
import com.gh.ndownload.NDataChanger
|
||||
import com.gh.ndownload.NDownloadBridge
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DownloadConfig
|
||||
import com.lightgame.download.DownloadEntity
|
||||
@ -124,6 +124,7 @@ object DownloadDataHelper {
|
||||
val payloadObject = JSONObject()
|
||||
payloadObject.put("host", downloadEntity.meta[DownloadEntity.DOWNLOAD_HOST_KEY] ?: "unknown")
|
||||
payloadObject.put("path", downloadEntity.meta[DownloadEntity.DOWNLOAD_PATH_KEY] ?: "unknown")
|
||||
payloadObject.put("redirected_host_list", downloadEntity.meta[NDownloadBridge.REDIRECTED_HOST_LIST] ?: "unknown")
|
||||
payloadObject.put("game_id", downloadEntity.gameId)
|
||||
payloadObject.put("gameName", downloadEntity.name)
|
||||
payloadObject.put("platform", downloadEntity.platform)
|
||||
@ -212,6 +213,7 @@ object DownloadDataHelper {
|
||||
|
||||
payloadObject.put("host", downloadEntity.meta[DownloadEntity.DOWNLOAD_HOST_KEY] ?: "unknown")
|
||||
payloadObject.put("path", downloadEntity.meta[DownloadEntity.DOWNLOAD_PATH_KEY] ?: "unknown")
|
||||
payloadObject.put("redirected_host_list", downloadEntity.meta[NDownloadBridge.REDIRECTED_HOST_LIST] ?: "unknown")
|
||||
payloadObject.put("game_id", downloadEntity.gameId)
|
||||
payloadObject.put("gameName", downloadEntity.name)
|
||||
payloadObject.put("platform", downloadEntity.platform)
|
||||
@ -251,6 +253,7 @@ object DownloadDataHelper {
|
||||
|
||||
payloadObject.put("host", downloadEntity.meta[DownloadEntity.DOWNLOAD_HOST_KEY] ?: "unknown")
|
||||
payloadObject.put("path", downloadEntity.meta[DownloadEntity.DOWNLOAD_PATH_KEY] ?: "unknown")
|
||||
payloadObject.put("redirected_host_list", downloadEntity.meta[NDownloadBridge.REDIRECTED_HOST_LIST] ?: "unknown")
|
||||
payloadObject.put("game_id", downloadEntity.gameId)
|
||||
payloadObject.put("gameName", downloadEntity.name)
|
||||
payloadObject.put("platform", downloadEntity.platform)
|
||||
@ -315,6 +318,7 @@ object DownloadDataHelper {
|
||||
|
||||
payloadObject.put("host", downloadEntity.meta[DownloadEntity.DOWNLOAD_HOST_KEY] ?: "unknown")
|
||||
payloadObject.put("path", downloadEntity.meta[DownloadEntity.DOWNLOAD_PATH_KEY] ?: "unknown")
|
||||
payloadObject.put("redirected_host_list", downloadEntity.meta[NDownloadBridge.REDIRECTED_HOST_LIST] ?: "unknown")
|
||||
payloadObject.put("game_id", downloadEntity.gameId)
|
||||
payloadObject.put("gameName", downloadEntity.name)
|
||||
payloadObject.put("platform", downloadEntity.platform)
|
||||
@ -357,6 +361,7 @@ object DownloadDataHelper {
|
||||
sheet = JSONObject()
|
||||
sheet.put("host", downloadEntity.meta[DownloadEntity.DOWNLOAD_HOST_KEY] ?: "unknown")
|
||||
sheet.put("path", downloadEntity.meta[DownloadEntity.DOWNLOAD_PATH_KEY] ?: "unknown")
|
||||
sheet.put("redirected_host_list", downloadEntity.meta[NDownloadBridge.REDIRECTED_HOST_LIST] ?: "unknown")
|
||||
sheet.put("game_id", downloadEntity.gameId)
|
||||
sheet.put("platform", downloadEntity.platform)
|
||||
sheet.put("package", downloadEntity.packageName)
|
||||
@ -376,6 +381,7 @@ object DownloadDataHelper {
|
||||
"path",
|
||||
downloadEntity.meta[DownloadEntity.DOWNLOAD_PATH_KEY] ?: "unknown"
|
||||
) // 初始化记录的 path 为空
|
||||
sheet.put("redirected_host_list", downloadEntity.meta[NDownloadBridge.REDIRECTED_HOST_LIST] ?: "unknown")
|
||||
sheet.put("total_size", downloadEntity.size / 1024 / 1024) // 初始化记录的 total_size 有可能为0
|
||||
sheet.put("progress_size", downloadEntity.progress / 1024 - progressSize)
|
||||
sheet.put("current_progress_size", downloadEntity.progress / 1024)
|
||||
|
||||
@ -20,9 +20,9 @@ import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge;
|
||||
import com.gh.gamecenter.core.AppExecutor;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.core.GHThreadFactory;
|
||||
import com.gh.gamecenter.feature.entity.TagStyleEntity;
|
||||
import com.gh.gamecenter.feature.entity.CustomPageTrackData;
|
||||
import com.gh.gamecenter.feature.entity.TagStyleEntity;
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent;
|
||||
import com.gh.common.exposure.ExposureUtils;
|
||||
import com.gh.common.history.HistoryHelper;
|
||||
@ -34,20 +34,13 @@ import com.gh.common.util.LunchType;
|
||||
import com.gh.common.util.PackageInstaller;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil;
|
||||
import com.gh.gamecenter.common.utils.DeviceUtils;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.utils.FileUtils;
|
||||
import com.gh.gamecenter.common.utils.NetworkUtils;
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge;
|
||||
import com.gh.gamecenter.core.AppExecutor;
|
||||
import com.gh.gamecenter.core.utils.AppDebugConfig;
|
||||
import com.gh.gamecenter.core.utils.GsonUtils;
|
||||
import com.gh.gamecenter.core.utils.PageSwitchDataHelper;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
import com.gh.gamecenter.core.utils.SentryHelper;
|
||||
import com.gh.gamecenter.download.DownloadedGameIdAndPackageNameDao;
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity;
|
||||
import com.gh.gamecenter.entity.HomePluggableFilterEntity;
|
||||
@ -55,7 +48,7 @@ import com.gh.gamecenter.eventbus.EBDownloadStatus;
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity;
|
||||
import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.feature.entity.PluginLocation;
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent;
|
||||
import com.gh.gamecenter.feature.utils.SentryHelper;
|
||||
import com.gh.gamecenter.login.user.UserManager;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository;
|
||||
@ -64,7 +57,6 @@ import com.gh.ndownload.NDownloadBridge;
|
||||
import com.gh.ndownload.NDownloadService;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.download.ConnectionUtils;
|
||||
import com.lightgame.download.DataWatcher;
|
||||
import com.lightgame.download.DownloadConfig;
|
||||
import com.lightgame.download.DownloadDao;
|
||||
@ -85,6 +77,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
public class DownloadManager implements DownloadStatusListener {
|
||||
@ -111,6 +105,9 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
|
||||
private final Set<String> mUpdateMarks;
|
||||
|
||||
private final ExecutorService packageExecutor
|
||||
= Executors.newSingleThreadExecutor(new GHThreadFactory("GH_DOWNLOAD_MANAGER_THREAD"));
|
||||
|
||||
@Override
|
||||
public void onTaskCancelled(DownloadEntity entity) {
|
||||
EBDownloadStatus status = new EBDownloadStatus("delete", entity.getName(),
|
||||
@ -179,9 +176,6 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
|
||||
mUpdateMarks = SPUtils.getStringSet(UPDATE_IS_READ_MARK);
|
||||
|
||||
// 只有下载模块需要这坨东西,因此移动到这里初始化
|
||||
ConnectionUtils.initHttpsUrlConnection(mContext);
|
||||
|
||||
updateDownloadMetaMap();
|
||||
|
||||
lastTimeMap = new ArrayMap<>();
|
||||
@ -304,7 +298,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
// 下载模拟器游戏配置文件,地址是 "模拟器游戏类型根目录/cheat/"
|
||||
if (!TextUtils.isEmpty(gameEntity.getSimulatorGameConfig())) {
|
||||
String configFilePath = SimulatorGameManager.getPathByType(gameEntity.getSimulatorType()) + "/cheat/" + apkEntity.getPackageName() + ".ini";
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
getInstance().packageExecutor.execute(() -> {
|
||||
FileUtils.downloadFile(gameEntity.getSimulatorGameConfig(), configFilePath);
|
||||
});
|
||||
}
|
||||
@ -661,7 +655,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
* @return 下载任务快照列表
|
||||
*/
|
||||
@NonNull
|
||||
private ArrayList<DownloadEntity> getAllDownloadEntitySnapshots() {
|
||||
public ArrayList<DownloadEntity> getAllDownloadEntitySnapshots() {
|
||||
return mDownloadDao.getAllSnapshots();
|
||||
}
|
||||
|
||||
@ -917,7 +911,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
DownloadEntity entry = mDownloadDao.getSnapshot(url);
|
||||
DownloadDataSimpleHelper.INSTANCE.removeDownloadSimpleEntity(url);
|
||||
if (entry != null) {
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
getInstance().packageExecutor.execute(() -> {
|
||||
NDownloadBridge.INSTANCE.cancel(url);
|
||||
|
||||
mDownloadDao.delete(url);
|
||||
@ -959,7 +953,6 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
|
||||
// 改任务队列的状态
|
||||
NDataChanger.INSTANCE.getDownloadingTaskUrlSet().remove(entry.getUrl());
|
||||
NDataChanger.INSTANCE.getDownloadEntries().remove(entry.getUrl());
|
||||
if (!cancelSilently) {
|
||||
NDataChanger.INSTANCE.notifyDataChanged(entry);
|
||||
onTaskCancelled(entry);
|
||||
@ -972,9 +965,9 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
* 暂停所有正在下载的任务
|
||||
*/
|
||||
public void pauseAll() {
|
||||
synchronized (NDataChanger.INSTANCE.getDownloadEntries()) {
|
||||
for (DownloadEntity entity : NDataChanger.INSTANCE.getDownloadEntries().values()) {
|
||||
pause(entity.getUrl());
|
||||
synchronized (NDataChanger.INSTANCE.getDownloadingTaskUrlSet()) {
|
||||
for (String url : NDataChanger.INSTANCE.getDownloadingTaskUrlSet()) {
|
||||
pause(url);
|
||||
}
|
||||
}
|
||||
Utils.log(DownloadManager.class.getSimpleName(), "pause all");
|
||||
@ -985,7 +978,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
*/
|
||||
public void pause(String url) {
|
||||
checkDownloadEntryRecordValidate(url);
|
||||
DownloadEntity entry = NDataChanger.INSTANCE.getDownloadEntries().get(url);
|
||||
DownloadEntity entry = getDownloadEntitySnapshot(url);
|
||||
if (entry != null) {
|
||||
startDownloadService(entry, DownloadStatus.pause);
|
||||
put(url, System.currentTimeMillis());
|
||||
@ -1215,7 +1208,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
* 标记下载已完成的任务为已读 (用于下载管理页入口的 toolbar 红点显示)
|
||||
*/
|
||||
public void markDownloadedTaskAsRead() {
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
getInstance().packageExecutor.execute(() -> {
|
||||
boolean markHasChanged = false;
|
||||
|
||||
List<DownloadEntity> all = getAllDownloadEntityExcludeSilentTask();
|
||||
@ -1255,7 +1248,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
* 更改下载中任务的已读状态(用于下载页及外部toolbar)
|
||||
*/
|
||||
private void markDownloadingTaskAsReadOrUnread(boolean isRead) {
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
getInstance().packageExecutor.execute(() -> {
|
||||
boolean markHasChanged = false;
|
||||
|
||||
List<DownloadEntity> all = getAllDownloadEntityExcludeSilentTask();
|
||||
@ -1286,7 +1279,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
* 标记可用更新为已读 (用于下载管理页入口的 toolbar 红点显示)
|
||||
*/
|
||||
public void markUpdatableTaskAsRead() {
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
getInstance().packageExecutor.execute(() -> {
|
||||
boolean markHasChanged = false;
|
||||
|
||||
ArrayList<GameUpdateEntity> updates = PackageRepository.INSTANCE.getGameUpdate();
|
||||
@ -1385,7 +1378,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
* 手动触发下载 LiveData 变更
|
||||
*/
|
||||
public void notifyDownloadLiveDataChanged() {
|
||||
AppExecutor.getIoExecutor().execute(() -> mDownloadEntityListLiveData.postValue(getAllDownloadEntity()));
|
||||
getInstance().packageExecutor.execute(() -> mDownloadEntityListLiveData.postValue(getAllDownloadEntity()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -14,12 +14,13 @@ import com.gh.gamecenter.common.retrofit.EmptyResponse
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.utils.NewFlatLogUtils
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.ThirdPartyPackageHelper
|
||||
import com.gh.gamecenter.core.utils.UrlFilterUtils
|
||||
import com.gh.gamecenter.entity.GameDigestEntity
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.utils.ConcernUtils
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
@ -55,7 +56,7 @@ object PackageObserver {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun onPackageChanged(busFour: EBPackage) {
|
||||
fun onPackageChanged(busFour: EBPackage, cachedGameEntity: GameEntity? = null) {
|
||||
val application = HaloApp.getInstance().application
|
||||
val packageName = busFour.packageName
|
||||
val versionName = busFour.versionName
|
||||
@ -99,7 +100,7 @@ object PackageObserver {
|
||||
if (EBPackage.TYPE_INSTALLED == busFour.type) {
|
||||
if (!busFour.isVGame) {
|
||||
// 非畅玩游戏才执行下面的代码
|
||||
mPackageViewModel.addInstalledGame(packageName)
|
||||
mPackageViewModel.addInstalledGame(packageName, cachedGameEntity)
|
||||
BrowserInstallHelper.onApkInstalled(mDownloadEntity?.path)
|
||||
}
|
||||
|
||||
@ -153,7 +154,7 @@ object PackageObserver {
|
||||
}
|
||||
}
|
||||
|
||||
runOnIoThread { postNewlyInstalledApp(gameId, packageName) }
|
||||
AppExecutor.logExecutor.execute { postNewlyInstalledApp(gameId, packageName) }
|
||||
}
|
||||
|
||||
if (EBPackage.TYPE_UNINSTALLED == busFour.type) {
|
||||
|
||||
@ -24,6 +24,7 @@ import com.gh.gamecenter.common.base.fragment.BaseDraggableDialogFragment
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.goneIf
|
||||
import com.gh.gamecenter.common.utils.observeNonNull
|
||||
import com.gh.gamecenter.common.utils.safelyGetInRelease
|
||||
import com.gh.gamecenter.common.utils.throwExceptionInDebug
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.utils.TimeElapsedHelper
|
||||
@ -181,7 +182,7 @@ class DownloadDialog : BaseDraggableDialogFragment() {
|
||||
AppExecutor.uiExecutor.executeWithDelay({
|
||||
recyclerView.adapter?.let {
|
||||
for (i in 0 until it.itemCount) {
|
||||
val apkEntity = itemList[i].normal ?: continue
|
||||
val apkEntity = itemList.safelyGetInRelease(i)?.normal ?: continue
|
||||
val apkCollection = apkEntity.apkCollection
|
||||
val platformName = platformList[0].name
|
||||
val packageName = platformList[0].packageName
|
||||
|
||||
@ -4,10 +4,12 @@ import android.content.Context
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.callback.OnViewClickListener
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.databinding.*
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
@ -100,7 +102,16 @@ class DownloadDialogAdapter(
|
||||
DirectUtils.directToQa(mContext, data.linkText, data.linkId)
|
||||
}
|
||||
"qa_collection" -> {
|
||||
DirectUtils.directToHelpAndFeedback(mContext, isPlugin = true)
|
||||
DirectUtils.directToQaCollection(mContext, data.linkText, data.linkId)
|
||||
}
|
||||
"qa_list" -> {
|
||||
DirectUtils.directToHelpAndFeedback(
|
||||
mContext, bundleOf(
|
||||
EntranceConsts.KEY_ENTRANCE to "选择下载加速版本-常见问题",
|
||||
EntranceConsts.KEY_GAME_ID to viewModel.gameEntity.id,
|
||||
EntranceConsts.KEY_GAME_NAME to viewModel.gameEntity.name
|
||||
)
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
//Utils.toast(mContext, "暂不支持类型:" + data.linkType)
|
||||
|
||||
@ -61,7 +61,7 @@ object BrowserInstallHelper {
|
||||
}
|
||||
|
||||
else -> {
|
||||
val allInstalledPackageList = PackageUtils.getAllPackageNameIncludeSystemApps(mContext)
|
||||
val allInstalledPackageList = PackageUtils.getAllPackageName(mContext)
|
||||
|
||||
if (allInstalledPackageList.isNotEmpty()) {
|
||||
mValidInstalledPackageList = allInstalledPackageList
|
||||
|
||||
@ -10,6 +10,9 @@ import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
import com.gh.gamecenter.entity.SubjectRecommendEntity
|
||||
import com.gh.gamecenter.game.GameFragment
|
||||
|
||||
/**
|
||||
* 板块
|
||||
*/
|
||||
class BlockActivity : DownloadToolbarActivity() {
|
||||
|
||||
companion object {
|
||||
|
||||
@ -14,6 +14,7 @@ import com.halo.assistant.fragment.ApkCleanerFragment;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/1/24.
|
||||
* 清理安装包
|
||||
*/
|
||||
@Route(path = RouteConsts.activity.cleanApkActivity)
|
||||
public class CleanApkActivity extends ToolBarActivity {
|
||||
|
||||
@ -16,6 +16,7 @@ import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by khy on 18/07/17.
|
||||
* 我的收藏
|
||||
*/
|
||||
public class CollectionActivity extends ToolBarActivity {
|
||||
@Override
|
||||
|
||||
@ -23,6 +23,9 @@ import java.lang.ref.SoftReference;
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* 裁剪图片
|
||||
*/
|
||||
public class CropImageActivity extends ToolBarActivity {
|
||||
|
||||
protected CropImageCustom mCropImageCustom;
|
||||
|
||||
@ -24,7 +24,7 @@ import com.halo.assistant.HaloApp
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/3/24.
|
||||
* 游戏详情适配器
|
||||
* 游戏详情页
|
||||
*/
|
||||
class GameDetailActivity : DownloadToolbarActivity() {
|
||||
|
||||
|
||||
@ -44,6 +44,7 @@ import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.entity.CommunityEntity
|
||||
import com.gh.gamecenter.common.entity.SensorsEvent
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.utils.ImageUtils.getIdealImageUrl
|
||||
@ -103,6 +104,7 @@ class ImageViewerActivity : BaseActivity(), OnPageChangeListener {
|
||||
private var mInitialPosition = 0
|
||||
private var mUseEnterAndExitAnimation = false
|
||||
private var mShowSaveBtn = false
|
||||
private var mSaveBtnText = ""
|
||||
private var mAnswerEntity: AnswerEntity? = null
|
||||
private var mIsFromImageContainerView = false
|
||||
|
||||
@ -126,6 +128,7 @@ class ImageViewerActivity : BaseActivity(), OnPageChangeListener {
|
||||
private var mTranslationY = 0f
|
||||
private var mTargetCenterX = 0f
|
||||
private var mTargetCenterY = 0f
|
||||
private var mSaveSensorsEvent: SensorsEvent? = null
|
||||
|
||||
override fun getLayoutId() = R.layout.activity_viewimage
|
||||
|
||||
@ -157,6 +160,8 @@ class ImageViewerActivity : BaseActivity(), OnPageChangeListener {
|
||||
mInitialPosition = it.getInt(EntranceConsts.KEY_CURRENT, 0)
|
||||
}
|
||||
mShowSaveBtn = it.getBoolean(KEY_SHOW_SAVE)
|
||||
mSaveBtnText = it.getString(KEY_SAVE_TEXT, "")
|
||||
mSaveSensorsEvent = it.getParcelable(KEY_SAVE_SENSORS_EVENT)
|
||||
mUseEnterAndExitAnimation = it.getBoolean(KEY_USE_ENTER_AND_EXIT_ANIMATION)
|
||||
mAnswerEntity = it.getParcelable(AnswerEntity::class.java.name)
|
||||
mOriginLeftList = it.getIntegerArrayList(KEY_LEFT)
|
||||
@ -172,6 +177,9 @@ class ImageViewerActivity : BaseActivity(), OnPageChangeListener {
|
||||
}
|
||||
|
||||
mSavePicBtn.visibleIf(mShowSaveBtn)
|
||||
if (mSaveBtnText.isNotEmpty()) {
|
||||
mBinding.btnSavePic.text = mSaveBtnText
|
||||
}
|
||||
mArticleDetailBtn.visibleIf(mAnswerEntity != null)
|
||||
mIndicatorMask.goneIf(mUrlList?.size == 1)
|
||||
mIndicatorTv.text = String.format("%d/%d", mInitialPosition + 1, mUrlList!!.size)
|
||||
@ -217,6 +225,7 @@ class ImageViewerActivity : BaseActivity(), OnPageChangeListener {
|
||||
}
|
||||
|
||||
mSavePicBtn.setOnClickListener {
|
||||
mSaveSensorsEvent?.let { SensorsBridge.trackEvent(it) }
|
||||
checkStoragePermissionBeforeAction {
|
||||
mBigImageView?.currentImageFile?.run {
|
||||
ImageUtils.saveImageToFile(this, mFinalUrl)
|
||||
@ -789,7 +798,7 @@ class ImageViewerActivity : BaseActivity(), OnPageChangeListener {
|
||||
} else {
|
||||
rawUrl
|
||||
}
|
||||
var compressedStandardImageUrl: String? = if (!mShowBase64Image && rawUrl.contains("ghzs")) {
|
||||
var compressedStandardImageUrl: String? = if (!mShowBase64Image && rawUrl.contains("ghzs") && !rawUrl.contains("x-oss-process")) {
|
||||
// 用 oss.jpeg 加上 limit 以后会出现双指放大的情况
|
||||
rawUrl + Config.getSettings()?.image?.oss?.gif
|
||||
} else {
|
||||
@ -935,8 +944,10 @@ class ImageViewerActivity : BaseActivity(), OnPageChangeListener {
|
||||
|
||||
private const val KEY_BASE64 = "base64"
|
||||
private const val KEY_SHOW_SAVE = "showSave"
|
||||
private const val KEY_SAVE_TEXT = "saveText"
|
||||
private const val KEY_USE_ENTER_AND_EXIT_ANIMATION = "use_enter_and_exit_animation"
|
||||
private const val KEY_IS_FROM_IMAGE_CONTAINER_VIEW = "is_from_image_container_view"
|
||||
private const val KEY_SAVE_SENSORS_EVENT = "save_sensors_event"
|
||||
|
||||
private const val KEY_LEFT = "left"
|
||||
private const val KEY_TOP = "top"
|
||||
@ -958,6 +969,27 @@ class ImageViewerActivity : BaseActivity(), OnPageChangeListener {
|
||||
return getIntent(context, list, position, null, entrance, false)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getSingleIntent(
|
||||
context: Context,
|
||||
url: String,
|
||||
isShowSaveBtn: Boolean,
|
||||
saveBtnText: String? = null,
|
||||
entrance: String? = null,
|
||||
saveSensorsEvent: SensorsEvent? = null
|
||||
): Intent {
|
||||
return getIntent(
|
||||
context,
|
||||
arrayListOf(url),
|
||||
0,
|
||||
null,
|
||||
entrance,
|
||||
isShowSaveBtn,
|
||||
saveBtnText = saveBtnText,
|
||||
saveSensorsEvent = saveSensorsEvent
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getIntent(
|
||||
context: Context,
|
||||
@ -994,7 +1026,9 @@ class ImageViewerActivity : BaseActivity(), OnPageChangeListener {
|
||||
entrance: String?,
|
||||
isShowSaveBtn: Boolean,
|
||||
answerEntity: AnswerEntity? = null,
|
||||
isFromICV: Boolean = false
|
||||
isFromICV: Boolean = false,
|
||||
saveBtnText: String? = null,
|
||||
saveSensorsEvent: SensorsEvent? = null
|
||||
): Intent {
|
||||
val intent = Intent(context, ImageViewerActivity::class.java)
|
||||
intent.putExtra(EntranceConsts.KEY_URL_LIST, list)
|
||||
@ -1003,6 +1037,8 @@ class ImageViewerActivity : BaseActivity(), OnPageChangeListener {
|
||||
intent.putExtra(AnswerEntity::class.java.name, answerEntity)
|
||||
intent.putExtra(EntranceConsts.KEY_ENTRANCE, entrance)
|
||||
intent.putExtra(KEY_IS_FROM_IMAGE_CONTAINER_VIEW, isFromICV)
|
||||
saveBtnText?.let { intent.putExtra(KEY_SAVE_TEXT, it) }
|
||||
saveSensorsEvent?.let { intent.putExtra(KEY_SAVE_SENSORS_EVENT, saveSensorsEvent) }
|
||||
|
||||
if (originalViewList != null) {
|
||||
val leftList = arrayListOf<Int>()
|
||||
|
||||
@ -16,6 +16,7 @@ import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by khy on 2016/12/12.
|
||||
* 礼包中心
|
||||
*/
|
||||
@Deprecated
|
||||
public class LibaoActivity extends ToolBarActivity {
|
||||
|
||||
@ -89,16 +89,15 @@ import com.gh.gamecenter.core.utils.DisplayUtils;
|
||||
import com.gh.gamecenter.core.utils.GsonUtils;
|
||||
import com.gh.gamecenter.core.utils.MtaHelper;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
import com.gh.gamecenter.core.utils.SentryHelper;
|
||||
import com.gh.gamecenter.core.utils.ToastUtils;
|
||||
import com.gh.gamecenter.core.utils.UrlFilterUtils;
|
||||
import com.gh.gamecenter.entity.StartupAdEntity;
|
||||
import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.feature.utils.PlatformUtils;
|
||||
import com.gh.gamecenter.feature.utils.SentryHelper;
|
||||
import com.gh.gamecenter.home.custom.model.CustomPageShareRepository;
|
||||
import com.gh.gamecenter.home.skip.PackageSkipActivity;
|
||||
import com.gh.gamecenter.login.user.UserManager;
|
||||
import com.gh.gamecenter.manager.DataCollectionManager;
|
||||
import com.gh.gamecenter.packagehelper.PackageViewModel;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.gh.gamecenter.room.AppDatabase;
|
||||
@ -136,6 +135,9 @@ import io.reactivex.SingleSource;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.HttpException;
|
||||
@ -281,13 +283,12 @@ public class MainActivity extends BaseActivity {
|
||||
Config.getGhzsSettings();
|
||||
} else if (Config.getVSettingEntity() == null) {
|
||||
Config.refreshVSettingEntity();
|
||||
} else if (Config.getVNewSettingEntity() == null) {
|
||||
Config.getNewSetting();
|
||||
}
|
||||
|
||||
// 耗时操作
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
// 上传数据
|
||||
DataCollectionManager.getInstance().upload();
|
||||
|
||||
// 初始化PlatformUtils
|
||||
PlatformUtils.getInstance(getApplicationContext());
|
||||
|
||||
@ -738,14 +739,11 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
ToastUtils.showToast("游戏启动中,请稍后~");
|
||||
handler.postDelayed(() -> {
|
||||
VHelper.postOnInitialized(() -> {
|
||||
if (VHelper.isInstalled(gamePackageName)) {
|
||||
VHelper.launch(this, gamePackageName, false, true);
|
||||
} else {
|
||||
ToastUtils.showToast("应用已被卸载!");
|
||||
}
|
||||
return null;
|
||||
});
|
||||
if(VHelper.isInnerInstalled(gamePackageName)) {
|
||||
launchGame(gamePackageName).invoke();
|
||||
} else {
|
||||
VHelper.postOnInitialized(launchGame(gamePackageName));
|
||||
}
|
||||
}, 500);
|
||||
break;
|
||||
case KEY_MARKET_DETAILS:
|
||||
@ -763,6 +761,19 @@ public class MainActivity extends BaseActivity {
|
||||
}, 500);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private Function0<Unit> launchGame(String gamePackageName) {
|
||||
return () -> {
|
||||
if (!VHelper.isInnerInstalled(gamePackageName) && !VHelper.isInstalled(gamePackageName)) {
|
||||
ToastUtils.showToast("应用已被卸载!");
|
||||
} else {
|
||||
VHelper.shortcutLaunch();
|
||||
VHelper.launch(this, gamePackageName, false, true);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用跳转
|
||||
*/
|
||||
@ -880,13 +891,6 @@ public class MainActivity extends BaseActivity {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
// 上传数据
|
||||
DataCollectionManager.getInstance().statClickData();
|
||||
super.finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NotNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
@ -930,9 +934,11 @@ public class MainActivity extends BaseActivity {
|
||||
Config.getGhzsSettings();
|
||||
} else if (Config.getVSettingEntity() == null) {
|
||||
Config.refreshVSettingEntity();
|
||||
} else if (Config.getVNewSettingEntity() == null) {
|
||||
Config.getNewSetting();
|
||||
}
|
||||
|
||||
mPackageViewModel.checkData();
|
||||
// mPackageViewModel.checkData();
|
||||
deleteSimulatorGame();
|
||||
}
|
||||
}
|
||||
@ -940,8 +946,10 @@ public class MainActivity extends BaseActivity {
|
||||
// 接收登录和登出更新事件统计的 Meta
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEventMainThread(EBReuse reuse) {
|
||||
if (reuse.getType().equals(LOGIN_TAG) || reuse.getType().equals(LOGOUT_TAG)) {
|
||||
boolean isLoginEvent = reuse.getType().equals(LOGIN_TAG);
|
||||
if (isLoginEvent || reuse.getType().equals(LOGOUT_TAG)) {
|
||||
MetaUtil.INSTANCE.refreshMeta();
|
||||
VHelper.INSTANCE.updateAuthorizeInfo(isLoginEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@ import com.gh.gamecenter.common.base.GlobalActivityManager
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.db.ISearchHistoryDao
|
||||
import com.gh.gamecenter.db.SearchHistoryDao
|
||||
import com.gh.gamecenter.eventbus.EBSearch
|
||||
import com.gh.gamecenter.search.SearchDefaultFragment
|
||||
@ -29,6 +30,9 @@ import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* 游戏搜索页
|
||||
*/
|
||||
open class SearchActivity : BaseActivity() {
|
||||
|
||||
lateinit var searchEt: EditText
|
||||
@ -36,7 +40,7 @@ open class SearchActivity : BaseActivity() {
|
||||
lateinit var backBtn: RelativeLayout
|
||||
private lateinit var deleteIv: ImageView
|
||||
|
||||
private var mDao: SearchHistoryDao? = null
|
||||
protected val mDao: ISearchHistoryDao by lazy { provideDao() }
|
||||
|
||||
protected var mSearchKey: String? = null
|
||||
protected var mIsAutoSearchDisabled: Boolean = false
|
||||
@ -75,7 +79,6 @@ open class SearchActivity : BaseActivity() {
|
||||
val searchImmediately = intent.getBooleanExtra(KEY_SEARCH_IMMEDIATELY, false)
|
||||
var ignoreTextChanges = savedInstanceState != null
|
||||
|
||||
mDao = SearchHistoryDao(this)
|
||||
mPublishSubject = PublishSubject.create()
|
||||
|
||||
mPublishSubject!!
|
||||
@ -99,7 +102,7 @@ open class SearchActivity : BaseActivity() {
|
||||
searchEt.hint = hint
|
||||
if (searchImmediately) {
|
||||
mDisplayType = GAME_DETAIL
|
||||
mDao?.add(hint)
|
||||
mDao.add(hint)
|
||||
search(SearchType.DEFAULT, hint)
|
||||
}
|
||||
} else {
|
||||
@ -187,12 +190,12 @@ open class SearchActivity : BaseActivity() {
|
||||
mIsAutoSearchDisabled = false
|
||||
}
|
||||
|
||||
private fun handleAutoSearch(key: String?) {
|
||||
protected open fun handleAutoSearch(key: String?) {
|
||||
val newSearchKey = searchEt.text.toString().trim { it <= ' ' }
|
||||
if (newSearchKey.isEmpty()) {
|
||||
val hint = searchEt.hint.toString()
|
||||
if (!TextUtils.isEmpty(hint) && HINT_TEXT != hint) {
|
||||
mDao?.add(hint)
|
||||
mDao.add(hint)
|
||||
search(SearchType.DEFAULT, hint)
|
||||
}
|
||||
} else {
|
||||
@ -210,7 +213,7 @@ open class SearchActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleDefaultSearch(key: String?) {
|
||||
protected open fun handleDefaultSearch(key: String?) {
|
||||
mSearchKey = key
|
||||
searchEt.setText(key)
|
||||
searchEt.setSelection(searchEt.text.length)
|
||||
@ -227,14 +230,14 @@ open class SearchActivity : BaseActivity() {
|
||||
// MtaHelper.onEvent("游戏搜索", "默认搜索", key)
|
||||
}
|
||||
|
||||
private fun handleHotSearch(key: String?) {
|
||||
protected open fun handleHotSearch(key: String?) {
|
||||
mSearchKey = key
|
||||
searchEt.setText(key)
|
||||
searchEt.setSelection(searchEt.text.length)
|
||||
updateDisplayType(GAME_DETAIL)
|
||||
}
|
||||
|
||||
private fun handleHistorySearch(key: String?) {
|
||||
protected open fun handleHistorySearch(key: String?) {
|
||||
mSearchKey = key
|
||||
searchEt.setText(key)
|
||||
searchEt.setSelection(searchEt.text.length)
|
||||
@ -251,12 +254,12 @@ open class SearchActivity : BaseActivity() {
|
||||
// MtaHelper.onEvent("游戏搜索", "历史搜索", key)
|
||||
}
|
||||
|
||||
private fun handleManualSearch() {
|
||||
protected open fun handleManualSearch() {
|
||||
val newSearchKey = searchEt.text.toString().trim { it <= ' ' }
|
||||
if (newSearchKey.isEmpty()) {
|
||||
val hint = searchEt.hint.toString()
|
||||
if (!TextUtils.isEmpty(hint) && HINT_TEXT != hint) {
|
||||
mDao?.add(hint)
|
||||
mDao.add(hint)
|
||||
search(SearchType.DEFAULT, hint)
|
||||
}
|
||||
} else if (newSearchKey != mSearchKey || mDisplayType != GAME_DETAIL) {
|
||||
@ -270,7 +273,7 @@ open class SearchActivity : BaseActivity() {
|
||||
mSourceEntrance
|
||||
)
|
||||
|
||||
mDao?.add(mSearchKey)
|
||||
mDao.add(mSearchKey)
|
||||
updateDisplayType(GAME_DETAIL)
|
||||
} else {
|
||||
toast("请输入搜索内容")
|
||||
@ -280,6 +283,8 @@ open class SearchActivity : BaseActivity() {
|
||||
// MtaHelper.onEvent("游戏搜索", "主动搜索", newSearchKey)
|
||||
}
|
||||
|
||||
protected open fun provideDao(): ISearchHistoryDao = SearchHistoryDao(this)
|
||||
|
||||
open fun updateDisplayType(type: DisplayType) {
|
||||
val transaction = supportFragmentManager.beginTransaction()
|
||||
when (type) {
|
||||
|
||||
@ -48,6 +48,7 @@ import io.reactivex.functions.Consumer;
|
||||
|
||||
/**
|
||||
* Created by khy on 2016/11/7.
|
||||
* 分享卡片
|
||||
*/
|
||||
public class ShareCardPicActivity extends ToolBarActivity {
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@ import com.tencent.tauth.Tencent;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/2/6.
|
||||
* 分享光环
|
||||
*/
|
||||
public class ShareGhActivity extends ToolBarActivity {
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package com.gh.gamecenter;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.ENTRANCE_BROWSER;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.ENTRANCE_PUSH;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_ANSWER;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_ARCHIVE_LOGIN;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_ARTICLE;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_CATEGORY;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_COLUMN;
|
||||
@ -21,6 +22,7 @@ import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_QQ_GAME;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_QQ_GROUP;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_QQ_QUN;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_QUESTION;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_RESTART_GAME;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_SUGGESTION;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_TOOLBOX;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_UPLOAD_VIDEO;
|
||||
@ -55,17 +57,22 @@ import com.gh.common.util.CheckLoginUtils;
|
||||
import com.gh.common.util.DirectUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts;
|
||||
import com.gh.gamecenter.common.entity.CommunityEntity;
|
||||
import com.gh.gamecenter.common.entity.LinkEntity;
|
||||
import com.gh.gamecenter.common.entity.SimpleGameEntity;
|
||||
import com.gh.gamecenter.core.utils.GsonUtils;
|
||||
import com.gh.gamecenter.core.utils.ToastUtils;
|
||||
import com.gh.gamecenter.entity.SubjectData;
|
||||
import com.gh.gamecenter.entity.SubjectRecommendEntity;
|
||||
import com.gh.gamecenter.entity.VideoLinkEntity;
|
||||
import com.gh.gamecenter.feature.utils.PlatformUtils;
|
||||
import com.gh.gamecenter.login.view.LoginActivity;
|
||||
import com.gh.gamecenter.feature.minigame.MiniGameItemHelper;
|
||||
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel;
|
||||
import com.gh.gamecenter.video.videomanager.VideoManagerActivity;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.gh.vspace.shortcut.OnCreateShortcutResult;
|
||||
import com.gh.vspace.shortcut.ShortcutManager;
|
||||
import com.gh.vspace.shortcut.ShortcutPermissionTipsDialog;
|
||||
@ -113,6 +120,7 @@ public class SkipActivity extends BaseActivity {
|
||||
String platform = uri.getQueryParameter(KEY_PLATFORM);
|
||||
String platformName = PlatformUtils.getInstance(this).getPlatformName(platform);
|
||||
String gameId = uri.getQueryParameter(EntranceConsts.KEY_GAMEID);
|
||||
String gameName = uri.getQueryParameter(KEY_GAME_NAME);
|
||||
String packageMd5 = uri.getQueryParameter(EntranceConsts.KEY_PACKAGE_MD5);
|
||||
String isQaFeedbackString = uri.getQueryParameter(EntranceConsts.KEY_IS_QA_FEEDBACK);
|
||||
String suggestionType = uri.getQueryParameter(KEY_TYPE);
|
||||
@ -152,7 +160,7 @@ public class SkipActivity extends BaseActivity {
|
||||
DirectUtils.directToGameDetail(this, path, "", entrance, "true".equals(uri.getQueryParameter("auto_download")), to, null);
|
||||
break;
|
||||
case HOST_COLUMN:
|
||||
DirectUtils.directToSubject(this, path, uri.getQueryParameter(KEY_NAME), entrance, null, false);
|
||||
DirectUtils.directToSubject(this, path, uri.getQueryParameter(KEY_NAME), entrance, null, SubjectData.SubjectType.NORMAL);
|
||||
break;
|
||||
case HOST_SUGGESTION:
|
||||
if (!TextUtils.isEmpty(qaId)) {
|
||||
@ -214,7 +222,7 @@ public class SkipActivity extends BaseActivity {
|
||||
String categoryId = uri.getQueryParameter("category_id");
|
||||
String link = uri.getQueryParameter("link");
|
||||
gameId = uri.getQueryParameter("gameId");
|
||||
String gameName = uri.getQueryParameter("gameName");
|
||||
gameName = uri.getQueryParameter("gameName");
|
||||
String tagActivityId = uri.getQueryParameter("tagActivityId");
|
||||
String tagActivityName = uri.getQueryParameter("tagActivityName");
|
||||
VideoLinkEntity linkEntity = new VideoLinkEntity(title, categoryId, link, tagActivityId, tagActivityName);
|
||||
@ -385,9 +393,9 @@ public class SkipActivity extends BaseActivity {
|
||||
break;
|
||||
case EntranceConsts.HOST_HELP_AND_FEEDBACK:
|
||||
if ("vgame".equals(suggestionType)) {
|
||||
DirectUtils.directToHelpAndFeedback(this, content, isQaFeedback, qaContentId, false, true, entrance);
|
||||
DirectUtils.directToHelpAndFeedback(this, content, isQaFeedback, qaContentId, false, true, gameId, gameName, "畅玩游戏悬浮窗");
|
||||
} else {
|
||||
DirectUtils.directToHelpAndFeedback(this, content, isQaFeedback, qaContentId, true, false, entrance);
|
||||
DirectUtils.directToHelpAndFeedback(this, content, isQaFeedback, qaContentId, true, false, gameId, gameName, "插件端悬浮窗");
|
||||
}
|
||||
break;
|
||||
case HOST_GAME_COLLECTION_DETAIL:
|
||||
@ -401,10 +409,31 @@ public class SkipActivity extends BaseActivity {
|
||||
try {
|
||||
JSONObject extJsonObject = new JSONObject(extJson);
|
||||
String qqGameId = extJsonObject.optString("aid");
|
||||
DirectUtils.directToQGameById(this, qqGameId);
|
||||
MiniGameItemHelper.INSTANCE.launchMiniGame(qqGameId, Constants.QQ_MINI_GAME);
|
||||
} catch (JSONException ignored) {
|
||||
}
|
||||
break;
|
||||
case HOST_ARCHIVE_LOGIN:
|
||||
String gamePkg = uri.getQueryParameter(EntranceConsts.KEY_GAME_PKG);
|
||||
if(CheckLoginUtils.isLogin()) {
|
||||
VHelper.INSTANCE.updateAuthorizeInfo(true);
|
||||
} else {
|
||||
Bundle newBundle = new Bundle();
|
||||
newBundle.putString(EntranceConsts.KEY_TO, LoginActivity.class.getName());
|
||||
EntranceUtils.jumpActivity(this, null, newBundle, (resultCode, data) -> {
|
||||
if(CheckLoginUtils.isLogin()) {
|
||||
VHelper.INSTANCE.updateAuthorizeInfo(true);
|
||||
}
|
||||
VHelper.launch(this, gamePkg, false, false);
|
||||
finish();
|
||||
});
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case HOST_RESTART_GAME:
|
||||
String restartGamePkg = uri.getQueryParameter(EntranceConsts.KEY_GAME_PKG);
|
||||
VHelper.launch(this, restartGamePkg, false, true);
|
||||
break;
|
||||
default:
|
||||
EntranceUtils.jumpActivity(this, new Bundle()); // 跳转至首页
|
||||
return;
|
||||
|
||||
@ -115,6 +115,7 @@ class SplashScreenActivity : BaseActivity() {
|
||||
)
|
||||
}
|
||||
} else {
|
||||
PackageHelper.checkIfGetInstalledApiSwitchShouldBeIgnored(this)
|
||||
cancelPreviousUpdateTask()
|
||||
launchMainActivity()
|
||||
}
|
||||
@ -167,10 +168,12 @@ class SplashScreenActivity : BaseActivity() {
|
||||
if (isMalfunctioningHonorDevice) {
|
||||
showHonorNotification()
|
||||
mBaseHandler.postDelayed({
|
||||
requestGetInstallListPermissionAndLaunchMainActivity()
|
||||
launchMainActivity()
|
||||
// requestGetInstallListPermissionAndLaunchMainActivity()
|
||||
}, 100L)
|
||||
} else {
|
||||
requestGetInstallListPermissionAndLaunchMainActivity()
|
||||
launchMainActivity()
|
||||
// requestGetInstallListPermissionAndLaunchMainActivity()
|
||||
}
|
||||
} else {
|
||||
DialogUtils.showPrivacyPolicyDisallowDialog(this) {
|
||||
@ -196,17 +199,17 @@ class SplashScreenActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
// 尝试获取安装应用列表权限并启动首页(不在乎结果)
|
||||
private fun requestGetInstallListPermissionAndLaunchMainActivity() {
|
||||
if (PackageHelper.isSupportGetInstalledAppsPermission(this)
|
||||
&& PermissionHelper.isGetInstalledListPermissionDisabled(this)
|
||||
) {
|
||||
PermissionHelper.requestGetInstalledAppsListPermission(this, true) {
|
||||
launchMainActivity()
|
||||
}
|
||||
} else {
|
||||
launchMainActivity()
|
||||
}
|
||||
}
|
||||
// private fun requestGetInstallListPermissionAndLaunchMainActivity() {
|
||||
// if (PackageHelper.isSupportGetInstalledAppsPermission(this)
|
||||
// && PermissionHelper.isGetInstalledListPermissionDisabled(this)
|
||||
// ) {
|
||||
// PermissionHelper.requestGetInstalledAppsListPermission(this, true) {
|
||||
// launchMainActivity()
|
||||
// }
|
||||
// } else {
|
||||
// launchMainActivity()
|
||||
// }
|
||||
// }
|
||||
|
||||
// 删除更新后的光环助手包
|
||||
private fun cancelPreviousUpdateTask() {
|
||||
|
||||
@ -7,6 +7,9 @@ import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
import com.halo.assistant.fragment.user.UserInfoFragment
|
||||
|
||||
/**
|
||||
* 编辑资料
|
||||
*/
|
||||
class UserInfoActivity : ToolBarActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@ -8,6 +8,9 @@ import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.login.user.UserViewModel
|
||||
import com.halo.assistant.fragment.user.UserInfoEditFragment
|
||||
|
||||
/**
|
||||
* 修改个人信息
|
||||
*/
|
||||
class UserInfoEditActivity : ToolBarActivity() {
|
||||
companion object {
|
||||
fun getIntent(context: Context, editType: String): Intent {
|
||||
|
||||
@ -8,6 +8,7 @@ import com.halo.assistant.fragment.user.SelectRegionFragment;
|
||||
|
||||
/**
|
||||
* Created by khy on 25/09/17.
|
||||
* 选择地区
|
||||
*/
|
||||
public class UserRegionActivity extends ToolBarActivity {
|
||||
|
||||
|
||||
@ -99,7 +99,7 @@ public class WeiBoShareActivity extends Activity implements WbShareCallback {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAppProvider != null) {
|
||||
mAppProvider.setSkippingThirdParty(true);
|
||||
mAppProvider.setDisableSplashAdTemporarily(true);
|
||||
}
|
||||
Bundle extras = getIntent().getExtras();
|
||||
|
||||
@ -365,7 +365,7 @@ public class WeiBoShareActivity extends Activity implements WbShareCallback {
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mAppProvider != null) {
|
||||
mAppProvider.setSkippingThirdParty(false);
|
||||
mAppProvider.setDisableSplashAdTemporarily(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@ import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -123,7 +122,7 @@ public class CleanApkAdapter extends BaseRecyclerAdapter<KcSelectGameViewHolder>
|
||||
appInfo.sourceDir = apk_path;
|
||||
appInfo.publicSourceDir = apk_path;
|
||||
Drawable apk_icon = appInfo.loadIcon(pm);
|
||||
Bitmap originalBitmap = BitmapUtils.drawableToBitmap(apk_icon, true);
|
||||
Bitmap originalBitmap = BitmapUtils.drawableIconToBitmapIconWithDownsampling(apk_icon, true);
|
||||
apkEntity.setGameBm(BitmapUtils.compressBitmap(originalBitmap, 100));
|
||||
/** apk的绝对路劲 */
|
||||
apkEntity.setGamePath(apk_path);
|
||||
@ -189,14 +188,11 @@ public class CleanApkAdapter extends BaseRecyclerAdapter<KcSelectGameViewHolder>
|
||||
}
|
||||
|
||||
private int doType(String packageName) {
|
||||
List<PackageInfo> pakageinfos = PackageHelper.INSTANCE.getInstalledPackages(mContext, 0);
|
||||
for (PackageInfo pi : pakageinfos) {
|
||||
if ((pi.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
String pi_packageName = pi.packageName;
|
||||
//如果这个包名在系统已经安装过的应用中存在
|
||||
if (packageName.endsWith(pi_packageName)) {
|
||||
return INSTALLED;
|
||||
}
|
||||
List<String> pakageNameList = PackageHelper.INSTANCE.getInstalledPackageNameList(mContext, 0);
|
||||
for (String pkgName : pakageNameList) {
|
||||
//如果这个包名在系统已经安装过的应用中存在
|
||||
if (packageName.endsWith(pkgName)) {
|
||||
return INSTALLED;
|
||||
}
|
||||
}
|
||||
return UNINSTALLED;
|
||||
|
||||
@ -27,7 +27,7 @@ class CommunicationService : Service() {
|
||||
override fun installGameCompleted(packageName: String, params: VGameInstallerResult) {
|
||||
Utils.log(VHelper.LOG_TAG, "包名 $packageName 安装的结果是 ${params.status}")
|
||||
|
||||
VHelper.onInstallFinished(packageName, params)
|
||||
VHelper.onInstallFinished(packageName, params.status)
|
||||
}
|
||||
|
||||
override fun connectionCompleted() {
|
||||
|
||||
@ -45,7 +45,7 @@ import kotlin.math.abs
|
||||
|
||||
class AmwayFragment : LazyListFragment<AmwayListItemData, AmwayViewModel>() {
|
||||
|
||||
private lateinit var mViewModel: AmwayViewModel
|
||||
private val mViewModel: AmwayViewModel by lazy { viewModelProvider() }
|
||||
private val mElapsedHelper by lazy { TimeElapsedHelper() }
|
||||
private lateinit var mExposureListener: ExposureListener
|
||||
|
||||
@ -131,14 +131,13 @@ class AmwayFragment : LazyListFragment<AmwayListItemData, AmwayViewModel>() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun provideListViewModel(): AmwayViewModel {
|
||||
mViewModel = viewModelProvider()
|
||||
return mViewModel
|
||||
}
|
||||
|
||||
override fun getItemDecoration() = VerticalItemDecoration(context, 12F, false)
|
||||
.apply { mItemDecoration = this }
|
||||
|
||||
override fun provideListViewModel(): AmwayViewModel? {
|
||||
return mViewModel
|
||||
}
|
||||
|
||||
override fun provideListAdapter(): ListAdapter<*> {
|
||||
if (mAdapter == null) {
|
||||
val basicExposureSource = arrayListOf<ExposureSource>().apply {
|
||||
|
||||
@ -9,12 +9,12 @@ import com.gh.gamecenter.DisplayType
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.SearchActivity
|
||||
import com.gh.gamecenter.SearchType
|
||||
import com.gh.gamecenter.db.ISearchHistoryDao
|
||||
import com.gh.gamecenter.search.SearchDefaultFragment
|
||||
|
||||
class AmwaySearchActivity : SearchActivity() {
|
||||
|
||||
private lateinit var mViewModel: AmwaySearchViewModel
|
||||
private val mSearchHistoryDao by lazy { AmwaySearchDao() }
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -22,38 +22,43 @@ class AmwaySearchActivity : SearchActivity() {
|
||||
mViewModel = viewModelProvider()
|
||||
}
|
||||
|
||||
override fun provideDao(): ISearchHistoryDao = AmwaySearchDao()
|
||||
|
||||
override fun handleAutoSearch(key: String?) {
|
||||
mSearchKey = key
|
||||
updateDisplayType(DisplayType.GAME_DIGEST)
|
||||
mViewModel.getSearchResult(mSearchKey!!)
|
||||
}
|
||||
|
||||
override fun handleHistorySearch(key: String?) {
|
||||
mSearchKey = key
|
||||
searchEt.setText(key)
|
||||
searchEt.setSelection(searchEt.text.length)
|
||||
mViewModel.getSearchResult(mSearchKey!!)
|
||||
updateDisplayType(DisplayType.GAME_DETAIL)
|
||||
}
|
||||
|
||||
private fun handleOtherSearch() {
|
||||
val newSearchKey = searchEt.text.toString().trim { it <= ' ' }
|
||||
if (newSearchKey != mSearchKey || mDisplayType != DisplayType.GAME_DETAIL) {
|
||||
mSearchKey = newSearchKey
|
||||
if (!TextUtils.isEmpty(mSearchKey)) {
|
||||
mViewModel.getSearchResult(mSearchKey!!)
|
||||
mDao.add(mSearchKey!!)
|
||||
updateDisplayType(DisplayType.GAME_DETAIL)
|
||||
} else {
|
||||
toast("请先输入游戏名再搜索~")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun search(type: SearchType, key: String?) {
|
||||
mSearchType = type
|
||||
mIsAutoSearchDisabled = true
|
||||
|
||||
when (type) {
|
||||
SearchType.AUTO -> {
|
||||
mSearchKey = key
|
||||
updateDisplayType(DisplayType.GAME_DIGEST)
|
||||
mViewModel.getSearchResult(mSearchKey!!)
|
||||
}
|
||||
|
||||
SearchType.HISTORY -> {
|
||||
mSearchKey = key
|
||||
searchEt.setText(key)
|
||||
searchEt.setSelection(searchEt.text.length)
|
||||
mViewModel.getSearchResult(mSearchKey!!)
|
||||
updateDisplayType(DisplayType.GAME_DETAIL)
|
||||
}
|
||||
|
||||
else -> {
|
||||
val newSearchKey = searchEt.text.toString().trim { it <= ' ' }
|
||||
if (newSearchKey != mSearchKey || mDisplayType != DisplayType.GAME_DETAIL) {
|
||||
mSearchKey = newSearchKey
|
||||
if (!TextUtils.isEmpty(mSearchKey)) {
|
||||
mViewModel.getSearchResult(mSearchKey!!)
|
||||
mSearchHistoryDao.add(mSearchKey!!)
|
||||
updateDisplayType(DisplayType.GAME_DETAIL)
|
||||
} else {
|
||||
toast("请先输入游戏名再搜索~")
|
||||
}
|
||||
}
|
||||
}
|
||||
SearchType.AUTO -> handleAutoSearch(key)
|
||||
SearchType.HISTORY -> handleHistorySearch(key)
|
||||
else -> handleOtherSearch()
|
||||
}
|
||||
mIsAutoSearchDisabled = false
|
||||
}
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
package com.gh.gamecenter.amway.search
|
||||
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.db.ISearchHistoryDao
|
||||
|
||||
class AmwaySearchDao {
|
||||
fun add(keyword: String) {
|
||||
class AmwaySearchDao : ISearchHistoryDao {
|
||||
|
||||
override fun add(keyword: String) {
|
||||
val originString = SPUtils.getString(SP_KEY)
|
||||
|
||||
if (originString.isEmpty()) {
|
||||
@ -28,16 +30,18 @@ class AmwaySearchDao {
|
||||
}
|
||||
}
|
||||
|
||||
fun getAll(): ArrayList<String>? {
|
||||
override fun getAll(): ArrayList<String>? {
|
||||
val list = SPUtils.getString(SP_KEY).split(SEARCH_KEY_DIVIDER)
|
||||
|
||||
return if (list.size == 1 && list[0].isEmpty()) null else ArrayList(list)
|
||||
}
|
||||
|
||||
fun deleteAll() {
|
||||
override fun deleteAll() {
|
||||
SPUtils.setString(SP_KEY, "")
|
||||
}
|
||||
|
||||
override fun delete(item: String) {}
|
||||
|
||||
companion object {
|
||||
const val SP_KEY = "amway_key"
|
||||
const val SEARCH_KEY_DIVIDER = "<-||->"
|
||||
|
||||
@ -7,6 +7,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.databinding.FragmentAmwaySearchDefaultBinding
|
||||
import com.gh.gamecenter.db.ISearchHistoryDao
|
||||
import com.gh.gamecenter.eventbus.EBSearch
|
||||
import com.gh.gamecenter.search.SearchDefaultFragment
|
||||
import com.lightgame.utils.Util_System_Keyboard
|
||||
@ -14,7 +15,6 @@ import org.greenrobot.eventbus.EventBus
|
||||
|
||||
class AmwaySearchDefaultFragment : SearchDefaultFragment() {
|
||||
|
||||
private lateinit var mSearchDao: AmwaySearchDao
|
||||
private lateinit var mViewModel: AmwaySearchViewModel
|
||||
|
||||
private val mAmwayBinding by lazy { FragmentAmwaySearchDefaultBinding.inflate(layoutInflater) }
|
||||
@ -22,11 +22,15 @@ class AmwaySearchDefaultFragment : SearchDefaultFragment() {
|
||||
override fun getLayoutId() = 0
|
||||
override fun getInflatedLayout() = mAmwayBinding.root
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
mViewModel = viewModelProviderFromParent()
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
mViewModel = viewModelProviderFromParent()
|
||||
mViewModel.playedGames.observeNonNull(this) {
|
||||
mViewModel.playedGames.observeNonNull(viewLifecycleOwner) {
|
||||
defaultViewModel?.isExistHotSearch = it.isNotEmpty()
|
||||
updateView()
|
||||
mBinding.hotList.run {
|
||||
@ -38,28 +42,21 @@ class AmwaySearchDefaultFragment : SearchDefaultFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun initDao() {
|
||||
mSearchDao = AmwaySearchDao()
|
||||
mHistoryList = mSearchDao.getAll()
|
||||
}
|
||||
|
||||
override fun provideDao(): ISearchHistoryDao = AmwaySearchDao()
|
||||
override fun initView() {
|
||||
mBinding = mAmwayBinding.searchContent
|
||||
defaultViewModel?.isExistHistory = mHistoryList?.isNotEmpty() == true
|
||||
updateView()
|
||||
mBinding.hotHeadContainer.headTitle.text = "最近玩过"
|
||||
mBinding.historyFlexContainer.setLimitHeight(mFlexMaxHeight)
|
||||
createFlexContent(mBinding.historyFlex, mHistoryList, clickListener = {
|
||||
val key = mHistoryList!![it]
|
||||
mSearchDao.add(key)
|
||||
EventBus.getDefault().post(EBSearch("history", key))
|
||||
Util_System_Keyboard.hideSoftKeyboardByIBinder(context, mBinding.historyFlex.windowToken)
|
||||
})
|
||||
|
||||
initHistoryHeadView()
|
||||
updateHistorySearchView(null)
|
||||
defaultViewModel?.historySearchLiveData?.observe(this) {
|
||||
updateHistorySearchView(it)
|
||||
}
|
||||
|
||||
initHeadView()
|
||||
}
|
||||
|
||||
private fun initHistoryHeadView() {
|
||||
override fun initHeadView() {
|
||||
mBinding.historyHeadContainer.run {
|
||||
headTitle.text = getString(R.string.search_history)
|
||||
headTitle.textSize = 16F
|
||||
@ -73,17 +70,15 @@ class AmwaySearchDefaultFragment : SearchDefaultFragment() {
|
||||
)
|
||||
headActionTv.setOnClickListener {
|
||||
DialogHelper.showCenterWarningDialog(requireContext(), "清空记录", "确定清空历史搜索记录?", confirmClickCallback = {
|
||||
mSearchDao.deleteAll()
|
||||
defaultViewModel?.isExistHistory = false
|
||||
updateView()
|
||||
updateNoPlayedGameHint()
|
||||
defaultViewModel?.deleteAll()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateNoPlayedGameHint() {
|
||||
if (mSearchDao.getAll() != null && mSearchDao.getAll()?.size != 0) {
|
||||
val historyList = defaultViewModel?.historySearchLiveData?.value
|
||||
if (!historyList.isNullOrEmpty()) {
|
||||
mAmwayBinding.noDataContainer.visibility = View.GONE
|
||||
return
|
||||
}
|
||||
@ -95,4 +90,21 @@ class AmwaySearchDefaultFragment : SearchDefaultFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateHistorySearchView(historyList: List<String>?) {
|
||||
defaultViewModel?.isExistHistory = historyList?.isNotEmpty() == true
|
||||
updateView()
|
||||
updateNoPlayedGameHint()
|
||||
historyList?.let {
|
||||
createFlexContent(mBinding.historyFlex, historyList, clickListener = { id ->
|
||||
val key = it[id]
|
||||
defaultViewModel?.add(key)
|
||||
EventBus.getDefault().post(EBSearch("history", key))
|
||||
Util_System_Keyboard.hideSoftKeyboardByIBinder(
|
||||
context,
|
||||
mBinding.historyFlex.windowToken
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -10,12 +10,15 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.ImageUtils
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
import com.gh.gamecenter.common.utils.viewModelProvider
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.databinding.ActivityAuthorizationBinding
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.login.view.LoginActivity
|
||||
import com.gh.vspace.VHelper
|
||||
import com.lightgame.utils.Utils
|
||||
|
||||
/**
|
||||
* @author : liujiarui
|
||||
@ -86,6 +89,11 @@ class AuthorizationActivity : ToolBarActivity() {
|
||||
gameId = gameId,
|
||||
gameName = gameName
|
||||
)
|
||||
SensorsBridge.trackEvent(
|
||||
"LoginAuthorizationPageShow",
|
||||
"authority_object",
|
||||
if (mContent == TYPE_PLUGIN) "网游插件" else "其他"
|
||||
)
|
||||
}
|
||||
|
||||
private fun initData() {
|
||||
@ -154,6 +162,11 @@ class AuthorizationActivity : ToolBarActivity() {
|
||||
gameName = gameName,
|
||||
buttonType = BUTTON_TYPE_CONFIRM
|
||||
)
|
||||
SensorsBridge.trackEvent(
|
||||
"LoginAuthorizationClick",
|
||||
"authority_object",
|
||||
if (mContent == TYPE_PLUGIN) "网游插件" else "其他"
|
||||
)
|
||||
checkLogin {
|
||||
authorization()
|
||||
}
|
||||
@ -162,9 +175,12 @@ class AuthorizationActivity : ToolBarActivity() {
|
||||
|
||||
private fun checkLogin(block: () -> Unit) {
|
||||
//判断光环是否登陆
|
||||
CheckLoginUtils.checkLogin(this, "光环助手授权登陆") {
|
||||
if (CheckLoginUtils.isLogin()) {
|
||||
initData()
|
||||
block()
|
||||
} else {
|
||||
Utils.toast(this, "需要登录")
|
||||
startActivity(LoginActivity.getIntent(this, "光环助手授权登陆"))
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,10 +196,12 @@ class AuthorizationActivity : ToolBarActivity() {
|
||||
private fun authorization() {
|
||||
val remotePkgName = mRemotePkgName
|
||||
if (remotePkgName == null) {
|
||||
logAuthResult(false)
|
||||
finish()
|
||||
return
|
||||
}
|
||||
if (mToken.isEmpty()) {
|
||||
logAuthResult(false)
|
||||
toast("授权失败")
|
||||
return
|
||||
}
|
||||
@ -200,10 +218,21 @@ class AuthorizationActivity : ToolBarActivity() {
|
||||
intent.putExtra(EntranceConsts.KEY_USER_NAME, username)
|
||||
intent.putExtra(EntranceConsts.KEY_USER_AVATAR, userAvatar)
|
||||
sendBroadcast(intent)
|
||||
logAuthResult(true)
|
||||
backToLaunchApp()
|
||||
finish()
|
||||
}
|
||||
|
||||
private fun logAuthResult(isSuccess: Boolean) {
|
||||
SensorsBridge.trackEvent(
|
||||
"LoginAuthorizationResult",
|
||||
"authority_object",
|
||||
if (mContent == TYPE_PLUGIN) "网游插件" else "其他",
|
||||
"authorization_result",
|
||||
if (isSuccess) "成功" else "失败"
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转回授权app
|
||||
*/
|
||||
@ -234,6 +263,7 @@ class AuthorizationActivity : ToolBarActivity() {
|
||||
companion object {
|
||||
private const val BUTTON_TYPE_CONFIRM = "确定"
|
||||
private const val BUTTON_TYPE_BACK = "返回"
|
||||
private const val TYPE_PLUGIN = "plugin"
|
||||
}
|
||||
|
||||
}
|
||||
@ -8,6 +8,9 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
|
||||
/**
|
||||
* 新分类2.0
|
||||
*/
|
||||
class CategoryV2Activity : DownloadToolbarActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@ -5,6 +5,7 @@ import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.baselist.ListAdapter
|
||||
import com.gh.gamecenter.common.utils.formatTime
|
||||
import com.gh.gamecenter.common.utils.toBinding
|
||||
import com.gh.gamecenter.databinding.ItemArchiveLimitBinding
|
||||
import com.gh.gamecenter.entity.ArchiveEntity
|
||||
@ -29,10 +30,7 @@ class ArchiveLimitAdapter(context: Context) : ListAdapter<ArchiveLimitAdapter.Ar
|
||||
if (holder is ArchiveLimitViewHolder) {
|
||||
val item = mEntityList[position]
|
||||
holder.binding.tvTitle.text = item.data.name
|
||||
val timeLong = item.data.time.create
|
||||
val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA)
|
||||
val date = Date(timeLong)
|
||||
holder.binding.tvTime.text = sdf.format(date)
|
||||
holder.binding.tvTime.text = item.data.time.create.formatTime("yyyy-MM-dd HH:mm")
|
||||
|
||||
val resId = if (item.isChecked) R.drawable.ic_selector_selected else R.drawable.ic_selector_default
|
||||
holder.binding.ivSelector.setImageResource(resId)
|
||||
@ -53,10 +51,10 @@ class ArchiveLimitAdapter(context: Context) : ListAdapter<ArchiveLimitAdapter.Ar
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int, payloads: MutableList<Any?>) {
|
||||
if(holder is ArchiveLimitViewHolder){
|
||||
if(payloads.isEmpty()){
|
||||
if (holder is ArchiveLimitViewHolder) {
|
||||
if (payloads.isEmpty()) {
|
||||
onBindViewHolder(holder, position)
|
||||
}else{
|
||||
} else {
|
||||
val item = mEntityList[position]
|
||||
val resId = if (item.isChecked) R.drawable.ic_selector_selected else R.drawable.ic_selector_default
|
||||
holder.binding.ivSelector.setImageResource(resId)
|
||||
|
||||
@ -31,8 +31,11 @@ import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.view.DownloadButton
|
||||
import com.gh.gamecenter.livedata.EventObserver
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
import com.gh.gamecenter.va.VCore
|
||||
import com.gh.gamecenter.va.provider.IVa
|
||||
import com.gh.vspace.VArchiveHelper
|
||||
import com.gh.vspace.VHelper
|
||||
import com.gh.vspace.VHelper.is32
|
||||
import com.lightgame.download.DataWatcher
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.download.DownloadStatus
|
||||
@ -41,6 +44,9 @@ import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* 云存档管理
|
||||
*/
|
||||
class CloudArchiveManagerActivity : BaseActivity_TabLayout(), ArchiveLimitSelectedListener {
|
||||
|
||||
private lateinit var mBinding: ActivityCloudArchiveManagerBinding
|
||||
@ -59,6 +65,8 @@ class CloudArchiveManagerActivity : BaseActivity_TabLayout(), ArchiveLimitSelect
|
||||
)
|
||||
}
|
||||
|
||||
private val va: IVa by lazy { VCore.getInstance() }
|
||||
|
||||
private val dataWatcher = object : DataWatcher() {
|
||||
override fun onDataChanged(downloadEntity: DownloadEntity) {
|
||||
if (downloadEntity.gameId == mViewModel.gameId && mGameEntity?.getApk()?.size == 1) {
|
||||
@ -101,6 +109,10 @@ class CloudArchiveManagerActivity : BaseActivity_TabLayout(), ArchiveLimitSelect
|
||||
controlUploadGameArchive()
|
||||
uploadTv.setOnClickListener {
|
||||
when {
|
||||
mGameEntity.is32() && VHelper.isInnerInstalled(mGameEntity?.getUniquePackageName()) && !va.isExtPackageInstalled() -> {
|
||||
VHelper.newCwValidateVspaceBeforeAction(this@CloudArchiveManagerActivity, mGameEntity) {
|
||||
}
|
||||
}
|
||||
// 检查是否已安装游戏
|
||||
!VHelper.isInstalled(mGameEntity?.getUniquePackageName()) -> toast("暂未检测到本地的存档数据,请玩会儿游戏再试~")
|
||||
else -> {
|
||||
@ -109,7 +121,10 @@ class CloudArchiveManagerActivity : BaseActivity_TabLayout(), ArchiveLimitSelect
|
||||
if (!VHelper.checkArchiveExist(mGameEntity?.getUniquePackageName() ?: "", it)) {
|
||||
toast("暂未检测到本地的存档数据,请玩会儿游戏再试~")
|
||||
} else {
|
||||
NewFlatLogUtils.logCloudArchiveUploadDialogShow(mGameEntity?.id ?: "", mGameEntity?.name ?: "")
|
||||
NewFlatLogUtils.logCloudArchiveUploadDialogShow(
|
||||
mGameEntity?.id ?: "",
|
||||
mGameEntity?.name ?: ""
|
||||
)
|
||||
SensorsBridge.trackEvent(
|
||||
"CloudSaveUploadDialogShow",
|
||||
"game_id", mGameEntity?.id ?: "",
|
||||
|
||||
@ -1,120 +0,0 @@
|
||||
package com.gh.gamecenter.db;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.gh.gamecenter.db.info.DataCollectionInfo;
|
||||
import com.j256.ormlite.dao.Dao;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
// TODO 这个数据库其实没有用了,上传到 loghub 已经有相关的逻辑处理,有空删掉它
|
||||
public class DataCollectionDao {
|
||||
|
||||
private DatabaseHelper helper;
|
||||
private Dao<DataCollectionInfo, String> dao;
|
||||
|
||||
public DataCollectionDao(Context context) {
|
||||
try {
|
||||
helper = DatabaseHelper.getHelper(context);
|
||||
dao = helper.getDao(DataCollectionInfo.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找一个数据
|
||||
*/
|
||||
public List<DataCollectionInfo> findByType(String type) {
|
||||
try {
|
||||
return dao.queryForEq("type", type);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加一个数据
|
||||
*/
|
||||
public void add(DataCollectionInfo entity) {
|
||||
try {
|
||||
dao.create(entity);
|
||||
} catch (Exception e) {
|
||||
// java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase:
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一个数据
|
||||
*/
|
||||
public void delete(String id) {
|
||||
try {
|
||||
dao.deleteById(id);
|
||||
} catch (Exception e) {
|
||||
// java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase:
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一组数据
|
||||
*/
|
||||
public void delete(List<String> ids) {
|
||||
try {
|
||||
dao.deleteIds(ids);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id获取某一个数据
|
||||
*/
|
||||
public DataCollectionInfo find(String id) {
|
||||
try {
|
||||
return dao.queryForId(id);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有的数据
|
||||
*/
|
||||
public List<DataCollectionInfo> getAll() {
|
||||
try {
|
||||
return dao.queryForAll();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取点击数据
|
||||
*/
|
||||
public List<DataCollectionInfo> getClickData() {
|
||||
try {
|
||||
return dao.queryForEq("type", "click-item");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
*/
|
||||
public void update(DataCollectionInfo entity) {
|
||||
try {
|
||||
dao.update(entity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,9 +5,7 @@ import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
import androidx.collection.ArrayMap;
|
||||
|
||||
import com.gh.gamecenter.db.info.DataCollectionInfo;
|
||||
import com.gh.gamecenter.db.info.GameTrendsInfo;
|
||||
import com.gh.gamecenter.db.info.PackageInfo;
|
||||
import com.gh.gamecenter.db.info.SearchHistoryInfo;
|
||||
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
|
||||
import com.j256.ormlite.dao.Dao;
|
||||
@ -52,8 +50,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||
try {
|
||||
Utils.log("DatabaseHelper onCreate");
|
||||
TableUtils.createTable(connectionSource, SearchHistoryInfo.class);
|
||||
TableUtils.createTable(connectionSource, DataCollectionInfo.class);
|
||||
TableUtils.createTable(connectionSource, PackageInfo.class);
|
||||
TableUtils.createTable(connectionSource, GameTrendsInfo.class);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
@ -65,8 +61,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||
try {
|
||||
Utils.log("DatabaseHelper onUpgrade");
|
||||
TableUtils.dropTable(connectionSource, SearchHistoryInfo.class, true);
|
||||
TableUtils.dropTable(connectionSource, DataCollectionInfo.class, true);
|
||||
TableUtils.dropTable(connectionSource, PackageInfo.class, true);
|
||||
TableUtils.dropTable(connectionSource, GameTrendsInfo.class, true);
|
||||
onCreate(database, connectionSource);
|
||||
} catch (SQLException e) {
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
package com.gh.gamecenter.db;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ISearchHistoryDao {
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void add(String item);
|
||||
|
||||
void delete(String item);
|
||||
|
||||
List<String> getAll();
|
||||
}
|
||||
@ -11,7 +11,7 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class SearchHistoryDao {
|
||||
public class SearchHistoryDao implements ISearchHistoryDao {
|
||||
|
||||
private DatabaseHelper helper;
|
||||
private Dao<SearchHistoryInfo, String> dao;
|
||||
@ -25,6 +25,7 @@ public class SearchHistoryDao {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(String item) {
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
try {
|
||||
@ -35,6 +36,7 @@ public class SearchHistoryDao {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String item) {
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
try {
|
||||
@ -45,6 +47,7 @@ public class SearchHistoryDao {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll() {
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
CloseableIterator<SearchHistoryInfo> iterator = dao.iterator();
|
||||
@ -59,6 +62,7 @@ public class SearchHistoryDao {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAll() {
|
||||
List<String> history = new ArrayList<String>();
|
||||
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
package com.gh.gamecenter.db.info;
|
||||
|
||||
import com.j256.ormlite.field.DatabaseField;
|
||||
import com.j256.ormlite.table.DatabaseTable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@DatabaseTable(tableName = "tb_datacollection")
|
||||
public class DataCollectionInfo implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3196892351397147390L;
|
||||
|
||||
@DatabaseField(id = true, columnName = "id")
|
||||
private String id;
|
||||
|
||||
@DatabaseField(columnName = "type")
|
||||
private String type;
|
||||
|
||||
@DatabaseField(columnName = "data")
|
||||
private String data;
|
||||
|
||||
public DataCollectionInfo() {
|
||||
|
||||
}
|
||||
|
||||
public DataCollectionInfo(String id, String type, String data) {
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DataCollectionEntity [id=" + id + ", type=" + type + ", data="
|
||||
+ data + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,42 +0,0 @@
|
||||
package com.gh.gamecenter.db.info;
|
||||
|
||||
import com.j256.ormlite.field.DatabaseField;
|
||||
import com.j256.ormlite.table.DatabaseTable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@DatabaseTable(tableName = "tb_package")
|
||||
public class PackageInfo implements Serializable {
|
||||
|
||||
@DatabaseField(id = true, columnName = "packageName")
|
||||
private String packageName;
|
||||
|
||||
@DatabaseField(columnName = "time")
|
||||
private long time;
|
||||
|
||||
public PackageInfo() {
|
||||
|
||||
}
|
||||
|
||||
public PackageInfo(String packageName, long time) {
|
||||
this.packageName = packageName;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
}
|
||||
@ -6,12 +6,10 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.PagerSnapHelper
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.exposure.ExposureManager
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.common.util.DownloadItemUtils
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.gamecenter.GameDetailActivity
|
||||
import com.gh.gamecenter.adapter.viewholder.GameViewHolder
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
import com.gh.gamecenter.common.exposure.ExposureSource
|
||||
import com.gh.gamecenter.common.utils.safelyGetInRelease
|
||||
@ -21,6 +19,7 @@ import com.gh.gamecenter.entity.AdConfig
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.game.GameItemViewHolder
|
||||
import com.gh.gamecenter.feature.minigame.MiniGameItemHelper
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter
|
||||
import com.lightgame.download.DownloadEntity
|
||||
|
||||
@ -93,11 +92,8 @@ class AdGameBannerAdapter(
|
||||
it.id,
|
||||
it.name ?: ""
|
||||
)
|
||||
if (it.isQQMiniGame()) {
|
||||
GlobalActivityManager.currentActivity?.let { activity ->
|
||||
NewFlatLogUtils.logQGameClick(it.qqMiniGameAppId, it.name)
|
||||
DirectUtils.directToQGameById(activity, it.qqMiniGameAppId)
|
||||
}
|
||||
if (it.isMiniGame()) {
|
||||
MiniGameItemHelper.launchMiniGame(it.miniGameAppId, it.miniGameType)
|
||||
} else {
|
||||
GameDetailActivity.startGameDetailActivity(
|
||||
mContext,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user