fix various annoyances
- only ask for notication monitoring permissions the on first start - filter out annoying system messages like keyboard notifications - rearrange buttons - bugfix for message being ignored when sending a test message to the Pebble (sender was used as message content)
This commit is contained in:
parent
88bb645834
commit
fcaf099e70
|
@ -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.
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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" />
|
||||
<Button
|
||||
android:id="@+id/testNotificationButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Create test Notification"
|
||||
android:text="create test notification"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentStart="true" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="start Service"
|
||||
android:text="start service"
|
||||
android:id="@+id/startServiceButton"
|
||||
android:layout_above="@+id/sendButton"
|
||||
android:layout_alignEnd="@+id/sendButton"
|
||||
android:layout_alignParentStart="true" />
|
||||
android:layout_above="@+id/setTimeButton"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignEnd="@+id/setTimeButton" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="set time"
|
||||
android:id="@+id/setTimeButton"
|
||||
android:layout_above="@+id/startServiceButton"
|
||||
android:layout_alignEnd="@+id/startServiceButton"
|
||||
android:layout_above="@+id/testNotificationButton"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentStart="true" />
|
||||
</RelativeLayout>
|
||||
|
|
Loading…
Reference in New Issue