Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
689cffce
Commit
689cffce
authored
Nov 14, 2018
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds the rocket.chat domain for avoid typing it
parent
4b1f0c9e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
8 deletions
+37
-8
ServerFragment.kt
...rocket/android/authentication/server/ui/ServerFragment.kt
+37
-8
No files found.
app/src/main/java/chat/rocket/android/authentication/server/ui/ServerFragment.kt
View file @
689cffce
package
chat.rocket.android.authentication.server.ui
import
android.os.Bundle
import
android.text.SpannableStringBuilder
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
...
...
@@ -11,6 +12,7 @@ import android.widget.ScrollView
import
android.widget.Toast
import
androidx.core.content.ContextCompat
import
androidx.core.net.toUri
import
androidx.core.text.color
import
androidx.core.view.ViewCompat
import
androidx.core.view.isVisible
import
androidx.fragment.app.Fragment
...
...
@@ -51,6 +53,8 @@ class ServerFragment : Fragment(), ServerView {
lateinit
var
analyticsManager
:
AnalyticsManager
private
var
deepLinkInfo
:
LoginDeepLinkInfo
?
=
null
private
var
protocol
=
"https://"
private
var
isDomainAppended
=
false
private
var
appendedText
=
""
private
lateinit
var
serverUrlDisposable
:
Disposable
private
val
layoutListener
=
ViewTreeObserver
.
OnGlobalLayoutListener
{
if
(
KeyboardHelper
.
isSoftKeyboardShown
(
scroll_view
.
rootView
))
{
...
...
@@ -131,7 +135,7 @@ class ServerFragment : Fragment(), ServerView {
}
private
fun
setupOnClickListener
()
=
ui
{
_
->
ui
{
button_connect
.
setOnClickListener
{
presenter
.
checkServer
(
"$protocol${text_server_url.textContent.sanitize()}"
)
}
...
...
@@ -244,16 +248,41 @@ class ServerFragment : Fragment(), ServerView {
private
fun
subscribeEditText
()
{
serverUrlDisposable
=
text_server_url
.
asObservable
()
.
filter
{
it
.
isNotBlank
()
}
.
subscribe
{
if
(
"$protocol${it.toString()}"
.
isValidUrl
())
{
.
subscribe
{
processUserInput
(
it
.
toString
())
}
}
private
fun
unsubscribeEditText
()
=
serverUrlDisposable
.
dispose
()
private
fun
processUserInput
(
text
:
String
)
{
if
(
text
.
last
().
toString
()
==
"."
&&
!
isDomainAppended
)
{
addDomain
()
}
else
if
(
isDomainAppended
&&
text
!=
appendedText
)
{
removeDomain
()
}
if
(
"$protocol$text"
.
isValidUrl
())
{
enableButtonConnect
()
}
else
{
disableButtonConnect
()
}
}
private
fun
addDomain
()
{
val
cursorPosition
=
text_server_url
.
length
()
text_server_url
.
append
(
SpannableStringBuilder
()
.
color
(
R
.
color
.
colorAuthenticationSecondaryText
)
{
append
(
"rocket.chat"
)
})
text_server_url
.
setSelection
(
cursorPosition
)
appendedText
=
text_server_url
.
text
.
toString
()
isDomainAppended
=
true
}
private
fun
unsubscribeEditText
()
=
serverUrlDisposable
.
dispose
()
private
fun
removeDomain
()
{
text_server_url
.
setText
(
text_server_url
.
text
.
toString
().
substring
(
0
,
text_server_url
.
selectionEnd
)
)
text_server_url
.
setSelection
(
text_server_url
.
length
())
isDomainAppended
=
false
}
private
fun
enableUserInput
()
{
enableButtonConnect
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment