Skip to content
Snippets Groups Projects
Verified Commit 668fc049 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Allow ignoring network changes for autoreconnect

parent 26b2fdf7
Branches
Tags
No related merge requests found
......@@ -93,10 +93,9 @@ class QuasselService : DaggerLifecycleService(),
val connectionSettings = Settings.connection(this)
if (this.connectionSettings.showNotification != connectionSettings.showNotification) {
this.connectionSettings = connectionSettings
updateNotificationStatus(this.progress)
}
this.connectionSettings = connectionSettings
val (accountId, reconnect) = this.sharedPreferences(Keys.Status.NAME, Context.MODE_PRIVATE) {
Pair(
......@@ -415,6 +414,7 @@ class QuasselService : DaggerLifecycleService(),
.observeNetworkConnectivity(applicationContext)
.toLiveData()
.observe(this, Observer { connectivity ->
if (!connectionSettings.ignoreNetworkChanges) {
log(INFO, "QuasselService", "Connectivity changed: $connectivity")
handlerService.backend {
log(INFO, "QuasselService", "Reconnect triggered: Network changed")
......@@ -423,6 +423,7 @@ class QuasselService : DaggerLifecycleService(),
ignoreSetting = true
)
}
}
})
sessionManager.state
......
......@@ -20,7 +20,8 @@
package de.kuschku.quasseldroid.settings
data class ConnectionSettings(
val showNotification: Boolean = true
val showNotification: Boolean = true,
val ignoreNetworkChanges: Boolean = false
) {
companion object {
val DEFAULT = ConnectionSettings()
......
......@@ -263,6 +263,10 @@ object Settings {
showNotification = getBoolean(
context.getString(R.string.preference_show_notification_key),
ConnectionSettings.DEFAULT.showNotification
),
ignoreNetworkChanges = getBoolean(
context.getString(R.string.preference_ignore_network_changes_key),
ConnectionSettings.DEFAULT.ignoreNetworkChanges
)
)
}
......
......@@ -333,5 +333,9 @@
<string name="preference_show_notification_title">Show notification</string>
<string name="preference_show_notification_summary">Keeps Quasseldroid always connected by showing a persistent notification</string>
<string name="preference_ignore_network_changes_key" translatable="false">ignore_network_changes</string>
<string name="preference_ignore_network_changes_title">Ignore network changes</string>
<string name="preference_ignore_network_changes_summary">Stops Quasseldroid from reconnecting automatically if the network changes</string>
<string name="preference_notification_id_key" translatable="false">notification_id</string>
</resources>
......@@ -348,5 +348,10 @@
android:key="@string/preference_show_notification_key"
android:summary="@string/preference_show_notification_summary"
android:title="@string/preference_show_notification_title" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/preference_ignore_network_changes_key"
android:summary="@string/preference_ignore_network_changes_summary"
android:title="@string/preference_ignore_network_changes_title" />
</PreferenceCategory>
</PreferenceScreen>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment