From e6f68f445ac4947ec266fdb0d3cd936c3afb316c Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Fri, 22 Jan 2016 21:30:50 +0100 Subject: [PATCH 1/3] Ignore generic notification when from SMSSecure when SMS Notifications are on. This should improve (not fix) #214 Still, we cannot decrypt SMS, so if you use SMSSecure as the default SMS App you should disable SMS Notifications which enables generic notifications for SMSSecure which are already decrypted. --- .../gadgetbridge/externalevents/NotificationListener.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java index 81eaaf80..d4f6ed63 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java @@ -196,8 +196,11 @@ public class NotificationListener extends NotificationListenerService { } } - if (source.equals("com.moez.QKSMS") || source.equals("com.android.mms") || - source.equals("com.sonyericsson.conversations") || source.equals("com.android.messaging")) { + if (source.equals("com.moez.QKSMS") || + source.equals("com.android.mms") || + source.equals("com.sonyericsson.conversations") || + source.equals("com.android.messaging") || + source.equals("org.smssecure.smssecure")) { if (!"never".equals(sharedPrefs.getString("notification_mode_sms", "when_screen_off"))) { return; } @@ -236,6 +239,7 @@ public class NotificationListener extends NotificationListenerService { case "com.android.mms": case "com.android.messaging": case "com.sonyericsson.conversations": + case "org.smssecure.smssecure": notificationSpec.type = NotificationType.SMS; break; case "eu.siacs.conversations": From 9af976657b60ab204a82d5e1ed2ec31a9aa0e75f Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sun, 24 Jan 2016 00:06:44 +0100 Subject: [PATCH 2/3] Pebble: Report correct connection state to PebbleKit companion apps (not always connected) --- CHANGELOG.md | 4 +++ .../PebbleContentProvider.java | 36 ++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa4bf7ba..9d1b2184 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ###Changelog +####Next Version +* Pebble: Report connection state to PebbleKit companion apps via content provider. NOTE: Makes Gadgetbridge mutual exclusive with the original Pebble app. +* Ignore generic notification when from SMSSecure when SMS Notifications are on + ####Version 0.7.2 * Pebble: Allow replying to generic notifications that contain a wearable reply action (tested with Signal) * Pebble: Support seting up a common suffix for canned replies (defaults to " (canned reply)") diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/contentprovider/PebbleContentProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/contentprovider/PebbleContentProvider.java index a6bf3792..c20a552d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/contentprovider/PebbleContentProvider.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/contentprovider/PebbleContentProvider.java @@ -1,11 +1,21 @@ package nodomain.freeyourgadget.gadgetbridge.contentprovider; +import android.content.BroadcastReceiver; import android.content.ContentProvider; import android.content.ContentValues; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.SharedPreferences; import android.database.Cursor; import android.database.MatrixCursor; import android.net.Uri; +import android.preference.PreferenceManager; import android.support.annotation.NonNull; +import android.support.v4.content.LocalBroadcastManager; + +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; public class PebbleContentProvider extends ContentProvider { @@ -24,8 +34,22 @@ public class PebbleContentProvider extends ContentProvider { static final String URL = "content://" + PROVIDER_NAME + "/state"; static final Uri CONTENT_URI = Uri.parse(URL); + private GBDevice mGBDevice = null; + + private final BroadcastReceiver mReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action.equals(GBDevice.ACTION_DEVICE_CHANGED)) { + mGBDevice = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE); + } + } + }; + @Override public boolean onCreate() { + LocalBroadcastManager.getInstance(this.getContext()).registerReceiver(mReceiver, new IntentFilter(GBDevice.ACTION_DEVICE_CHANGED)); + return true; } @@ -33,7 +57,17 @@ public class PebbleContentProvider extends ContentProvider { public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { if (uri.equals(CONTENT_URI)) { MatrixCursor mc = new MatrixCursor(columnNames); - mc.addRow(new Object[]{1, 1, 0, 3, 8, 0, "Gadgetbridge"}); + int connected = 0; + int appMessage = 0; + SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this.getContext()); + if (sharedPrefs.getBoolean("pebble_enable_pebblekit", false)) { + appMessage = 1; + } + if (mGBDevice != null && mGBDevice.getType() == DeviceType.PEBBLE && mGBDevice.isInitialized()) { + connected = 1; + } + mc.addRow(new Object[]{connected, appMessage, 0, 3, 8, 2, "Gadgetbridge"}); + return mc; } else { return null; From 857e282bdca23434de2fc9f29b9df6eb16009d2d Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sun, 24 Jan 2016 22:48:51 +0100 Subject: [PATCH 3/3] bump version --- CHANGELOG.md | 2 +- app/build.gradle | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d1b2184..7213e752 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ###Changelog -####Next Version +####Version 0.7.3 * Pebble: Report connection state to PebbleKit companion apps via content provider. NOTE: Makes Gadgetbridge mutual exclusive with the original Pebble app. * Ignore generic notification when from SMSSecure when SMS Notifications are on diff --git a/app/build.gradle b/app/build.gradle index 8d42d35b..ea5621ac 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,8 +14,8 @@ android { targetSdkVersion 23 // note: always bump BOTH versionCode and versionName! - versionName "0.7.2" - versionCode 38 + versionName "0.7.3" + versionCode 39 } buildTypes { release {