fix crash when Account.displayName is null (#1667)

main
Konrad Pozniak 5 years ago committed by GitHub
parent 7dcd6221aa
commit d368ed464e
  1. 2
      app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt
  2. 2
      app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationEntity.kt
  3. 4
      app/src/main/java/com/keylesspalace/tusky/entity/Account.kt
  4. 2
      app/src/main/java/com/keylesspalace/tusky/repository/TimelineRepository.kt

@ -458,7 +458,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
loadAvatar(movedAccount.avatar, accountMovedAvatar, avatarRadius, animateAvatar)
accountMovedText.text = getString(R.string.account_moved_description, movedAccount.displayName)
accountMovedText.text = getString(R.string.account_moved_description, movedAccount.name)
// this is necessary because API 19 can't handle vector compound drawables
val movedIcon = ContextCompat.getDrawable(this, R.drawable.ic_briefcase)?.mutate()

@ -166,7 +166,7 @@ fun Account.toEntity() =
ConversationAccountEntity(
id,
username,
displayName,
displayName.orEmpty(),
avatar,
emojis ?: emptyList()
)

@ -31,7 +31,7 @@ data class Account(
val id: String,
@SerializedName("username") val localUsername: String,
@SerializedName("acct") val username: String,
@SerializedName("display_name") val displayName: String,
@SerializedName("display_name") val displayName: String?, // should never be null per Api definition, but some servers break the contract
val note: @WriteWith<SpannedParceler>() Spanned,
val url: String,
val avatar: String,
@ -49,7 +49,7 @@ data class Account(
) : Parcelable {
val name: String
get() = if (displayName.isEmpty()) {
get() = if (displayName.isNullOrEmpty()) {
localUsername
} else displayName

@ -298,7 +298,7 @@ fun Account.toEntity(accountId: Long, gson: Gson): TimelineAccountEntity {
timelineUserId = accountId,
localUsername = localUsername,
username = username,
displayName = displayName,
displayName = displayName.orEmpty(),
url = url,
avatar = avatar,
emojis = gson.toJson(emojis),

Loading…
Cancel
Save