Goooler 2023-03-02 04:06:55 +08:00 committed by GitHub
parent ed188783de
commit ca29ee2b0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 17 additions and 17 deletions

View file

@ -114,7 +114,7 @@ class AccountsInListFragment : DialogFragment(), Injectable {
binding.searchView.isSubmitButtonEnabled = true binding.searchView.isSubmitButtonEnabled = true
binding.searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener { binding.searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String?): Boolean { override fun onQueryTextSubmit(query: String?): Boolean {
viewModel.search(query ?: "") viewModel.search(query.orEmpty())
return true return true
} }

View file

@ -136,7 +136,7 @@ class EditProfileActivity : BaseActivity(), Injectable {
binding.noteEditText.setText(me.source?.note) binding.noteEditText.setText(me.source?.note)
binding.lockedCheckBox.isChecked = me.locked binding.lockedCheckBox.isChecked = me.locked
accountFieldEditAdapter.setFields(me.source?.fields ?: emptyList()) accountFieldEditAdapter.setFields(me.source?.fields.orEmpty())
binding.addFieldButton.isVisible = binding.addFieldButton.isVisible =
(me.source?.fields?.size ?: 0) < maxAccountFields (me.source?.fields?.size ?: 0) < maxAccountFields

View file

@ -463,8 +463,8 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide
val emojifiedNote = account.note.parseAsMastodonHtml().emojify(account.emojis, binding.accountNoteTextView, animateEmojis) val emojifiedNote = account.note.parseAsMastodonHtml().emojify(account.emojis, binding.accountNoteTextView, animateEmojis)
setClickableText(binding.accountNoteTextView, emojifiedNote, emptyList(), null, this) setClickableText(binding.accountNoteTextView, emojifiedNote, emptyList(), null, this)
accountFieldAdapter.fields = account.fields ?: emptyList() accountFieldAdapter.fields = account.fields.orEmpty()
accountFieldAdapter.emojis = account.emojis ?: emptyList() accountFieldAdapter.emojis = account.emojis.orEmpty()
accountFieldAdapter.notifyDataSetChanged() accountFieldAdapter.notifyDataSetChanged()
binding.accountLockedImageView.visible(account.locked) binding.accountLockedImageView.visible(account.locked)

View file

@ -145,7 +145,7 @@ fun TimelineAccount.toEntity() =
username = username, username = username,
displayName = name, displayName = name,
avatar = avatar, avatar = avatar,
emojis = emojis ?: emptyList() emojis = emojis.orEmpty()
) )
fun Status.toEntity( fun Status.toEntity(

View file

@ -207,7 +207,7 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable {
entryValues = (listOf("") + locales.map { it.language }).toTypedArray() entryValues = (listOf("") + locales.map { it.language }).toTypedArray()
key = PrefKeys.DEFAULT_POST_LANGUAGE key = PrefKeys.DEFAULT_POST_LANGUAGE
icon = makeIcon(requireContext(), GoogleMaterial.Icon.gmd_translate, iconSize) icon = makeIcon(requireContext(), GoogleMaterial.Icon.gmd_translate, iconSize)
value = accountManager.activeAccount?.defaultPostLanguage ?: "" value = accountManager.activeAccount?.defaultPostLanguage.orEmpty()
isPersistent = false // This will be entirely server-driven isPersistent = false // This will be entirely server-driven
setSummaryProvider { entry } setSummaryProvider { entry }
@ -339,7 +339,7 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable {
it.defaultPostPrivacy = account.source?.privacy it.defaultPostPrivacy = account.source?.privacy
?: Status.Visibility.PUBLIC ?: Status.Visibility.PUBLIC
it.defaultMediaSensitivity = account.source?.sensitive ?: false it.defaultMediaSensitivity = account.source?.sensitive ?: false
it.defaultPostLanguage = language ?: "" it.defaultPostLanguage = language.orEmpty()
accountManager.saveAccount(it) accountManager.saveAccount(it)
} }
} else { } else {

View file

@ -54,7 +54,7 @@ class ReportNoteFragment : Fragment(R.layout.fragment_report_note), Injectable {
private fun handleChanges() { private fun handleChanges() {
binding.editNote.doAfterTextChanged { binding.editNote.doAfterTextChanged {
viewModel.reportNote = it?.toString() ?: "" viewModel.reportNote = it?.toString().orEmpty()
} }
binding.checkIsNotifyRemote.setOnCheckedChangeListener { _, isChecked -> binding.checkIsNotifyRemote.setOnCheckedChangeListener { _, isChecked ->
viewModel.isRemoteNotify = isChecked viewModel.isRemoteNotify = isChecked

View file

@ -114,7 +114,7 @@ class SearchActivity : BottomSheetActivity(), HasAndroidInjector, MenuProvider {
private fun handleIntent(intent: Intent) { private fun handleIntent(intent: Intent) {
if (Intent.ACTION_SEARCH == intent.action) { if (Intent.ACTION_SEARCH == intent.action) {
viewModel.currentQuery = intent.getStringExtra(SearchManager.QUERY) ?: "" viewModel.currentQuery = intent.getStringExtra(SearchManager.QUERY).orEmpty()
viewModel.search(viewModel.currentQuery) viewModel.search(viewModel.currentQuery)
} }
} }

View file

@ -468,7 +468,7 @@ class SearchStatusesFragment : SearchFragment<StatusViewData.Concrete>(), Status
val intent = ComposeActivity.startIntent( val intent = ComposeActivity.startIntent(
requireContext(), requireContext(),
ComposeOptions( ComposeOptions(
content = redraftStatus.text ?: "", content = redraftStatus.text.orEmpty(),
inReplyToId = redraftStatus.inReplyToId, inReplyToId = redraftStatus.inReplyToId,
visibility = redraftStatus.visibility, visibility = redraftStatus.visibility,
contentWarning = redraftStatus.spoilerText, contentWarning = redraftStatus.spoilerText,

View file

@ -72,7 +72,7 @@ class TrendingAdapter(
is TrendingViewData.Tag -> { is TrendingViewData.Tag -> {
val maxTrendingValue = currentList val maxTrendingValue = currentList
.flatMap { trendingViewData -> .flatMap { trendingViewData ->
trendingViewData.asTagOrNull()?.tag?.history ?: emptyList() trendingViewData.asTagOrNull()?.tag?.history.orEmpty()
} }
.mapNotNull { it.uses.toLongOrNull() } .mapNotNull { it.uses.toLongOrNull() }
.maxOrNull() ?: 1 .maxOrNull() ?: 1

View file

@ -153,9 +153,9 @@ class AccountManager @Inject constructor(db: AppDatabase) {
it.displayName = account.name it.displayName = account.name
it.profilePictureUrl = account.avatar it.profilePictureUrl = account.avatar
it.defaultPostPrivacy = account.source?.privacy ?: Status.Visibility.PUBLIC it.defaultPostPrivacy = account.source?.privacy ?: Status.Visibility.PUBLIC
it.defaultPostLanguage = account.source?.language ?: "" it.defaultPostLanguage = account.source?.language.orEmpty()
it.defaultMediaSensitivity = account.source?.sensitive ?: false it.defaultMediaSensitivity = account.source?.sensitive ?: false
it.emojis = account.emojis ?: emptyList() it.emojis = account.emojis.orEmpty()
Log.d(TAG, "updateActiveAccount: saving account with id " + it.id) Log.d(TAG, "updateActiveAccount: saving account with id " + it.id)
accountDao.insertOrReplace(it) accountDao.insertOrReplace(it)

View file

@ -49,8 +49,8 @@ class SendStatusBroadcastReceiver : BroadcastReceiver() {
val senderFullName = intent.getStringExtra(NotificationHelper.KEY_SENDER_ACCOUNT_FULL_NAME) val senderFullName = intent.getStringExtra(NotificationHelper.KEY_SENDER_ACCOUNT_FULL_NAME)
val citedStatusId = intent.getStringExtra(NotificationHelper.KEY_CITED_STATUS_ID) val citedStatusId = intent.getStringExtra(NotificationHelper.KEY_CITED_STATUS_ID)
val visibility = intent.getSerializableExtra(NotificationHelper.KEY_VISIBILITY) as Status.Visibility val visibility = intent.getSerializableExtra(NotificationHelper.KEY_VISIBILITY) as Status.Visibility
val spoiler = intent.getStringExtra(NotificationHelper.KEY_SPOILER) ?: "" val spoiler = intent.getStringExtra(NotificationHelper.KEY_SPOILER).orEmpty()
val mentions = intent.getStringArrayExtra(NotificationHelper.KEY_MENTIONS) ?: emptyArray() val mentions = intent.getStringArrayExtra(NotificationHelper.KEY_MENTIONS).orEmpty()
val account = accountManager.getAccountById(senderId) val account = accountManager.getAccountById(senderId)

View file

@ -86,7 +86,7 @@ fun markupHiddenUrls(context: Context, content: CharSequence): SpannableStringBu
false false
} else { } else {
val text = spannableContent.subSequence(start, spannableContent.getSpanEnd(it)).toString() val text = spannableContent.subSequence(start, spannableContent.getSpanEnd(it)).toString()
.split(' ').lastOrNull() ?: "" .split(' ').lastOrNull().orEmpty()
var textDomain = getDomain(text) var textDomain = getDomain(text)
if (textDomain.isBlank()) { if (textDomain.isBlank()) {
textDomain = getDomain("https://$text") textDomain = getDomain("https://$text")

View file

@ -73,7 +73,7 @@ class LocaleUtilsTest {
clientId = null, clientId = null,
clientSecret = null, clientSecret = null,
isActive = true, isActive = true,
defaultPostLanguage = configuredLanguages[1] ?: "", defaultPostLanguage = configuredLanguages[1].orEmpty(),
) )
) )
} }