Compare commits

...

27 Commits

Author SHA1 Message Date
7712039804 chore: 版本更新至 5.14.3 2022-11-08 15:15:57 +08:00
fee65172d1 Merge branch 'hotfix-v5.14.2-632-delete_apk_crash' into 'release'
fix: 捕抓清理安装包时的 concurrent 异常

See merge request halo/android/assistant-android!419
2022-11-08 15:13:36 +08:00
b09f0cde18 fix: 捕抓清理安装包时的 concurrent 异常 2022-11-08 15:04:12 +08:00
cb355b2490 Merge branch 'hotfix-v5.14.2-632-wrong_dark_mode_setting' into 'release'
fix: 修复错误的深色模式切换开关配置

See merge request halo/android/assistant-android!418
2022-11-08 12:01:27 +08:00
806ceee7e7 Merge branch 'hotfix-v5.14.2-632-super_did_not_called_crash' into 'release'
fix: 修复因为混淆问题导致 onConfigurationChanged 没有调用 super.onConfigurationChanged 而造成的闪退

See merge request halo/android/assistant-android!417
2022-11-08 11:55:35 +08:00
0cc8904852 fix: 修复错误的深色模式切换开关配置 2022-11-08 11:33:33 +08:00
1ffb58feea fix: 修复因为混淆问题导致 onConfigurationChanged 没有调用 super.onConfigurationChanged 而造成的闪退 2022-11-08 11:09:32 +08:00
3ae27ebdb6 chore: 版本更新至 5.14.2 2022-11-01 17:20:30 +08:00
aab422662a Merge branch 'hotfix-v5.14.1-631-onConfigurationChanged' into 'release'
fix: 添加 onConfigurationChanged 日志辅助闪退确定问题

See merge request halo/android/assistant-android!407
2022-11-01 17:19:23 +08:00
8193b9ec9f fix: 添加 onConfigurationChanged 日志辅助闪退确定问题 2022-11-01 16:23:54 +08:00
13929f4dc5 Merge branch 'hotfix-v5.14.1-631-webview_dark_error' into 'release'
fix: 修复web页面开启夜间模式闪退问题

See merge request halo/android/assistant-android!404
2022-11-01 16:18:12 +08:00
0ea0834140 fix: 修复web页面开启夜间模式闪退问题 2022-11-01 16:09:05 +08:00
7efdb5e432 Merge branch 'hotfix-v5.14.1-631-simulator_sync_error' into 'release'
fix: 修复模拟器游戏列表可能出现的服务端为空,本地不为空的问题

See merge request halo/android/assistant-android!393
2022-10-31 18:51:40 +08:00
681ba37c4e Merge branch 'hotfix-v5.14.1-631-simulator_sync_error' into 'release'
fix: 修复模拟器游戏列表可能出现的服务端为空,本地不为空的问题

See merge request halo/android/assistant-android!393
2022-10-31 14:23:57 +08:00
d4d71d27ce fix: 修复模拟器游戏列表可能出现的服务端为空,本地不为空的问题 2022-10-31 13:47:10 +08:00
987ab1ccc9 Merge branch 'hotfix-v5.14.1-631-clean_apk_crash' into 'release'
修复清理 APK 时因为原图标过大导致的闪退

See merge request halo/android/assistant-android!392
2022-10-31 12:41:56 +08:00
8863b02c7a fix: 修复安装包清理遇到原始图标过大而造成的闪退问题 2022-10-31 11:41:02 +08:00
a94bb4dcb5 fix: 修复模拟器运行即闪退的问题 2022-10-28 16:22:29 +08:00
195d9343eb chore: 版本更新至 5.14.1 2022-10-28 15:45:09 +08:00
997bfdf93d Merge branch 'hotfix-v5.14.0-630-vector_crash' into 'release'
fix:修复5.0以下系统部分矢量图加载出错导致无法显示的问题

See merge request halo/android/assistant-android!373
2022-10-27 15:34:53 +08:00
de712065f5 Merge branch 'hotfix-v5.14.0-630-soft_keyboard' into 'release'
fix: 修复评论页面发表评论内容跳转登录页面返回时软键盘消失的问题

See merge request halo/android/assistant-android!372
2022-10-27 14:56:33 +08:00
511449c709 fix:修复5.0以下系统部分矢量图加载出错导致无法显示的问题 2022-10-27 14:50:24 +08:00
03095b682b fix: 修复评论页面发表评论内容跳转登录页面返回时软键盘消失的问题 2022-10-27 14:32:48 +08:00
8437bfe1e3 Merge branch 'hotfix-v5.14.0-630-soft_keyboard' into 'release'
fix: 修复评论页面发表评论内容跳转登录页面返回时软键盘消失的问题

See merge request halo/android/assistant-android!369
2022-10-27 11:34:54 +08:00
a169ce1989 fix: 修复评论页面发表评论内容跳转登录页面返回时软键盘消失的问题 2022-10-27 10:48:14 +08:00
9690429e95 Merge branch 'hotfix-v5.14.0-630-banned_vote_error' into 'release'
【光环助手V5.15.0】违规整合-正式环境运营验收问题(19) https://git.shanqu.cc/pm/halo/halo-app-issues/-/issues/2129

See merge request halo/android/assistant-android!367
2022-10-25 16:58:08 +08:00
b1dff15234 fix: 【光环助手V5.15.0】违规整合-正式环境运营验收问题(19) https://git.shanqu.cc/pm/halo/halo-app-issues/-/issues/2129 2022-10-25 15:45:48 +08:00
12 changed files with 197 additions and 92 deletions

View File

@ -381,7 +381,6 @@ public class Config {
mNightModeSetting = data.getNightMode();
if (HaloApp.getInstance().isNewForThisVersion && mNightModeSetting != null && mNightModeSetting.getInstall()) {
DarkModeUtils.INSTANCE.updateFollowSystemDarkModeToSp(true);
DarkModeUtils.INSTANCE.updateAppDarkModeStatusToSp(true);
DarkModeUtils.INSTANCE.initDarkMode();
}

View File

@ -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());
}
}

View File

@ -4,6 +4,7 @@ import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Environment;
import android.view.View;
@ -117,7 +118,8 @@ public class CleanApkAdapter extends BaseRecyclerAdapter<KcSelectGameViewHolder>
appInfo.sourceDir = apk_path;
appInfo.publicSourceDir = apk_path;
Drawable apk_icon = appInfo.loadIcon(pm);
apkEntity.setGameBm(BitmapUtils.drawableToBitmap(apk_icon, true));
Bitmap originalBitmap = BitmapUtils.drawableToBitmap(apk_icon, true);
apkEntity.setGameBm(BitmapUtils.compressBitmap(originalBitmap, 100));
/** apk的绝对路劲 */
apkEntity.setGamePath(apk_path);
/** apk的版本名称 String */

View File

@ -152,8 +152,18 @@ open class BaseAnswerOrArticleItemViewHolder(itemView: View) : BaseRecyclerViewH
NewLogUtils.logRecommendFeedForumClick(contentType, entity.id, entity.bbs.id, bbsType)
}
MtaHelper.onEvent(getEventId(entrance), getKey(entrance), if (entity.bbs.name.isEmpty()) entity.community.name else entity.bbs.name)
itemView.context.startActivity(ForumDetailActivity.getIntent(itemView.context, entity.community.id, entrance))
MtaHelper.onEvent(
getEventId(entrance),
getKey(entrance),
if (entity.bbs.name.isEmpty()) entity.community.name else entity.bbs.name
)
itemView.context.startActivity(
ForumDetailActivity.getIntent(
itemView.context,
entity.community.id,
entrance
)
)
LogUtils.uploadAccessToBbs(entity.community.id, "文章外所属论坛")
}
@ -208,11 +218,24 @@ open class BaseAnswerOrArticleItemViewHolder(itemView: View) : BaseRecyclerViewH
itemView.context.startActivity(intent)
}
"answer" -> {
val intent = NewQuestionDetailActivity.getCommentIntent(it.context, entity.questions.id, entity.id, entrance, "")
val intent = NewQuestionDetailActivity.getCommentIntent(
it.context,
entity.questions.id,
entity.id,
entrance,
""
)
itemView.context.startActivity(intent)
}
"video" -> {
itemView.context.startActivity(ForumVideoDetailActivity.getIntent(itemView.context, entity.id, entity.community.id, true))
itemView.context.startActivity(
ForumVideoDetailActivity.getIntent(
itemView.context,
entity.id,
entity.community.id,
true
)
)
}
else -> {
val communityId = entity.community.id
@ -300,7 +323,8 @@ open class BaseAnswerOrArticleItemViewHolder(itemView: View) : BaseRecyclerViewH
commentCount.setCompoundDrawables(commentIcon, null, null, null)
commentCount.setTextColor(R.color.text_subtitleDesc.toColor(commentCount.context))
} else {
val commentCloseIcon = itemView.context.resources.getDrawable(R.drawable.community_comment_count_unavailable)
val commentCloseIcon =
itemView.context.resources.getDrawable(R.drawable.community_comment_count_unavailable)
commentCloseIcon.setBounds(0, 0, commentCloseIcon.minimumWidth, commentCloseIcon.minimumHeight)
commentCount.setCompoundDrawables(commentCloseIcon, null, null, null)
commentCount.setTextColor(R.color.text_body.toColor(commentCount.context))
@ -317,17 +341,24 @@ open class BaseAnswerOrArticleItemViewHolder(itemView: View) : BaseRecyclerViewH
RetrofitManager.getInstance()
.api.voteVideo(entity.id)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : BiResponse<ResponseBody>() {
override fun onSuccess(data: ResponseBody) {
//Utils.toast(getApplication(), "已点赞")
entity.count.vote = entity.count.vote + 1
entity.me.isVoted = true
voteCount.text = if (entity.count.vote > 0) entity.count.vote.toString() else "赞同"
EnergyTaskHelper.postEnergyTask("vote_video", entity.id)
setVoteAndCommentStyle(entity)
}
override fun onFailure(exception: Exception) {
super.onFailure(exception)
entity.count.vote = entity.count.vote - 1
entity.me.isVoted = false
voteCount.text = if (entity.count.vote > 0) entity.count.vote.toString() else "赞同"
if (exception is HttpException) {
ErrorHelper.handleError(
itemView.context,
exception.response()?.errorBody()?.string()
)
}
setVoteAndCommentStyle(entity)
}
})
@ -352,73 +383,75 @@ open class BaseAnswerOrArticleItemViewHolder(itemView: View) : BaseRecyclerViewH
EnergyTaskHelper.postEnergyTask("vote_answer", entity.id)
}
ToastUtils.showToast("已赞同")
entity.count.vote = entity.count.vote + 1
voteCount.text = if (entity.count.vote > 0) entity.count.vote.toString() else "赞同"
setVoteAndCommentStyle(entity)
}
override fun onFailure(e: HttpException?) {
ErrorHelper.handleErrorWithCustomizedHandler(itemView.context, e?.response()?.errorBody()?.string(), false) {
if (403008 == it) {
Utils.toast(itemView.context, R.string.ask_vote_hint)
true
} else if (403036 == it) {
Utils.toast(itemView.context, R.string.ask_vote_limit_hint)
true
} else if (404001 == it) {
Utils.toast(itemView.context, "内容可能已被删除")
entity.active = false
setVoteAndCommentStyle(entity)
true
} else {
entity.count.vote = entity.count.vote - 1
if (entity.type == "community_article") {
entity.me.isCommunityArticleVote = true
} else {
entity.me.isAnswerVoted = true
ErrorHelper.handleErrorWithCustomizedHandler(
itemView.context,
e?.response()?.errorBody()?.string(),
false
) {
when (it) {
403008 -> {
Utils.toast(itemView.context, R.string.ask_vote_hint)
true
}
403036 -> {
Utils.toast(itemView.context, R.string.ask_vote_limit_hint)
true
}
404001 -> {
Utils.toast(itemView.context, "内容可能已被删除")
entity.active = false
setVoteAndCommentStyle(entity)
true
}
else -> {
setVoteAndCommentStyle(entity)
false
}
voteCount.text = if (entity.count.vote > 0) entity.count.vote.toString() else "赞同"
setVoteAndCommentStyle(entity)
false
}
}
}
})
}
entity.count.vote = entity.count.vote + 1
voteCount.text = if (entity.count.vote > 0) entity.count.vote.toString() else "赞同"
playVoteAnimation()
}
@SuppressLint("CheckResult")
fun cancelAnswerVote(entity: AnswerEntity) {
entity.count.vote = entity.count.vote - 1
voteIcon.isChecked = false
voteCount.setTextColor(R.color.text_subtitleDesc.toColor(voteCount.context))
voteCount.text = if (entity.count.vote > 0) entity.count.vote.toString() else "赞同"
if (entity.type == "video") {
RetrofitManager.getInstance()
.api.undoVoteVideo(entity.id)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : BiResponse<ResponseBody>() {
override fun onSuccess(data: ResponseBody) {
entity.count.vote = entity.count.vote - 1
entity.me.isVoted = false
voteCount.text = if (entity.count.vote > 0) entity.count.vote.toString() else "赞同"
setVoteAndCommentStyle(entity)
Utils.toast(itemView.context, "取消点赞")
}
override fun onFailure(exception: Exception) {
super.onFailure(exception)
entity.count.vote = entity.count.vote + 1
entity.me.isVoted = true
voteCount.text = if (entity.count.vote > 0) entity.count.vote.toString() else "赞同"
if (exception is HttpException) {
ErrorHelper.handleError(
itemView.context,
exception.response()?.errorBody()?.string()
)
}
setVoteAndCommentStyle(entity)
}
})
} else {
val unVoteObservable = if (entity.type == "community_article") {
entity.me.isCommunityArticleVote = false
RetrofitManager.getInstance().api.postCommunityArticleUnVote(entity.id)
} else {
entity.me.isAnswerVoted = false
RetrofitManager.getInstance().api
.postAnswerUnvote(entity.id)
}
@ -427,32 +460,42 @@ open class BaseAnswerOrArticleItemViewHolder(itemView: View) : BaseRecyclerViewH
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Response<VoteEntity>() {
override fun onResponse(response: VoteEntity?) {
entity.count.vote = entity.count.vote - 1
if (entity.type == "community_article") {
entity.me.isCommunityArticleVote = false
} else {
entity.me.isAnswerVoted = false
}
voteCount.text = if (entity.count.vote > 0) entity.count.vote.toString() else "赞同"
setVoteAndCommentStyle(entity)
Utils.toast(itemView.context, "取消赞同")
}
override fun onFailure(e: HttpException?) {
ErrorHelper.handleErrorWithCustomizedHandler(itemView.context, e?.response()?.errorBody()?.string(), false) {
if (403008 == it) {
Utils.toast(itemView.context, R.string.ask_vote_hint)
true
} else if (403036 == it) {
Utils.toast(itemView.context, R.string.ask_vote_limit_hint)
true
} else if (404001 == it) {
Utils.toast(itemView.context, "内容可能已被删除")
entity.active = false
setVoteAndCommentStyle(entity)
true
} else {
entity.count.vote = entity.count.vote + 1
if (entity.type == "community_article") {
entity.me.isCommunityArticleVote = true
} else {
entity.me.isAnswerVoted = true
ErrorHelper.handleErrorWithCustomizedHandler(
itemView.context,
e?.response()?.errorBody()?.string(),
false
) {
when (it) {
403008 -> {
Utils.toast(itemView.context, R.string.ask_vote_hint)
true
}
403036 -> {
Utils.toast(itemView.context, R.string.ask_vote_limit_hint)
true
}
404001 -> {
Utils.toast(itemView.context, "内容可能已被删除")
entity.active = false
setVoteAndCommentStyle(entity)
true
}
else -> {
setVoteAndCommentStyle(entity)
false
}
voteCount.text = if (entity.count.vote > 0) entity.count.vote.toString() else "赞同"
setVoteAndCommentStyle(entity)
false
}
}
}
@ -477,7 +520,11 @@ open class BaseAnswerOrArticleItemViewHolder(itemView: View) : BaseRecyclerViewH
}
override fun onFailure(e: HttpException?) {
ErrorHelper.handleErrorWithCustomizedHandler(itemView.context, e?.response()?.errorBody()?.string(), false) {
ErrorHelper.handleErrorWithCustomizedHandler(
itemView.context,
e?.response()?.errorBody()?.string(),
false
) {
if (403008 == it) {
Utils.toast(itemView.context, R.string.ask_vote_hint)
true
@ -518,7 +565,11 @@ open class BaseAnswerOrArticleItemViewHolder(itemView: View) : BaseRecyclerViewH
}
override fun onFailure(e: HttpException?) {
ErrorHelper.handleErrorWithCustomizedHandler(itemView.context, e?.response()?.errorBody()?.string(), false) {
ErrorHelper.handleErrorWithCustomizedHandler(
itemView.context,
e?.response()?.errorBody()?.string(),
false
) {
if (403008 == it) {
Utils.toast(itemView.context, R.string.ask_vote_hint)
true

View File

@ -311,6 +311,13 @@ open class NewCommentFragment : ListFragment<CommentEntity, NewCommentViewModel>
super.onResume()
mKeyboardHeightProvider?.setKeyboardHeightObserver(this)
EventBus.getDefault().post(EBReuse(COMMENT_RESUME))
if (::commentEt.isInitialized && commentEt.text.isNotEmpty()) {
// 若不延迟,可能回来的时候不能获取焦点导致弹不起来
mBaseHandler.postDelayed({
Util_System_Keyboard.showSoftKeyboard(context, commentEt)
}, 200)
}
}
override fun onPause() {

View File

@ -45,7 +45,7 @@ class SimulatorGameViewModel(application: Application) : AndroidViewModel(applic
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe({
val localSimulatorList: List<SimulatorEntity> = AppDatabase.getInstance().simulatorGameDao().getSimulatorList()
val localSimulatorList: List<SimulatorEntity> = mSimulatorGameDao.getSimulatorList()
if (it.isNotEmpty()) {
when (it[0]) {
@ -59,6 +59,11 @@ class SimulatorGameViewModel(application: Application) : AndroidViewModel(applic
}
}
}
} else {
// 若网络数据为空,本地数据不为空时同步本地数据到服务端 (避免本地数据与网络数据不一致的问题)
if (localSimulatorList.isNotEmpty()) {
SimulatorGameManager.recordDownloadSimulatorGames()
}
}
}, {
simulators.postValue(mResultSimulatorsList)

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

View File

@ -7,8 +7,8 @@ ext {
targetSdkVersion = 28
// application info (每个大版本之间的 versionCode 增加 20)
versionCode = 630
versionName = "5.14.0"
versionCode = 633
versionName = "5.14.3"
applicationId = "com.gh.gamecenter"
// AndroidX

View File

@ -24,13 +24,17 @@ class CustomLayoutInflaterFactory(
mAppCompatActivity.delegate.createView(parent, name, context, attrs)
?: mAppCompatActivity.onCreateView(parent, name, context, attrs)
?: mAppCompatActivity.layoutInflater.createView(name, null, attrs)
} catch (e: ClassNotFoundException) {
} catch (e: Exception) {
try {
mAppCompatActivity.layoutInflater.createView(name, "android.widget.", attrs)
if (e is ClassNotFoundException) {
mAppCompatActivity.layoutInflater.createView(name, "android.widget.", attrs)
}
} catch (e2: Exception) {
e2.printStackTrace()
return null
}
e.printStackTrace()
return null
}
val n = attrs.attributeCount

View File

@ -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

View File

@ -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
)
}
}