aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorYuutaW <17158086+Trumeet@users.noreply.github.com>2019-02-24 13:57:18 -0800
committerYuutaW <17158086+Trumeet@users.noreply.github.com>2019-02-24 13:57:18 -0800
commit6ec68733e0f1c6a2bbbbb4735e9c1f2de8cf6b8c (patch)
tree8910595b4d1310ca99d4a0d0bf4b74578e1ce341 /app/src
parent100068c5622162d3c3dcd752c0fca565378ac01d (diff)
downloadWorkMode-6ec68733e0f1c6a2bbbbb4735e9c1f2de8cf6b8c.tar
WorkMode-6ec68733e0f1c6a2bbbbb4735e9c1f2de8cf6b8c.tar.gz
WorkMode-6ec68733e0f1c6a2bbbbb4735e9c1f2de8cf6b8c.tar.bz2
WorkMode-6ec68733e0f1c6a2bbbbb4735e9c1f2de8cf6b8c.zip
feat(app): implement Fabric
Signed-off-by: YuutaW <17158086+Trumeet@users.noreply.github.com>
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/AndroidManifest.xml3
-rw-r--r--app/src/main/java/moe/yuuta/workmode/App.kt1
-rw-r--r--app/src/main/java/moe/yuuta/workmode/MainActivity.kt3
-rw-r--r--app/src/main/java/moe/yuuta/workmode/Setup.kt13
4 files changed, 20 insertions, 0 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 435ee2b..062de4b 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -54,5 +54,8 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>
+ <meta-data
+ android:name="io.fabric.ApiKey"
+ android:value="${fabricKey}" />
</application>
</manifest> \ No newline at end of file
diff --git a/app/src/main/java/moe/yuuta/workmode/App.kt b/app/src/main/java/moe/yuuta/workmode/App.kt
index 3735a3e..a1d0d92 100644
--- a/app/src/main/java/moe/yuuta/workmode/App.kt
+++ b/app/src/main/java/moe/yuuta/workmode/App.kt
@@ -6,5 +6,6 @@ class App : Application() {
override fun onCreate() {
super.onCreate()
Setup.initLogs(Setup.getLogsPath(this).absolutePath)
+ Setup.initFabric(this)
}
} \ No newline at end of file
diff --git a/app/src/main/java/moe/yuuta/workmode/MainActivity.kt b/app/src/main/java/moe/yuuta/workmode/MainActivity.kt
index b1d425b..f18370f 100644
--- a/app/src/main/java/moe/yuuta/workmode/MainActivity.kt
+++ b/app/src/main/java/moe/yuuta/workmode/MainActivity.kt
@@ -18,6 +18,7 @@ import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.android.settings.widget.SwitchBar
+import com.crashlytics.android.Crashlytics
import com.elvishew.xlog.Logger
import com.elvishew.xlog.XLog
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
@@ -96,6 +97,8 @@ class MainActivity : AppCompatActivity(), SwitchBar.OnSwitchChangeListener, View
displayUI()
if (!success) {
logger.e("Unable scheduleApply settings", e)
+ if (Setup.FABRIC_ENABLE)
+ Crashlytics.getInstance().core.logException(e)
Toast.makeText(this@MainActivity, R.string.error_apply, Toast.LENGTH_LONG).show()
}
}
diff --git a/app/src/main/java/moe/yuuta/workmode/Setup.kt b/app/src/main/java/moe/yuuta/workmode/Setup.kt
index fd75ff0..0553ea6 100644
--- a/app/src/main/java/moe/yuuta/workmode/Setup.kt
+++ b/app/src/main/java/moe/yuuta/workmode/Setup.kt
@@ -4,6 +4,8 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.core.content.FileProvider
+import com.crashlytics.android.Crashlytics
+import com.crashlytics.android.answers.Answers
import com.elvishew.xlog.LogConfiguration
import com.elvishew.xlog.LogUtils
import com.elvishew.xlog.XLog
@@ -11,12 +13,15 @@ import com.elvishew.xlog.interceptor.BlacklistTagsFilterInterceptor
import com.elvishew.xlog.printer.AndroidPrinter
import com.elvishew.xlog.printer.file.FilePrinter
import com.elvishew.xlog.printer.file.clean.FileLastModifiedCleanStrategy
+import io.fabric.sdk.android.Fabric
import moe.yuuta.workmode.utils.Utils
import java.io.File
import java.text.SimpleDateFormat
import java.util.*
object Setup {
+ val FABRIC_ENABLE = !BuildConfig.DEBUG && BuildConfig.FABRIC_KEY != "disabled"
+
fun getLogsPath(context: Context): File =
File(context.applicationContext.dataDir.absolutePath + "/logs")
@@ -61,4 +66,12 @@ object Setup {
intent.putExtra(Intent.EXTRA_STREAM, fileUri)
return intent
}
+
+ internal fun initFabric(context: Context) {
+ if (FABRIC_ENABLE) {
+ Fabric.with(Fabric.Builder(context)
+ .kits(Crashlytics(), Answers())
+ .build())
+ }
+ }
} \ No newline at end of file