Merge remote-tracking branch 'origin/main'

This commit is contained in:
Hosted Weblate
2024-08-02 08:01:09 +00:00
7 changed files with 7 additions and 65 deletions
@@ -10,6 +10,5 @@ import androidx.annotation.Nullable;
public class FcmReceiveService {
public static void register(Context context) {}
public static void waitForRegisterFinished() {}
public static void deleteToken() {}
@Nullable public static String getToken() { return null; }
}
@@ -92,23 +92,6 @@ public class FcmReceiveService extends FirebaseMessagingService {
return prefixedToken;
}
public static void deleteToken() {
if (prefixedToken == null) {
Log.i(TAG, "FCM not registered yet, no token to delete");
return;
}
Util.runOnAnyBackgroundThread(() -> {
try {
Tasks.await(FirebaseMessaging.getInstance().deleteToken());
prefixedToken = null;
Log.i(TAG, "FCM token deleted for " + BuildConfig.APPLICATION_ID);
} catch (Exception e) {
Log.e(TAG, "cannot delete FCM token for " + BuildConfig.APPLICATION_ID + ": " + e);
}
});
}
@Override
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
Log.i(TAG, "FCM push notification received");
@@ -228,12 +228,8 @@ public class ApplicationContext extends MultiDexApplication {
fetchWorkRequest);
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
if (BuildConfig.USE_PLAY_SERVICES) {
if (Prefs.isPushEnabled(this)) {
FcmReceiveService.register(this);
} else {
Log.i(TAG, "FCM disabled in user settings");
}
if (Prefs.isPushEnabled(this)) {
FcmReceiveService.register(this);
} else {
Log.i(TAG, "FCM disabled at build time");
}
@@ -73,27 +73,6 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme
initializeRingtoneSummary(findPreference(Prefs.RINGTONE_PREF));
CheckBoxPreference usePushService = this.findPreference("pref_push_enabled");
usePushService.setChecked(Prefs.isPushEnabled(getContext()));
usePushService.setEnabled(BuildConfig.USE_PLAY_SERVICES);
usePushService.setOnPreferenceChangeListener((preference, newValue) -> {
final boolean enabled = (Boolean) newValue;
if (!enabled) {
new AlertDialog.Builder(getContext())
.setMessage(R.string.pref_push_ask_disable)
.setPositiveButton(R.string.ok, (dialogInterface, i) -> {
((CheckBoxPreference)preference).setChecked(false);
})
.setNegativeButton(R.string.cancel, null)
.setNeutralButton(R.string.learn_more, (dialogInterface, i) -> {
DcHelper.openHelp(getActivity(), "#instant-delivery");
})
.show();
return false;
}
return true;
});
ignoreBattery = this.findPreference("pref_ignore_battery_optimizations");
ignoreBattery.setVisible(needsIgnoreBatteryOptimizations());
ignoreBattery.setOnPreferenceChangeListener((preference, newValue) -> {
@@ -137,18 +116,6 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme
notificationsEnabled.setChecked(!dcContext.isMuted());
}
@Override
public void onPause() {
super.onPause();
// we delay applying token changes to avoid changes and races if the user is just playing around
if (Prefs.isPushEnabled(getContext()) && FcmReceiveService.getToken() == null) {
FcmReceiveService.register(getContext());
} else if(!Prefs.isPushEnabled(getContext()) && FcmReceiveService.getToken() != null) {
FcmReceiveService.deleteToken();
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
@@ -168,7 +168,7 @@ public class Prefs {
}
public static boolean isPushEnabled(Context context) {
return BuildConfig.USE_PLAY_SERVICES && getBooleanPreference(context, "pref_push_enabled", true);
return BuildConfig.USE_PLAY_SERVICES;
}
public static boolean isHardCompressionEnabled(Context context) {
+4 -1
View File
@@ -1146,11 +1146,14 @@
<!-- android specific strings, developers: please take care to remove strings that are no longer used! -->
<string name="pref_instant_delivery">Instant Delivery</string>
<!-- deprecated -->
<string name="pref_push_notifications">Use Push Service</string>
<!-- deprecated -->
<string name="pref_push_notifications_explain">Reliable Push Notifications for Chatmail-Servers</string>
<!-- deprecated -->
<string name="pref_push_ask_disable">Disable using Push Service?\n\nThis may result in delayed notifications.</string>
<string name="pref_background_notifications">Use Background Connection</string>
<string name="pref_background_notifications_explain">Requires ignored battery optimizations, use if Push Service is unavailable</string>
<string name="pref_background_notifications_explain">Requires ignored battery optimizations, use if notifications don\'t arrive on time</string>
<string name="pref_reliable_service">Force Background Connection</string>
<string name="pref_reliable_service_explain">Causes a permanent notification</string>
@@ -50,12 +50,6 @@
android:defaultValue="true" />
<PreferenceCategory android:title="@string/pref_instant_delivery">
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:key="pref_push_enabled"
android:defaultValue="true"
android:title="@string/pref_push_notifications"
android:summary="@string/pref_push_notifications_explain"/>
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:key="pref_ignore_battery_optimizations"
android:defaultValue="false"