Display an error if we cannot open picker instead of crashing.

fork-5.53.8
Alex Hart 2021-11-29 15:21:01 -04:00 zatwierdzone przez Greyson Parrelli
rodzic c0ac2176c1
commit e690e9bd69
2 zmienionych plików z 16 dodań i 4 usunięć

Wyświetl plik

@ -1,6 +1,7 @@
package org.thoughtcrime.securesms.components.settings.app.notifications
import android.app.Activity
import android.content.ActivityNotFoundException
import android.content.Intent
import android.graphics.ColorFilter
import android.graphics.PorterDuff
@ -10,6 +11,7 @@ import android.net.Uri
import android.provider.Settings
import android.text.TextUtils
import android.view.View
import android.widget.Toast
import androidx.annotation.RequiresApi
import androidx.core.content.ContextCompat
import androidx.lifecycle.ViewModelProvider
@ -241,7 +243,6 @@ class NotificationsSettingsFragment : DSLSettingsFragment(R.string.preferences__
}
}
@Suppress("DEPRECATION")
private fun launchMessageSoundSelectionIntent() {
val current = SignalStore.settings().messageNotificationSound
@ -255,7 +256,7 @@ class NotificationsSettingsFragment : DSLSettingsFragment(R.string.preferences__
)
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, current)
startActivityForResult(intent, MESSAGE_SOUND_SELECT)
openRingtonePicker(intent, MESSAGE_SOUND_SELECT)
}
@RequiresApi(26)
@ -269,7 +270,6 @@ class NotificationsSettingsFragment : DSLSettingsFragment(R.string.preferences__
startActivity(intent)
}
@Suppress("DEPRECATION")
private fun launchCallRingtoneSelectionIntent() {
val current = SignalStore.settings().callRingtone
@ -283,7 +283,16 @@ class NotificationsSettingsFragment : DSLSettingsFragment(R.string.preferences__
)
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, current)
startActivityForResult(intent, CALL_RINGTONE_SELECT)
openRingtonePicker(intent, CALL_RINGTONE_SELECT)
}
@Suppress("DEPRECATION")
private fun openRingtonePicker(intent: Intent, requestCode: Int) {
try {
startActivityForResult(intent, requestCode)
} catch (e: ActivityNotFoundException) {
Toast.makeText(requireContext(), R.string.NotificationSettingsFragment__failed_to_open_picker, Toast.LENGTH_LONG).show()
}
}
private class LedColorPreference(

Wyświetl plik

@ -4025,6 +4025,9 @@
<string name="Boost__thank_you_for_your_donation" translatable="false">Thank you for your donation. Your contribution helps fuel the mission of developing open source privacy technology that protects free expression and enables secure global communication for millions around the world. Signal Technology Foundation is a tax-exempt nonprofit organization in the United States under section 501c3 of the Internal Revenue Code. Our Federal Tax ID is 82-4506840. No goods or services were provided in exchange for this donation. Please retain this receipt for your tax records.</string>
<!-- Displayed in a toast when we fail to open the ringtone picker -->
<string name="NotificationSettingsFragment__failed_to_open_picker">Failed to open picker.</string>
<!-- EOF -->
</resources>