完成光环助手V3.6.6-权限相关测试汇总 https://gitlab.ghzs.com/pm/halo-app-issues/issues/596
This commit is contained in:
@ -25,11 +25,13 @@ import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DeviceTokenUtils;
|
||||
import com.gh.common.util.DeviceUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.EmptyCallback;
|
||||
import com.gh.common.util.GameRepositoryHelper;
|
||||
import com.gh.common.util.GdtHelper;
|
||||
import com.gh.common.util.MtaHelper;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.common.util.SPUtils;
|
||||
import com.gh.common.util.TagUtils;
|
||||
import com.gh.common.util.TimestampUtils;
|
||||
import com.gh.download.DownloadManager;
|
||||
@ -65,12 +67,11 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
|
||||
private SharedPreferences mSharedPreferences;
|
||||
|
||||
private long start;
|
||||
|
||||
private boolean isFirst;
|
||||
private boolean isNewFirstLaunch;
|
||||
|
||||
private final static int REQUEST_PERMISSION_TAG = 30001;
|
||||
private static final int REQUEST_PERMISSION_TAG = 30001;
|
||||
private static final String SP_BRAND_NEW_USER = "brand_new_user"; // 用于标记是否为新用户,应用更新再打开的不算是新用户
|
||||
private String[] mPermissions = {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
@ -101,12 +102,11 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
start = System.currentTimeMillis();
|
||||
|
||||
TimestampUtils.initMap();
|
||||
|
||||
isFirst = true;
|
||||
|
||||
// 判断是不是这个版本的新用户
|
||||
if (isNewFirstLaunch) {
|
||||
setTheme(R.style.AppGuideTheme);
|
||||
|
||||
@ -123,15 +123,33 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
ViewPager guideLayout = findViewById(R.id.splash_intro_vp_guide);
|
||||
guideLayout.setAdapter(new GuidePagerAdapter());
|
||||
|
||||
|
||||
showPrivacyPolicy();
|
||||
// 判断是不是光环的新用户
|
||||
if (SPUtils.getBoolean(SP_BRAND_NEW_USER, true)) {
|
||||
showPrivacyPolicy(() -> {
|
||||
// 用户点击我知道了
|
||||
SPUtils.setBoolean(SP_BRAND_NEW_USER, false);
|
||||
requestPermissionAndLaunchMainActivity();
|
||||
});
|
||||
} else {
|
||||
requestPermissionAndLaunchMainActivity();
|
||||
}
|
||||
} else {
|
||||
setTheme(R.style.AppFullScreenTheme);
|
||||
launchMainActivity();
|
||||
}
|
||||
}
|
||||
|
||||
private void requestPermissionAndLaunchMainActivity() {
|
||||
if (EasyPermissions.hasPermissions(this, mPermissions)) {
|
||||
GdtHelper.INSTANCE.logAction(ActionType.START_APP, GdtHelper.NETWORK_TYPE, DeviceUtils.getNetwork(this));
|
||||
launchMainActivity();
|
||||
} else {
|
||||
checkAndRequestPermission();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void showPrivacyPolicy() {
|
||||
private void showPrivacyPolicy(EmptyCallback callback) {
|
||||
RetrofitManager.getInstance(this).getApi()
|
||||
.getPrivacyPolicy()
|
||||
.subscribeOn(Schedulers.io())
|
||||
@ -139,17 +157,21 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
.subscribe(new BiResponse<ResponseBody>() {
|
||||
@Override
|
||||
public void onSuccess(ResponseBody data) {
|
||||
String content = null;
|
||||
String title = null;
|
||||
try {
|
||||
String content = new JSONObject(data.string()).getString("content");
|
||||
DialogUtils.showPrivacyPolicyDialog(SplashScreenActivity.this, content);
|
||||
content = new JSONObject(data.string()).getString("content");
|
||||
title = new JSONObject(data.string()).getString("title");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
DialogUtils.showPrivacyPolicyDialog(SplashScreenActivity.this, title, content, callback);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull Exception exception) {
|
||||
DialogUtils.showPrivacyPolicyDialog(SplashScreenActivity.this, null);
|
||||
DialogUtils.showPrivacyPolicyDialog(SplashScreenActivity.this, null, null, callback);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -171,7 +193,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
|
||||
if (isNewFirstLaunch && EasyPermissions.hasPermissions(this, mPermissions)) {
|
||||
launch();
|
||||
launchMainActivity();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
@ -180,14 +202,17 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
// 跳转到主界面
|
||||
private void launch() {
|
||||
private void launchMainActivity() {
|
||||
getUniqueId();
|
||||
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class);
|
||||
if (bundle != null) intent.putExtras(bundle);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
long delay = isNewFirstLaunch ? 2000 : 1000;
|
||||
getWindow().getDecorView().postDelayed(() -> {
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class);
|
||||
if (bundle != null) intent.putExtras(bundle);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}, delay);
|
||||
}
|
||||
|
||||
private void getUniqueId() {
|
||||
@ -226,33 +251,13 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
|
||||
DownloadManager.getInstance(this).initDownloadService();
|
||||
});
|
||||
|
||||
// 检查权限
|
||||
if (EasyPermissions.hasPermissions(this, mPermissions)) {
|
||||
GdtHelper.INSTANCE.logAction(ActionType.START_APP, GdtHelper.NETWORK_TYPE, DeviceUtils.getNetwork(this));
|
||||
if (!isNewFirstLaunch) {
|
||||
long end = System.currentTimeMillis() - start;
|
||||
if (end < 2000) {
|
||||
getWindow().getDecorView().postDelayed(this::launch, 2000 - end);
|
||||
} else {
|
||||
launch();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 仅首次启动申请授权
|
||||
if (isNewFirstLaunch) {
|
||||
checkAndRequestPermission();
|
||||
} else {
|
||||
launch();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@AfterPermissionGranted(REQUEST_PERMISSION_TAG)
|
||||
private void checkAndRequestPermission() {
|
||||
if (EasyPermissions.hasPermissions(this, mPermissions)) {
|
||||
launch();
|
||||
launchMainActivity();
|
||||
MtaHelper.onEvent("授权情况", "启动授权", "都授权");
|
||||
// 检查是否有旧版本光环,有就删掉
|
||||
HaloApp.getInstance().getMainExecutor().execute(this::checkOldGhFile);
|
||||
@ -271,7 +276,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
intent.setData(Uri.parse("package:" + getPackageName()));
|
||||
startActivity(intent);
|
||||
}, () -> {
|
||||
launch();
|
||||
launchMainActivity();
|
||||
logGrantedPermission(perms);
|
||||
});
|
||||
} else {
|
||||
@ -279,7 +284,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
"在设置-应用-光环助手-权限中开启存储和手机信息权限,以保证能正常使用相关功能", "重试", "放弃",
|
||||
this::checkAndRequestPermission,
|
||||
() -> {
|
||||
launch();
|
||||
launchMainActivity();
|
||||
logGrantedPermission(perms);
|
||||
});
|
||||
}
|
||||
@ -340,7 +345,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
TextView tvSkip = view.findViewById(R.id.splsh_guide_tv_skip);
|
||||
tvSkip.setOnClickListener(v -> {
|
||||
if (EasyPermissions.hasPermissions(SplashScreenActivity.this, mPermissions)) {
|
||||
launch();
|
||||
launchMainActivity();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user