Merge branch 'fix/displayname'
This commit is contained in:
commit
5a46be79a8
|
@ -126,7 +126,7 @@ class EditProfileActivity : BaseActivity(), Injectable {
|
||||||
val me = profileRes.data
|
val me = profileRes.data
|
||||||
if (me != null) {
|
if (me != null) {
|
||||||
|
|
||||||
displayNameEditText.setText(me.displayName)
|
displayNameEditText.setText(me.intentionallyUseDisplayName)
|
||||||
noteEditText.setText(me.source?.note)
|
noteEditText.setText(me.source?.note)
|
||||||
lockedCheckBox.isChecked = me.locked
|
lockedCheckBox.isChecked = me.locked
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ fun Account.toEntity() =
|
||||||
ConversationAccountEntity(
|
ConversationAccountEntity(
|
||||||
id,
|
id,
|
||||||
username,
|
username,
|
||||||
displayName.orEmpty(),
|
name,
|
||||||
avatar,
|
avatar,
|
||||||
emojis ?: emptyList()
|
emojis ?: emptyList()
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,13 +17,13 @@ package com.keylesspalace.tusky.entity
|
||||||
|
|
||||||
import android.text.Spanned
|
import android.text.Spanned
|
||||||
import com.google.gson.annotations.SerializedName
|
import com.google.gson.annotations.SerializedName
|
||||||
import java.util.Date
|
import java.util.*
|
||||||
|
|
||||||
data class Account(
|
data class Account(
|
||||||
val id: String,
|
val id: String,
|
||||||
@SerializedName("username") val localUsername: String,
|
@SerializedName("username") val localUsername: String,
|
||||||
@SerializedName("acct", alternate = ["subject"]) val username: String,
|
@SerializedName("acct", alternate = ["subject"]) val username: String,
|
||||||
@SerializedName("display_name") val displayName: String?, // should never be null per Api definition, but some servers break the contract
|
@SerializedName("display_name") private val displayName: String?, // should never be null per Api definition, but some servers break the contract
|
||||||
val note: Spanned,
|
val note: Spanned,
|
||||||
val url: String,
|
val url: String,
|
||||||
val avatar: String,
|
val avatar: String,
|
||||||
|
@ -46,6 +46,13 @@ data class Account(
|
||||||
localUsername
|
localUsername
|
||||||
} else displayName
|
} else displayName
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We have to use [localUsername] when [displayName] is empty.
|
||||||
|
* Should use [name] for displaying purposes.
|
||||||
|
*/
|
||||||
|
val intentionallyUseDisplayName: String
|
||||||
|
get() = displayName.orEmpty()
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int {
|
||||||
return id.hashCode()
|
return id.hashCode()
|
||||||
}
|
}
|
||||||
|
|
|
@ -313,7 +313,7 @@ fun Account.toEntity(accountId: Long, gson: Gson): TimelineAccountEntity {
|
||||||
timelineUserId = accountId,
|
timelineUserId = accountId,
|
||||||
localUsername = localUsername,
|
localUsername = localUsername,
|
||||||
username = username,
|
username = username,
|
||||||
displayName = displayName.orEmpty(),
|
displayName = name,
|
||||||
url = url,
|
url = url,
|
||||||
avatar = avatar,
|
avatar = avatar,
|
||||||
emojis = gson.toJson(emojis),
|
emojis = gson.toJson(emojis),
|
||||||
|
|
|
@ -52,7 +52,7 @@ public final class ViewDataUtils {
|
||||||
.setSensitive(visibleStatus.getSensitive())
|
.setSensitive(visibleStatus.getSensitive())
|
||||||
.setIsShowingSensitiveContent(alwaysShowSensitiveMedia || !visibleStatus.getSensitive())
|
.setIsShowingSensitiveContent(alwaysShowSensitiveMedia || !visibleStatus.getSensitive())
|
||||||
.setSpoilerText(visibleStatus.getSpoilerText())
|
.setSpoilerText(visibleStatus.getSpoilerText())
|
||||||
.setRebloggedByUsername(status.getReblog() == null ? null : status.getAccount().getDisplayName())
|
.setRebloggedByUsername(status.getReblog() == null ? null : status.getAccount().getName())
|
||||||
.setUserFullName(visibleStatus.getAccount().getName())
|
.setUserFullName(visibleStatus.getAccount().getName())
|
||||||
.setVisibility(visibleStatus.getVisibility())
|
.setVisibility(visibleStatus.getVisibility())
|
||||||
.setSenderId(visibleStatus.getAccount().getId())
|
.setSenderId(visibleStatus.getAccount().getId())
|
||||||
|
|
|
@ -15,12 +15,12 @@
|
||||||
|
|
||||||
package com.keylesspalace.tusky.viewmodel
|
package com.keylesspalace.tusky.viewmodel
|
||||||
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
|
||||||
import androidx.lifecycle.ViewModel
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
import com.keylesspalace.tusky.EditProfileActivity.Companion.AVATAR_SIZE
|
import com.keylesspalace.tusky.EditProfileActivity.Companion.AVATAR_SIZE
|
||||||
import com.keylesspalace.tusky.EditProfileActivity.Companion.HEADER_HEIGHT
|
import com.keylesspalace.tusky.EditProfileActivity.Companion.HEADER_HEIGHT
|
||||||
import com.keylesspalace.tusky.EditProfileActivity.Companion.HEADER_WIDTH
|
import com.keylesspalace.tusky.EditProfileActivity.Companion.HEADER_WIDTH
|
||||||
|
@ -36,10 +36,10 @@ import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.rxkotlin.addTo
|
import io.reactivex.rxkotlin.addTo
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||||
import okhttp3.RequestBody.Companion.asRequestBody
|
|
||||||
import okhttp3.RequestBody.Companion.toRequestBody
|
|
||||||
import okhttp3.MultipartBody
|
import okhttp3.MultipartBody
|
||||||
import okhttp3.RequestBody
|
import okhttp3.RequestBody
|
||||||
|
import okhttp3.RequestBody.Companion.asRequestBody
|
||||||
|
import okhttp3.RequestBody.Companion.toRequestBody
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import retrofit2.Call
|
import retrofit2.Call
|
||||||
|
@ -145,7 +145,7 @@ class EditProfileViewModel @Inject constructor(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val displayName = if (oldProfileData?.displayName == newDisplayName) {
|
val displayName = if (oldProfileData?.intentionallyUseDisplayName == newDisplayName) {
|
||||||
null
|
null
|
||||||
} else {
|
} else {
|
||||||
newDisplayName.toRequestBody(MultipartBody.FORM)
|
newDisplayName.toRequestBody(MultipartBody.FORM)
|
||||||
|
@ -285,4 +285,4 @@ class EditProfileViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class QuoteInlineHelper {
|
||||||
|
|
||||||
public void setupQuoteContainer() {
|
public void setupQuoteContainer() {
|
||||||
Account account = quoteStatus.getAccount();
|
Account account = quoteStatus.getAccount();
|
||||||
setDisplayName(account.getDisplayName().equals("") ? account.getLocalUsername() : account.getDisplayName(), account.getEmojis());
|
setDisplayName(account.getName(), account.getEmojis());
|
||||||
setUsername(account.getUsername());
|
setUsername(account.getUsername());
|
||||||
setContent(quoteStatus.getContent(), quoteStatus.getMentions(),
|
setContent(quoteStatus.getContent(), quoteStatus.getMentions(),
|
||||||
quoteStatus.getEmojis(), listener);
|
quoteStatus.getEmojis(), listener);
|
||||||
|
|
Loading…
Reference in New Issue