1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-19 03:20:21 +02:00

Pebble message intent notifications default to "never" now

If these get turned on, Conversations notifications will be handled through Pebble message intents and get filtered out from generic notifcation handling.
This commit is contained in:
Andreas Shimokawa 2015-05-08 12:50:42 +02:00
parent c999c52501
commit 6f162c593b
3 changed files with 20 additions and 11 deletions

View File

@ -48,8 +48,6 @@ public class NotificationListener extends NotificationListenerService {
return;
}
String source = sbn.getPackageName();
Log.i(TAG, source);
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
if (!sharedPrefs.getBoolean("notifications_generic_whenscreenon", false)) {
@ -59,8 +57,13 @@ public class NotificationListener extends NotificationListenerService {
}
}
String source = sbn.getPackageName();
Notification notification = sbn.getNotification();
if ((notification.flags & Notification.FLAG_ONGOING_EVENT) == Notification.FLAG_ONGOING_EVENT) {
return;
}
/* do not display messages from "android"
* This includes keyboard selection message, usb connection messages, etc
* Hope it does not filter out too much, we will see...
@ -70,13 +73,14 @@ public class NotificationListener extends NotificationListenerService {
source.equals("com.android.systemui") ||
source.equals("com.android.dialer") ||
source.equals("com.android.mms") ||
source.equals("com.fsck.k9") ||
source.equals("eu.siacs.conversations")) {
source.equals("com.fsck.k9")) {
return;
}
if ((notification.flags & Notification.FLAG_ONGOING_EVENT) == Notification.FLAG_ONGOING_EVENT) {
return;
if (source.equals("eu.siacs.conversations")) {
if (!"never".equals(sharedPrefs.getString("notification_mode_pebblemsg", "never"))) {
return;
}
}
Log.i(TAG, "Processing notification from source " + source);
@ -84,20 +88,25 @@ public class NotificationListener extends NotificationListenerService {
Bundle extras = notification.extras;
String title = extras.getCharSequence(Notification.EXTRA_TITLE).toString();
String content = null;
if (extras.containsKey(Notification.EXTRA_TEXT)) {
if (extras.containsKey(Notification.EXTRA_TEXT))
{
CharSequence contentCS = extras.getCharSequence(Notification.EXTRA_TEXT);
if (contentCS != null) {
content = contentCS.toString();
}
}
if (content != null) {
if (content != null)
{
Intent startIntent = new Intent(NotificationListener.this, BluetoothCommunicationService.class);
startIntent.setAction(BluetoothCommunicationService.ACTION_NOTIFICATION_GENERIC);
startIntent.putExtra("notification_title", title);
startIntent.putExtra("notification_body", content);
startService(startIntent);
}
}
@Override

View File

@ -21,10 +21,10 @@ public class PebbleReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
if ("never".equals(sharedPrefs.getString("notification_mode_pebblemsg", "when_screen_off"))) {
if ("never".equals(sharedPrefs.getString("notification_mode_pebblemsg", "never"))) {
return;
}
if ("when_screen_off".equals(sharedPrefs.getString("notification_mode_pebblemsg", "when_screen_off"))) {
if ("when_screen_off".equals(sharedPrefs.getString("notification_mode_pebblemsg", "never"))) {
PowerManager powermanager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (powermanager.isScreenOn()) {
return;

View File

@ -35,7 +35,7 @@
android:title="@string/pref_title_notifications_k9mail" />
<ListPreference
android:defaultValue="when_screen_off"
android:defaultValue="never"
android:entries="@array/notification_mode"
android:entryValues="@array/notification_mode_values"
android:key="notification_mode_pebblemsg"