mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-29 05:16:51 +01:00
Allow ignore notifications from work profile
This commit is contained in:
parent
a1607ef3ae
commit
7f593bf5e4
@ -35,6 +35,8 @@ import android.media.session.MediaSession;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
import android.service.notification.NotificationListenerService;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
|
||||
@ -280,6 +282,13 @@ public class NotificationListener extends NotificationListenerService {
|
||||
if (isServiceNotRunningAndShouldIgnoreNotifications()) return;
|
||||
|
||||
final Prefs prefs = GBApplication.getPrefs();
|
||||
|
||||
final boolean ignoreWorkProfile = prefs.getBoolean("notifications_ignore_work_profile", false);
|
||||
if (ignoreWorkProfile && isWorkProfile(sbn)) {
|
||||
LOG.debug("Ignoring notification from work profile");
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean mediaIgnoresAppList = prefs.getBoolean("notification_media_ignores_application_list", false);
|
||||
|
||||
// If media notifications ignore app list, check them before
|
||||
@ -717,6 +726,13 @@ public class NotificationListener extends NotificationListenerService {
|
||||
if (isServiceNotRunningAndShouldIgnoreNotifications()) return;
|
||||
|
||||
final Prefs prefs = GBApplication.getPrefs();
|
||||
|
||||
final boolean ignoreWorkProfile = prefs.getBoolean("notifications_ignore_work_profile", false);
|
||||
if (ignoreWorkProfile && isWorkProfile(sbn)) {
|
||||
LOG.debug("Ignoring notification removal from work profile");
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean mediaIgnoresAppList = prefs.getBoolean("notification_media_ignores_application_list", false);
|
||||
|
||||
// If media notifications ignore app list, check them before
|
||||
@ -885,6 +901,11 @@ public class NotificationListener extends NotificationListenerService {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isWorkProfile(StatusBarNotification sbn) {
|
||||
final UserHandle currentUser = Process.myUserHandle();
|
||||
return !sbn.getUser().equals(currentUser);
|
||||
}
|
||||
|
||||
private boolean shouldIgnoreNotification(StatusBarNotification sbn, boolean remove) {
|
||||
Notification notification = sbn.getNotification();
|
||||
String source = sbn.getPackageName();
|
||||
|
@ -253,6 +253,8 @@
|
||||
<string name="pref_title_whenscreenon">…also when screen is on</string>
|
||||
<string name="pref_title_notifications_ignore_low_priority">Ignore low priority notifications</string>
|
||||
<string name="pref_summary_notifications_ignore_low_priority">Do not send low and minimum priority notifications to the watch</string>
|
||||
<string name="pref_title_notifications_ignore_work_profile">Ignore work profile notifications</string>
|
||||
<string name="pref_summary_notifications_ignore_work_profile">Do not send notifications from apps in the work profile to the watch</string>
|
||||
<string name="pref_title_notification_prefer_long_text">Prefer long notification text</string>
|
||||
<string name="pref_summary_notification_prefer_long_text">If available, send the long notification text to the device</string>
|
||||
<string name="pref_title_notification_cache_while_disconnected">Cache while out of range</string>
|
||||
|
@ -30,6 +30,14 @@
|
||||
android:title="@string/pref_title_notifications_ignore_low_priority"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="notifications_ignore_work_profile"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_notifications_ignore_work_profile"
|
||||
android:title="@string/pref_title_notifications_ignore_work_profile"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="notification_prefer_long_text"
|
||||
|
Loading…
Reference in New Issue
Block a user