diff --git a/CHANGES.md b/CHANGES.md
index 3c37763248..9be8d85871 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -8,7 +8,7 @@ Improvements 🙌:
- The initial sync is now handled by a foreground service
- Render aliases and canonical alias change in the timeline
- Fix autocompletion issues and add support for rooms and groups
- - Introduce developer mode in the settings (#796)
+ - Introduce developer mode in the settings (#745, #796)
- Improve devices list screen
- Add settings for rageshake sensibility
- Fix autocompletion issues and add support for rooms, groups, and emoji (#780)
diff --git a/vector/src/main/java/im/vector/riotx/VectorApplication.kt b/vector/src/main/java/im/vector/riotx/VectorApplication.kt
index 3f55e8f5e6..c76af027ba 100644
--- a/vector/src/main/java/im/vector/riotx/VectorApplication.kt
+++ b/vector/src/main/java/im/vector/riotx/VectorApplication.kt
@@ -42,7 +42,7 @@ import im.vector.riotx.core.di.DaggerVectorComponent
import im.vector.riotx.core.di.HasVectorInjector
import im.vector.riotx.core.di.VectorComponent
import im.vector.riotx.core.extensions.configureAndStart
-import im.vector.riotx.core.rx.setupRxPlugin
+import im.vector.riotx.core.rx.RxConfig
import im.vector.riotx.features.configuration.VectorConfiguration
import im.vector.riotx.features.lifecycle.VectorActivityLifecycleCallbacks
import im.vector.riotx.features.notifications.NotificationDrawerManager
@@ -75,6 +75,7 @@ class VectorApplication : Application(), HasVectorInjector, MatrixConfiguration.
@Inject lateinit var versionProvider: VersionProvider
@Inject lateinit var notificationUtils: NotificationUtils
@Inject lateinit var appStateHandler: AppStateHandler
+ @Inject lateinit var rxConfig: RxConfig
lateinit var vectorComponent: VectorComponent
private var fontThreadHandler: Handler? = null
@@ -84,7 +85,7 @@ class VectorApplication : Application(), HasVectorInjector, MatrixConfiguration.
vectorComponent = DaggerVectorComponent.factory().create(this)
vectorComponent.inject(this)
vectorUncaughtExceptionHandler.activate(this)
- setupRxPlugin()
+ rxConfig.setupRxPlugin()
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
diff --git a/vector/src/main/java/im/vector/riotx/core/rx/Rx.kt b/vector/src/main/java/im/vector/riotx/core/rx/RxConfig.kt
similarity index 57%
rename from vector/src/main/java/im/vector/riotx/core/rx/Rx.kt
rename to vector/src/main/java/im/vector/riotx/core/rx/RxConfig.kt
index 89de9030dc..d8828eb1b8 100644
--- a/vector/src/main/java/im/vector/riotx/core/rx/Rx.kt
+++ b/vector/src/main/java/im/vector/riotx/core/rx/RxConfig.kt
@@ -17,19 +17,26 @@
package im.vector.riotx.core.rx
import im.vector.riotx.BuildConfig
+import im.vector.riotx.features.settings.VectorPreferences
import io.reactivex.plugins.RxJavaPlugins
import timber.log.Timber
+import javax.inject.Inject
-/**
- * Make sure unhandled Rx error does not crash the app in production
- */
-fun setupRxPlugin() {
- RxJavaPlugins.setErrorHandler { throwable ->
- Timber.e(throwable, "RxError")
+class RxConfig @Inject constructor(
+ private val vectorPreferences: VectorPreferences
+) {
- // Avoid crash in production
- if (BuildConfig.DEBUG) {
- throw throwable
+ /**
+ * Make sure unhandled Rx error does not crash the app in production
+ */
+ fun setupRxPlugin() {
+ RxJavaPlugins.setErrorHandler { throwable ->
+ Timber.e(throwable, "RxError")
+
+ // Avoid crash in production
+ if (BuildConfig.DEBUG || vectorPreferences.failFast()) {
+ throw throwable
+ }
}
}
}
diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorPreferences.kt
index 0ec67789fe..72f8cf01dd 100755
--- a/vector/src/main/java/im/vector/riotx/features/settings/VectorPreferences.kt
+++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorPreferences.kt
@@ -151,6 +151,7 @@ class VectorPreferences @Inject constructor(private val context: Context) {
private const val SETTINGS_DEVELOPER_MODE_PREFERENCE_KEY = "SETTINGS_DEVELOPER_MODE_PREFERENCE_KEY"
private const val SETTINGS_LABS_SHOW_HIDDEN_EVENTS_PREFERENCE_KEY = "SETTINGS_LABS_SHOW_HIDDEN_EVENTS_PREFERENCE_KEY"
private const val SETTINGS_LABS_ENABLE_SWIPE_TO_REPLY = "SETTINGS_LABS_ENABLE_SWIPE_TO_REPLY"
+ private const val SETTINGS_DEVELOPER_MODE_FAIL_FAST_PREFERENCE_KEY = "SETTINGS_DEVELOPER_MODE_FAIL_FAST_PREFERENCE_KEY"
// analytics
const val SETTINGS_USE_ANALYTICS_KEY = "SETTINGS_USE_ANALYTICS_KEY"
@@ -266,6 +267,10 @@ class VectorPreferences @Inject constructor(private val context: Context) {
return developerMode() && defaultPrefs.getBoolean(SETTINGS_LABS_ALLOW_EXTENDED_LOGS, false)
}
+ fun failFast(): Boolean {
+ return developerMode() && defaultPrefs.getBoolean(SETTINGS_DEVELOPER_MODE_FAIL_FAST_PREFERENCE_KEY, false)
+ }
+
/**
* Tells if we have already asked the user to disable battery optimisations on android >= M devices.
*
diff --git a/vector/src/main/res/values/strings_riotX.xml b/vector/src/main/res/values/strings_riotX.xml
index 3e8485ebcc..d46231cff4 100644
--- a/vector/src/main/res/values/strings_riotX.xml
+++ b/vector/src/main/res/values/strings_riotX.xml
@@ -20,4 +20,7 @@
Showing only the first results, type more letters…
+ Fail-fast
+ RiotX may crash more often when an unexpected error occurs
+
diff --git a/vector/src/main/res/xml/vector_settings_advanced_settings.xml b/vector/src/main/res/xml/vector_settings_advanced_settings.xml
index 11ca97870d..131b43c8d5 100644
--- a/vector/src/main/res/xml/vector_settings_advanced_settings.xml
+++ b/vector/src/main/res/xml/vector_settings_advanced_settings.xml
@@ -23,6 +23,13 @@
android:summary="@string/labs_allow_extended_logging_summary"
android:title="@string/labs_allow_extended_logging" />
+
+