From 0306caadb5d1de6d95f5b009eda2bf3e4e96d853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=90=9B=E9=99=B6?= Date: Wed, 23 Nov 2022 10:19:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=95=85=E7=8E=A9?= =?UTF-8?q?=E6=B8=B8=E6=88=8F=E5=8F=8D=E9=A6=88=E6=97=A0=E6=B3=95=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E8=B7=B3=E8=BD=AC=E7=9A=84=E9=97=AE=E9=A2=98=20https:?= =?UTF-8?q?//jira.shanqu.cc/browse/GHZS-309?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gh/common/util/DirectUtils.kt | 30 +++++++++++++++++++ .../com/gh/common/util/EntranceUtils.java | 26 ++++++++++++++++ .../java/com/gh/gamecenter/MainActivity.java | 1 + .../java/com/gh/gamecenter/SkipActivity.java | 2 +- .../main/java/com/halo/assistant/HaloApp.java | 5 ++-- 5 files changed, 60 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/gh/common/util/DirectUtils.kt b/app/src/main/java/com/gh/common/util/DirectUtils.kt index 24c6a1e02f..b37ea0b164 100644 --- a/app/src/main/java/com/gh/common/util/DirectUtils.kt +++ b/app/src/main/java/com/gh/common/util/DirectUtils.kt @@ -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() diff --git a/app/src/main/java/com/gh/common/util/EntranceUtils.java b/app/src/main/java/com/gh/common/util/EntranceUtils.java index bb3a0033db..cf6b0e3434 100644 --- a/app/src/main/java/com/gh/common/util/EntranceUtils.java +++ b/app/src/main/java/com/gh/common/util/EntranceUtils.java @@ -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) 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); diff --git a/app/src/main/java/com/gh/gamecenter/MainActivity.java b/app/src/main/java/com/gh/gamecenter/MainActivity.java index 980a9041a4..0527b644fb 100644 --- a/app/src/main/java/com/gh/gamecenter/MainActivity.java +++ b/app/src/main/java/com/gh/gamecenter/MainActivity.java @@ -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); diff --git a/app/src/main/java/com/gh/gamecenter/SkipActivity.java b/app/src/main/java/com/gh/gamecenter/SkipActivity.java index d144ce79ab..bdcf75f28c 100644 --- a/app/src/main/java/com/gh/gamecenter/SkipActivity.java +++ b/app/src/main/java/com/gh/gamecenter/SkipActivity.java @@ -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); } diff --git a/app/src/main/java/com/halo/assistant/HaloApp.java b/app/src/main/java/com/halo/assistant/HaloApp.java index 58328e7318..c19a377b62 100644 --- a/app/src/main/java/com/halo/assistant/HaloApp.java +++ b/app/src/main/java/com/halo/assistant/HaloApp.java @@ -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 webViewAbiList; private ChannelProvider mChannelProvider = new ChannelProviderImp(); private final ServiceLoader mApplicationList = ServiceLoader.load(IApplication.class, this.getClass().getClassLoader());