mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
Developer mode: Fail-fast (#745)
This commit is contained in:
parent
8ef5c60e2e
commit
17c4013383
@ -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)
|
||||
|
@ -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())
|
||||
|
@ -17,8 +17,14 @@
|
||||
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
|
||||
|
||||
class RxConfig @Inject constructor(
|
||||
private val vectorPreferences: VectorPreferences
|
||||
) {
|
||||
|
||||
/**
|
||||
* Make sure unhandled Rx error does not crash the app in production
|
||||
@ -28,8 +34,9 @@ fun setupRxPlugin() {
|
||||
Timber.e(throwable, "RxError")
|
||||
|
||||
// Avoid crash in production
|
||||
if (BuildConfig.DEBUG) {
|
||||
if (BuildConfig.DEBUG || vectorPreferences.failFast()) {
|
||||
throw throwable
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -20,4 +20,7 @@
|
||||
|
||||
<string name="autocomplete_limited_results">Showing only the first results, type more letters…</string>
|
||||
|
||||
<string name="settings_developer_mode_fail_fast_title">Fail-fast</string>
|
||||
<string name="settings_developer_mode_fail_fast_summary">RiotX may crash more often when an unexpected error occurs</string>
|
||||
|
||||
</resources>
|
||||
|
@ -23,6 +23,13 @@
|
||||
android:summary="@string/labs_allow_extended_logging_summary"
|
||||
android:title="@string/labs_allow_extended_logging" />
|
||||
|
||||
<im.vector.riotx.core.preference.VectorSwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:dependency="SETTINGS_DEVELOPER_MODE_PREFERENCE_KEY"
|
||||
android:key="SETTINGS_DEVELOPER_MODE_FAIL_FAST_PREFERENCE_KEY"
|
||||
android:summary="@string/settings_developer_mode_fail_fast_summary"
|
||||
android:title="@string/settings_developer_mode_fail_fast_title" />
|
||||
|
||||
<!-- TODO Display unsupported events -->
|
||||
|
||||
</im.vector.riotx.core.preference.VectorPreferenceCategory>
|
||||
|
Loading…
Reference in New Issue
Block a user