Compare commits
27 Commits
feature-mo
...
v5.14.5-63
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b178c0bbe | |||
| 6270f9fb98 | |||
| 0306caadb5 | |||
| 30268a5cda | |||
| 5d4f489ddd | |||
| 102d285c09 | |||
| 6b0611e05f | |||
| 384469bcae | |||
| 0aeb37a5eb | |||
| 900ee8e641 | |||
| bad1e32fda | |||
| b602960882 | |||
| fadd165e68 | |||
| 255b6ea141 | |||
| 7712039804 | |||
| fee65172d1 | |||
| b09f0cde18 | |||
| cb355b2490 | |||
| 806ceee7e7 | |||
| 0cc8904852 | |||
| 1ffb58feea | |||
| 3ae27ebdb6 | |||
| aab422662a | |||
| 8193b9ec9f | |||
| 13929f4dc5 | |||
| 0ea0834140 | |||
| 7efdb5e432 |
@ -8,23 +8,24 @@ import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
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.SuggestionActivity;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse;
|
||||
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.entity.GameGuidePopupEntity;
|
||||
import com.gh.gamecenter.entity.NewApiSettingsEntity;
|
||||
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.VSetting;
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse;
|
||||
import com.gh.gamecenter.common.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.halo.assistant.HaloApp;
|
||||
@ -63,8 +64,9 @@ public class Config {
|
||||
|
||||
private static SettingsEntity mSettingsEntity;
|
||||
private static NewSettingsEntity mNewSettingsEntity;
|
||||
private static NewApiSettingsEntity mNewApiSettingsEntity;
|
||||
|
||||
private static NewSettingsEntity.NightMode mNightModeSetting;
|
||||
private static NewApiSettingsEntity.NightMode mNightModeSetting;
|
||||
private static VSetting mVSetting;
|
||||
private static GameGuidePopupEntity mGameGuidePopupEntity;
|
||||
private static SharedPreferences mDefaultSharedPreferences;
|
||||
@ -221,11 +223,11 @@ public class Config {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static NewSettingsEntity.NightMode getNightModeSetting() {
|
||||
public static NewApiSettingsEntity.NightMode getNightModeSetting() {
|
||||
if (mNightModeSetting != null) {
|
||||
return mNightModeSetting;
|
||||
} else if (mNewSettingsEntity != null && mNewSettingsEntity.getNightMode() != null) {
|
||||
return mNewSettingsEntity.getNightMode();
|
||||
} else if (mNewApiSettingsEntity != null && mNewApiSettingsEntity.getNightMode() != null) {
|
||||
return mNewApiSettingsEntity.getNightMode();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -350,9 +352,6 @@ 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));
|
||||
}
|
||||
});
|
||||
@ -370,25 +369,21 @@ public class Config {
|
||||
});
|
||||
}
|
||||
|
||||
if (mNightModeSetting == null) {
|
||||
if (mNewApiSettingsEntity == null) {
|
||||
RetrofitManager.getInstance()
|
||||
.getNewApi().getNewSettings(PackageUtils.getGhVersionName(), channel)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BiResponse<NewSettingsEntity>() {
|
||||
.subscribe(new BiResponse<NewApiSettingsEntity>() {
|
||||
@Override
|
||||
public void onSuccess(NewSettingsEntity data) {
|
||||
public void onSuccess(NewApiSettingsEntity data) {
|
||||
mNewApiSettingsEntity = data;
|
||||
mNightModeSetting = data.getNightMode();
|
||||
if (HaloApp.getInstance().isNewForThisVersion && mNightModeSetting != null && mNightModeSetting.getInstall()) {
|
||||
DarkModeUtils.INSTANCE.updateFollowSystemDarkModeToSp(true);
|
||||
DarkModeUtils.INSTANCE.updateAppDarkModeStatusToSp(true);
|
||||
DarkModeUtils.INSTANCE.initDarkMode();
|
||||
}
|
||||
|
||||
if (mNewSettingsEntity != null) {
|
||||
mNewSettingsEntity.setNightMode(mNightModeSetting);
|
||||
SPUtils.setString(Constants.SP_NEW_SETTINGS, GsonUtils.toJson(data));
|
||||
}
|
||||
SPUtils.setString(Constants.SP_NEW_API_SETTINGS, GsonUtils.toJson(data));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -681,6 +681,36 @@ object DirectUtils {
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToFeedbackCompat(
|
||||
context: Context,
|
||||
content: String? = null,
|
||||
hintType: String? = null,
|
||||
isQaFeedback: Boolean = false,
|
||||
qaContentId: String? = "",
|
||||
entrance: String? = null
|
||||
) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_TO, SuggestionActivity::class.java.simpleName)
|
||||
if (isQaFeedback) {
|
||||
bundle.putBoolean(KEY_IS_QA_FEEDBACK, true)
|
||||
bundle.putString(KEY_QA_CONTENT_ID, qaContentId)
|
||||
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.normal)
|
||||
} else {
|
||||
bundle.putString(KEY_CONTENT, content)
|
||||
if (TextUtils.isEmpty(hintType)) {
|
||||
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.gameQuestion)
|
||||
bundle.putString(KEY_SUGGEST_HINT_TYPE, KEY_PLUGIN)
|
||||
} else {
|
||||
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.normal)
|
||||
bundle.putString(KEY_SUGGEST_HINT_TYPE, hintType)
|
||||
}
|
||||
}
|
||||
|
||||
jumpActivityCompat(context, bundle)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToDownloadManager(context: Context, entrance: String? = null) {
|
||||
val bundle = Bundle()
|
||||
|
||||
@ -37,6 +37,32 @@ import java.util.Set;
|
||||
|
||||
public class EntranceUtils {
|
||||
|
||||
public static void jumpActivityCompat(Context context, Bundle bundle) {
|
||||
bundle.putBoolean(KEY_REQUIRE_REDIRECT, true);
|
||||
|
||||
if (HaloApp.getInstance().isRunningForeground || HaloApp.getInstance().isAlreadyUpAndRunning) {
|
||||
// 应用正在运行,前台或后台
|
||||
String to = bundle.getString(KEY_TO);
|
||||
Class<?> clazz = ClassUtils.forName(to);
|
||||
if (clazz == null) clazz = MainActivity.class;
|
||||
if (ToolbarFragment.class.isAssignableFrom(clazz)) { // 兼容ToolbarFragment
|
||||
ToolBarActivity.startFragmentNewTask(context, (Class<? extends ToolbarFragment>) clazz, bundle);
|
||||
} else {
|
||||
Intent intent1 = new Intent(context, clazz);
|
||||
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
// 如果 activity 名称有 singleton 的就添加 reorder_to_front 标签 (有点粗暴有点蠢,但暂时就先这样吧 :C )
|
||||
if (clazz.getSimpleName().toLowerCase().contains("singleton")) {
|
||||
intent1.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
}
|
||||
intent1.putExtras(bundle);
|
||||
context.startActivity(intent1);
|
||||
}
|
||||
} else {
|
||||
// 应用未在运行
|
||||
context.startActivity(SplashScreenActivity.getSplashScreenIntent(context, bundle));
|
||||
}
|
||||
}
|
||||
|
||||
public static void jumpActivity(Context context, Bundle bundle) {
|
||||
bundle.putBoolean(KEY_REQUIRE_REDIRECT, true);
|
||||
|
||||
|
||||
@ -36,6 +36,7 @@ import com.gh.common.util.PackageUtils;
|
||||
import com.gh.gamecenter.core.utils.PageSwitchDataHelper;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.core.utils.SentryHelper;
|
||||
import com.gh.gamecenter.download.DownloadedGameIdAndPackageNameDao;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
@ -389,12 +390,16 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
* 清理不存在本地 APK 文件的任务
|
||||
*/
|
||||
public void clearTasksThatFileBeenDeleted() {
|
||||
for (DownloadEntity entity : getAllDownloadEntity()) {
|
||||
if (entity.getStatus() == DownloadStatus.done) {
|
||||
if (FileUtils.isEmptyFile(entity.getPath())) {
|
||||
cancel(entity.getUrl());
|
||||
try {
|
||||
for (DownloadEntity entity : getAllDownloadEntity()) {
|
||||
if (entity.getStatus() == DownloadStatus.done) {
|
||||
if (FileUtils.isEmptyFile(entity.getPath())) {
|
||||
cancel(entity.getUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
SentryHelper.INSTANCE.onEvent("CLEAR_DELETED_TASK_ERROR", "exception_digest", e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -180,6 +180,7 @@ public class MainActivity extends BaseActivity {
|
||||
showAd = getIntent().getBooleanExtra(SHOW_AD, false) && savedInstanceState == null;
|
||||
|
||||
HaloApp.getInstance().initFresco();
|
||||
HaloApp.getInstance().isAlreadyUpAndRunning = true;
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setStatusBarColor(Color.TRANSPARENT);
|
||||
|
||||
@ -137,7 +137,7 @@ public class SkipActivity extends BaseActivity {
|
||||
if (!TextUtils.isEmpty(qaId)) {
|
||||
DirectUtils.directToQa(this, qaTitle, qaId);
|
||||
} else if ("vgame".equals(suggestionType)) {
|
||||
DirectUtils.directToFeedback(this, content, "game", isQaFeedback, qaContentId, EntranceConsts.ENTRANCE_BROWSER);
|
||||
DirectUtils.directToFeedbackCompat(this, content, "game", isQaFeedback, qaContentId, EntranceConsts.ENTRANCE_BROWSER);
|
||||
} else {
|
||||
DirectUtils.directToFeedback(this, content, null, isQaFeedback, qaContentId, EntranceConsts.ENTRANCE_BROWSER);
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.gamecenter
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
@ -25,6 +26,7 @@ import com.gh.common.util.GameSubstituteRepositoryHelper.updateGameSubstituteRep
|
||||
import com.gh.common.util.UsageStatsHelper.checkAndPostUsageStats
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
import com.gh.gamecenter.common.callback.SimpleCallback
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.tracker.TrackerLogger
|
||||
@ -60,6 +62,8 @@ class SplashScreenActivity : BaseActivity() {
|
||||
private var mShouldPrefetchData = true
|
||||
|
||||
private val mPermissions = arrayOf(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
PermissionHelper.PERMISSION_GET_INSTALLED_LIST
|
||||
)
|
||||
|
||||
@ -149,42 +153,41 @@ class SplashScreenActivity : BaseActivity() {
|
||||
private fun showPrivacyDialog(guideLayout: ViewPager) {
|
||||
NewPrivacyPolicyDialogFragment.show(this, null) { isSuccess: Boolean ->
|
||||
if (isSuccess) {
|
||||
guideLayout.visibility = View.VISIBLE
|
||||
SPUtils.setBoolean(Constants.SP_BRAND_NEW_USER, false)
|
||||
// guideLayout.visibility = View.VISIBLE
|
||||
// SPUtils.setBoolean(Constants.SP_BRAND_NEW_USER, false)
|
||||
//
|
||||
// // 恢复畅玩数据
|
||||
// VHelper.recoverVDataIfPossible()
|
||||
//
|
||||
// requestPermission()
|
||||
//
|
||||
// // 检查是否有旧版本光环,有就删掉
|
||||
// AppExecutor.ioExecutor.execute { deleteOutdatedUpdatePackage() }
|
||||
// if (mStartMainActivityDirectly) {
|
||||
// launchMainActivity()
|
||||
// }
|
||||
|
||||
// 恢复畅玩数据
|
||||
VHelper.recoverVDataIfPossible()
|
||||
mShouldPrefetchData = false
|
||||
prefetchData()
|
||||
|
||||
requestPermission()
|
||||
|
||||
// 检查是否有旧版本光环,有就删掉
|
||||
AppExecutor.ioExecutor.execute { deleteOutdatedUpdatePackage() }
|
||||
if (mStartMainActivityDirectly) {
|
||||
launchMainActivity()
|
||||
} else {
|
||||
mShouldPrefetchData = false
|
||||
prefetchData()
|
||||
val callback = object : SimpleCallback<Boolean> {
|
||||
override fun onCallback(arg: Boolean) {
|
||||
// Dialog dismiss 后的回调
|
||||
guideLayout.visibility = View.VISIBLE
|
||||
SPUtils.setBoolean(Constants.SP_BRAND_NEW_USER, false)
|
||||
if (arg) {
|
||||
requestPermission()
|
||||
} else {
|
||||
mStartMainActivityDirectly = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// val callback = object : SimpleCallback<Boolean> {
|
||||
// override fun onCallback(arg: Boolean) {
|
||||
// // Dialog dismiss 后的回调
|
||||
// guideLayout.visibility = View.VISIBLE
|
||||
// SPUtils.setBoolean(Constants.SP_BRAND_NEW_USER, false)
|
||||
// if (arg) {
|
||||
// requestPermission()
|
||||
// } else {
|
||||
// mStartMainActivityDirectly = false
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// mViewModel?.showPrivacyPolicy({
|
||||
// DialogUtils.showPrivacyPolicyDialog(this@SplashScreenActivity, it, callback)
|
||||
// }, {
|
||||
// DialogUtils.showPrivacyPolicyDialog(this@SplashScreenActivity, PrivacyPolicyEntity.createDefaultData(), callback)
|
||||
// })
|
||||
|
||||
mViewModel?.showPrivacyPolicy({
|
||||
DialogUtils.showPrivacyPolicyDialog(this@SplashScreenActivity, it, callback)
|
||||
}, {
|
||||
DialogUtils.showPrivacyPolicyDialog(this@SplashScreenActivity, PrivacyPolicyEntity.createDefaultData(), callback)
|
||||
})
|
||||
} else {
|
||||
DialogUtils.showPrivacyPolicyDisallowDialog(this, PrivacyPolicyEntity.createDefaultData(), object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
@ -381,10 +384,10 @@ class SplashScreenActivity : BaseActivity() {
|
||||
private fun checkAndRequestPermission() {
|
||||
if (EasyPermissions.hasPermissions(this, *mPermissions)) {
|
||||
// 恢复畅玩数据
|
||||
// VHelper.recoverVDataIfPossible()
|
||||
VHelper.recoverVDataIfPossible()
|
||||
|
||||
// 检查是否有旧版本光环,有就删掉
|
||||
// AppExecutor.ioExecutor.execute { deleteOutdatedUpdatePackage() }
|
||||
AppExecutor.ioExecutor.execute { deleteOutdatedUpdatePackage() }
|
||||
if (mStartMainActivityDirectly) {
|
||||
if (com.gh.gamecenter.common.BuildConfig.BUILD_TIME != 0L) {
|
||||
showGitLogDialogIfNeeded()
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
package com.gh.gamecenter.entity
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class NewApiSettingsEntity(
|
||||
@SerializedName("night_mode")
|
||||
var nightMode: NightMode? = null,
|
||||
) {
|
||||
/**
|
||||
*
|
||||
* "icon": false, // 是否显示切换,true显示
|
||||
* "setting": false, // 设置页面是否显示,true显示
|
||||
* "install": false, // 安装时的默认值,true开启
|
||||
*/
|
||||
data class NightMode(
|
||||
val icon: Boolean,
|
||||
val setting: Boolean,
|
||||
val install: Boolean
|
||||
)
|
||||
}
|
||||
@ -5,8 +5,6 @@ import com.google.gson.annotations.SerializedName
|
||||
data class NewSettingsEntity(
|
||||
@SerializedName("install_model")
|
||||
var installModel: InstallModel? = null,
|
||||
@SerializedName("night_mode")
|
||||
var nightMode: NightMode? = null,
|
||||
) {
|
||||
data class InstallModel(
|
||||
var status: String = "",
|
||||
@ -14,16 +12,4 @@ data class NewSettingsEntity(
|
||||
@SerializedName("white_list")
|
||||
var whiteList: ArrayList<String>? = arrayListOf()
|
||||
)
|
||||
|
||||
/**
|
||||
*
|
||||
* "icon": false, // 是否显示切换,true显示
|
||||
* "setting": false, // 设置页面是否显示,true显示
|
||||
* "install": false, // 安装时的默认值,true开启
|
||||
*/
|
||||
data class NightMode(
|
||||
val icon: Boolean,
|
||||
val setting: Boolean,
|
||||
val install: Boolean
|
||||
)
|
||||
}
|
||||
@ -23,10 +23,10 @@ data class PrivacyPolicyEntity(
|
||||
icon = "res:///" + R.drawable.permission_storage,
|
||||
name = "存储权限",
|
||||
intro = "用于下载游戏,以及实现内容缓存提升浏览体验"))
|
||||
permissions.add(PermissionsEntity(
|
||||
icon = "res:///" + R.drawable.permission_phone_state,
|
||||
name = "设备信息",
|
||||
intro = "为保障您的账号安全及使用软件与服务可安全运行"))
|
||||
// permissions.add(PermissionsEntity(
|
||||
// icon = "res:///" + R.drawable.permission_phone_state,
|
||||
// name = "设备信息",
|
||||
// intro = "为保障您的账号安全及使用软件与服务可安全运行"))
|
||||
// permissions.add(PermissionsEntity(
|
||||
// icon = "res:///" + R.drawable.permission_sdk,
|
||||
// name = "第三方SDK使用信息提醒",
|
||||
|
||||
@ -948,7 +948,7 @@ public interface ApiService {
|
||||
* 新的设置接口
|
||||
*/
|
||||
@GET("settings")
|
||||
Single<NewSettingsEntity> getNewSettings(@Query("version") String version, @Query("channel") String channel);
|
||||
Single<NewApiSettingsEntity> getNewSettings(@Query("version") String version, @Query("channel") String channel);
|
||||
|
||||
/**
|
||||
* 获取新的配置信息,因为旧的已经太大了避免冲突
|
||||
|
||||
@ -71,12 +71,9 @@ import com.lightgame.utils.Utils;
|
||||
import com.llew.huawei.verifier.LoadedApkHuaWei;
|
||||
import com.shuyu.gsyvideoplayer.cache.CacheFactory;
|
||||
import com.shuyu.gsyvideoplayer.player.PlayerFactory;
|
||||
import com.walkud.rom.checker.Rom;
|
||||
import com.walkud.rom.checker.RomIdentifier;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import io.reactivex.plugins.RxJavaPlugins;
|
||||
@ -102,6 +99,8 @@ public class HaloApp extends MultiDexApplication {
|
||||
public boolean isBrandNewInstall = false; // 当前用户是否是安装光环后第一次打开
|
||||
public boolean isNewForThisVersion = false; // 当前用户是否是安装当前版本后第一次打开 (包括全新和更新)
|
||||
public boolean isRunningForeground = false; // 标记当前 APP 是否处于前台运行中
|
||||
|
||||
public boolean isAlreadyUpAndRunning = false; // 应用是否处于运行中状态 (进入到 MainActivity 就当运行中)
|
||||
private List<String> webViewAbiList;
|
||||
private ChannelProvider mChannelProvider = new ChannelProviderImp();
|
||||
private final ServiceLoader<IApplication> mApplicationList = ServiceLoader.load(IApplication.class, this.getClass().getClassLoader());
|
||||
|
||||
@ -7,8 +7,8 @@ ext {
|
||||
targetSdkVersion = 28
|
||||
|
||||
// application info (每个大版本之间的 versionCode 增加 20)
|
||||
versionCode = 631
|
||||
versionName = "5.14.1"
|
||||
versionCode = 635
|
||||
versionName = "5.14.5"
|
||||
applicationId = "com.gh.gamecenter"
|
||||
|
||||
// AndroidX
|
||||
|
||||
@ -80,6 +80,9 @@ import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.sentry.Breadcrumb;
|
||||
import io.sentry.Sentry;
|
||||
import io.sentry.SentryLevel;
|
||||
import kotlin.Pair;
|
||||
import pub.devrel.easypermissions.EasyPermissions;
|
||||
|
||||
@ -564,12 +567,19 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
|
||||
// 这里根据调用栈是否存在 DarkModeUtils 来确定是否为系统回调
|
||||
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
|
||||
for (StackTraceElement element : trace) {
|
||||
if (element.getClassName().contains(DarkModeUtils.class.getSimpleName())) {
|
||||
if (element.getClassName().equals(DarkModeUtils.class.getName())) {
|
||||
isCalledBySystem = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Breadcrumb breadcrumb = new Breadcrumb();
|
||||
breadcrumb.setCategory("onConfigurationChanged");
|
||||
breadcrumb.setMessage("IsCalledBySystem " + isCalledBySystem + ","
|
||||
+ this.getClass().getSimpleName() + " lifecycle is " + getLifecycle().getCurrentState());
|
||||
breadcrumb.setLevel(SentryLevel.INFO);
|
||||
Sentry.addBreadcrumb(breadcrumb);
|
||||
|
||||
if (BuildConfig.IS_DARK_MODE_ON && mIsDarkModeOn != DarkModeUtils.INSTANCE.isDarkModeOn(this)) {
|
||||
// 当且仅当页面处于可见状态时响应新的 UiMode,并将它传递下去
|
||||
// (在不可见的 activity 调用 onConfigurationChanged 方法有一定概率触发 ANR)
|
||||
|
||||
@ -207,6 +207,9 @@ public class Constants {
|
||||
// 补充配置项
|
||||
public static final String SP_NEW_SETTINGS = "new_settings";
|
||||
|
||||
// 新接口配置项
|
||||
public static final String SP_NEW_API_SETTINGS = "new_api_settings";
|
||||
|
||||
// 畅玩组件的配置
|
||||
public static final String SP_V_SETTINGS = "v_settings";
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.gamecenter.common.utils
|
||||
|
||||
import android.animation.Animator
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
@ -331,7 +332,8 @@ fun Fragment.ifLogin(entrance: String, action: (() -> Unit)? = null) {
|
||||
}
|
||||
|
||||
fun Context.ifLogin(entrance: String, action: (() -> Unit)? = null) {
|
||||
val checkLoginConfig = ARouter.getInstance().build(RouteConsts.provider.checkLogin).navigation() as? ICheckLoginProvider
|
||||
val checkLoginConfig =
|
||||
ARouter.getInstance().build(RouteConsts.provider.checkLogin).navigation() as? ICheckLoginProvider
|
||||
checkLoginConfig?.checkLogin(this, entrance, action)
|
||||
}
|
||||
|
||||
@ -379,8 +381,10 @@ fun String.containHtmlTag(): Boolean {
|
||||
*/
|
||||
fun Fragment.showRegulationTestDialogIfNeeded(action: (() -> Unit)) {
|
||||
val provider = ARouter.getInstance().build(RouteConsts.provider.directUtils).navigation() as? IDirectProvider
|
||||
val userManagerProvider = ARouter.getInstance().build(RouteConsts.provider.userManager).navigation() as? IUserManagerProvider
|
||||
val dialogUtils = ARouter.getInstance().build(RouteConsts.provider.dialogUtils).navigation() as? IDialogUtilsProvider
|
||||
val userManagerProvider =
|
||||
ARouter.getInstance().build(RouteConsts.provider.userManager).navigation() as? IUserManagerProvider
|
||||
val dialogUtils =
|
||||
ARouter.getInstance().build(RouteConsts.provider.dialogUtils).navigation() as? IDialogUtilsProvider
|
||||
if (userManagerProvider?.userShouldTakeRegulationBaseOnLastRemind() == true) {
|
||||
dialogUtils?.showRegulationTestDialog(requireContext(),
|
||||
{ provider?.directToRegulationTestPage(requireContext()) },
|
||||
@ -392,8 +396,10 @@ fun Fragment.showRegulationTestDialogIfNeeded(action: (() -> Unit)) {
|
||||
|
||||
fun Context.showRegulationTestDialogIfNeeded(action: (() -> Unit)) {
|
||||
val provider = ARouter.getInstance().build(RouteConsts.provider.directUtils).navigation() as? IDirectProvider
|
||||
val userManagerProvider = ARouter.getInstance().build(RouteConsts.provider.userManager).navigation() as? IUserManagerProvider
|
||||
val dialogUtils = ARouter.getInstance().build(RouteConsts.provider.dialogUtils).navigation() as? IDialogUtilsProvider
|
||||
val userManagerProvider =
|
||||
ARouter.getInstance().build(RouteConsts.provider.userManager).navigation() as? IUserManagerProvider
|
||||
val dialogUtils =
|
||||
ARouter.getInstance().build(RouteConsts.provider.dialogUtils).navigation() as? IDialogUtilsProvider
|
||||
if (userManagerProvider?.userShouldTakeRegulationBaseOnLastRemind() == true) {
|
||||
dialogUtils?.showRegulationTestDialog(this,
|
||||
{ provider?.directToRegulationTestPage(this) },
|
||||
@ -864,8 +870,10 @@ fun CharSequence.interceptUrlSpanAndRoundImageSpan(clickedCallback: ((url: Strin
|
||||
|
||||
override fun onClick(widget: View) {
|
||||
clickedCallback?.invoke(it.url)
|
||||
val webActivityProvider = ARouter.getInstance().build(RouteConsts.provider.webActivity).navigation() as? IWebProvider
|
||||
val provider = ARouter.getInstance().build(RouteConsts.provider.defaultUrlHandler).navigation() as IDefaultUrlHandlerProvider
|
||||
val webActivityProvider =
|
||||
ARouter.getInstance().build(RouteConsts.provider.webActivity).navigation() as? IWebProvider
|
||||
val provider = ARouter.getInstance().build(RouteConsts.provider.defaultUrlHandler)
|
||||
.navigation() as IDefaultUrlHandlerProvider
|
||||
if (!provider.interceptUrl(widget.context, it.url, "")) {
|
||||
webActivityProvider?.getIntent(widget.context, it.url, true)?.run {
|
||||
widget.context.startActivity(this)
|
||||
@ -992,8 +1000,10 @@ fun Context.doOnMainProcessOnly(callback: EmptyCallback) {
|
||||
* 虽然现在我们没有了友盟以后只是单进程APP,但在 debug 模式下还有 whatTheStack 这个进程如果不限定主进程会出现奇奇怪怪的问题 (BroadcastReceiver相关)
|
||||
*/
|
||||
inline fun Context.doOnMainProcessOnly(f: () -> Unit) {
|
||||
val buildConfig = ARouter.getInstance().build(RouteConsts.provider.buildConfig).navigation() as? IBuildConfigProvider
|
||||
val packageUtilsConfig = ARouter.getInstance().build(RouteConsts.provider.packageUtils).navigation() as? IPackageUtilsProvider
|
||||
val buildConfig =
|
||||
ARouter.getInstance().build(RouteConsts.provider.buildConfig).navigation() as? IBuildConfigProvider
|
||||
val packageUtilsConfig =
|
||||
ARouter.getInstance().build(RouteConsts.provider.packageUtils).navigation() as? IPackageUtilsProvider
|
||||
val processName = packageUtilsConfig?.obtainProcessName(this)
|
||||
if (processName == null || buildConfig?.getApplicationId() == processName) {
|
||||
f.invoke()
|
||||
@ -1005,8 +1015,10 @@ inline fun Context.doOnMainProcessOnly(f: () -> Unit) {
|
||||
}
|
||||
|
||||
inline fun doOnMainProcessOnly(f: () -> Unit) {
|
||||
val buildConfig = ARouter.getInstance().build(RouteConsts.provider.buildConfig).navigation() as? IBuildConfigProvider
|
||||
val packageUtilsConfig = ARouter.getInstance().build(RouteConsts.provider.packageUtils).navigation() as? IPackageUtilsProvider
|
||||
val buildConfig =
|
||||
ARouter.getInstance().build(RouteConsts.provider.buildConfig).navigation() as? IBuildConfigProvider
|
||||
val packageUtilsConfig =
|
||||
ARouter.getInstance().build(RouteConsts.provider.packageUtils).navigation() as? IPackageUtilsProvider
|
||||
val processName = packageUtilsConfig?.obtainProcessName(HaloApp.getInstance())
|
||||
if (processName == null || buildConfig?.getApplicationId() == processName) {
|
||||
f.invoke()
|
||||
@ -1251,9 +1263,19 @@ fun String.emojiCount(): Int {
|
||||
/**
|
||||
* WebView启用强制深色模式
|
||||
*/
|
||||
@SuppressLint("RequiresFeature")
|
||||
fun WebView.enableForceDark(isDarkModeOn: Boolean) {
|
||||
if (BuildConfig.IS_DARK_MODE_ON && WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
|
||||
WebSettingsCompat.setForceDark(settings, if (isDarkModeOn) WebSettingsCompat.FORCE_DARK_ON else WebSettingsCompat.FORCE_DARK_OFF)
|
||||
val isFeatureSupported = try {
|
||||
WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)
|
||||
} catch (throwable: Throwable) {
|
||||
throwable.printStackTrace()
|
||||
false
|
||||
}
|
||||
if (BuildConfig.IS_DARK_MODE_ON && isFeatureSupported) {
|
||||
WebSettingsCompat.setForceDark(
|
||||
settings,
|
||||
if (isDarkModeOn) WebSettingsCompat.FORCE_DARK_ON else WebSettingsCompat.FORCE_DARK_OFF
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
package com.gh.gamecenter.common.utils
|
||||
|
||||
import com.gh.gamecenter.common.json.JsonObjectBuilder
|
||||
import com.gh.gamecenter.common.json.json
|
||||
import com.gh.gamecenter.common.loghub.LoghubUtils
|
||||
import com.lightgame.utils.Utils
|
||||
import org.json.JSONObject
|
||||
|
||||
object NewFlagLogUtils {
|
||||
|
||||
private fun log(jsonObject: JSONObject, logStore: String, uploadImmediately: Boolean) {
|
||||
Utils.log("NewFlatLogUtils", jsonObject.toString(4))
|
||||
LoghubUtils.log(jsonObject, logStore, uploadImmediately, true)
|
||||
}
|
||||
|
||||
private fun parseAndPutMeta(): JsonObjectBuilder.() -> Unit = {
|
||||
val meta = LogUtils.getMetaObject()
|
||||
val metaKeys = meta.keys()
|
||||
while (metaKeys.hasNext()) {
|
||||
val key: String = metaKeys.next().toString()
|
||||
val value = meta.getString(key)
|
||||
key to value
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录外部存储权限提示弹窗出现
|
||||
*/
|
||||
fun logExternalStoragePermissionDialogAppearance() {
|
||||
val json = json {
|
||||
"event" to "storage_permission_pop_show"
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录外部存储权限弹窗行为
|
||||
*/
|
||||
fun logExternalStoragePermissionDialogAction(action: String) {
|
||||
val json = json {
|
||||
"event" to "storage_permission_pop_click"
|
||||
"button" to action
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
}
|
||||
@ -244,24 +244,41 @@ object PermissionHelper {
|
||||
}
|
||||
|
||||
private fun showDialogBeforeRequestingStorageDialog(context: FragmentActivity, emptyCallback: EmptyCallback) {
|
||||
// 是否点击外部区域触发弹窗消失
|
||||
var isCanceledByClickingOutside = true
|
||||
|
||||
NewFlagLogUtils.logExternalStoragePermissionDialogAppearance()
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
title = "权限申请",
|
||||
content = "光环助手将向您申请开启设备的存储权限,以保证能正常使用相关功能。拒绝授权将无法正常使用部分功能。",
|
||||
cancelText = "放弃",
|
||||
confirmText = "去授权",
|
||||
cancelClickCallback = null,
|
||||
confirmClickCallback = { checkStoragePermissionBeforeAction(context, emptyCallback) },
|
||||
cancelClickCallback = {
|
||||
isCanceledByClickingOutside = false
|
||||
NewFlagLogUtils.logExternalStoragePermissionDialogAction("放弃")
|
||||
},
|
||||
confirmClickCallback = {
|
||||
isCanceledByClickingOutside = false
|
||||
checkStoragePermissionBeforeAction(context, emptyCallback)
|
||||
NewFlagLogUtils.logExternalStoragePermissionDialogAction("去授权")
|
||||
},
|
||||
extraConfig = DialogHelper.Config(hint = "查看权限应用场景"),
|
||||
uiModificationCallback = {
|
||||
it.hintTv.setTextColor(ContextCompat.getColor(context, R.color.theme_font))
|
||||
it.hintTv.setOnClickListener {
|
||||
val provider = ARouter.getInstance().build(RouteConsts.provider.directUtils).navigation() as? IDirectProvider
|
||||
val provider =
|
||||
ARouter.getInstance().build(RouteConsts.provider.directUtils).navigation() as? IDirectProvider
|
||||
provider?.directToWebView(context, Constants.PERMISSION_SCENARIO_ADDRESS, "(权限弹窗)")
|
||||
NewFlagLogUtils.logExternalStoragePermissionDialogAction("查看权限应用场景")
|
||||
}
|
||||
it.contentTv.setTextColor(ContextCompat.getColor(context, R.color.text_title))
|
||||
}
|
||||
)
|
||||
)?.setOnDismissListener {
|
||||
if (isCanceledByClickingOutside) {
|
||||
NewFlagLogUtils.logExternalStoragePermissionDialogAction("点击弹窗以外空白区域")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showDialogBeforeRequestingGetInstalledListDialog(context: FragmentActivity, emptyCallback: EmptyCallback) {
|
||||
|
||||
Reference in New Issue
Block a user