remove push notifications toggle

This commit is contained in:
adbenitez 2024-08-01 11:49:17 +02:00
parent 8e802e1062
commit 3e72837688
4 changed files with 3 additions and 46 deletions

View file

@ -228,12 +228,8 @@ public class ApplicationContext extends MultiDexApplication {
fetchWorkRequest); fetchWorkRequest);
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
if (BuildConfig.USE_PLAY_SERVICES) { if (Prefs.isPushEnabled(this)) {
if (Prefs.isPushEnabled(this)) { FcmReceiveService.register(this);
FcmReceiveService.register(this);
} else {
Log.i(TAG, "FCM disabled in user settings");
}
} else { } else {
Log.i(TAG, "FCM disabled at build time"); Log.i(TAG, "FCM disabled at build time");
} }

View file

@ -73,27 +73,6 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme
initializeRingtoneSummary(findPreference(Prefs.RINGTONE_PREF)); 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 = this.findPreference("pref_ignore_battery_optimizations");
ignoreBattery.setVisible(needsIgnoreBatteryOptimizations()); ignoreBattery.setVisible(needsIgnoreBatteryOptimizations());
ignoreBattery.setOnPreferenceChangeListener((preference, newValue) -> { ignoreBattery.setOnPreferenceChangeListener((preference, newValue) -> {
@ -137,18 +116,6 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme
notificationsEnabled.setChecked(!dcContext.isMuted()); 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 @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);

View file

@ -168,7 +168,7 @@ public class Prefs {
} }
public static boolean isPushEnabled(Context context) { 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) { public static boolean isHardCompressionEnabled(Context context) {

View file

@ -50,12 +50,6 @@
android:defaultValue="true" /> android:defaultValue="true" />
<PreferenceCategory android:title="@string/pref_instant_delivery"> <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 <org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:key="pref_ignore_battery_optimizations" android:key="pref_ignore_battery_optimizations"
android:defaultValue="false" android:defaultValue="false"