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
a5963579
Commit
a5963579
authored
Jul 30, 2018
by
divyanshu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
join community
parent
d4ee1595
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
95 additions
and
23 deletions
+95
-23
OnBoardingPresenter.kt
...entication/onboarding/presentation/OnBoardingPresenter.kt
+43
-1
OnBoardingView.kt
.../authentication/onboarding/presentation/OnBoardingView.kt
+6
-1
OnBoardingFragment.kt
...ndroid/authentication/onboarding/ui/OnBoardingFragment.kt
+33
-7
ServerFragment.kt
...rocket/android/authentication/server/ui/ServerFragment.kt
+1
-1
fragment_authentication_on_boarding.xml
...c/main/res/layout/fragment_authentication_on_boarding.xml
+11
-1
spinner_list.xml
app/src/main/res/layout/spinner_list.xml
+0
-11
styles.xml
app/src/main/res/values/styles.xml
+1
-1
No files found.
app/src/main/java/chat/rocket/android/authentication/onboarding/presentation/OnBoardingPresenter.kt
View file @
a5963579
package
chat.rocket.android.authentication.onboarding.presentation
import
chat.rocket.android.authentication.presentation.AuthenticationNavigator
import
chat.rocket.android.core.behaviours.showMessage
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.server.domain.GetAccountsInteractor
import
chat.rocket.android.server.domain.RefreshSettingsInteractor
import
chat.rocket.android.server.domain.SaveConnectingServerInteractor
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extensions.isValidUrl
import
javax.inject.Inject
class
OnBoardingPresenter
@Inject
constructor
(
private
val
view
:
OnBoardingView
,
private
val
strategy
:
CancelStrategy
,
private
val
navigator
:
AuthenticationNavigator
private
val
navigator
:
AuthenticationNavigator
,
private
val
serverInteractor
:
SaveConnectingServerInteractor
,
private
val
refreshSettingsInteractor
:
RefreshSettingsInteractor
,
private
val
getAccountsInteractor
:
GetAccountsInteractor
)
{
fun
createServer
(){
navigator
.
toWebPage
(
"https://cloud.rocket.chat/trial"
)
}
fun
connect
(
server
:
String
)
{
//code that leads to login screen (smart lock will be implemented after this)
connectToServer
(
server
)
{
navigator
.
toLoginOptions
()
}
}
private
fun
connectToServer
(
server
:
String
,
block
:
()
->
Unit
)
{
if
(!
server
.
isValidUrl
())
{
view
.
showInvalidServerUrlMessage
()
}
else
{
launchUI
(
strategy
)
{
// Check if we already have an account for this server...
val
account
=
getAccountsInteractor
.
get
().
firstOrNull
{
it
.
serverUrl
==
server
}
if
(
account
!=
null
)
{
navigator
.
toChatList
(
server
)
return
@launchUI
}
view
.
showLoading
()
try
{
refreshSettingsInteractor
.
refresh
(
server
)
serverInteractor
.
save
(
server
)
block
()
}
catch
(
ex
:
Exception
)
{
view
.
showMessage
(
ex
)
}
finally
{
view
.
hideLoading
()
}
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/authentication/onboarding/presentation/OnBoardingView.kt
View file @
a5963579
package
chat.rocket.android.authentication.onboarding.presentation
import
chat.rocket.android.core.behaviours.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
interface
OnBoardingView
:
LoadingView
{
interface
OnBoardingView
:
LoadingView
,
MessageView
{
/**
* Shows an invalid server URL message.
*/
fun
showInvalidServerUrlMessage
()
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/authentication/onboarding/ui/OnBoardingFragment.kt
View file @
a5963579
...
...
@@ -12,16 +12,17 @@ import chat.rocket.android.authentication.onboarding.presentation.OnBoardingPres
import
chat.rocket.android.authentication.onboarding.presentation.OnBoardingView
import
chat.rocket.android.authentication.server.ui.ServerFragment
import
chat.rocket.android.authentication.ui.AuthenticationActivity
import
chat.rocket.android.util.extensions.addFragmentBackStack
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.util.extensions.*
import
dagger.android.support.AndroidSupportInjection
import
kotlinx.android.synthetic.main.app_bar_chat_room.*
import
kotlinx.android.synthetic.main.fragment_authentication_on_boarding.*
import
javax.inject.Inject
class
OnBoardingFragment
:
Fragment
(),
OnBoardingView
{
@Inject
lateinit
var
presenter
:
OnBoardingPresenter
private
var
protocol
=
"https://"
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
=
container
?.
inflate
(
R
.
layout
.
fragment_authentication_on_boarding
)
...
...
@@ -45,9 +46,7 @@ class OnBoardingFragment : Fragment(), OnBoardingView {
}
}
button_join_community
.
setOnClickListener
{
(
activity
as
AuthenticationActivity
).
addFragmentBackStack
(
"ServerFragment"
,
R
.
id
.
fragment_container
)
{
ServerFragment
.
newInstance
(
deepLinkInfo
)
}
connectToCommunityServer
()
}
button_create_server
.
setOnClickListener
{
presenter
.
createServer
()
...
...
@@ -60,14 +59,41 @@ class OnBoardingFragment : Fragment(), OnBoardingView {
}
override
fun
showLoading
()
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
ui
{
view_loading
.
setVisible
(
true
)
}
}
override
fun
hideLoading
()
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
ui
{
view_loading
.
setVisible
(
false
)
}
}
override
fun
showInvalidServerUrlMessage
()
=
showMessage
(
getString
(
R
.
string
.
msg_invalid_server_url
))
override
fun
showMessage
(
resId
:
Int
)
{
ui
{
showToast
(
resId
)
}
}
override
fun
showMessage
(
message
:
String
)
{
ui
{
showToast
(
message
)
}
}
override
fun
showGenericErrorMessage
()
{
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
}
private
fun
connectToCommunityServer
()
{
ui
{
val
url
=
"open.rocket.chat"
presenter
.
connect
(
"$protocol${url.sanitize()}"
)
}
}
companion
object
{
fun
newInstance
()
=
OnBoardingFragment
()
}
...
...
app/src/main/java/chat/rocket/android/authentication/server/ui/ServerFragment.kt
View file @
a5963579
...
...
@@ -71,7 +71,7 @@ class ServerFragment : Fragment(), ServerView {
}
text_server_protocol
.
adapter
=
ArrayAdapter
<
String
>(
activity
,
R
.
layout
.
spinner_list
,
arrayOf
(
"https://"
,
"http://"
))
android
.
R
.
layout
.
simple_dropdown_item_1line
,
arrayOf
(
"https://"
,
"http://"
))
text_server_protocol
.
onItemSelectedListener
=
object
:
AdapterView
.
OnItemSelectedListener
{
override
fun
onItemSelected
(
parent
:
AdapterView
<
*
>?,
view
:
View
?,
position
:
Int
,
id
:
Long
)
{
when
(
position
)
{
...
...
app/src/main/res/layout/fragment_authentication_on_boarding.xml
View file @
a5963579
...
...
@@ -166,11 +166,21 @@
android:textStyle=
"bold"
android:textColor=
"#fff"
android:letterSpacing=
"0.04"
android:text=
"C
onnect with a
server"
android:text=
"C
reate a new
server"
android:layout_centerVertical=
"true"
android:layout_toEndOf=
"@id/image_new_server"
/>
</RelativeLayout>
<com.wang.avi.AVLoadingIndicatorView
android:id=
"@+id/view_loading"
style=
"@style/Authentication.AVLoadingIndicatorView"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
android:visibility=
"gone"
tools:visibility=
"visible"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
app/src/main/res/layout/spinner_list.xml
deleted
100644 → 0
View file @
d4ee1595
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"48dp"
android:textSize=
"16sp"
android:textColor=
"@color/colorPrimaryText"
android:textAlignment=
"center"
android:background=
"@color/colorWhite"
android:padding=
"12dp"
tools:text=
"https"
/>
\ No newline at end of file
app/src/main/res/values/styles.xml
View file @
a5963579
...
...
@@ -13,7 +13,7 @@
<item
name=
"searchViewStyle"
>
@style/ChatRoom.SearchView
</item>
</style>
<style
name=
"AuthenticationTheme"
parent=
"Theme.AppCompat.NoActionBar"
>
<style
name=
"AuthenticationTheme"
parent=
"Theme.AppCompat.
Light.
NoActionBar"
>
<item
name=
"android:statusBarColor"
>
@color/colorPrimaryDark
</item>
<item
name=
"android:windowBackground"
>
@color/colorWhite
</item>
</style>
...
...
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