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
b0d03bea
Unverified
Commit
b0d03bea
authored
Jan 17, 2018
by
Lucio Maciel
Committed by
GitHub
Jan 17, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #705 from RocketChat/feature-2.x/save-login
[NEW] Save login information and server settings
parents
813ede16
130d2bba
Changes
31
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
264 additions
and
43 deletions
+264
-43
build.gradle
app/build.gradle
+15
-3
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+2
-2
AuthenticationModule.kt
.../rocket/android/authentication/di/AuthenticationModule.kt
+10
-0
TokenModel.kt
.../rocket/android/authentication/domain/model/TokenModel.kt
+6
-0
MemoryTokenRepository.kt
...d/authentication/infraestructure/MemoryTokenRepository.kt
+1
-1
SharedPreferencesMultiServerTokenRepository.kt
...estructure/SharedPreferencesMultiServerTokenRepository.kt
+33
-0
TokenMapper.kt
...ket/android/authentication/infraestructure/TokenMapper.kt
+11
-0
LoginPresenter.kt
...droid/authentication/login/presentation/LoginPresenter.kt
+4
-1
AuthenticationNavigator.kt
...id/authentication/presentation/AuthenticationNavigator.kt
+2
-2
AuthenticationPresenter.kt
...id/authentication/presentation/AuthenticationPresenter.kt
+29
-0
AuthenticationView.kt
...android/authentication/presentation/AuthenticationView.kt
+5
-0
TwoFAPresenter.kt
...d/authentication/twofactor/presentation/TwoFAPresenter.kt
+5
-1
AuthenticationActivity.kt
...ocket/android/authentication/ui/AuthenticationActivity.kt
+20
-6
ChatRoomsModule.kt
.../java/chat/rocket/android/chatrooms/di/ChatRoomsModule.kt
+2
-2
ChatRoomsNavigator.kt
...cket/android/chatrooms/presentation/ChatRoomsNavigator.kt
+2
-2
ChatRoomsPresenter.kt
...cket/android/chatrooms/presentation/ChatRoomsPresenter.kt
+4
-0
ChatRoomsActivity.kt
...ava/chat/rocket/android/chatrooms/ui/ChatRoomsActivity.kt
+6
-2
ChatRoomsFragment.kt
...ava/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
+7
-0
ActivityBuilder.kt
...java/chat/rocket/android/dagger/module/ActivityBuilder.kt
+2
-2
AppModule.kt
.../main/java/chat/rocket/android/dagger/module/AppModule.kt
+17
-8
PushManager.kt
app/src/main/java/chat/rocket/android/push/PushManager.kt
+2
-2
MultiServerTokenRepository.kt
...ocket/android/server/domain/MultiServerTokenRepository.kt
+9
-0
RocketChatClientFactory.kt
...android/server/infraestructure/RocketChatClientFactory.kt
+2
-2
SharedPreferencesSettingsRepository.kt
...er/infraestructure/SharedPreferencesSettingsRepository.kt
+28
-0
SharedPrefsCurrentServerRepository.kt
...ver/infraestructure/SharedPrefsCurrentServerRepository.kt
+5
-3
AppJsonAdapterFactory.kt
...in/java/chat/rocket/android/util/AppJsonAdapterFactory.kt
+11
-0
splash_screen.xml
app/src/main/res/drawable/splash_screen.xml
+14
-0
activity_chat_rooms.xml
app/src/main/res/layout/activity_chat_rooms.xml
+1
-1
styles.xml
app/src/main/res/values/styles.xml
+5
-0
circle.yml
circle.yml
+2
-2
dependencies.gradle
dependencies.gradle
+2
-1
No files found.
app/build.gradle
View file @
b0d03bea
...
...
@@ -11,16 +11,27 @@ android {
applicationId
"chat.rocket.android"
minSdkVersion
21
targetSdkVersion
versions
.
targetSdk
versionCode
1
versionName
"2.0.0-
beta
1"
versionCode
1
001
versionName
"2.0.0-
dev
1"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled
true
}
signingConfigs
{
release
{
storeFile
project
.
rootProject
.
file
(
'Rocket.jks'
).
getCanonicalFile
()
storePassword
System
.
getenv
(
"KEYSTORE_PASSWORD"
)
keyAlias
System
.
getenv
(
"KEY_ALIAS"
)
keyPassword
System
.
getenv
(
"KEY_PASSWORD"
)
}
}
buildTypes
{
release
{
signingConfig
signingConfigs
.
release
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
),
'proguard-rules.pro'
applicationIdSuffix
".dev"
}
debug
{
...
...
@@ -75,7 +86,8 @@ dependencies {
implementation
libraries
.
frescoImageViewer
implementation
libraries
.
kotshi
kapt
libraries
.
kotshiCompiler
implementation
libraries
.
kotshiApi
implementation
libraries
.
floatingSearchView
...
...
app/src/main/AndroidManifest.xml
View file @
b0d03bea
...
...
@@ -26,7 +26,7 @@
android:name=
".authentication.ui.AuthenticationActivity"
android:configChanges=
"orientation"
android:screenOrientation=
"portrait"
android:theme=
"@style/A
uthenticationTheme
"
android:theme=
"@style/A
ppTheme.SplashScreen
"
android:windowSoftInputMode=
"adjustResize"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
...
...
@@ -41,7 +41,7 @@
android:theme=
"@style/AppTheme"
/>
<activity
android:name=
".chatrooms.ui.
Main
Activity"
android:name=
".chatrooms.ui.
ChatRooms
Activity"
android:theme=
"@style/ChatListTheme"
/>
<activity
...
...
app/src/main/java/chat/rocket/android/authentication/di/AuthenticationModule.kt
View file @
b0d03bea
package
chat.rocket.android.authentication.di
import
android.content.Context
import
chat.rocket.android.authentication.infraestructure.SharedPreferencesMultiServerTokenRepository
import
chat.rocket.android.authentication.presentation.AuthenticationNavigator
import
chat.rocket.android.authentication.ui.AuthenticationActivity
import
chat.rocket.android.dagger.scope.PerActivity
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.MultiServerTokenRepository
import
com.squareup.moshi.Moshi
import
dagger.Module
import
dagger.Provides
...
...
@@ -13,4 +17,10 @@ class AuthenticationModule {
@Provides
@PerActivity
fun
provideAuthenticationNavigator
(
activity
:
AuthenticationActivity
,
context
:
Context
)
=
AuthenticationNavigator
(
activity
,
context
)
@Provides
@PerActivity
fun
provideMultiServerTokenRepository
(
repository
:
LocalRepository
,
moshi
:
Moshi
):
MultiServerTokenRepository
{
return
SharedPreferencesMultiServerTokenRepository
(
repository
,
moshi
)
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/authentication/domain/model/TokenModel.kt
0 → 100644
View file @
b0d03bea
package
chat.rocket.android.authentication.domain.model
import
se.ansman.kotshi.JsonSerializable
@JsonSerializable
data class
TokenModel
(
val
userId
:
String
,
val
authToken
:
String
)
\ No newline at end of file
app/src/main/java/chat/rocket/android/authentication/infraestructure/
Auth
TokenRepository.kt
→
app/src/main/java/chat/rocket/android/authentication/infraestructure/
Memory
TokenRepository.kt
View file @
b0d03bea
...
...
@@ -3,7 +3,7 @@ package chat.rocket.android.authentication.infraestructure
import
chat.rocket.common.model.Token
import
chat.rocket.core.TokenRepository
class
Auth
TokenRepository
:
TokenRepository
{
class
Memory
TokenRepository
:
TokenRepository
{
var
savedToken
:
Token
?
=
null
override
fun
get
():
Token
?
{
...
...
app/src/main/java/chat/rocket/android/authentication/infraestructure/SharedPreferencesMultiServerTokenRepository.kt
0 → 100644
View file @
b0d03bea
package
chat.rocket.android.authentication.infraestructure
import
chat.rocket.android.authentication.domain.model.TokenModel
import
chat.rocket.android.dagger.scope.PerActivity
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.MultiServerTokenRepository
import
com.squareup.moshi.Moshi
@PerActivity
class
SharedPreferencesMultiServerTokenRepository
(
private
val
repository
:
LocalRepository
,
private
val
moshi
:
Moshi
)
:
MultiServerTokenRepository
{
override
fun
get
(
server
:
String
):
TokenModel
?
{
val
token
=
repository
.
get
(
"$TOKEN_KEY$server"
)
val
adapter
=
moshi
.
adapter
<
TokenModel
>(
TokenModel
::
class
.
java
)
token
?.
let
{
return
adapter
.
fromJson
(
token
)
}
return
null
}
override
fun
save
(
server
:
String
,
token
:
TokenModel
)
{
val
adapter
=
moshi
.
adapter
<
TokenModel
>(
TokenModel
::
class
.
java
)
repository
.
save
(
"$TOKEN_KEY$server"
,
adapter
.
toJson
(
token
))
}
}
const
val
TOKEN_KEY
=
"token_"
\ No newline at end of file
app/src/main/java/chat/rocket/android/authentication/infraestructure/TokenMapper.kt
0 → 100644
View file @
b0d03bea
package
chat.rocket.android.authentication.infraestructure
import
chat.rocket.android.authentication.domain.model.TokenModel
import
chat.rocket.android.util.DataToDomain
import
chat.rocket.common.model.Token
object
TokenMapper
:
DataToDomain
<
Token
,
TokenModel
>
{
override
fun
translate
(
data
:
Token
):
TokenModel
{
return
TokenModel
(
data
.
userId
,
data
.
authToken
)
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/authentication/login/presentation/LoginPresenter.kt
View file @
b0d03bea
package
chat.rocket.android.authentication.login.presentation
import
chat.rocket.android.authentication.domain.model.TokenModel
import
chat.rocket.android.authentication.presentation.AuthenticationNavigator
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.helper.NetworkHelper
...
...
@@ -18,6 +19,7 @@ import javax.inject.Inject
class
LoginPresenter
@Inject
constructor
(
private
val
view
:
LoginView
,
private
val
strategy
:
CancelStrategy
,
private
val
navigator
:
AuthenticationNavigator
,
private
val
multiServerRepository
:
MultiServerTokenRepository
,
private
val
localRepository
:
LocalRepository
,
private
val
settingsInteractor
:
GetSettingsInteractor
,
private
val
serverInteractor
:
GetCurrentServerInteractor
,
...
...
@@ -90,7 +92,8 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
view
.
showLoading
()
try
{
client
.
login
(
usernameOrEmail
,
password
)
// TODO This function returns a user token so should we save it?
val
token
=
client
.
login
(
usernameOrEmail
,
password
)
multiServerRepository
.
save
(
server
,
TokenModel
(
token
.
userId
,
token
.
authToken
))
registerPushToken
()
navigator
.
toChatList
()
}
catch
(
exception
:
RocketChatException
)
{
...
...
app/src/main/java/chat/rocket/android/authentication/presentation/AuthenticationNavigator.kt
View file @
b0d03bea
...
...
@@ -7,7 +7,7 @@ import chat.rocket.android.authentication.login.ui.LoginFragment
import
chat.rocket.android.authentication.signup.ui.SignupFragment
import
chat.rocket.android.authentication.twofactor.ui.TwoFAFragment
import
chat.rocket.android.authentication.ui.AuthenticationActivity
import
chat.rocket.android.chatrooms.ui.
Main
Activity
import
chat.rocket.android.chatrooms.ui.
ChatRooms
Activity
import
chat.rocket.android.util.addFragmentBackStack
import
chat.rocket.android.webview.webViewIntent
...
...
@@ -36,7 +36,7 @@ class AuthenticationNavigator(internal val activity: AuthenticationActivity, int
}
fun
toChatList
()
{
val
chatList
=
Intent
(
activity
,
Main
Activity
::
class
.
java
).
apply
{
val
chatList
=
Intent
(
activity
,
ChatRooms
Activity
::
class
.
java
).
apply
{
//TODO any parameter to pass
}
activity
.
startActivity
(
chatList
)
...
...
app/src/main/java/chat/rocket/android/authentication/presentation/AuthenticationPresenter.kt
0 → 100644
View file @
b0d03bea
package
chat.rocket.android.authentication.presentation
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.MultiServerTokenRepository
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.common.model.Token
import
chat.rocket.core.TokenRepository
import
javax.inject.Inject
class
AuthenticationPresenter
@Inject
constructor
(
private
val
navigator
:
AuthenticationNavigator
,
private
val
getCurrentServerInteractor
:
GetCurrentServerInteractor
,
private
val
multiServerRepository
:
MultiServerTokenRepository
,
private
val
settingsRepository
:
SettingsRepository
,
private
val
tokenRepository
:
TokenRepository
)
{
fun
loadCredentials
(
callback
:
(
authenticated
:
Boolean
)
->
Unit
)
{
val
currentServer
=
getCurrentServerInteractor
.
get
()
val
serverToken
=
currentServer
?.
let
{
multiServerRepository
.
get
(
currentServer
)
}
val
settings
=
currentServer
?.
let
{
settingsRepository
.
get
(
currentServer
)
}
if
(
currentServer
==
null
||
serverToken
==
null
||
settings
==
null
)
{
callback
(
false
)
}
else
{
tokenRepository
.
save
(
Token
(
serverToken
.
userId
,
serverToken
.
authToken
))
callback
(
true
)
navigator
.
toChatList
()
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/authentication/presentation/AuthenticationView.kt
0 → 100644
View file @
b0d03bea
package
chat.rocket.android.authentication.presentation
interface
AuthenticationView
{
fun
showServerInput
()
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/authentication/twofactor/presentation/TwoFAPresenter.kt
View file @
b0d03bea
package
chat.rocket.android.authentication.twofactor.presentation
import
chat.rocket.android.authentication.domain.model.TokenModel
import
chat.rocket.android.authentication.presentation.AuthenticationNavigator
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.helper.NetworkHelper
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.MultiServerTokenRepository
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.launchUI
import
chat.rocket.common.RocketChatAuthException
...
...
@@ -18,6 +20,7 @@ import javax.inject.Inject
class
TwoFAPresenter
@Inject
constructor
(
private
val
view
:
TwoFAView
,
private
val
strategy
:
CancelStrategy
,
private
val
navigator
:
AuthenticationNavigator
,
private
val
multiServerRepository
:
MultiServerTokenRepository
,
private
val
localRepository
:
LocalRepository
,
private
val
serverInteractor
:
GetCurrentServerInteractor
,
private
val
factory
:
RocketChatClientFactory
)
{
...
...
@@ -40,7 +43,8 @@ class TwoFAPresenter @Inject constructor(private val view: TwoFAView,
view
.
showLoading
()
try
{
// The token is saved via the client TokenProvider
client
.
login
(
usernameOrEmail
,
password
,
twoFactorAuthenticationCode
)
val
token
=
client
.
login
(
usernameOrEmail
,
password
,
twoFactorAuthenticationCode
)
multiServerRepository
.
save
(
server
,
TokenModel
(
token
.
userId
,
token
.
authToken
))
registerPushToken
()
navigator
.
toChatList
()
}
catch
(
exception
:
RocketChatException
)
{
...
...
app/src/main/java/chat/rocket/android/authentication/ui/AuthenticationActivity.kt
View file @
b0d03bea
...
...
@@ -4,6 +4,7 @@ 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.authentication.presentation.AuthenticationPresenter
import
chat.rocket.android.authentication.server.ui.ServerFragment
import
chat.rocket.android.util.addFragment
import
dagger.android.AndroidInjection
...
...
@@ -14,19 +15,32 @@ import javax.inject.Inject
class
AuthenticationActivity
:
AppCompatActivity
(),
HasSupportFragmentInjector
{
@Inject
lateinit
var
fragmentDispatchingAndroidInjector
:
DispatchingAndroidInjector
<
Fragment
>
@Inject
lateinit
var
presenter
:
AuthenticationPresenter
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_authentication
)
AndroidInjection
.
inject
(
this
)
addFragment
(
"ServerFragment"
,
R
.
id
.
fragment_container
)
{
ServerFragment
.
newInstance
()
presenter
.
loadCredentials
{
authenticated
->
if
(
authenticated
)
{
// just call onCreate, and the presenter will call the navigator...
super
.
onCreate
(
savedInstanceState
)
}
else
{
showServerInput
(
savedInstanceState
)
}
}
}
override
fun
supportFragmentInjector
():
AndroidInjector
<
Fragment
>
{
return
fragmentDispatchingAndroidInjector
}
fun
showServerInput
(
savedInstanceState
:
Bundle
?)
{
setContentView
(
R
.
layout
.
activity_authentication
)
setTheme
(
R
.
style
.
AuthenticationTheme
)
super
.
onCreate
(
savedInstanceState
)
addFragment
(
"ServerFragment"
,
R
.
id
.
fragment_container
)
{
ServerFragment
.
newInstance
()
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatrooms/di/ChatRoomsModule.kt
View file @
b0d03bea
...
...
@@ -2,7 +2,7 @@ package chat.rocket.android.chatrooms.di
import
android.content.Context
import
chat.rocket.android.chatrooms.presentation.ChatRoomsNavigator
import
chat.rocket.android.chatrooms.ui.
Main
Activity
import
chat.rocket.android.chatrooms.ui.
ChatRooms
Activity
import
chat.rocket.android.dagger.scope.PerActivity
import
dagger.Module
import
dagger.Provides
...
...
@@ -12,5 +12,5 @@ class ChatRoomsModule {
@Provides
@PerActivity
fun
provideAuthenticationNavigator
(
activity
:
Main
Activity
,
context
:
Context
)
=
ChatRoomsNavigator
(
activity
,
context
)
fun
provideAuthenticationNavigator
(
activity
:
ChatRooms
Activity
,
context
:
Context
)
=
ChatRoomsNavigator
(
activity
,
context
)
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatrooms/presentation/ChatRoomsNavigator.kt
View file @
b0d03bea
...
...
@@ -3,9 +3,9 @@ package chat.rocket.android.chatrooms.presentation
import
android.content.Context
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.ui.chatRoomIntent
import
chat.rocket.android.chatrooms.ui.
Main
Activity
import
chat.rocket.android.chatrooms.ui.
ChatRooms
Activity
class
ChatRoomsNavigator
(
private
val
activity
:
Main
Activity
,
private
val
context
:
Context
)
{
class
ChatRoomsNavigator
(
private
val
activity
:
ChatRooms
Activity
,
private
val
context
:
Context
)
{
fun
toChatRoom
(
chatRoomId
:
String
,
chatRoomName
:
String
,
chatRoomType
:
String
,
isChatRoomReadOnly
:
Boolean
)
{
activity
.
startActivity
(
context
.
chatRoomIntent
(
chatRoomId
,
chatRoomName
,
chatRoomType
,
isChatRoomReadOnly
))
...
...
app/src/main/java/chat/rocket/android/chatrooms/presentation/ChatRoomsPresenter.kt
View file @
b0d03bea
...
...
@@ -241,4 +241,8 @@ class ChatRoomsPresenter @Inject constructor(private val view: ChatRoomsView,
}
saveChatRoomsInteractor
.
save
(
currentServer
,
sortRooms
(
chatRooms
))
}
fun
disconnect
()
{
client
.
disconnect
()
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatrooms/ui/
Main
Activity.kt
→
app/src/main/java/chat/rocket/android/chatrooms/ui/
ChatRooms
Activity.kt
View file @
b0d03bea
...
...
@@ -11,19 +11,23 @@ import dagger.android.DispatchingAndroidInjector
import
dagger.android.support.HasSupportFragmentInjector
import
javax.inject.Inject
class
Main
Activity
:
AppCompatActivity
(),
HasSupportFragmentInjector
{
class
ChatRooms
Activity
:
AppCompatActivity
(),
HasSupportFragmentInjector
{
@Inject
lateinit
var
fragmentDispatchingAndroidInjector
:
DispatchingAndroidInjector
<
Fragment
>
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
AndroidInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_
main
)
setContentView
(
R
.
layout
.
activity_
chat_rooms
)
addFragment
(
"ChatRoomsFragment"
,
R
.
id
.
fragment_container
)
{
ChatRoomsFragment
.
newInstance
()
}
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
}
override
fun
supportFragmentInjector
():
AndroidInjector
<
Fragment
>
{
return
fragmentDispatchingAndroidInjector
}
...
...
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
View file @
b0d03bea
...
...
@@ -22,6 +22,7 @@ import kotlinx.coroutines.experimental.CommonPool
import
kotlinx.coroutines.experimental.android.UI
import
kotlinx.coroutines.experimental.async
import
kotlinx.coroutines.experimental.launch
import
timber.log.Timber
import
javax.inject.Inject
class
ChatRoomsFragment
:
Fragment
(),
ChatRoomsView
{
...
...
@@ -39,6 +40,12 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
setHasOptionsMenu
(
true
)
}
override
fun
onDestroy
()
{
Timber
.
d
(
"Called on destroy..."
)
presenter
.
disconnect
()
super
.
onDestroy
()
}
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
=
inflater
.
inflate
(
R
.
layout
.
fragment_chat_rooms
,
container
,
false
)
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
...
...
app/src/main/java/chat/rocket/android/dagger/module/ActivityBuilder.kt
View file @
b0d03bea
...
...
@@ -10,7 +10,7 @@ import chat.rocket.android.chatroom.di.ChatRoomFragmentProvider
import
chat.rocket.android.chatroom.ui.ChatRoomActivity
import
chat.rocket.android.chatrooms.di.ChatRoomsFragmentProvider
import
chat.rocket.android.chatrooms.di.ChatRoomsModule
import
chat.rocket.android.chatrooms.ui.
Main
Activity
import
chat.rocket.android.chatrooms.ui.
ChatRooms
Activity
import
chat.rocket.android.dagger.scope.PerActivity
import
dagger.Module
import
dagger.android.ContributesAndroidInjector
...
...
@@ -29,7 +29,7 @@ abstract class ActivityBuilder {
@PerActivity
@ContributesAndroidInjector
(
modules
=
[
ChatRoomsModule
::
class
,
ChatRoomsFragmentProvider
::
class
])
abstract
fun
bindMainActivity
():
Main
Activity
abstract
fun
bindMainActivity
():
ChatRooms
Activity
@PerActivity
@ContributesAndroidInjector
(
modules
=
[
ChatRoomFragmentProvider
::
class
])
...
...
app/src/main/java/chat/rocket/android/dagger/module/AppModule.kt
View file @
b0d03bea
...
...
@@ -6,19 +6,22 @@ import android.content.Context
import
android.content.SharedPreferences
import
chat.rocket.android.BuildConfig
import
chat.rocket.android.app.RocketChatDatabase
import
chat.rocket.android.authentication.infraestructure.
Auth
TokenRepository
import
chat.rocket.android.authentication.infraestructure.
Memory
TokenRepository
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.infrastructure.SharedPrefsLocalRepository
import
chat.rocket.android.server.domain.ChatRoomsRepository
import
chat.rocket.android.server.domain.CurrentServerRepository
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.android.server.infraestructure.MemoryChatRoomsRepository
import
chat.rocket.android.server.infraestructure.MemorySettingsRepository
import
chat.rocket.android.server.infraestructure.ServerDao
import
chat.rocket.android.server.infraestructure.SharedPreferencesSettingsRepository
import
chat.rocket.android.server.infraestructure.SharedPrefsCurrentServerRepository
import
chat.rocket.android.util.AppJsonAdapterFactory
import
chat.rocket.android.util.TimberLogger
import
chat.rocket.common.util.PlatformLogger
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.TokenRepository
import
com.squareup.moshi.Moshi
import
dagger.Module
import
dagger.Provides
import
kotlinx.coroutines.experimental.Job
...
...
@@ -31,7 +34,7 @@ class AppModule {
@Provides
@Singleton
fun
provideRocketChatClient
(
okHttpClient
:
OkHttpClient
,
repository
:
Auth
TokenRepository
,
logger
:
PlatformLogger
):
RocketChatClient
{
fun
provideRocketChatClient
(
okHttpClient
:
OkHttpClient
,
repository
:
TokenRepository
,
logger
:
PlatformLogger
):
RocketChatClient
{
return
RocketChatClient
.
create
{
httpClient
=
okHttpClient
tokenRepository
=
repository
...
...
@@ -88,8 +91,8 @@ class AppModule {
@Provides
@Singleton
fun
provide
AuthTokenRepository
():
Auth
TokenRepository
{
return
Auth
TokenRepository
()
fun
provide
TokenRepository
():
TokenRepository
{
return
Memory
TokenRepository
()
}
@Provides
...
...
@@ -105,7 +108,7 @@ class AppModule {
@Provides
@Singleton
fun
provide
SharedPreferences
Repository
(
prefs
:
SharedPreferences
):
LocalRepository
{
fun
provide
Local
Repository
(
prefs
:
SharedPreferences
):
LocalRepository
{
return
SharedPrefsLocalRepository
(
prefs
)
}
...
...
@@ -117,8 +120,8 @@ class AppModule {
@Provides
@Singleton
fun
provideSettingsRepository
():
SettingsRepository
{
return
MemorySettingsRepository
(
)
fun
provideSettingsRepository
(
localRepository
:
LocalRepository
):
SettingsRepository
{
return
SharedPreferencesSettingsRepository
(
localRepository
)
}
@Provides
...
...
@@ -126,4 +129,10 @@ class AppModule {
fun
provideChatRoomsRepository
():
ChatRoomsRepository
{
return
MemoryChatRoomsRepository
()
}
@Provides
@Singleton
fun
provideMoshi
():
Moshi
{
return
Moshi
.
Builder
().
add
(
AppJsonAdapterFactory
.
INSTANCE
).
build
()
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/push/PushManager.kt
View file @
b0d03bea
...
...
@@ -20,7 +20,7 @@ import android.text.Spanned
import
android.util.Log
import
chat.rocket.android.BuildConfig
import
chat.rocket.android.R
import
chat.rocket.android.chatrooms.ui.
Main
Activity
import
chat.rocket.android.chatrooms.ui.
ChatRooms
Activity
import
org.json.JSONObject
import
java.io.Serializable
import
java.util.*
...
...
@@ -455,7 +455,7 @@ object PushManager {
}
private
fun
getContentIntent
(
context
:
Context
,
notificationId
:
Int
,
pushMessage
:
PushMessage
,
grouped
:
Boolean
=
false
):
PendingIntent
{
val
notificationIntent
=
Intent
(
context
,
Main
Activity
::
class
.
java
)
val
notificationIntent
=
Intent
(
context
,
ChatRooms
Activity
::
class
.
java
)
.
addFlags
(
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
or
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
)
.
putExtra
(
EXTRA_NOT_ID
,
notificationId
)
.
putExtra
(
EXTRA_HOSTNAME
,
pushMessage
.
host
)
...
...
app/src/main/java/chat/rocket/android/server/domain/MultiServerTokenRepository.kt
0 → 100644
View file @
b0d03bea
package
chat.rocket.android.server.domain
import
chat.rocket.android.authentication.domain.model.TokenModel
interface
MultiServerTokenRepository
{
fun
get
(
server
:
String
):
TokenModel
?
fun
save
(
server
:
String
,
token
:
TokenModel
)
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/server/infraestructure/RocketChatClientFactory.kt
View file @
b0d03bea
package
chat.rocket.android.server.infraestructure
import
chat.rocket.android.authentication.infraestructure.AuthTokenRepository
import
chat.rocket.common.util.PlatformLogger
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.TokenRepository
import
okhttp3.OkHttpClient
import
timber.log.Timber
import
javax.inject.Inject
...
...
@@ -10,7 +10,7 @@ import javax.inject.Singleton
@Singleton
class
RocketChatClientFactory
@Inject
constructor
(
val
okHttpClient
:
OkHttpClient
,
val
repository
:
Auth
TokenRepository
,
val
repository
:
TokenRepository
,
val
logger
:
PlatformLogger
)
{
private
val
cache
=
HashMap
<
String
,
RocketChatClient
>()
...
...
app/src/main/java/chat/rocket/android/server/infraestructure/
Memory
SettingsRepository.kt
→
app/src/main/java/chat/rocket/android/server/infraestructure/
SharedPreferences
SettingsRepository.kt
View file @
b0d03bea
package
chat.rocket.android.server.infraestructure
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.core.internal.SettingsAdapter
import
chat.rocket.core.model.Value
class
MemorySettingsRepository
:
SettingsRepository
{
class
SharedPreferencesSettingsRepository
(
private
val
localRespository
:
LocalRepository
)
:
SettingsRepository
{
val
cache
=
HashMap
<
String
,
Map
<
String
,
Value
<
Any
>>>
()
private
val
adapter
=
SettingsAdapter
()
override
fun
save
(
url
:
String
,
settings
:
Map
<
String
,
Value
<
Any
>>)
{
cache
.
put
(
url
,
settings
)
localRespository
.
save
(
"$SETTINGS_KEY$url"
,
adapter
.
toJson
(
settings
)
)
}
override
fun
get
(
url
:
String
):
Map
<
String
,
Value
<
Any
>>?
{
return
cache
[
url
]
val
settings
=
localRespository
.
get
(
"$SETTINGS_KEY$url"
)
settings
?.
let
{
return
adapter
.
fromJson
(
it
)
}
return
null
}
companion
object
{
private
const
val
SETTINGS_KEY
=
"settings_"
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/server/infraestructure/SharedPrefsCurrentServerRepository.kt
View file @
b0d03bea
...
...
@@ -4,14 +4,16 @@ import android.content.SharedPreferences
import
chat.rocket.android.server.domain.CurrentServerRepository
class
SharedPrefsCurrentServerRepository
(
private
val
preferences
:
SharedPreferences
)
:
CurrentServerRepository
{
private
val
CURRENT_SERVER
=
"current_server"
override
fun
save
(
url
:
String
)
{
preferences
.
edit
().
putString
(
CURRENT_SERVER
,
url
).
apply
()
preferences
.
edit
().
putString
(
CURRENT_SERVER
_KEY
,
url
).
apply
()
}
override
fun
get
():
String
?
{
return
preferences
.
getString
(
CURRENT_SERVER
,
null
)
return
preferences
.
getString
(
CURRENT_SERVER
_KEY
,
null
)
}
companion
object
{
private
const
val
CURRENT_SERVER_KEY
=
"current_server"
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/util/AppJsonAdapterFactory.kt
0 → 100644
View file @
b0d03bea
package
chat.rocket.android.util
import
com.squareup.moshi.JsonAdapter
import
se.ansman.kotshi.KotshiJsonAdapterFactory
@KotshiJsonAdapterFactory
abstract
class
AppJsonAdapterFactory
:
JsonAdapter
.
Factory
{
companion
object
{
val
INSTANCE
:
AppJsonAdapterFactory
=
KotshiAppJsonAdapterFactory
()
}
}
app/src/main/res/drawable/splash_screen.xml
0 → 100644
View file @
b0d03bea
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item>
<color
android:color=
"@color/colorPrimary"
/>
</item>
<!--<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher"/>
</item>-->
</layer-list>
\ No newline at end of file
app/src/main/res/layout/activity_
main
.xml
→
app/src/main/res/layout/activity_
chat_rooms
.xml
View file @
b0d03bea
...
...
@@ -4,7 +4,7 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:theme=
"@style/ChatListTheme"
tools:context=
".chatrooms.ui.
Main
Activity"
>
tools:context=
".chatrooms.ui.
ChatRooms
Activity"
>
<FrameLayout
android:id=
"@+id/fragment_container"
...
...
app/src/main/res/values/styles.xml
View file @
b0d03bea
...
...
@@ -9,8 +9,13 @@
<item
name=
"android:statusBarColor"
>
@color/colorPrimaryDark
</item>
</style>
<style
name=
"AppTheme.SplashScreen"
parent=
"AppTheme"
>
<item
name=
"android:windowBackground"
>
@drawable/splash_screen
</item>
</style>
<style
name=
"AuthenticationTheme"
parent=
"Theme.AppCompat.NoActionBar"
>
<item
name=
"android:statusBarColor"
>
@color/colorPrimaryDark
</item>
<item
name=
"android:windowBackground"
>
@color/colorPrimary
</item>
</style>
<style
name=
"ChatListTheme"
parent=
"AppTheme"
>
...
...
circle.yml
View file @
b0d03bea
...
...
@@ -7,8 +7,8 @@
machine
:
environment
:
ANDROID_HOME
:
/usr/local/android-sdk-linux
GRADLE_OPTS
:
'
-Xmx1
024m
-Dorg.gradle.jvmargs="-Xmx1024m
-XX:MaxPermSize=512m
-XX:+HeapDumpOnOutOfMemoryError"'
JAVA_OPTS
:
"
-Xms518m
-Xmx1
024m
"
GRADLE_OPTS
:
'
-Xmx1
536M
-Dorg.gradle.jvmargs="-Xmx1536M
-XX:MaxPermSize=512m
-XX:+HeapDumpOnOutOfMemoryError"'
JAVA_OPTS
:
"
-Xms518m
-Xmx1
536M
"
pre
:
-
git clone https://github.com/RocketChat/Rocket.Chat.Kotlin.SDK.git Rocket.Chat.Kotlin.SDK
...
...
dependencies.gradle
View file @
b0d03bea
...
...
@@ -77,7 +77,8 @@ ext {
frescoImageViewer
:
"com.github.stfalcon:frescoimageviewer:${versions.frescoImageViewer}"
,
kotshi
:
"se.ansman.kotshi:api:${versions.kotshi}"
,
kotshiApi
:
"se.ansman.kotshi:api:${versions.kotshi}"
,
kotshiCompiler
:
"se.ansman.kotshi:compiler:${versions.kotshi}"
,
floatingSearchView
:
"com.github.arimorty:floatingsearchview:${versions.floatingSearchView}"
,
...
...
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