Initial commit
This commit is contained in:
369
sources/com/ubt/jimu/SplashActivity.java
Normal file
369
sources/com/ubt/jimu/SplashActivity.java
Normal file
@@ -0,0 +1,369 @@
|
||||
package com.ubt.jimu;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.DialogInterface;
|
||||
import android.media.AudioManager;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
import android.widget.VideoView;
|
||||
import butterknife.ButterKnife;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.ubt.jimu.analytics.AppDelayInit;
|
||||
import com.ubt.jimu.analytics.BuglyUtil;
|
||||
import com.ubt.jimu.analytics.JimuAnalyticsUtil;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.cache.SharePreferenceHelper;
|
||||
import com.ubt.jimu.base.db.user.UserDbHandler;
|
||||
import com.ubt.jimu.base.dialog.JimuSimpleDialog;
|
||||
import com.ubt.jimu.base.dialog.LegalExamineDialog;
|
||||
import com.ubt.jimu.base.entities.Constant;
|
||||
import com.ubt.jimu.base.http.ApiClient;
|
||||
import com.ubt.jimu.base.http.response.Timestamp;
|
||||
import com.ubt.jimu.base.http.service.UserService;
|
||||
import com.ubt.jimu.blockly.dao.JimuSoundDbHandler;
|
||||
import com.ubt.jimu.sync.OfflineDataUploadTool;
|
||||
import com.ubt.jimu.transport3.upgrade.Version2DbUpgrade;
|
||||
import com.ubt.jimu.transport3.upgrade.VersionUpgrade;
|
||||
import com.ubt.jimu.unity.bluetooth.ConnectionStatus;
|
||||
import com.ubt.jimu.utils.GsonUtil;
|
||||
import com.ubt.jimu.utils.LocaleUtils;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
import com.ubt.jimu.utils.SPUtils;
|
||||
import com.ubt.jimu.utils.ThreadManagerUtils;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import com.ubtrobot.ubtlib.analytics.JimuAnalytics;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SplashActivity extends BaseActivity {
|
||||
private int a;
|
||||
private LegalExamineDialog b;
|
||||
private JimuSimpleDialog c;
|
||||
private PrivacyVersion d;
|
||||
VideoView videoView;
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void F0() {
|
||||
AppDelayInit.a(getApplicationContext());
|
||||
H0();
|
||||
initData();
|
||||
}
|
||||
|
||||
private void G0() {
|
||||
if (SPUtils.a(Constant.NoviceGuide.SHOW_GUIDE)) {
|
||||
K0();
|
||||
} else {
|
||||
NoviceGuideActivity.b(this);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private void H0() {
|
||||
LogUtils.c("对时开始");
|
||||
((UserService) ApiClient.getService(UserService.class)).getServerTimestamp().observeOn(Schedulers.b()).subscribeOn(Schedulers.b()).subscribe(new Observer<Timestamp>(this) { // from class: com.ubt.jimu.SplashActivity.4
|
||||
@Override // io.reactivex.Observer
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public void onNext(Timestamp timestamp) {
|
||||
LogUtils.c("对时接口请求成功:" + timestamp);
|
||||
if (timestamp == null || timestamp.getTimestamp() == 0) {
|
||||
a();
|
||||
return;
|
||||
}
|
||||
long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||
long timestamp2 = (timestamp.getTimestamp() * 1000) - elapsedRealtime;
|
||||
LogUtils.c("开机时间:" + elapsedRealtime + " 服务器时间:" + timestamp.getTimestamp() + " 差异:" + timestamp2);
|
||||
Cache.getInstance().differ = timestamp2;
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onComplete() {
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onError(Throwable th) {
|
||||
LogUtils.c("对时失败");
|
||||
a();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
}
|
||||
|
||||
private void a() {
|
||||
Cache.getInstance().differ = System.currentTimeMillis() - SystemClock.elapsedRealtime();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void I0() {
|
||||
getIntent().getIntExtra(Constant.Base.ACTIVITY_START_ACTION, 0);
|
||||
}
|
||||
|
||||
private boolean J0() {
|
||||
String b = SPUtils.b(Constant.Privacy.SP_KEY_PRIVACY_POLICY_VERSION);
|
||||
String b2 = SPUtils.b(Constant.Privacy.SP_KEY_CHILD_PRIVACY_POLICY_VERSION);
|
||||
PrivacyVersion M0 = M0();
|
||||
if (TextUtils.isEmpty(b) && TextUtils.isEmpty(b2) && M0 == null) {
|
||||
return false;
|
||||
}
|
||||
if (M0 == null) {
|
||||
ALog.a("Not internal privacy version!", new Object[0]);
|
||||
return false;
|
||||
}
|
||||
if (TextUtils.isEmpty(b) || TextUtils.isEmpty(b2)) {
|
||||
ALog.c("Not agreed privacy version!", new Object[0]);
|
||||
return true;
|
||||
}
|
||||
ALog.b("privacyVersion:" + M0.getJimuPrivacyPolicyVersion() + " childrenPrivacyPolicyVersion:" + M0.getJimuChildrenPrivacyPolicyVersion(), new Object[0]);
|
||||
if (b.equals(M0.getJimuPrivacyPolicyVersion()) && b2.equals(M0.getJimuChildrenPrivacyPolicyVersion())) {
|
||||
return false;
|
||||
}
|
||||
ALog.b("internal privacy policy version has update!", new Object[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void K0() {
|
||||
runOnUiThread(new Runnable() { // from class: com.ubt.jimu.f
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
SplashActivity.this.D0();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void L0() {
|
||||
this.videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.splash_screen));
|
||||
this.videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { // from class: com.ubt.jimu.g
|
||||
@Override // android.media.MediaPlayer.OnCompletionListener
|
||||
public final void onCompletion(MediaPlayer mediaPlayer) {
|
||||
SplashActivity.this.a(mediaPlayer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public PrivacyVersion M0() {
|
||||
PrivacyVersion privacyVersion = this.d;
|
||||
if (privacyVersion != null) {
|
||||
return privacyVersion;
|
||||
}
|
||||
try {
|
||||
InputStream open = getAssets().open("privacy/version.json");
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(open, "utf-8"));
|
||||
String str = "";
|
||||
while (true) {
|
||||
String readLine = bufferedReader.readLine();
|
||||
if (readLine == null) {
|
||||
bufferedReader.close();
|
||||
open.close();
|
||||
PrivacyVersion privacyVersion2 = (PrivacyVersion) GsonUtil.a(str, PrivacyVersion.class);
|
||||
ALog.b("privacyVersion:" + privacyVersion2.getJimuPrivacyPolicyVersion() + " childrenPrivacyPolicyVersion:" + privacyVersion2.getJimuChildrenPrivacyPolicyVersion(), new Object[0]);
|
||||
this.d = privacyVersion2;
|
||||
return privacyVersion2;
|
||||
}
|
||||
str = str + readLine;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
ALog.a(e, "get privacy policy version fail!", new Object[0]);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void N0() {
|
||||
if (this.c == null) {
|
||||
this.c = new JimuSimpleDialog.Builder(this).title(R.string.ubt_user_experience_title).cancel(R.string.dialog_add_later).ok(R.string.ok).content(R.string.ubt_user_experience_content).gravity(17).canceledOnTouchOutside(false).cancleBtnBg(R.drawable.sel_common_negative_btn).onCancel(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.e
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
SplashActivity.this.a(dialogInterface, i);
|
||||
}
|
||||
}).onOk(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.h
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
SplashActivity.this.b(dialogInterface, i);
|
||||
}
|
||||
}).build();
|
||||
this.c.setOnKeyListener(new DialogInterface.OnKeyListener() { // from class: com.ubt.jimu.d
|
||||
@Override // android.content.DialogInterface.OnKeyListener
|
||||
public final boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
|
||||
return SplashActivity.a(dialogInterface, i, keyEvent);
|
||||
}
|
||||
});
|
||||
this.c.show();
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ boolean a(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void e(boolean z) {
|
||||
G0();
|
||||
f(z);
|
||||
}
|
||||
|
||||
private void f(boolean z) {
|
||||
if (z) {
|
||||
JimuAnalyticsUtil.a(this);
|
||||
JimuAnalytics.b().a(z);
|
||||
} else {
|
||||
ALog.b("未打开体验优化", new Object[0]);
|
||||
}
|
||||
BuglyUtil.a(z);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
SPUtils.a(Constant.NoviceGuide.APP_HAS_PAUSE, true);
|
||||
final int versionCode = Cache.getInstance().getVersionCode();
|
||||
if (versionCode <= 0) {
|
||||
Cache.getInstance().clearCacheUser();
|
||||
UserDbHandler.clearUser();
|
||||
}
|
||||
Cache.getInstance().putInt(Constant.Cache.APP_VERSION_CODE, 3960075);
|
||||
Cache.getInstance().putInt(SharePreferenceHelper.SP_KEY_CONNECTION_STATUS, ConnectionStatus.DIS_CONNECT.getStatus());
|
||||
ThreadManagerUtils.a().a(new Runnable() { // from class: com.ubt.jimu.SplashActivity.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (versionCode <= 0) {
|
||||
ALog.a("upgrade").d("新安装或者从2.x更新过来:versionCode=" + versionCode);
|
||||
new Version2DbUpgrade().migrate(JimuApplication.l());
|
||||
JimuSoundDbHandler.update2Version3();
|
||||
}
|
||||
VersionUpgrade.doUpgrade();
|
||||
SplashActivity.this.E0();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public /* synthetic */ void D0() {
|
||||
ARouter.b().a("/page/main").t();
|
||||
finish();
|
||||
}
|
||||
|
||||
public void E0() {
|
||||
OfflineDataUploadTool.h().d();
|
||||
}
|
||||
|
||||
@Override // android.app.Activity, android.view.ContextThemeWrapper, android.content.ContextWrapper
|
||||
protected void attachBaseContext(Context context) {
|
||||
super.attachBaseContext(new ContextWrapper(this, context) { // from class: com.ubt.jimu.SplashActivity.3
|
||||
@Override // android.content.ContextWrapper, android.content.Context
|
||||
public Object getSystemService(String str) {
|
||||
return "audio".equals(str) ? getApplicationContext().getSystemService(str) : super.getSystemService(str);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, androidx.core.app.ComponentActivity, android.app.Activity
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
setContentView(R.layout.activity_splash);
|
||||
ButterKnife.a(this);
|
||||
I0();
|
||||
if (getIntent() == null || (getIntent().getFlags() & 4194304) == 0) {
|
||||
L0();
|
||||
} else {
|
||||
XLog.a("splash", "brought to front, finish, do nothing");
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
protected void onDestroy() {
|
||||
ThreadManagerUtils.a().a();
|
||||
super.onDestroy();
|
||||
((AudioManager) getSystemService("audio")).abandonAudioFocus(null);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
VideoView videoView = this.videoView;
|
||||
if (videoView != null) {
|
||||
this.a = videoView.getCurrentPosition();
|
||||
this.videoView.pause();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
VideoView videoView = this.videoView;
|
||||
if (videoView != null) {
|
||||
videoView.seekTo(this.a);
|
||||
this.videoView.start();
|
||||
}
|
||||
}
|
||||
|
||||
public /* synthetic */ void b(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
e(true);
|
||||
SPUtils.a(Constant.NoviceGuide.JOIN_USER_EXPERIENCE, true);
|
||||
}
|
||||
|
||||
public /* synthetic */ void a(MediaPlayer mediaPlayer) {
|
||||
LegalExamineDialog legalExamineDialog = this.b;
|
||||
if (legalExamineDialog == null || !legalExamineDialog.isShowing()) {
|
||||
JimuSimpleDialog jimuSimpleDialog = this.c;
|
||||
if (jimuSimpleDialog == null || !jimuSimpleDialog.isShowing()) {
|
||||
new SharePreferenceHelper().put(SharePreferenceHelper.SP_KEY_START_FROM_SPLASH, true);
|
||||
if (((!SPUtils.a(Constant.NoviceGuide.AGREE_LEGAL_EXAMINE)) || J0()) && LocaleUtils.g()) {
|
||||
if (this.b == null) {
|
||||
this.b = new LegalExamineDialog.Builder(this).onLegalResult(new LegalExamineDialog.LegalResult() { // from class: com.ubt.jimu.SplashActivity.2
|
||||
@Override // com.ubt.jimu.base.dialog.LegalExamineDialog.LegalResult
|
||||
public void pass() {
|
||||
SplashActivity.this.b.dismiss();
|
||||
SplashActivity.this.F0();
|
||||
if (SPUtils.a(Constant.NoviceGuide.JOIN_USER_EXPERIENCE)) {
|
||||
SplashActivity.this.e(true);
|
||||
} else {
|
||||
SplashActivity.this.N0();
|
||||
}
|
||||
PrivacyVersion M0 = SplashActivity.this.M0();
|
||||
if (M0 != null) {
|
||||
SPUtils.a(Constant.Privacy.SP_KEY_PRIVACY_POLICY_VERSION, M0.getJimuPrivacyPolicyVersion());
|
||||
SPUtils.a(Constant.Privacy.SP_KEY_CHILD_PRIVACY_POLICY_VERSION, M0.getJimuChildrenPrivacyPolicyVersion());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.dialog.LegalExamineDialog.LegalResult
|
||||
public void reject() {
|
||||
SplashActivity.this.b.dismiss();
|
||||
SplashActivity.this.finish();
|
||||
}
|
||||
}).build();
|
||||
this.b.show();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!LocaleUtils.g() && !SPUtils.a(Constant.NoviceGuide.JOIN_USER_EXPERIENCE) && !SPUtils.a(Constant.NoviceGuide.APP_HAS_PAUSE)) {
|
||||
N0();
|
||||
F0();
|
||||
} else {
|
||||
e(true);
|
||||
F0();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public /* synthetic */ void a(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
e(false);
|
||||
SPUtils.a(Constant.NoviceGuide.JOIN_USER_EXPERIENCE, false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user