Cleanup after Onuray's review and improve wording when removing display name
This commit is contained in:
parent
9754e26e5f
commit
35fed2676a
|
@ -33,8 +33,8 @@
|
|||
<string name="notice_display_name_set_by_you">You set your display name to %1$s</string>
|
||||
<string name="notice_display_name_changed_from">%1$s changed their display name from %2$s to %3$s</string>
|
||||
<string name="notice_display_name_changed_from_by_you">You changed your display name from %1$s to %2$s</string>
|
||||
<string name="notice_display_name_removed">%1$s removed their display name (%2$s)</string>
|
||||
<string name="notice_display_name_removed_by_you">You removed your display name (%1$s)</string>
|
||||
<string name="notice_display_name_removed">%1$s removed their display name (it was %2$s)</string>
|
||||
<string name="notice_display_name_removed_by_you">You removed your display name (it was %1$s)</string>
|
||||
<string name="notice_room_topic_changed">%1$s changed the topic to: %2$s</string>
|
||||
<string name="notice_room_topic_changed_by_you">You changed the topic to: %1$s</string>
|
||||
<string name="notice_room_name_changed">%1$s changed the room name to: %2$s</string>
|
||||
|
|
|
@ -122,7 +122,9 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
|
|||
it.summary = session.getUser(session.myUserId)?.displayName ?: ""
|
||||
it.text = it.summary.toString()
|
||||
it.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
||||
onDisplayNameClick(newValue?.let { (it as String).trim() })
|
||||
newValue
|
||||
?.let { value -> (value as? String)?.trim() }
|
||||
?.let { value -> onDisplayNameChanged(value) }
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -857,20 +859,21 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
|
|||
/**
|
||||
* Update the displayname.
|
||||
*/
|
||||
private fun onDisplayNameClick(value: String?) {
|
||||
value ?: return
|
||||
private fun onDisplayNameChanged(value: String) {
|
||||
val currentDisplayName = session.getUser(session.myUserId)?.displayName ?: ""
|
||||
if (currentDisplayName != value) {
|
||||
displayLoadingView()
|
||||
|
||||
session.setDisplayName(session.myUserId, value, object : MatrixCallback<Unit> {
|
||||
override fun onSuccess(data: Unit) {
|
||||
if (!isAdded) return
|
||||
// refresh the settings value
|
||||
mDisplayNamePreference.summary = value
|
||||
onCommonDone(null)
|
||||
}
|
||||
|
||||
override fun onFailure(failure: Throwable) {
|
||||
if (!isAdded) return
|
||||
onCommonDone(failure.localizedMessage)
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue