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
49c0e63b
Commit
49c0e63b
authored
Nov 27, 2017
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly logging-out user
parent
c9342bf7
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
55 additions
and
40 deletions
+55
-40
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+2
-5
MainContract.java
.../main/java/chat/rocket/android/activity/MainContract.java
+1
-1
MainPresenter.java
...main/java/chat/rocket/android/activity/MainPresenter.java
+3
-1
SidebarMainContract.java
.../rocket/android/fragment/sidebar/SidebarMainContract.java
+2
-2
SidebarMainFragment.java
.../rocket/android/fragment/sidebar/SidebarMainFragment.java
+5
-15
SidebarMainPresenter.java
...rocket/android/fragment/sidebar/SidebarMainPresenter.java
+34
-14
RealmBasedConnectivityManager.java
...rocket/android/service/RealmBasedConnectivityManager.java
+6
-2
RocketChatWebSocketThread.java
...hat/rocket/android/service/RocketChatWebSocketThread.java
+2
-0
No files found.
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
49c0e63b
...
...
@@ -347,15 +347,12 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
@DebugLog
public
void
onLogout
()
{
presenter
.
prepareToLogout
();
if
(
new
RocketChatCache
(
getApplicationContext
()).
getSelectedServerHostname
()
==
null
)
{
finish
();
LaunchUtil
.
showMainActivity
(
this
);
}
else
{
onHostnameUpdated
();
}
}
@DebugLog
public
void
beforeLogoutCleanUp
()
{
presenter
.
beforeLogoutCleanUp
();
}
}
app/src/main/java/chat/rocket/android/activity/MainContract.java
View file @
49c0e63b
...
...
@@ -40,6 +40,6 @@ public interface MainContract {
void
loadSignedInServers
(
String
hostname
);
void
beforeLogoutCleanUp
();
void
prepareToLogout
();
}
}
app/src/main/java/chat/rocket/android/activity/MainPresenter.java
View file @
49c0e63b
...
...
@@ -28,6 +28,7 @@ import chat.rocket.core.models.Session;
import
chat.rocket.core.models.User
;
import
chat.rocket.core.repositories.PublicSettingRepository
;
import
chat.rocket.core.utils.Pair
;
import
hugo.weaving.DebugLog
;
import
io.reactivex.Flowable
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.disposables.Disposable
;
...
...
@@ -133,8 +134,9 @@ public class MainPresenter extends BasePresenter<MainContract.View>
addSubscription
(
subscription
);
}
@DebugLog
@Override
public
void
beforeLogoutCleanUp
()
{
public
void
prepareToLogout
()
{
clearSubscriptions
();
}
...
...
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainContract.java
View file @
49c0e63b
...
...
@@ -25,7 +25,7 @@ public interface SidebarMainContract {
void
show
(
User
user
);
void
on
LogoutCleanUp
();
void
on
PreparedToLogOut
();
}
interface
Presenter
extends
BaseContract
.
Presenter
<
View
>
{
...
...
@@ -48,6 +48,6 @@ public interface SidebarMainContract {
void
onLogout
(
Continuation
<
Void
,
Object
>
continuation
);
void
beforeLogoutCleanUp
();
void
prepareToLogOut
();
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainFragment.java
View file @
49c0e63b
...
...
@@ -22,7 +22,6 @@ import java.util.ArrayList;
import
java.util.Collections
;
import
java.util.List
;
import
bolts.Task
;
import
chat.rocket.android.BuildConfig
;
import
chat.rocket.android.R
;
import
chat.rocket.android.RocketChatCache
;
...
...
@@ -51,6 +50,7 @@ import chat.rocket.persistence.realm.repositories.RealmServerInfoRepository;
import
chat.rocket.persistence.realm.repositories.RealmSessionRepository
;
import
chat.rocket.persistence.realm.repositories.RealmSpotlightRepository
;
import
chat.rocket.persistence.realm.repositories.RealmUserRepository
;
import
hugo.weaving.DebugLog
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.disposables.Disposable
;
...
...
@@ -323,17 +323,12 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
adapter
.
setRoomListHeaders
(
roomListHeaders
);
}
@DebugLog
@Override
public
void
on
LogoutCleanUp
()
{
Activity
activity
=
getActivity
();
public
void
on
PreparedToLogOut
()
{
final
Activity
activity
=
getActivity
();
if
(
activity
!=
null
&&
activity
instanceof
MainActivity
)
{
((
MainActivity
)
activity
).
onLogout
();
presenter
.
onLogout
(
task
->
{
if
(
task
.
isFaulted
())
{
return
Task
.
forError
(
task
.
getError
());
}
return
null
;
});
}
}
...
...
@@ -341,12 +336,7 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
rootView
.
findViewById
(
R
.
id
.
btn_logout
).
setOnClickListener
(
view
->
{
closeUserActionContainer
();
// Clear relative data and set new hostname if any.
presenter
.
beforeLogoutCleanUp
();
final
Activity
activity
=
getActivity
();
if
(
activity
!=
null
&&
activity
instanceof
MainActivity
)
{
// Clear subscriptions on MainPresenter.
((
MainActivity
)
activity
).
beforeLogoutCleanUp
();
}
presenter
.
prepareToLogOut
();
});
}
...
...
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainPresenter.java
View file @
49c0e63b
...
...
@@ -12,6 +12,7 @@ import bolts.Task;
import
chat.rocket.android.BackgroundLooper
;
import
chat.rocket.android.RocketChatApplication
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.activity.MainActivity
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.helper.AbsoluteUrlHelper
;
import
chat.rocket.android.helper.LogIfError
;
...
...
@@ -20,6 +21,7 @@ import chat.rocket.android.helper.TextUtils;
import
chat.rocket.android.service.ConnectivityManager
;
import
chat.rocket.android.service.ConnectivityManagerApi
;
import
chat.rocket.android.shared.BasePresenter
;
import
chat.rocket.android_ddp.DDPClient
;
import
chat.rocket.core.interactors.RoomInteractor
;
import
chat.rocket.core.models.Room
;
import
chat.rocket.core.models.RoomSidebar
;
...
...
@@ -29,6 +31,12 @@ import chat.rocket.core.repositories.SpotlightRepository;
import
chat.rocket.core.repositories.UserRepository
;
import
chat.rocket.persistence.realm.RealmHelper
;
import
chat.rocket.persistence.realm.RealmStore
;
import
chat.rocket.persistence.realm.models.ddp.RealmEmail
;
import
chat.rocket.persistence.realm.models.ddp.RealmUser
;
import
chat.rocket.persistence.realm.models.internal.GetUsersOfRoomsProcedure
;
import
chat.rocket.persistence.realm.models.internal.LoadMessageProcedure
;
import
chat.rocket.persistence.realm.models.internal.MethodCall
;
import
chat.rocket.persistence.realm.models.internal.RealmSession
;
import
chat.rocket.persistence.realm.repositories.RealmSpotlightRepository
;
import
io.reactivex.Flowable
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
...
...
@@ -150,21 +158,33 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
}
@Override
public
void
beforeLogoutCleanUp
()
{
public
void
prepareToLogOut
()
{
onLogout
(
task
->
{
if
(
task
.
isFaulted
())
{
return
Task
.
forError
(
task
.
getError
());
}
clearSubscriptions
();
DDPClient
.
get
().
close
();
String
currentHostname
=
rocketChatCache
.
getSelectedServerHostname
();
RealmHelper
realmHelper
=
RealmStore
.
getOrCreate
(
currentHostname
);
realmHelper
.
executeTransaction
(
realm
->
{
realm
.
executeTransactionAsync
(
realmObj
->
realmObj
.
deleteAll
());
return
realmHelper
.
executeTransaction
(
realm
->
{
CookieManager
.
getInstance
().
removeAllCookie
();
ConnectivityManagerApi
connectivityManagerApi
=
ConnectivityManager
.
getInstance
(
RocketChatApplication
.
getInstance
());
connectivityManagerApi
.
removeServer
(
currentHostname
);
rocketChatCache
.
removeHostname
(
currentHostname
);
rocketChatCache
.
removeSelectedRoomId
(
currentHostname
);
rocketChatCache
.
setSelectedServerHostname
(
rocketChatCache
.
getFirstLoggedHostnameIfAny
());
view
.
onLogoutCleanUp
();
realm
.
delete
(
RealmEmail
.
class
);
realm
.
delete
(
RealmUser
.
class
);
realm
.
delete
(
RealmSession
.
class
);
realm
.
delete
(
MethodCall
.
class
);
realm
.
delete
(
LoadMessageProcedure
.
class
);
realm
.
delete
(
GetUsersOfRoomsProcedure
.
class
);
view
.
onPreparedToLogOut
();
return
null
;
});
});
}
@Override
...
...
app/src/main/java/chat/rocket/android/service/RealmBasedConnectivityManager.java
View file @
49c0e63b
...
...
@@ -109,6 +109,7 @@ import io.reactivex.subjects.BehaviorSubject;
if
(
serverConnectivityList
.
containsKey
(
hostname
))
{
disconnectFromServerIfNeeded
(
hostname
)
.
subscribe
(
_val
->
{
System
.
out
.
println
(
"Disconnected "
+
_val
);
},
RCLog:
:
e
);
}
}
...
...
@@ -279,8 +280,11 @@ import io.reactivex.subjects.BehaviorSubject;
if
(
serviceInterface
!=
null
)
{
return
serviceInterface
.
disconnectFromServer
(
hostname
)
// //after disconnection from server, remove HOSTNAME key from HashMap
.
doAfterTerminate
(()
->
serverConnectivityList
.
remove
(
hostname
));
//after disconnection from server, remove HOSTNAME key from HashMap
.
doAfterTerminate
(()
->
{
serverConnectivityList
.
remove
(
hostname
);
serverConnectivityList
.
put
(
hostname
,
ServerConnectivity
.
STATE_DISCONNECTED
);
});
}
else
{
return
Single
.
error
(
new
IllegalStateException
(
"not prepared"
));
}
...
...
app/src/main/java/chat/rocket/android/service/RocketChatWebSocketThread.java
View file @
49c0e63b
...
...
@@ -229,6 +229,8 @@ public class RocketChatWebSocketThread extends HandlerThread {
RxWebSocketCallback
.
Close
result
=
_task
.
getResult
();
if
(
result
.
code
==
DDPClient
.
REASON_NETWORK_ERROR
)
{
reconnect
();
}
else
{
unregisterListeners
();
}
return
null
;
});
...
...
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