Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
10 changes: 10 additions & 0 deletions src/main/java/com/b44t/messenger/DcAccounts.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,14 @@ public void unref() {
private native long getJsonrpcInstanceCPtr ();
private native long getAccountCPtr (int accountId);
private native long getSelectedAccountCPtr ();

public boolean isAllChatmail() {
for (int accountId : getAll()) {
DcContext dcContext = getAccount(accountId);
if (!dcContext.isChatmail()) {
return false;
}
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,9 @@ public static void dozeReminderTapped(Context context) {
}
}

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

private static boolean isPushAvailableAndSufficient() {
return isAllChatmail() && FcmReceiveService.getToken() != null;
return ApplicationContext.dcAccounts.isAllChatmail()
&& FcmReceiveService.getToken() != null;
}

public static void maybeAskDirectly(Context context) {
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
17 changes: 12 additions & 5 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 @@ -213,12 +215,17 @@ public static void setChatRingtone(Context context, int accountId, int chatId, U
}

public static boolean reliableService(Context context) {
try {
return getBooleanPreference(context, "pref_reliable_service", false);
}
catch(Exception e) {
return false;
final String key = "pref_reliable_service";
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (prefs.contains(key)) {
try {
return prefs.getBoolean(key, true);
} catch(Exception e) {}
}

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

// vibrate
Expand Down
Loading