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
cf18e7f8
Commit
cf18e7f8
authored
Dec 11, 2017
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement go back action from LoginActivity to fix the user getting locked at this screen
parent
b1514363
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
547 additions
and
446 deletions
+547
-446
RocketChatCache.java
app/src/main/java/chat/rocket/android/RocketChatCache.java
+70
-23
MethodCallHelper.java
...c/main/java/chat/rocket/android/api/MethodCallHelper.java
+2
-2
AbstractChatRoomFragment.java
...t/android/fragment/chatroom/AbstractChatRoomFragment.java
+1
-1
RoomFragment.java
...a/chat/rocket/android/fragment/chatroom/RoomFragment.java
+21
-20
RoomPresenter.java
.../chat/rocket/android/fragment/chatroom/RoomPresenter.java
+291
-256
AbstractServerConfigFragment.java
.../fragment/server_config/AbstractServerConfigFragment.java
+1
-1
LoginFragment.kt
...at/rocket/android/fragment/server_config/LoginFragment.kt
+2
-2
LoginPresenter.kt
...t/rocket/android/fragment/server_config/LoginPresenter.kt
+21
-1
Logger.kt
app/src/main/java/chat/rocket/android/helper/Logger.kt
+1
-2
PushManager.kt
app/src/main/java/chat/rocket/android/push/PushManager.kt
+0
-1
RealmBasedConnectivityManager.java
...rocket/android/service/RealmBasedConnectivityManager.java
+5
-5
fragment_login.xml
app/src/main/res/layout/fragment_login.xml
+132
-132
No files found.
app/src/main/java/chat/rocket/android/RocketChatCache.java
View file @
cf18e7f8
...
@@ -2,10 +2,13 @@ package chat.rocket.android;
...
@@ -2,10 +2,13 @@ package chat.rocket.android;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
android.support.annotation.NonNull
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
com.hadisatrio.optional.Optional
;
import
com.hadisatrio.optional.Optional
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
...
@@ -20,8 +23,6 @@ import chat.rocket.android.log.RCLog;
...
@@ -20,8 +23,6 @@ import chat.rocket.android.log.RCLog;
import
chat.rocket.core.utils.Pair
;
import
chat.rocket.core.utils.Pair
;
import
io.reactivex.BackpressureStrategy
;
import
io.reactivex.BackpressureStrategy
;
import
io.reactivex.Flowable
;
import
io.reactivex.Flowable
;
import
io.reactivex.annotations.NonNull
;
import
io.reactivex.annotations.Nullable
;
import
okhttp3.HttpUrl
;
import
okhttp3.HttpUrl
;
/**
/**
...
@@ -38,13 +39,12 @@ public class RocketChatCache {
...
@@ -38,13 +39,12 @@ public class RocketChatCache {
private
static
final
String
KEY_SESSION_TOKEN
=
"KEY_SESSION_TOKEN"
;
private
static
final
String
KEY_SESSION_TOKEN
=
"KEY_SESSION_TOKEN"
;
private
Context
context
;
private
Context
context
;
private
String
session
;
public
RocketChatCache
(
Context
context
)
{
public
RocketChatCache
(
Context
context
)
{
this
.
context
=
context
.
getApplicationContext
();
this
.
context
=
context
.
getApplicationContext
();
}
}
public
void
addOpenedRoom
(
@No
n
Null
String
roomId
,
long
lastSeen
)
{
public
void
addOpenedRoom
(
@No
t
Null
String
roomId
,
long
lastSeen
)
{
JSONObject
openedRooms
=
getOpenedRooms
();
JSONObject
openedRooms
=
getOpenedRooms
();
try
{
try
{
JSONObject
room
=
new
JSONObject
().
put
(
"rid"
,
roomId
).
put
(
"ls"
,
lastSeen
);
JSONObject
room
=
new
JSONObject
().
put
(
"rid"
,
roomId
).
put
(
"ls"
,
lastSeen
);
...
@@ -55,15 +55,15 @@ public class RocketChatCache {
...
@@ -55,15 +55,15 @@ public class RocketChatCache {
setString
(
KEY_OPENED_ROOMS
,
openedRooms
.
toString
());
setString
(
KEY_OPENED_ROOMS
,
openedRooms
.
toString
());
}
}
public
void
removeOpenedRoom
(
@No
n
Null
String
roomId
)
{
public
void
removeOpenedRoom
(
@No
t
Null
String
roomId
)
{
JSONObject
openedRooms
=
getOpenedRooms
();
JSONObject
openedRooms
=
getOpenedRooms
();
if
(
openedRooms
.
has
(
roomId
))
{
if
(
openedRooms
.
has
(
roomId
))
{
openedRooms
.
remove
(
roomId
);
openedRooms
.
remove
(
roomId
);
}
}
}
}
public
@Non
Null
@Not
Null
JSONObject
getOpenedRooms
()
{
public
JSONObject
getOpenedRooms
()
{
String
openedRooms
=
getString
(
KEY_OPENED_ROOMS
,
""
);
String
openedRooms
=
getString
(
KEY_OPENED_ROOMS
,
""
);
if
(
openedRooms
.
isEmpty
())
{
if
(
openedRooms
.
isEmpty
())
{
return
new
JSONObject
();
return
new
JSONObject
();
...
@@ -88,9 +88,9 @@ public class RocketChatCache {
...
@@ -88,9 +88,9 @@ public class RocketChatCache {
setString
(
KEY_SELECTED_SERVER_HOSTNAME
,
newHostname
);
setString
(
KEY_SELECTED_SERVER_HOSTNAME
,
newHostname
);
}
}
public
void
add
HostSiteName
(
@NonNull
String
currentHostname
,
@Non
Null
String
siteName
)
{
public
void
add
SiteName
(
@NotNull
String
currentHostname
,
@Not
Null
String
siteName
)
{
try
{
try
{
String
hostSiteNamesJson
=
get
HostSiteNamesJson
();
String
hostSiteNamesJson
=
get
SiteName
();
JSONObject
jsonObject
=
(
hostSiteNamesJson
==
null
)
?
JSONObject
jsonObject
=
(
hostSiteNamesJson
==
null
)
?
new
JSONObject
()
:
new
JSONObject
(
hostSiteNamesJson
);
new
JSONObject
()
:
new
JSONObject
(
hostSiteNamesJson
);
jsonObject
.
put
(
currentHostname
,
siteName
);
jsonObject
.
put
(
currentHostname
,
siteName
);
...
@@ -100,8 +100,22 @@ public class RocketChatCache {
...
@@ -100,8 +100,22 @@ public class RocketChatCache {
}
}
}
}
public
@NonNull
public
void
removeSiteName
(
@NotNull
String
hostname
)
{
String
getHostSiteName
(
@NonNull
String
host
)
{
try
{
String
siteNameJson
=
getSiteName
();
JSONObject
jsonObject
=
(
siteNameJson
==
null
)
?
new
JSONObject
()
:
new
JSONObject
(
siteNameJson
);
if
(
jsonObject
.
has
(
hostname
))
{
jsonObject
.
remove
(
hostname
);
}
setString
(
KEY_SELECTED_SITE_NAME
,
jsonObject
.
toString
());
}
catch
(
JSONException
e
)
{
RCLog
.
e
(
e
);
}
}
@NotNull
public
String
getHostSiteName
(
@NotNull
String
host
)
{
if
(
host
.
startsWith
(
"http"
))
{
if
(
host
.
startsWith
(
"http"
))
{
HttpUrl
url
=
HttpUrl
.
parse
(
host
);
HttpUrl
url
=
HttpUrl
.
parse
(
host
);
if
(
url
!=
null
)
{
if
(
url
!=
null
)
{
...
@@ -109,7 +123,7 @@ public class RocketChatCache {
...
@@ -109,7 +123,7 @@ public class RocketChatCache {
}
}
}
}
try
{
try
{
String
hostSiteNamesJson
=
get
HostSiteNamesJson
();
String
hostSiteNamesJson
=
get
SiteName
();
JSONObject
jsonObject
=
(
hostSiteNamesJson
==
null
)
?
JSONObject
jsonObject
=
(
hostSiteNamesJson
==
null
)
?
new
JSONObject
()
:
new
JSONObject
(
hostSiteNamesJson
);
new
JSONObject
()
:
new
JSONObject
(
hostSiteNamesJson
);
host
=
getSiteUrlFor
(
host
);
host
=
getSiteUrlFor
(
host
);
...
@@ -120,18 +134,18 @@ public class RocketChatCache {
...
@@ -120,18 +134,18 @@ public class RocketChatCache {
return
""
;
return
""
;
}
}
private
@Nullable
@Nullable
String
getHostSiteNamesJson
()
{
private
String
getSiteName
()
{
return
getString
(
KEY_SELECTED_SITE_NAME
,
null
);
return
getString
(
KEY_SELECTED_SITE_NAME
,
null
);
}
}
public
void
add
HostnameSiteUrl
(
@Nullable
String
hostnameAlias
,
@Non
Null
String
currentHostname
)
{
public
void
add
SiteUrl
(
@Nullable
String
hostnameAlias
,
@Not
Null
String
currentHostname
)
{
String
alias
=
null
;
String
alias
=
null
;
if
(
hostnameAlias
!=
null
)
{
if
(
hostnameAlias
!=
null
)
{
alias
=
hostnameAlias
.
toLowerCase
();
alias
=
hostnameAlias
.
toLowerCase
();
}
}
try
{
try
{
String
selectedHostnameAliasJson
=
get
LoginHostnamesJson
();
String
selectedHostnameAliasJson
=
get
SiteUrlForAllServers
();
JSONObject
jsonObject
=
selectedHostnameAliasJson
==
null
?
JSONObject
jsonObject
=
selectedHostnameAliasJson
==
null
?
new
JSONObject
()
:
new
JSONObject
(
selectedHostnameAliasJson
);
new
JSONObject
()
:
new
JSONObject
(
selectedHostnameAliasJson
);
jsonObject
.
put
(
alias
,
currentHostname
);
jsonObject
.
put
(
alias
,
currentHostname
);
...
@@ -141,14 +155,33 @@ public class RocketChatCache {
...
@@ -141,14 +155,33 @@ public class RocketChatCache {
}
}
}
}
public
@Nullable
private
void
removeSiteUrl
(
@NotNull
String
hostname
)
{
String
getSiteUrlFor
(
String
hostname
)
{
try
{
String
siteUrlForAllServersJson
=
getSiteUrlForAllServers
();
JSONObject
jsonObject
=
siteUrlForAllServersJson
==
null
?
new
JSONObject
()
:
new
JSONObject
(
siteUrlForAllServersJson
);
Iterator
<
String
>
keys
=
jsonObject
.
keys
();
while
(
keys
.
hasNext
())
{
String
alias
=
keys
.
next
();
if
(
hostname
.
equals
(
jsonObject
.
getString
(
alias
)))
{
jsonObject
.
remove
(
alias
);
break
;
}
}
setString
(
KEY_SELECTED_SITE_URL
,
jsonObject
.
toString
());
}
catch
(
JSONException
e
)
{
RCLog
.
e
(
e
);
}
}
@Nullable
public
String
getSiteUrlFor
(
String
hostname
)
{
try
{
try
{
String
selectedServerHostname
=
getSelectedServerHostname
();
String
selectedServerHostname
=
getSelectedServerHostname
();
if
(
get
LoginHostnamesJson
()
==
null
||
getLoginHostnamesJson
().
isEmpty
())
{
if
(
get
SiteUrlForAllServers
()
==
null
||
getSiteUrlForAllServers
().
isEmpty
())
{
return
null
;
return
null
;
}
}
return
new
JSONObject
(
get
LoginHostnamesJson
())
return
new
JSONObject
(
get
SiteUrlForAllServers
())
.
optString
(
hostname
,
selectedServerHostname
);
.
optString
(
hostname
,
selectedServerHostname
);
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
RCLog
.
e
(
e
);
RCLog
.
e
(
e
);
...
@@ -156,12 +189,12 @@ public class RocketChatCache {
...
@@ -156,12 +189,12 @@ public class RocketChatCache {
return
null
;
return
null
;
}
}
private
@Nullable
@Nullable
String
getLoginHostnamesJson
()
{
private
String
getSiteUrlForAllServers
()
{
return
getString
(
KEY_SELECTED_SITE_URL
,
null
);
return
getString
(
KEY_SELECTED_SITE_URL
,
null
);
}
}
public
void
addHostname
(
@No
n
Null
String
hostname
,
@Nullable
String
hostnameAvatarUri
,
String
siteName
)
{
public
void
addHostname
(
@No
t
Null
String
hostname
,
@Nullable
String
hostnameAvatarUri
,
String
siteName
)
{
String
hostnameList
=
getString
(
KEY_HOSTNAME_LIST
,
null
);
String
hostnameList
=
getString
(
KEY_HOSTNAME_LIST
,
null
);
try
{
try
{
JSONObject
json
;
JSONObject
json
;
...
@@ -257,6 +290,7 @@ public class RocketChatCache {
...
@@ -257,6 +290,7 @@ public class RocketChatCache {
}
}
}
}
@NonNull
private
JSONObject
getSelectedRoomIdJsonObject
()
throws
JSONException
{
private
JSONObject
getSelectedRoomIdJsonObject
()
throws
JSONException
{
String
json
=
getString
(
KEY_SELECTED_ROOM_ID
,
null
);
String
json
=
getString
(
KEY_SELECTED_ROOM_ID
,
null
);
if
(
json
==
null
)
{
if
(
json
==
null
)
{
...
@@ -367,4 +401,17 @@ public class RocketChatCache {
...
@@ -367,4 +401,17 @@ public class RocketChatCache {
return
null
;
return
null
;
}
}
/**
* Wipe all given hostname entries and references from cache.
*/
public
void
clearSelectedHostnameReferences
()
{
String
hostname
=
getSelectedServerHostname
();
if
(
hostname
!=
null
)
{
removeSiteName
(
hostname
);
removeHostname
(
hostname
);
removeSiteUrl
(
hostname
);
setSelectedServerHostname
(
null
);
}
}
}
}
app/src/main/java/chat/rocket/android/api/MethodCallHelper.java
View file @
cf18e7f8
...
@@ -512,8 +512,8 @@ public class MethodCallHelper {
...
@@ -512,8 +512,8 @@ public class MethodCallHelper {
if
(
httpSiteUrl
!=
null
)
{
if
(
httpSiteUrl
!=
null
)
{
String
host
=
httpSiteUrl
.
host
();
String
host
=
httpSiteUrl
.
host
();
RocketChatCache
rocketChatCache
=
new
RocketChatCache
(
context
);
RocketChatCache
rocketChatCache
=
new
RocketChatCache
(
context
);
rocketChatCache
.
add
Hostname
SiteUrl
(
host
,
currentHostname
);
rocketChatCache
.
addSiteUrl
(
host
,
currentHostname
);
rocketChatCache
.
add
Host
SiteName
(
currentHostname
,
siteName
);
rocketChatCache
.
addSiteName
(
currentHostname
,
siteName
);
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/AbstractChatRoomFragment.java
View file @
cf18e7f8
...
@@ -11,7 +11,7 @@ import chat.rocket.android.fragment.AbstractFragment;
...
@@ -11,7 +11,7 @@ import chat.rocket.android.fragment.AbstractFragment;
import
chat.rocket.android.widget.RoomToolbar
;
import
chat.rocket.android.widget.RoomToolbar
;
import
chat.rocket.core.models.User
;
import
chat.rocket.core.models.User
;
abstract
class
AbstractChatRoomFragment
extends
AbstractFragment
{
public
abstract
class
AbstractChatRoomFragment
extends
AbstractFragment
{
private
RoomToolbar
roomToolbar
;
private
RoomToolbar
roomToolbar
;
@Nullable
@Nullable
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomFragment.java
View file @
cf18e7f8
...
@@ -131,7 +131,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
...
@@ -131,7 +131,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
private
MethodCallHelper
methodCallHelper
;
private
MethodCallHelper
methodCallHelper
;
private
AbsoluteUrlHelper
absoluteUrlHelper
;
private
AbsoluteUrlHelper
absoluteUrlHelper
;
private
Message
edit
t
ingMessage
=
null
;
private
Message
editingMessage
=
null
;
private
RoomToolbar
toolbar
;
private
RoomToolbar
toolbar
;
...
@@ -344,7 +344,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
...
@@ -344,7 +344,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
optionalPane
.
ifPresent
(
pane
->
pane
.
setPanelSlideListener
(
new
SlidingPaneLayout
.
PanelSlideListener
()
{
optionalPane
.
ifPresent
(
pane
->
pane
.
setPanelSlideListener
(
new
SlidingPaneLayout
.
PanelSlideListener
()
{
@Override
@Override
public
void
onPanelSlide
(
View
view
,
float
v
)
{
public
void
onPanelSlide
(
@NonNull
View
view
,
float
v
)
{
messageFormManager
.
enableComposingText
(
false
);
messageFormManager
.
enableComposingText
(
false
);
sidebarFragment
.
clearSearchViewFocus
();
sidebarFragment
.
clearSearchViewFocus
();
//Ref: ActionBarDrawerToggle#setProgress
//Ref: ActionBarDrawerToggle#setProgress
...
@@ -352,12 +352,12 @@ public class RoomFragment extends AbstractChatRoomFragment implements
...
@@ -352,12 +352,12 @@ public class RoomFragment extends AbstractChatRoomFragment implements
}
}
@Override
@Override
public
void
onPanelOpened
(
View
view
)
{
public
void
onPanelOpened
(
@NonNull
View
view
)
{
toolbar
.
setNavigationIconVerticalMirror
(
true
);
toolbar
.
setNavigationIconVerticalMirror
(
true
);
}
}
@Override
@Override
public
void
onPanelClosed
(
View
view
)
{
public
void
onPanelClosed
(
@NonNull
View
view
)
{
messageFormManager
.
enableComposingText
(
true
);
messageFormManager
.
enableComposingText
(
true
);
toolbar
.
setNavigationIconVerticalMirror
(
false
);
toolbar
.
setNavigationIconVerticalMirror
(
false
);
subPane
.
closePane
();
subPane
.
closePane
();
...
@@ -487,8 +487,8 @@ public class RoomFragment extends AbstractChatRoomFragment implements
...
@@ -487,8 +487,8 @@ public class RoomFragment extends AbstractChatRoomFragment implements
@Override
@Override
public
boolean
onBackPressed
()
{
public
boolean
onBackPressed
()
{
if
(
edit
t
ingMessage
!=
null
)
{
if
(
editingMessage
!=
null
)
{
edit
t
ingMessage
=
null
;
editingMessage
=
null
;
messageFormManager
.
clearComposingText
();
messageFormManager
.
clearComposingText
();
}
}
return
false
;
return
false
;
...
@@ -547,15 +547,15 @@ public class RoomFragment extends AbstractChatRoomFragment implements
...
@@ -547,15 +547,15 @@ public class RoomFragment extends AbstractChatRoomFragment implements
}
}
private
void
sendMessage
(
String
messageText
)
{
private
void
sendMessage
(
String
messageText
)
{
if
(
edit
t
ingMessage
==
null
)
{
if
(
editingMessage
==
null
)
{
presenter
.
sendMessage
(
messageText
);
presenter
.
sendMessage
(
messageText
);
}
else
{
}
else
{
presenter
.
updateMessage
(
edit
t
ingMessage
,
messageText
);
presenter
.
updateMessage
(
editingMessage
,
messageText
);
}
}
}
}
@Override
@Override
public
void
setupWith
(
RocketChatAbsoluteUrl
rocketChatAbsoluteUrl
)
{
public
void
setupWith
(
@NonNull
RocketChatAbsoluteUrl
rocketChatAbsoluteUrl
)
{
if
(
rocketChatAbsoluteUrl
!=
null
)
{
if
(
rocketChatAbsoluteUrl
!=
null
)
{
token
=
rocketChatAbsoluteUrl
.
getToken
();
token
=
rocketChatAbsoluteUrl
.
getToken
();
userId
=
rocketChatAbsoluteUrl
.
getUserId
();
userId
=
rocketChatAbsoluteUrl
.
getUserId
();
...
@@ -564,7 +564,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
...
@@ -564,7 +564,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
}
}
@Override
@Override
public
void
render
(
Room
room
)
{
public
void
render
(
@NonNull
Room
room
)
{
roomType
=
room
.
getType
();
roomType
=
room
.
getType
();
setToolbarTitle
(
room
.
getName
());
setToolbarTitle
(
room
.
getName
());
...
@@ -589,7 +589,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
...
@@ -589,7 +589,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
}
}
@Override
@Override
public
void
showUserStatus
(
User
user
)
{
public
void
showUserStatus
(
@NonNull
User
user
)
{
showToolbarUserStatuslIcon
(
user
.
getStatus
());
showToolbarUserStatuslIcon
(
user
.
getStatus
());
}
}
...
@@ -610,7 +610,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
...
@@ -610,7 +610,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
public
void
onMessageSendSuccessfully
()
{
public
void
onMessageSendSuccessfully
()
{
scrollToLatestMessage
();
scrollToLatestMessage
();
messageFormManager
.
onMessageSend
();
messageFormManager
.
onMessageSend
();
edit
t
ingMessage
=
null
;
editingMessage
=
null
;
}
}
@Override
@Override
...
@@ -629,15 +629,16 @@ public class RoomFragment extends AbstractChatRoomFragment implements
...
@@ -629,15 +629,16 @@ public class RoomFragment extends AbstractChatRoomFragment implements
}
}
@Override
@Override
public
void
showMessages
(
List
<
Message
>
messages
)
{
public
void
showMessages
(
@NonNull
List
<?
extends
Message
>
messages
)
{
if
(
messageListAdapter
==
null
)
{
if
(
messageListAdapter
==
null
)
{
return
;
return
;
}
}
messageListAdapter
.
updateData
(
messages
);
messageListAdapter
.
updateData
((
List
<
Message
>)
messages
);
}
}
@Override
@Override
public
void
showMessageSendFailure
(
Message
message
)
{
public
void
showMessageSendFailure
(
@NonNull
Message
message
)
{
new
AlertDialog
.
Builder
(
getContext
())
new
AlertDialog
.
Builder
(
getContext
())
.
setPositiveButton
(
R
.
string
.
resend
,
.
setPositiveButton
(
R
.
string
.
resend
,
(
dialog
,
which
)
->
presenter
.
resendMessage
(
message
))
(
dialog
,
which
)
->
presenter
.
resendMessage
(
message
))
...
@@ -648,7 +649,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
...
@@ -648,7 +649,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
}
}
@Override
@Override
public
void
showMessageDeleteFailure
(
Message
message
)
{
public
void
showMessageDeleteFailure
(
@NonNull
Message
message
)
{
new
AlertDialog
.
Builder
(
getContext
())
new
AlertDialog
.
Builder
(
getContext
())
.
setTitle
(
getContext
().
getString
(
R
.
string
.
failed_to_delete
))
.
setTitle
(
getContext
().
getString
(
R
.
string
.
failed_to_delete
))
.
setMessage
(
getContext
().
getString
(
R
.
string
.
failed_to_delete_message
))
.
setMessage
(
getContext
().
getString
(
R
.
string
.
failed_to_delete_message
))
...
@@ -667,12 +668,12 @@ public class RoomFragment extends AbstractChatRoomFragment implements
...
@@ -667,12 +668,12 @@ public class RoomFragment extends AbstractChatRoomFragment implements
}
}
@Override
@Override
public
void
onReply
(
AbsoluteUrl
absoluteUrl
,
String
markdown
,
Message
message
)
{
public
void
onReply
(
@NonNull
AbsoluteUrl
absoluteUrl
,
@NonNull
String
markdown
,
@NonNull
Message
message
)
{
messageFormManager
.
setReply
(
absoluteUrl
,
markdown
,
message
);
messageFormManager
.
setReply
(
absoluteUrl
,
markdown
,
message
);
}
}
@Override
@Override
public
void
onCopy
(
String
message
)
{
public
void
onCopy
(
@NonNull
String
message
)
{
RocketChatApplication
context
=
RocketChatApplication
.
getInstance
();
RocketChatApplication
context
=
RocketChatApplication
.
getInstance
();
ClipboardManager
clipboardManager
=
ClipboardManager
clipboardManager
=
(
ClipboardManager
)
context
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
);
(
ClipboardManager
)
context
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
);
...
@@ -680,7 +681,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
...
@@ -680,7 +681,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
}
}
@Override
@Override
public
void
showMessageActions
(
Message
message
)
{
public
void
showMessageActions
(
@NonNull
Message
message
)
{
Activity
context
=
getActivity
();
Activity
context
=
getActivity
();
if
(
context
!=
null
&&
context
instanceof
MainActivity
)
{
if
(
context
!=
null
&&
context
instanceof
MainActivity
)
{
MessagePopup
.
take
(
message
)
MessagePopup
.
take
(
message
)
...
@@ -694,7 +695,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
...
@@ -694,7 +695,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
}
}
private
void
onEditMessage
(
Message
message
)
{
private
void
onEditMessage
(
Message
message
)
{
edit
t
ingMessage
=
message
;
editingMessage
=
message
;
messageFormManager
.
setEditMessage
(
message
.
getMessage
());
messageFormManager
.
setEditMessage
(
message
.
getMessage
());
}
}
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomPresenter.java
View file @
cf18e7f8
This diff is collapsed.
Click to expand it.
app/src/main/java/chat/rocket/android/fragment/server_config/AbstractServerConfigFragment.java
View file @
cf18e7f8
...
@@ -8,7 +8,7 @@ import chat.rocket.android.R;
...
@@ -8,7 +8,7 @@ import chat.rocket.android.R;
import
chat.rocket.android.fragment.AbstractFragment
;
import
chat.rocket.android.fragment.AbstractFragment
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.helper.TextUtils
;
abstract
class
AbstractServerConfigFragment
extends
AbstractFragment
{
public
abstract
class
AbstractServerConfigFragment
extends
AbstractFragment
{
public
static
final
String
KEY_HOSTNAME
=
"hostname"
;
public
static
final
String
KEY_HOSTNAME
=
"hostname"
;
protected
String
hostname
;
protected
String
hostname
;
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/LoginFragment.kt
View file @
cf18e7f8
...
@@ -99,14 +99,14 @@ class LoginFragment : AbstractServerConfigFragment(), LoginContract.View {
...
@@ -99,14 +99,14 @@ class LoginFragment : AbstractServerConfigFragment(), LoginContract.View {
showFragmentWithBackStack
(
fragment
)
showFragmentWithBackStack
(
fragment
)
}
}
}
}
viewMap
[
info
.
serviceName
]
?.
setVisibility
(
View
.
VISIBLE
)
viewMap
[
info
.
serviceName
]
?.
visibility
=
View
.
VISIBLE
}
}
}
}
}
}
for
(
info
in
OAuthProviderInfo
.
LIST
)
{
for
(
info
in
OAuthProviderInfo
.
LIST
)
{
if
(
supportedMap
[
info
.
serviceName
]
==
false
)
{
if
(
supportedMap
[
info
.
serviceName
]
==
false
)
{
viewMap
[
info
.
serviceName
]
?.
setVisibility
(
View
.
GONE
)
viewMap
[
info
.
serviceName
]
?.
visibility
=
View
.
GONE
}
}
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/LoginPresenter.kt
View file @
cf18e7f8
...
@@ -3,10 +3,14 @@ package chat.rocket.android.fragment.server_config
...
@@ -3,10 +3,14 @@ package chat.rocket.android.fragment.server_config
import
bolts.Continuation
import
bolts.Continuation
import
bolts.Task
import
bolts.Task
import
chat.rocket.android.BackgroundLooper
import
chat.rocket.android.BackgroundLooper
import
chat.rocket.android.LaunchUtil
import
chat.rocket.android.RocketChatApplication
import
chat.rocket.android.RocketChatCache
import
chat.rocket.android.api.MethodCallHelper
import
chat.rocket.android.api.MethodCallHelper
import
chat.rocket.android.api.TwoStepAuthException
import
chat.rocket.android.api.TwoStepAuthException
import
chat.rocket.android.helper.Logger
import
chat.rocket.android.helper.Logger
import
chat.rocket.android.helper.TextUtils
import
chat.rocket.android.helper.TextUtils
import
chat.rocket.android.service.ConnectivityManager
import
chat.rocket.android.shared.BasePresenter
import
chat.rocket.android.shared.BasePresenter
import
chat.rocket.core.PublicSettingsConstants
import
chat.rocket.core.PublicSettingsConstants
import
chat.rocket.core.models.PublicSetting
import
chat.rocket.core.models.PublicSetting
...
@@ -26,6 +30,20 @@ class LoginPresenter(private val loginServiceConfigurationRepository: LoginServi
...
@@ -26,6 +30,20 @@ class LoginPresenter(private val loginServiceConfigurationRepository: LoginServi
getLoginServices
()
getLoginServices
()
}
}
override
fun
release
()
{
val
context
=
RocketChatApplication
.
getInstance
()
val
rocketChatCache
=
RocketChatCache
(
context
)
val
hostname
=
rocketChatCache
.
selectedServerHostname
hostname
?.
let
{
ConnectivityManager
.
getInstance
(
context
).
removeServer
(
hostname
)
rocketChatCache
.
clearSelectedHostnameReferences
()
}
super
.
release
()
LaunchUtil
.
showMainActivity
(
context
)
}
override
fun
login
(
username
:
String
,
password
:
String
)
{
override
fun
login
(
username
:
String
,
password
:
String
)
{
if
(
TextUtils
.
isEmpty
(
username
)
||
TextUtils
.
isEmpty
(
password
))
{
if
(
TextUtils
.
isEmpty
(
username
)
||
TextUtils
.
isEmpty
(
password
))
{
return
return
...
@@ -50,7 +68,9 @@ class LoginPresenter(private val loginServiceConfigurationRepository: LoginServi
...
@@ -50,7 +68,9 @@ class LoginPresenter(private val loginServiceConfigurationRepository: LoginServi
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribeBy
(
.
subscribeBy
(
onNext
=
{
loginServiceConfigurations
->
view
.
showLoginServices
(
loginServiceConfigurations
)
},
onNext
=
{
loginServiceConfigurations
->
view
.
showLoginServices
(
loginServiceConfigurations
);
},
onError
=
{
Logger
.
report
(
it
)
}
onError
=
{
Logger
.
report
(
it
)
}
)
)
)
)
...
...
app/src/main/java/chat/rocket/android/helper/Logger.kt
View file @
cf18e7f8
package
chat.rocket.android.helper
package
chat.rocket.android.helper
import
chat.rocket.android.BuildConfig
import
com.crashlytics.android.Crashlytics
import
com.crashlytics.android.Crashlytics
import
com.google.firebase.crash.FirebaseCrash
import
com.google.firebase.crash.FirebaseCrash
import
chat.rocket.android.BuildConfig
object
Logger
{
object
Logger
{
fun
report
(
throwable
:
Throwable
)
{
fun
report
(
throwable
:
Throwable
)
{
...
...
app/src/main/java/chat/rocket/android/push/PushManager.kt
View file @
cf18e7f8
...
@@ -22,7 +22,6 @@ import chat.rocket.android.BuildConfig
...
@@ -22,7 +22,6 @@ import chat.rocket.android.BuildConfig
import
chat.rocket.android.R
import
chat.rocket.android.R
import
chat.rocket.android.RocketChatCache
import
chat.rocket.android.RocketChatCache
import
chat.rocket.android.activity.MainActivity
import
chat.rocket.android.activity.MainActivity
import
chat.rocket.android.extensions.printStackTraceOnDebug
import
chat.rocket.android.helper.Logger
import
chat.rocket.android.helper.Logger
import
chat.rocket.core.interactors.MessageInteractor
import
chat.rocket.core.interactors.MessageInteractor
import
chat.rocket.core.models.Room
import
chat.rocket.core.models.Room
...
...
app/src/main/java/chat/rocket/android/service/RealmBasedConnectivityManager.java
View file @
cf18e7f8
...
@@ -107,7 +107,7 @@ import io.reactivex.subjects.BehaviorSubject;
...
@@ -107,7 +107,7 @@ import io.reactivex.subjects.BehaviorSubject;
public
void
removeServer
(
String
hostname
)
{
public
void
removeServer
(
String
hostname
)
{
RealmBasedServerInfo
.
remove
(
hostname
);
RealmBasedServerInfo
.
remove
(
hostname
);
if
(
serverConnectivityList
.
containsKey
(
hostname
))
{
if
(
serverConnectivityList
.
containsKey
(
hostname
))
{
disconnectFromServerIfNeeded
(
hostname
)
disconnectFromServerIfNeeded
(
hostname
,
DDPClient
.
REASON_CLOSED_BY_USER
)
.
subscribe
(
_val
->
{
.
subscribe
(
_val
->
{
},
RCLog:
:
e
);
},
RCLog:
:
e
);
}
}
...
@@ -207,7 +207,7 @@ import io.reactivex.subjects.BehaviorSubject;
...
@@ -207,7 +207,7 @@ import io.reactivex.subjects.BehaviorSubject;
});
});
}
}
private
Single
<
Boolean
>
disconnectFromServerIfNeeded
(
String
hostname
)
{
private
Single
<
Boolean
>
disconnectFromServerIfNeeded
(
String
hostname
,
int
reason
)
{
return
Single
.
defer
(()
->
{
return
Single
.
defer
(()
->
{
final
int
connectivity
=
serverConnectivityList
.
get
(
hostname
);
final
int
connectivity
=
serverConnectivityList
.
get
(
hostname
);
if
(
connectivity
==
ServerConnectivity
.
STATE_DISCONNECTED
)
{
if
(
connectivity
==
ServerConnectivity
.
STATE_DISCONNECTED
)
{
...
@@ -216,8 +216,8 @@ import io.reactivex.subjects.BehaviorSubject;
...
@@ -216,8 +216,8 @@ import io.reactivex.subjects.BehaviorSubject;
if
(
connectivity
==
ServerConnectivity
.
STATE_CONNECTING
)
{
if
(
connectivity
==
ServerConnectivity
.
STATE_CONNECTING
)
{
return
waitForConnected
(
hostname
)
return
waitForConnected
(
hostname
)
.
doOnError
(
err
->
notifyConnectionLost
(
hostname
,
DDPClient
.
REASON_NETWORK_ERRO
R
))
// .doOnError(err -> notifyConnectionLost(hostname, DDPClient.REASON_CLOSED_BY_USE
R))
.
flatMap
(
_val
->
disconnectFromServerIfNeeded
(
hostname
));
.
flatMap
(
_val
->
disconnectFromServerIfNeeded
(
hostname
,
DDPClient
.
REASON_CLOSED_BY_USER
));
}
}
if
(
connectivity
==
ServerConnectivity
.
STATE_DISCONNECTING
)
{
if
(
connectivity
==
ServerConnectivity
.
STATE_DISCONNECTING
)
{
...
@@ -286,7 +286,7 @@ import io.reactivex.subjects.BehaviorSubject;
...
@@ -286,7 +286,7 @@ import io.reactivex.subjects.BehaviorSubject;
if
(
serviceInterface
!=
null
)
{
if
(
serviceInterface
!=
null
)
{
return
serviceInterface
.
disconnectFromServer
(
hostname
)
return
serviceInterface
.
disconnectFromServer
(
hostname
)
//after disconnection from server, remove HOSTNAME key from HashMap
//after disconnection from server, remove HOSTNAME key from HashMap
.
doAfterTerminate
(()
->
{
.
doAfterTerminate
(()
->
{
serverConnectivityList
.
remove
(
hostname
);
serverConnectivityList
.
remove
(
hostname
);
serverConnectivityList
.
put
(
hostname
,
ServerConnectivity
.
STATE_DISCONNECTED
);
serverConnectivityList
.
put
(
hostname
,
ServerConnectivity
.
STATE_DISCONNECTED
);
...
...
app/src/main/res/layout/fragment_login.xml
View file @
cf18e7f8
This diff is collapsed.
Click to expand it.
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