Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
xx Messenger Android
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile
android
xx Messenger Android
Commits
01258bba
Commit
01258bba
authored
2 years ago
by
Kamal Bramwell
Browse files
Options
Downloads
Patches
Plain Diff
FE-954: Username input field repeats
parent
4ce8269f
No related branches found
No related tags found
2 merge requests
!84
Version 2.92 build 629
,
!83
FE-954: Username input field repeats
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/src/main/java/io/xxlabs/messenger/ui/intro/registration/username/UsernameRegistration.kt
+29
-17
29 additions, 17 deletions
...er/ui/intro/registration/username/UsernameRegistration.kt
app/src/main/res/values/strings.xml
+1
-0
1 addition, 0 deletions
app/src/main/res/values/strings.xml
with
30 additions
and
17 deletions
app/src/main/java/io/xxlabs/messenger/ui/intro/registration/username/UsernameRegistration.kt
+
29
−
17
View file @
01258bba
...
...
@@ -113,12 +113,12 @@ class UsernameRegistration @AssistedInject constructor(
override
val
usernameFilters
:
Array
<
InputFilter
>
=
arrayOf
(
InputFilter
{
source
,
start
,
end
,
_
,
_
,
_
->
val
input
=
source
?.
subSequence
(
start
,
end
)
val
filtered
=
source
?.
subSequence
(
start
,
end
)
?.
replace
(
Regex
(
USERNAME_FILTER_REGEX
),
""
)
if
(
filtered
==
input
)
null
else
filtered
},
//
InputFilter { source, start, end, _, _, _ ->
//
val input = source?.subSequence(start, end)
//
val filtered = source?.subSequence(start, end)
//
?.replace(Regex(USERNAME_FILTER_REGEX), "")
//
if (filtered == input) null else filtered
//
},
InputFilter
.
LengthFilter
(
MAX_USERNAME_LENGTH
)
)
...
...
@@ -179,19 +179,25 @@ class UsernameRegistration @AssistedInject constructor(
this
.
equals
(
PLAY_STORE_DEMO_USERNAME
,
true
)
private
fun
String
?.
isValidUsername
():
Boolean
{
if
(
isNullOrEmpty
()
||
!
isMinimumLength
())
{
return
when
{
isNullOrEmpty
()
||
!
isMinimumLength
()
->
{
minimumLengthError
()
return
false
false
}
return
if
(
this
.
matches
(
USERNAME_VALIDATION_REGEX
.
toRegex
()))
{
matches
(
USERNAME_VALIDATION_REGEX
.
toRegex
())
->
{
error
.
value
=
null
true
}
else
{
}
contains
(
Regex
(
USERNAME_FILTER_REGEX
))
->
{
invalidCharsInUsernameError
()
false
}
else
->
{
invalidUsernameError
()
false
}
}
}
private
fun
String
.
isMinimumLength
()
=
length
>
MIN_USERNAME_LENGTH
...
...
@@ -203,6 +209,12 @@ class UsernameRegistration @AssistedInject constructor(
error
.
value
=
application
.
getString
(
R
.
string
.
registration_error_username_invalid
)
}
private
fun
invalidCharsInUsernameError
()
{
error
.
postValue
(
application
.
getString
(
R
.
string
.
registration_error_username_invalid_chars
)
)
}
private
fun
registerUsername
(
username
:
String
,
isDemoAcct
:
Boolean
=
false
)
{
if
(!
loggedIn
)
{
getOrCreateSession
()
...
...
This diff is collapsed.
Click to expand it.
app/src/main/res/values/strings.xml
+
1
−
0
View file @
01258bba
...
...
@@ -519,6 +519,7 @@
<string
name=
"label_edit"
>
Edit
</string>
<string
name=
"notification_group_request_text"
>
Group request received
</string>
<string
name=
"registration_error_username_invalid"
>
Username must start and end with an alphanumeric character.
</string>
<string
name=
"registration_error_username_invalid_chars"
>
Username contains invalid characters.
</string>
<string
name=
"settings_confirm_delete_button"
>
Confirm Delete
</string>
<string
name=
"settings_delete_account_confirm_username_hint"
>
Username
</string>
<string
name=
"settings_account_recovery_dialog_title"
>
Please note
</string>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment