From 1a1277fa3d16f92a7d284eaee443b7b80976e1ac Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sat, 5 Sep 2015 20:40:12 +0200 Subject: [PATCH 01/11] Pebble: Fix "Open on Phone" on OG Pebble (no more error display) --- .../devices/pebble/PebbleProtocol.java | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java index ce34d9a53..c50e69393 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java @@ -478,7 +478,7 @@ public class PebbleProtocol extends GBDeviceProtocol { buf.put((byte) 0x00); // ? buf.put((byte) 0x01); // add notifications - buf.putInt(0x00000002); // flags - ? + buf.putInt(0x00000000); // flags - ? buf.putInt(id); buf.putInt(0x00000000); // ANCS id buf.putInt(timestamp); @@ -664,6 +664,27 @@ public class PebbleProtocol extends GBDeviceProtocol { return encodeBlobdb(UUID.randomUUID(), BLOBDB_INSERT, BLOBDB_NOTIFICATION, buf.array()); } + public byte[] encodeActionResponse2x(int id, int iconId, String caption) { + short length = (short) (18 + caption.length()); + ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + length); + buf.order(ByteOrder.BIG_ENDIAN); + buf.putShort(length); + buf.putShort(ENDPOINT_EXTENSIBLENOTIFS); + buf.order(ByteOrder.LITTLE_ENDIAN); + buf.put(NOTIFICATIONACTION_RESPONSE); + buf.putInt(id); + buf.put((byte) 0x01); // action id? + buf.put(NOTIFICATIONACTION_ACK); + buf.put((byte) 2); //nr of attributes + buf.put((byte) 6); // icon + buf.putShort((short) 4); // length + buf.putInt(iconId); + buf.put((byte) 2); // title + buf.putShort((short) caption.length()); + buf.put(caption.getBytes()); + return buf.array(); + } + public byte[] encodeActionResponse(UUID uuid, int iconId, String caption) { short length = (short) (29 + caption.length()); ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + length); @@ -1132,7 +1153,7 @@ public class PebbleProtocol extends GBDeviceProtocol { return null; } - private GBDeviceEventNotificationControl decodeNotificationAction2x(ByteBuffer buf) { + private GBDeviceEvent[] decodeNotificationAction2x(ByteBuffer buf) { buf.order(ByteOrder.LITTLE_ENDIAN); byte command = buf.get(); @@ -1142,9 +1163,13 @@ public class PebbleProtocol extends GBDeviceProtocol { if (action >= 0x01 && action <= 0x03) { GBDeviceEventNotificationControl devEvtNotificationControl = new GBDeviceEventNotificationControl(); devEvtNotificationControl.handle = id; + GBDeviceEventSendBytes sendBytesAck = null; + switch (action) { case 0x01: devEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.OPEN; + sendBytesAck = new GBDeviceEventSendBytes(); + sendBytesAck.encodedBytes = encodeActionResponse2x(id, 6, "Opened"); break; case 0x02: devEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.DISMISS; @@ -1155,7 +1180,7 @@ public class PebbleProtocol extends GBDeviceProtocol { default: return null; } - return devEvtNotificationControl; + return new GBDeviceEvent[]{sendBytesAck, devEvtNotificationControl}; } LOG.info("unexpected paramerter in dismiss action: " + action); } @@ -1488,7 +1513,7 @@ public class PebbleProtocol extends GBDeviceProtocol { devEvts = new GBDeviceEvent[]{decodeScreenshot(buf, length)}; break; case ENDPOINT_EXTENSIBLENOTIFS: - devEvts = new GBDeviceEvent[]{decodeNotificationAction2x(buf)}; + devEvts = decodeNotificationAction2x(buf); break; case ENDPOINT_NOTIFICATIONACTION: devEvts = decodeNotificationAction3x(buf); From a839f074965e90d28f06e4af2eb1f896dce0b6bf Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sat, 5 Sep 2015 21:00:18 +0200 Subject: [PATCH 02/11] Pebble: use proper icon for "Open on Phone" on Pebble Time --- .../gadgetbridge/service/devices/pebble/PebbleProtocol.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java index c50e69393..84a57cee4 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java @@ -1207,7 +1207,7 @@ public class PebbleProtocol extends GBDeviceProtocol { case 0x01: dismissNotification.event = GBDeviceEventNotificationControl.Event.OPEN; caption = "Opened"; - icon_id = 47; // FIXME: find a better one + icon_id = 49; break; case 0x02: dismissNotification.event = GBDeviceEventNotificationControl.Event.DISMISS; From 02cc8ba455e0b5dc5aa676dd6a773c12b8eb6903 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sat, 5 Sep 2015 21:32:46 +0200 Subject: [PATCH 03/11] Allow K9 Mail notifications to be handled as a generic notification if K9 Mail notification mode is set to "never" This makes it possible to use the "Open on Phone" and individial dismiss feature with K9 Mail. --- .../externalevents/NotificationListener.java | 9 +++++++-- 1 file changed, 7 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 e5cb681aa..016f93d29 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java @@ -130,8 +130,7 @@ public class NotificationListener extends NotificationListenerService { source.equals("com.android.dialer") || source.equals("com.android.mms") || source.equals("com.moez.QKSMS") || - source.equals("com.cyanogenmod.eleven") || - source.equals("com.fsck.k9")) { + source.equals("com.cyanogenmod.eleven")) { return; } @@ -141,6 +140,12 @@ public class NotificationListener extends NotificationListenerService { } } + if (source.equals("com.fsck.k9")) { + if (!"never".equals(sharedPrefs.getString("notification_mode_k9mail", "when_screen_off"))) { + return; + } + } + LOG.info("Processing notification from source " + source); Bundle extras = notification.extras; From 3fb92e2e794cfe93b9a72f31958320342dc38469 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sat, 5 Sep 2015 21:38:35 +0200 Subject: [PATCH 04/11] update CHANGELOG.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb67a7822..e7c41e824 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ###Changelog +####Next Version +* Pebble: For generic notifications, support dismissing individual notficications and "Open on Phone" feature (OG & PT) +* Pebble: Allow to treat K9 notifcations as generic notifications (if notification mode is set to never) +* Ignore QKSMS notificaions to avoid double notification for incoming SMS + ####Version 0.5.2 * Pebble: support "dismiss all" action also on Pebble Time/FW 3.x notifications * Miband: show a notification when the battery is below 10% From a62647fa46d08fd47ab6926c5579b3af56554835 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sat, 5 Sep 2015 22:20:22 +0200 Subject: [PATCH 05/11] bump version, update README.md --- CHANGELOG.md | 2 +- README.md | 5 +++-- app/build.gradle | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7c41e824..58d84a25d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ###Changelog -####Next Version +####Version 0.5.3 * Pebble: For generic notifications, support dismissing individual notficications and "Open on Phone" feature (OG & PT) * Pebble: Allow to treat K9 notifcations as generic notifications (if notification mode is set to never) * Ignore QKSMS notificaions to avoid double notification for incoming SMS diff --git a/README.md b/README.md index 01bb5bf5d..0c42e1ebb 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,8 @@ need to create an account and transmit any of your data to the vendor's servers. * SMS notification (sender, body) * K-9 Mail notification support (sender, subject, preview) * Support for generic notifications (above filtered out) -* Dismiss all notifications from the action menu of a notification +* Dismiss individial notifications or open corresponding app on phone from the action menu (generic notifications) +* Dismiss all notifications from the action menu (non-generic notifications) * Music playback info (artist, album, track). Apollo and CM 12.1 Music App supported. * Music control: play/pause, next track, previous track, volume up, volume down * List and remove installed apps/watchfaces @@ -34,7 +35,7 @@ need to create an account and transmit any of your data to the vendor's servers. All features are also supported on the Pebble Time, except for the following: -* Listing installed watchfaces (it will simply display the UUIDs of previously installed watchapps, no matter if they are stil installed or not) +* Listing installed watchfaces (it will simply display the UUIDs of previously installed watchapps, no matter if they are still installed or not) * Firmware installation is untested and will probably not work. ## How to use (Pebble) diff --git a/app/build.gradle b/app/build.gradle index 40c65d15d..2a53d1da2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,8 +12,8 @@ android { applicationId "nodomain.freeyourgadget.gadgetbridge" minSdkVersion 19 targetSdkVersion 23 - versionCode 23 - versionName "0.5.2" + versionCode 24 + versionName "0.5.3" } buildTypes { release { From 78321e28bf6ef8af1d13803069b75e0a6d7771d3 Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Sat, 5 Sep 2015 23:06:28 +0200 Subject: [PATCH 06/11] Adjust to API change --- .../gadgetbridge/service/TestDeviceSupport.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/TestDeviceSupport.java b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/TestDeviceSupport.java index 61de0b47d..cb85dd2b5 100644 --- a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/TestDeviceSupport.java +++ b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/TestDeviceSupport.java @@ -58,8 +58,8 @@ public class TestDeviceSupport extends AbstractDeviceSupport { } @Override - public void onGenericNotification(String title, String details) { - + public void onGenericNotification(String title, String details, int handle) { + } @Override From ed6629a9c72d9cf0463b28058b40205ad7e4b1d3 Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Sat, 5 Sep 2015 23:11:40 +0200 Subject: [PATCH 07/11] Updated translations from transifex (thanks!) --- app/src/main/res/values-es/strings.xml | 5 ---- app/src/main/res/values-fr/strings.xml | 36 +++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index abc637dfb..0bfb925f4 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -16,10 +16,6 @@ Borrar Instalador de FW/App - Estás a punto de instalar el firmware %s en lugar del que está actualmente en tu MiBand. - Este firmware ha sido probado y se sabe que es compatible con GadgetBridge. - Este firmware no se ha probado y puede no ser compatible con GadgetBridge. No se recomienda la instalación en tu MiBand. - Si a pesar de esto deseas continuar y las cosas continúan funcionando bien posteriormente, por favor, informa a los desarrolladores de GadgetBridge para que incluyan la versión de firmware:%s en la lista blanca Ajustes Ajustes generales @@ -146,7 +142,6 @@ No se ha podido encontrar un controlador para instalar este archivo. No se puede instalar el archivo: $1%s No se puede instalar este firmware: no coincide con la revision hardware de tu Pebble. - Por favor, espera mientras se determina el estado de la instalación ... Tu sueño Pasos por semana Tu actividad y sueño diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 44ec84417..a86ebf6b6 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -12,11 +12,12 @@ Déconnexion Débugger + Gestionnaire d\'application Supprimer - Vous êtes sur le point d\'installer le firmware %s à la place de celui qui est actuellement sur votre MiBand. - Ce firmware a été testé et est compatible with GadgetBridge - Ce firmware n\'est pas testé and peut ne pas être compatible avec GadgetBridge. Il ne vous est pas conseillé de flasher votre MiBand + Vous êtes sur le point d\'installer le firmware %s à la place de celui qui est actuellement sur votre Mi Band. + Ce firmware a été testé et est connu pour être compatible avec Gadgetbridge. + Ce firmware n\'a pas été testé et peut ne pas être compatible avec Gadgetbridge. \ N \ nIl n\'est pas conseillé de flasher votre Mi Band. Paramètre Paramètres généraux @@ -30,6 +31,7 @@ Appel entrant K9-Email Message Pebble + Support pour les applications qui envoient des notifications au Pebble via Intent. Peut être utilisé pour les conversations. Support des notififactions génériques même lorsque l\'écran est allumé toujours @@ -54,6 +56,7 @@ Ceci est un test de notification venant de Gadgetbridge Le bluetooth n\'est pas supporté Le bluetooth est désactivé + Taper sur lpour le connecter au gestionnaire d\'application Tapper sur l\'appareil pour le connecter Ne peut être connecter. L’adresse bluetooth est invalide? Gadgetbridge est en fonctionnement @@ -61,6 +64,7 @@ installation en échec installation réalisé VOUS ÊTES EN TRAIN D\'INSTALLER UN FIRMWARE, PROCEDEZ À VOS PROPRES RISQUES. CE FIRMWARE EST POUR LA VERSION HW: %s + Vous êtes sur le point d\'installer l\'application suivante:\n\n\n%1$s Version %2$s par %3$s\n N/A initialisé %1$s par %2$s @@ -86,6 +90,7 @@ Installer Rendre votre appareil découvrable. Actuellement les appareils connectés ne seront pas découvert. Note: + Image de l\'appareil A propos de vous Nom/Pseudo Année de naissance @@ -96,6 +101,7 @@ Moniteur de sommeil Ecrire le fichier de logs (besoin de redemarrer) iniitialisation + Récupération des données d\'activité De %1$s à %2$s Port main gauche ou droite? Profil de vibration @@ -138,5 +144,27 @@ Impossible de trouver un gestionnaire pour installer ce fichier. Impossible d\'installer le fichier donné: $1%s Impossible d\'installer le firmware donnée: il ne correspond pas à la version du matériel de votre Pebble. - S\'il vous plaît patienter pendant la détermination de l\'état de l\'installation ... + S\'il vous plait patientez pendant la détermination du status de l\'installation... + Gadget batterie Vide! + %1$s batterie restante: %2$s%% + Dernière charge: %s \n + Nombre de charges: %s + Votre sommeil + Pas de la semaine + Votre activité et sommeil + Mise à jour du Firmware... + Le fichier ne peut pas être installé, l\'appareil n\'est pas prêt. + Firmware Mi Band %1$s + Version compatible + Version non testé! + Connexion à l\'appareil: %1$s + Firmware Pebble %1$s + Révision correcte du matériel + Version Hardware incorrecte! + %1$s (%2$s) + Problème avec le transfert du firmware. Ne redémarrez pas votre bande Mi! + Problème avec le transfert de métadonnées du firmware + Installation complète du firmware + Installation complète du firmware, redémarrage de l\'appareil + Échec lors de l\'écriture du firmware From fbd23c2d4cc6c91401a51eb99a577c149889a2d1 Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Sun, 6 Sep 2015 00:03:56 +0200 Subject: [PATCH 08/11] Some layout improvements (#30) --- .../activities/FwAppInstallerActivity.java | 4 +- .../main/res/layout/activity_appinstaller.xml | 40 +++++++++++++------ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FwAppInstallerActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FwAppInstallerActivity.java index a9f568d7c..a9ff065f3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FwAppInstallerActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FwAppInstallerActivity.java @@ -179,7 +179,9 @@ public class FwAppInstallerActivity extends Activity implements InstallActivity @Override public void setInstallEnabled(boolean enable) { - installButton.setEnabled(device != null && device.isConnected() && enable); + boolean enabled = device != null && device.isConnected() && enable; + installButton.setEnabled(enabled); + installButton.setVisibility(enabled ? View.VISIBLE : View.GONE); } @Override diff --git a/app/src/main/res/layout/activity_appinstaller.xml b/app/src/main/res/layout/activity_appinstaller.xml index 3e64f9150..8846623b0 100644 --- a/app/src/main/res/layout/activity_appinstaller.xml +++ b/app/src/main/res/layout/activity_appinstaller.xml @@ -1,4 +1,4 @@ - + android:layout_height="wrap_content" + android:layout_alignParentEnd="false"> + android:layout_alignParentTop="false" + android:layout_alignParentEnd="false" + android:layout_alignParentStart="false" + android:layout_below="@+id/itemListView" /> + android:layout_centerHorizontal="true" + android:layout_alignParentTop="false" + android:layout_alignParentLeft="false" + android:layout_below="@+id/infoTextView" /> + android:visibility="gone" + android:layout_below="@+id/fwappStatusIcon" + android:layout_centerHorizontal="true" />