diff --git a/app/src/debug/java/org/tasks/BuildSetup.kt b/app/src/debug/java/org/tasks/BuildSetup.kt
index 6165bdafb..b4c7bd3e3 100644
--- a/app/src/debug/java/org/tasks/BuildSetup.kt
+++ b/app/src/debug/java/org/tasks/BuildSetup.kt
@@ -12,6 +12,7 @@ import com.facebook.flipper.plugins.network.NetworkFlipperPlugin
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin
import com.facebook.soloader.SoLoader
import leakcanary.AppWatcher
+import org.tasks.data.CRASH_ON_MAIN_THREAD
import org.tasks.preferences.Preferences
import timber.log.Timber
import timber.log.Timber.DebugTree
@@ -24,6 +25,7 @@ class BuildSetup @Inject constructor(
fun setup() {
Timber.plant(DebugTree())
SoLoader.init(context, false)
+ CRASH_ON_MAIN_THREAD = preferences.getBoolean(R.string.p_crash_main_queries, false)
if (preferences.getBoolean(R.string.p_leakcanary, false)) {
AppWatcher.manualInstall(context)
}
diff --git a/app/src/debug/java/org/tasks/preferences/fragments/Debug.kt b/app/src/debug/java/org/tasks/preferences/fragments/Debug.kt
index 9f1fd140c..34622ec91 100644
--- a/app/src/debug/java/org/tasks/preferences/fragments/Debug.kt
+++ b/app/src/debug/java/org/tasks/preferences/fragments/Debug.kt
@@ -27,7 +27,7 @@ class Debug : InjectingPreferenceFragment() {
R.string.p_flipper,
R.string.p_strict_mode_vm,
R.string.p_strict_mode_thread,
- R.string.p_debug_main_queries
+ R.string.p_crash_main_queries
)) {
findPreference(pref)
.setOnPreferenceChangeListener { _: Preference?, _: Any? ->
diff --git a/app/src/debug/res/values/keys.xml b/app/src/debug/res/values/keys.xml
index e45e9f6ca..dc0caf556 100644
--- a/app/src/debug/res/values/keys.xml
+++ b/app/src/debug/res/values/keys.xml
@@ -13,5 +13,5 @@
debug_themes
debug_tasker
Reset SSL certificates
- Allow queries on main thread
+ Crash queries on main thread
\ No newline at end of file
diff --git a/app/src/debug/res/xml/preferences_debug.xml b/app/src/debug/res/xml/preferences_debug.xml
index fd997c92f..648ced1ac 100644
--- a/app/src/debug/res/xml/preferences_debug.xml
+++ b/app/src/debug/res/xml/preferences_debug.xml
@@ -18,8 +18,8 @@
android:title="@string/debug_strict_mode_vm"/>
runBlocking(context: CoroutineContext = EmptyCoroutineContext, block: suspend CoroutineScope.() -> T): T {
- assertNotMainThread()
+ if (CRASH_ON_MAIN_THREAD) {
+ assertNotMainThread()
+ }
return kotlinx.coroutines.runBlocking(context, block)
}
diff --git a/app/src/main/java/org/tasks/injection/ProductionModule.kt b/app/src/main/java/org/tasks/injection/ProductionModule.kt
index abc088131..08b9c72f7 100644
--- a/app/src/main/java/org/tasks/injection/ProductionModule.kt
+++ b/app/src/main/java/org/tasks/injection/ProductionModule.kt
@@ -26,7 +26,7 @@ internal class ProductionModule {
fun getAppDatabase(@ApplicationContext context: Context, preferences: Preferences): Database {
val builder = Room.databaseBuilder(context, Database::class.java, Database.NAME)
.addMigrations(*Migrations.MIGRATIONS)
- if (!BuildConfig.DEBUG || preferences.getBoolean(R.string.p_debug_main_queries, true)) {
+ if (!BuildConfig.DEBUG || !preferences.getBoolean(R.string.p_crash_main_queries, false)) {
builder.allowMainThreadQueries()
}
return builder.build()
diff --git a/app/src/main/res/values/keys.xml b/app/src/main/res/values/keys.xml
index 239a945d6..445a0154e 100644
--- a/app/src/main/res/values/keys.xml
+++ b/app/src/main/res/values/keys.xml
@@ -330,7 +330,7 @@
p_leakcanary
p_flipper
debug_pro
- debug_main_queries
+ debug_crash_main_queries
warned_play_services
background_sync_unmetered_only
sync_ongoing