Move battery settings to experimental section

This commit is contained in:
Philipp Heckel 2022-01-16 15:21:34 -05:00
parent 4dd09ac39d
commit 6b6bf0bd7a
5 changed files with 18 additions and 13 deletions

View file

@ -19,7 +19,7 @@ class ApiService {
.writeTimeout(15, TimeUnit.SECONDS)
.build()
private val subscriberClient = OkHttpClient.Builder()
.readTimeout(5, TimeUnit.MINUTES) // Assuming that keepalive messages are more frequent than this
.readTimeout(77, TimeUnit.SECONDS) // Assuming that keepalive messages are more frequent than this
.build()
private val parser = NotificationParser()

View file

@ -71,6 +71,7 @@ class DownloadWorker(private val context: Context, params: WorkerParameters) : W
.addHeader("User-Agent", ApiService.USER_AGENT)
.build()
client.newCall(request).execute().use { response ->
Log.d(TAG, "Download: headers received: $response")
if (!response.isSuccessful || response.body == null) {
throw Exception("Unexpected response: ${response.code}")
}

View file

@ -49,7 +49,7 @@ class WsConnection(
return
}
if (webSocket != null) {
webSocket!!.close(1000, "")
webSocket!!.close(WS_CLOSE_NORMAL, "")
}
state = State.Connecting
val nextId = ID.incrementAndGet()
@ -68,7 +68,7 @@ class WsConnection(
}
Log.d(TAG, "[$url] WebSocket(${ID.get()}): closing existing connection")
state = State.Disconnected
webSocket!!.close(1000, "")
webSocket!!.close(WS_CLOSE_NORMAL, "")
webSocket = null
}
@ -166,6 +166,7 @@ class WsConnection(
companion object {
private const val TAG = "NtfyWsConnection"
private const val RECONNECT_TAG = "WsReconnect"
private const val WS_CLOSE_NORMAL = 1000
private val RETRY_SECONDS = listOf(5, 10, 15, 20, 30, 45, 60, 120)
private val ID = AtomicLong(0)
}

View file

@ -226,6 +226,11 @@
<string name="settings_unified_push_base_url_title">Server URL</string>
<string name="settings_unified_push_base_url_default_summary">%1$s (default)</string>
<string name="settings_advanced_header">Advanced</string>
<string name="settings_advanced_broadcast_key">BroadcastEnabled</string>
<string name="settings_advanced_broadcast_title">Broadcast messages</string>
<string name="settings_advanced_broadcast_summary_enabled">Apps can receive incoming notifications as broadcasts</string>
<string name="settings_advanced_broadcast_summary_disabled">Apps cannot receive notifications as broadcasts</string>
<string name="settings_experimental_header">Experimental</string>
<string name="settings_advanced_connection_protocol_key">ConnectionProtocol</string>
<string name="settings_advanced_connection_protocol_title">Connection protocol</string>
<string name="settings_advanced_connection_protocol_summary_jsonhttp">Use a JSON stream over HTTP to connect to the server. This is the tried and true method, though it may consume more battery.</string>
@ -236,10 +241,6 @@
<string name="settings_advanced_wakelock_title">Permanent wakelock</string>
<string name="settings_advanced_wakelock_summary_enabled">Prevents app from sleeping to ensure timely notification delivery. This consumes a lot of battery, but some devices require this.</string>
<string name="settings_advanced_wakelock_summary_disabled">Allows app to enter sleep mode. This may negatively impact notification delivery. It depends on the device.</string>
<string name="settings_advanced_broadcast_key">BroadcastEnabled</string>
<string name="settings_advanced_broadcast_title">Broadcast messages</string>
<string name="settings_advanced_broadcast_summary_enabled">Apps can receive incoming notifications as broadcasts</string>
<string name="settings_advanced_broadcast_summary_disabled">Apps cannot receive notifications as broadcasts</string>
<string name="settings_about_header">About</string>
<string name="settings_about_version_key">Version</string>
<string name="settings_about_version_title">Version</string>

View file

@ -34,6 +34,12 @@
app:dependency="@string/settings_unified_push_enabled_key"/>
</PreferenceCategory>
<PreferenceCategory app:title="@string/settings_advanced_header">
<SwitchPreference
app:key="@string/settings_advanced_broadcast_key"
app:title="@string/settings_advanced_broadcast_title"
app:enabled="true"/>
</PreferenceCategory>
<PreferenceCategory app:title="@string/settings_experimental_header">
<ListPreference
app:key="@string/settings_advanced_connection_protocol_key"
app:title="@string/settings_advanced_connection_protocol_title"
@ -44,10 +50,6 @@
app:key="@string/settings_advanced_wakelock_key"
app:title="@string/settings_advanced_wakelock_title"
app:enabled="true"/>
<SwitchPreference
app:key="@string/settings_advanced_broadcast_key"
app:title="@string/settings_advanced_broadcast_title"
app:enabled="true"/>
</PreferenceCategory>
<PreferenceCategory app:title="@string/settings_about_header">
<Preference