From d9a8cbb0d7514d66d7d14d27ee70982bfeb00d80 Mon Sep 17 00:00:00 2001 From: Catfriend1 Date: Wed, 22 Aug 2018 22:50:23 +0200 Subject: [PATCH] Better default prefs and crash detection Move pref "use_root" to behaviour category (#23) Always show notification if syncthing binary crashed fixes #https://github.com/Catfriend1/syncthing-android/issues/17 fixes #https://github.com/syncthing/syncthing-android/issues/1172 fixes #https://github.com/syncthing/syncthing-android/issues/1220 --- .../service/NotificationHandler.java | 22 +++++++++---------- .../service/SyncthingRunnable.java | 2 +- .../service/SyncthingService.java | 2 +- app/src/main/res/values-ca-rES/strings.xml | 2 -- app/src/main/res/values-cs/strings.xml | 2 -- app/src/main/res/values-da/strings.xml | 2 -- app/src/main/res/values-de/strings.xml | 4 +--- app/src/main/res/values-el/strings.xml | 2 -- app/src/main/res/values-es/strings.xml | 2 -- app/src/main/res/values-fi/strings.xml | 2 -- app/src/main/res/values-fr/strings.xml | 2 -- app/src/main/res/values-hu/strings.xml | 2 -- app/src/main/res/values-in/strings.xml | 2 -- app/src/main/res/values-it/strings.xml | 2 -- app/src/main/res/values-ja/strings.xml | 2 -- app/src/main/res/values-ko/strings.xml | 2 -- app/src/main/res/values-nl/strings.xml | 2 -- app/src/main/res/values-pl/strings.xml | 2 -- app/src/main/res/values-pt-rBR/strings.xml | 2 -- app/src/main/res/values-ro/strings.xml | 2 -- app/src/main/res/values-ru/strings.xml | 2 -- app/src/main/res/values-sv/strings.xml | 2 -- app/src/main/res/values-uk/strings.xml | 1 - app/src/main/res/values-zh-rCN/strings.xml | 2 -- app/src/main/res/values-zh-rTW/strings.xml | 2 -- app/src/main/res/values/strings.xml | 7 +----- app/src/main/res/xml/app_settings.xml | 17 +++++--------- 27 files changed, 20 insertions(+), 75 deletions(-) diff --git a/app/src/main/java/com/nutomic/syncthingandroid/service/NotificationHandler.java b/app/src/main/java/com/nutomic/syncthingandroid/service/NotificationHandler.java index 88e98258..7782f778 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/service/NotificationHandler.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/service/NotificationHandler.java @@ -168,18 +168,16 @@ public class NotificationHandler { mNotificationManager.cancel(ID_PERSISTENT_WAITING); } - public void showCrashedNotification(@StringRes int title, boolean force) { - if (force || mPreferences.getBoolean("notify_crashes", false)) { - Intent intent = new Intent(mContext, LogActivity.class); - Notification n = getNotificationBuilder(mInfoChannel) - .setContentTitle(mContext.getString(title)) - .setContentText(mContext.getString(R.string.notification_crash_text)) - .setSmallIcon(R.drawable.ic_stat_notify) - .setContentIntent(PendingIntent.getActivity(mContext, 0, intent, 0)) - .setAutoCancel(true) - .build(); - mNotificationManager.notify(ID_CRASH, n); - } + public void showCrashedNotification(@StringRes int title) { + Intent intent = new Intent(mContext, LogActivity.class); + Notification n = getNotificationBuilder(mInfoChannel) + .setContentTitle(mContext.getString(title)) + .setContentText(mContext.getString(R.string.notification_crash_text)) + .setSmallIcon(R.drawable.ic_stat_notify) + .setContentIntent(PendingIntent.getActivity(mContext, 0, intent, 0)) + .setAutoCancel(true) + .build(); + mNotificationManager.notify(ID_CRASH, n); } /** diff --git a/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingRunnable.java b/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingRunnable.java index bb09db6c..fc1aa1f2 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingRunnable.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingRunnable.java @@ -185,7 +185,7 @@ public class SyncthingRunnable implements Runnable { break; default: Log.w(TAG, "Syncthing has crashed (exit code " + ret + ")"); - mNotificationHandler.showCrashedNotification(R.string.notification_crash_title, false); + mNotificationHandler.showCrashedNotification(R.string.notification_crash_title); } } catch (IOException | InterruptedException e) { Log.e(TAG, "Failed to execute syncthing binary or read output", e); diff --git a/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java b/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java index 1d893160..3cf03707 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java @@ -337,7 +337,7 @@ public class SyncthingService extends Service { syncthingService.mConfig = new ConfigXml(syncthingService); syncthingService.mConfig.updateIfNeeded(); } catch (ConfigXml.OpenConfigException e) { - syncthingService.mNotificationHandler.showCrashedNotification(R.string.config_read_failed, true); + syncthingService.mNotificationHandler.showCrashedNotification(R.string.config_read_failed); synchronized (syncthingService.mStateLock) { syncthingService.onServiceStateChange(State.ERROR); } diff --git a/app/src/main/res/values-ca-rES/strings.xml b/app/src/main/res/values-ca-rES/strings.xml index c3af30c5..3aa36a6c 100644 --- a/app/src/main/res/values-ca-rES/strings.xml +++ b/app/src/main/res/values-ca-rES/strings.xml @@ -266,8 +266,6 @@ Ens podeu informar dels problemes que trobeu a través de Github. Obre el registre Obre la finestra de registre del Syncthing i de l\'Android - Notifica els bloquejos del Syncthing - Mostra una notificació si es detecta que el Syncthing s\'ha bloquejat Informeu d\'un problema diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 3147e181..9822bc7b 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -239,8 +239,6 @@ Všechny zaznamenané chyby prosím hlašte přes Github. Otevřít log Otevřít okno logu pro Syncthing a Android - Upozornit na pády Syncthing - Zobraz upozornění pokaždé, kdy je zaznamenán pád Syncthing Nahlásit chybu diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index c31cc655..303a4607 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -236,8 +236,6 @@ Vær venlig at rapportere ethvert problem, du støder på, via Github. Åben Log Åben Syncthing\'s og Android\'s log vindue - Underret om Syncthing crashes - Vis en notifikation hver gang et Syncthing crash bliver opdaget Rapporter problem diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index f8700b49..94fe2678 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -184,7 +184,7 @@ Bitte melden Sie auftretende Probleme via GitHub. Erweiterte Verzeichnisauswahl benutzen Alle Verzeichnisse auf dem Gerät für Synchronisation auswählbar Syncthing mit Superuser Rechten ausführen - Dies ist eine instabile Funktion, welche Probleme mit Syncthing und deinem Gerät verursachen könnte. Wenn du Probleme feststellst, musst du Syncthing möglicherweise neu installieren. + Wenn Syncthing unter dem Root-Benutzer ausgeführt wird, hat es Schreibzugriff auf Ordner, die Android normalerweise auf schreibgeschützten Zugriff beschränkt. Verwende diese Funktion mit Bedacht. Permanente Benachrichtigung Wähle die Art der Benachrichtigung @@ -282,8 +282,6 @@ Bitte melden Sie auftretende Probleme via GitHub. Log öffnen Öffne das Syncthing und Android Log Fenster - Syncthing Abstürze benachrichtigen - Benachrichtigung anzeigen wenn ein Syncthing Absturz erkannt wurde Fehler melden diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 8945ea08..99b30bd1 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -236,8 +236,6 @@ Άνοιγμα καταγραφής συμβάντων Άνοιγμα του παραθύρου καταγραφής συμβάντων του Syncthing και Android - Ειδοποίηση για καταρρεύσεις του Syncthing - Να εμφανίζεται μια ειδοποίηση όποτε ανιχνεύεται κατάρρευση του Syncthing Αναφορά προβλήματος diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 7963fbde..92ee7396 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -214,8 +214,6 @@ Abrir registro Abrir ventana de registro de Syncthing y Android - Notificar sobre los accidentes de Syncthing - Mostrar una notificación cada vez que se detecta un bloqueo de Syncthing Informar de un problema diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index 059df4ea..ffd8fc04 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -219,8 +219,6 @@ Ilmoitathan ystävällisesti kaikista havaitsemistasi ongelmista Githubin kautta Avaa loki Avaa Syncthingin ja Androidin loki-ikkuna - Ilmoita Syncthingin kaatumisista - Näytä ilmoitus kun Syncthingin kaatuminen havaitaan Ilmoita ongelmasta diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index c7d04d2d..495e5e35 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -267,8 +267,6 @@ S\'il vous plaît, soumettez les problèmes que vous rencontrez via Github.Ouvrir le journal Ouvre la fenêtre du journal de Syncthing et Android - Prévenir quand Syncthing se plante - Affiche une notification quand un plantage de Syncthing est détecté. Signaler un problème diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 47672849..ced4151b 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -270,8 +270,6 @@ VIGYÁZAT! Más alkalmazások kiolvashatják a backupból a titkos kulcsot, és Napló megnyitása A Syncthing és az Android naplók megnyitása - Értesítés a Syncthing összeomlásáról - Megjelenít egy értesítést, amennyiben a Syncthing összeomlik Hibabejelentés diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index 79f60052..be3f0162 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -223,8 +223,6 @@ Jika ada masalah silakan laporkan lewat Github. Buka Log Buat jendela log Syncthing dan Android - Beritahu jika aplikasi Syncthing mati - Tampilkan notifikasi jika kegagalan Syncthing ditemukan Laporkan Masalah diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 4ccfa2ec..2a6267bd 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -267,8 +267,6 @@ Si prega di segnalare eventuali problemi che si incontrano via Github. Apri Registro Apre la finestra di log di Syncthing e Android - Notifica i crash di Syncthing - Mostra una notifica ogni volta che viene rilevato un crash di Syncthing Segnala Problema diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 92926fd1..2bd467e7 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -236,8 +236,6 @@ ログを開く Syncthing と Android のログウインドウを開く - Syncthing のクラッシュを通知 - Syncthing のクラッシュを検知した時に通知を表示します 問題を報告 diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index a20f5e15..157aab0e 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -235,8 +235,6 @@ 로그 열기 Syncthing 및 Android 로그 윈도우 열기 - Syncthing 충돌에 대해 알려주기 - Syncthing 충돌이 감지 되었을 때 알림을 보여줍니다 문제 보고 diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 52294e3a..377c44b6 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -267,8 +267,6 @@ Als je problemen tegenkomt, meld ze dan via GitHub. Log openen Open het Syncthing- en Android-logvenster - Toon melding wanneer Syncthing crasht - Toon een melding wanneer een crash van Syncthing wordt gedetecteerd Probleem rapporteren diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 75cd208b..d1943494 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -234,8 +234,6 @@ Proszę zgłaszać napotkane błędy programu za pośrednictwem serwisu Github.< Otwórz dziennik Wyświetla dzienniki Syncthing oraz Androida - Powiadamiaj o awariach Syncthing - Powiadamiaj za każdym razem, kiedy wykryta zostanie awaria Syncthing Zgłoś błąd diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index d14ce75e..d3740b2d 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -258,8 +258,6 @@ Por favor, nos avise sobre quaisquer problemas que você encontrar via Github.Abrir log Abrir a janela de log do Syncthing e do Android - Notificar sobre as falhas do Syncthing - Exibir uma notificação quando uma falha no Syncthing for detectada Reportar problema diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index d6269c3c..3f3d3eef 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -286,8 +286,6 @@ Vă rugăm să raportați orice problemă întâlniți, prin intermediul GitHub. Deschide jurnal de erori Deschide fereastra de jurnal de erori Syncthing și Android - Notifică despre opririle neașteptate ale Syncthing - Arată o notificare de fiecare dată când Syncthing s-a oprit pe neașteptate Raportează problemă diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 00105f95..8f5ae5ca 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -267,8 +267,6 @@ Открыть лог Открывает логи Syncthing и Android - Сообщать о сбоях Syncthing - Показывать уведомлениепри обнаружении сбоев Syncthing Сообщить о проблеме diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 45da3a9f..34d67d5c 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -284,8 +284,6 @@ Vänligen rapportera eventuella problem du stöter på via Github. Öppna logg Öppna loggfönstret för Syncthing och Android - Meddela om Syncthing kraschar - Visa en avisering när en Syncthing krasch detekteras Rapportera problem diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 38e131e6..b678f335 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -188,7 +188,6 @@ Відкрити журнал - Повідомляти про аварійні завершення роботи Syncthing Повідомити про проблему diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 26574b2b..2c0cca7d 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -238,8 +238,6 @@ 打开日志 打开 Syncthing 与 Android 系统日志窗口 - 通知 Syncthing 崩溃 - 当检查到 Syncthing 崩溃时显示通知 回报问题 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 8ff471df..689c1e9e 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -235,8 +235,6 @@ 打開日誌 開啟 Syncthing 及 Android 日誌視窗 - 通知關於 Syncthing 當機 - 當偵測到 Syncthing 當機,顯示通知 回報問題 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e81c05c8..7e806593 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -353,7 +353,7 @@ Please report any problems you encounter via Github. Run Syncthing as Superuser - This is an unstable feature that may cause problems with Syncthing and with your device. If you encounter problems, you may have to reinstall Syncthing. + Running Syncthing as root allows it to write to folders Android normally restricts to be readonly accessed. Use this feature cautious. Notification @@ -516,11 +516,6 @@ Please report any problems you encounter via Github. Open the Syncthing and Android log window - - Notify about Syncthing crashes - - Show a notification whenever a Syncthing crash is detected - Report Issue diff --git a/app/src/main/res/xml/app_settings.xml b/app/src/main/res/xml/app_settings.xml index c9602971..7f813f20 100644 --- a/app/src/main/res/xml/app_settings.xml +++ b/app/src/main/res/xml/app_settings.xml @@ -67,6 +67,12 @@ android:key="category_behaviour" android:title="@string/category_behaviour"> + + - - @@ -241,12 +242,6 @@ android:title="@string/category_experimental" android:key="category_experimental"> - -