Merge pull request #929 from Bnyro/master

network type for notifcations option
This commit is contained in:
Bnyro 2022-07-31 14:37:17 +02:00 committed by GitHub
commit f018e41545
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 48 additions and 2 deletions

View File

@ -70,6 +70,7 @@ object PreferenceKeys {
*/
const val NOTIFICATION_ENABLED = "notification_toggle"
const val CHECKING_FREQUENCY = "checking_frequency"
const val REQUIRED_NETWORK = "required_network"
const val LAST_STREAM_VIDEO_ID = "last_stream_video_id"
/**

View File

@ -41,10 +41,20 @@ object NotificationHelper {
// schedule the work manager request if logged in and notifications enabled
if (notificationsEnabled && PreferenceHelper.getToken() != "") {
// required network type for the work
val networkType = when (
PreferenceHelper.getString(PreferenceKeys.REQUIRED_NETWORK, "all")
) {
"all" -> NetworkType.CONNECTED
"wifi" -> NetworkType.UNMETERED
"metered" -> NetworkType.METERED
else -> NetworkType.CONNECTED
}
// requirements for the work
// here: network needed to run the task
val constraints = Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.setRequiredNetworkType(networkType)
.build()
// create the worker

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="#FF000000"
android:pathData="m4.05,44 l40,-40v40Z" />
</vector>

View File

@ -796,4 +796,16 @@
<item>channel_name_za</item>
</string-array>
<string-array name="requiredNetwork">
<item>@string/network_all</item>
<item>@string/network_wifi</item>
<item>@string/network_metered</item>
</string-array>
<string-array name="requiredNetworkValues">
<item>all</item>
<item>wifi</item>
<item>metered</item>
</string-array>
</resources>

View File

@ -280,4 +280,8 @@
<string name="channel_name_az">Channel Name (A-Z)</string>
<string name="channel_name_za">Channel Name (Z-A)</string>
<string name="sort">Sort</string>
<string name="required_network">Required network type</string>
<string name="network_all">All networks</string>
<string name="network_metered">Metered</string>
<string name="network_wifi">WiFi only</string>
</resources>

View File

@ -20,6 +20,15 @@
app:title="@string/checking_frequency"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:icon="@drawable/ic_signal"
app:defaultValue="all"
app:entries="@array/requiredNetwork"
app:entryValues="@array/requiredNetworkValues"
app:key="required_network"
app:title="@string/required_network"
app:useSimpleSummaryProvider="true" />
</PreferenceCategory>
</PreferenceScreen>