mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-30 14:02:56 +01:00
Do not send notifications out notification when screen is on. Also filter out "ongoing" notifications
This commit is contained in:
parent
e0c146bde9
commit
bc40f41eab
@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.PowerManager;
|
||||
|
||||
public class K9Receiver extends BroadcastReceiver {
|
||||
|
||||
@ -13,6 +14,12 @@ public class K9Receiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
PowerManager powermanager = (PowerManager) context.getSystemService(context.POWER_SERVICE);
|
||||
if (powermanager.isScreenOn()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// get sender and subject from the Intent
|
||||
String sender = intent.getStringExtra("com.fsck.k9.intent.extra.FROM");
|
||||
String subject = intent.getStringExtra("com.fsck.k9.intent.extra.SUBJECT");
|
||||
|
@ -3,6 +3,7 @@ package nodomain.freeyourgadget.gadgetbridge;
|
||||
import android.app.Notification;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.service.notification.NotificationListenerService;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.util.Log;
|
||||
@ -23,14 +24,21 @@ public class NotificationListener extends NotificationListenerService {
|
||||
|
||||
@Override
|
||||
public void onNotificationPosted(StatusBarNotification sbn) {
|
||||
|
||||
String source = sbn.getPackageName();
|
||||
Log.i(TAG, source);
|
||||
|
||||
PowerManager powermanager = (PowerManager) getSystemService(POWER_SERVICE);
|
||||
if (powermanager.isScreenOn() && !source.equals(getPackageName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Notification notification = sbn.getNotification();
|
||||
|
||||
/* 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...
|
||||
*/
|
||||
String source = sbn.getPackageName();
|
||||
Log.i(TAG, source);
|
||||
|
||||
if (source.equals("android") ||
|
||||
source.equals("com.android.dialer") ||
|
||||
@ -39,11 +47,14 @@ public class NotificationListener extends NotificationListenerService {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((notification.flags & Notification.FLAG_ONGOING_EVENT) == Notification.FLAG_ONGOING_EVENT) {
|
||||
return;
|
||||
}
|
||||
|
||||
Log.i(TAG, "Processing notification from source " + source);
|
||||
|
||||
Bundle extras = notification.extras;
|
||||
String title = extras.getCharSequence(Notification.EXTRA_TITLE).toString();
|
||||
|
||||
String content = "";
|
||||
if (extras.containsKey(Notification.EXTRA_TEXT)) {
|
||||
CharSequence contentCS = extras.getCharSequence(Notification.EXTRA_TEXT);
|
||||
|
@ -64,8 +64,8 @@ public class PebbleProtocol {
|
||||
|
||||
static final byte PHONEVERSION_APPVERSION_MAGIC = 2; // increase this if pebble complains
|
||||
static final byte PHONEVERSION_APPVERSION_MAJOR = 2;
|
||||
static final byte PHONEVERSION_APPVERSION_MINOR = 2;
|
||||
static final byte PHONEVERSION_APPVERSION_PATCH = 2;
|
||||
static final byte PHONEVERSION_APPVERSION_MINOR = 3;
|
||||
static final byte PHONEVERSION_APPVERSION_PATCH = 0;
|
||||
|
||||
|
||||
static final int PHONEVERSION_SESSION_CAPS_GAMMARAY = (int) 0x80000000;
|
||||
|
@ -4,12 +4,19 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.telephony.SmsMessage;
|
||||
|
||||
public class SMSReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
PowerManager powermanager = (PowerManager) context.getSystemService(context.POWER_SERVICE);
|
||||
if (powermanager.isScreenOn()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Bundle bundle = intent.getExtras();
|
||||
if (bundle != null) {
|
||||
Object[] pdus = (Object[]) bundle.get("pdus");
|
||||
|
Loading…
Reference in New Issue
Block a user