From b6c4299398f4ba35d3bf43b5fa1d4067ef2d59e7 Mon Sep 17 00:00:00 2001 From: HuanCheng65 <609486518@qq.com> Date: Fri, 3 Dec 2021 19:04:16 +0800 Subject: [PATCH] =?UTF-8?q?pref:=20=E4=BF=AE=E6=94=B9=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=A4=87=E4=BB=BD=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 7 +++-- .../tieba/post/BaseApplication.kt | 4 --- .../tieba/post/activities/MainActivity.kt | 30 ++++++++++++++----- app/src/main/res/xml/backup_descriptor.xml | 21 +++++++++++-- 4 files changed, 46 insertions(+), 16 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 00f4b1c9..802645a5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -96,7 +96,7 @@ dependencies { //AndroidX implementation "androidx.appcompat:appcompat:1.3.1" implementation "androidx.core:core-ktx:1.6.0" - implementation "androidx.annotation:annotation:1.2.0" + implementation "androidx.annotation:annotation:1.3.0" implementation "androidx.constraintlayout:constraintlayout:2.1.1" implementation "androidx.preference:preference-ktx:1.1.1" implementation "androidx.gridlayout:gridlayout:1.0.0" @@ -138,7 +138,6 @@ dependencies { implementation "com.zhihu.android:matisse:0.5.3-beta3" implementation "com.yanzhenjie:permission:2.0.3" implementation "com.gyf.immersionbar:immersionbar:3.0.0" - api "com.flurry.android:analytics:13.0.0" implementation "com.github.yalantis:ucrop:2.2.7" @@ -150,4 +149,8 @@ dependencies { implementation ("com.alibaba.android:vlayout:1.2.31@aar") { transitive = true } + + def appCenterSdkVersion = '4.3.1' + implementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}" + implementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}" } diff --git a/app/src/main/java/com/huanchengfly/tieba/post/BaseApplication.kt b/app/src/main/java/com/huanchengfly/tieba/post/BaseApplication.kt index 5aeb9bbf..50805b01 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/BaseApplication.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/BaseApplication.kt @@ -24,7 +24,6 @@ import android.widget.TextView import androidx.annotation.RequiresApi import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatDelegate -import com.flurry.android.FlurryAgent import com.huanchengfly.tieba.post.activities.BaseActivity import com.huanchengfly.tieba.post.api.interfaces.CommonCallback import com.huanchengfly.tieba.post.components.dialogs.LoadingDialog @@ -76,9 +75,6 @@ class BaseApplication : Application(), IApp { ThemeUtils.init(ThemeDelegate) AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) LitePal.initialize(this) - FlurryAgent.Builder() - .withCaptureUncaughtExceptions(true) - .build(this, "ZMRX6W76WNF95ZHT857X") registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks { private var clipBoardHash: Int = 0 private fun updateClipBoardHashCode() { diff --git a/app/src/main/java/com/huanchengfly/tieba/post/activities/MainActivity.kt b/app/src/main/java/com/huanchengfly/tieba/post/activities/MainActivity.kt index 12523533..0996521b 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/activities/MainActivity.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/activities/MainActivity.kt @@ -33,6 +33,9 @@ import com.huanchengfly.tieba.post.models.MyInfoBean import com.huanchengfly.tieba.post.services.NotifyJobService import com.huanchengfly.tieba.post.utils.* import com.huanchengfly.tieba.post.widgets.MyViewPager +import com.microsoft.appcenter.AppCenter +import com.microsoft.appcenter.analytics.Analytics +import com.microsoft.appcenter.crashes.Crashes open class MainActivity : BaseActivity(), BottomNavigationView.OnNavigationItemSelectedListener, OnNavigationItemReselectedListener { var mAdapter: ViewPagerAdapter = ViewPagerAdapter(supportFragmentManager) @@ -151,15 +154,26 @@ open class MainActivity : BaseActivity(), BottomNavigationView.OnNavigationItemS findView() initView() initListener() - if (!SharedPreferencesUtil.get(SharedPreferencesUtil.SP_APP_DATA).getBoolean("notice_dialog", false)) { + AppCenter.start( + getApplication(), "b56debcc-264b-4368-a2cd-8c20213f6433", + Analytics::class.java, Crashes::class.java + ) + if (!SharedPreferencesUtil.get(SharedPreferencesUtil.SP_APP_DATA) + .getBoolean("notice_dialog", false) + ) { showDialog(DialogUtil.build(this) - .setTitle(R.string.title_dialog_notice) - .setMessage(R.string.message_dialog_notice) - .setPositiveButton(R.string.button_sure_default) { _, _ -> - SharedPreferencesUtil.put(this, SharedPreferencesUtil.SP_APP_DATA, "notice_dialog", true) - } - .setCancelable(false) - .create()) + .setTitle(R.string.title_dialog_notice) + .setMessage(R.string.message_dialog_notice) + .setPositiveButton(R.string.button_sure_default) { _, _ -> + SharedPreferencesUtil.put( + this, + SharedPreferencesUtil.SP_APP_DATA, + "notice_dialog", + true + ) + } + .setCancelable(false) + .create()) } if (shouldShowSwitchSnackbar()) { Util.createSnackbar(mViewPager, if (ThemeUtil.isNightMode(this)) R.string.snackbar_auto_switch_to_night else R.string.snackbar_auto_switch_from_night, Snackbar.LENGTH_SHORT) diff --git a/app/src/main/res/xml/backup_descriptor.xml b/app/src/main/res/xml/backup_descriptor.xml index 48f973d0..99297f28 100644 --- a/app/src/main/res/xml/backup_descriptor.xml +++ b/app/src/main/res/xml/backup_descriptor.xml @@ -1,6 +1,23 @@ - + - + + + + + + \ No newline at end of file