Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* drop too short disappearing messages options
* fix Direct Share shortcuts
* fix: don't show error message when cancelling profile creation
* enable permanent notification by default if push notifications are not available

## v2.11.0
2025-08
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme
private CheckBoxPreference ignoreBattery;
private CheckBoxPreference notificationsEnabled;
private CheckBoxPreference mentionNotifEnabled;
private CheckBoxPreference reliableService;

@Override
public void onCreate(Bundle paramBundle) {
Expand Down Expand Up @@ -85,7 +86,7 @@ public void onCreate(Bundle paramBundle) {
}


CheckBoxPreference reliableService = this.findPreference("pref_reliable_service");
reliableService = this.findPreference("pref_reliable_service");
if (reliableService != null) {
reliableService.setOnPreferenceChangeListener((preference, newValue) -> {
Context context = getContext();
Expand Down Expand Up @@ -132,6 +133,10 @@ public void onResume() {
ignoreBattery.setChecked(isIgnoringBatteryOptimizations());
notificationsEnabled.setChecked(!dcContext.isMuted());
mentionNotifEnabled.setChecked(dcContext.isMentionsEnabled());
if (Prefs.reliableService(getActivity())) {
// only alter the "unset" state of the preference if true
reliableService.setChecked(true);
}
}

@Override
Expand Down
31 changes: 28 additions & 3 deletions src/main/java/org/thoughtcrime/securesms/util/Prefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;

import com.b44t.messenger.DcAccounts;
import com.b44t.messenger.DcContext;

import org.thoughtcrime.securesms.BuildConfig;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.notifications.FcmReceiveService;
import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference;

import java.util.ArrayList;
Expand Down Expand Up @@ -212,13 +214,36 @@ public static void setChatRingtone(Context context, int accountId, int chatId, U
return result==null? null : Uri.parse(result);
}

private static boolean isAllChatmail(Context context) {
DcAccounts dcAccounts = DcHelper.getAccounts(context);
for (int accountId : dcAccounts.getAll()) {
DcContext dcContext = dcAccounts.getAccount(accountId);
if (!dcContext.isChatmail()) {
return false;
}
}
return true;
}

public static boolean reliableService(Context context) {
final String key = "pref_reliable_service";
boolean value = false;
try {
value = getBooleanPreference(context, key, false);
} catch(Exception e) {}
boolean value2;
try {
return getBooleanPreference(context, "pref_reliable_service", false);
value2 = getBooleanPreference(context, key, !value);
} catch(Exception e) {
value2 = !value;
}
catch(Exception e) {
return false;

// if the key was unset, then calculate default value
if (value != value2) {
value = FcmReceiveService.getToken() == null || !isAllChatmail(context);
}

return value;
}

// vibrate
Expand Down
Loading