From b0641a49c3b39958a43aa77aadcc86dec9fef19d Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sun, 10 May 2020 00:27:52 +0200 Subject: [PATCH 1/5] change default for 'reliable background service' to false reason is that ppl are pretty annoyed by the permanant notification, that might have been expected and that would be okay. but, more worse, for whatever reasons, this drains more battery on some systems than having just "allow consuming battery" enabled, maybe some system do not go to doze mode because of the permantent-notification. anyway, to avoid initial annoyances, we switch back to - asking the user to "allow consuming battery" - having a 15 mintues or so polling interval (as on iOS) but, in contrast to 1.3, we now still have the _option_ to enable a permantent-notification that user can enabled if everything else described at https://dontkillmyapp.com does not work. the "smart" permantent notification from 1.3, that are only shown under some circumstances, however, are gone. they are not realiable, eg. we did not use them when "consume battery" was enabled - which is not sufficient on various "modern" systems. but the main reason is that _if_ the user enables a permantent notification, this can also be regarded as a hint that things are up and running. --- res/xml/preferences_notifications.xml | 2 +- src/org/thoughtcrime/securesms/util/Prefs.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/res/xml/preferences_notifications.xml b/res/xml/preferences_notifications.xml index 976e142c1..d0e4c5af4 100644 --- a/res/xml/preferences_notifications.xml +++ b/res/xml/preferences_notifications.xml @@ -59,7 +59,7 @@ android:entryValues="@array/pref_notification_priority_values"/> diff --git a/src/org/thoughtcrime/securesms/util/Prefs.java b/src/org/thoughtcrime/securesms/util/Prefs.java index e1c1aa6e9..0c69a5602 100644 --- a/src/org/thoughtcrime/securesms/util/Prefs.java +++ b/src/org/thoughtcrime/securesms/util/Prefs.java @@ -236,7 +236,7 @@ public class Prefs { public static boolean reliableService(Context context) { try { - return getBooleanPreference(context, "pref_reliable_service", true); + return getBooleanPreference(context, "pref_reliable_service", false); } catch(Exception e) { return false; From d1690399cc287034ab9330402082b5051934adad Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sun, 10 May 2020 01:10:29 +0200 Subject: [PATCH 2/5] move permantent-notification switch more prominent, let it depend on notifications-enabled --- res/xml/preferences_notifications.xml | 13 +++++++------ .../securesms/LogViewFragment.java | 2 ++ .../securesms/connect/KeepAliveService.java | 2 +- .../NotificationsPreferenceFragment.java | 19 ++++++++++++++----- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/res/xml/preferences_notifications.xml b/res/xml/preferences_notifications.xml index d0e4c5af4..d451db047 100644 --- a/res/xml/preferences_notifications.xml +++ b/res/xml/preferences_notifications.xml @@ -7,6 +7,13 @@ android:title="@string/pref_notifications" android:defaultValue="true" /> + + - - diff --git a/src/org/thoughtcrime/securesms/LogViewFragment.java b/src/org/thoughtcrime/securesms/LogViewFragment.java index e4032b267..ba5e0b81f 100644 --- a/src/org/thoughtcrime/securesms/LogViewFragment.java +++ b/src/org/thoughtcrime/securesms/LogViewFragment.java @@ -241,6 +241,8 @@ public class LogViewFragment extends Fragment { builder.append("ignoreBatteryOptimizations=").append( powerManager.isIgnoringBatteryOptimizations(context.getPackageName())).append("\n"); } + builder.append("notifications=").append( + Prefs.isNotificationsEnabled(context)).append("\n"); builder.append("reliableService=").append( Prefs.reliableService(context)).append("\n"); } catch (Exception e) { diff --git a/src/org/thoughtcrime/securesms/connect/KeepAliveService.java b/src/org/thoughtcrime/securesms/connect/KeepAliveService.java index 7bbdda3fb..4a672dd6e 100644 --- a/src/org/thoughtcrime/securesms/connect/KeepAliveService.java +++ b/src/org/thoughtcrime/securesms/connect/KeepAliveService.java @@ -25,7 +25,7 @@ public class KeepAliveService extends Service { // note, that unfortunately, the check for isIgnoringBatteryOptimizations() is not sufficient, // this checks only stock-android settings, several os have additional "optimizers" that ignore this setting. // therefore, the most reliable way to not get killed is a permanent-foreground-notification. - if(Prefs.reliableService(context)) { + if (Prefs.isNotificationsEnabled(context) && Prefs.reliableService(context)) { startSelf(context); } } diff --git a/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java b/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java index f9c20b0bf..0b0a5e76b 100644 --- a/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java +++ b/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java @@ -71,14 +71,26 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme CheckBoxPreference reliableService = this.findPreference("pref_reliable_service"); reliableService.setOnPreferenceChangeListener((preference, newValue) -> { Context context = getContext(); - boolean enabled = (Boolean) newValue; - if (enabled) { + boolean enabled = (Boolean) newValue; // Prefs.reliableService() still has the old value + if (enabled && Prefs.isNotificationsEnabled(context)) { KeepAliveService.startSelf(context); } else { context.stopService(new Intent(context, KeepAliveService.class)); } return true; }); + + CheckBoxPreference notificationsEnabled = this.findPreference("pref_key_enable_notifications"); + notificationsEnabled.setOnPreferenceChangeListener((preference, newValue) -> { + Context context = getContext(); + boolean enabled = (Boolean) newValue; // Prefs.isNotificationsEnabled() still has the old value + if (enabled && Prefs.reliableService(context)) { + KeepAliveService.startSelf(context); + } else { + context.stopService(new Intent(context, KeepAliveService.class)); + } + return true; + }); } @Override @@ -137,9 +149,6 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme public static CharSequence getSummary(Context context) { boolean notificationsEnabled = Prefs.isNotificationsEnabled(context); String ret = context.getString(notificationsEnabled ? R.string.on : R.string.off); - if (notificationsEnabled && !Prefs.reliableService(context)) { - ret += ", " + context.getString(R.string.pref_reliable_service) + " " + context.getString(R.string.off); - } return ret; } From c0d74a0acf2e4ca1470961a3885a4c53cbd9ae68 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sun, 10 May 2020 01:32:34 +0200 Subject: [PATCH 3/5] show changed situation to 1.6 users --- res/values/strings.xml | 1 + .../securesms/ConversationListActivity.java | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 4516f5969..d803a4c9a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -693,6 +693,7 @@ You may already have noticed, that there is a hint \"Background connection enabled\" shown by the system.\n\nšŸ‘‰ The hint normally prevents the operating system from killing the connection between Delta Chat and your server.\n\nšŸ‘‰ If the hint disappears without any action on your part, the connection has probably been killed anyway.\nIf you think this is weird, we totally agree - but many manufacturers do exactly that. The site https://dontkillmyapp.com shows some workarounds.\n\nHowever, we are happy that we could improve the receiving of messages in background with this change and could fulfil the requests of many users - thanks for reporting šŸ¤— + You can now enable and disabled the \"Background connection\" as needed at \"Settings / Notifications\". diff --git a/src/org/thoughtcrime/securesms/ConversationListActivity.java b/src/org/thoughtcrime/securesms/ConversationListActivity.java index 0a4e063c6..3b31f9154 100644 --- a/src/org/thoughtcrime/securesms/ConversationListActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationListActivity.java @@ -84,14 +84,13 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit protected void onCreate(Bundle icicle, boolean ready) { ApplicationDcContext dcContext = DcHelper.getContext(this); - // show the permanent-notification hint above the welcome-messages (that is also visible in the preview) - // for existing installation, of course, that will be the last as the welcome-messages are added long time ago. - DcMsg msg = new DcMsg(dcContext, DcMsg.DC_MSG_TEXT); - msg.setText(getString(R.string.device_talk_background_connection_android)); - dcContext.addDeviceMsg("update1.6.0-h", msg); - // add welcome message dcContext.updateDeviceChats(); + if (dcContext.wasDeviceMsgEverAdded("update1.6.0-h")) { + DcMsg msg = new DcMsg(dcContext, DcMsg.DC_MSG_TEXT); + msg.setText(getString(R.string.device_talk_background_connection2_android)); + dcContext.addDeviceMsg("update1.8.0-a", msg); + } setContentView(R.layout.conversation_list_activity); From 0de50e08c710bd832b9af2b47a20a89bdff86c98 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sun, 10 May 2020 01:49:11 +0200 Subject: [PATCH 4/5] bump version --- CHANGELOG.md | 12 ++++++++++++ build.gradle | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf6d36e22..ea2975cc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Delta Chat Android Changelog +## v1.8.0 +2020-05-10 + +* by default, the permantent notification is no longer shown; + the background fetch realibility depends on the system and the + permantent notification can be enabled at "Settings / Notifications" as needed +* bug fixes +* update translations + + ## v1.6.2 2020-05-02 @@ -19,6 +29,8 @@ * new experimental feature that allows switching the account in use * improve interaction with traditional mail clients * improved onboarding when the provider returns a link +* to improve background fetch, show a permantent notification by default +* the permantent notification can be disabled at "Settins / Notifications" * bug fixes * add Indonesian and Persian translations, update other translations diff --git a/build.gradle b/build.gradle index bc8a73449..b7d8037fb 100644 --- a/build.gradle +++ b/build.gradle @@ -89,8 +89,8 @@ android { } defaultConfig { - versionCode 580 - versionName "1.7.0" + versionCode 581 + versionName "1.8.0" applicationId "com.b44t.messenger" multiDexEnabled true From 6bf4df0440b523be06554acb858942c3d08b95dc Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Mon, 11 May 2020 01:13:35 +0200 Subject: [PATCH 5/5] changelog --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea2975cc3..da18d5a2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,13 @@ # Delta Chat Android Changelog ## v1.8.0 -2020-05-10 +2020-05-11 * by default, the permantent notification is no longer shown; the background fetch realibility depends on the system and the permantent notification can be enabled at "Settings / Notifications" as needed -* bug fixes +* fix a bug that stops receiving messages under some circumstances +* more bug fixes * update translations