diff --git a/README.md b/README.md
index a7b8dd01c..d49145cc6 100644
--- a/README.md
+++ b/README.md
@@ -15,11 +15,9 @@ Known Visible Issues:
* No special notifications, EVERYTHING will be send as a Chat/SMS message
* Notifications are not properly queued, if two arrive at about the same time,
- one of them will get lost
+ one of them will get lost (TODO: confirm)
* Android 4.4+ only, we can only change this by implementing an
AccessibiltyService. Don't know if it is worth the hassle.
-* This will open the dialog to allow capturing notifications every time the
- Activity gets restarted.
Apart from that there are many internal design flaws which we will discuss using
the issue tracker.
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java
index e98a90349..6d3c184e8 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java
@@ -2,8 +2,9 @@ package nodomain.freeyourgadget.gadgetbridge;
import android.app.NotificationManager;
import android.content.Intent;
-import android.content.IntentFilter;
+import android.content.SharedPreferences;
import android.os.Bundle;
+import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
@@ -49,7 +50,7 @@ public class ControlCenter extends ActionBarActivity {
Intent startIntent = new Intent(ControlCenter.this, BluetoothCommunicationService.class);
startIntent.setAction(BluetoothCommunicationService.ACTION_SENDMESSAGE);
startIntent.putExtra("notification_title", editTitle.getText().toString());
- startIntent.putExtra("notification_content", editTitle.getText().toString());
+ startIntent.putExtra("notification_content", editContent.getText().toString());
startService(startIntent);
}
});
@@ -71,12 +72,16 @@ public class ControlCenter extends ActionBarActivity {
}
});
- Intent enableIntent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
-
- startActivity(enableIntent);
-
- IntentFilter filter = new IntentFilter();
- filter.addAction("nodomain.freeyourgadget.gadgetbridge.NOTIFICATION_LISTENER");
+ /*
+ * Ask for permission to intercept notifications on first run.
+ * TODO: allow re-request in preferences
+ */
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
+ if (sharedPrefs.getBoolean("firstrun", true)) {
+ sharedPrefs.edit().putBoolean("firstrun", false).commit();
+ Intent enableIntent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
+ startActivity(enableIntent);
+ }
}
private void testNotification() {
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/NotificationListener.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/NotificationListener.java
index bad1208b4..8d52d671d 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/NotificationListener.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/NotificationListener.java
@@ -23,12 +23,21 @@ public class NotificationListener extends NotificationListenerService {
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
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...
+ */
+ if (sbn.getPackageName().equals("android"))
+ return;
+
Bundle extras = notification.extras;
String title = extras.getString(Notification.EXTRA_TITLE);
String content = "";
if (extras.containsKey(Notification.EXTRA_TEXT))
content = extras.getString(Notification.EXTRA_TEXT);
+
if (content != null) {
Intent startIntent = new Intent(NotificationListener.this, BluetoothCommunicationService.class);
startIntent.setAction(BluetoothCommunicationService.ACTION_SENDMESSAGE);
diff --git a/app/src/main/res/layout/activity_controlcenter.xml b/app/src/main/res/layout/activity_controlcenter.xml
index 0cf476069..7a8363710 100644
--- a/app/src/main/res/layout/activity_controlcenter.xml
+++ b/app/src/main/res/layout/activity_controlcenter.xml
@@ -41,32 +41,32 @@
android:id="@+id/sendButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="Send to Pebble"
- android:layout_above="@+id/testNotificationButton"
+ android:text="send to Pebble"
+ android:layout_below="@+id/editContent"
android:layout_alignParentStart="true" />
+ android:layout_above="@+id/setTimeButton"
+ android:layout_alignParentStart="true"
+ android:layout_alignEnd="@+id/setTimeButton" />