mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Remove Settings / Notifications / Calls category #14
This commit is contained in:
@@ -71,30 +71,6 @@
|
||||
|
||||
<PreferenceCategory android:layout="@layout/preference_divider"/>
|
||||
|
||||
<PreferenceCategory android:title="@string/preferences_notifications__calls">
|
||||
|
||||
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
|
||||
android:key="pref_call_notifications"
|
||||
android:title="@string/preferences__notifications"
|
||||
android:defaultValue="true" />
|
||||
|
||||
<org.thoughtcrime.securesms.preferences.widgets.SignalPreference
|
||||
android:dependency="pref_call_notifications"
|
||||
android:key="pref_call_ringtone"
|
||||
android:title="@string/preferences_notifications__ringtone"
|
||||
android:persistent="false"
|
||||
android:defaultValue="content://settings/system/ringtone" />
|
||||
|
||||
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
|
||||
android:dependency="pref_call_notifications"
|
||||
android:key="pref_call_vibrate"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/preferences__vibrate"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:layout="@layout/preference_divider"/>
|
||||
|
||||
<PreferenceCategory android:title="@string/preferences_notifications__events">
|
||||
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
|
||||
android:key="pref_enable_new_contacts_notifications"
|
||||
|
||||
@@ -59,7 +59,6 @@ import org.thoughtcrime.securesms.preferences.widgets.ColorPickerPreference;
|
||||
import org.thoughtcrime.securesms.preferences.widgets.ContactPreference;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
|
||||
import org.thoughtcrime.securesms.service.WebRtcCallService;
|
||||
import org.thoughtcrime.securesms.util.CommunicationActions;
|
||||
import org.thoughtcrime.securesms.util.Dialogs;
|
||||
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
||||
@@ -438,10 +437,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
Uri value = (Uri)newValue;
|
||||
|
||||
Uri defaultValue;
|
||||
|
||||
if (calls) defaultValue = TextSecurePreferences.getCallNotificationRingtone(getContext());
|
||||
else defaultValue = TextSecurePreferences.getNotificationRingtone(getContext());
|
||||
Uri defaultValue = TextSecurePreferences.getNotificationRingtone(getContext());
|
||||
|
||||
if (defaultValue.equals(value)) value = null;
|
||||
else if (value == null) value = Uri.EMPTY;
|
||||
@@ -469,16 +465,8 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Uri current;
|
||||
Uri defaultUri;
|
||||
|
||||
if (calls) {
|
||||
current = recipient.getCallRingtone();
|
||||
defaultUri = TextSecurePreferences.getCallNotificationRingtone(getContext());
|
||||
} else {
|
||||
current = recipient.getMessageRingtone();
|
||||
defaultUri = TextSecurePreferences.getNotificationRingtone(getContext());
|
||||
}
|
||||
Uri current = recipient.getMessageRingtone();
|
||||
Uri defaultUri = TextSecurePreferences.getNotificationRingtone(getContext());
|
||||
|
||||
if (current == null) current = Settings.System.DEFAULT_NOTIFICATION_URI;
|
||||
else if (current.toString().isEmpty()) current = null;
|
||||
|
||||
@@ -16,11 +16,8 @@ import android.text.TextUtils;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.components.SwitchPreferenceCompat;
|
||||
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
||||
import org.thoughtcrime.securesms.preferences.widgets.SignalPreference;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
|
||||
@@ -45,8 +42,6 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme
|
||||
.setOnPreferenceChangeListener(new NotificationPrivacyListener());
|
||||
this.findPreference(TextSecurePreferences.NOTIFICATION_PRIORITY_PREF)
|
||||
.setOnPreferenceChangeListener(new ListSummaryListener());
|
||||
this.findPreference(TextSecurePreferences.CALL_RINGTONE_PREF)
|
||||
.setOnPreferenceChangeListener(new RingtoneSummaryListener());
|
||||
|
||||
this.findPreference(TextSecurePreferences.RINGTONE_PREF)
|
||||
.setOnPreferenceClickListener(preference -> {
|
||||
@@ -64,22 +59,6 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme
|
||||
return true;
|
||||
});
|
||||
|
||||
this.findPreference(TextSecurePreferences.CALL_RINGTONE_PREF)
|
||||
.setOnPreferenceClickListener(preference -> {
|
||||
Uri current = TextSecurePreferences.getCallNotificationRingtone(getContext());
|
||||
|
||||
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_RINGTONE);
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, Settings.System.DEFAULT_RINGTONE_URI);
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, current);
|
||||
|
||||
startActivityForResult(intent, 2);
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_COLOR_PREF));
|
||||
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_BLINK_PREF));
|
||||
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.REPEAT_ALERTS_PREF));
|
||||
@@ -87,8 +66,6 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme
|
||||
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.NOTIFICATION_PRIORITY_PREF));
|
||||
|
||||
initializeRingtoneSummary(findPreference(TextSecurePreferences.RINGTONE_PREF));
|
||||
initializeCallRingtoneSummary(findPreference(TextSecurePreferences.CALL_RINGTONE_PREF));
|
||||
initializeCallVibrateSummary((SwitchPreferenceCompat)findPreference(TextSecurePreferences.CALL_VIBRATE_PREF));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,16 +91,6 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme
|
||||
}
|
||||
|
||||
initializeRingtoneSummary(findPreference(TextSecurePreferences.RINGTONE_PREF));
|
||||
} else if (requestCode == 2 && resultCode == RESULT_OK && data != null) {
|
||||
Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
||||
|
||||
if (Settings.System.DEFAULT_RINGTONE_URI.equals(uri)) {
|
||||
TextSecurePreferences.removeCallNotificationRingtone(getContext());
|
||||
} else {
|
||||
TextSecurePreferences.setCallNotificationRingtone(getContext(), uri != null ? uri.toString() : Uri.EMPTY.toString());
|
||||
}
|
||||
|
||||
initializeCallRingtoneSummary(findPreference(TextSecurePreferences.CALL_RINGTONE_PREF));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,17 +120,6 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme
|
||||
listener.onPreferenceChange(pref, uri);
|
||||
}
|
||||
|
||||
private void initializeCallRingtoneSummary(Preference pref) {
|
||||
RingtoneSummaryListener listener = (RingtoneSummaryListener) pref.getOnPreferenceChangeListener();
|
||||
Uri uri = TextSecurePreferences.getCallNotificationRingtone(getContext());
|
||||
|
||||
listener.onPreferenceChange(pref, uri);
|
||||
}
|
||||
|
||||
private void initializeCallVibrateSummary(SwitchPreferenceCompat pref) {
|
||||
pref.setChecked(TextSecurePreferences.isCallNotificationVibrateEnabled(getContext()));
|
||||
}
|
||||
|
||||
public static CharSequence getSummary(Context context) {
|
||||
final int onCapsResId = R.string.ApplicationPreferencesActivity_On;
|
||||
final int offCapsResId = R.string.ApplicationPreferencesActivity_Off;
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.media.AudioManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -30,7 +29,6 @@ import org.thoughtcrime.securesms.WebRtcCallActivity;
|
||||
import org.thoughtcrime.securesms.contacts.ContactAccessor;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.VibrateState;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.events.WebRtcViewModel;
|
||||
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
||||
@@ -39,7 +37,6 @@ import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.FutureTaskListener;
|
||||
import org.thoughtcrime.securesms.util.ListenableFutureTask;
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.webrtc.CallNotificationBuilder;
|
||||
import org.thoughtcrime.securesms.webrtc.CameraState;
|
||||
@@ -565,15 +562,6 @@ public class WebRtcCallService extends Service implements InjectableType,
|
||||
startCallCardActivity();
|
||||
audioManager.initializeAudioForCall();
|
||||
|
||||
if (TextSecurePreferences.isCallNotificationsEnabled(this)) {
|
||||
Uri ringtone = recipient.resolve().getCallRingtone();
|
||||
VibrateState vibrateState = recipient.resolve().getCallVibrate();
|
||||
|
||||
if (ringtone == null) ringtone = TextSecurePreferences.getCallNotificationRingtone(this);
|
||||
|
||||
audioManager.startIncomingRinger(ringtone, vibrateState == VibrateState.ENABLED || (vibrateState == VibrateState.DEFAULT && TextSecurePreferences.isCallNotificationVibrateEnabled(this)));
|
||||
}
|
||||
|
||||
registerPowerButtonReceiver();
|
||||
|
||||
setCallInProgressNotification(TYPE_INCOMING_RINGING, recipient);
|
||||
|
||||
@@ -120,10 +120,6 @@ public class TextSecurePreferences {
|
||||
private static final String ATTACHMENT_UNENCRYPTED_SECRET = "pref_attachment_unencrypted_secret";
|
||||
private static final String NEEDS_SQLCIPHER_MIGRATION = "pref_needs_sql_cipher_migration";
|
||||
|
||||
public static final String CALL_NOTIFICATIONS_PREF = "pref_call_notifications";
|
||||
public static final String CALL_RINGTONE_PREF = "pref_call_ringtone";
|
||||
public static final String CALL_VIBRATE_PREF = "pref_call_vibrate";
|
||||
|
||||
private static final String NEXT_PRE_KEY_ID = "pref_next_pre_key_id";
|
||||
private static final String ACTIVE_SIGNED_PRE_KEY_ID = "pref_active_signed_pre_key_id";
|
||||
private static final String NEXT_SIGNED_PRE_KEY_ID = "pref_next_signed_pre_key_id";
|
||||
@@ -726,10 +722,6 @@ public class TextSecurePreferences {
|
||||
return getBooleanPreference(context, NOTIFICATION_PREF, true);
|
||||
}
|
||||
|
||||
public static boolean isCallNotificationsEnabled(Context context) {
|
||||
return getBooleanPreference(context, CALL_NOTIFICATIONS_PREF, true);
|
||||
}
|
||||
|
||||
public static @NonNull Uri getNotificationRingtone(Context context) {
|
||||
String result = getStringPreference(context, RINGTONE_PREF, Settings.System.DEFAULT_NOTIFICATION_URI.toString());
|
||||
|
||||
@@ -740,46 +732,18 @@ public class TextSecurePreferences {
|
||||
return Uri.parse(result);
|
||||
}
|
||||
|
||||
public static @NonNull Uri getCallNotificationRingtone(Context context) {
|
||||
String result = getStringPreference(context, CALL_RINGTONE_PREF, Settings.System.DEFAULT_RINGTONE_URI.toString());
|
||||
|
||||
if (result != null && result.startsWith("file:")) {
|
||||
result = Settings.System.DEFAULT_RINGTONE_URI.toString();
|
||||
}
|
||||
|
||||
return Uri.parse(result);
|
||||
}
|
||||
|
||||
public static void removeNotificationRingtone(Context context) {
|
||||
removePreference(context, RINGTONE_PREF);
|
||||
}
|
||||
|
||||
public static void removeCallNotificationRingtone(Context context) {
|
||||
removePreference(context, CALL_RINGTONE_PREF);
|
||||
}
|
||||
|
||||
public static void setNotificationRingtone(Context context, String ringtone) {
|
||||
setStringPreference(context, RINGTONE_PREF, ringtone);
|
||||
}
|
||||
|
||||
public static void setCallNotificationRingtone(Context context, String ringtone) {
|
||||
setStringPreference(context, CALL_RINGTONE_PREF, ringtone);
|
||||
}
|
||||
|
||||
public static boolean isNotificationVibrateEnabled(Context context) {
|
||||
return getBooleanPreference(context, VIBRATE_PREF, true);
|
||||
}
|
||||
|
||||
public static boolean isCallNotificationVibrateEnabled(Context context) {
|
||||
boolean defaultValue = true;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
defaultValue = (Settings.System.getInt(context.getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, 1) == 1);
|
||||
}
|
||||
|
||||
return getBooleanPreference(context, CALL_VIBRATE_PREF, defaultValue);
|
||||
}
|
||||
|
||||
public static String getNotificationLedColor(Context context) {
|
||||
return getStringPreference(context, LED_COLOR_PREF, "blue");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user