Fix various compiler warnings.

main
Cody Henthorne 2022-12-12 15:21:09 -05:00
rodzic 819c9f61dc
commit c5b4f44ab8
26 zmienionych plików z 48 dodań i 54 usunięć

Wyświetl plik

@ -51,6 +51,7 @@ private class AudioRecorderFocusManager26(context: Context, changeListener: OnAu
}
}
@Suppress("DEPRECATION")
private class AudioRecorderFocusManagerLegacy(context: Context, val changeListener: OnAudioFocusChangeListener) : AudioRecorderFocusManager(context) {
override fun requestAudioFocus(): Int {
return audioManager.requestAudioFocus(changeListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE)

Wyświetl plik

@ -30,6 +30,7 @@ class TextAvatarDrawable(
setBounds(0, 0, size, size)
}
@Suppress("DEPRECATION")
override fun draw(canvas: Canvas) {
val width = bounds.width()
val textSize = Avatars.getTextSizeForLength(context, avatar.text, width * 0.8f, width * 0.45f)

Wyświetl plik

@ -31,6 +31,7 @@ class GiftFlowActivity : FragmentWrapperActivity(), DonationPaymentComponent {
return NavHostFragment.create(R.navigation.gift_flow)
}
@Suppress("DEPRECATION")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
googlePayResultPublisher.onNext(DonationPaymentComponent.GooglePayResult(requestCode, resultCode, data))

Wyświetl plik

@ -122,6 +122,7 @@ class AppSettingsActivity : DSLSettingsActivity(), DonationPaymentComponent {
}
}
@Suppress("DEPRECATION")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
googlePayResultPublisher.onNext(DonationPaymentComponent.GooglePayResult(requestCode, resultCode, data))

Wyświetl plik

@ -344,7 +344,7 @@ class PrivacySettingsFragment : DSLSettingsFragment(R.string.preferences__privac
if (!ServiceUtil.getKeyguardManager(requireContext()).isKeyguardSecure) {
showGoToPhoneSettings()
} else if (state.paymentLock) {
biometricAuth.authenticate(requireContext(), true) { biometricDeviceLockLauncher?.launch(getString(R.string.BiometricDeviceAuthentication__signal)) }
biometricAuth.authenticate(requireContext(), true) { biometricDeviceLockLauncher.launch(getString(R.string.BiometricDeviceAuthentication__signal)) }
} else {
viewModel.togglePaymentLock(true)
}

Wyświetl plik

@ -29,7 +29,7 @@ class OneTimeDonationRepository(private val donationsService: DonationsService)
companion object {
private val TAG = Log.tag(OneTimeDonationRepository::class.java)
fun <T> handleCreatePaymentIntentError(throwable: Throwable, badgeRecipient: RecipientId, paymentSourceType: PaymentSourceType): Single<T> {
fun <T : Any> handleCreatePaymentIntentError(throwable: Throwable, badgeRecipient: RecipientId, paymentSourceType: PaymentSourceType): Single<T> {
return if (throwable is DonationError) {
Single.error(throwable)
} else {

Wyświetl plik

@ -23,6 +23,7 @@ class DonateToSignalActivity : FragmentWrapperActivity(), DonationPaymentCompone
return NavHostFragment.create(R.navigation.donate_to_signal, DonateToSignalFragmentArgs.Builder(DonateToSignalType.ONE_TIME).build().toBundle())
}
@Suppress("DEPRECATION")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
googlePayResultPublisher.onNext(DonationPaymentComponent.GooglePayResult(requestCode, resultCode, data))

Wyświetl plik

@ -84,7 +84,7 @@ class CreditCardFragment : Fragment(R.layout.credit_card_fragment) {
binding.cardNumber.addTextChangedListener(CreditCardTextWatcher())
binding.cardNumber.setOnFocusChangeListener { v, hasFocus ->
binding.cardNumber.setOnFocusChangeListener { _, hasFocus ->
viewModel.onNumberFocusChanged(hasFocus)
}
@ -92,7 +92,7 @@ class CreditCardFragment : Fragment(R.layout.credit_card_fragment) {
viewModel.onCodeChanged(it?.toString() ?: "")
})
binding.cardCvv.setOnFocusChangeListener { v, hasFocus ->
binding.cardCvv.setOnFocusChangeListener { _, hasFocus ->
viewModel.onCodeFocusChanged(hasFocus)
}
@ -111,7 +111,7 @@ class CreditCardFragment : Fragment(R.layout.credit_card_fragment) {
binding.cardExpiry.addTextChangedListener(CreditCardExpirationTextWatcher())
binding.cardExpiry.setOnFocusChangeListener { v, hasFocus ->
binding.cardExpiry.setOnFocusChangeListener { _, hasFocus ->
viewModel.onExpirationFocusChanged(hasFocus)
}

Wyświetl plik

@ -77,7 +77,7 @@ class ManageDonationsViewModel(
disposables += SubscriptionRedemptionJobWatcher.watch().subscribeBy { jobStateOptional ->
store.update { manageDonationsState ->
manageDonationsState.copy(
subscriptionRedemptionState = jobStateOptional.map { jobState ->
subscriptionRedemptionState = jobStateOptional.map { jobState: JobTracker.JobState ->
when (jobState) {
JobTracker.JobState.PENDING -> ManageDonationsState.SubscriptionRedemptionState.IN_PROGRESS
JobTracker.JobState.RUNNING -> ManageDonationsState.SubscriptionRedemptionState.IN_PROGRESS

Wyświetl plik

@ -57,6 +57,7 @@ open class ConversationActivity : PassphraseRequiredActivity(), ConversationPare
replaceFragment(intent!!)
}
@Suppress("DEPRECATION")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
googlePayResultPublisher.onNext(DonationPaymentComponent.GooglePayResult(requestCode, resultCode, data))

Wyświetl plik

@ -29,6 +29,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.color.ViewColorSet
import org.thoughtcrime.securesms.components.ContactFilterView
import org.thoughtcrime.securesms.components.TooltipPopup
import org.thoughtcrime.securesms.components.WrapperDialogFragment
@ -146,11 +147,9 @@ class MultiselectForwardFragment :
val sendButton: AppCompatImageView = bottomBar.findViewById(R.id.share_confirm)
val backgroundHelper: View = bottomBar.findViewById(R.id.background_helper)
val sendButtonColors = args.sendButtonColors
if (sendButtonColors != null) {
sendButton.setColorFilter(sendButtonColors.foreground.resolve(requireContext()))
ViewCompat.setBackgroundTintList(sendButton, ColorStateList.valueOf(sendButtonColors.background.resolve(requireContext())))
}
val sendButtonColors: ViewColorSet = args.sendButtonColors
sendButton.setColorFilter(sendButtonColors.foreground.resolve(requireContext()))
ViewCompat.setBackgroundTintList(sendButton, ColorStateList.valueOf(sendButtonColors.background.resolve(requireContext())))
FullscreenHelper.configureBottomBarLayout(requireActivity(), bottomBarSpacer, bottomBar)

Wyświetl plik

@ -2186,7 +2186,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
}
fun bulkUpdatedRegisteredStatus(registered: Map<RecipientId, ServiceId?>, unregistered: Collection<RecipientId>) {
writableDatabase.withinTransaction { db ->
writableDatabase.withinTransaction {
val registeredWithServiceId: Set<RecipientId> = getRegisteredWithServiceIds()
val needsMarkRegistered: Map<RecipientId, ServiceId?> = registered - registeredWithServiceId
@ -2855,7 +2855,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
operations += PnpOperation.ChangeNumberInsert(
recipientId = data.byAciSid,
oldE164 = data.aciSidRecord.e164,
newE164 = e164!!
newE164 = e164
)
}
} else {

Wyświetl plik

@ -15,6 +15,7 @@ import org.signal.core.util.delete
import org.signal.core.util.logging.Log
import org.signal.core.util.or
import org.signal.core.util.readToList
import org.signal.core.util.readToSingleLong
import org.signal.core.util.requireBoolean
import org.signal.core.util.requireInt
import org.signal.core.util.requireLong
@ -1072,13 +1073,7 @@ class ThreadTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTa
.from(TABLE_NAME)
.where("$RECIPIENT_ID = ?", recipientId)
.run()
.use { cursor ->
return if (cursor.moveToFirst()) {
cursor.requireLong(ID)
} else {
-1
}
}
.readToSingleLong(-1)
}
fun getOrCreateValidThreadId(recipient: Recipient, candidateId: Long): Long {

Wyświetl plik

@ -19,7 +19,7 @@ enum class StoryViewState {
companion object {
@JvmStatic
fun getForRecipientId(recipientId: RecipientId): Observable<StoryViewState> {
if (recipientId.equals(Recipient.self().id)) {
if (recipientId == Recipient.self().id) {
return Observable.fromCallable {
SignalDatabase.recipients.getDistributionListRecipientIds()
}.flatMap { ids ->
@ -27,7 +27,7 @@ enum class StoryViewState {
if (combined.isEmpty()) {
NONE
} else {
val results = combined.toList() as List<StoryViewState>
val results: List<StoryViewState> = combined.filterIsInstance<StoryViewState>()
when {
results.any { it == UNVIEWED } -> UNVIEWED
results.any { it == VIEWED } -> VIEWED

Wyświetl plik

@ -1,8 +1,8 @@
package org.thoughtcrime.securesms.exporter.flow
import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.activity.result.contract.ActivityResultContracts
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import org.signal.smsexporter.BecomeSmsAppFailure
@ -12,17 +12,20 @@ import org.thoughtcrime.securesms.databinding.SetSignalAsDefaultSmsAppFragmentBi
import org.thoughtcrime.securesms.util.navigation.safeNavigate
class SetSignalAsDefaultSmsAppFragment : Fragment(R.layout.set_signal_as_default_sms_app_fragment) {
companion object {
private const val REQUEST_CODE = 1
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val binding = SetSignalAsDefaultSmsAppFragmentBinding.bind(view)
val smsDefaultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
if (DefaultSmsHelper.isDefaultSms(requireContext())) {
navigateToExporter()
}
}
binding.continueButton.setOnClickListener {
DefaultSmsHelper.becomeDefaultSms(requireContext()).either(
onSuccess = {
startActivityForResult(it, REQUEST_CODE)
smsDefaultLauncher.launch(it)
},
onFailure = {
when (it) {
@ -34,12 +37,6 @@ class SetSignalAsDefaultSmsAppFragment : Fragment(R.layout.set_signal_as_default
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == REQUEST_CODE && DefaultSmsHelper.isDefaultSms(requireContext())) {
navigateToExporter()
}
}
private fun navigateToExporter() {
findNavController().safeNavigate(SetSignalAsDefaultSmsAppFragmentDirections.actionSetSignalAsDefaultSmsAppFragmentToExportingSmsMessagesFragment())
}

Wyświetl plik

@ -54,7 +54,7 @@ class StickerSearchDialogFragment : DialogFragment(), KeyboardStickerListAdapter
list.adapter = adapter
list.addItemDecoration(InsetItemDecoration(StickerInsetSetter()))
val viewModel: StickerSearchViewModel = ViewModelProvider(this, StickerSearchViewModel.Factory(requireContext())).get(StickerSearchViewModel::class.java)
val viewModel: StickerSearchViewModel = ViewModelProvider(this, StickerSearchViewModel.Factory()).get(StickerSearchViewModel::class.java)
viewModel.searchResults.observe(viewLifecycleOwner) { stickers ->
adapter.submitList(stickers)

Wyświetl plik

@ -1,6 +1,5 @@
package org.thoughtcrime.securesms.keyboard.sticker
import android.content.Context
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
@ -20,7 +19,7 @@ class StickerSearchViewModel(private val searchRepository: StickerSearchReposito
searchQuery.postValue(query)
}
class Factory(context: Context) : ViewModelProvider.Factory {
class Factory : ViewModelProvider.Factory {
val repository = StickerSearchRepository()
override fun <T : ViewModel> create(modelClass: Class<T>): T {

Wyświetl plik

@ -310,7 +310,7 @@ internal class AccountValues internal constructor(store: KeyValueStore) : Signal
}
if (previous && !registered) {
clearLocalCredentials(ApplicationDependencies.getApplication())
clearLocalCredentials()
}
}
@ -329,7 +329,7 @@ internal class AccountValues internal constructor(store: KeyValueStore) : Signal
val isLinkedDevice: Boolean
get() = !isPrimaryDevice
private fun clearLocalCredentials(context: Context) {
private fun clearLocalCredentials() {
putString(KEY_SERVICE_PASSWORD, Util.getSecret(18))
val newProfileKey = ProfileKeyUtil.createNew()

Wyświetl plik

@ -70,6 +70,7 @@ private class BooleanValue(private val key: String, private val default: Boolean
private class StringValue<T : String?>(private val key: String, private val default: T, store: KeyValueStore) : SignalStoreValueDelegate<T>(store) {
override fun getValue(values: KeyValueStore): T {
@Suppress("UNCHECKED_CAST")
return values.getString(key, default) as T
}

Wyświetl plik

@ -181,7 +181,7 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
when (currentState.loadState) {
MediaPreviewV2State.LoadState.DATA_LOADED -> bindDataLoadedState(currentState)
MediaPreviewV2State.LoadState.MEDIA_READY -> bindMediaReadyState(currentState)
else -> null
else -> Unit
}
}

Wyświetl plik

@ -99,7 +99,7 @@ data class NotificationConversation(
return notificationItems.any { it.isNewNotification }
}
fun getChannelId(context: Context): String {
fun getChannelId(): String {
return if (isOnlyContactJoinedEvent) {
NotificationChannels.getInstance().JOIN_EVENTS
} else {

Wyświetl plik

@ -188,7 +188,7 @@ object NotificationFactory {
setCategory(NotificationCompat.CATEGORY_MESSAGE)
setGroup(DefaultMessageNotifier.NOTIFICATION_GROUP)
setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN)
setChannelId(conversation.getChannelId(context))
setChannelId(conversation.getChannelId())
setContentTitle(conversation.getContentTitle(context))
setLargeIcon(conversation.getContactLargeIcon(context).toLargeBitmap(context))
addPerson(conversation.recipient)
@ -221,7 +221,7 @@ object NotificationFactory {
val notificationId: Int = if (Build.VERSION.SDK_INT < 24) NotificationIds.MESSAGE_SUMMARY else conversation.notificationId
NotificationManagerCompat.from(context).safelyNotify(context, conversation.recipient, notificationId, builder.build())
NotificationManagerCompat.from(context).safelyNotify(conversation.recipient, notificationId, builder.build())
}
private fun notifySummary(context: Context, state: NotificationState) {
@ -257,7 +257,7 @@ object NotificationFactory {
}
Log.d(TAG, "showing summary notification")
NotificationManagerCompat.from(context).safelyNotify(context, null, NotificationIds.MESSAGE_SUMMARY, builder.build())
NotificationManagerCompat.from(context).safelyNotify(null, NotificationIds.MESSAGE_SUMMARY, builder.build())
}
private fun notifyInThread(context: Context, recipient: Recipient, lastAudibleNotification: Long) {
@ -326,7 +326,7 @@ object NotificationFactory {
setChannelId(NotificationChannels.getInstance().FAILURES)
}
NotificationManagerCompat.from(context).safelyNotify(context, recipient, NotificationIds.getNotificationIdForMessageDeliveryFailed(thread), builder.build())
NotificationManagerCompat.from(context).safelyNotify(recipient, NotificationIds.getNotificationIdForMessageDeliveryFailed(thread), builder.build())
}
fun notifyProofRequired(context: Context, recipient: Recipient, thread: ConversationId, visibleThread: ConversationId?) {
@ -356,7 +356,7 @@ object NotificationFactory {
setChannelId(NotificationChannels.getInstance().FAILURES)
}
NotificationManagerCompat.from(context).safelyNotify(context, recipient, NotificationIds.getNotificationIdForMessageDeliveryFailed(thread), builder.build())
NotificationManagerCompat.from(context).safelyNotify(recipient, NotificationIds.getNotificationIdForMessageDeliveryFailed(thread), builder.build())
}
@JvmStatic
@ -379,7 +379,7 @@ object NotificationFactory {
setColor(ContextCompat.getColor(context, R.color.core_ultramarine))
setCategory(NotificationCompat.CATEGORY_MESSAGE)
setGroup(DefaultMessageNotifier.NOTIFICATION_GROUP)
setChannelId(conversation.getChannelId(context))
setChannelId(conversation.getChannelId())
setContentTitle(conversation.getContentTitle(context))
setLargeIcon(conversation.getContactLargeIcon(context).toLargeBitmap(context))
addPerson(conversation.recipient)
@ -390,10 +390,10 @@ object NotificationFactory {
}
Log.d(TAG, "Posting Notification for requested bubble")
NotificationManagerCompat.from(context).safelyNotify(context, recipient, conversation.notificationId, builder.build())
NotificationManagerCompat.from(context).safelyNotify(recipient, conversation.notificationId, builder.build())
}
private fun NotificationManagerCompat.safelyNotify(context: Context, threadRecipient: Recipient?, notificationId: Int, notification: Notification) {
private fun NotificationManagerCompat.safelyNotify(threadRecipient: Recipient?, notificationId: Int, notification: Notification) {
try {
notify(notificationId, notification)
Log.internal().i(TAG, "Posted notification: $notification")

Wyświetl plik

@ -231,9 +231,6 @@ class ImageEditorHudV2 @JvmOverloads constructor(
isAvatarEdit = true
}
fun setColorPalette(colors: Set<Int>) {
}
fun getActiveColor(): Int {
return if (currentMode == Mode.HIGHLIGHT) {
withHighlighterAlpha(drawSeekBar.getColor())

Wyświetl plik

@ -105,7 +105,7 @@ class StoriesLandingRepository(context: Context) {
Observable.just(emptyList())
} else {
Observable.combineLatest(observables) {
it.toList() as List<StoriesLandingItemData>
it.filterIsInstance<StoriesLandingItemData>()
}
}
}.subscribeOn(Schedulers.io())

Wyświetl plik

@ -158,7 +158,7 @@ open class StoryViewerPageRepository(context: Context, private val storyViewStat
if (posts.isEmpty()) {
Observable.just(emptyList())
} else {
Observable.combineLatest(posts) { it.toList() as List<StoryPost> }
Observable.combineLatest(posts) { it.filterIsInstance<StoryPost>() }
}
}.observeOn(Schedulers.io())
}

Wyświetl plik

@ -58,7 +58,7 @@ class SpinnerApplicationContext : ApplicationContext() {
"E164" to (SignalStore.account().e164 ?: "none"),
"ACI" to (SignalStore.account().aci?.toString() ?: "none"),
"PNI" to (SignalStore.account().pni?.toString() ?: "none"),
Spinner.KEY_ENVIRONMENT to BuildConfig.FLAVOR_environment.toUpperCase(Locale.US)
Spinner.KEY_ENVIRONMENT to BuildConfig.FLAVOR_environment.uppercase(Locale.US)
),
linkedMapOf(
"signal" to DatabaseConfig(