diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 000000000..1637e8149 --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,28 @@ + Andreas Shimokawa + cpfeiffer + Daniele Gobbetti + Daniele Gobbetti + danielegobbetti + Carsten Pfeiffer + Julien Pivotto + Lem Dulfo + Sergey Trofimov + Daniele Gobbetti + cpfeiffer + 0nse <0nse@users.noreply.github.com> + Christian Fischer + Normano64 + Ⲇⲁⲛⲓ Φi + xphnx + Tarik Sekmen + rober + Nicolò Balzarotti + Marc Schlaich + kevlarcade + Kasha + Chris Perelstein + Alexey Afanasev + +And all the Transifex translators, which I cannot automatically list, at the moment. + +git log --raw | grep "^Author: " | sort | uniq -c | sort -k 1 -n -r | cut -f 2- -d: > CONTRIBUTORS.md diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java index 028a68a33..3e7dda6fb 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java @@ -1,16 +1,21 @@ package nodomain.freeyourgadget.gadgetbridge; import android.app.Application; +import android.app.NotificationManager; +import android.app.NotificationManager.Policy; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.res.Resources; +import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; +import android.net.Uri; import android.os.Build; import android.os.Build.VERSION; import android.preference.PreferenceManager; +import android.provider.ContactsContract.PhoneLookup; import android.support.v4.content.LocalBroadcastManager; import android.util.Log; import android.util.TypedValue; @@ -61,6 +66,7 @@ public class GBApplication extends Application { private static Prefs prefs; private static GBPrefs gbPrefs; private static DBHandler lockHandler; + private static NotificationManager notificationManager; public static final String ACTION_QUIT = "nodomain.freeyourgadget.gadgetbridge.gbapplication.action.quit"; @@ -123,6 +129,10 @@ public class GBApplication extends Application { filterLocal.addAction(ACTION_QUIT); LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filterLocal); + if (isRunningMarshmallowOrLater()) { + notificationManager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE); + } + // for testing DB stuff // SQLiteDatabase db = mActivityDatabaseHandler.getWritableDatabase(); // db.close(); @@ -260,6 +270,61 @@ public class GBApplication extends Application { return VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; } + public static boolean isRunningMarshmallowOrLater() { + return VERSION.SDK_INT >= Build.VERSION_CODES.M; + } + + private static boolean isPrioritySender(int prioritySenders, String number) { + if (prioritySenders == Policy.PRIORITY_SENDERS_ANY) { + return true; + } else { + Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number)); + String[] projection = new String[]{PhoneLookup._ID, PhoneLookup.STARRED}; + Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null); + boolean exists = false; + int starred = 0; + try { + if (cursor.moveToFirst()) { + exists = true; + starred = cursor.getInt(cursor.getColumnIndexOrThrow(PhoneLookup.STARRED)); + } + } finally { + if (cursor != null) { + cursor.close(); + } + } + if (prioritySenders == Policy.PRIORITY_SENDERS_CONTACTS && exists) { + return true; + } else if (prioritySenders == Policy.PRIORITY_SENDERS_STARRED && starred == 1) { + return true; + } + return false; + } + } + + public static boolean isPriorityNumber(int priorityType, String number) { + NotificationManager.Policy notificationPolicy = notificationManager.getNotificationPolicy(); + if(priorityType == Policy.PRIORITY_CATEGORY_MESSAGES) { + if ((notificationPolicy.priorityCategories & Policy.PRIORITY_CATEGORY_MESSAGES) == Policy.PRIORITY_CATEGORY_MESSAGES) { + return isPrioritySender(notificationPolicy.priorityMessageSenders, number); + } + } else if (priorityType == Policy.PRIORITY_CATEGORY_CALLS) { + if ((notificationPolicy.priorityCategories & Policy.PRIORITY_CATEGORY_CALLS) == Policy.PRIORITY_CATEGORY_CALLS) { + return isPrioritySender(notificationPolicy.priorityCallSenders, number); + } + } + return false; + } + + public static int getGrantedInterruptionFilter() { + if (prefs.getBoolean("notification_filter", false) && GBApplication.isRunningMarshmallowOrLater()) { + if (notificationManager.isNotificationPolicyAccessGranted()) { + return notificationManager.getCurrentInterruptionFilter(); + } + } + return NotificationManager.INTERRUPTION_FILTER_ALL; + } + public static HashSet blacklist = null; private static void loadBlackList() { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java index c8bfe8356..c6479695e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java @@ -6,6 +6,7 @@ import android.content.pm.ResolveInfo; import android.os.Bundle; import android.preference.ListPreference; import android.preference.Preference; +import android.preference.PreferenceCategory; import android.support.v4.content.LocalBroadcastManager; import android.widget.Toast; @@ -107,6 +108,12 @@ public class SettingsActivity extends AbstractSettingsActivity { }); + if (!GBApplication.isRunningMarshmallowOrLater()) { + pref = findPreference("notification_filter"); + PreferenceCategory category = (PreferenceCategory) findPreference("pref_key_notifications"); + category.removePreference(pref); + } + // Get all receivers of Media Buttons Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/K9Receiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/K9Receiver.java index 899ee0c6a..439c34b09 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/K9Receiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/K9Receiver.java @@ -1,5 +1,6 @@ package nodomain.freeyourgadget.gadgetbridge.externalevents; +import android.app.NotificationManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -33,6 +34,14 @@ public class K9Receiver extends BroadcastReceiver { return; } } + switch (GBApplication.getGrantedInterruptionFilter()) { + case NotificationManager.INTERRUPTION_FILTER_ALL: + break; + case NotificationManager.INTERRUPTION_FILTER_ALARMS: + case NotificationManager.INTERRUPTION_FILTER_NONE: + case NotificationManager.INTERRUPTION_FILTER_PRIORITY: + return; + } String uriWanted = intent.getData().toString(); 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 9f93618b2..a3c3d37c4 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java @@ -3,6 +3,7 @@ package nodomain.freeyourgadget.gadgetbridge.externalevents; import android.annotation.SuppressLint; import android.app.ActivityManager; import android.app.Notification; +import android.app.NotificationManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; @@ -167,6 +168,16 @@ public class NotificationListener extends NotificationListenerService { return; } } + switch (GBApplication.getGrantedInterruptionFilter()) { + case NotificationManager.INTERRUPTION_FILTER_ALL: + break; + case NotificationManager.INTERRUPTION_FILTER_ALARMS: + case NotificationManager.INTERRUPTION_FILTER_NONE: + return; + case NotificationManager.INTERRUPTION_FILTER_PRIORITY: + // FIXME: Handle Reminders and Events if they are enabled in Do Not Disturb + return; + } String source = sbn.getPackageName(); Notification notification = sbn.getNotification(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/PhoneCallReceiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/PhoneCallReceiver.java index 496872db3..29693538b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/PhoneCallReceiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/PhoneCallReceiver.java @@ -1,5 +1,7 @@ package nodomain.freeyourgadget.gadgetbridge.externalevents; +import android.app.NotificationManager; +import android.app.NotificationManager.Policy; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -67,6 +69,19 @@ public class PhoneCallReceiver extends BroadcastReceiver { if ("never".equals(prefs.getString("notification_mode_calls", "always"))) { return; } + switch (GBApplication.getGrantedInterruptionFilter()) { + case NotificationManager.INTERRUPTION_FILTER_ALL: + break; + case NotificationManager.INTERRUPTION_FILTER_ALARMS: + case NotificationManager.INTERRUPTION_FILTER_NONE: + return; + case NotificationManager.INTERRUPTION_FILTER_PRIORITY: + if (GBApplication.isPriorityNumber(Policy.PRIORITY_CATEGORY_CALLS, mSavedNumber)) { + break; + } + // FIXME: Handle Repeat callers if it is enabled in Do Not Disturb + return; + } CallSpec callSpec = new CallSpec(); callSpec.number = mSavedNumber; callSpec.command = callCommand; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/SMSReceiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/SMSReceiver.java index 0404cbc22..5df07c8d6 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/SMSReceiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/SMSReceiver.java @@ -1,5 +1,7 @@ package nodomain.freeyourgadget.gadgetbridge.externalevents; +import android.app.NotificationManager; +import android.app.NotificationManager.Policy; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -41,6 +43,18 @@ public class SMSReceiver extends BroadcastReceiver { notificationSpec.body = message.getDisplayMessageBody(); notificationSpec.phoneNumber = message.getOriginatingAddress(); if (notificationSpec.phoneNumber != null) { + switch (GBApplication.getGrantedInterruptionFilter()) { + case NotificationManager.INTERRUPTION_FILTER_ALL: + break; + case NotificationManager.INTERRUPTION_FILTER_ALARMS: + case NotificationManager.INTERRUPTION_FILTER_NONE: + return; + case NotificationManager.INTERRUPTION_FILTER_PRIORITY: + if (GBApplication.isPriorityNumber(Policy.PRIORITY_CATEGORY_MESSAGES, notificationSpec.phoneNumber)) { + break; + } + return; + } GBApplication.deviceService().onNotification(notificationSpec); } } diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 6dc1e3cc2..adf7da93a 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -69,8 +69,6 @@ Notificación de prueba desde Gadgetbridge Bluetooth no está soportado. Bluetooth está desactivado. - pulsa el dispositivo conectado para el Gestor de App - pulsa un dispositivo para conectar No se puede conectar. ¿Dirección BT incorrecta? Gadgetbridge funcionando instalando binario %1$d/%2$d @@ -101,13 +99,11 @@ No se han proporcionado datos de usuario válidos, se usarán datos de usuario por defecto. Cuando tu MiBand vibre y parpadee, púlsala repetidas veces. Instalar - Haz visible tu dispositivo. No es probable que se detecten los dispositivos que ya están conectados. Nota: Imagen del dispositivo Nombre/Apodo Número de vibraciones Monitor de sueño - Guardar logs iniciando Recuperando datos de actividad Desde %1$s a %2$s @@ -178,9 +174,9 @@ Pasos Actividad Pasos hoy, objetivo: %1$s + No confirmar transferencia Si los datos no son marcados como descargados, no serán borrados de tu MiBand. Útil si Gadgetbridge se usa conjuntamente con otras apps. Mantendrá los datos de actividad en la MiBand incluso después de la sincronización. Útil si GB se usa junto con otras apps. - No confirmar transferencia Historial de pasos Pasos/min actuales Pasos totales diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 4324f1f65..0ae83aa00 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -178,9 +178,9 @@ Pas Activité en direct Nombre de pas aujourd\'hui, objectif: %1$s + Ne pas confirmer le transfert de données d\'activités Les données d\'activités ne seront pas effacées du bracelet si elles ne sont pas confirmées. Utile si GB est utilisé avec d\'autres applications. Les données d\'activités seront conservées sur le Mi Band après la synchronisation. Utile si GB est utilisé avec d\'autres applications. - Ne pas confirmer le transfert de données d\'activités Historique de pas Pas/minute actuel Nombre total de pas diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 14f87afb0..3f1e31357 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -70,8 +70,6 @@ Notifica di prova creata da Gadgetbridge Bluetooth non supportato. Bluetooth disabilitato. - tocca il dispositivo connesso per gestire le App - tocca il dispositivo da connettere Impossibile connettersi. Indirizzo BT non valido? Gadgetbridge in esecuzione installazione del binario %1$d/%2$d @@ -102,13 +100,11 @@ Dati dell\'utente non inseriti, vengono usati dati d\'esempio. Quando la Mi Band vibra e lampeggia, dalle qualche leggero colpetto. Installa - Imposta il tuo dispositivo perchè sia rilevabile. I dispositivi attualmente connessi non saranno probabilmente rilevati. Nota: Immagine dispositivo Nome / Soprannome Numero vibrazioni Monitoraggio del sonno - Salva il log su file inizializzazione in corso Recupero dati attività Da %1$s a %2$s @@ -179,9 +175,9 @@ Passi Attività in tempo reale Passi di oggi, traguardo: %1$s + Non confermare il trasferimento dati Se il trasferimento non viene confermato, i dati rimangono memorizzati sulla Mi Band. Utile se GB è usato insieme ad altre app. Conserva i dati delle attività sulla Mi Band anche dopo averli sincronizzati. Utile se GB è usato insieme ad altre app. - Non confermare il trasferimento dati Storico dei passi Passi/minuto Passi totali diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index ddce42bca..2afb4a029 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -181,9 +181,9 @@ 걸음 수 실시간 활동 오늘 걸음 수, 목표: %1$s + 활동 데이터 전송을 확인하지 않음 만약 활동 데이터가 밴드에 확인되지 않았다면, 지워지지 않을 것입니다. 가젯브릿지가 다른 앱들과 같이 사용될 때 유용합니다. 동기화 이후에도 Mi Band의 활동 데이터가 유지될 것입니다. 가젯브릿지가 다른 앱들과 같이 사용될 때 유용합니다. - 활동 데이터 전송을 확인하지 않음 걸음 수 기록 현재의 분당 걸음 수 전체 걸음 수 @@ -224,4 +224,5 @@ 펌웨어가 전송되지 않음 심박수 심박수 + 자동으로 재연결 diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index f17487481..bc0929a38 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -67,8 +67,6 @@ To jest testowe powiadomienie z Gadgetbridge Bluetooth nie jest obsługiwane Bluetooth jest wyłączone - Kliknij podłączone urządzenia dla zarządzania aplikacjami - kliknij urządzenie by połączyć Nie można połączyć. Adres BT nieprawidłowy? Gadgetbridge działa Instalowanie binarki %1$d/%2$d @@ -99,13 +97,11 @@ Brak prawidłowych danych użytkownika, używam danych zastępczych na ten moment. Gdy twój Mi Band wibruje i błyska, stuknij go kilka razy pod rząd. instaluj - Uwidocznij swoje urządzenie. Aktualnie połączone urządzenia prawdopodobnie nie będą znalezione. Uwaga Obraz urządzenia Nazwisko/Pseudonim Liczba wibracji Monitor snu - Zapisuj logi Uruchamianie Pobieranie danych aktywności Od %1$s do %2$s @@ -176,9 +172,9 @@ Kroki Ostatnia aktywność Kroków dziś, cel: %1$s + Nie wysyłaj danych aktywności Gdy dane aktywności nie są przesłane na opaskę, wtedy nie będą usuwane. Przydatne gdy Gadgetbridge jest używany wraz z innymi aplikacjami Dane aktywności będą zachowane na Mi Band nawet po synchronizacji. Przydatne gdy Gadgetbridge jest używany z innymi aplikacjami. - Nie wysyłaj danych aktywności Historia kroków Aktualnie kroków/min Kroków łącznie diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 5039e880b..5ea805eba 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -68,8 +68,6 @@ Это тестовое уведомление от Gadgetbridge Bluetooth не поддерживается. Bluetooth отключён. - нажмите на подключённое устройство для App Manager - нажмите на устройство для соединения Не удалось соединиться. Неверен адрес BT? Gadgetbridge запущен установки бинарного файла %1$d/%2$d @@ -100,13 +98,11 @@ Не предоставлено действительных данных пользователя. Используются данные по-умолчанию. Когда ваш Mi Band вибрирует и мигает, постучите по нему несколько раз. Установить - Подключённые в настоящее время устройства, скорее всего, не будут обнаружены. Заметка: Изображение устройства Имя/псевдоним Количество вибраций Анализ сна - Записывать файлы журнала Инициализация Получение данных активности От %1$s до %2$s @@ -177,9 +173,9 @@ Шаги Жизненная активность Шагов сегодня, цель: %1$s + Не передавать данные об активности Если данные об активности не будут переданы на устройство, оно не будет очищено. Полезно, если GB используется с другими приложениями. Хранить данные о деятельности на Mi Band, даже после синхронизации. Полезно, если Mi Band используется совместно с другими приложениями. - Не передавать данные об активности История шагов Текущие шаги в минуту Всего шагов diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index f0d6f36a4..7f79179f6 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -31,6 +31,9 @@ Дата і час Синхронізувати час під час з\'єднання Синхронізувати час під час з\'єднання з пристроєм, а також під час зміни часу чи часової зони в системі + Тема + Світла + Темна Сповіщення Повтори Виклики @@ -67,8 +70,6 @@ Це тестове сповіщення від Gadgetbridge Bluetooth не підтримується. Bluetooth вимкнуто. - натисніть на під\'єднаний пристрій для App Manager - натисніть на пристрій для з\'єднання Не вдалося з\'єднатися. Можливо помилкова адреса BT? Gadgetbridge запущено встановлення бінарного файлу %1$d/%2$d @@ -99,13 +100,11 @@ Не отримано дійсних даних користувача. Використовуються типові дані. Коли ваш Mi—Band вібрує та блимає, постукайте по ньому кілька раз. Встановити - Під\'єднані на даний момент пристрої, скоріш за все не будуть виявлені. Замітка: Зображення пристрою Ім\'я/нік Кількість вібрацій Аналіз сну - Записувати файли звіту Ініціалізація… Отримання даних активності Від %1$s до %2$s @@ -176,9 +175,9 @@ Кроки Життєва активність Кроків сьогодні, мета: %1$s + Не передавати дані про активність Якщо дані не будуть передані на пристрій, пристрій не буде очищений. Корисно, якщо Gadgetbridge використовується разом з іншими додатками. Дозволяє лишити дані на Mi-браслеті після синхронізації. Зазвичай використовується, якщо GB працює ще з іншими додатками. - Не передавати дані про активність Історія кроків Поточні кроки/хв Загалом кроків diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index af3de63c3..f41f84780 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -52,8 +52,6 @@ Đây là một kiểm tra thông báo từ Gadgetbridge Không hỗ trợ Bluetooth. Đã tắt Bluetooth. - chạm vào thiết bị đã kết nối để chạy Trình quản lý ứng dụng - chạm vào một thiết bị để kết nối Không thể kết nối. Địa chỉ BT không hợp lệ? Gadgetbridge đang chạy đang cài phần mềm chạy %1$d/%2$d @@ -83,7 +81,6 @@ Ảnh thiết bị Tên/Bí danh Trình giám sát giấc ngủ - Ghi tập tin nhật ký đang khởi chạy Từ %1$s đến %2$s Đeo bên trái hay phải? diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 133216e52..95f0f1884 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -52,6 +52,8 @@ Support for applications which send Notifications to the Pebble via Intent. Can be used for Conversations. Generic notification support … also when screen is on + Do Not Disturb + Stop unwanted Notifications from being sent based on the Do Not Disturb mode. always when screen is off diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 4def8d019..6ae2be495 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -77,6 +77,13 @@ android:defaultValue="false" android:key="notifications_generic_whenscreenon" android:title="@string/pref_title_whenscreenon" /> + + +