Compare commits

..

10 Commits

Author SHA1 Message Date
04468c0627 build: suppress warning 2022-12-23 16:16:12 +08:00
e585d905ac fix: 处理一些细节问题 2022-11-08 17:56:55 +08:00
1f066e676f Merge branch 'feature-module_setting' into feature-module_setting_compose 2022-11-08 17:51:03 +08:00
a08f3aa9ac Merge branch 'dev-5.16.0' into feature-module_setting
# Conflicts:
#	app/src/main/res/values/strings.xml
2022-11-08 17:30:04 +08:00
f799096655 fix: 处理一些细节问题 2022-11-07 18:01:28 +08:00
431aa52e49 refactor:使用 Jetpack Compose 实现设置功能模块的 UI https://git.shanqu.cc/halo/android/assistant-android/-/issues/88 2022-11-04 11:36:25 +08:00
26d6e4086a fix: 处理合并分支后出现的冲突 2022-11-02 17:16:55 +08:00
7e999784b7 Merge branch 'feature-module_setting' into dev
# Conflicts:
#	app/build.gradle
#	app/src/main/java/com/gh/common/util/DownloadObserver.kt
#	app/src/main/java/com/gh/gamecenter/home/HomeFragmentAdapter.kt
#	app/src/main/java/com/gh/gamecenter/personal/HaloPersonalFragment.kt
#	app/src/main/java/com/gh/gamecenter/personal/PersonalFunctionAdapter.kt
#	module_core/src/main/java/com/gh/gamecenter/core/provider/IAppProvider.kt
#	module_setting/src/main/java/com/gh/gamecenter/setting/view/GameDownloadSettingActivity.kt
#	module_setting/src/main/java/com/gh/gamecenter/setting/view/GameDownloadSettingFragment.kt
#	module_setting/src/main/java/com/gh/gamecenter/setting/view/NetworkDiagnosisActivity.kt
#	module_setting/src/main/java/com/gh/gamecenter/setting/view/SettingsFragment.kt
#	module_setting/src/main/java/com/gh/gamecenter/setting/view/VideoSettingActivity.kt
#	module_setting/src/main/java/com/gh/gamecenter/setting/view/security/BindPhoneFragment.kt
#	module_setting/src/main/java/com/gh/gamecenter/setting/view/security/SecurityActivity.kt
#	module_setting/src/main/java/com/gh/gamecenter/setting/view/security/SecurityFragment.kt
2022-11-02 16:56:56 +08:00
f07bcc89e8 fix:修复无法跳转安装包清理的问题 2022-10-28 17:47:14 +08:00
22cff4ed72 refactor: 组件化设置功能 https://git.shanqu.cc/halo/android/assistant-android/-/issues/87 2022-10-18 11:57:27 +08:00
1901 changed files with 23712 additions and 53168 deletions

View File

@ -1,43 +1,43 @@
stages:
- analysis
- sendmail
- analysis
- sendmail
## 代码检查
sonarqube_analysis:
tags:
- offline-test
stage: analysis
image: sonarsource/sonar-scanner-cli:latest
dependencies: [] #禁止传递来的artifact
script:
## 获取项目的一级组和二级组和项目名作为projectKey例如projectKey=platform-backend-eci-monitor
- group=`echo $CI_PROJECT_PATH | sed 's#/#-#g'`
- sonar-scanner
-Dsonar.host.url=http://sonarqube-server.sonarqube:9000/
-Dsonar.login=be43de7264ce4c4766eb0c020373c3e74e6df257
-Dsonar.jacoco.reportPaths=target/jacoco.exec
-Dsonar.projectKey=$group
-Dsonar.projectName=$CI_PROJECT_PATH
-Dsonar.sourceEncoding=UTF-8
-Dsonar.exclusions=**/vendor/**,**/errcode/**
-Dsonar.gitlab.project_id=$CI_PROJECT_ID
-Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA
-Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME
-Dsonar.gitlab.ci_merge_request_iid=$CI_MERGE_REQUEST_IID
-Dsonar.gitlab.merge_request_discussion=true
-Dsonar.java.binaries=. # 如果不使用Maven或Gradle进行分析则必须手动提供测试二进制文件
only:
- dev
tags:
- offline-test
stage: analysis
image: sonarsource/sonar-scanner-cli:latest
dependencies: [] #禁止传递来的artifact
script:
## 获取项目的一级组和二级组和项目名作为projectKey例如projectKey=platform-backend-eci-monitor
- group=`echo $CI_PROJECT_PATH | sed 's#/#-#g'`
- sonar-scanner
-Dsonar.host.url=http://sonarqube-server.sonarqube:9000/
-Dsonar.login=be43de7264ce4c4766eb0c020373c3e74e6df257
-Dsonar.jacoco.reportPaths=target/jacoco.exec
-Dsonar.projectKey=$group
-Dsonar.projectName=$CI_PROJECT_PATH
-Dsonar.sourceEncoding=UTF-8
-Dsonar.exclusions=**/vendor/**,**/errcode/**
-Dsonar.gitlab.project_id=$CI_PROJECT_ID
-Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA
-Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME
-Dsonar.gitlab.ci_merge_request_iid=$CI_MERGE_REQUEST_IID
-Dsonar.gitlab.merge_request_discussion=true
-Dsonar.java.binaries=. # 如果不使用Maven或Gradle进行分析则必须手动提供测试二进制文件
only:
- dev
## 发送简易检测结果报告
send_sonar_report:
tags:
- offline-test
stage: sendmail
image: hub.shanqu.cc/library/docker:latest
dependencies: [] #禁止传递来的artifact
script:
- group=`echo $CI_PROJECT_PATH | sed 's#/#-#g'`
- docker run -e PROJECTKEY=$group -e EMAIL=$GITLAB_USER_EMAIL --name send-email --rm hub.shanqu.cc/platform/send-sonar-report:latest
only:
- dev
tags:
- offline-test
stage: sendmail
image: hub.shanqu.cc/library/docker:latest
dependencies: [] #禁止传递来的artifact
script:
- group=`echo $CI_PROJECT_PATH | sed 's#/#-#g'`
- docker run -e PROJECTKEY=$group -e EMAIL=$GITLAB_USER_EMAIL --name send-email --rm hub.shanqu.cc/platform/send-sonar-report:latest
only:
- dev

9
.gitmodules vendored
View File

@ -1,13 +1,10 @@
[submodule "libraries/LGLibrary"]
path = libraries/LGLibrary
url = ../../../android/common-library.git
url = git@git.shanqu.cc:android/common-library.git
branch = master
[submodule "vspace-bridge"]
path = vspace-bridge
url = ../../../cwzs/android/vspace-bridge.git
url = git@git.shanqu.cc:cwzs/android/vspace-bridge.git
[submodule "module_common/src/debug/assets/assistant-android-mock"]
path = module_common/src/debug/assets/assistant-android-mock
url = ../../../halo/android/assistant-android-mock.git
[submodule "ndownload"]
path = ndownload
url = ../../../android/ndownload.git
url = git@git.shanqu.cc:halo/android/assistant-android-mock.git

View File

@ -1,15 +0,0 @@
FROM openjdk:11-jdk
WORKDIR /project
SHELL ["/bin/bash", "-c"]
#配置SDK环境变量
ENV ANDROID_SDK_ROOT /usr/lib/sdk
ENV ANDROID_HOME /usr/lib/sdk
ENV PATH $ANDROID_SDK_ROOT:$PATH
ENV PATH=$PATH:${ANDROID_HOME}/cmdline-tools/cmdline-tools/bin/
ENV GRADLE_USER_HOME /project/.gradle
RUN source ~/.bashrc
RUN sed -i "s@http://\(deb\|security\).debian.org@https://mirrors.aliyun.com@g" /etc/apt/sources.list \
&& apt-get --quiet update --yes \
&& apt-get --quiet install --yes lib32stdc++6 lib32z1 libncurses5 util-linux bash tzdata librdkafka-dev pkgconf \
&& rm -rf /var/lib/apt/lists/*
COPY .gradle /project/.gradle

View File

@ -9,9 +9,6 @@ import groovy.xml.XmlUtil
android {
String CONFIG_ID = ""
String FIRST_LAUNCH = ""
buildFeatures {
viewBinding true
dataBinding true
@ -70,13 +67,9 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt', 'proguard-fresco.txt'
// 推广用的配置 id
buildConfigField "String", "CONFIG_ID", "\"${CONFIG_ID}\""
// 首次启动的跳转配置
buildConfigField "String", "FIRST_LAUNCH", "\"${FIRST_LAUNCH}\""
// All third-party appid/appkey
/**
* All third-party appid/appkey
*/
buildConfigField "String", "API_HOST", "\"${API_HOST}\""
buildConfigField "String", "NEW_API_HOST", "\"${NEW_API_HOST}\""
buildConfigField "String", "VAPI_HOST", "\"${VAPI_HOST}\""
@ -134,7 +127,7 @@ android {
variantFilter { variant ->
def names = variant.flavors*.name
def isDebugType = variant.buildType.name == "debug"
if ((names.contains("tea") || name.contains("kuaishou") || name.contains("gdt")) && isDebugType) {
if ((names.contains("tea")) && isDebugType) {
setIgnore(true)
}
}
@ -151,12 +144,6 @@ android {
tea {
java.srcDirs = ['src/main/java', 'src/tea/java']
}
kuaishou {
java.srcDirs = ['src/main/java', 'src/kuaishou/java']
}
gdt {
java.srcDirs = ['src/main/java', 'src/gdt/java']
}
}
productFlavors {
@ -194,26 +181,6 @@ android {
manifestPlaceholders.put("APPLOG_SCHEME", "rangersapplog.byAx6uYt".toLowerCase())
}
kuaishou {
dimension "env"
buildConfigField "String", "DEV_API_HOST", "\"${API_HOST}\""
buildConfigField "String", "NEW_DEV_API_HOST", "\"${NEW_API_HOST}\""
buildConfigField "String", "DEV_VAPI_HOST", "\"${VAPI_HOST}\""
buildConfigField "String", "QUICK_LOGIN_APPID", "\"${QUICK_LOGIN_APPID}\""
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
}
gdt {
dimension "env"
buildConfigField "String", "DEV_API_HOST", "\"${API_HOST}\""
buildConfigField "String", "NEW_DEV_API_HOST", "\"${NEW_API_HOST}\""
buildConfigField "String", "DEV_VAPI_HOST", "\"${VAPI_HOST}\""
buildConfigField "String", "QUICK_LOGIN_APPID", "\"${QUICK_LOGIN_APPID}\""
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
}
}
}
@ -228,8 +195,6 @@ dependencies {
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
teaImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/tea/libs')
kuaishouImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/kuaishou/libs')
gdtImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/gdt/libs')
testImplementation 'junit:junit:4.12'
debugImplementation "com.squareup.leakcanary:leakcanary-android:${leakcanary}"
@ -237,7 +202,8 @@ dependencies {
// debugImplementation "com.gu.android:toolargetool:${toolargetool}" // 需要使用调试时才启用
debugImplementation "com.github.nichbar:WhatTheStack:${whatTheStack}"
// debugImplementation "io.github.didi.dokit:dokitx:${dokit}"
debugImplementation "io.github.didi.dokit:dokitx:${dokit}"
implementation "androidx.multidex:multidex:${multiDex}"
implementation "androidx.fragment:fragment-ktx:${fragment}"
@ -277,7 +243,6 @@ dependencies {
implementation "com.llew.huawei:verifier:${verifier}"
teaImplementation "com.bytedance.applog:RangersAppLog-Lite-cn:${bytedanceApplog}"
teaImplementation "com.bytedance.applog:RangersAppLog-All-convert:${bytedanceApplog}"
implementation "net.lingala.zip4j:zip4j:${zip4j}"
@ -292,12 +257,9 @@ dependencies {
implementation "com.lg:gid:${gid}"
implementation "com.lg:shortcut:${shortcut}"
compileOnly "com.github.axen1314.lancet:lancet-base:${lancet_version}"
kapt "com.alibaba:arouter-compiler:$arouterVersion"
implementation project(':ndownload')
implementation project(':vspace-bridge:vspace')
implementation (project(':module_common')) {
@ -306,26 +268,14 @@ dependencies {
implementation(project(':module_login')) {
exclude group: 'androidx.swiperefreshlayout'
}
implementation(project(':module_setting')) {
implementation(project(':module_setting_compose')) {
exclude group: 'androidx.swiperefreshlayout'
}
// implementation(project(':module_setting_compose')) {
// 默认不接入光能模块,提高编译速度
// debugImplementation(project(':module_energy')) {
// exclude group: 'androidx.swiperefreshlayout'
// }
implementation(project(':module_core_feature')) {
exclude group: 'androidx.swiperefreshlayout'
}
implementation(project(':module_feedback')) {
exclude group: 'androidx.swiperefreshlayout'
}
implementation(project(':module_sensors_data')) {
exclude group: 'androidx.swiperefreshlayout'
}
// implementation(project(':module_vpn'))
implementation(project(':module_pkg'))
implementation(project(':feature:floating-window'))
}
File propFile = file('sign.properties')
if (propFile.exists()) {
Properties props = new Properties()
@ -465,12 +415,7 @@ andResGuard {
"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"
"R.drawable.suggest_pic_delete"
]
compressFilePattern = [
"*.png",
@ -479,7 +424,7 @@ andResGuard {
"*.gif",
]
sevenzip {
artifact = 'io.github.leon406:SevenZip:1.2.22.5'
artifact = 'com.tencent.mm:SevenZip:1.2.20'
}
}

View File

@ -17,31 +17,15 @@
-dontwarn com.j256.**
### app models
-keep class com.gh.common.view.* {*;}
-keep class com.gh.gamecenter.db.info.* {*;}
-keep class com.gh.gamecenter.entity.** {<fields>;}
-keep class com.gh.gamecenter.qa.entity.** {<fields>;}
-keep class com.gh.gamecenter.floatingwindow.FloatingWindowEntity {<fields>;}
-keep class com.gh.gamecenter.BR
-keep class com.gh.gamecenter.entity.* {*;}
-keep class com.gh.gamecenter.qa.entity.* {*;}
-keep class com.gh.gamecenter.retrofit.* {*;}
-keep class com.gh.gamecenter.eventbus.* {*;}
-keep class com.gh.gamecenter.home.gamecollection.GameCollectionStackLayout {*;}
-keep class com.gh.gamecenter.home.gamecollection.GameCollectionStackAnimation {*;}
-keep class com.gh.gamecenter.video.detail.* {*;}
-keep class com.gh.gamecenter.home.gamecollection.* {*;}
# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}
# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * extends com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
# Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher.
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken
# TODO What's this ?
-ignorewarnings
@ -55,7 +39,7 @@
-dontwarn com.shuyu.gsyvideoplayer.utils.**
-keep class tv.danmaku.ijk.* { *; }
-dontwarn tv.danmaku.ijk.**
-keep public class * extends android.view.View {
-keep public class * extends android.view.View{
*** get*();
void set*(***);
public <init>(android.content.Context);
@ -63,16 +47,6 @@
public <init>(android.content.Context, android.util.AttributeSet, int);
}
### RecyclerView.jumpToPositionForSmoothScroller
-keep class androidx.recyclerview.widget.RecyclerView {
void jumpToPositionForSmoothScroller(int);
}
### ViewBinding 反射相关
-keep class * implements androidx.viewbinding.ViewBinding {
public static *** inflate(android.view.LayoutInflater, android.view.ViewGroup, boolean);
}
### TEA
-keep class com.gh.gamecenter.TeaHelper { *; }
@ -82,12 +56,13 @@
### dokit
-keep class com.didichuxing.** {*;}
### 广点通SDK
-dontwarn com.qq.gdt.action.**
-keep class com.qq.gdt.action.** {*;}
-keep public class com.tencent.turingfd.sdk.**
-keepclasseswithmembers class * {
native <methods>;
# Flutter模块
-keep class com.gh.common.util.DirectUtils {
public static void directToQa(...);
public static void directToQaCollection(...);
public static void directToGift(...);
public static void directToConcernInfo(...);
public static void directToFeedback(...);
public static void directToSuggestion(...);
}

View File

@ -1,16 +1,14 @@
package com.gh.gamecenter.provider
import android.app.Activity
import android.app.Application
import android.text.TextUtils
import com.gh.gamecenter.common.constant.Config
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.utils.PackageFlavorHelper
import com.gh.gamecenter.core.provider.IFlavorProvider
import com.gh.gamecenter.core.utils.SPUtils
import com.leon.channel.helper.ChannelReaderUtil
class FlavorProviderImp : IFlavorProvider {
class ChannelProviderImp : ChannelProvider {
override fun getChannelStr(application: Application): String {
var channel = ChannelReaderUtil.getChannel(application)
if (channel == null || TextUtils.isEmpty(channel.trim())) {
@ -25,12 +23,4 @@ class FlavorProviderImp : IFlavorProvider {
}
return channel
}
override fun init(application: Application, activity: Activity) {
// do nothing
}
override fun logEvent(content: String) {
// do nothing
}
}

View File

@ -1,37 +0,0 @@
package com.gh.gamecenter
import android.app.Application
import com.lightgame.utils.Utils
import com.qq.gdt.action.ActionParam
import com.qq.gdt.action.ActionType
import com.qq.gdt.action.GDTAction
import org.json.JSONObject
object GdtHelper {
private const val USER_ACTION_SET_ID = "1201041887"
private const val APP_SECRET_ID = "c29cc5c48cf540c43b4b97363bb09216"
private const val KS_USER_ACTION_SET_ID = "1201032128"
private const val KS_APP_SECRET_ID = "9bdbbb81d4e0bd333a2a581f9ee36986"
@JvmStatic
fun init(application: Application, channel: String) {
if (channel == "KS_GDT_GHZS_MC01") {
GDTAction.init(application, KS_USER_ACTION_SET_ID, KS_APP_SECRET_ID, channel)
} else {
GDTAction.init(application, USER_ACTION_SET_ID, APP_SECRET_ID, channel)
}
Utils.log("init GdtHelper")
}
@JvmStatic
fun logAction(type: String) {
when (type) {
"EVENT_ACTIVE" -> GDTAction.logAction(ActionType.START_APP)
"active_register" -> GDTAction.logAction(ActionType.REGISTER)
"EVENT_NEXTDAY_STAY" -> GDTAction.logAction(ActionType.START_APP, JSONObject().apply {
put(ActionParam.Key.LENGTH_OF_STAY, 1)
})
}
}
}

View File

@ -1,48 +0,0 @@
package com.gh.gamecenter.provider
import android.app.Activity
import android.app.Application
import android.text.TextUtils
import com.gh.gamecenter.GdtHelper
import com.gh.gamecenter.core.provider.IFlavorProvider
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.core.utils.TimeUtils
import com.halo.assistant.HaloApp
import com.leon.channel.helper.ChannelReaderUtil
class FlavorProviderImp : IFlavorProvider {
override fun init(application: Application, activity: Activity) {
GdtHelper.init(application, getChannelStr(application))
if (HaloApp.getInstance().isBrandNewInstall) {
logEvent("EVENT_ACTIVE")
SPUtils.setLong("TIME_OF_BRAND_NEW_INSTALL", System.currentTimeMillis() / 1000)
} else {
val shouldSendRetentionLogEvent =
SPUtils.getBoolean("SHOULD_SEND_RETENTION_EVENT", true)
val installTimeNotToday =
!TimeUtils.isToday(SPUtils.getLong("TIME_OF_BRAND_NEW_INSTALL", System.currentTimeMillis() / 1000))
if (shouldSendRetentionLogEvent && installTimeNotToday) {
logEvent("EVENT_NEXTDAY_STAY")
SPUtils.setBoolean("SHOULD_SEND_RETENTION_EVENT", false)
}
}
}
override fun getChannelStr(application: Application): String {
var channel = ChannelReaderUtil.getChannel(application)
if (channel == null || TextUtils.isEmpty(channel.trim())) {
channel = GDT_DEFAULT_CHANNEL
}
return channel
}
override fun logEvent(content: String) {
GdtHelper.logAction(content)
}
companion object {
private const val GDT_DEFAULT_CHANNEL = "GDT_GHZS_01"
}
}

View File

@ -1,30 +0,0 @@
package com.gh.gamecenter
import android.content.Context
import com.kwai.monitor.log.TurboAgent
import com.kwai.monitor.log.TurboConfig
object KuaishouHelper {
private const val APP_ID = "80655"
private const val APP_NAME = "guanghuanzhushou_1"
@JvmStatic
fun init(context: Context, channel: String) {
TurboAgent.init(
TurboConfig.TurboConfigBuilder.create(context)
.setAppId(APP_ID)
.setAppName(APP_NAME)
.setAppChannel(channel)
.build()
)
}
@JvmStatic
fun onEvent(type: String) {
when (type) {
"EVENT_ACTIVE" -> TurboAgent.onAppActive()
"active_register" -> TurboAgent.onRegister()
"EVENT_NEXTDAY_STAY" -> TurboAgent.onNextDayStay()
}
}
}

View File

@ -1,48 +0,0 @@
package com.gh.gamecenter.provider
import android.app.Activity
import android.app.Application
import android.text.TextUtils
import com.gh.gamecenter.KuaishouHelper
import com.gh.gamecenter.core.provider.IFlavorProvider
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.core.utils.TimeUtils
import com.halo.assistant.HaloApp
import com.leon.channel.helper.ChannelReaderUtil
class FlavorProviderImp : IFlavorProvider {
override fun init(application: Application, activity: Activity) {
KuaishouHelper.init(application, getChannelStr(application))
if (HaloApp.getInstance().isBrandNewInstall) {
logEvent("EVENT_ACTIVE")
SPUtils.setLong("TIME_OF_BRAND_NEW_INSTALL", System.currentTimeMillis() / 1000)
} else {
val shouldSendRetentionLogEvent =
SPUtils.getBoolean("SHOULD_SEND_RETENTION_EVENT", true)
val installTimeNotToday =
!TimeUtils.isToday(SPUtils.getLong("TIME_OF_BRAND_NEW_INSTALL", System.currentTimeMillis() / 1000))
if (shouldSendRetentionLogEvent && installTimeNotToday) {
logEvent("EVENT_NEXTDAY_STAY")
SPUtils.setBoolean("SHOULD_SEND_RETENTION_EVENT", false)
}
}
}
override fun getChannelStr(application: Application): String {
var channel = ChannelReaderUtil.getChannel(application)
if (channel == null || TextUtils.isEmpty(channel.trim())) {
channel = KUAISHOU_CHANNEL
}
return channel
}
override fun logEvent(content: String) {
KuaishouHelper.onEvent(content)
}
companion object {
private const val KUAISHOU_CHANNEL = "KS-GHZS-01"
}
}

View File

@ -6,11 +6,6 @@
<queries>
<package android:name="com.gh.gamecenter" />
</queries>
<queries>
<package android:name="com.lg.vspace" />
</queries>
<!-- 允许应用程序访问网络连接 -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- 允许应用程序写入外部存储如SD卡上写文件 -->
@ -76,7 +71,7 @@
androidx.compose.animation.core,
androidx.constraintlayout.compose,
androidx.compose.ui.test.manifest,
androidx.compose.ui.tooling.preview" />
androidx.compose.ui.tooling.preview"/>
<!-- 去掉 SDK 一些流氓权限 -->
<uses-permission
@ -119,8 +114,6 @@
android:name="io.sentry.breadcrumbs.system-events"
android:value="false" />
<service android:name = "com.gh.ndownload.NDownloadService" />
<activity
android:name="com.gh.gamecenter.SplashScreenActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
@ -137,15 +130,10 @@
<activity
android:name="com.gh.gamecenter.MainActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="@style/AppCompatTheme.APP"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
android:windowSoftInputMode="stateAlwaysHidden|adjustResize" />
<activity
android:name="com.gh.gamecenter.DownloadManagerActivity"
@ -261,6 +249,9 @@
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.SuggestionActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.VoteActivity"
android:screenOrientation="portrait"
@ -444,6 +435,10 @@
android:name="com.gh.gamecenter.qa.editor.LocalMediaActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.mygame.PlayedGameActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.servers.GameServersActivity"
android:screenOrientation="portrait" />
@ -460,6 +455,15 @@
android:name="com.halo.assistant.fragment.user.UserPortraitCropImageActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.HelpAndFeedbackActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name="com.gh.gamecenter.help.HelpDetailActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.qa.comment.CommentActivity"
android:theme="@style/Theme.Transparent"
@ -483,6 +487,10 @@
android:name="com.gh.gamecenter.gamedetail.fuli.kaifu.ServersCalendarActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.QaActivity"
android:screenOrientation="portrait" />
<activity
android:name=".qa.answer.draft.AnswerDraftActivity"
android:screenOrientation="portrait" />
@ -626,8 +634,8 @@
<!-- android:theme="@android:style/Theme.Translucent" />-->
<activity
android:name="com.gh.gamecenter.SkipActivity"
android:exported="true"
android:name="com.gh.gamecenter.SkipActivity"
android:theme="@style/Theme.AppCompat.Light.Fullscreen.Transparent">
<intent-filter>
<data android:scheme="ghzhushou" />
@ -646,19 +654,6 @@
</intent-filter>
</activity>
<!-- 光环助手授权登陆页面 -->
<activity
android:name=".authorization.AuthorizationActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait">
<intent-filter>
<data android:scheme="ghzhushou_authorization" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<activity
android:name="com.gh.gamecenter.teenagermode.TeenagerModeActivity"
android:screenOrientation="portrait" />
@ -734,23 +729,6 @@
android:name=".discovery.DiscoveryActivity"
android:screenOrientation="portrait" />
<activity
android:name=".cloudarchive.CloudArchiveManagerActivity"
android:screenOrientation="portrait" />
<activity
android:name=".savegame.GameArchiveListActivity"
android:screenOrientation="portrait" />
<activity
android:name=".discovery.interestedgame.InterestedGameActivity"
android:screenOrientation="portrait" />
<activity
android:name=".servers.gametest2.GameServerTestV2Activity"
android:screenOrientation="portrait" />
<!-- <activity-->
<!-- android:name="${applicationId}.douyinapi.DouYinEntryActivity"-->
<!-- android:launchMode="singleTask"-->
@ -773,26 +751,6 @@
android:enabled="true"
android:exported="true" />
<provider
android:name="com.gh.vspace.VFileProvider"
android:authorities="${applicationId}.virtual_file_provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
<service
android:name=".aidl.CommunicationService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.gh.gamecenter.aidl.CommunicationService" />
</intent-filter>
</service>
<!-- <provider-->
<!-- android:name="androidx.startup.InitializationProvider"-->
<!-- android:authorities="${applicationId}.androidx-startup"-->

Binary file not shown.

View File

@ -0,0 +1 @@
{"v":"5.5.9","fr":60,"ip":0,"op":90,"w":1080,"h":202,"nm":"click","ddd":0,"assets":[{"id":"comp_0","layers":[{"ddd":0,"ind":1,"ty":4,"nm":"椭圆形","sr":1,"ks":{"o":{"a":0,"k":20,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[204,1455,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[24,24],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"椭圆形","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":120,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"椭圆形","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":63,"s":[10]},{"t":70,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[204,1455,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":39,"s":[100,100,100]},{"t":49,"s":[110,110,100]}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[36,36],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"椭圆形","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":120,"st":0,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"圆环","refId":"comp_0","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.531],"y":[0]},"t":28,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":38,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.526],"y":[0]},"t":48,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.446],"y":[0]},"t":63,"s":[50]},{"t":82,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[125.951,79.658,0],"ix":2},"a":{"a":0,"k":[205.951,1458.658,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.601,0.601,0.333],"y":[0,0,0]},"t":28,"s":[50,50,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.528,0.528,0.333],"y":[0,0,0]},"t":38,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.526,0.526,0.333],"y":[0,0,0]},"t":48,"s":[120,120,100]},{"t":63,"s":[100,100,100]}],"ix":6}},"ao":0,"w":1080,"h":1920,"ip":0,"op":120,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"点击手","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.596],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":10,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.515],"y":[0]},"t":63,"s":[100]},{"t":83,"s":[0]}],"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.507],"y":[0]},"t":10,"s":[6]},{"t":30,"s":[2]}],"ix":10},"p":{"a":0,"k":[178.982,123.325,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.489,0.489,0.333],"y":[0,0,0]},"t":10,"s":[100,100,100]},{"t":30,"s":[90,90,100]}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-5.33,-8.3],[3.89,0.27],[-4.4,-1.68],[-4.33,-0.67],[-4.08,9.32],[3.33,5.44],[3.39,4.6],[0.87,-3.7],[3.6,-0.86],[1.03,-0.21],[2.34,-0.53],[0.96,1.15],[4.22,5.48],[-1.18,-4.56]],"o":[[1.11,1.71],[-3.89,-0.27],[6.42,2.5],[4.33,0.66],[1.63,-5.32],[-3.34,-5.45],[-1.68,-2.1],[-0.71,3.14],[-3.43,0.95],[-0.57,0.08],[-3.86,1.12],[-3.23,-3.94],[-1.89,-2.28],[2.42,4.64]],"v":[[-5.387,9.698],[-10.717,8.498],[-12.327,15.628],[5.813,21.748],[23.313,11.778],[20.273,-1.202],[11.563,-13.962],[5.393,-12.362],[1.083,-13.722],[-2.087,-9.742],[-5.707,-11.752],[-8.777,-7.572],[-18.297,-20.542],[-23.827,-17.832]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"路径备份 2","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":120,"st":0,"bm":0}],"markers":[]}

View File

@ -0,0 +1 @@
{"v":"5.6.4","fr":25,"ip":0,"op":35,"w":1080,"h":214,"nm":"点赞","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"椭圆形 2","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.588],"y":[0]},"t":17,"s":[15]},{"t":20,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[468.04,73.68,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.659,0.659,0.333],"y":[0,0,0]},"t":10,"s":[50,50,100]},{"t":19,"s":[150,150,100]}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[24,24],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"椭圆形","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":10,"op":1510,"st":10,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"椭圆形 3","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.588],"y":[0]},"t":27,"s":[15]},{"t":30,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[468.04,73.68,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.659,0.659,0.333],"y":[0,0,0]},"t":20,"s":[50,50,100]},{"t":28,"s":[140,140,100]}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[24,24],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"椭圆形","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":20,"op":1520,"st":20,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"路径备份 2","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.602],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":5,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.663],"y":[0]},"t":24,"s":[100]},{"t":29,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[531.02,129.675,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.514,0.514,0.333],"y":[0,0,0]},"t":5,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.533,0.533,0.333],"y":[0,0,0]},"t":10,"s":[90,90,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.586,0.586,0.333],"y":[0,0,0]},"t":15,"s":[95,95,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.499,0.499,0.333],"y":[0,0,0]},"t":19,"s":[90,90,100]},{"t":24,"s":[100,100,100]}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-5.33,-8.3],[3.89,0.27],[-4.4,-1.68],[-4.33,-0.67],[-4.08,9.32],[3.33,5.44],[3.39,4.6],[0.87,-3.7],[3.6,-0.86],[1.03,-0.21],[2.34,-0.53],[0.96,1.15],[4.22,5.48],[-1.18,-4.56]],"o":[[1.11,1.71],[-3.89,-0.27],[6.42,2.5],[4.33,0.66],[1.63,-5.32],[-3.34,-5.45],[-1.68,-2.1],[-0.71,3.14],[-3.43,0.95],[-0.57,0.08],[-3.86,1.12],[-3.23,-3.94],[-1.89,-2.28],[2.42,4.64]],"v":[[-5.387,9.698],[-10.717,8.498],[-12.327,15.628],[5.813,21.748],[23.313,11.778],[20.273,-1.202],[11.563,-13.962],[5.393,-12.362],[1.083,-13.722],[-2.087,-9.742],[-5.707,-11.752],[-8.777,-7.572],[-18.297,-20.542],[-23.827,-17.832]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"路径备份 2","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":1500,"st":0,"bm":0}],"markers":[]}

View File

@ -1 +0,0 @@
{"v":"5.9.1","fr":60,"ip":0,"op":100,"w":64,"h":64,"nm":"多版本下载提示_dark","ddd":0,"assets":[{"id":"comp_0","nm":"arrow 合成_dark","fr":60,"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"arrow","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.333],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":24,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.667],"y":[0]},"t":76,"s":[100]},{"t":100,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.333,"y":1},"o":{"x":0.364,"y":0},"t":0,"s":[28,-12,0],"to":[0,6.382,0],"ti":[0,-0.284,0]},{"i":{"x":0.667,"y":0.667},"o":{"x":0.333,"y":0.333},"t":24,"s":[28,28,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.667,"y":0},"t":76,"s":[28,28,0],"to":[0,6.667,0],"ti":[0,-6.667,0]},{"t":100,"s":[28,68,0]}],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[0,2],[0,-2]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-2,0],[0,2]],"c":false},"ix":2},"nm":"路径 2","mn":"ADBE Vector Shape - Group","hd":false},{"ind":2,"ty":"sh","ix":3,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[2,0],[0,2]],"c":false},"ix":2},"nm":"路径 3","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.333,0.333],"y":[1,1]},"o":{"x":[0.333,0.333],"y":[0,0]},"t":0,"s":[80,120]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":24,"s":[100,100]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":76,"s":[100,100]},{"t":100,"s":[80,120]}],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.156862750649,0.533333361149,0.878431379795,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"stroke","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[400,400],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"Vector 97","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":100,"st":0,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"arrow 合成_dark","refId":"comp_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[32,32,0],"ix":2,"l":2},"a":{"a":0,"k":[28,28,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"w":56,"h":56,"ip":0,"op":100,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"base","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[32,32,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[15,15],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.156862750649,0.533333361149,0.878431379795,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"stroke","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.137254908681,0.137254908681,0.137254908681,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"filling","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[400,400],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"Ellipse 44","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":100,"st":0,"bm":0}],"markers":[]}

View File

@ -1 +0,0 @@
{"v":"5.9.1","fr":60,"ip":0,"op":100,"w":64,"h":64,"nm":"多版本下载提示_light","ddd":0,"assets":[{"id":"comp_0","nm":"arrow 合成_light","fr":60,"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"arrow","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.333],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":24,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.667],"y":[0]},"t":76,"s":[100]},{"t":100,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.333,"y":1},"o":{"x":0.364,"y":0},"t":0,"s":[28,-12,0],"to":[0,6.382,0],"ti":[0,-0.284,0]},{"i":{"x":0.667,"y":0.667},"o":{"x":0.333,"y":0.333},"t":24,"s":[28,28,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.667,"y":0},"t":76,"s":[28,28,0],"to":[0,6.667,0],"ti":[0,-6.667,0]},{"t":100,"s":[28,68,0]}],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[0,2],[0,-2]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-2,0],[0,2]],"c":false},"ix":2},"nm":"路径 2","mn":"ADBE Vector Shape - Group","hd":false},{"ind":2,"ty":"sh","ix":3,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[2,0],[0,2]],"c":false},"ix":2},"nm":"路径 3","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.333,0.333],"y":[1,1]},"o":{"x":[0.333,0.333],"y":[0,0]},"t":0,"s":[80,120]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":24,"s":[100,100]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":76,"s":[100,100]},{"t":100,"s":[80,120]}],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.141176477075,0.588235318661,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"stroke","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[400,400],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"Vector 97","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":100,"st":0,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"arrow 合成_light","refId":"comp_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[32,32,0],"ix":2,"l":2},"a":{"a":0,"k":[28,28,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"w":56,"h":56,"ip":0,"op":100,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"base","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[32,32,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[15,15],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.141176477075,0.588235318661,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"stroke","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"filling","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[400,400],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"Ellipse 44","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":100,"st":0,"bm":0}],"markers":[]}

View File

@ -0,0 +1 @@
{"v":"5.5.9","fr":60,"ip":0,"op":120,"w":1080,"h":586,"nm":"上滑","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":2,"ty":4,"nm":"手","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.642],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":6,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.558],"y":[0]},"t":60,"s":[100]},{"t":71,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.479,"y":0},"t":3,"s":[611,475,0],"to":[0,-62.75,0],"ti":[0,62.75,0]},{"t":40,"s":[611,98.5,0]}],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[90,90,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-7.78,-12.06],[5.68,0.39],[-6.42,-2.45],[-6.32,-0.97],[-5.95,13.55],[4.87,7.91],[4.94,6.69],[1.26,-5.37],[5.25,-1.25],[1.5,-0.3],[3.4,-0.77],[1.4,1.68],[6.15,7.98],[-1.73,-6.64]],"o":[[1.62,2.49],[-5.68,-0.39],[9.37,3.63],[6.31,0.98],[2.39,-7.74],[-4.87,-7.92],[-2.45,-3.05],[-1.05,4.57],[-4.99,1.39],[-0.83,0.13],[-5.63,1.63],[-4.71,-5.72],[-2.75,-3.31],[3.52,6.76]],"v":[[-7.86,14.26],[-15.64,12.52],[-17.99,22.89],[8.47,31.78],[33.98,17.29],[29.55,-1.59],[16.85,-20.15],[7.86,-17.83],[1.56,-19.8],[-3.05,-14.02],[-8.33,-16.94],[-12.44,-11.045],[-26.761,-30.19],[-34.75,-25.78]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"路径","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":120,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"矩形","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.715],"y":[0]},"t":57,"s":[100]},{"t":67,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[525,228.5,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"hasMask":true,"masksProperties":[{"inv":false,"mode":"a","pt":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.491,"y":0},"t":3,"s":[{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[24.328,180.5],[-22,180.5],[-22,204.5],[24.328,204.5]],"c":true}]},{"t":40,"s":[{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[24.328,-207.5],[-22,-207.5],[-22,204.5],[24.328,204.5]],"c":true}]}],"ix":1},"o":{"a":0,"k":100,"ix":3},"x":{"a":0,"k":0,"ix":4},"nm":"蒙版 1"}],"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[6,137],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":2,"ix":4},"nm":"矩形路径 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"gf","o":{"a":0,"k":100,"ix":10},"r":1,"bm":0,"g":{"p":3,"k":{"a":0,"k":[0,1,1,1,0.5,1,1,1,1,1,1,1,0,1,0.5,0.5,1,0],"ix":9}},"s":{"a":0,"k":[0,-68.5],"ix":5},"e":{"a":0,"k":[0,68.5],"ix":6},"t":1,"nm":"Gradient Fill 1","mn":"ADBE Vector Graphic - G-Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"矩形","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":0,"k":0,"ix":1},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":33,"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":3,"op":123,"st":3,"bm":0}],"markers":[]}

View File

@ -6,7 +6,6 @@ import android.app.Activity
import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.text.TextUtils
import android.view.View
@ -26,10 +25,9 @@ import com.gh.gamecenter.core.AppExecutor
import com.gh.gamecenter.core.runOnIoThread
import com.gh.gamecenter.core.utils.*
import com.gh.gamecenter.entity.*
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.qa.editor.*
import com.gh.gamecenter.feature.entity.AnswerEntity
import com.gh.gamecenter.feature.entity.ArticleEntity
import com.gh.gamecenter.qa.entity.AnswerEntity
import com.gh.gamecenter.qa.entity.ArticleEntity
import com.gh.gamecenter.qa.entity.EditorInsertEntity
import com.gh.gamecenter.video.poster.PosterEditActivity
import com.gh.gamecenter.video.upload.UploadManager
@ -216,8 +214,6 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
mKeyboardHeightProvider = KeyboardHeightProvider(this)
mRichEditor.post { mKeyboardHeightProvider?.start() }
mRichEditor.enableForceDark(DarkModeUtils.isDarkModeOn(this))
mRichEditor.setEditorBackgroundColor(R.color.background_white.toColor(this))
mRichEditor.setEditorFontColor(if (mIsDarkModeOn) Color.parseColor("#C2C2C2") else Color.parseColor("#4A4A4A"))
// 防止个别手机在Js里无法获取粘贴内容
mRichEditor.addJavascriptInterface(OnPasteListener(), "onPasteListener")
mRichEditor.addJavascriptInterface(OnCursorChangeListener(), "OnCursorChangeListener")
@ -477,14 +473,14 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
private fun chooseImage() {
MtaHelper.onEvent(mtaEventName(), "插入图片", "插入图片")
val imageCount = mViewModel.quoteCountEntity.imageCount
if (imageCount >= MAX_IMAGE_COUNT) {
if (imageCount >= MAX_MEDIA_COUNT) {
toast(R.string.answer_edit_max_img_hint)
return
}
try {
PermissionHelper.checkStoragePermissionBeforeAction(this, object : EmptyCallback {
override fun onCallback() {
val maxChooseCount = if (imageCount + 10 <= MAX_IMAGE_COUNT) 10 else MAX_IMAGE_COUNT - imageCount
val maxChooseCount = if (imageCount + 10 <= MAX_MEDIA_COUNT) 10 else MAX_MEDIA_COUNT - imageCount
val intent = LocalMediaActivity.getIntent(
this@BaseRichEditorActivity,
LocalMediaActivity.ChooseType.IMAGE,
@ -754,8 +750,6 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
super.onDarkModeChanged()
updateStatusBarColor(R.color.background_white, R.color.background_white)
mRichEditor.enableForceDark(DarkModeUtils.isDarkModeOn(this))
mRichEditor.setEditorBackgroundColor(R.color.background_white.toColor(this))
mRichEditor.setEditorFontColor(if (mIsDarkModeOn) Color.parseColor("#C2C2C2") else Color.parseColor("#4A4A4A"))
}
companion object {
@ -776,7 +770,6 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
const val INSERT_VIDEO_CODE = 415
const val MAX_INPUT_TEXT_NUM = 10000
const val MAX_MEDIA_COUNT = 20
const val MAX_IMAGE_COUNT = 35
const val REQUEST_CODE_IMAGE = 120
const val INSERT_MEDIA_VIDEO_CODE = 121

View File

@ -1,6 +1,5 @@
package com.gh.base
import android.annotation.SuppressLint
import android.app.Application
import android.content.Intent
import android.graphics.Bitmap
@ -10,19 +9,16 @@ import android.text.TextUtils
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.MutableLiveData
import com.gh.gamecenter.R
import com.gh.gamecenter.common.base.fragment.WaitingDialogFragment
import com.gh.gamecenter.common.retrofit.Response
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.runOnUiThread
import com.gh.gamecenter.core.utils.MD5Utils
import com.gh.gamecenter.core.utils.ToastUtils
import com.gh.gamecenter.common.entity.ErrorEntity
import com.gh.gamecenter.common.retrofit.BiResponse
import com.gh.gamecenter.entity.ForumDetailEntity
import com.gh.gamecenter.R
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.utils.*
import com.gh.gamecenter.entity.ErrorEntity
import com.gh.gamecenter.entity.LocalVideoEntity
import com.gh.gamecenter.entity.QuoteCountEntity
import com.gh.gamecenter.qa.BbsType
import com.gh.gamecenter.common.retrofit.Response
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.retrofit.service.ApiService
import com.gh.gamecenter.video.upload.OnUploadListener
@ -31,20 +27,25 @@ import com.google.gson.JsonObject
import com.lightgame.utils.Utils
import com.zhihu.matisse.Matisse
import com.zhihu.matisse.internal.utils.PathUtils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import okhttp3.ResponseBody
import retrofit2.HttpException
import java.io.File
import java.io.FileOutputStream
import java.util.*
import kotlin.collections.HashMap
import kotlin.collections.LinkedHashMap
import kotlin.collections.List
import kotlin.collections.Map
import kotlin.collections.find
import kotlin.collections.forEach
import kotlin.collections.set
// TODO: 移动到module_bbs模块
abstract class BaseRichEditorViewModel(application: Application) : AndroidViewModel(application) {
val mApi: ApiService = RetrofitManager.getInstance().api
val mNewApi: ApiService = RetrofitManager.getInstance().newApi
val processDialog = MediatorLiveData<WaitingDialogFragment.WaitingDialogData>()
val uploadingImage = ArrayList<LinkedHashMap<String, String>>()
val chooseImagesUpload = MutableLiveData<LinkedHashMap<String, String>>()
val chooseImagesUploadSuccess = MutableLiveData<LinkedHashMap<String, String>>()
var uploadImageSubscription: Disposable? = null
@ -61,8 +62,6 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
var id = ""//视频标记
var videoId = ""//更改封面视频id
val quoteCountEntity = QuoteCountEntity()//数据上报用
val sectionListLiveData = MutableLiveData<List<ForumDetailEntity.Section>>()
var isModerator = false
fun setUploadVideoListener(uploadVideoListener: UploadVideoListener) {
this.mUploadVideoListener = uploadVideoListener
@ -71,10 +70,7 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
//检查图片是否符合规则并上传图片
fun uploadPic(data: Intent) {
val uris = Matisse.obtainResult(data)
val rawImgUrlList = ArrayList<String>() // 需要上传图片的原始地址列表
val uploadingImgList = ArrayList<String>() // 正在上传图片的地址列表(已压缩处理)
val compressedImgUrlList = ArrayList<String>() // 压缩处理后图片的地址列表
val pictureList = ArrayList<String>()
for (uri in uris) {
val picturePath = PathUtils.getPath(getApplication(), uri)
if (picturePath != null) {
@ -88,12 +84,12 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
continue
}
Utils.log("picturePath = $picturePath")
rawImgUrlList.add(picturePath)
pictureList.add(picturePath)
} else {
Utils.log("picturePath is null")
}
}
if (rawImgUrlList.size == 0) return
if (pictureList.size == 0) return
val imageType = when (getRichType()) {
RichType.ARTICLE -> UploadImageUtils.UploadType.community_article
RichType.QUESTION -> UploadImageUtils.UploadType.question
@ -101,7 +97,7 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
}
uploadImageSubscription = UploadImageUtils.compressAndUploadImageList(
imageType,
rawImgUrlList,
pictureList,
false,
object : UploadImageUtils.OnUploadImageListListener {
override fun onProgress(total: Long, progress: Long) {}
@ -111,108 +107,87 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
imageUrls.forEach {
chooseImageMd5Map[MD5Utils.getUrlMD5(it)] = ""
}
uploadingImgList.addAll(imageUrls)
compressedImgUrlList.addAll(imageUrls)
uploadingImage.add(chooseImageMd5Map)
chooseImagesUpload.postValue(chooseImageMd5Map)
}
override fun onSingleSuccess(imageUrlMap: Map<String, String>) {
imageUrlMap.forEach {
if (uploadingImgList.contains(it.key)) {
uploadingImgList.remove(it.key)
}
}
override fun onSingleSuccess(imageUrl: Map<String, String>) {
val map = LinkedHashMap<String, String>()
for (key in imageUrlMap.keys) {
for (key in imageUrl.keys) {
map[MD5Utils.getUrlMD5(key)] = FILE_HOST + key.decodeURI()
mapImages[TextUtils.htmlEncode(key).decodeURI()] = imageUrlMap[key] ?: ""
mapImages[TextUtils.htmlEncode(key).decodeURI()] = imageUrl[key] ?: ""
}
chooseImagesUploadSuccess.value = map
chooseImagesUploadSuccess.postValue(map)
}
override fun onSuccess(imageUrlMap: LinkedHashMap<String, String>, errorMap: Map<String, Exception>) {
imageUrlMap.forEach {
if (uploadingImgList.contains(it.key)) {
uploadingImgList.remove(it.key)
}
override fun onSuccess(
imageUrl: LinkedHashMap<String, String>,
errorMap: Map<String, Exception>
) {
val uploadMap = uploadingImage.find {
it.containsKey(
MD5Utils.getUrlMD5(
imageUrl.entries.iterator().next().key
)
)
}
uploadMap?.let {
uploadingImage.remove(uploadMap)
}
var errorSize = compressedImgUrlList.size - imageUrlMap.size
if (errorSize > 0 || uploadingImgList.isNotEmpty()) {
val errorImageMap = LinkedHashMap<String, String>()
val errorSize = pictureList.size - imageUrl.size
if (errorSize > 0) {
val map = LinkedHashMap<String, String>()
for (key in errorMap.keys) {
errorImageMap[MD5Utils.getUrlMD5(key)] = ""
map[MD5Utils.getUrlMD5(key)] = ""
}
//value为空会删除PlaceholderImage
chooseImagesUploadSuccess.postValue(map)
for (rawImgUrl in compressedImgUrlList) {
if (!imageUrlMap.containsKey(rawImgUrl)) {
errorImageMap[MD5Utils.getUrlMD5(rawImgUrl)] = ""
for (error in errorMap.values) {
if (error is HttpException && error.code() == 403) {
Utils.toast(getApplication(), errorSize.toString() + "张违规图片上传失败")
return
}
}
errorSize = if (errorMap.isEmpty()) {
errorImageMap.size
} else {
errorMap.size + errorImageMap.size
}
// value为空会删除PlaceholderImage
chooseImagesUploadSuccess.value = errorImageMap
if (handleUploadError(errorSize, errorMap)) return
if (errorSize > 0) {
ToastUtils.showToast(errorSize.toString() + "张图片上传失败")
}
Utils.toast(getApplication(), errorSize.toString() + "张图片上传失败")
}
}
override fun onError(errorMap: Map<String, Exception>) {
val errorSize = uploadingImgList.size
if (uploadingImgList.size > 0) {
val errorSize = errorMap.size
if (errorSize > 0) {
val map = LinkedHashMap<String, String>()
for (key in uploadingImgList) {
for (key in errorMap.keys) {
map[MD5Utils.getUrlMD5(key)] = ""
}
// value为空会删除PlaceholderImage
chooseImagesUploadSuccess.value = map
//value为空会删除PlaceholderImage
chooseImagesUploadSuccess.postValue(map)
}
if (handleUploadError(errorSize, errorMap)) return
if (errorSize == 0) return
for (error in errorMap.values) {
if (error is HttpException && error.code() == 403) {
val e = error.response()?.errorBody()?.string()?.toObject<ErrorEntity>()
if (e != null && e.code == 403017) {
Utils.toast(
getApplication(),
errorSize.toString() + "张图片的宽或高超过限制,请裁剪后上传"
)
} else {
Utils.toast(getApplication(), errorSize.toString() + "张违规图片上传失败")
}
return
}
}
if (errorSize == 1) {
ToastUtils.showToast("图片上传失败")
Utils.toast(getApplication(), "图片上传失败")
} else {
ToastUtils.showToast(errorSize.toString() + "张图片上传失败")
Utils.toast(getApplication(), errorSize.toString() + "张图片上传失败")
}
}
})
}
/**
* 处理上传错误 (包括超时 cancel 的异常)
* @return 如果 toast 过了就返回 true
*/
private fun handleUploadError(
errorSize: Int,
errorMap: Map<String, Exception>
): Boolean {
for (error in errorMap.values) {
if (error is HttpException && error.code() == 403) {
val e = error.response()?.errorBody()?.string()?.toObject<ErrorEntity>()
if (e != null && e.code == 403017) {
ToastUtils.showToast(errorSize.toString() + "张图片的宽或高超过限制,请裁剪后上传")
} else {
ToastUtils.showToast(errorSize.toString() + "张违规图片上传失败")
}
return true
}
}
return false
}
fun uploadPoster(picturePath: String) {
processDialog.postValue(WaitingDialogFragment.WaitingDialogData("封面上传中...", true))
uploadImageSubscription =
@ -416,30 +391,6 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
return true
}
fun getForumSections(bbsId: String) {
mNewApi.getForumSections(bbsId)
.compose(observableToMain())
.subscribe(object : Response<List<ForumDetailEntity.Section>>() {
override fun onResponse(response: List<ForumDetailEntity.Section>?) {
response?.run {
sectionListLiveData.postValue(this)
}
}
})
}
@SuppressLint("CheckResult")
fun getModeratorsInfo(bbsId: String) {
mApi.getModeratorsInfo(bbsId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : BiResponse<JsonObject>() {
override fun onSuccess(data: JsonObject) {
isModerator = data["is_moderators"].asBoolean
}
})
}
private fun getVideoType(): String {
return when (type) {
BbsType.GAME_BBS.value -> {

View File

@ -6,12 +6,14 @@ import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.gh.common.util.FloatingBackViewManager
import com.gh.download.DownloadManager
import com.gh.gamecenter.SingletonWebActivity
import com.gh.gamecenter.SkipActivity
import com.gh.gamecenter.MainActivity
import com.gh.gamecenter.SplashScreenActivity
import com.gh.gamecenter.authorization.AuthorizationActivity
import com.gh.gamecenter.common.base.GlobalActivityManager
import com.gh.gamecenter.common.utils.PackageFlavorHelper
import com.gh.gamecenter.forum.detail.ForumDetailActivity
import com.gh.gamecenter.forum.list.ForumListActivity
import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity
import com.gh.gamecenter.qa.questions.newdetail.NewQuestionDetailActivity
import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity
import com.gh.vspace.VHelper
import com.halo.assistant.HaloApp
@ -29,7 +31,11 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
override fun onActivityResumed(activity: Activity) {
// 判断是否需要显示或隐藏返回小浮窗
if (FloatingBackViewManager.getType().isNotEmpty()) {
if (activity is SingletonWebActivity
if ((activity::class.java.name == "EnergyCenterActivity")
&& FloatingBackViewManager.getType() == FloatingBackViewManager.TYPE_TASK
) {
FloatingBackViewManager.disableBackView()
} else if (!shouldShowActivityBackView(activity)
&& FloatingBackViewManager.getType() == FloatingBackViewManager.TYPE_ACTIVITY
) {
FloatingBackViewManager.disableBackView()
@ -54,15 +60,20 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
DarkModeSwitchHelper.showDarkModeSwitchFloatingView(activity)
}
if (activity is AppCompatActivity
&& activity !is SplashScreenActivity
&& activity !is SkipActivity
&& activity !is AuthorizationActivity
) {
if (activity is AppCompatActivity && activity !is SplashScreenActivity) {
VHelper.showFeedbackDialogIfLastSuccessfulLaunchedGameExitUnexpectedly(activity)
}
}
private fun shouldShowActivityBackView(activity: Activity): Boolean {
return (activity is MainActivity
|| activity is ArticleDetailActivity
|| activity is ForumVideoDetailActivity
|| activity is ForumDetailActivity
|| activity is ForumListActivity
|| activity is NewQuestionDetailActivity)
}
override fun onActivityPaused(activity: Activity) {
FloatingBackViewManager.dismissBackView()
if (PackageFlavorHelper.IS_TEST_FLAVOR && activity is AppCompatActivity) {

View File

@ -0,0 +1,14 @@
package com.gh.base
import android.app.Activity
import java.lang.ref.WeakReference
object GlobalActivityManager {
private var mCurrentActivityWeakRef: WeakReference<Activity>? = null
var currentActivity: Activity?
get() = mCurrentActivityWeakRef?.get()
set(activity) {
mCurrentActivityWeakRef = WeakReference<Activity>(activity)
}
}

View File

@ -4,39 +4,33 @@ import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.util.Base64
import android.view.View
import android.webkit.JavascriptInterface
import androidx.annotation.Keep
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentManager
import com.alibaba.android.arouter.launcher.ARouter
import com.gh.common.util.*
import com.gh.common.util.LogUtils
import com.gh.download.DownloadManager
import com.gh.download.PackageObserver
import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.ImageViewerActivity
import com.gh.gamecenter.WebActivity
import com.gh.gamecenter.common.callback.BiCallback
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.common.entity.NotificationUgc
import com.gh.gamecenter.common.loghub.LoghubUtils
import com.gh.gamecenter.common.provider.IHelpAndFeedbackProvider
import com.gh.gamecenter.common.tracker.Tracker
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.common.view.dsbridge.CompletionHandler
import com.gh.gamecenter.core.AppExecutor
import com.gh.gamecenter.core.runOnIoThread
import com.gh.gamecenter.core.runOnUiThread
import com.gh.gamecenter.core.utils.*
import com.gh.gamecenter.entity.SensorsEvent
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.eventbus.EBPackage
import com.gh.gamecenter.feature.entity.Badge
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.core.utils.CurrentActivityHolder
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.core.utils.MtaHelper
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.energy.EnergyBridge
import com.gh.gamecenter.entity.MtaEvent
import com.gh.gamecenter.help.QaFeedbackDialogFragment
import com.gh.gamecenter.login.entity.Badge
import com.gh.gamecenter.login.user.LoginTag
import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.login.user.UserRepository
@ -44,35 +38,19 @@ import com.gh.gamecenter.login.utils.LoginHelper
import com.gh.gamecenter.login.utils.QuickLoginHelper
import com.gh.gamecenter.login.view.LoginActivity
import com.gh.gamecenter.personalhome.border.AvatarBorderActivity
import com.gh.gamecenter.setting.SettingBridge
import com.gh.vspace.VHelper
import com.gh.gamecenter.setting.compose.activity.ComposeAboutActivity
import com.gh.gamecenter.setting.compose.activity.ComposeBindPhoneActivity
import com.halo.assistant.HaloApp
import com.lightgame.download.DataWatcher
import com.lightgame.download.DownloadEntity
import com.lightgame.download.DownloadStatus.*
import com.lightgame.utils.Utils
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import org.json.JSONObject
import java.io.BufferedOutputStream
import java.io.File
import java.io.FileOutputStream
import java.util.*
class DefaultJsApi(var context: Context, val entrance: String = "", private var mFragment: Fragment? = null) {
class DefaultJsApi(var context: Context, val entrance: String = "") {
private var mLoginHandler: CompletionHandler<Any>? = null
private var mDownloadWatcher: DataWatcher? = null // 下载观察者
private var mDownloadUrlSet: HashSet<String>? = null // 下载的 url 集合
private var mDownloadHandler: CompletionHandler<Any>? = null // 下载信息回调
init {
if (mFragment != null) {
EventBus.getDefault().register(this)
autoUnregisterDownloadObserverIfNeeded(mFragment)
}
}
@JavascriptInterface
fun isGhzs(msg: Any): String {
@ -86,20 +64,9 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
@JavascriptInterface
fun logMtaEvent(event: Any) {
// do nothing, mta is deprecated
}
val mtaEvent = event.toString().toObject() ?: MtaEvent()
@JavascriptInterface
fun logSensorsEvent(event: Any) {
val sensorsEvent = event.toString().toObject() ?: SensorsEvent()
val trackEvent = JSONObject()
tryCatchInRelease {
sensorsEvent.kv.split(",").forEach {
val kv = it.split(":")
trackEvent.put(kv[0], kv[1])
}
}
SensorsBridge.trackEvent(sensorsEvent.name, trackEvent)
MtaHelper.onEvent(mtaEvent.name, mtaEvent.key, mtaEvent.value)
}
@JavascriptInterface
@ -164,6 +131,7 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
WechatBindHelper.bindWechat(wechatLoginInfoMap, object : BiCallback<Boolean, Boolean> {
override fun onFirst(first: Boolean) {
EnergyBridge.postEnergyTask("bind_wechat")
handler.complete(true)
}
@ -199,18 +167,7 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
@JavascriptInterface
fun startApp(msg: Any) {
val packageName = msg.toString()
val context = HaloApp.getInstance().application
runOnUiThread {
// 若畅玩列表中安装了,优先启动畅玩游戏
if (VHelper.isInstalled(packageName)) {
if (!VHelper.showDialogIfVSpaceIsNeeded(context, "", "")) {
VHelper.launch(context, packageName)
}
} else {
PackageUtils.launchApplicationByPackageName(context, packageName)
}
}
PackageUtils.launchApplicationByPackageName(HaloApp.getInstance().application, packageName)
}
@JavascriptInterface
@ -266,6 +223,7 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
@JavascriptInterface
fun updateRegulationTestStatus(msg: Any) {
if (msg.toString().toLowerCase(Locale.getDefault()) == "pass") {
EnergyBridge.postEnergyTask("finish_etiquette_exam")
SPUtils.setString(Constants.SP_REGULATION_TEST_PASS_STATUS, "pass")
}
}
@ -312,7 +270,7 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
@JavascriptInterface
fun bindPhone(msg: Any) {
val intent = SettingBridge.getBindPhoneNormalIntent(context, false)
val intent = ComposeBindPhoneActivity.getNormalIntent(context, false)
context.startActivity(intent)
}
@ -341,24 +299,22 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
@JavascriptInterface
fun postWearBadgeTask(msg: Any) {
// do nothing
EnergyBridge.postEnergyTask("wear_badge")
}
@JavascriptInterface
fun startEnergyCenter(msg: Any) {
// do nothing
context.startActivity(EnergyBridge.getEnergyCenterIntent(context))
}
@JavascriptInterface
fun startEnergyHouse(msg: Any) {
// do nothing
context.startActivity(EnergyBridge.getEnergyHouseIntent(context, null))
}
@JavascriptInterface
fun showQaFeedbackDialog(msg: Any) {
val mHelpAndFeedbackHelp =
ARouter.getInstance().build(RouteConsts.provider.helpAndFeedback).navigation() as? IHelpAndFeedbackProvider
mHelpAndFeedbackHelp?.showQaFeedbackDialogFragment(context as AppCompatActivity, msg.toString())
QaFeedbackDialogFragment.show(context as AppCompatActivity, msg.toString())
}
@JavascriptInterface
@ -405,6 +361,11 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
FloatingBackViewManager.enableBackView(FloatingBackViewManager.TYPE_ACTIVITY, msg.toString())
}
@JavascriptInterface
fun startBBSStayTimeCount(msg: Any) {
BbsStayTimeHelper.enableStayTimeCount(msg.toString().toInt())
}
@JavascriptInterface
fun saveBase64ImageToGallery(msg: Any) {
val base64StringData = msg.toString()
@ -444,9 +405,18 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
runOnUiThread { DirectUtils.directToFullScreenWebPage(context, url.toString(), true, entrance) }
}
@JavascriptInterface
fun startGameCollectionSquareBrowseTask(event: Any) {
val browseTimeEvent = event.toString().toObject() ?: BrowseTaskEvent()
GameCollectionSquareBrowseTaskHelper.enableBrowseTimeCount(
browseTimeEvent.timeout.toInt(),
browseTimeEvent.isFinished == "true"
)
}
@JavascriptInterface
fun checkUpdateGhzs(msg: Any) {
context.startActivity(SettingBridge.getAboutIntent(context, true))
context.startActivity(ComposeAboutActivity.getIntent(context, true))
}
@JavascriptInterface
@ -469,192 +439,17 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
@JavascriptInterface
fun getEntrance(msg: Any): String {
return when {
entrance.contains("论坛-活动") -> "社区-活动tab-活动banner"
entrance.contains("启动弹窗") -> "首页_弹窗"
entrance.contains("新首页-轮播图") -> "首页banner"
entrance.contains("论坛banner") -> "社区banner"
entrance.contains("启动广告") -> "app_开屏文案"
// entrance.contains("资讯广场-轮播图") -> "资讯_活动banner"
entrance.contains("通用链接合集") -> "资讯_活动banner"
entrance.contains("视频流广告位") -> "视频流_广告位"
entrance.contains("我的光环banner") -> "我的光环_banner"
entrance.contains("论坛详情页置顶栏") -> "社区_论坛置顶"
else -> entrance
}
}
@JavascriptInterface
fun getInstallStatus(event: Any): String {
val localInstalledPackageList = PackageUtils.getAllPackageName(HaloApp.getInstance().application)
val packageNameList: ArrayList<String> = event.toString().toObject() ?: ArrayList()
val installStatusMap: HashMap<String, Boolean> = hashMapOf()
for (packageName in packageNameList) {
installStatusMap[packageName] =
localInstalledPackageList.contains(packageName) || VHelper.isInstalled(packageName)
}
return installStatusMap.toJson()
}
@JavascriptInterface
fun installDownloadedGame(event: Any) {
val url = event.toString()
val vUrl = VHelper.getVUrl(url)
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(url, null, false)
?: DownloadManager.getInstance().getDownloadEntitySnapshot(vUrl, null, false)
downloadEntity?.let {
PackageInstaller.install(context, it, showUnzipToast = false)
}
}
@JavascriptInterface
fun registerDownloadCallback(msg: Any, handler: CompletionHandler<Any>) {
val downloadUrlSet: HashSet<String> = msg.toString().toObject() ?: return
mDownloadHandler = handler
mDownloadUrlSet = downloadUrlSet
if (mDownloadWatcher == null) {
mDownloadWatcher = object : DataWatcher() {
override fun onDataInit(downloadEntity: DownloadEntity) {
onDataChanged(downloadEntity)
}
override fun onDataChanged(downloadEntity: DownloadEntity?) {
val url = VHelper.getOriginalUrl(downloadEntity?.url)
if (downloadEntity != null && mDownloadUrlSet?.contains(url) == true) {
mDownloadHandler?.setProgressData(
SimpleDownloadEntity.fromDownloadEntity(downloadEntity).toJson()
)
}
}
}
DownloadManager.getInstance().addObserver(mDownloadWatcher)
}
}
@JavascriptInterface
fun registerPackageChangesCallback(msg: Any, handler: CompletionHandler<Any>) {
PackageObserver.registerPackageChangeChangeListener(object : PackageObserver.PackageChangeListener {
override fun onChanged(data: EBPackage) {
handler.setProgressData(data.toJson())
}
})
}
@JavascriptInterface
fun startDownload(msg: Any) {
val gameEntity: GameEntity? = msg.toString().toObject()
if (gameEntity == null) {
ToastUtils.toast("下载异常,请稍后重试")
return
}
runOnUiThread {
// 用一个假的 view 来当 downloadView
val stubView = View(context)
DownloadItemUtils.setOnClickListener(
position = 0,
context = context,
downloadBtn = stubView,
gameEntity = gameEntity,
adapter = null,
entrance = "(网页活动)",
location = "",
traceEvent = null,
clickCallback = null,
refreshCallback = null,
allStateClickCallback = null
)
stubView.performClick()
}
}
@JavascriptInterface
fun resumeDownload(msg: Any) {
val url = msg.toString()
DownloadManager.getInstance().resumeDownload(url)
}
@JavascriptInterface
fun pauseDownload(msg: Any) {
val url = msg.toString()
DownloadManager.getInstance().pause(url)
}
@JavascriptInterface
fun shareText(event: Any) {
val textShareEvent = event.toString().toObject() ?: TextShareEvent()
if (textShareEvent.text.isNotEmpty() && textShareEvent.type.isNotEmpty()) {
val activity = CurrentActivityHolder.getCurrentActivity()
MessageShareUtils.getInstance(activity).shareTextFromWeb(activity, textShareEvent.text, textShareEvent.type)
}
}
private fun autoUnregisterDownloadObserverIfNeeded(fragment: Fragment?) {
fragment?.parentFragmentManager?.registerFragmentLifecycleCallbacks(
object : FragmentManager.FragmentLifecycleCallbacks() {
override fun onFragmentViewDestroyed(fm: FragmentManager, f: Fragment) {
super.onFragmentViewDestroyed(fm, f)
if (f === fragment) {
fragment.parentFragmentManager.unregisterFragmentLifecycleCallbacks(this)
if (mDownloadWatcher != null) {
DownloadManager.getInstance().removeObserver(mDownloadWatcher)
}
EventBus.getDefault().unregister(this@DefaultJsApi)
}
}
override fun onFragmentResumed(fm: FragmentManager, f: Fragment) {
super.onFragmentResumed(fm, f)
if (f === fragment && mDownloadWatcher != null) {
DownloadManager.getInstance().addObserver(mDownloadWatcher)
}
}
override fun onFragmentPaused(fm: FragmentManager, f: Fragment) {
super.onFragmentPaused(fm, f)
if (f === fragment && mDownloadWatcher != null) {
DownloadManager.getInstance().removeObserver(mDownloadWatcher)
}
}
}, false
)
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEventMainThread(status: EBDownloadStatus) {
// 将下载任务删除事件回调给网页
if (mDownloadHandler != null && "delete" == status.status) {
mDownloadHandler?.setProgressData(SimpleDownloadEntity(status.url, 0F, "UNKNOWN").toJson())
}
return entrance
}
@Keep
internal class ImageEvent(var imageList: ArrayList<String> = arrayListOf(), var position: Int = 0)
internal data class ImageEvent(var imageList: ArrayList<String> = arrayListOf(), var position: Int = 0)
@Keep
internal class ImageShareEvent(var image: String = "", var type: String = "")
internal data class ImageShareEvent(var image: String = "", var type: String = "")
@Keep
internal class TextShareEvent(var text: String = "", var type: String = "")
@Keep
internal class InviteFriendsEvent(
internal data class InviteFriendsEvent(
var type: String = "",
var way: String = "",
var url: String = "",
@ -662,48 +457,16 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
)
@Keep
internal class LogEvent(var jsonString: String = "", var logStore: String = "")
internal data class LogEvent(var jsonString: String = "", var logStore: String = "")
@Keep
class GameActivityEvent(
internal data class BrowseTaskEvent(var timeout: String = "", var isFinished: String = "")
@Keep
data class GameActivityEvent(
var gameId: String = "",
var activityTitle: String = "",
var activityId: String = "",
var platform: String = ""
)
@Keep
class SimpleDownloadEntity(
var url: String = "",
var progress: Float = 0F,
var status: String = "" // DOWNLOADING, PAUSED, DOWNLOADED, ERROR, UNKNOWN
) {
companion object {
fun fromDownloadEntity(downloadEntity: DownloadEntity): SimpleDownloadEntity {
val status: String = when (downloadEntity.status) {
add,
download,
downloading -> "DOWNLOADING"
done -> "DOWNLOADED"
pause,
resume,
subscribe,
waiting -> "PAUSED"
cancel,
delete -> "UNKNOWN"
else -> "ERROR"
}
return SimpleDownloadEntity(
url = VHelper.getOriginalUrl(downloadEntity.url),
progress = downloadEntity.percent.toFloat(),
status = status
)
}
}
}
}

View File

@ -5,8 +5,9 @@ import android.content.Intent
import android.net.Uri
import android.text.TextUtils
import android.util.Base64
import com.gh.common.util.CheckLoginUtils
import com.gh.common.util.DirectUtils
import com.gh.gamecenter.core.utils.CurrentActivityHolder
import com.gh.gamecenter.common.constant.Constants
import com.gh.common.util.*
import com.gh.common.util.DirectUtils.directToFeedback
import com.gh.common.util.DirectUtils.directToGameDetailVideoStreaming
import com.gh.common.util.DirectUtils.directToGameServerCalendar
@ -14,37 +15,25 @@ import com.gh.common.util.DirectUtils.directToGameVideo
import com.gh.common.util.DirectUtils.directToLegacyVideoDetail
import com.gh.common.util.DirectUtils.directToLinkPage
import com.gh.common.util.DirectUtils.directToQa
import com.gh.common.util.PackageUtils
import com.gh.gamecenter.core.utils.GsonUtils.gson
import com.gh.gamecenter.LibaoDetailActivity
import com.gh.gamecenter.MainActivity
import com.gh.gamecenter.NewsDetailActivity
import com.gh.gamecenter.WebActivity
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.common.eventbus.EBReuse
import com.gh.gamecenter.core.AppExecutor
import com.gh.gamecenter.common.utils.DialogHelper
import com.gh.gamecenter.common.utils.EnvHelper
import com.gh.gamecenter.core.AppExecutor
import com.gh.gamecenter.core.utils.CurrentActivityHolder
import com.gh.gamecenter.core.utils.GsonUtils.gson
import com.gh.gamecenter.core.utils.ToastUtils
import com.gh.gamecenter.entity.ActivityLabelEntity
import com.gh.gamecenter.entity.SubjectRecommendEntity
import com.gh.gamecenter.entity.VideoLinkEntity
import com.gh.gamecenter.eventbus.EBSkip
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.utils.PlatformUtils
import com.gh.gamecenter.fragment.MainWrapperFragment
import com.gh.gamecenter.entity.*
import com.gh.gamecenter.gamecollection.publish.GameCollectionEditActivity
import com.gh.gamecenter.qa.BbsType
import com.gh.gamecenter.qa.video.publish.VideoPublishActivity
import com.gh.gamecenter.subject.SubjectActivity
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel
import com.lightgame.utils.Utils
import org.greenrobot.eventbus.EventBus
import java.nio.charset.Charset
object DefaultUrlHandler {
@ -196,12 +185,10 @@ object DefaultUrlHandler {
EntranceConsts.HOST_USERHOME -> {
val position = uri.getQueryParameter("position")
val subtype = uri.getQueryParameter("sub_type") ?: ""
val subGameType = uri.getQueryParameter("sub_game_type") ?: "game_collection"
DirectUtils.directToHomeActivity(
context,
id,
subtype,
subGameType,
if (position.isNullOrEmpty()) -1 else position.toInt(),
entrance,
""
@ -273,6 +260,21 @@ object DefaultUrlHandler {
EntranceConsts.HOST_COLUMN -> {
DirectUtils.directToSubject(context, id, uri.getQueryParameter(EntranceConsts.KEY_NAME), entrance)
}
EntranceConsts.HOST_COMMUNITY_QUESTION_LABEL_DETAIL -> {
val community = CommunityEntity()
community.id = uri.getQueryParameter("community_id") ?: ""
community.name = uri.getQueryParameter("community_name") ?: ""
val tag = uri.getQueryParameter("tag") ?: ""
DirectUtils.directAskColumnLabelDetail(context, tag, community, entrance, "")
}
EntranceConsts.HOST_COMMUNITY_COLUMN_DETAIL -> {
val community = CommunityEntity()
community.id = uri.getQueryParameter("community_id") ?: ""
community.name = uri.getQueryParameter("community_name") ?: ""
val columnId = uri.getQueryParameter("column_id") ?: ""
DirectUtils.directAskColumnDetail(context, columnId, community, entrance, "")
}
EntranceConsts.HOST_BLOCK -> {
val name = uri.getQueryParameter("name")
?: ""
@ -408,11 +410,10 @@ object DefaultUrlHandler {
val packageMd5 = uri.getQueryParameter(EntranceConsts.KEY_PACKAGE_MD5)
val isQaFeedback = uri.getQueryParameter(EntranceConsts.KEY_IS_QA_FEEDBACK) == "true"
val content = if (TextUtils.isEmpty(gameId) || TextUtils.isEmpty(packageMd5)) String.format(
"%s—V%s—%sV%s",
"%s-%s-V%s",
uri.getQueryParameter(EntranceConsts.KEY_GAME_NAME),
uri.getQueryParameter(EntranceConsts.KEY_VERSION),
if (TextUtils.isEmpty(platformName)) platform else platformName,
uri.getQueryParameter(EntranceConsts.KEY_PLATFORM_VERSION),
uri.getQueryParameter(EntranceConsts.KEY_VERSION)
) else String.format(
"%s-%s-V%s\n游戏ID%s\n游戏包MD5%s\n",
uri.getQueryParameter(EntranceConsts.KEY_GAME_NAME),
@ -489,18 +490,6 @@ object DefaultUrlHandler {
)
}
EntranceConsts.HOST_GAME_LIBRARY -> {
DirectUtils.directToMainActivity(context)
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_GAME))
}
EntranceConsts.HOST_HOME_GAME_COLLECTION_SQUARE -> {
DirectUtils.directToMainActivity(context)
EventBus.getDefault()
.post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_HOME))
EventBus.getDefault().post(EBReuse(host))
}
else -> {
if (bringAppToFront) {
DirectUtils.directToMainActivity(context)

View File

@ -2,15 +2,14 @@ package com.gh.common
import com.gh.common.exposure.ExposureManager
import com.gh.common.filter.RegionSettingHelper
import com.gh.common.util.AdHelper
import com.gh.common.videolog.VideoRecordUtils
import com.gh.download.DownloadDataHelper
import com.gh.gamecenter.common.loghub.LoghubUtils
import com.gh.gamecenter.common.retrofit.Response
import com.gh.gamecenter.common.utils.doOnMainProcessOnly
import com.gh.gamecenter.common.utils.tryCatchInRelease
import com.gh.gamecenter.core.runOnUiThread
import com.gh.common.videolog.VideoRecordUtils
import com.gh.download.DownloadDataHelper
import com.gh.gamecenter.entity.TimeEntity
import com.gh.gamecenter.common.retrofit.Response
import com.gh.gamecenter.core.runOnUiThread
import com.gh.gamecenter.retrofit.RetrofitManager
import com.halo.assistant.HaloApp
import io.reactivex.schedulers.Schedulers
@ -18,15 +17,14 @@ import kotlin.concurrent.fixedRateTimer
object FixedRateJobHelper {
private const val CHECKER_PERIOD: Long = 15 * 1000L
private const val TIME_PERIOD: Long = 10 * 60 * 1000L
private const val LOGHUB_PERIOD: Long = 2 * 60 * 1000L
private const val EXPOSURE_PERIOD: Long = 5 * 60 * 1000L
private const val REGION_SETTING_PERIOD: Long = 30 * 1000L
private const val TIME_PERIOD: Long = 600 * 1000L
private const val LOGHUB_PERIOD: Long = 120 * 1000L
private const val EXPOSURE_PERIOD: Long = 300 * 1000L
private const val REGION_SETTING_PERIOD: Long = 300 * 1000L
private const val VIDEO_RECORD_PERIOD: Long = 60 * 1000L
private const val DOWNLOAD_HEARTBEAT_PERIOD: Long = 60 * 1000L
private const val DOWNLOAD_HEARTBEAT_SHEET_PERIOD: Long = 15 * 1000L
private const val STARTUP_AD: Long = 30 * 60 * 1000L
private var mExecuteCount: Int = 0
@ -35,11 +33,9 @@ object FixedRateJobHelper {
@JvmStatic
fun begin() {
doOnMainProcessOnly {
// 时间检查每15秒检查一次
fixedRateTimer("Global-Fixed-Rate-Timer", initialDelay = 100, period = CHECKER_PERIOD) {
val elapsedTime = mExecuteCount * CHECKER_PERIOD
// 时间校对10分钟一次
if (elapsedTime % TIME_PERIOD == 0L) {
if ((mExecuteCount * CHECKER_PERIOD) % TIME_PERIOD == 0L) {
RetrofitManager.getInstance().api.time
.subscribeOn(Schedulers.io())
.subscribe(object : Response<TimeEntity>() {
@ -53,12 +49,14 @@ object FixedRateJobHelper {
}
// 提交曝光数据
if (elapsedTime % EXPOSURE_PERIOD == 0L) {
ExposureManager.commitSavedExposureEvents(true)
if ((mExecuteCount * CHECKER_PERIOD) % EXPOSURE_PERIOD == 0L) {
runOnUiThread {
ExposureManager.commitSavedExposureEvents(true)
}
}
// 分片检测下载进度
if (elapsedTime % DOWNLOAD_HEARTBEAT_SHEET_PERIOD == 0L) {
if ((mExecuteCount * CHECKER_PERIOD) % DOWNLOAD_HEARTBEAT_SHEET_PERIOD == 0L) {
tryCatchInRelease {
val upload = (mExecuteCount * CHECKER_PERIOD) % DOWNLOAD_HEARTBEAT_PERIOD == 0L
DownloadDataHelper.uploadDownloadHeartbeat(upload)
@ -66,29 +64,25 @@ object FixedRateJobHelper {
}
// 提交普通 loghub 数据
if (elapsedTime % LOGHUB_PERIOD == 0L) {
if ((mExecuteCount * CHECKER_PERIOD) % LOGHUB_PERIOD == 0L) {
runOnUiThread {
LoghubUtils.commitSavedLoghubEvents(true)
}
}
// 更新游戏屏蔽信息
if (elapsedTime % REGION_SETTING_PERIOD == 0L) {
if ((mExecuteCount * CHECKER_PERIOD) % REGION_SETTING_PERIOD == 0L) {
if (HaloApp.getInstance().isRunningForeground) {
RegionSettingHelper.getRegionSetting()
}
}
// 提交视频浏览记录数据
if (elapsedTime % VIDEO_RECORD_PERIOD == 0L) {
if ((mExecuteCount * CHECKER_PERIOD) % VIDEO_RECORD_PERIOD == 0L) {
VideoRecordUtils.commitVideoRecord()
}
// 获取启动广告 (第一次不需要获取)
if (elapsedTime % STARTUP_AD == 0L && mExecuteCount != 0) {
AdHelper.getSettingAdCache()
}
// ExposureUtils.logADownloadCompleteExposureEvent(GameEntity(id = mExecuteCount.toString(), name = "测试曝光上传"), platform = "", trace = null, downloadType = ExposureUtils.DownloadType.DOWNLOAD)
mExecuteCount++
}
}

View File

@ -3,7 +3,7 @@ package com.gh.common.chain
import android.content.Context
import com.gh.download.server.BrowserInstallHelper
import com.gh.gamecenter.core.utils.EmptyCallback
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.entity.GameEntity
class BrowserInstallHandler : ChainHandler() {

View File

@ -2,7 +2,7 @@ package com.gh.common.chain
import android.content.Context
import com.gh.common.dialog.CertificationDialog
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.entity.GameEntity
class CertificationHandler : ChainHandler() {

View File

@ -1,7 +1,7 @@
package com.gh.common.chain
import android.content.Context
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.entity.GameEntity
abstract class ChainHandler {
private var next: ChainHandler? = null

View File

@ -3,7 +3,7 @@ package com.gh.common.chain
import android.content.Context
import com.gh.common.util.DialogUtils
import com.gh.gamecenter.common.utils.safelyGetInRelease
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.entity.GameEntity
class CheckDownloadHandler : ChainHandler() {

View File

@ -3,7 +3,7 @@ package com.gh.common.chain
import android.content.Context
import com.gh.gamecenter.common.utils.PermissionHelper
import com.gh.gamecenter.core.utils.EmptyCallback
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.entity.GameEntity
class CheckStoragePermissionHandler : ChainHandler() {

View File

@ -4,7 +4,7 @@ import android.content.Context
import com.gh.common.util.DownloadDialogHelper
import com.gh.gamecenter.common.utils.safelyGetInRelease
import com.gh.gamecenter.core.utils.EmptyCallback
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.entity.GameEntity
class DownloadDialogHelperHandler : ChainHandler() {

View File

@ -2,7 +2,7 @@ package com.gh.common.chain
import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment
class GamePermissionHandler : ChainHandler() {

View File

@ -2,7 +2,7 @@ package com.gh.common.chain
import android.content.Context
import com.gh.common.util.DialogUtils
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.entity.GameEntity
class OverseaDownloadHandler : ChainHandler() {

View File

@ -3,7 +3,7 @@ package com.gh.common.chain
import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import com.gh.common.dialog.PackageCheckDialogFragment
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.entity.GameEntity
class PackageCheckHandler : ChainHandler() {

View File

@ -3,7 +3,7 @@ package com.gh.common.chain
import android.content.Context
import com.gh.common.simulator.NewSimulatorGameManager
import com.gh.common.simulator.SimulatorGameManager
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.entity.GameEntity
class UpdateNewSimulatorHandler: ChainHandler() {

View File

@ -1,13 +1,13 @@
package com.gh.common.chain
import android.content.Context
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.entity.GameEntity
import com.gh.vspace.VHelper
class ValidateVSpaceHandler : ChainHandler() {
override fun handleRequest(context: Context, gameEntity: GameEntity) {
VHelper.validateVSpaceBeforeAction(context, gameEntity) {
VHelper.validateVSpaceBeforeAction(context, gameEntity, true) {
if (hasNext()) {
getNext()?.handleRequest(context, gameEntity)
} else {

View File

@ -1,33 +1,18 @@
package com.gh.common.chain
import android.content.Context
import com.gh.gamecenter.R
import com.gh.gamecenter.common.utils.DialogHelper
import com.gh.gamecenter.common.utils.toResString
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.common.util.DialogUtils
import com.gh.gamecenter.entity.GameEntity
class VersionNumberHandler : ChainHandler() {
override fun handleRequest(context: Context, gameEntity: GameEntity) {
val confirmCallback = {
DialogUtils.showVersionNumberDialog(context, gameEntity) {
if (hasNext()) {
getNext()?.handleRequest(context, gameEntity)
} else {
processEndCallback?.invoke(null)
}
}
if (!gameEntity.isShowVersionNumber()) {
confirmCallback.invoke()
} else {
DialogHelper.showGuideDialog(
context,
"温馨提示",
gameEntity.getVersionNumberString(),
"继续下载",
R.string.cancel.toResString(),
{ confirmCallback.invoke() },
extraConfig = DialogHelper.Config(titleIcon = R.drawable.ic_dialog_tips)
)
}
}
}

View File

@ -8,27 +8,24 @@ import android.text.TextUtils;
import androidx.annotation.Nullable;
import com.gh.common.util.AdHelper;
import com.gh.gamecenter.common.utils.DarkModeUtils;
import com.gh.gamecenter.common.utils.EnvHelper;
import com.gh.gamecenter.common.constant.Constants;
import com.gh.gamecenter.core.utils.GsonUtils;
import com.gh.common.util.PackageHelper;
import com.gh.common.util.PackageUtils;
import com.gh.gamecenter.BuildConfig;
import com.gh.gamecenter.common.constant.CommonConsts;
import com.gh.gamecenter.common.constant.Constants;
import com.gh.gamecenter.SuggestionActivity;
import com.gh.gamecenter.core.utils.SPUtils;
import com.gh.gamecenter.entity.GameGuidePopupEntity;
import com.gh.gamecenter.entity.NewSettingsEntity;
import com.gh.gamecenter.entity.NewsEntity;
import com.gh.gamecenter.entity.SettingsEntity;
import com.gh.gamecenter.common.eventbus.EBReuse;
import com.gh.gamecenter.entity.SimulatorEntity;
import com.gh.gamecenter.entity.VSetting;
import com.gh.gamecenter.common.retrofit.BiResponse;
import com.gh.gamecenter.common.retrofit.Response;
import com.gh.gamecenter.common.utils.DarkModeUtils;
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.GameGuidePopupEntity;
import com.gh.gamecenter.entity.NewApiSettingsEntity;
import com.gh.gamecenter.entity.NewSettingsEntity;
import com.gh.gamecenter.entity.VSetting;
import com.gh.gamecenter.feature.entity.NewsEntity;
import com.gh.gamecenter.feature.entity.SettingsEntity;
import com.gh.gamecenter.feature.entity.SimulatorEntity;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.gh.vspace.VHelper;
import com.halo.assistant.HaloApp;
@ -67,9 +64,8 @@ public class Config {
private static SettingsEntity mSettingsEntity;
private static NewSettingsEntity mNewSettingsEntity;
private static NewApiSettingsEntity mNewApiSettingsEntity;
private static NewApiSettingsEntity.NightMode mNightModeSetting;
private static NewSettingsEntity.NightMode mNightModeSetting;
private static SimulatorEntity mNewSimulatorEntity;
private static VSetting mVSetting;
private static GameGuidePopupEntity mGameGuidePopupEntity;
@ -77,6 +73,8 @@ public class Config {
public static final String FIX_DOWNLOAD_KEY = "isFixDownload";
public static final String FIX_PLUGIN_KEY = "isFixPlugin";
public static final String FIX_ARTICLE_KEY = "isFixArticle";
public static final String FIX_COMMUNITY_KEY = "isFixCommunity";
public static final int VIDEO_PAGE_SIZE = 21; // 视频列表大多都是一行3个
@ -133,18 +131,6 @@ public class Config {
return !"off".equals(getSettings().getGameSmooth());
}
/**
* VPN 开关选项是否开启
*/
public static boolean isVpnOptionEnabled() {
if (mNewApiSettingsEntity == null
|| mNewApiSettingsEntity.getInstall() == null
|| mNewApiSettingsEntity.getInstall().getVpnRequired() == null) {
return false;
}
return mNewApiSettingsEntity.getInstall().getVpnRequired().getShouldShowVpnOption();
}
public static boolean isShowPlugin(String gameId) {
SharedPreferences preferences = getPreferences();
@ -241,32 +227,24 @@ public class Config {
public static SimulatorEntity getNewSimulatorEntitySetting() {
if (mNewSimulatorEntity != null) {
return mNewSimulatorEntity;
} else if (mNewApiSettingsEntity != null && mNewApiSettingsEntity.getSimulator() != null) {
return mNewApiSettingsEntity.getSimulator();
} else if (mNewSettingsEntity != null && mNewSettingsEntity.getSimulator() != null) {
return mNewSettingsEntity.getSimulator();
} else {
return null;
}
}
@Nullable
public static NewApiSettingsEntity.NightMode getNightModeSetting() {
public static NewSettingsEntity.NightMode getNightModeSetting() {
if (mNightModeSetting != null) {
return mNightModeSetting;
} else if (mNewApiSettingsEntity != null && mNewApiSettingsEntity.getNightMode() != null) {
return mNewApiSettingsEntity.getNightMode();
} else if (mNewSettingsEntity != null && mNewSettingsEntity.getNightMode() != null) {
return mNewSettingsEntity.getNightMode();
} else {
return null;
}
}
public static boolean getUserInterestedGame() {
if (mNewApiSettingsEntity != null) {
return mNewApiSettingsEntity.getUserInterestedGame();
} else {
return false;
}
}
@Nullable
public static NewSettingsEntity getNewSettingsEntity() {
if (mNewSettingsEntity == null) {
@ -282,26 +260,6 @@ public class Config {
return mNewSettingsEntity;
}
@Nullable
public static NewApiSettingsEntity getNewApiSettingsEntity() {
if (mNewApiSettingsEntity == null) {
try {
String json = SPUtils.getString(Constants.SP_NEW_API_SETTINGS);
if (!TextUtils.isEmpty(json)) {
mNewApiSettingsEntity = GsonUtils.fromJson(json, NewApiSettingsEntity.class);
}
} catch (Exception e) {
e.printStackTrace();
}
}
return mNewApiSettingsEntity;
}
public static void updateNewApiSettings(NewApiSettingsEntity settingsEntity) {
mNewApiSettingsEntity = settingsEntity;
SPUtils.setString(Constants.SP_NEW_API_SETTINGS, GsonUtils.toJson(settingsEntity));
}
@Nullable
public static VSetting getVSettingEntity() {
if (mVSetting == null) {
@ -354,10 +312,6 @@ public class Config {
@SuppressLint("CheckResult")
public static void getGhzsSettings() {
String channel = HaloApp.getInstance().getChannel();
// 把请求提前,避免请求过多阻塞,首页显示广告时老是用到上一次的缓存
getNewSettings(channel);
RetrofitManager.getInstance()
.getApi().getSettings(PackageUtils.getGhVersionName(), channel)
.subscribeOn(Schedulers.io())
@ -369,7 +323,7 @@ public class Config {
// 意见反馈
SharedPreferences.Editor edit = getPreferences().edit();
edit.putString(CommonConsts.SUGGESTION_HINT_TYPE,
edit.putString(SuggestionActivity.SUGGESTION_HINT_TYPE,
GsonUtils.toJson(response.getSuggestion()));
edit.apply();
@ -390,20 +344,50 @@ public class Config {
@Override
public void onSuccess(NewSettingsEntity data) {
mNewSettingsEntity = data;
if (mNightModeSetting != null) {
mNewSettingsEntity.setNightMode(mNightModeSetting);
}
SPUtils.setString(Constants.SP_NEW_SETTINGS, GsonUtils.toJson(data));
}
});
RetrofitManager.getInstance()
.getVApi().getSettings(BuildConfig.VERSION_NAME)
.subscribeOn(Schedulers.io())
.subscribe(new BiResponse<VSetting>() {
@Override
public void onSuccess(VSetting data) {
mVSetting = data;
SPUtils.setString(Constants.SP_V_SETTINGS, GsonUtils.toJson(data));
}
});
if (mVSetting == null) {
RetrofitManager.getInstance()
.getVApi().getSettings(BuildConfig.VERSION_NAME)
.subscribeOn(Schedulers.io())
.subscribe(new BiResponse<VSetting>() {
@Override
public void onSuccess(VSetting data) {
mVSetting = data;
SPUtils.setString(Constants.SP_V_SETTINGS, GsonUtils.toJson(data));
}
});
}
if (mNightModeSetting == null && mNewSimulatorEntity == null) {
RetrofitManager.getInstance()
.getNewApi().getNewSettings(PackageUtils.getGhVersionName(), channel)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new BiResponse<NewSettingsEntity>() {
@Override
public void onSuccess(NewSettingsEntity data) {
mNightModeSetting = data.getNightMode();
mNewSimulatorEntity = data.getSimulator();
if (HaloApp.getInstance().isNewForThisVersion && mNightModeSetting != null && mNightModeSetting.getInstall()) {
DarkModeUtils.INSTANCE.updateFollowSystemDarkModeToSp(true);
DarkModeUtils.INSTANCE.updateAppDarkModeStatusToSp(true);
DarkModeUtils.INSTANCE.initDarkMode();
}
if (mNewSettingsEntity != null) {
mNewSettingsEntity.setSimulator(mNewSimulatorEntity);
mNewSettingsEntity.setNightMode(mNightModeSetting);
SPUtils.setString(Constants.SP_NEW_SETTINGS, GsonUtils.toJson(data));
}
}
});
}
RetrofitManager.getInstance()
.getApi().getGameGuidePopup(Build.MANUFACTURER, Build.VERSION.RELEASE, Build.MODEL, channel, BuildConfig.VERSION_NAME)
@ -436,34 +420,4 @@ public class Config {
});
}
}
@SuppressLint("CheckResult")
private static void getNewSettings(String channel) {
if (mNewApiSettingsEntity == null) {
String filterString = UrlFilterUtils.getFilterQuery(
"manufacturer", Build.MANUFACTURER,
"model", Build.MODEL,
"android_sdk_version", String.valueOf(Build.VERSION.SDK_INT));
RetrofitManager.getInstance()
.getNewApi().getNewSettings(PackageUtils.getGhVersionName(), channel, filterString)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new BiResponse<NewApiSettingsEntity>() {
@Override
public void onSuccess(NewApiSettingsEntity data) {
mNewApiSettingsEntity = data;
mNightModeSetting = data.getNightMode();
mNewSimulatorEntity = data.getSimulator();
if (HaloApp.getInstance().isNewForThisVersion && mNightModeSetting != null && mNightModeSetting.getInstall()) {
DarkModeUtils.INSTANCE.updateFollowSystemDarkModeToSp(true);
DarkModeUtils.INSTANCE.initDarkMode();
}
AdHelper.prefetchStartUpAd(mNewApiSettingsEntity);
SPUtils.setString(Constants.SP_NEW_API_SETTINGS, GsonUtils.toJson(data));
}
});
}
}
}

View File

@ -21,7 +21,7 @@ import com.gh.gamecenter.R
import com.gh.gamecenter.databinding.KaifuAddItemBinding
import com.gh.gamecenter.databinding.LayoutAddKaifuPopupBinding
import com.gh.gamecenter.databinding.LayoutPopupContainerBinding
import com.gh.gamecenter.feature.entity.ServerCalendarEntity
import com.gh.gamecenter.entity.ServerCalendarEntity
import com.gh.gamecenter.servers.add.AddKaiFuPopupAdapter
import java.text.SimpleDateFormat
import java.util.*

View File

@ -31,6 +31,7 @@ import com.gh.common.chain.PackageCheckHandler;
import com.gh.common.chain.ValidateVSpaceHandler;
import com.gh.common.chain.VersionNumberHandler;
import com.gh.common.constant.Config;
import com.gh.common.exposure.ExposureEvent;
import com.gh.common.filter.RegionSetting;
import com.gh.common.filter.RegionSettingHelper;
import com.gh.common.history.HistoryHelper;
@ -45,7 +46,10 @@ import com.gh.common.util.LogUtils;
import com.gh.common.util.NewsUtils;
import com.gh.common.util.PackageInstaller;
import com.gh.common.util.PackageUtils;
import com.gh.common.util.PlatformUtils;
import com.gh.common.util.ReservationHelper;
import com.gh.common.view.DownloadButton;
import com.gh.common.view.GameIconView;
import com.gh.download.DownloadManager;
import com.gh.download.dialog.DownloadDialog;
import com.gh.gamecenter.DownloadManagerActivity;
@ -53,29 +57,25 @@ import com.gh.gamecenter.R;
import com.gh.gamecenter.WebActivity;
import com.gh.gamecenter.common.baselist.LoadStatus;
import com.gh.gamecenter.common.callback.OnViewClickListener;
import com.gh.gamecenter.common.entity.LinkEntity;
import com.gh.gamecenter.common.eventbus.EBReuse;
import com.gh.gamecenter.common.utils.DarkModeUtils;
import com.gh.gamecenter.common.utils.ExtensionsKt;
import com.gh.gamecenter.common.utils.ImageUtils;
import com.gh.gamecenter.common.utils.DarkModeUtils;
import com.gh.gamecenter.common.view.DrawableView;
import com.gh.gamecenter.core.utils.DisplayUtils;
import com.gh.gamecenter.core.utils.MtaHelper;
import com.gh.gamecenter.core.utils.NumberUtils;
import com.gh.gamecenter.databinding.KaifuDetailItemRowBinding;
import com.gh.gamecenter.feature.entity.ApkEntity;
import com.gh.gamecenter.feature.entity.CommunityVideoEntity;
import com.gh.gamecenter.feature.entity.GameEntity;
import com.gh.gamecenter.feature.entity.PluginLocation;
import com.gh.gamecenter.feature.entity.ServerCalendarEntity;
import com.gh.gamecenter.feature.entity.TagStyleEntity;
import com.gh.gamecenter.feature.entity.TestEntity;
import com.gh.gamecenter.feature.exposure.ExposureEvent;
import com.gh.gamecenter.feature.utils.PlatformUtils;
import com.gh.gamecenter.feature.view.DownloadButton;
import com.gh.gamecenter.feature.view.GameIconView;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.common.entity.LinkEntity;
import com.gh.gamecenter.entity.PluginLocation;
import com.gh.gamecenter.entity.ServerCalendarEntity;
import com.gh.gamecenter.entity.TagStyleEntity;
import com.gh.gamecenter.entity.TestEntity;
import com.gh.gamecenter.common.eventbus.EBReuse;
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment;
import com.gh.gamecenter.manager.PackagesManager;
import com.gh.gamecenter.qa.entity.CommunityVideoEntity;
import com.gh.vspace.VDownloadManagerActivity;
import com.gh.vspace.VHelper;
import com.lightgame.download.DownloadEntity;
@ -261,7 +261,7 @@ public class BindingAdapters {
public static void setGameIcon(View view, GameEntity gameEntity) {
if (gameEntity != null && view instanceof GameIconView) {
((GameIconView) view).displayGameIcon(gameEntity.getIcon(), gameEntity.getIconSubscript(), gameEntity.getIconFloat());
((GameIconView) view).displayGameIcon(gameEntity.getIcon(), gameEntity.getIconSubscript());
}
}
@ -488,7 +488,7 @@ public class BindingAdapters {
case RESERVABLE:
GamePermissionDialogFragment.show((AppCompatActivity) v.getContext(), gameEntity, gameEntity.getInfo(), () -> {
CheckLoginUtils.checkLogin(progressBar.getContext(), "", () -> {
ReservationHelper.reserve(v.getContext(), gameEntity.getId(), gameEntity.getName(), () -> {
ReservationHelper.reserve(v.getContext(), gameEntity.getId(), () -> {
LogUtils.logReservation(gameEntity, traceEvent);
updateReservation(progressBar, gameEntity);
});
@ -593,11 +593,9 @@ public class BindingAdapters {
case pause:
case timeout:
case neterror:
case diskisfull:
case diskioerror:
case waiting:
progressBar.setText(R.string.downloading);
if (downloadEntity.isPluggable() && PackagesManager.isInstalled(downloadEntity.getPackageName())) {
if (downloadEntity.isPluggable() && PackagesManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
progressBar.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN);
} else {
progressBar.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
@ -606,7 +604,7 @@ public class BindingAdapters {
case done:
progressBar.setText(R.string.install);
if (downloadEntity.isPluggable()
&& PackagesManager.isInstalled(downloadEntity.getPackageName())) {
&& PackagesManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
progressBar.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_PLUGIN);
} else {
progressBar.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_NORMAL);
@ -788,21 +786,12 @@ public class BindingAdapters {
public static void setGameName(TextView view, GameEntity game, boolean isShowPlatform, @Nullable Boolean isShowSuffix) {
if (isShowSuffix == null) isShowSuffix = true; // 默认显示
String gameName;
if (isShowPlatform && game.getApk().size() > 0) {
gameName = String.format("%s - %s", !isShowSuffix ? game.getNameWithoutSuffix() : game.getName(),
view.setText(String.format("%s - %s", !isShowSuffix ? game.getNameWithoutSuffix() : game.getName(),
PlatformUtils.getInstance(view.getContext()).getPlatformName(
game.getApk().get(0).getPlatform()));
if (!gameName.equals((String) view.getTag(R.string.tag_game_name_id))) {
view.setText(gameName);
view.setTag(R.string.tag_game_name_id, gameName);
}
game.getApk().get(0).getPlatform())));
} else {
gameName = !isShowSuffix ? game.getNameWithoutSuffix() : game.getName();
if (gameName != null && !gameName.equals((String) view.getTag(R.string.tag_game_name_id))) {
view.setText(gameName);
view.setTag(R.string.tag_game_name_id, gameName);
}
view.setText(!isShowSuffix ? game.getNameWithoutSuffix() : game.getName());
}
}
@ -853,7 +842,7 @@ public class BindingAdapters {
int start = index;
int end = start + tag.getName().length() + ((i != showCount - 1) ? 1 : 0);
index = end;
span.setSpan(new ForegroundColorSpan(ExtensionsKt.hexStringToIntColor("#" + tag.getColor(), Color.WHITE)),
span.setSpan(new ForegroundColorSpan(Color.parseColor("#" + tag.getColor())),
start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
view.setText(span);
@ -861,11 +850,11 @@ public class BindingAdapters {
public static void setVideoData(TextView view, int count) {
if (count > 0) {
ExtensionsKt.setDrawableStart(view, ContextCompat.getDrawable(view.getContext(), R.drawable.ic_video_data_up), null, null);
view.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(view.getContext(), R.drawable.ic_video_data_up), null, null, null);
view.setTextColor(ContextCompat.getColor(view.getContext(), R.color.text_EA3333));
view.setText(count + "");
} else {
ExtensionsKt.removeDrawable(view);
view.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
view.setTextColor(ContextCompat.getColor(view.getContext(), R.color.text_subtitleDesc));
view.setText("-");
}

View File

@ -22,12 +22,11 @@ import com.gh.gamecenter.R
import com.gh.gamecenter.ShellActivity
import com.gh.gamecenter.common.callback.ConfirmListener
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.utils.SensorsBridge
import com.gh.gamecenter.core.utils.GsonUtils
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.feature.entity.AuthDialogEntity
import com.gh.gamecenter.feature.entity.AuthDialogLevel
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.entity.AuthDialogEntity
import com.gh.gamecenter.entity.AuthDialogLevel
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.login.user.UserManager
import com.google.gson.reflect.TypeToken
import com.halo.assistant.fragment.user.UserInfoEditFragment
@ -36,7 +35,7 @@ import com.lightgame.utils.AppManager
class CertificationDialog(
context: Context,
private val authDialogEntity: AuthDialogEntity,
val gameEntity: GameEntity,
val gameId: String,
val listener: ConfirmListener
) :
Dialog(context, R.style.GhAlertDialog) {
@ -70,11 +69,9 @@ class CertificationDialog(
actionRightTv.text = "去实名认证"
noRemindAgainCb.visibility = View.GONE
actionLeftTv.setOnClickListener {
SensorsBridge.trackEvent("VerificationPopupClick", "button_name", actionLeftTv.text.toString())
dismiss()
}
actionRightTv.setOnClickListener {
SensorsBridge.trackEvent("VerificationPopupClick", "button_name", actionRightTv.text.toString())
if (UserManager.getInstance().isLoggedIn) {
gotoAuthPage()
} else {
@ -87,7 +84,6 @@ class CertificationDialog(
actionRightTv.text = "继续下载"
noRemindAgainCb.visibility = View.GONE
actionLeftTv.setOnClickListener {
SensorsBridge.trackEvent("VerificationPopupClick", "button_name", actionLeftTv.text.toString())
if (UserManager.getInstance().isLoggedIn) {
gotoAuthPage()
} else {
@ -95,7 +91,6 @@ class CertificationDialog(
}
}
actionRightTv.setOnClickListener {
SensorsBridge.trackEvent("VerificationPopupClick", "button_name", actionRightTv.text.toString())
listener.onConfirm()
dismiss()
}
@ -105,9 +100,8 @@ class CertificationDialog(
actionRightTv.text = "继续下载"
noRemindAgainCb.visibility = View.VISIBLE
actionLeftTv.setOnClickListener {
SensorsBridge.trackEvent("VerificationPopupClick", "button_name", actionLeftTv.text.toString())
if (noRemindAgainCb.isChecked) {
SPUtils.setBoolean(gameEntity.id, true)
SPUtils.setBoolean(gameId, true)
}
if (UserManager.getInstance().isLoggedIn) {
gotoAuthPage()
@ -116,25 +110,14 @@ class CertificationDialog(
}
}
actionRightTv.setOnClickListener {
SensorsBridge.trackEvent("VerificationPopupClick", "button_name", actionRightTv.text.toString())
if (noRemindAgainCb.isChecked) {
SPUtils.getBoolean(gameEntity.id, true)
SPUtils.getBoolean(gameId, true)
}
listener.onConfirm()
dismiss()
}
}
}
SensorsBridge.trackEvent(
"VerificationDialogShow",
"game_id",
gameEntity.id,
"game_name",
gameEntity.name ?: "",
"game_type",
gameEntity.categoryChinese
)
}
//跳转登录页面
@ -162,7 +145,7 @@ class CertificationDialog(
context,
ShellActivity.Type.REAL_NAME_INFO,
).apply {
putExtra(EntranceConsts.KEY_GAME_ID, gameEntity.id)
putExtra(EntranceConsts.KEY_GAME_ID, gameId)
}, object : Callback {
override fun onActivityResult(resultCode: Int, data: Intent?) {
if (resultCode == Activity.RESULT_OK && data != null) {
@ -211,7 +194,7 @@ class CertificationDialog(
}
val isCloseAuthDialog = SPUtils.getBoolean(game.id, false)
if (authDialog != null && (authDialog.level != AuthDialogLevel.OPTIONAL_HINT.value || !isCloseAuthDialog)) {
val dialog = CertificationDialog(context, authDialog, game, listener)
val dialog = CertificationDialog(context, authDialog, game.id, listener)
dialog.show()
} else {
listener.onConfirm()

View File

@ -28,7 +28,8 @@ import com.gh.gamecenter.core.utils.GsonUtils
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.databinding.DialogDeviceRemindBinding
import com.gh.gamecenter.entity.DeviceDialogEntity
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.setting.compose.activity.ComposeGameDownloadSettingActivity
import com.google.gson.reflect.TypeToken
import com.lightgame.download.DataWatcher
import com.lightgame.download.DownloadEntity
@ -52,7 +53,7 @@ class DeviceRemindDialog(context: Context, val entity: DeviceDialogEntity, val g
private val dataWatcher = object : DataWatcher() {
override fun onDataChanged(downloadEntity: DownloadEntity) {
if (downloadEntity.status == DownloadStatus.done && downloadEntity.name == gameEntity.name) {
val autoInstall = SPUtils.getBoolean(Constants.SP_AUTO_INSTALL, true)
val autoInstall = SPUtils.getBoolean(ComposeGameDownloadSettingActivity.AUTO_INSTALL_SP_KEY, true)
if (autoInstall) {
dismiss()
}

View File

@ -16,7 +16,7 @@ import com.gh.gamecenter.common.utils.dip2px
import com.gh.gamecenter.common.utils.toColor
import com.gh.gamecenter.R
import com.gh.gamecenter.databinding.DialogGameOffServiceBinding
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.entity.GameEntity
// 游戏关闭下载弹窗
class GameOffServiceDialogFragment : BaseDialogFragment() {

View File

@ -13,7 +13,6 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentTransaction
import com.airbnb.lottie.LottieAnimationView
import com.gh.common.constant.Config
import com.gh.common.util.NewFlatLogUtils
import com.gh.common.xapk.XapkInstaller
import com.gh.gamecenter.R
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
@ -32,8 +31,6 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
lateinit var mView: View
var isXapk = false
var url: String = ""
var gameId: String = ""
var gameName: String = ""
var mCallBack: ((isFromPermissionGrantedCallback: Boolean) -> Unit)? = null
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
@ -53,8 +50,6 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
switchLottie.setAnimation("lottie/install_permission_switch.json")
switchLottie.playAnimation()
if (isXapk) NewFlatLogUtils.logXApkInstallPermissionDialogShowed(gameId, gameName)
val randomNumber = if (isXapk) 1 else Random.nextInt(2)
closeTv.goneIf(randomNumber == 0)
closeIv.goneIf(randomNumber != 0)
@ -65,17 +60,14 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
closeTv.setOnClickListener {
if (isXapk) {
NewFlatLogUtils.logXApkInstallPermissionDialogClick("尝试解压", false, gameId, gameName)
mCallBack?.invoke(false)
}
dismiss()
}
closeIv.setOnClickListener {
if (isXapk) NewFlatLogUtils.logXApkInstallPermissionDialogClick("关闭", false, gameId, gameName)
dismiss()
}
activateTv.setOnClickListener {
NewFlatLogUtils.logXApkInstallPermissionDialogClick("立即开启", false, gameId, gameName)
PermissionHelper.toInstallPermissionSetting(requireActivity())
if (isXapk) {
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, requireActivity().javaClass.name)
@ -87,8 +79,6 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == RESULT_OK && requestCode == INSTALL_PERMISSION_CODE) {
NewFlatLogUtils.logXApkInstallPermissionDialogClick("立即开启", true, gameId, gameName)
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, "")
SPUtils.setString(Constants.SP_XAPK_URL, "")
@ -134,8 +124,6 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
installPermissionDialogFragment.mCallBack = callBack
installPermissionDialogFragment.isXapk = isXapk
installPermissionDialogFragment.url = downloadEntity.url
installPermissionDialogFragment.gameId = downloadEntity.gameId
installPermissionDialogFragment.gameName = downloadEntity.name
val transaction: FragmentTransaction = activity.supportFragmentManager.beginTransaction()
transaction.show(installPermissionDialogFragment)
transaction.commit()
@ -144,8 +132,6 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
this.mCallBack = callBack
this.isXapk = isXapk
this.url = downloadEntity.url
this.gameId = downloadEntity.gameId
this.gameName = downloadEntity.name
}
installPermissionDialogFragment.show(
activity.supportFragmentManager,

View File

@ -13,11 +13,13 @@ import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentTransaction
import com.gh.common.util.DirectUtils
import com.gh.gamecenter.R
import com.gh.gamecenter.WebActivity
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
import com.gh.gamecenter.common.utils.dip2px
import com.gh.gamecenter.common.view.CustomLinkMovementMethod
import com.gh.gamecenter.databinding.DialogPrivacyProtocolNewBinding
import com.gh.gamecenter.entity.DialogEntity
import splitties.bundle.put
class NewPrivacyPolicyDialogFragment : BaseDialogFragment() {
@ -159,7 +161,7 @@ class NewPrivacyPolicyDialogFragment : BaseDialogFragment() {
}
}
privacyDialogFragment.arguments = Bundle().apply {
putParcelable(KEY_DATA, privacyPolicyEntity)
put(KEY_DATA, privacyPolicyEntity)
}
privacyDialogFragment.show(
activity.supportFragmentManager,

View File

@ -31,9 +31,9 @@ import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.core.utils.SpanBuilder
import com.gh.gamecenter.databinding.FragmentPackageCheckBinding
import com.gh.gamecenter.databinding.PackageCheckItemBinding
import com.gh.gamecenter.feature.entity.DetectionObjectEntity
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.PackageDialogEntity
import com.gh.gamecenter.entity.DetectionObjectEntity
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.entity.PackageDialogEntity
import com.gh.gamecenter.eventbus.EBPackage
import com.halo.assistant.HaloApp
import com.lightgame.adapter.BaseRecyclerAdapter
@ -303,7 +303,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
//安装、卸载事件
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEventMainThread(busFour: EBPackage) {
if (busFour.isInstalledOrUninstalled()) {
if ("安装" == busFour.type || "卸载" == busFour.type) {
mAllInstalledPackages = PackageUtils.getInstalledPackages(HaloApp.getInstance().application, 0)
mAdapter?.notifyDataSetChanged()
}

View File

@ -23,6 +23,7 @@ import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.databinding.DialogPrivacyProtocolBinding
import com.gh.gamecenter.entity.DialogEntity
import com.lightgame.utils.AppManager
import splitties.bundle.put
class PrivacyPolicyDialogFragment : BaseDialogFragment() {
@ -183,7 +184,7 @@ class PrivacyPolicyDialogFragment : BaseDialogFragment() {
}
}
privacyDialogFragment.arguments = Bundle().apply {
putParcelable(KEY_DATA, privacyPolicyEntity)
put(KEY_DATA, privacyPolicyEntity)
}
privacyDialogFragment.show(
activity.supportFragmentManager,

View File

@ -15,7 +15,7 @@ import com.gh.gamecenter.R
import com.gh.gamecenter.common.view.FixLinearLayoutManager
import com.gh.gamecenter.databinding.DialogReserveBinding
import com.gh.gamecenter.databinding.DialogReserveItemBinding
import com.gh.gamecenter.common.entity.SimpleGameEntity
import com.gh.gamecenter.entity.SimpleGameEntity
import com.gh.gamecenter.mygame.MyGameActivity
import com.lightgame.adapter.BaseRecyclerAdapter

View File

@ -1,19 +1,16 @@
package com.gh.gamecenter.feature.exposure
package com.gh.common.exposure
import android.os.Parcelable
import androidx.annotation.Keep
import androidx.room.PrimaryKey
import com.alibaba.android.arouter.launcher.ARouter
import com.gh.common.exposure.time.TimeUtil
import com.gh.download.server.BrowserInstallHelper
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.common.entity.ExposureEntity
import com.gh.gamecenter.common.exposure.meta.Meta
import com.gh.gamecenter.common.exposure.meta.MetaUtil
import com.gh.gamecenter.common.utils.getFirstElementDividedByDivider
import com.gh.gamecenter.core.provider.IBrowserInstallHelperProvider
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.time.TimeUtil
import com.gh.gamecenter.feature.provider.IRegionSettingHelperProvider
import com.gh.gamecenter.entity.GameEntity
import com.lightgame.download.DownloadEntity
import com.lightgame.utils.Utils
import kotlinx.parcelize.IgnoredOnParcel
@ -32,7 +29,7 @@ data class ExposureEvent(
var timeInMillisecond: Long = System.currentTimeMillis(),
@PrimaryKey
var id: String = UUID.randomUUID().toString(),
) : Parcelable, Cloneable {
) : Parcelable {
@Transient
@IgnoredOnParcel
@ -48,42 +45,33 @@ data class ExposureEvent(
eTrace: List<ExposureEvent>? = null,
event: ExposureType = ExposureType.EXPOSURE
) {
if (gameEntity?.adIconActive == true) {
gameEntity.isAdData = true
}
val browserInstallHelper = ARouter.getInstance().build(RouteConsts.provider.browserInstallHelper)
.navigation() as? IBrowserInstallHelperProvider
val regionSettingHelper = ARouter.getInstance().build(RouteConsts.provider.regionSettingHelper)
.navigation() as? IRegionSettingHelperProvider
val firstTracePayload = eTrace?.firstOrNull()?.payload
this.payload = ExposureEntity(
gameId = gameEntity?.id?.getFirstElementDividedByDivider(DownloadEntity.GAME_ID_DIVIDER),
gameName = if (!firstTracePayload?.gameName.isNullOrEmpty()) {
firstTracePayload?.gameName
} else {
gameEntity?.name?.removeSuffix(Constants.GAME_NAME_DECORATOR)
},
gameVersion = firstTracePayload?.gameVersion ?: gameEntity?.gameVersion,
subjectId = firstTracePayload?.subjectId ?: gameEntity?.subjectId ?: gameEntity?.subjectData?.id,
isMirrorData = firstTracePayload?.isMirrorData ?: gameEntity?.shouldUseMirrorInfo() ?: false,
isWebDownload = (browserInstallHelper?.isUseBrowserToInstallEnabled()
?: false) && browserInstallHelper?.shouldUseBrowserToInstall() ?: false, // 实时的值,不用从 eTrace 里取
sequence = firstTracePayload?.sequence ?: gameEntity?.sequence,
outerSequence = firstTracePayload?.outerSequence ?: gameEntity?.outerSequence,
platform = firstTracePayload?.platform ?: gameEntity?.platform,
gameName = eTrace?.firstOrNull()?.payload?.gameName
?: gameEntity?.name?.removeSuffix(Constants.GAME_NAME_DECORATOR),
gameVersion = eTrace?.firstOrNull()?.payload?.gameVersion
?: gameEntity?.gameVersion,
subjectId = eTrace?.firstOrNull()?.payload?.subjectId
?: gameEntity?.subjectId
?: gameEntity?.subjectData?.id,
isMirrorData = eTrace?.firstOrNull()?.payload?.isMirrorData
?: gameEntity?.shouldUseMirrorInfo() ?: false,
isWebDownload = BrowserInstallHelper.isUseBrowserToInstallEnabled() && BrowserInstallHelper.shouldUseBrowserToInstall(), // 实时的值,不用从 eTrace 里取
sequence = eTrace?.firstOrNull()?.payload?.sequence ?: gameEntity?.sequence,
outerSequence = eTrace?.firstOrNull()?.payload?.outerSequence
?: gameEntity?.outerSequence,
platform = eTrace?.firstOrNull()?.payload?.platform ?: gameEntity?.platform,
downloadType = gameEntity?.downloadType,
downloadCompleteType = gameEntity?.downloadCompleteType,
displayType = firstTracePayload?.displayType ?: gameEntity?.displayContent,
displayType = eTrace?.firstOrNull()?.payload?.displayType
?: gameEntity?.displayContent,
isPlatformRecommend = gameEntity?.isPlatformRecommend,
// ugly
welcomeDialogId = gameEntity?.welcomeDialogId ?: firstTracePayload?.welcomeDialogId,
welcomeDialogLinkTitle = gameEntity?.welcomeDialogTitle ?: firstTracePayload?.welcomeDialogLinkTitle,
isAdData = gameEntity?.isAdData ?: firstTracePayload?.isAdData ?: false,
country = regionSettingHelper?.getIpInfo()?.country ?: "",
province = regionSettingHelper?.getIpInfo()?.province ?: "",
city = regionSettingHelper?.getIpInfo()?.city ?: ""
welcomeDialogId = gameEntity?.welcomeDialogId
?: eTrace?.firstOrNull()?.payload?.welcomeDialogId,
welcomeDialogLinkTitle = gameEntity?.welcomeDialogTitle
?: eTrace?.firstOrNull()?.payload?.welcomeDialogLinkTitle,
isAdData = gameEntity?.adIconActive ?: eTrace?.firstOrNull()?.payload?.isAdData ?: false
)
this.id = UUID.randomUUID().toString()
this.timeInMillisecond = System.currentTimeMillis()
@ -92,19 +80,19 @@ data class ExposureEvent(
this.eTrace = eTrace
this.event = event
this.also {
it.payload.categoryId = firstTracePayload?.categoryId
it.payload.categoryV2Id = firstTracePayload?.categoryV2Id
it.payload.testServerId = firstTracePayload?.testServerId
it.payload.blockId = firstTracePayload?.blockId
it.payload.categoryId = eTrace?.firstOrNull()?.payload?.categoryId
it.payload.categoryV2Id = eTrace?.firstOrNull()?.payload?.categoryV2Id
it.payload.testServerId = eTrace?.firstOrNull()?.payload?.testServerId
it.payload.blockId = eTrace?.firstOrNull()?.payload?.blockId
it.payload.setContainerInfo(
firstTracePayload?.containerId ?: gameEntity?.containerId,
firstTracePayload?.containerType ?: gameEntity?.containerType
eTrace?.firstOrNull()?.payload?.containerId ?: gameEntity?.containerId,
eTrace?.firstOrNull()?.payload?.containerType ?: gameEntity?.containerType
)
it.payload.sourcePage = firstTracePayload?.sourcePage
it.payload.sourcePageId = firstTracePayload?.sourcePageId
it.payload.sourcePageName = firstTracePayload?.sourcePageName
it.payload.sourcePage = eTrace?.firstOrNull()?.payload?.sourcePage
it.payload.sourcePageId = eTrace?.firstOrNull()?.payload?.sourcePageId
it.payload.sourcePageName = eTrace?.firstOrNull()?.payload?.sourcePageName
gameEntity?.exposureEvent = it
}
}
@ -136,10 +124,6 @@ data class ExposureEvent(
return flags == FLAG_IN_USE
}
fun deepCopy(): ExposureEvent {
return super.clone() as ExposureEvent
}
companion object {
private val sPoolSync = Any()
private var sPool: ExposureEvent? = null

View File

@ -4,7 +4,6 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.gh.gamecenter.feature.exposure.ExposureEvent
import io.reactivex.functions.Consumer
/**

View File

@ -5,8 +5,6 @@ import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.common.loghub.LoghubHelper
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
/**
@ -31,13 +29,11 @@ object ExposureManager {
* Log a single exposure event.
*/
fun log(event: ExposureEvent) {
AppExecutor.logExecutor.execute {
if (!exposureCache.contains(event.id)) {
exposureSet.add(event)
exposureCache.add(event.id)
} else {
Utils.log("Exposure", "遇到重复曝光事件,自动过滤 ${event.id} - ${event.payload.gameName}")
}
if (!exposureCache.contains(event.id)) {
exposureSet.add(event)
exposureCache.add(event.id)
} else {
Utils.log("Exposure", "遇到重复曝光事件,自动过滤 ${event.id} - ${event.payload.gameName}")
}
}
@ -45,39 +41,35 @@ object ExposureManager {
* Log a collection of exposure event.
*/
fun log(eventList: List<ExposureEvent>) {
AppExecutor.logExecutor.execute {
for (event in eventList) {
if (!exposureCache.contains(event.id)) {
exposureSet.add(event)
exposureCache.add(event.id)
} else {
Utils.log("Exposure", "遇到重复曝光事件,自动过滤 ${event.id} - ${event.payload.gameName}")
}
for (event in eventList) {
if (!exposureCache.contains(event.id)) {
exposureSet.add(event)
exposureCache.add(event.id)
} else {
Utils.log("Exposure", "遇到重复曝光事件,自动过滤 ${event.id} - ${event.payload.gameName}")
}
commitSavedExposureEvents()
}
commitSavedExposureEvents()
}
/**
* @param forcedUpload Ignore all restrictions.
*/
fun commitSavedExposureEvents(forcedUpload: Boolean = false) {
AppExecutor.logExecutor.execute {
if (exposureSet.size < STORE_SIZE && !forcedUpload || exposureSet.size == 0) return@execute
if (exposureSet.size < STORE_SIZE && !forcedUpload || exposureSet.size == 0) return
uploadExposures(exposureSet, forcedUpload)
uploadExposures(exposureSet.toList(), forcedUpload)
Utils.log("Exposure", "提交了${exposureSet.size}条曝光记录")
exposureSet.clear()
}
Utils.log("Exposure", "提交了${exposureSet.size}条曝光记录")
exposureSet.clear()
}
private fun eliminateMultipleBrackets(jsonWithMultipleBracket: String): String {
return jsonWithMultipleBracket.replace("[[", "[").replace("]]", "]")
}
private fun uploadExposures(eventSet: HashSet<ExposureEvent>, forced: Boolean) {
eventSet.forEach {
private fun uploadExposures(eventList: List<ExposureEvent>, forced: Boolean) {
eventList.forEach {
LoghubHelper.uploadLog(buildLog(it), LOG_STORE, forced)
it.recycle()
}
@ -95,6 +87,7 @@ object ExposureManager {
eliminateMultipleBrackets(event.eTrace?.toJson() ?: "")
} else ""
)
logTime = event.time.toLong()
}
}

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.feature.exposure
package com.gh.common.exposure
import android.os.Parcelable
import androidx.annotation.Keep
@ -6,4 +6,4 @@ import kotlinx.parcelize.Parcelize
@Keep
@Parcelize
class ExposureSource(var k: String, var v: String = "") : Parcelable
data class ExposureSource(var k: String, var v: String = "") : Parcelable

View File

@ -1,20 +1,16 @@
package com.gh.common.exposure
import com.gh.gamecenter.feature.exposure.ExposureEvent
object ExposureTraceUtils {
fun appendTrace(event: ExposureEvent?): List<ExposureEvent> {
val traceList = arrayListOf<ExposureEvent>()
event?.let {
//这里使用deepCopy是为了防止循环引用调用hashCode方法触发StackOverflowError错误
val deepCopy = it.deepCopy()
if (deepCopy.eTrace == null) {
traceList.add(deepCopy)
if (event.eTrace == null) {
traceList.add(event)
} else {
traceList.addAll(deepCopy.eTrace!!)
traceList.add(flattenTrace(deepCopy))
traceList.addAll(event.eTrace!!)
traceList.add(flattenTrace(event))
}
}

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.feature.exposure
package com.gh.common.exposure
enum class ExposureType {
EXPOSURE,

View File

@ -5,10 +5,8 @@ import com.g00fy2.versioncompare.Version
import com.gh.common.util.PackageUtils
import com.gh.gamecenter.common.utils.FixedSizeLinkedHashSet
import com.gh.gamecenter.common.utils.toObject
import com.gh.gamecenter.feature.entity.ApkEntity
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.ExposureType
import com.gh.gamecenter.entity.ApkEntity
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.manager.PackagesManager
import com.halo.assistant.HaloApp
import com.lightgame.download.DownloadEntity
@ -24,15 +22,12 @@ object ExposureUtils {
traceEvent: ExposureEvent?,
downloadType: DownloadType
): ExposureEvent {
val gameEntity = entity.copy()
val gameEntity = entity.clone()
gameEntity.id = if (entity.id.contains(DownloadEntity.GAME_ID_DIVIDER)) {
entity.id.split(DownloadEntity.GAME_ID_DIVIDER).toTypedArray()[0]
} else {
entity.id
}
traceEvent ?: gameEntity.exposureEvent
gameEntity.gameVersion = entity.getApk().elementAtOrNull(0)?.version
?: gameEntity.gameVersion
gameEntity.platform = platform
@ -54,12 +49,11 @@ object ExposureUtils {
entity: GameEntity,
platform: String?,
trace: String?,
speed: Long,
host: String? = "unknown",
path: String? = "unknown",
downloadType: DownloadType
) {
val gameEntity = entity.copy()
val gameEntity = entity.clone()
gameEntity.platform = platform
gameEntity.downloadCompleteType = downloadType.toString()
val traceEvent = trace?.toObject<ExposureEvent>()
@ -81,8 +75,6 @@ object ExposureUtils {
)
exposureEvent.payload.host = host
exposureEvent.payload.path = path
exposureEvent.payload.speed = speed
ExposureManager.log(exposureEvent)
ExposureManager.commitSavedExposureEvents(forcedUpload = true)
}

View File

@ -1,7 +1,5 @@
package com.gh.common.exposure
import com.gh.gamecenter.feature.exposure.ExposureEvent
/**
* 统计曝光的列表的 adapter 需要实现这个接口
*/

View File

@ -0,0 +1,15 @@
package com.gh.common.exposure.time
import com.gh.common.FixedRateJobHelper
object TimeUtil {
fun currentTimeMillis(): Long {
return FixedRateJobHelper.timeDeltaBetweenServerAndClient + System.currentTimeMillis()
}
fun currentTime(): Int {
return ((FixedRateJobHelper.timeDeltaBetweenServerAndClient + System.currentTimeMillis()) / 1000).toInt()
}
}

View File

@ -1,11 +1,10 @@
package com.gh.common.filter
import androidx.annotation.Keep
import com.gh.gamecenter.feature.entity.IpInfo
import com.google.gson.annotations.SerializedName
@Keep
class RegionSetting(
data class RegionSetting(
@SerializedName("game_mirror")
var mirrorGameIdSet: HashSet<String>,
@SerializedName("game_block")
@ -15,13 +14,11 @@ class RegionSetting(
@SerializedName("game_h5_download")
var gameH5DownloadList: List<GameH5Download>,
@SerializedName("game_special_download")
var gameSpecialDownloadInfoList: List<GameSpecialDownloadInfo>,
@SerializedName("ip_info")
var ipInfo: IpInfo? = null
var gameSpecialDownloadInfoList: List<GameSpecialDownloadInfo>
) {
@Keep
class ChannelControl(
data class ChannelControl(
@SerializedName("game_category")
var gameCategory: String,
@SerializedName("effect")
@ -29,7 +26,7 @@ class RegionSetting(
)
@Keep
class GameH5Download(
data class GameH5Download(
@SerializedName("game_id")
var gameId: String,// 游戏id
@SerializedName("h5_link")
@ -40,7 +37,7 @@ class RegionSetting(
var buttonText: String,// 按钮文案
)
class GameSpecialDownloadInfo(
data class GameSpecialDownloadInfo(
@SerializedName("game_id")
var gameId: String = "",
@SerializedName("bbs_id")

View File

@ -1,16 +1,14 @@
package com.gh.common.filter
import android.annotation.SuppressLint
import com.gh.gamecenter.R
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.retrofit.BiResponse
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.common.utils.debounceActionWithInterval
import com.gh.gamecenter.common.utils.toJson
import com.gh.gamecenter.common.utils.toObject
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.IpInfo
import com.gh.gamecenter.feature.entity.SimpleGame
import com.gh.gamecenter.R
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.common.retrofit.BiResponse
import com.gh.gamecenter.retrofit.RetrofitManager
import com.halo.assistant.HaloApp
import io.reactivex.functions.Function
@ -18,20 +16,14 @@ import io.reactivex.schedulers.Schedulers
object RegionSettingHelper {
// 是否是初始化调用
private var mIsInit = true
private var mChannelControl: RegionSetting.ChannelControl? = null
private var mFilterGameIdSet: HashSet<String>? = hashSetOf()
private var mDisplayMirrorIfoGameIdSet: HashSet<String>? = hashSetOf()
private var mGameH5DownloadList: List<RegionSetting.GameH5Download>? = listOf()
private var mGameSpecialDownloadInfoList: List<RegionSetting.GameSpecialDownloadInfo>? = listOf()
private var mIpInfo: IpInfo? = null
private const val SP_SETTING = "region_setting"
const val SP_SETTING_FAILURE = "region_setting_failure"
@JvmStatic
fun shouldThisGameDisplayMirrorInfo(gameId: String): Boolean {
return mDisplayMirrorIfoGameIdSet?.contains(gameId) ?: false
}
@ -47,8 +39,6 @@ object RegionSettingHelper {
@JvmStatic
fun getGameSpecialDownloadInfo(gameId: String) = mGameSpecialDownloadInfoList?.find { it.gameId == gameId }
fun getIpInfo(): IpInfo? = mIpInfo
@JvmStatic
fun filterGame(list: List<GameEntity>?): ArrayList<GameEntity> {
if (list == null) return arrayListOf()
@ -62,19 +52,6 @@ object RegionSettingHelper {
return listCopy
}
@JvmStatic
fun filterSimpleGame(list: List<SimpleGame>?): ArrayList<SimpleGame> {
if (list == null) return arrayListOf()
if (mFilterGameIdSet?.isEmpty() == true) {
if (list is ArrayList) return list
}
val listCopy: ArrayList<SimpleGame> = if (list is ArrayList) list else ArrayList(list)
listCopy.removeAll { mFilterGameIdSet?.contains(it.id) ?: false }
return listCopy
}
@JvmField
var filterGame = Function { list: List<GameEntity> ->
filterGame(list)
@ -99,15 +76,6 @@ object RegionSettingHelper {
@JvmStatic
fun getRegionSetting() {
debounceActionWithInterval(R.string.app_name, 5000) {
// 初始启动时先使用历史数据
if (mIsInit) {
SPUtils.getString(SP_SETTING).toObject<RegionSetting>()?.let {
updateSettingsInMemory(it)
}
mIsInit = false
}
// 使用默认的 Schdulers.io() 可能会触发 OOM
RetrofitManager.getInstance()
.api
@ -120,10 +88,9 @@ object RegionSettingHelper {
}
override fun onFailure(exception: Exception) {
SPUtils.getString(SP_SETTING).toObject<RegionSetting>()?.let {
SPUtils.getString(SP_SETTING)?.toObject<RegionSetting>()?.let {
updateSettingsInMemory(it)
}
SPUtils.setBoolean(SP_SETTING_FAILURE, true)
}
})
}
@ -135,7 +102,6 @@ object RegionSettingHelper {
mChannelControl = data.channelControl
mGameH5DownloadList = data.gameH5DownloadList
mGameSpecialDownloadInfoList = data.gameSpecialDownloadInfoList
mIpInfo = data.ipInfo
}
/**

View File

@ -9,17 +9,16 @@ import androidx.sqlite.db.SupportSQLiteDatabase
import com.gh.gamecenter.entity.GamesCollectionEntity
import com.gh.gamecenter.entity.HistoryGameEntity
import com.gh.gamecenter.entity.MyVideoEntity
import com.gh.gamecenter.feature.entity.NewsEntity
import com.gh.gamecenter.feature.entity.AnswerEntity
import com.gh.gamecenter.feature.entity.ArticleEntity
import com.gh.gamecenter.feature.room.converter.*
import com.gh.gamecenter.entity.NewsEntity
import com.gh.gamecenter.qa.entity.AnswerEntity
import com.gh.gamecenter.qa.entity.ArticleEntity
import com.gh.gamecenter.room.converter.*
import com.gh.gamecenter.room.dao.*
import com.halo.assistant.HaloApp
@Database(
entities = [AnswerEntity::class, ArticleEntity::class, NewsEntity::class, HistoryGameEntity::class, MyVideoEntity::class, GamesCollectionEntity::class],
version = 13,
version = 11,
exportSchema = false
)
@TypeConverters(
@ -29,7 +28,6 @@ import com.halo.assistant.HaloApp
AnswerUserConverter::class,
ThumbnailConverter::class,
TagStyleListConverter::class,
TagStyleConverter::class,
StringArrayListConverter::class,
ListStringConverter::class,
CommunityVideoConverter::class,
@ -40,8 +38,7 @@ import com.halo.assistant.HaloApp
MeConverter::class,
SimpleGameListConverter::class,
TagInfoListConverter::class,
ActivityLabelListConverter::class,
IconFloatConverter::class
ActivityLabelListConverter::class
)
abstract class HistoryDatabase : RoomDatabase() {
@ -130,19 +127,6 @@ abstract class HistoryDatabase : RoomDatabase() {
}
}
val MIGRATION_11_12: Migration = object : Migration(11, 12) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("Alter TABLE HistoryGameEntity add subtitle TEXT NOT NULL DEFAULT ''")
database.execSQL("Alter TABLE HistoryGameEntity add subtitleStyle TEXT")
}
}
val MIGRATION_12_13: Migration = object : Migration(12, 13) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("Alter TABLE HistoryGameEntity add iconFloat TEXT")
}
}
val instance by lazy {
Room.databaseBuilder(
HaloApp.getInstance().application,
@ -158,8 +142,6 @@ abstract class HistoryDatabase : RoomDatabase() {
.addMigrations(MIGRATION_8_9)
.addMigrations(MIGRATION_9_10)
.addMigrations(MIGRATION_10_11)
.addMigrations(MIGRATION_11_12)
.addMigrations(MIGRATION_12_13)
.build()
}
}

View File

@ -6,12 +6,10 @@ import com.gh.gamecenter.common.utils.removeVideoContent
import com.gh.gamecenter.common.utils.tryCatchInRelease
import com.gh.gamecenter.core.runOnIoThread
import com.gh.gamecenter.entity.*
import com.gh.gamecenter.feature.entity.AnswerEntity
import com.gh.gamecenter.feature.entity.ArticleEntity
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.NewsEntity
import com.gh.gamecenter.qa.entity.AnswerDetailEntity
import com.gh.gamecenter.qa.entity.AnswerEntity
import com.gh.gamecenter.qa.entity.ArticleDetailEntity
import com.gh.gamecenter.qa.entity.ArticleEntity
object HistoryHelper {
@ -56,7 +54,6 @@ object HistoryHelper {
historyGame.des = ""
historyGame.icon = updateEntity.rawIcon ?: updateEntity.icon
historyGame.iconSubscript = updateEntity.iconSubscript
historyGame.iconFloat = updateEntity.iconFloat
historyGame.name = updateEntity.name
historyGame.tagStyle = updateEntity.tagStyle
return historyGame
@ -71,12 +68,9 @@ object HistoryHelper {
historyGame.des = gameEntity.des
historyGame.icon = gameEntity.rawIcon ?: gameEntity.icon
historyGame.iconSubscript = gameEntity.iconSubscript
historyGame.iconFloat = gameEntity.iconFloat
historyGame.name = gameEntity.name
historyGame.tagStyle = gameEntity.tagStyle
historyGame.tag = gameEntity.getTag()
historyGame.subtitle = gameEntity.subtitle
historyGame.subtitleStyle = gameEntity.subtitleStyle
return historyGame
}

View File

@ -1,19 +0,0 @@
package com.gh.common.provider
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.common.util.AdHelper
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.feature.entity.SettingsEntity
import com.gh.gamecenter.feature.provider.IAdHelperProvider
@Route(path = RouteConsts.provider.adHelper, name = "AdHelper暴露服务")
class AdHelperProviderImpl : IAdHelperProvider {
override fun getSuggestionFunctionAd(): SettingsEntity.AD? {
return AdHelper.getAd(AdHelper.LOCATION_SUGGESTION_FUNCTION)
}
override fun init(context: Context?) {
// Do nothing
}
}

View File

@ -5,7 +5,6 @@ import com.alibaba.android.arouter.facade.annotation.Route
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.halo.assistant.HaloApp
@Route(path = RouteConsts.provider.app, name = "Application暴露服务")
@ -57,20 +56,4 @@ class AppProviderImpl : IAppProvider {
override fun isUserAcceptPrivacyPolicy(context: Context): Boolean {
return HaloApp.isUserAcceptPrivacyPolicy(context)
}
override fun put(key: String, any: Any) {
HaloApp.put(key, any)
}
override fun get(key: String, isRemove: Boolean): Any? {
return HaloApp.get(key, isRemove)
}
override fun getFlavorProvider(): IFlavorProvider {
return HaloApp.getInstance().flavorProvider
}
override fun getIsBrandNewInstall(): Boolean {
return HaloApp.getInstance().isBrandNewInstall
}
}

View File

@ -1,30 +0,0 @@
package com.gh.common.provider
import android.content.Context
import android.widget.LinearLayout
import android.widget.TextView
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.common.databind.BindingAdapters
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.provider.IBindingAdaptersProvider
@Route(path = RouteConsts.provider.bindingAdapters, name = "BindingAdapters暴露服务")
class BindingAdaptersProviderImpl : IBindingAdaptersProvider {
override fun setGameName(
view: TextView,
game: GameEntity,
isShowPlatform: Boolean,
isShowSuffix: Boolean
) {
BindingAdapters.setGameName(view, game, isShowPlatform, isShowSuffix)
}
override fun setGameTags(layout: LinearLayout, gameEntity: GameEntity) {
BindingAdapters.setGameTags(layout, gameEntity)
}
override fun init(context: Context?) {
// Do nothing
}
}

View File

@ -60,14 +60,6 @@ class ConfigProviderImpl : IConfigProvider {
return Config.getSettings()?.support?.qq ?: ""
}
override fun getQQun(): String {
return Config.getSettings()?.support?.qQun ?: ""
}
override fun getQQunKey(): String {
return Config.getSettings()?.support?.qQunKey ?: ""
}
override fun getQuickLoginAppId(): String {
return Config.QUICK_LOGIN_APPID
}
@ -84,10 +76,6 @@ class ConfigProviderImpl : IConfigProvider {
return Config.getNightModeSetting()?.setting ?: false
}
override fun isShowPlugin(gameId: String): Boolean {
return Config.isShowPlugin(gameId)
}
override fun init(context: Context?) {
// Do nothing
}

View File

@ -25,6 +25,23 @@ class DialogUtilsProviderImpl : IDialogUtilsProvider {
override fun showWaitDialog(context: Context, string: String): Dialog = DialogUtils.showWaitDialog(context, string)
override fun showForceDialog(
context: Context,
title: String,
message: CharSequence,
positive: String,
negative: String,
confirm: () -> Unit,
cancel: () -> Unit
) {
DialogUtils.showForceDialog(context, title, message, positive, negative,
{ confirm.invoke() }, object :CancelListener{
override fun onCancel() {
cancel.invoke()
}
})
}
override fun showUsageStatsDialog(context: Context, confirm: () -> Unit, cancel: () -> Unit) {
DialogUtils.showUsageStatsDialog(context,
{ confirm.invoke() }, object :CancelListener{

View File

@ -57,18 +57,6 @@ class DirectProviderImpl : IDirectProvider {
DirectUtils.directToSuggestion(context, diagnosis = diagnosis)
}
override fun directToQa(context: Context, text: String?, id: String) {
DirectUtils.directToQa(context, text, id)
}
override fun directToHelpAndFeedback(context: Context, position: Int) {
DirectUtils.directToHelpAndFeedback(context, position)
}
override fun directToQqGroup(context: Context, groupNumber: String?): Boolean {
return DirectUtils.directToQqGroup(context, groupNumber)
}
override fun init(context: Context?) {
// Do nothing
}

View File

@ -5,7 +5,6 @@ import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.common.util.ErrorHelper
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.IErrorHelperProvider
import com.gh.gamecenter.login.user.LoginTag
import retrofit2.HttpException
@Route(path = RouteConsts.provider.errorHelper, name = "ErrorHelper暴露服务")
@ -19,13 +18,8 @@ class ErrorHelperProviderImpl : IErrorHelperProvider {
ErrorHelper.handleError(context, errorString, showHighPriorityHint)
}
override fun handleLoginError(
context: Context,
httpException: HttpException?,
loginTagChinese: String,
isCertificate: Boolean
) {
ErrorHelper.handleLoginError(context, httpException, loginTagChinese, isCertificate)
override fun handleLoginError(context: Context, httpException: HttpException?) {
ErrorHelper.handleLoginError(context, httpException)
}
override fun init(context: Context?) {

View File

@ -1,20 +0,0 @@
package com.gh.common.provider
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.common.exposure.ExposureManager
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.provider.IExposureManagerProvider
@Route(path = RouteConsts.provider.exposureManager, name = "ExposureManager暴露服务")
class ExposureManagerProviderImpl: IExposureManagerProvider {
override fun logExposure(exposureEvent: ExposureEvent) {
ExposureManager.log(exposureEvent)
}
override fun init(context: Context?) {
// do nothing
}
}

View File

@ -1,18 +0,0 @@
package com.gh.common.provider
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.common.FixedRateJobHelper
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.IFixedRateJobHelperProvider
@Route(path = RouteConsts.provider.fixedRateJobHelper, name = "FixedRateJobHelper暴露服务")
class FixedRateJobHelperProviderImpl : IFixedRateJobHelperProvider {
override fun getTimeDeltaBetweenServerAndClient(): Long {
return FixedRateJobHelper.timeDeltaBetweenServerAndClient
}
override fun init(context: Context?) {
// Do nothing
}
}

View File

@ -0,0 +1,19 @@
package com.gh.common.provider
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.common.util.FloatingBackViewManager
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.IFloatingBackViewManagerProvider
@Route(path = RouteConsts.provider.floatingBackViewManager, name = "FloatingViewBackManager暴露服务")
class FloatingBackViewManagerProviderImpl : IFloatingBackViewManagerProvider {
override fun enableBackViewForTaskType() {
FloatingBackViewManager.enableBackView(FloatingBackViewManager.TYPE_TASK)
}
override fun init(context: Context?) {
// Do nothing
}
}

View File

@ -1,46 +0,0 @@
package com.gh.common.provider
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.gamecenter.GameDetailActivity
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.provider.IGameDetailProvider
@Route(path = RouteConsts.provider.gameDetail, name = "GameDetailActivity暴露服务")
class GameDetailProviderImpl : IGameDetailProvider {
override fun startGameDetailActivity(
context: Context,
gameId: String,
entrance: String?,
traceEvent: ExposureEvent?
) {
GameDetailActivity.startGameDetailActivity(context, gameId, entrance, traceEvent)
}
override fun startGameDetailActivity(
context: Context,
gameEntity: GameEntity?,
entrance: String,
defaultTab: Int,
isSkipGameComment: Boolean,
scrollToLibao: Boolean,
scrollToServer: Boolean,
traceEvent: ExposureEvent?
) {
GameDetailActivity.startGameDetailActivity(
context,
gameEntity,
entrance,
defaultTab,
isSkipGameComment,
scrollToLibao,
scrollToServer,
traceEvent
)
}
override fun init(context: Context?) {
// Do nothing
}
}

View File

@ -3,13 +3,13 @@ package com.gh.common.provider
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.common.filter.RegionSettingHelper
import com.gh.gamecenter.feature.utils.ApkActiveUtils
import com.gh.common.util.ApkActiveUtils
import com.gh.download.DownloadManager
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.common.utils.countOccurrences
import com.gh.gamecenter.core.provider.IHandleGameResponseProvider
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.entity.GameEntity
@Route(path = RouteConsts.provider.handleGameResponse, name = "处理游戏类型返回")
class HandleGameResponseProviderImpl : IHandleGameResponseProvider {

View File

@ -5,10 +5,7 @@ import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.common.util.DirectUtils
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.common.entity.SimpleGameEntity
import com.gh.gamecenter.common.entity.SuggestType
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.provider.ILinkDirectUtilsProvider
import com.gh.gamecenter.common.provider.ILinkDirectUtilsProvider
@Route(path = RouteConsts.provider.linkDirectUtils, name = "DirectUtils暴露服务主要是暴露directToLinkPage方法")
class LinkDirectUtilsProviderImpl : ILinkDirectUtilsProvider {
@ -22,45 +19,6 @@ class LinkDirectUtilsProviderImpl : ILinkDirectUtilsProvider {
DirectUtils.directToLinkPage(context, linkEntity, entrance, path)
}
override fun directToLinkPage(
context: Context,
linkEntity: LinkEntity,
entrance: String,
path: String,
exposureEvent: ExposureEvent?
) {
DirectUtils.directToLinkPage(context, linkEntity, entrance, path, exposureEvent)
}
override fun directToSuggestion(context: Context, type: SuggestType, requestCode: Int?) {
DirectUtils.directToSuggestion(context, type, requestCode)
}
override fun directToSuggestion(
context: Context,
type: SuggestType,
suggestHintType: String?,
content: String?,
isQaFeedback: Boolean,
qaContentId: String
) {
DirectUtils.directToSuggestion(context, type, suggestHintType, content, isQaFeedback, qaContentId)
}
override fun directToSuggestion(
context: Context,
type: SuggestType,
suggestHintType: String?,
content: String?,
game: SimpleGameEntity,
platform: String
) {
DirectUtils.directToSuggestion(context, type, suggestHintType, content, game, platform)
}
override fun directToSuggestion(context: Context, type: SuggestType, hiddenHint: String) {
DirectUtils.directToSuggestion(context, type, hiddenHint)
}
override fun init(context: Context?) {
// Do nothing

View File

@ -1,8 +1,10 @@
package com.gh.common.provider
import android.content.Context
import android.content.Intent
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.gamecenter.MainActivity
import com.gh.gamecenter.WebActivity
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.IMainProvider

View File

@ -1,18 +0,0 @@
package com.gh.common.provider
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.IPackagesManagerProvider
import com.gh.gamecenter.manager.PackagesManager
@Route(path = RouteConsts.provider.packagesManager, name = "PackagesManager暴露服务")
class PackagesManagerProviderImpl: IPackagesManagerProvider {
override fun isCanPluggable(gameId: String?, packageName: String?): Boolean {
return PackagesManager.isCanPluggable(gameId, packageName)
}
override fun init(context: Context?) {
// Do nothing
}
}

View File

@ -1,32 +0,0 @@
package com.gh.common.provider
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.common.filter.RegionSettingHelper
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.IpInfo
import com.gh.gamecenter.feature.provider.IRegionSettingHelperProvider
@Route(path = RouteConsts.provider.regionSettingHelper, name = "RegionSettingHelper暴露服务")
class RegionSettingHelperProviderImpl : IRegionSettingHelperProvider {
override fun shouldThisGameDisplayMirrorInfo(gameId: String): Boolean {
return RegionSettingHelper.shouldThisGameDisplayMirrorInfo(gameId)
}
override fun shouldThisGameShowSpecialDownload(gameId: String): Boolean {
return RegionSettingHelper.shouldThisGameShowSpecialDownload(gameId)
}
override fun filterGame(list: List<GameEntity>): ArrayList<GameEntity> {
return RegionSettingHelper.filterGame(list)
}
override fun getIpInfo(): IpInfo? {
return RegionSettingHelper.getIpInfo()
}
override fun init(context: Context?) {
// Do nothing
}
}

View File

@ -2,7 +2,7 @@ package com.gh.common.provider
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.gamecenter.feature.exposure.time.TimeUtil
import com.gh.common.exposure.time.TimeUtil
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.ITimeUtilProvider

View File

@ -5,6 +5,7 @@ import android.os.Build
import androidx.annotation.RequiresApi
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.common.util.UsageStatsHelper
import com.gh.common.util.WechatBindHelper
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.IUsageStatsHelperProvider

View File

@ -1,26 +0,0 @@
package com.gh.common.provider
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.IVHelperProvider
import com.gh.vspace.VHelper
@Route(path = RouteConsts.provider.vhelper, name = "VHelper暴露服务")
class VHelperProviderImpl: IVHelperProvider {
override fun getPlatformV(): String {
return VHelper.PLATFORM_V
}
override fun getVUrl(originUrl: String?): String {
return VHelper.getVUrl(originUrl)
}
override fun isVGameOn(): Boolean {
return VHelper.isVGameOn()
}
override fun init(context: Context?) {
// Do nothing
}
}

View File

@ -25,16 +25,6 @@ class WebProviderImpl : IWebProvider {
return WebActivity.getSecurityCertificationIntent(context)
}
override fun getQAIntent(
context: Context?,
url: String?,
title: String?,
isWebPageHandleBackPressed: Boolean,
qaType: Int
): Intent {
return WebActivity.getQAIntent(context, url, title, isWebPageHandleBackPressed, qaType)
}
override fun init(context: Context?) {
// Do nothing
}

View File

@ -0,0 +1,57 @@
package com.gh.common.repository
import com.gh.common.filter.RegionSettingHelper
import com.gh.common.util.ApkActiveUtils
import com.gh.gamecenter.core.utils.RandomUtils
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.retrofit.RetrofitManager
import io.reactivex.Observable
// 热门卡牌的仓库
object RemenkapaiRepository {
var remenkapaiList = arrayListOf<GameEntity>()
@JvmStatic
fun getRemenkapai(size: Int): Observable<List<GameEntity>> {
return if (remenkapaiList.isEmpty()) {
RetrofitManager.getInstance().api.remenkapai
.map(RegionSettingHelper.filterGame)
.map { gameList -> filterEntityWithoutApk(gameList) }
.map { pickRandomSizeEntity(size) }
.map(ApkActiveUtils.filterMapperList)
} else {
Observable.create { emitter -> emitter.onNext(pickRandomSizeEntity(size)) }
}
}
/**
* 选择随机数量的热门卡牌
*/
private fun pickRandomSizeEntity(size: Int): List<GameEntity> {
if (size > remenkapaiList.size) return remenkapaiList
val randomGameList = arrayListOf<GameEntity>()
val randomArray = RandomUtils.getRandomArray(size, remenkapaiList.size)
for (i in randomArray) {
randomGameList.add(remenkapaiList[i])
}
return randomGameList
}
/**
* 过滤没有 Apk 的实体
*/
private fun filterEntityWithoutApk(gameList: List<GameEntity>): List<GameEntity> {
val realGameList = arrayListOf<GameEntity>()
for (gameEntity in gameList) {
val apk = gameEntity.getApk()
if (apk.size != 0) {
realGameList.add(gameEntity)
}
}
remenkapaiList = realGameList
return remenkapaiList
}
}

View File

@ -7,9 +7,12 @@ import android.content.Intent
import android.graphics.Bitmap
import android.view.Gravity
import androidx.core.content.FileProvider
import com.g00fy2.versioncompare.Version
import com.gh.common.constant.Config
import com.gh.common.util.DownloadItemUtils
import com.gh.common.util.LogUtils
import com.gh.common.util.NewFlatLogUtils
import com.gh.common.util.PackageUtils
import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.R
import com.gh.gamecenter.common.utils.*
@ -17,7 +20,7 @@ import com.gh.gamecenter.core.utils.EmptyCallback
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.core.utils.TimeUtils
import com.gh.gamecenter.core.utils.ToastUtils
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.entity.GameEntity
import com.halo.assistant.HaloApp
import com.lightgame.download.DownloadEntity
import com.lightgame.utils.AppManager

View File

@ -8,6 +8,7 @@ import android.widget.ProgressBar
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.widget.ConstraintLayout
import com.g00fy2.versioncompare.Version
import com.gh.common.util.LogUtils
import com.gh.common.util.NewFlatLogUtils
import com.gh.common.util.PackageInstaller
@ -19,15 +20,11 @@ import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.AppExecutor.uiExecutor
import com.gh.gamecenter.core.utils.*
import com.gh.gamecenter.feature.entity.ApkEntity
import com.gh.gamecenter.feature.entity.SimulatorEntity
import com.gh.gamecenter.entity.ApkEntity
import com.gh.gamecenter.entity.SimulatorEntity
import com.gh.gamecenter.entity.TrackableEntity
import com.gh.ndownload.NDataChanger
import com.halo.assistant.HaloApp
import com.lightgame.download.DataWatcher
import com.lightgame.download.DownloadEntity
import com.lightgame.download.DownloadStatus
import com.lightgame.download.FileUtils
import com.lightgame.download.*
import com.lightgame.utils.Utils
import java.lang.ref.WeakReference
import java.text.DecimalFormat
@ -99,12 +96,6 @@ class SimulatorDownloadManager private constructor() {
downloadDialog?.dismiss()
}
}
DownloadStatus.diskisfull == downloadEntity.status -> {
ToastUtils.showToast("存储空间已满,下载任务已暂停")
}
DownloadStatus.diskioerror == downloadEntity.status -> {
ToastUtils.showToast("下载 IO 出现异常,下载任务已暂停")
}
DownloadStatus.neterror == downloadEntity.status -> {
ToastUtils.showToast("网络不稳定,下载任务已暂停")
}
@ -155,31 +146,21 @@ class SimulatorDownloadManager private constructor() {
PermissionHelper.checkGetInstalledAppsListBeforeAction(context, object : EmptyCallback {
override fun onCallback() {
val isInstalledNewSimulator =
SimulatorGameManager.isNewSimulatorInstalled(HaloApp.getInstance().application)
//当没有安装新版本模拟器时候 判断是否隐藏
if (simulator?.active == false && !isInstalledNewSimulator) {
//判断是否隐藏
if (simulator?.active == false) {
showNoneEmulatorDialog(context)
return
}
var isInstalled = PackageUtils.isInstalledFromAllPackage(
context,
simulator?.apk?.packageName
)
//模拟器管理界面还是用之前的逻辑
if (isInstalledNewSimulator && location != SimulatorLocation.SIMULATOR_MANAGE) {
isInstalled = isInstalledNewSimulator
}
val isInstalled = PackageUtils.isInstalledFromAllPackage(context, simulator?.apk?.packageName)
// val versionFromInstalledApp = PackageUtils.getVersionNameByPackageName(simulator?.apk?.packageName)
val shouldShowUpdate =
PackageUtils.isInstalledApkMatchedMd5(simulator?.apk?.packageName, simulator?.apk?.md5)
val shouldShowUpdate = PackageUtils.isInstalledApkMatchedMd5(simulator?.apk?.packageName, simulator?.apk?.md5)
val showAlertTag = SPUtils.getString(SimulatorGameManager.SIMULATOR_UPDATE_SHOW_ALERT_TAG, "") //当天是否弹过
val todayIsShow = showAlertTag == TimeUtils.getToday()
downloadType = if (shouldShowUpdate && isInstalled) "update" else "download"
if (downloadType == "update" && todayIsShow && location != SimulatorLocation.SIMULATOR_MANAGE) {
if (downloadType == "update" && todayIsShow && location != SimulatorLocation.SIMULATOR_MANAGE){
return
}
if (downloadType == "download" && isInstalled) {
if (downloadType == "download" && isInstalled){
return
}
val title = if (shouldShowUpdate && isInstalled) "更新模拟器" else "安装模拟器"
@ -300,17 +281,13 @@ class SimulatorDownloadManager private constructor() {
HaloApp.put(simulator.name, simulator)
if (entity != null) {
when (entity.status) {
DownloadStatus.pause,
DownloadStatus.subscribe,
DownloadStatus.neterror,
DownloadStatus.timeout,
DownloadStatus.diskioerror,
DownloadStatus.diskisfull -> {
DownloadStatus.pause, DownloadStatus.subscribe,
DownloadStatus.neterror, DownloadStatus.timeout -> {
DownloadManager.getInstance().addObserver(dataWatcher)
uiExecutor.executeWithDelay(Runnable { DownloadManager.getInstance().resume(entity, true) }, 200)
downloadDialog?.show()
}
DownloadStatus.done -> NDataChanger.notifyDataChanged(entity)
DownloadStatus.done -> DataChanger.notifyDataChanged(entity)
else -> createDownload(apkEntity, simulator)
}

View File

@ -8,7 +8,7 @@ import android.graphics.Bitmap
import android.net.Uri
import android.text.TextUtils
import com.gh.common.constant.Config
import com.gh.gamecenter.feature.utils.ApkActiveUtils
import com.gh.common.util.ApkActiveUtils
import com.gh.common.util.LogUtils
import com.gh.common.util.PackageUtils
import com.gh.download.DownloadManager
@ -22,8 +22,8 @@ import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.core.utils.TimeUtils
import com.gh.gamecenter.core.utils.ToastUtils
import com.gh.gamecenter.core.utils.UrlFilterUtils
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.SimulatorGameRecordEntity
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.entity.SimulatorGameRecordEntity
import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.room.AppDatabase

View File

@ -4,17 +4,25 @@ import android.net.Uri
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.utils.EnvHelper
import com.gh.gamecenter.common.utils.tryWithDefaultCatch
import com.gh.gamecenter.core.GHThreadFactory
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
/**
* 活动相关数据统计辅助类
*/
object ActivityCountHelper {
private const val MAX_STAY_TIME = 320
private val ACTIVITY_URL_COMMON_PREF by lazy {
private val ACTIVITY_URL_COMMON_PREF =
if (EnvHelper.isDevEnv) Constants.ACTIVITY_DETAIL_ADDRESS_DEV else Constants.ACTIVITY_DETAIL_ADDRESS
}
private var mStayTimeCount = 0
private var mIsStayTimeCountEnabled = false
private var mStayTimeArray = arrayOf(5, 10, 20, 40, 80, 160)
private const val MAX_STAY_TIME = 320
private val mThreadService: ExecutorService by lazy {
Executors.newSingleThreadExecutor(GHThreadFactory("STAY_TIME_THREAD"))
}
@JvmStatic
fun postActivityPageEnter(url: String?, entrance: String) {
@ -37,20 +45,34 @@ object ActivityCountHelper {
}
}
fun handleStayTime(url: String, stayTime: Int) {
fun startCountStayTime(url: String) {
if (url.contains(ACTIVITY_URL_COMMON_PREF)) {
val uri = Uri.parse(url)
val activityId = uri.getQueryParameter("id") ?: return
when {
stayTime % MAX_STAY_TIME == 0 -> NewFlatLogUtils.logActivityPageView(
MAX_STAY_TIME,
activityId
)
mStayTimeArray.contains(stayTime) -> NewFlatLogUtils.logActivityPageView(
stayTime,
activityId
)
mIsStayTimeCountEnabled = true
mThreadService.execute {
while (mIsStayTimeCountEnabled) {
tryWithDefaultCatch {
mStayTimeCount++
when {
mStayTimeCount % MAX_STAY_TIME == 0 -> NewFlatLogUtils.logActivityPageView(
MAX_STAY_TIME,
activityId
)
mStayTimeArray.contains(mStayTimeCount) -> NewFlatLogUtils.logActivityPageView(
mStayTimeCount,
activityId
)
}
}
Thread.sleep(1000)
}
}
}
}
fun endCountStayTime() {
mIsStayTimeCountEnabled = false
mStayTimeCount = 0
}
}

View File

@ -1,15 +1,15 @@
package com.gh.common.util
import android.annotation.SuppressLint
import androidx.lifecycle.MutableLiveData
import com.gh.common.constant.Config
import com.gh.gamecenter.common.retrofit.Response
import com.gh.gamecenter.common.utils.ImageUtils
import com.gh.gamecenter.common.utils.observableToMain
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.entity.NewApiSettingsEntity
import com.gh.gamecenter.common.utils.NetworkUtils
import com.gh.gamecenter.entity.SettingsEntity
import com.gh.gamecenter.entity.StartupAdEntity
import com.gh.gamecenter.feature.entity.SettingsEntity
import com.gh.gamecenter.common.retrofit.BiResponse
import com.gh.gamecenter.retrofit.RetrofitManager
import com.halo.assistant.HaloApp
import io.reactivex.schedulers.Schedulers
object AdHelper {
@ -19,40 +19,24 @@ object AdHelper {
const val LOCATION_SUGGESTION_FUNCTION = "suggestion_function"
const val LOCATION_SIMULATOR_GAME = "simulator_game"
@JvmStatic
fun getStartUpAd(): StartupAdEntity? {
return Config.getNewApiSettingsEntity()?.startAd
}
@JvmField
var startupAd = MutableLiveData<StartupAdEntity>()
@JvmStatic
fun getStartUp(): StartupAdEntity? {
return Config.getNewApiSettingsEntity()?.startup
}
@JvmStatic
fun prefetchStartUpAd(settingsEntity: NewApiSettingsEntity) {
if (settingsEntity.startAd != null && !settingsEntity.startAd?.img.isNullOrEmpty()) {
val screenWidth = DisplayUtils.getScreenWidth()
val transformedUrl = ImageUtils.getTransformedUrl(settingsEntity.startAd?.img, screenWidth) ?: return
ImageUtils.prefetchToDiskCache(transformedUrl)
@SuppressLint("CheckResult")
fun getStartUpAd() {
if (!NetworkUtils.isNetworkConnected(HaloApp.getInstance())) {
startupAd.postValue(null)
return
}
}
fun getSettingAdCache() {
RetrofitManager.getInstance().newApi
.getSettingAdCache(HaloApp.getInstance().channel)
.compose(observableToMain())
.subscribe(object : Response<NewApiSettingsEntity>() {
override fun onResponse(response: NewApiSettingsEntity?) {
super.onResponse(response)
val settings = Config.getNewApiSettingsEntity()
if (settings != null) {
settings.startAd = response?.startAd
Config.updateNewApiSettings(settings)
if (response != null) {
prefetchStartUpAd(response)
}
}
RetrofitManager.getInstance()
.api
.getSplashAd(HaloApp.getInstance().channel)
.subscribeOn(Schedulers.io())
.subscribe(object : BiResponse<StartupAdEntity>() {
override fun onSuccess(data: StartupAdEntity) {
startupAd.postValue(data)
}
})
}

View File

@ -1,11 +1,9 @@
package com.gh.gamecenter.feature.utils;
package com.gh.common.util;
import com.alibaba.android.arouter.launcher.ARouter;
import com.gh.gamecenter.common.constant.RouteConsts;
import com.gh.gamecenter.core.provider.IPackagesManagerProvider;
import com.gh.gamecenter.feature.BuildConfig;
import com.gh.gamecenter.feature.entity.ApkEntity;
import com.gh.gamecenter.feature.entity.GameEntity;
import com.gh.gamecenter.BuildConfig;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.manager.PackagesManager;
import com.lightgame.utils.Utils;
import java.util.List;
@ -26,8 +24,7 @@ public class ApkActiveUtils {
ApkEntity apkEntity = apkList.get(i);
String packageName = apkEntity.getPackageName();
String id = gameEntity.getId();
IPackagesManagerProvider provider = (IPackagesManagerProvider)ARouter.getInstance().build(RouteConsts.provider.packagesManager).navigation();
if (!apkEntity.isActive() && !provider.isCanPluggable(id, packageName)) {
if (!apkEntity.isActive() && !PackagesManager.INSTANCE.isCanPluggable(id, packageName)) {
apkList.remove(i);
i--;
}

View File

@ -1,298 +0,0 @@
package com.gh.common.util
import android.app.Dialog
import android.content.Context
import android.view.View
import android.view.Window
import android.widget.TextView
import androidx.fragment.app.Fragment
import com.gh.download.simple.AutoUnregisteredSimpleDownloadListener
import com.gh.download.simple.DownloadListener
import com.gh.gamecenter.R
import com.gh.gamecenter.common.eventbus.EBReuse
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.runOnUiThread
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.core.utils.ToastUtils
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.vspace.VArchiveHelper
import com.gh.vspace.VHelper
import com.lg.download.DownloadError
import com.lg.download.DownloadStatus
import io.reactivex.schedulers.Schedulers
import org.greenrobot.eventbus.EventBus
import splitties.systemservices.layoutInflater
/**
* 云存档下载按钮辅助类
*/
object ArchiveDownloadButtonHelper {
fun bindItem(
context: Context,
entrance: String,
fragment: Fragment,
packageName: String,
archiveEntity: ArchiveEntity,
downloadBtn: TextView,
gameEntity: GameEntity?,
downloadCompletedListener: (() -> Unit)? = null
) {
downloadBtn.text = if (VArchiveHelper.isArchiveDownloaded(archiveEntity.md5)) {
R.string.archive_apply.toResString()
} else {
R.string.archive_download.toResString()
}
downloadBtn.setOnClickListener {
when {
// 检查是否已安装畅玩助手
!VHelper.isVSpaceInstalled(context) -> showVspaceTipDialog(context, gameEntity)
// 检查是否已安装游戏
!VHelper.isInstalled(packageName) -> {
// 检查游戏是否在安装中
if (!VHelper.isInstalling(packageName)) {
showDownloadTipDialog(context)
} else {
ToastUtils.toast("游戏正在安装中,请稍候")
}
}
// 检查本地是否已下载存档
VArchiveHelper.isArchiveDownloaded(archiveEntity.md5) -> showApplyArchiveTipDialog(
context,
entrance,
packageName,
archiveEntity,
gameEntity
)
// 检查完毕下载存档
else -> downloadArchive(
context,
entrance,
fragment,
packageName,
archiveEntity,
downloadBtn,
gameEntity,
downloadCompletedListener
)
}
}
}
private fun showVspaceTipDialog(context: Context, gameEntity: GameEntity?) {
NewFlatLogUtils.logCloudArchiveVSpaceDownloadDialogShow()
DialogHelper.showDialog(
context,
R.string.archive_dialog_title.toResString(),
R.string.archive_vspace_dialog_content.toResString(),
R.string.archive_vspace_dialog_confirm.toResString(),
R.string.cancel.toResString(),
{
NewFlatLogUtils.logCloudArchiveVSpaceDownloadDialogClick(R.string.archive_vspace_dialog_confirm.toResString())
VHelper.showVspaceDialog(context, gameEntity)
},
{
NewFlatLogUtils.logCloudArchiveVSpaceDownloadDialogClick(R.string.cancel.toResString())
},
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
)
}
private fun showDownloadTipDialog(context: Context) {
NewFlatLogUtils.logCloudArchiveGameDownloadDialogShow()
DialogHelper.showDialog(
context,
R.string.archive_dialog_title.toResString(),
R.string.archive_download_dialog_content.toResString(),
R.string.archive_download_dialog_confirm.toResString(),
R.string.cancel.toResString(),
{
NewFlatLogUtils.logCloudArchiveGameDownloadDialogClick(R.string.archive_download_dialog_confirm.toResString())
VHelper.disableLaunchGameAfterInstallation()
EventBus.getDefault().post(EBReuse("download"))
},
{
NewFlatLogUtils.logCloudArchiveGameDownloadDialogClick(R.string.cancel.toResString())
},
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
)
}
private fun applyArchive(
context: Context,
entrance: String,
packageName: String,
archiveEntity: ArchiveEntity,
gameEntity: GameEntity?
) {
VArchiveHelper.getArchiveFile(archiveEntity.md5)?.run {
RetrofitManager.getInstance().newApi
.postArchiveUsage(archiveEntity.gameId, archiveEntity.id)
.subscribeOn(Schedulers.io())
.subscribe()
VArchiveHelper.applyGameArchive(context, packageName, this) { packageName, isSuccess ->
runOnUiThread {
if (isSuccess) {
VHelper.launch(context, packageName)
} else {
ToastUtils.toast(R.string.archive_apply_fail.toResString())
}
}
}
}
NewFlatLogUtils.logCloudArchiveDownloadOrApply(
archiveEntity.name,
entrance,
gameEntity?.id ?: "",
gameEntity?.name ?: "",
archiveEntity.id,
false
)
}
private fun downloadArchive(
context: Context,
entrance: String,
fragment: Fragment,
packageName: String,
archiveEntity: ArchiveEntity,
downloadBtn: TextView,
gameEntity: GameEntity?,
downloadCompletedListener: (() -> Unit)? = null
) {
// 执行下载
VArchiveHelper.downloadArchive(archiveEntity)
// 下载进度弹窗
val archiveLoadingDialog = Dialog(context, R.style.DialogWindowTransparent)
val archiveLoadingBinding = DialogArchiveLoadingBinding.inflate(context.layoutInflater)
showArchiveLoadingDialog(archiveLoadingDialog, archiveLoadingBinding.root)
// 下载进度监听
AutoUnregisteredSimpleDownloadListener(archiveEntity.id, fragment, object : DownloadListener {
override fun onError(error: DownloadError) {
dismissArchiveLoadingDialog(archiveLoadingDialog)
ToastUtils.toast(R.string.archive_download_fail.toResString())
}
override fun onProgress(progress: Float) {
archiveLoadingBinding.run {
progressTv.text = "${progress.roundTo(1)}%"
progressBar.progress = progress.toInt()
}
}
override fun onSizeReceived(fileSize: Long) {
// Do nothing
}
override fun onStatusChanged(status: DownloadStatus) {
when (status) {
DownloadStatus.COMPLETED -> {
dismissArchiveLoadingDialog(archiveLoadingDialog)
downloadBtn.text = R.string.archive_apply.toResString()
showApplyArchiveTipDialog(context, entrance, packageName, archiveEntity, gameEntity)
downloadCompletedListener?.invoke()
}
else -> {
// Do nothing
}
}
}
override fun onSpeedChanged(speed: Float) {
// Do nothing
}
})
NewFlatLogUtils.logCloudArchiveDownloadOrApply(
archiveEntity.name,
entrance,
gameEntity?.id ?: "",
gameEntity?.name ?: "",
archiveEntity.id,
true
)
SensorsBridge.trackEvent(
"CloudSaveDownload",
"cloud_save_name", archiveEntity.name,
"game_id", gameEntity?.id ?: "",
"game_name", gameEntity?.name ?: "",
"source_entrance", entrance
)
}
private fun showArchiveLoadingDialog(
archiveLoadingDialog: Dialog,
contentView: View
) {
archiveLoadingDialog.run {
setCancelable(false)
setCanceledOnTouchOutside(false)
requestWindowFeature(Window.FEATURE_NO_TITLE)
setContentView(contentView)
show()
}
archiveLoadingDialog.window?.attributes?.apply {
width = DisplayUtils.getScreenWidth() - 120F.dip2px()
archiveLoadingDialog.window?.attributes = this
}
}
private fun showApplyArchiveTipDialog(
context: Context,
entrance: String,
packageName: String,
archiveEntity: ArchiveEntity,
gameEntity: GameEntity?
) {
DialogHelper.showDialog(
context,
R.string.archive_dialog_title.toResString(),
R.string.archive_apply_dialog_content.toResString(),
R.string.archive_apply.toResString(),
R.string.cancel.toResString(),
{
applyArchive(context, entrance, packageName, 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", "取消")
SensorsBridge.trackEvent(
"CloudSaveOverwriteDialogClick",
"game_id", gameEntity?.id ?: "",
"game_name", gameEntity?.name ?: "",
"button_name", "取消"
)
},
extraConfig = DialogHelper.Config(centerTitle = true)
)
NewFlatLogUtils.logCloudArchiveApplyDialogRelated("cloud_save_overwrite_dialog_show")
SensorsBridge.trackEvent(
"CloudSaveOverwriteDialogShow",
"game_id", gameEntity?.id ?: "",
"game_name", gameEntity?.name ?: ""
)
}
private fun dismissArchiveLoadingDialog(archiveLoadingDialog: Dialog) {
if (archiveLoadingDialog.isShowing) {
archiveLoadingDialog.dismiss()
}
}
}

View File

@ -9,19 +9,19 @@ import android.view.View
import android.view.Window
import androidx.core.widget.doOnTextChanged
import androidx.recyclerview.widget.LinearLayoutManager
import com.gh.gamecenter.R
import com.gh.gamecenter.adapter.ReportReasonAdapter
import com.gh.gamecenter.common.constant.CommonConsts
import com.gh.gamecenter.core.utils.CurrentActivityHolder
import com.gh.gamecenter.common.json.json
import com.gh.gamecenter.common.retrofit.BiResponse
import com.gh.gamecenter.common.view.VerticalItemDecoration
import com.gh.gamecenter.R
import com.gh.gamecenter.SuggestionActivity
import com.gh.gamecenter.adapter.ReportReasonAdapter
import com.gh.gamecenter.core.utils.ToastUtils
import com.gh.gamecenter.common.utils.toColor
import com.gh.gamecenter.common.utils.toObject
import com.gh.gamecenter.common.utils.toRequestBody
import com.gh.gamecenter.common.view.VerticalItemDecoration
import com.gh.gamecenter.core.utils.CurrentActivityHolder
import com.gh.gamecenter.core.utils.ToastUtils
import com.gh.gamecenter.databinding.DialogReportReasonBinding
import com.gh.gamecenter.feature.entity.SettingsEntity
import com.gh.gamecenter.entity.SettingsEntity
import com.gh.gamecenter.common.retrofit.BiResponse
import com.gh.gamecenter.retrofit.RetrofitManager
import com.halo.assistant.HaloApp
import io.reactivex.android.schedulers.AndroidSchedulers
@ -35,7 +35,7 @@ object BbsReportHelper {
fun showReportDialog(contentId: String) {
val sp = PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance())
val suggestion: SettingsEntity.Suggestion? =
sp.getString(CommonConsts.SUGGESTION_HINT_TYPE, null)?.toObject()
sp.getString(SuggestionActivity.SUGGESTION_HINT_TYPE, null)?.toObject()
val reportList = suggestion?.report ?: return
CurrentActivityHolder.getCurrentActivity()?.apply {

View File

@ -0,0 +1,131 @@
package com.gh.common.util
import android.annotation.SuppressLint
import android.app.Activity
import android.app.Application
import android.os.Bundle
import com.gh.gamecenter.core.utils.CurrentActivityHolder
import com.gh.gamecenter.core.GHThreadFactory
import com.gh.gamecenter.MainActivity
import com.gh.gamecenter.core.utils.ToastUtils
import com.gh.gamecenter.common.utils.isPublishEnv
import com.gh.gamecenter.common.utils.tryWithDefaultCatch
import com.gh.gamecenter.forum.detail.ForumDetailActivity
import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity
import com.gh.gamecenter.qa.comment.CommentActivity
import com.gh.gamecenter.qa.questions.newdetail.NewQuestionDetailActivity
import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity
import com.gh.gamecenter.common.retrofit.BiResponse
import com.gh.gamecenter.retrofit.RetrofitManager
import com.halo.assistant.HaloApp
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.ResponseBody
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
object BbsStayTimeHelper {
private var mStayTimeCount = 0
private var mIsStayTimeCountEnabled = false // 论坛停留时间统计是否开启
private var mStayTimeTimeout = 30
private var mIsStayTimeCountValid = false // 论坛停留时间统计是否有效
const val IS_BBS_CONTENT_VISIBLE = "is_bbs_content_visible"
private val mThreadService: ExecutorService by lazy {
Executors.newSingleThreadExecutor(GHThreadFactory("STAY_TIME_THREAD"))
}
private val mActivityLifecycleCallbacks by lazy {
object : Application.ActivityLifecycleCallbacks {
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {}
override fun onActivityStopped(activity: Activity) {}
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {}
override fun onActivityDestroyed(activity: Activity) {}
override fun onActivityStarted(activity: Activity) {}
override fun onActivityResumed(activity: Activity) {
if (isTopActivityBbsRelated(activity) && mIsStayTimeCountEnabled) {
resumeTimeCount()
}
}
override fun onActivityPaused(activity: Activity) {
if (isTopActivityBbsRelated(activity) && mIsStayTimeCountEnabled) {
pauseTimeCount()
}
}
}
}
fun enableStayTimeCount(timeout: Int) {
mIsStayTimeCountEnabled = true
mStayTimeTimeout = timeout
resumeTimeCount()
HaloApp.getInstance().registerActivityLifecycleCallbacks(mActivityLifecycleCallbacks)
}
fun disableStayTimeCount() {
mIsStayTimeCountEnabled = false
mStayTimeCount = 0
HaloApp.getInstance().unregisterActivityLifecycleCallbacks(mActivityLifecycleCallbacks)
}
fun resumeTimeCount() {
if (!mIsStayTimeCountEnabled) return
mIsStayTimeCountValid = true
mThreadService.execute {
while (mIsStayTimeCountEnabled && mIsStayTimeCountValid) {
val topActivity = CurrentActivityHolder.getCurrentActivity() ?: continue
if (isTopActivityBbsRelated(topActivity)) {
tryWithDefaultCatch {
mStayTimeCount++
if (mStayTimeCount >= mStayTimeTimeout) {
postExploreFinish()
}
}
}
Thread.sleep(1000)
}
}
}
fun pauseTimeCount() {
if (!mIsStayTimeCountEnabled) return
mIsStayTimeCountValid = false
}
private fun isTopActivityBbsRelated(activity: Activity): Boolean {
return (activity is MainActivity && activity.intent.extras?.getBoolean(IS_BBS_CONTENT_VISIBLE) == true)
|| activity is ForumDetailActivity
|| activity is ArticleDetailActivity
|| activity is ForumVideoDetailActivity
|| activity is CommentActivity
|| activity is NewQuestionDetailActivity
}
@SuppressLint("CheckResult")
private fun postExploreFinish() {
RetrofitManager.getInstance()
.api
.postExplorerFinish()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : BiResponse<ResponseBody>() {
override fun onSuccess(data: ResponseBody) {
if (!isPublishEnv()) {
ToastUtils.toast("完成了论坛停留任务(仅测试环境有这个 toast 不要慌)")
}
disableStayTimeCount()
}
})
}
}

View File

@ -1,9 +1,11 @@
package com.gh.common.util
import android.content.Context
import com.gh.gamecenter.eventbus.EBCollectionChanged
import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.common.retrofit.Response
import com.gh.gamecenter.retrofit.RetrofitManager
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.ResponseBody
@ -17,16 +19,18 @@ import retrofit2.HttpException
object CollectionUtils {
enum class CollectionType {
TOOLKIT, ARTICLE, ANSWER, COMMUNITY_ARTICLE
toolkit, article, answer, communityArticle
}
fun postCollection(content: String, type: CollectionType, listener: OnCollectionListener) {
val api = RetrofitManager.getInstance().api
fun postCollection(context: Context, content: String, type: CollectionType, listener: OnCollectionListener) {
val postCollection = when (type) {
CollectionType.ARTICLE -> api.postCollectionArticle(UserManager.getInstance().userId, content)
CollectionType.TOOLKIT -> api.postCollectionTools(UserManager.getInstance().userId, content)
CollectionType.ANSWER -> api.postCollectionAnswer(UserManager.getInstance().userId, content)
CollectionType.article -> RetrofitManager.getInstance().getApi()
.postCollectionArticle(UserManager.getInstance().userId, content)
CollectionType.toolkit -> RetrofitManager.getInstance().getApi()
.postCollectionTools(UserManager.getInstance().userId, content)
CollectionType.answer -> RetrofitManager.getInstance().getApi()
.postCollectionAnswer(UserManager.getInstance().userId, content)
else -> return
}
postCollection
@ -43,7 +47,7 @@ object CollectionUtils {
super.onFailure(e)
if (e != null) {
try {
val string = e.response()?.errorBody()?.string() ?: ""
val string = e.response()?.errorBody()?.string()
val errorBody = JSONObject(string)
if (errorBody.getInt("code") == 403009) {
listener.onSuccess()
@ -58,13 +62,16 @@ object CollectionUtils {
})
}
fun deleteCollection(id: String, type: CollectionType, listener: OnCollectionListener) {
val api = RetrofitManager.getInstance().api
fun deleteCollection(context: Context, id: String, type: CollectionType, listener: OnCollectionListener) {
val postCollection = when (type) {
CollectionType.ARTICLE -> api.deletaCollectionArticle(UserManager.getInstance().userId, id)
CollectionType.TOOLKIT -> api.deleteCollectionTools(UserManager.getInstance().userId, id)
CollectionType.ANSWER -> api.deleteCollectionAnswer(UserManager.getInstance().userId, id)
val postCollection: Observable<ResponseBody>
when (type) {
CollectionType.article -> postCollection =
RetrofitManager.getInstance().getApi().deletaCollectionArticle(UserManager.getInstance().userId, id)
CollectionType.toolkit -> postCollection =
RetrofitManager.getInstance().getApi().deleteCollectionTools(UserManager.getInstance().userId, id)
CollectionType.answer -> postCollection =
RetrofitManager.getInstance().getApi().deleteCollectionAnswer(UserManager.getInstance().userId, id)
else -> return
}
postCollection

View File

@ -10,15 +10,22 @@ import com.gh.gamecenter.CommentDetailActivity
import com.gh.gamecenter.R
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.json.json
import com.gh.gamecenter.common.retrofit.Response
import com.gh.gamecenter.common.utils.DialogHelper
import com.gh.gamecenter.common.utils.ifLogin
import com.gh.gamecenter.common.utils.showAutoOrientation
import com.gh.gamecenter.common.view.BugFixedPopupWindow
import com.gh.gamecenter.entity.CommentEntity
import com.gh.gamecenter.feature.entity.Permissions
import com.gh.gamecenter.entity.MeEntity
import com.gh.gamecenter.entity.Permissions
import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.qa.comment.OnCommentOptionClickListener
import com.gh.gamecenter.retrofit.RetrofitManager
import com.halo.assistant.HaloApp
import com.lightgame.utils.Utils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.ResponseBody
import org.json.JSONObject
import retrofit2.HttpException
@ -309,6 +316,200 @@ object CommentHelper {
popupWindow.showAutoOrientation(view)
}
private fun showControlDialog(
context: Context,
answerId: String? = null,
articleId: String? = null,
communityId: String? = null,
comment: CommentEntity,
me: MeEntity
) {
val dialogOptions = arrayListOf<String>()
val highlight = "置顶评论"
val hide = "隐藏评论"
var canHighlightCommentDirectly = false
var canHideCommentDirectly = false
if (me.isModerator || me.moderatorPermissions.topAnswerComment > Permissions.GUEST
|| me.moderatorPermissions.topCommunityArticleComment > Permissions.GUEST
) {
dialogOptions.add(highlight)
if (me.moderatorPermissions.topAnswerComment > Permissions.REPORTER
|| me.moderatorPermissions.topCommunityArticleComment > Permissions.REPORTER
) {
canHighlightCommentDirectly = true
}
}
if (me.isModerator || me.moderatorPermissions.hideAnswerComment > Permissions.GUEST
|| me.moderatorPermissions.hideCommunityArticleComment > Permissions.GUEST
) {
dialogOptions.add(hide)
if (me.moderatorPermissions.hideAnswerComment > Permissions.REPORTER
|| me.moderatorPermissions.hideCommunityArticleComment > Permissions.REPORTER
) {
canHideCommentDirectly = true
}
}
val highlightDialogHintContent = if (canHighlightCommentDirectly) {
"你的操作将立即生效,确定提交吗?(你的管理权限为:高级)"
} else {
"你的操作将提交给小编审核,确定提交吗?"
}
val hideDialogHintContent = if (canHideCommentDirectly) {
"你的操作将立即生效,确定提交吗?(你的管理权限为:高级)"
} else {
"你的操作将提交给小编审核,确定提交吗?"
}
val disabledOptions = arrayListOf<String>()
if (comment.priority != 0) {
disabledOptions.add(highlight)
}
comment.me?.let {
if (it.isCommentOwner) {
disabledOptions.add(highlight)
}
}
DialogUtils.showListDialog(context, dialogOptions, disabledOptions) {
when (it) {
highlight -> {
if (comment.priority != 0) {
Utils.toast(context, "评论已经置顶")
return@showListDialog
}
comment.me?.let { me ->
if (me.isCommentOwner) {
Utils.toast(context, "不能置顶自己的评论")
return@showListDialog
}
}
val highlightObserver = object : Response<ResponseBody>() {
override fun onResponse(response: ResponseBody?) {
if (canHighlightCommentDirectly) {
Utils.toast(context, "置顶成功,请刷新列表")
} else {
Utils.toast(context, "提交成功")
}
}
override fun onFailure(e: HttpException?) {
super.onFailure(e)
e?.let { httpException ->
if (httpException.code() == 403) {
val string = e.response().errorBody()?.string()
val errorJson = JSONObject(string)
val errorCode = errorJson.getInt("code")
if (errorCode == 403059) {
Utils.toast(
HaloApp.getInstance().application,
"权限错误,请刷新后重试"
)
return
} else {
Utils.toast(HaloApp.getInstance().application, e.message())
}
}
}
}
}
if (answerId != null) {
DialogHelper.showDialog(
context, highlight, highlightDialogHintContent,
"确定", "取消", {
RetrofitManager.getInstance().api
.highlightAnswerComment(answerId, comment.id)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(highlightObserver)
},
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
)
} else {
DialogHelper.showDialog(
context, highlight, highlightDialogHintContent,
"确定", "取消", {
RetrofitManager.getInstance().api
.highlightCommunityArticleComment(comment.id)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(highlightObserver)
},
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
)
}
}
hide -> {
val hideObserver = object : Response<ResponseBody>() {
override fun onResponse(response: ResponseBody?) {
if (canHideCommentDirectly) {
Utils.toast(context, "隐藏成功,请刷新列表")
} else {
Utils.toast(context, "提交成功")
}
}
override fun onFailure(e: HttpException?) {
super.onFailure(e)
e?.let { httpException ->
if (httpException.code() == 403) {
val string = e.response().errorBody()?.string()
val errorJson = JSONObject(string)
val errorCode = errorJson.getInt("code")
if (errorCode == 403059) {
Utils.toast(
HaloApp.getInstance().application,
"权限错误,请刷新后重试"
)
return
} else {
Utils.toast(HaloApp.getInstance().application, e.message())
}
}
}
}
}
if (answerId != null) {
DialogHelper.showDialog(
context, hide, hideDialogHintContent,
"确定", "取消", {
RetrofitManager.getInstance().api
.hideAnswerComment(answerId, comment.id)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(hideObserver)
},
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
)
} else {
DialogHelper.showDialog(
context, hide, hideDialogHintContent,
"确定", "取消", {
RetrofitManager.getInstance().api
.hideCommunityArticleComment(comment.id)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(hideObserver)
},
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
)
}
}
}
}
}
private fun showReportTypeDialog(
context: Context,
reportCallback: (reportType: String) -> Unit

View File

@ -3,6 +3,7 @@ package com.gh.common.util;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;
import android.view.Window;
@ -25,7 +26,7 @@ import com.gh.gamecenter.core.utils.DisplayUtils;
import com.gh.gamecenter.core.utils.NumberUtils;
import com.gh.gamecenter.core.utils.ToastUtils;
import com.gh.gamecenter.entity.CommentEntity;
import com.gh.gamecenter.feature.entity.MeEntity;
import com.gh.gamecenter.entity.MeEntity;
import com.gh.gamecenter.login.entity.UserInfoEntity;
import com.gh.gamecenter.login.user.UserManager;
import com.gh.gamecenter.retrofit.RetrofitManager;

View File

@ -1,5 +1,6 @@
package com.gh.common.util
import android.content.Context
import android.text.TextUtils
import com.gh.gamecenter.eventbus.EBConcernChanged
import com.gh.gamecenter.login.user.UserManager
@ -7,8 +8,11 @@ import com.gh.gamecenter.common.retrofit.Response
import com.gh.gamecenter.retrofit.RetrofitManager
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.MediaType
import okhttp3.RequestBody
import okhttp3.ResponseBody
import org.greenrobot.eventbus.EventBus
import org.json.JSONArray
import retrofit2.HttpException
/**
@ -21,8 +25,9 @@ object ConcernUtils {
* autoConcern:是否自动关注'关联关注'
*/
fun postConcernGameId(
context: Context,
gameId: String,
listener: OnConcernListener?,
listener: onConcernListener?,
autoConcern: Boolean = false
) {
val mode = if (autoConcern) "auto" else "manual"
@ -48,7 +53,7 @@ object ConcernUtils {
})
}
fun deleteConcernData(gameId: String, listener: OnConcernListener?) {
fun deleteConcernData(context: Context, gameId: String, listener: onConcernListener?) {
RetrofitManager.getInstance().api
.deleteConcern(UserManager.getInstance().userId, gameId)
.subscribeOn(Schedulers.io())
@ -67,7 +72,73 @@ object ConcernUtils {
})
}
interface OnConcernListener {
fun updateConcernData(context: Context, data: JSONArray) {
val body = RequestBody.create(
MediaType.parse("application/json"),
data.toString()
)
RetrofitManager.getInstance().api
.putConcern(UserManager.getInstance().userId, body)
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe(object : Response<ResponseBody>() {
override fun onResponse(response: ResponseBody?) {
EventBus.getDefault().post(EBConcernChanged())
}
})
}
fun deleteConcernQuestions(context: Context, questionsId: String, listener: onConcernListener?) {
RetrofitManager.getInstance().api
.deleteConcernQuestions(UserManager.getInstance().userId, questionsId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Response<ResponseBody>() {
override fun onResponse(response: ResponseBody?) {
super.onResponse(response)
listener?.onSuccess()
}
override fun onFailure(e: HttpException?) {
super.onFailure(e)
listener?.onError()
var errorString: String? = null
try {
errorString = e?.response()?.errorBody()?.string()
} catch (e1: Exception) {
e1.printStackTrace()
}
ErrorHelper.handleError(context, errorString, false)
}
})
}
fun postConcernQuestions(context: Context, questionsId: String, listener: onConcernListener?) {
RetrofitManager.getInstance().api
.postConcernQuestions(UserManager.getInstance().userId, questionsId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Response<ResponseBody>() {
override fun onResponse(response: ResponseBody?) {
super.onResponse(response)
listener?.onSuccess()
}
override fun onFailure(e: HttpException?) {
super.onFailure(e)
listener?.onError()
var errorString: String? = null
try {
errorString = e?.response()?.errorBody()?.string()
} catch (e1: Exception) {
e1.printStackTrace()
}
ErrorHelper.handleError(context, errorString, false)
}
})
}
interface onConcernListener {
fun onSuccess()
fun onError()
}

View File

@ -6,9 +6,8 @@ import android.os.Build;
import com.gh.gamecenter.common.constant.Constants;
import com.gh.gamecenter.common.constant.EntranceConsts;
import com.gh.gamecenter.common.utils.NetworkUtils;
import com.gh.gamecenter.feature.entity.GameEntity;
import com.gh.gamecenter.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;
@ -72,6 +71,16 @@ public class DataCollectionUtils {
DataCollectionManager.onEvent(context, "click-item", map);
}
// 上传游戏数据
public static void uploadGame(Context context, GameEntity gameEntity, int seconds, String from) {
Map<String, Object> map = new HashMap<>();
map.put("game", gameEntity.getName());
map.put("game_id", gameEntity.getId());
map.put("time", seconds);
map.put("from", from);
DataCollectionManager.onEvent(context, "game", map);
}
// 上传新闻数据
public static void uploadNews(Context context, NewsDetailEntity newsDetailEntity,
GameEntity gameEntity, int seconds, String from) {
@ -107,6 +116,15 @@ public class DataCollectionUtils {
DataCollectionManager.onEvent(context, "hijack", map);
}
// 上传用户数据
public static void uploadUser(Context context) {
Map<String, Object> map = new HashMap<>();
map.put("type", Build.MODEL);
map.put("system", Build.VERSION.SDK_INT + "=" + Build.VERSION.RELEASE);
map.put("install", PackagesManager.INSTANCE.getInstalledList());
DataCollectionManager.upsert(context, "user", map);
}
// 上传搜索数据
public static void uploadSearch(Context context, String... args) {
if (args.length != 5) {

View File

@ -2,21 +2,22 @@ package com.gh.common.util;
import android.annotation.SuppressLint;
import android.app.Application;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;
import com.gh.gamecenter.common.base.GlobalActivityManager;
import com.gh.base.GlobalActivityManager;
import com.gh.gamecenter.BuildConfig;
import com.gh.gamecenter.common.base.activity.BaseActivity;
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.utils.SensorsBridge;
import com.gh.gamecenter.core.AppExecutor;
import com.gh.gamecenter.core.utils.GsonUtils;
import com.gh.gamecenter.core.utils.MtaHelper;
@ -32,8 +33,6 @@ import com.halo.assistant.HaloApp;
import com.lightgame.config.CommonDebug;
import com.lightgame.utils.Utils;
import org.greenrobot.eventbus.EventBus;
import io.reactivex.schedulers.Schedulers;
import io.sentry.Sentry;
import io.sentry.android.core.SentryAndroid;
@ -118,13 +117,6 @@ public class DataUtils {
String originalGid = HaloApp.getInstance().getGid();
HaloApp.getInstance().setGid(gid);
// gid 变更时上报 gid 变更日志
if (!TextUtils.isEmpty(originalGid) && !originalGid.equals(gid)) {
NewFlatLogUtils.logGidChanged(originalGid, gid);
}
SensorsBridge.setGid(gid);
// 避免重复调用
if (!TextUtils.isEmpty(gid) && !gid.equals(originalGid)) {
GameSubstituteRepositoryHelper.updateSubstitutableGames();
@ -134,16 +126,6 @@ public class DataUtils {
// 避免初始化顺序问题导致 MetaUtil 一直持有空的 gid
MetaUtil.INSTANCE.refreshMeta();
ContentValues values = new ContentValues();
values.put(GhContentProvider.KEY_GID, gid);
values.put(GhContentProvider.KEY_ANDROID_ID, MetaUtil.getBase64EncodedAndroidId());
try {
HaloApp.getInstance().getContentResolver().insert(Uri.parse("content://com.gh.gamecenter.provider/device"), values);
} catch (Exception exception) {
SentryHelper.INSTANCE.onEvent("DEVICE_INSERT_ERROR", "exception_digest", exception.getLocalizedMessage());
exception.printStackTrace();
}
}
@Override
@ -181,8 +163,6 @@ public class DataUtils {
values.put(GhContentProvider.KEY_IS_ADULT, false);
}
EventBus.getDefault().post(new EBReuse(Constants.EB_REALNAME_RESULT));
// new GhContentProvider().localInsert( HaloApp.getInstance().getApplication(),values);
try {
// Unknown URL content://com.gh.gamecenter.provider/certification

Some files were not shown because too many files have changed in this diff Show More