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 22499a596a..7661f613d8 100644 --- a/app/src/main/java/com/gh/common/util/DirectUtils.kt +++ b/app/src/main/java/com/gh/common/util/DirectUtils.kt @@ -771,6 +771,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 eb2cde7f2e..8d9c791328 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 c832bd5b02..aa89167850 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/gh/gamecenter/SplashScreenActivity.kt b/app/src/main/java/com/gh/gamecenter/SplashScreenActivity.kt index 971b5d4320..b56f83e814 100644 --- a/app/src/main/java/com/gh/gamecenter/SplashScreenActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/SplashScreenActivity.kt @@ -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 ) @@ -150,42 +154,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 { + 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 { -// 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, @@ -385,10 +388,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() diff --git a/app/src/main/java/com/gh/gamecenter/entity/PrivacyPolicyEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/PrivacyPolicyEntity.kt index b33cfa2ccf..cd22d930a2 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/PrivacyPolicyEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/PrivacyPolicyEntity.kt @@ -28,13 +28,13 @@ data class PrivacyPolicyEntity( 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使用信息提醒", diff --git a/app/src/main/java/com/halo/assistant/HaloApp.java b/app/src/main/java/com/halo/assistant/HaloApp.java index 0bce443c2a..3a67ab5cf2 100644 --- a/app/src/main/java/com/halo/assistant/HaloApp.java +++ b/app/src/main/java/com/halo/assistant/HaloApp.java @@ -98,6 +98,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()); diff --git a/module_common/src/main/java/com/gh/gamecenter/common/utils/NewFlagLogUtils.kt b/module_common/src/main/java/com/gh/gamecenter/common/utils/NewFlagLogUtils.kt new file mode 100644 index 0000000000..b0dca3340c --- /dev/null +++ b/module_common/src/main/java/com/gh/gamecenter/common/utils/NewFlagLogUtils.kt @@ -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) + } + +} \ No newline at end of file diff --git a/module_common/src/main/java/com/gh/gamecenter/common/utils/PermissionHelper.kt b/module_common/src/main/java/com/gh/gamecenter/common/utils/PermissionHelper.kt index e78dd65733..cf4138de31 100644 --- a/module_common/src/main/java/com/gh/gamecenter/common/utils/PermissionHelper.kt +++ b/module_common/src/main/java/com/gh/gamecenter/common/utils/PermissionHelper.kt @@ -249,14 +249,25 @@ 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)) @@ -264,10 +275,15 @@ object PermissionHelper { 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(