Skip to content

Nick color #4826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Jan 5, 2022
Merged

Nick color #4826

merged 29 commits into from
Jan 5, 2022

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Dec 31, 2021

Replacement for #2614 (see details there).

Fixes #2610

mitchnull and others added 24 commits January 3, 2021 18:52
- allow changing the nick color by clicking the dispay-name in the room
  member detail page.
- the ovirride-color can be specified as a hex string (#rrggbb) or as palette
  index (2)
- entering an invalid color code or leaving the field blank reverts to
  the default hash-based nick color
- the setting is stored in `account_data` as `im.vector.setting.override_colors`

- future improvements / notes:
  - replace the text-based color entry with a proper color picker dialog
  - make the feature more discoverable
  - the color change listener is now in AppStateHandler, not sure if this is
    the best place
  - implement override color support in element-web / element-desktop, too

Signed-off-by: Péter Radics <[email protected]>
…ndroid into feature/issue-2610-override-nick-color-via-user-account-data
Remove the click handler that opens the override color dialog from the
display-name part on the member profile page, as this is not really
discoverable and we have a proper menu item for it now.
…erge branch 'develop' of https://github.com./vector-im/element-android into feature/issue-2610-override-nick-color-via-user-account-data
…develop' of github.com.:mitchnull/element-android into feature/issue-2610-override-nick-color-via-user-account-data
…ndroid into feature/issue-2610-override-nick-color-via-user-account-data
…ndroid into feature/issue-2610-override-nick-color-via-user-account-data
…ick-color-via-user-account-data

[issue-2610] implement setting to override nick color
@bmarty bmarty marked this pull request as ready for review December 31, 2021 14:23
@github-actions
Copy link

github-actions bot commented Dec 31, 2021

Unit Test Results

  66 files  ±0    66 suites  ±0   52s ⏱️ +4s
135 tests ±0  135 ✔️ ±0  0 💤 ±0  0 ±0 
418 runs  ±0  418 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit 02a8fd2. ± Comparison against base commit 5efe1f4.

♻️ This comment has been updated with latest results.

null
} else {
try {
if (colorText.length == 1) {
Copy link
Contributor

@mitchnull mitchnull Jan 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break if/when the palette is extended to 16 or more colors. Maybe it would be better to just try to parse it as int, and if that works then it's a color index (from the palette) otherwise parse with Color.parseColor. Another option would be to check if the text starts with a digit to select the palette version.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but the plan is to change this dialog to do something more user friendly, so it's acceptable like that to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, cool, thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

being able to set the colour by index is quite cryptic, I wouldn't have expected an input with a hex string hint to also allow a 0-9 index

something a UI iteration could help to improve

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is really a hidden feature. Sort of easter egg.
I see in my dream a nice dialog with all the 8 predefined colors, a color picker and a field to manually enter a html color. Even a reset button, instead of validating a empty dialog to reset the color.
Also note that now using the word "black" or any other color that Color.parse() understand will also work, not sure for the other non Android-Element Matrix clients compatibility though.

@bmarty bmarty requested a review from ouchadam January 3, 2022 10:34
@bmarty
Copy link
Member Author

bmarty commented Jan 3, 2022

@ouchadam can you have a quick look on this PR please? Thanks.

@@ -27,4 +27,5 @@ object UserAccountDataTypes {
const val TYPE_ALLOWED_WIDGETS = "im.vector.setting.allowed_widgets"
const val TYPE_IDENTITY_SERVER = "m.identity_server"
const val TYPE_ACCEPTED_TERMS = "m.accepted_terms"
const val TYPE_OVERRIDE_COLORS = "im.vector.setting.override_colors"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this type need to be added to the matrix spec somewhere?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have another PR that implements the same functionality in element-desktop (matrix-org/matrix-react-sdk#5626). As far as I understand keys under im.vector.setting are free-to-use by clients, so I don't think it's absolutely necessary to include it in the matrix spec (apart from maybe documenting its existence so that other clients can pick this up if they wish)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right, using domain prefixed type is fine. Nowadays we should maybe consider using io.element.prefix.
More details here: https://spec.matrix.org/latest/#namespacing

views.editText.setText(state.userColorOverride)
views.editText.hint = "#000000"

MaterialAlertDialogBuilder(requireContext())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allowing the user to provide a hex string is quite verbose, perhaps another iteration of this could use a colour wheel UI

Copy link
Contributor

@mitchnull mitchnull Jan 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't include a full-fledged UI for this in my original PR because I didn't have the necessary expertise to do it quickly, and it wasn't clear that the PR / idea would be accepted at all (this is mostly a PoC and a working solution for us). I do agree that a proper color selector should be created for this (that can select a color from the current palette or select an arbitrary RGB color)

.liveUserAccountData(UserAccountDataTypes.TYPE_OVERRIDE_COLORS)
.unwrap()
.map { it.content.toModel<Map<String, String>>() }
.map { userColorAccountDataContent ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could merge these maps

.map { 
  val userColorAccountDataContent = it.content.toModel<Map<String, String>>()
  userColorAccountDataContent?.get(initialState.userId)
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to rework, thanks, will update

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -2812,6 +2812,8 @@
<string name="direct_room_profile_section_more_leave">Leave</string>
<string name="room_profile_leaving_room">"Leaving the room…"</string>

<string name="room_member_override_nick_color">Override nick color</string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the nick terminology used in other places, or should this be display name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nick is used in the slash command /myroomnick but nowhere else AFAIK. The color will be used to tint the display name but also for the background of the default avatar. So not only the display name.
Maybe using "Override user color" is fine. Please vote with 👍 and 👎 !

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no strong opinions from me on this 😄 maybe one for product cc @daniellekirkwood

Copy link
Contributor

@ouchadam ouchadam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💯 small comment about the field UI label but we can always update it later

@bmarty bmarty merged commit 17e485f into develop Jan 5, 2022
@bmarty bmarty deleted the feature/bma/nick_color_final branch January 5, 2022 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow users to change the color of nick names
3 participants