Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 56d208df authored by Danny Baumann's avatar Danny Baumann Committed by Michael Bestas
Browse files

Settings: Add setup UI for minimum delay between an app's notification sounds

Author: LuK1337 <priv.luk@gmail.com>
Date:   Tue Jul 23 20:28:56 2019 +0200

    Settings: Preserve sound timeout pref when showing legacy notification settings

    * Fixes : https://gitlab.com/LineageOS/issues/android/issues/936
              https://gitlab.com/LineageOS/issues/android/issues/939

    Change-Id: I61da5790fd09f6340c6fdbe89378114cd1e0dc5b

Author: Luk1337 <priv.luk@gmail.com>
Date:   Tue Aug 27 17:35:07 2019 +0800

    Settings: Remove sound timeout preference from channel_settings PreferenceScreen

    * Fixes: https://gitlab.com/LineageOS/issues/android/issues/1098

    Change-Id: I228fef766b70ad4f3fc47b83cf113517eb9db99f

Change-Id: I70e9cc308b4f7c7681457a0b09dd73e5d1aebb73
parent 922a9ad2
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2016 The CyanogenMod Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<resources>
    <!-- Per-app notification settings: Timeout period in which the app notifications are muted. These are shown in a list dialog. -->
    <string-array name="app_notification_sound_timeout_entries" translatable="false">
        <item>@string/app_notification_sound_timeout_value_none</item>
        <item>@string/app_notification_sound_timeout_value_10_seconds</item>
        <item>@string/app_notification_sound_timeout_value_30_seconds</item>
        <item>@string/app_notification_sound_timeout_value_1_minute</item>
        <item>@string/app_notification_sound_timeout_value_5_minutes</item>
        <item>@string/app_notification_sound_timeout_value_15_minutes</item>
        <item>@string/app_notification_sound_timeout_value_30_minutes</item>
    </string-array>

    <!-- Do not translate. -->
    <string-array name="app_notification_sound_timeout_values" translatable="false">
        <item>0</item>
        <item>10000</item>
        <item>30000</item>
        <item>60000</item>
        <item>300000</item>
        <item>900000</item>
        <item>1800000</item>
    </string-array>
</resources>
+11 −0
Original line number Diff line number Diff line
@@ -79,6 +79,17 @@
    <string name="show_navbar_hint_title">Navigation hint</string>
    <string name="show_navbar_hint_summary">Show navigation hint bar at the bottom of the screen</string>

    <!-- Notification sound timeout -->
    <string name="app_notification_sound_timeout_title">Minimum time between notification sounds</string>
    <string name="app_notification_sound_timeout_summary_template">Allow sounds or vibration no more than once every <xliff:g id="duration">%1$s</xliff:g></string>
    <string name="app_notification_sound_timeout_value_none">No restriction</string>
    <string name="app_notification_sound_timeout_value_10_seconds">10 seconds</string>
    <string name="app_notification_sound_timeout_value_30_seconds">30 seconds</string>
    <string name="app_notification_sound_timeout_value_1_minute">1 minute</string>
    <string name="app_notification_sound_timeout_value_5_minutes">5 minutes</string>
    <string name="app_notification_sound_timeout_value_15_minutes">10 minutes</string>
    <string name="app_notification_sound_timeout_value_30_minutes">30 minutes</string>

    <!-- Per-app data restrictions -->
    <string name="data_usage_app_restrict_all">Allow network access</string>
    <string name="data_usage_app_restrict_all_summary">Enable network usage</string>
+8 −0
Original line number Diff line number Diff line
@@ -86,6 +86,14 @@
        android:title="@string/app_notification_override_dnd_title"
        android:summary="@string/app_notification_override_dnd_summary"/>

    <com.android.settings.RestrictedListPreference
        android:key="sound_timeout"
        android:title="@string/app_notification_sound_timeout_title"
        android:entries="@array/app_notification_sound_timeout_entries"
        android:entryValues="@array/app_notification_sound_timeout_values"
        android:order="1003"
        android:persistent="false" />

        <Preference
            android:key="app_link"
            android:order="1003"
+21 −0
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ public class NotificationBackend {
        row.userId = UserHandle.getUserId(row.uid);
        row.blockedChannelCount = getBlockedChannelCount(row.pkg, row.uid);
        row.channelCount = getChannelCount(row.pkg, row.uid);
        row.soundTimeout = getNotificationSoundTimeout(row.pkg, row.uid);
        recordAggregatedUsageEvents(context, row);
        return row;
    }
@@ -658,6 +659,25 @@ public class NotificationBackend {
        sINM = inm;
    }

    public long getNotificationSoundTimeout(String pkg, int uid) {
        try {
            return sINM.getNotificationSoundTimeout(pkg, uid);
        } catch (Exception e) {
            Log.w(TAG, "Error calling NoMan", e);
            return 0;
        }
    }

    public boolean setNotificationSoundTimeout(String pkg, int uid, long timeout) {
        try {
            sINM.setNotificationSoundTimeout(pkg, uid, timeout);
            return true;
        } catch (Exception e) {
            Log.w(TAG, "Error calling NoMan", e);
            return false;
        }
    }

    /**
     * NotificationsSentState contains how often an app sends notifications and how recently it sent
     * one.
@@ -688,6 +708,7 @@ public class NotificationBackend {
        public int userId;
        public int blockedChannelCount;
        public int channelCount;
        public long soundTimeout;
        public Map<String, NotificationsSentState> sentByChannel;
        public NotificationsSentState sentByApp;
    }
+1 −0
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ public class AppNotificationSettings extends NotificationSettings {
        mControllers.add(new HeaderPreferenceController(context, this));
        mControllers.add(new BlockPreferenceController(context, mDependentFieldListener, mBackend));
        mControllers.add(new BadgePreferenceController(context, mBackend));
        mControllers.add(new SoundTimeoutPreferenceController(context, mBackend));
        mControllers.add(new AllowSoundPreferenceController(
                context, mDependentFieldListener, mBackend));
        mControllers.add(new ImportancePreferenceController(
Loading