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
2e6ecfcb
Commit
2e6ecfcb
authored
Apr 19, 2018
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat.Android into new/active-users
parents
63c8303c
b6a83f35
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
163 additions
and
92 deletions
+163
-92
build.gradle
app/build.gradle
+1
-1
LoginPresenter.kt
...droid/authentication/login/presentation/LoginPresenter.kt
+16
-29
LoginView.kt
...et/android/authentication/login/presentation/LoginView.kt
+1
-1
LoginFragment.kt
...t/rocket/android/authentication/login/ui/LoginFragment.kt
+1
-22
ServerPresenter.kt
...oid/authentication/server/presentation/ServerPresenter.kt
+15
-3
ServerView.kt
.../android/authentication/server/presentation/ServerView.kt
+1
-1
VersionCheckView.kt
...id/authentication/server/presentation/VersionCheckView.kt
+5
-0
ServerFragment.kt
...rocket/android/authentication/server/ui/ServerFragment.kt
+57
-5
AuthenticationActivity.kt
...ocket/android/authentication/ui/AuthenticationActivity.kt
+1
-1
ChatRoomFragmentModule.kt
...chat/rocket/android/chatroom/di/ChatRoomFragmentModule.kt
+0
-3
ChatRoomModule.kt
...in/java/chat/rocket/android/chatroom/di/ChatRoomModule.kt
+14
-0
ChatRoomNavigator.kt
...rocket/android/chatroom/presentation/ChatRoomNavigator.kt
+6
-0
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+7
-7
ChatRoomActivity.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomActivity.kt
+10
-1
ActivityBuilder.kt
...java/chat/rocket/android/dagger/module/ActivityBuilder.kt
+4
-1
ProfilePresenter.kt
...t/rocket/android/profile/presentation/ProfilePresenter.kt
+15
-8
ProfileView.kt
...a/chat/rocket/android/profile/presentation/ProfileView.kt
+1
-2
ProfileFragment.kt
...in/java/chat/rocket/android/profile/ui/ProfileFragment.kt
+3
-3
CheckServerPresenter.kt
...ocket/android/server/presentation/CheckServerPresenter.kt
+4
-3
ChangeServerActivity.kt
...ava/chat/rocket/android/server/ui/ChangeServerActivity.kt
+1
-1
No files found.
app/build.gradle
View file @
2e6ecfcb
...
...
@@ -13,7 +13,7 @@ android {
applicationId
"chat.rocket.android"
minSdkVersion
21
targetSdkVersion
versions
.
targetSdk
versionCode
201
2
versionCode
201
3
versionName
"2.1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled
true
...
...
app/src/main/java/chat/rocket/android/authentication/login/presentation/LoginPresenter.kt
View file @
2e6ecfcb
...
...
@@ -32,23 +32,22 @@ private const val SERVICE_NAME_GOOGLE = "google"
private
const
val
SERVICE_NAME_LINKEDIN
=
"linkedin"
private
const
val
SERVICE_NAME_GILAB
=
"gitlab"
class
LoginPresenter
@Inject
constructor
(
private
val
view
:
LoginView
,
private
val
strategy
:
CancelStrategy
,
private
val
navigator
:
AuthenticationNavigator
,
private
val
tokenRepository
:
TokenRepository
,
private
val
localRepository
:
LocalRepository
,
private
val
getAccountsInteractor
:
GetAccountsInteractor
,
private
val
settingsInteractor
:
GetSettingsInteractor
,
serverInteractor
:
GetCurrentServerInteractor
,
private
val
saveAccountInteractor
:
SaveAccountInteractor
,
private
val
factory
:
RocketChatClientFactory
)
:
CheckServerPresenter
(
strategy
,
factory
,
view
)
{
class
LoginPresenter
@Inject
constructor
(
private
val
view
:
LoginView
,
private
val
strategy
:
CancelStrategy
,
private
val
navigator
:
AuthenticationNavigator
,
private
val
tokenRepository
:
TokenRepository
,
private
val
localRepository
:
LocalRepository
,
private
val
getAccountsInteractor
:
GetAccountsInteractor
,
private
val
settingsInteractor
:
GetSettingsInteractor
,
serverInteractor
:
GetCurrentServerInteractor
,
private
val
saveAccountInteractor
:
SaveAccountInteractor
,
private
val
factory
:
RocketChatClientFactory
)
{
// TODO - we should validate the current server when opening the app, and have a nonnull get()
private
val
currentServer
=
serverInteractor
.
get
()
!!
private
lateinit
var
client
:
RocketChatClient
private
lateinit
var
settings
:
PublicSettings
//private val client: RocketChatClient = factory.create(currentServer)
//private val settings: PublicSettings = settingsInteractor.get(currentServer)
private
lateinit
var
usernameOrEmail
:
String
private
lateinit
var
password
:
String
private
lateinit
var
credentialToken
:
String
...
...
@@ -62,7 +61,6 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
setupUserRegistrationView
()
setupCasView
()
setupOauthServicesView
()
checkServerInfo
(
currentServer
)
}
fun
authenticateWithUserAndPassword
(
usernameOrEmail
:
String
,
password
:
String
)
{
...
...
@@ -92,25 +90,14 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
doAuthentication
(
TYPE_LOGIN_OAUTH
)
}
fun
authentica
d
eWithDeepLink
(
deepLinkInfo
:
LoginDeepLinkInfo
)
{
fun
authentica
t
eWithDeepLink
(
deepLinkInfo
:
LoginDeepLinkInfo
)
{
val
serverUrl
=
deepLinkInfo
.
url
setupConnectionInfo
(
serverUrl
)
deepLinkUserId
=
deepLinkInfo
.
userId
deepLinkToken
=
deepLinkInfo
.
token
tokenRepository
.
save
(
serverUrl
,
Token
(
deepLinkUserId
,
deepLinkToken
))
launchUI
(
strategy
)
{
try
{
val
version
=
checkServerVersion
(
serverUrl
).
await
()
when
(
version
)
{
is
Version
.
OutOfDateError
->
{
view
.
blockAndAlertNotRequiredVersion
()
}
else
->
doAuthentication
(
TYPE_LOGIN_DEEP_LINK
)
}
}
catch
(
ex
:
Exception
)
{
Timber
.
d
(
ex
,
"Error performing deep link login"
)
}
}
doAuthentication
(
TYPE_LOGIN_DEEP_LINK
)
}
private
fun
setupConnectionInfo
(
serverUrl
:
String
)
{
...
...
@@ -291,7 +278,7 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
private
fun
getOauthClientId
(
listMap
:
List
<
Map
<
String
,
String
>>,
serviceName
:
String
):
String
?
{
return
listMap
.
find
{
map
->
map
.
containsValue
(
serviceName
)
}
?.
get
(
"appId"
)
?.
get
(
"appId"
)
}
private
suspend
fun
saveAccount
(
username
:
String
)
{
...
...
app/src/main/java/chat/rocket/android/authentication/login/presentation/LoginView.kt
View file @
2e6ecfcb
...
...
@@ -4,7 +4,7 @@ import chat.rocket.android.authentication.server.presentation.VersionCheckView
import
chat.rocket.android.core.behaviours.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
interface
LoginView
:
LoadingView
,
MessageView
,
VersionCheckView
{
interface
LoginView
:
LoadingView
,
MessageView
{
/**
* Shows the form view (i.e the username/email and password fields) if it is enabled by the server settings.
...
...
app/src/main/java/chat/rocket/android/authentication/login/ui/LoginFragment.kt
View file @
2e6ecfcb
...
...
@@ -72,7 +72,7 @@ class LoginFragment : Fragment(), LoginView {
}
deepLinkInfo
?.
let
{
presenter
.
authentica
d
eWithDeepLink
(
it
)
presenter
.
authentica
t
eWithDeepLink
(
it
)
}.
ifNull
{
presenter
.
setupView
()
}
...
...
@@ -370,27 +370,6 @@ class LoginFragment : Fragment(), LoginView {
}
}
override
fun
alertNotRecommendedVersion
()
{
ui
{
AlertDialog
.
Builder
(
it
)
.
setMessage
(
getString
(
R
.
string
.
msg_ver_not_recommended
,
BuildConfig
.
RECOMMENDED_SERVER_VERSION
))
.
setPositiveButton
(
R
.
string
.
msg_ok
,
null
)
.
create
()
.
show
()
}
}
override
fun
blockAndAlertNotRequiredVersion
()
{
ui
{
AlertDialog
.
Builder
(
it
)
.
setMessage
(
getString
(
R
.
string
.
msg_ver_not_minimum
,
BuildConfig
.
REQUIRED_SERVER_VERSION
))
.
setOnDismissListener
{
activity
?.
onBackPressed
()
}
.
setPositiveButton
(
R
.
string
.
msg_ok
,
null
)
.
create
()
.
show
()
}
}
private
fun
showRemainingSocialAccountsView
()
{
social_accounts_container
.
postDelayed
(
300
)
{
ui
{
...
...
app/src/main/java/chat/rocket/android/authentication/server/presentation/ServerPresenter.kt
View file @
2e6ecfcb
...
...
@@ -7,9 +7,10 @@ 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.SaveCurrentServerInteractor
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.server.presentation.CheckServerPresenter
import
chat.rocket.android.util.extensions.isValidUrl
import
chat.rocket.android.util.extensions.launchUI
import
chat.rocket.common.util.ifNull
import
javax.inject.Inject
class
ServerPresenter
@Inject
constructor
(
private
val
view
:
ServerView
,
...
...
@@ -17,7 +18,18 @@ class ServerPresenter @Inject constructor(private val view: ServerView,
private
val
navigator
:
AuthenticationNavigator
,
private
val
serverInteractor
:
SaveCurrentServerInteractor
,
private
val
refreshSettingsInteractor
:
RefreshSettingsInteractor
,
private
val
getAccountsInteractor
:
GetAccountsInteractor
)
{
private
val
getAccountsInteractor
:
GetAccountsInteractor
,
factory
:
RocketChatClientFactory
)
:
CheckServerPresenter
(
strategy
,
factory
,
view
)
{
fun
checkServer
(
server
:
String
)
{
if
(!
server
.
isValidUrl
())
{
view
.
showInvalidServerUrlMessage
()
}
else
{
view
.
showLoading
()
checkServerInfo
(
server
)
}
}
fun
connect
(
server
:
String
)
{
connectToServer
(
server
)
{
...
...
@@ -25,7 +37,7 @@ class ServerPresenter @Inject constructor(private val view: ServerView,
}
}
fun
connectToServer
(
server
:
String
,
block
:
()
->
Unit
)
{
private
fun
connectToServer
(
server
:
String
,
block
:
()
->
Unit
)
{
if
(!
server
.
isValidUrl
())
{
view
.
showInvalidServerUrlMessage
()
}
else
{
...
...
app/src/main/java/chat/rocket/android/authentication/server/presentation/ServerView.kt
View file @
2e6ecfcb
...
...
@@ -3,7 +3,7 @@ package chat.rocket.android.authentication.server.presentation
import
chat.rocket.android.core.behaviours.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
interface
ServerView
:
LoadingView
,
MessageView
{
interface
ServerView
:
LoadingView
,
MessageView
,
VersionCheckView
{
/**
* Shows an invalid server URL message.
...
...
app/src/main/java/chat/rocket/android/authentication/server/presentation/VersionCheckView.kt
View file @
2e6ecfcb
...
...
@@ -10,4 +10,9 @@ interface VersionCheckView {
* Block user to proceed and alert him due to server having an unsupported server version.
*/
fun
blockAndAlertNotRequiredVersion
()
/**
* Do some action if version is ok. This is optional.
*/
fun
versionOk
()
{}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/authentication/server/ui/ServerFragment.kt
View file @
2e6ecfcb
package
chat.rocket.android.authentication.server.ui
import
android.app.AlertDialog
import
android.net.Uri
import
android.os.Bundle
import
android.support.v4.app.Fragment
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.view.ViewTreeObserver
import
chat.rocket.android.BuildConfig
import
chat.rocket.android.R
import
chat.rocket.android.authentication.domain.model.LoginDeepLinkInfo
import
chat.rocket.android.authentication.server.presentation.ServerPresenter
import
chat.rocket.android.authentication.server.presentation.ServerView
import
chat.rocket.android.helper.KeyboardHelper
import
chat.rocket.android.util.extensions.*
import
chat.rocket.common.util.ifNull
import
dagger.android.support.AndroidSupportInjection
import
kotlinx.android.synthetic.main.fragment_authentication_server.*
import
javax.inject.Inject
class
ServerFragment
:
Fragment
(),
ServerView
{
@Inject
lateinit
var
presenter
:
ServerPresenter
@Inject
lateinit
var
presenter
:
ServerPresenter
private
var
deepLinkInfo
:
LoginDeepLinkInfo
?
=
null
private
val
layoutListener
=
ViewTreeObserver
.
OnGlobalLayoutListener
{
text_server_url
.
isCursorVisible
=
KeyboardHelper
.
isSoftKeyboardShown
(
relative_layout
.
rootView
)
...
...
@@ -49,6 +54,8 @@ class ServerFragment : Fragment(), ServerView {
setupOnClickListener
()
deepLinkInfo
?.
let
{
val
uri
=
Uri
.
parse
(
it
.
url
)
uri
?.
let
{
text_server_protocol
.
hintContent
=
it
.
host
}
presenter
.
deepLink
(
it
)
}
}
...
...
@@ -74,7 +81,7 @@ class ServerFragment : Fragment(), ServerView {
}
}
override
fun
showMessage
(
resId
:
Int
){
override
fun
showMessage
(
resId
:
Int
)
{
ui
{
showToast
(
resId
)
}
...
...
@@ -90,15 +97,60 @@ class ServerFragment : Fragment(), ServerView {
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
}
override
fun
alertNotRecommendedVersion
()
{
ui
{
hideLoading
()
AlertDialog
.
Builder
(
it
)
.
setMessage
(
getString
(
R
.
string
.
msg_ver_not_recommended
,
BuildConfig
.
RECOMMENDED_SERVER_VERSION
))
.
setPositiveButton
(
R
.
string
.
msg_ok
,
{
_
,
_
->
performConnect
()
})
.
create
()
.
show
()
}
}
override
fun
blockAndAlertNotRequiredVersion
()
{
ui
{
hideLoading
()
AlertDialog
.
Builder
(
it
)
.
setMessage
(
getString
(
R
.
string
.
msg_ver_not_minimum
,
BuildConfig
.
REQUIRED_SERVER_VERSION
))
.
setPositiveButton
(
R
.
string
.
msg_ok
,
null
)
.
setOnDismissListener
{
// reset the deeplink info, so the user can log to another server...
deepLinkInfo
=
null
}
.
create
()
.
show
()
}
}
override
fun
versionOk
()
{
performConnect
()
}
private
fun
performConnect
()
{
ui
{
deepLinkInfo
?.
let
{
presenter
.
deepLink
(
it
)
}.
ifNull
{
val
url
=
text_server_url
.
textContent
.
ifEmpty
(
text_server_url
.
hintContent
)
presenter
.
connect
(
text_server_protocol
.
textContent
+
url
)
}
}
}
private
fun
enableUserInput
(
value
:
Boolean
)
{
button_connect
.
isEnabled
=
value
text_server_url
.
isEnabled
=
value
}
private
fun
setupOnClickListener
()
{
button_connect
.
setOnClickListener
{
val
url
=
text_server_url
.
textContent
.
ifEmpty
(
text_server_url
.
hintContent
)
presenter
.
connect
(
text_server_protocol
.
textContent
+
url
)
ui
{
button_connect
.
setOnClickListener
{
val
url
=
text_server_url
.
textContent
.
ifEmpty
(
text_server_url
.
hintContent
)
presenter
.
checkServer
(
text_server_protocol
.
textContent
+
url
)
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/authentication/ui/AuthenticationActivity.kt
View file @
2e6ecfcb
...
...
@@ -34,7 +34,7 @@ class AuthenticationActivity : AppCompatActivity(), HasSupportFragmentInjector {
val
deepLinkInfo
=
intent
.
getLoginDeepLinkInfo
()
launch
(
UI
+
job
)
{
val
newServer
=
intent
.
getBooleanExtra
(
INTENT_ADD_NEW_SERVER
,
false
)
// if we got authentica
d
eWithDeepLink information, pass true to newServer also
// if we got authentica
t
eWithDeepLink information, pass true to newServer also
presenter
.
loadCredentials
(
newServer
||
deepLinkInfo
!=
null
)
{
authenticated
->
if
(!
authenticated
)
{
showServerInput
(
savedInstanceState
,
deepLinkInfo
)
...
...
app/src/main/java/chat/rocket/android/chatroom/di/ChatRoomFragmentModule.kt
View file @
2e6ecfcb
...
...
@@ -15,9 +15,6 @@ import kotlinx.coroutines.experimental.Job
@PerFragment
class
ChatRoomFragmentModule
{
@Provides
fun
provideChatRoomNavigator
(
activity
:
ChatRoomActivity
)
=
ChatRoomNavigator
(
activity
)
@Provides
fun
chatRoomView
(
frag
:
ChatRoomFragment
):
ChatRoomView
{
return
frag
...
...
app/src/main/java/chat/rocket/android/chatroom/di/ChatRoomModule.kt
0 → 100644
View file @
2e6ecfcb
package
chat.rocket.android.chatroom.di
import
chat.rocket.android.chatroom.presentation.ChatRoomNavigator
import
chat.rocket.android.chatroom.ui.ChatRoomActivity
import
chat.rocket.android.dagger.scope.PerActivity
import
dagger.Module
import
dagger.Provides
@Module
@PerActivity
class
ChatRoomModule
{
@Provides
fun
provideChatRoomNavigator
(
activity
:
ChatRoomActivity
)
=
ChatRoomNavigator
(
activity
)
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomNavigator.kt
View file @
2e6ecfcb
...
...
@@ -3,6 +3,7 @@ package chat.rocket.android.chatroom.presentation
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.ui.ChatRoomActivity
import
chat.rocket.android.members.ui.newInstance
import
chat.rocket.android.server.ui.changeServerIntent
import
chat.rocket.android.util.extensions.addFragmentBackStack
class
ChatRoomNavigator
(
internal
val
activity
:
ChatRoomActivity
)
{
...
...
@@ -12,4 +13,9 @@ class ChatRoomNavigator(internal val activity: ChatRoomActivity) {
newInstance
(
chatRoomId
,
chatRoomType
)
}
}
fun
toNewServer
()
{
activity
.
startActivity
(
activity
.
changeServerIntent
())
activity
.
finish
()
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
2e6ecfcb
...
...
@@ -10,6 +10,7 @@ import chat.rocket.android.chatroom.viewmodel.ViewModelMapper
import
chat.rocket.android.chatroom.viewmodel.suggestion.ChatRoomSuggestionViewModel
import
chat.rocket.android.chatroom.viewmodel.suggestion.CommandSuggestionViewModel
import
chat.rocket.android.chatroom.viewmodel.suggestion.PeopleSuggestionViewModel
import
chat.rocket.android.core.behaviours.showMessage
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.infrastructure.username
...
...
@@ -172,7 +173,7 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
launchUI
(
strategy
)
{
view
.
showLoading
()
try
{
val
fileName
=
async
{
uriInteractor
.
getFileName
(
uri
)
}.
await
()
val
fileName
=
async
{
uriInteractor
.
getFileName
(
uri
)
}.
await
()
?:
uri
.
toString
()
val
mimeType
=
async
{
uriInteractor
.
getMimeType
(
uri
)
}.
await
()
val
fileSize
=
async
{
uriInteractor
.
getFileSize
(
uri
)
}.
await
()
val
maxFileSize
=
settings
.
uploadMaxFileSize
()
...
...
@@ -189,12 +190,11 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
}
}
}
}
catch
(
ex
:
RocketChatException
)
{
Timber
.
d
(
ex
)
ex
.
message
?.
let
{
view
.
showMessage
(
it
)
}.
ifNull
{
view
.
showGenericErrorMessage
()
}
catch
(
ex
:
Exception
)
{
Timber
.
d
(
ex
,
"Error uploading file"
)
when
(
ex
)
{
is
RocketChatException
->
view
.
showMessage
(
ex
)
else
->
view
.
showGenericErrorMessage
()
}
}
finally
{
view
.
hideLoading
()
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomActivity.kt
View file @
2e6ecfcb
...
...
@@ -8,12 +8,14 @@ import android.os.Bundle
import
android.support.v4.app.Fragment
import
android.support.v7.app.AppCompatActivity
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.presentation.ChatRoomNavigator
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import
chat.rocket.android.util.extensions.addFragment
import
chat.rocket.android.util.extensions.textContent
import
chat.rocket.common.model.RoomType
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.util.ifNull
import
dagger.android.AndroidInjection
import
dagger.android.AndroidInjector
import
dagger.android.DispatchingAndroidInjector
...
...
@@ -51,6 +53,7 @@ class ChatRoomActivity : AppCompatActivity(), HasSupportFragmentInjector {
// TODO - workaround for now... We will move to a single activity
@Inject
lateinit
var
serverInteractor
:
GetCurrentServerInteractor
@Inject
lateinit
var
navigator
:
ChatRoomNavigator
@Inject
lateinit
var
managerFactory
:
ConnectionManagerFactory
private
lateinit
var
chatRoomId
:
String
...
...
@@ -66,7 +69,13 @@ class ChatRoomActivity : AppCompatActivity(), HasSupportFragmentInjector {
setContentView
(
R
.
layout
.
activity_chat_room
)
// Workaround for when we are coming to the app via the recents app and the app was killed.
managerFactory
.
create
(
serverInteractor
.
get
()
!!
).
connect
()
val
serverUrl
=
serverInteractor
.
get
()
if
(
serverUrl
!=
null
)
{
managerFactory
.
create
(
serverUrl
).
connect
()
}
else
{
navigator
.
toNewServer
()
return
}
chatRoomId
=
intent
.
getStringExtra
(
INTENT_CHAT_ROOM_ID
)
requireNotNull
(
chatRoomId
)
{
"no chat_room_id provided in Intent extras"
}
...
...
app/src/main/java/chat/rocket/android/dagger/module/ActivityBuilder.kt
View file @
2e6ecfcb
...
...
@@ -8,6 +8,7 @@ import chat.rocket.android.authentication.signup.di.SignupFragmentProvider
import
chat.rocket.android.authentication.twofactor.di.TwoFAFragmentProvider
import
chat.rocket.android.authentication.ui.AuthenticationActivity
import
chat.rocket.android.chatroom.di.ChatRoomFragmentProvider
import
chat.rocket.android.chatroom.di.ChatRoomModule
import
chat.rocket.android.chatroom.di.PinnedMessagesFragmentProvider
import
chat.rocket.android.chatroom.ui.ChatRoomActivity
import
chat.rocket.android.chatroom.ui.PinnedMessagesActivity
...
...
@@ -45,7 +46,9 @@ abstract class ActivityBuilder {
abstract
fun
bindMainActivity
():
MainActivity
@PerActivity
@ContributesAndroidInjector
(
modules
=
[
ChatRoomFragmentProvider
::
class
,
MembersFragmentProvider
::
class
])
@ContributesAndroidInjector
(
modules
=
[
ChatRoomModule
::
class
,
ChatRoomFragmentProvider
::
class
,
MembersFragmentProvider
::
class
])
abstract
fun
bindChatRoomActivity
():
ChatRoomActivity
@PerActivity
...
...
app/src/main/java/chat/rocket/android/profile/presentation/ProfilePresenter.kt
View file @
2e6ecfcb
...
...
@@ -28,14 +28,21 @@ class ProfilePresenter @Inject constructor(private val view: ProfileView,
view
.
showLoading
()
try
{
val
myself
=
retryIO
(
"me"
)
{
client
.
me
()
}
myselfId
=
myself
.
id
!!
val
avatarUrl
=
serverUrl
.
avatarUrl
(
myself
.
username
!!
)
view
.
showProfile
(
avatarUrl
,
myself
.
name
?:
""
,
myself
.
username
?:
""
,
myself
.
emails
?.
get
(
0
)
?.
address
!!
)
val
id
=
myself
.
id
val
username
=
myself
.
username
if
(
id
==
null
||
username
==
null
)
{
view
.
showGenericErrorMessage
()
}
else
{
myselfId
=
id
val
avatarUrl
=
serverUrl
.
avatarUrl
(
username
)
val
email
=
myself
.
emails
?.
getOrNull
(
0
)
?.
address
view
.
showProfile
(
avatarUrl
,
myself
.
name
?:
""
,
myself
.
username
?:
""
,
email
)
}
}
catch
(
exception
:
RocketChatException
)
{
view
.
showMessage
(
exception
)
}
finally
{
...
...
app/src/main/java/chat/rocket/android/profile/presentation/ProfileView.kt
View file @
2e6ecfcb
...
...
@@ -2,7 +2,6 @@ package chat.rocket.android.profile.presentation
import
chat.rocket.android.core.behaviours.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
import
chat.rocket.core.model.Myself
interface
ProfileView
:
LoadingView
,
MessageView
{
...
...
@@ -14,7 +13,7 @@ interface ProfileView : LoadingView, MessageView {
* @param username The user username.
* @param email The user email.
*/
fun
showProfile
(
avatarUrl
:
String
,
name
:
String
,
username
:
String
,
email
:
String
)
fun
showProfile
(
avatarUrl
:
String
,
name
:
String
,
username
:
String
,
email
:
String
?
)
/**
* Shows a profile update successfully message
...
...
app/src/main/java/chat/rocket/android/profile/ui/ProfileFragment.kt
View file @
2e6ecfcb
...
...
@@ -55,18 +55,18 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
super
.
onDestroyView
()
}
override
fun
showProfile
(
avatarUrl
:
String
,
name
:
String
,
username
:
String
,
email
:
String
)
{
override
fun
showProfile
(
avatarUrl
:
String
,
name
:
String
,
username
:
String
,
email
:
String
?
)
{
ui
{
image_avatar
.
setImageURI
(
avatarUrl
)
text_name
.
textContent
=
name
text_username
.
textContent
=
username
text_email
.
textContent
=
email
text_email
.
textContent
=
email
?:
""
text_avatar_url
.
textContent
=
""
currentName
=
name
currentUsername
=
username
currentEmail
=
email
currentEmail
=
email
?:
""
currentAvatar
=
avatarUrl
profile_container
.
setVisible
(
true
)
...
...
app/src/main/java/chat/rocket/android/server/presentation/CheckServerPresenter.kt
View file @
2e6ecfcb
...
...
@@ -18,17 +18,18 @@ abstract class CheckServerPresenter constructor(private val strategy: CancelStra
private
val
factory
:
RocketChatClientFactory
,
private
val
view
:
VersionCheckView
)
{
private
lateinit
var
currentServer
:
String
private
val
client
:
RocketChatClient
by
lazy
{
factory
.
create
(
currentServer
)
}
private
lateinit
var
client
:
RocketChatClient
internal
fun
checkServerInfo
(
serverUrl
:
String
):
Job
{
return
launchUI
(
strategy
)
{
try
{
currentServer
=
serverUrl
client
=
factory
.
create
(
currentServer
)
val
version
=
checkServerVersion
(
serverUrl
).
await
()
when
(
version
)
{
is
Version
.
VersionOk
->
{
Timber
.
i
(
"Your version is nice! (Requires: 0.62.0, Yours: ${version.version})"
)
view
.
versionOk
()
}
is
Version
.
RecommendedVersionWarning
->
{
Timber
.
i
(
"Your server ${version.version} is bellow recommended version ${BuildConfig.RECOMMENDED_SERVER_VERSION}"
)
...
...
app/src/main/java/chat/rocket/android/server/ui/ChangeServerActivity.kt
View file @
2e6ecfcb
...
...
@@ -41,7 +41,7 @@ private const val INTENT_SERVER_URL = "INTENT_SERVER_URL"
private
const
val
INTENT_CHAT_ROOM_NAME
=
"INTENT_CHAT_ROOM_NAME"
private
const
val
INTENT_CHAT_ROOM_TYPE
=
"INTENT_CHAT_ROOM_TYPE"
fun
Context
.
changeServerIntent
(
serverUrl
:
String
?):
Intent
{
fun
Context
.
changeServerIntent
(
serverUrl
:
String
?
=
null
):
Intent
{
return
Intent
(
this
,
ChangeServerActivity
::
class
.
java
).
apply
{
serverUrl
?.
let
{
url
->
putExtra
(
INTENT_SERVER_URL
,
url
)
...
...
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