feat: bugly

This commit is contained in:
zhoubinjia committed 2026-01-07 14:00:38 +08:00
1 parent 09305b5e94
commit c822ad22e1
6 files changed
+83

No files matched your search

@@ -0,0 +1,28 @@
package com.hinnka.mycamera.utils
import android.content.Context
import android.provider.Settings
import com.tencent.bugly.crashreport.BuglyLog
import com.tencent.bugly.crashreport.CrashReport
object BuglyHelper {
fun init(context: Context) {
val strategy = CrashReport.UserStrategy(context).apply {
deviceID = Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID)
deviceModel = DeviceUtil.model
}
CrashReport.initCrashReport(context.applicationContext, "9966e9cd35", false, strategy)
}
fun setUserScene(context: Context, scene: Int) {
CrashReport.setUserSceneTag(context, scene)
}
fun putUserData(context: Context, key: String, value: String) {
CrashReport.putUserData(context, key, value)
}
fun log(tag: String, msg: String, throwable: Throwable? = null) {
BuglyLog.e(tag, msg, throwable)
}
}
@@ -0,0 +1,18 @@
package com.hinnka.mycamera.utils
import android.content.Context
object BuglyHelper {
fun init(context: Context) {
// No-op for google flavor
}
fun setUserScene(context: Context, scene: Int) {
}
fun putUserData(context: Context, key: String, value: String) {
}
fun log(tag: String, msg: String, throwable: Throwable? = null) {
}
}
+3
View File
@@ -3,10 +3,13 @@
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<application
android:name=".MyCameraApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
@@ -27,6 +27,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
@@ -46,6 +47,7 @@ import com.hinnka.mycamera.ui.gallery.PhotoDetailScreen
import com.hinnka.mycamera.ui.gallery.PhotoEditScreen
import com.hinnka.mycamera.ui.settings.SettingsScreen
import com.hinnka.mycamera.ui.theme.PhotonCameraTheme
import com.hinnka.mycamera.utils.BuglyHelper
import com.hinnka.mycamera.utils.OrientationObserver
import com.hinnka.mycamera.viewmodel.CameraViewModel
import com.hinnka.mycamera.viewmodel.GalleryViewModel
@@ -152,7 +154,11 @@ fun NavigationHost(
cameraViewModel: CameraViewModel,
galleryViewModel: GalleryViewModel
) {
val context = LocalContext.current
val navController = rememberNavController()
navController.addOnDestinationChangedListener { _, destination, _ ->
BuglyHelper.setUserScene(context, destination.route.hashCode())
}
NavHost(
navController = navController,
@@ -0,0 +1,13 @@
package com.hinnka.mycamera
import android.app.Application
import com.hinnka.mycamera.utils.BuglyHelper
class MyCameraApplication : Application() {
override fun onCreate() {
super.onCreate()
BuglyHelper.init(this)
}
}