Move battery settings to experimental section
This commit is contained in:
parent
4dd09ac39d
commit
6b6bf0bd7a
5 changed files with 18 additions and 13 deletions
|
@ -19,7 +19,7 @@ class ApiService {
|
||||||
.writeTimeout(15, TimeUnit.SECONDS)
|
.writeTimeout(15, TimeUnit.SECONDS)
|
||||||
.build()
|
.build()
|
||||||
private val subscriberClient = OkHttpClient.Builder()
|
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()
|
.build()
|
||||||
private val parser = NotificationParser()
|
private val parser = NotificationParser()
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ class DownloadWorker(private val context: Context, params: WorkerParameters) : W
|
||||||
.addHeader("User-Agent", ApiService.USER_AGENT)
|
.addHeader("User-Agent", ApiService.USER_AGENT)
|
||||||
.build()
|
.build()
|
||||||
client.newCall(request).execute().use { response ->
|
client.newCall(request).execute().use { response ->
|
||||||
|
Log.d(TAG, "Download: headers received: $response")
|
||||||
if (!response.isSuccessful || response.body == null) {
|
if (!response.isSuccessful || response.body == null) {
|
||||||
throw Exception("Unexpected response: ${response.code}")
|
throw Exception("Unexpected response: ${response.code}")
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ class WsConnection(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (webSocket != null) {
|
if (webSocket != null) {
|
||||||
webSocket!!.close(1000, "")
|
webSocket!!.close(WS_CLOSE_NORMAL, "")
|
||||||
}
|
}
|
||||||
state = State.Connecting
|
state = State.Connecting
|
||||||
val nextId = ID.incrementAndGet()
|
val nextId = ID.incrementAndGet()
|
||||||
|
@ -68,7 +68,7 @@ class WsConnection(
|
||||||
}
|
}
|
||||||
Log.d(TAG, "[$url] WebSocket(${ID.get()}): closing existing connection")
|
Log.d(TAG, "[$url] WebSocket(${ID.get()}): closing existing connection")
|
||||||
state = State.Disconnected
|
state = State.Disconnected
|
||||||
webSocket!!.close(1000, "")
|
webSocket!!.close(WS_CLOSE_NORMAL, "")
|
||||||
webSocket = null
|
webSocket = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +166,7 @@ class WsConnection(
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "NtfyWsConnection"
|
private const val TAG = "NtfyWsConnection"
|
||||||
private const val RECONNECT_TAG = "WsReconnect"
|
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 RETRY_SECONDS = listOf(5, 10, 15, 20, 30, 45, 60, 120)
|
||||||
private val ID = AtomicLong(0)
|
private val ID = AtomicLong(0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,6 +226,11 @@
|
||||||
<string name="settings_unified_push_base_url_title">Server URL</string>
|
<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_unified_push_base_url_default_summary">%1$s (default)</string>
|
||||||
<string name="settings_advanced_header">Advanced</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_key">ConnectionProtocol</string>
|
||||||
<string name="settings_advanced_connection_protocol_title">Connection protocol</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>
|
<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_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_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_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_header">About</string>
|
||||||
<string name="settings_about_version_key">Version</string>
|
<string name="settings_about_version_key">Version</string>
|
||||||
<string name="settings_about_version_title">Version</string>
|
<string name="settings_about_version_title">Version</string>
|
||||||
|
|
|
@ -34,6 +34,12 @@
|
||||||
app:dependency="@string/settings_unified_push_enabled_key"/>
|
app:dependency="@string/settings_unified_push_enabled_key"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory app:title="@string/settings_advanced_header">
|
<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
|
<ListPreference
|
||||||
app:key="@string/settings_advanced_connection_protocol_key"
|
app:key="@string/settings_advanced_connection_protocol_key"
|
||||||
app:title="@string/settings_advanced_connection_protocol_title"
|
app:title="@string/settings_advanced_connection_protocol_title"
|
||||||
|
@ -41,12 +47,8 @@
|
||||||
app:entryValues="@array/settings_advanced_connection_protocol_values"
|
app:entryValues="@array/settings_advanced_connection_protocol_values"
|
||||||
app:defaultValue="jsonhttp"/>
|
app:defaultValue="jsonhttp"/>
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
app:key="@string/settings_advanced_wakelock_key"
|
app:key="@string/settings_advanced_wakelock_key"
|
||||||
app:title="@string/settings_advanced_wakelock_title"
|
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"/>
|
app:enabled="true"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory app:title="@string/settings_about_header">
|
<PreferenceCategory app:title="@string/settings_about_header">
|
||||||
|
|
Loading…
Reference in a new issue