[Proposal] Hide displayName to prevent mistakes
This commit is contained in:
parent
12c402f25b
commit
e6c2b2c822
|
@ -126,7 +126,7 @@ class EditProfileActivity : BaseActivity(), Injectable {
|
|||
val me = profileRes.data
|
||||
if (me != null) {
|
||||
|
||||
displayNameEditText.setText(me.displayName)
|
||||
displayNameEditText.setText(me.intentionallyUseDisplayName)
|
||||
noteEditText.setText(me.source?.note)
|
||||
lockedCheckBox.isChecked = me.locked
|
||||
|
||||
|
|
|
@ -17,13 +17,13 @@ package com.keylesspalace.tusky.entity
|
|||
|
||||
import android.text.Spanned
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import java.util.Date
|
||||
import java.util.*
|
||||
|
||||
data class Account(
|
||||
val id: String,
|
||||
@SerializedName("username") val localUsername: String,
|
||||
@SerializedName("acct") 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 url: String,
|
||||
val avatar: String,
|
||||
|
@ -45,6 +45,13 @@ data class Account(
|
|||
localUsername
|
||||
} 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 {
|
||||
return id.hashCode()
|
||||
}
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
|
||||
package com.keylesspalace.tusky.viewmodel
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.net.Uri
|
||||
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.HEADER_HEIGHT
|
||||
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.schedulers.Schedulers
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.RequestBody.Companion.asRequestBody
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import okhttp3.MultipartBody
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.asRequestBody
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import retrofit2.Call
|
||||
|
@ -145,7 +145,7 @@ class EditProfileViewModel @Inject constructor(
|
|||
return
|
||||
}
|
||||
|
||||
val displayName = if (oldProfileData?.displayName == newDisplayName) {
|
||||
val displayName = if (oldProfileData?.intentionallyUseDisplayName == newDisplayName) {
|
||||
null
|
||||
} else {
|
||||
newDisplayName.toRequestBody(MultipartBody.FORM)
|
||||
|
@ -285,4 +285,4 @@ class EditProfileViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue