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
eb3d41bb
Commit
eb3d41bb
authored
Oct 24, 2017
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keep alive the server when tapping a notification
parent
a088ec8b
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
39 additions
and
10 deletions
+39
-10
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+13
-3
MainContract.java
.../main/java/chat/rocket/android/activity/MainContract.java
+2
-0
MainPresenter.java
...main/java/chat/rocket/android/activity/MainPresenter.java
+1
-0
RoomFragment.java
...a/chat/rocket/android/fragment/chatroom/RoomFragment.java
+4
-0
PushManager.kt
app/src/main/java/chat/rocket/android/push/PushManager.kt
+4
-6
ConnectivityManagerApi.java
...a/chat/rocket/android/service/ConnectivityManagerApi.java
+3
-0
RealmBasedConnectivityManager.java
...rocket/android/service/RealmBasedConnectivityManager.java
+6
-0
RocketChatService.java
...n/java/chat/rocket/android/service/RocketChatService.java
+4
-1
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 @
eb3d41bb
...
@@ -74,8 +74,10 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -74,8 +74,10 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
onHostnameUpdated
();
onHostnameUpdated
();
}
}
}
else
{
}
else
{
presenter
.
bindViewOnly
(
this
);
ConnectivityManager
.
getInstance
(
getApplicationContext
()).
keepAliveServer
();
presenter
.
bindView
(
this
);
presenter
.
loadSignedInServers
(
hostname
);
presenter
.
loadSignedInServers
(
hostname
);
roomId
=
new
RocketChatCache
(
getApplicationContext
()).
getSelectedRoomId
();
}
}
}
}
...
@@ -302,6 +304,15 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -302,6 +304,15 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
}
}
}
}
@Override
public
void
refreshRoom
()
{
Fragment
fragment
=
getSupportFragmentManager
().
findFragmentById
(
getLayoutContainerForFragment
());
if
(
fragment
!=
null
&&
fragment
instanceof
RoomFragment
)
{
RoomFragment
roomFragment
=
(
RoomFragment
)
fragment
;
roomFragment
.
loadMessages
();
}
}
private
void
changeServerIfNeeded
(
String
serverHostname
)
{
private
void
changeServerIfNeeded
(
String
serverHostname
)
{
if
(!
hostname
.
equalsIgnoreCase
(
serverHostname
))
{
if
(!
hostname
.
equalsIgnoreCase
(
serverHostname
))
{
RocketChatCache
rocketChatCache
=
new
RocketChatCache
(
getApplicationContext
());
RocketChatCache
rocketChatCache
=
new
RocketChatCache
(
getApplicationContext
());
...
@@ -328,7 +339,6 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -328,7 +339,6 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
public
static
final
int
STATUS_DISMISS
=
0
;
public
static
final
int
STATUS_DISMISS
=
0
;
public
static
final
int
STATUS_CONNECTION_ERROR
=
1
;
public
static
final
int
STATUS_CONNECTION_ERROR
=
1
;
public
static
final
int
STATUS_TOKEN_LOGIN
=
2
;
public
static
final
int
STATUS_TOKEN_LOGIN
=
2
;
public
static
final
int
STATUS_LOGGING_OUT
=
3
;
private
int
status
;
private
int
status
;
private
Snackbar
snackbar
;
private
Snackbar
snackbar
;
...
...
app/src/main/java/chat/rocket/android/activity/MainContract.java
View file @
eb3d41bb
...
@@ -26,6 +26,8 @@ public interface MainContract {
...
@@ -26,6 +26,8 @@ public interface MainContract {
void
showConnectionOk
();
void
showConnectionOk
();
void
showSignedInServers
(
List
<
Pair
<
String
,
Pair
<
String
,
String
>>>
serverList
);
void
showSignedInServers
(
List
<
Pair
<
String
,
Pair
<
String
,
String
>>>
serverList
);
void
refreshRoom
();
}
}
interface
Presenter
extends
BaseContract
.
Presenter
<
View
>
{
interface
Presenter
extends
BaseContract
.
Presenter
<
View
>
{
...
...
app/src/main/java/chat/rocket/android/activity/MainPresenter.java
View file @
eb3d41bb
...
@@ -225,6 +225,7 @@ public class MainPresenter extends BasePresenter<MainContract.View>
...
@@ -225,6 +225,7 @@ public class MainPresenter extends BasePresenter<MainContract.View>
connectivity
->
{
connectivity
->
{
if
(
connectivity
.
state
==
ServerConnectivity
.
STATE_CONNECTED
)
{
if
(
connectivity
.
state
==
ServerConnectivity
.
STATE_CONNECTED
)
{
view
.
showConnectionOk
();
view
.
showConnectionOk
();
view
.
refreshRoom
();
return
;
return
;
}
}
view
.
showConnecting
();
view
.
showConnecting
();
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomFragment.java
View file @
eb3d41bb
...
@@ -701,4 +701,8 @@ public class RoomFragment extends AbstractChatRoomFragment implements
...
@@ -701,4 +701,8 @@ public class RoomFragment extends AbstractChatRoomFragment implements
startActivity
(
intent
);
startActivity
(
intent
);
}
}
}
}
public
void
loadMessages
()
{
presenter
.
loadMessages
();
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/push/PushManager.kt
View file @
eb3d41bb
...
@@ -348,8 +348,8 @@ object PushManager {
...
@@ -348,8 +348,8 @@ object PushManager {
val
userMessages
=
pushMessageList
.
filter
{
val
userMessages
=
pushMessageList
.
filter
{
it
.
notificationId
==
lastPushMessage
.
notificationId
}
it
.
notificationId
==
lastPushMessage
.
notificationId
}
builder
.
setContentTitle
(
getTitle
(
userMessages
.
size
,
title
))
builder
.
setContentTitle
(
getTitle
(
messageCount
,
title
))
inbox
.
setBigContentTitle
(
getTitle
(
userMessages
.
size
,
title
))
inbox
.
setBigContentTitle
(
getTitle
(
messageCount
,
title
))
for
(
push
in
userMessages
)
{
for
(
push
in
userMessages
)
{
inbox
.
addLine
(
push
.
message
)
inbox
.
addLine
(
push
.
message
)
...
@@ -601,11 +601,9 @@ object PushManager {
...
@@ -601,11 +601,9 @@ object PushManager {
roomUserTuple
.
flatMap
{
tuple
->
messageInteractor
.
send
(
tuple
.
first
,
tuple
.
second
,
message
as
String
)
}
roomUserTuple
.
flatMap
{
tuple
->
messageInteractor
.
send
(
tuple
.
first
,
tuple
.
second
,
message
as
String
)
}
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
.
subscribe
({
success
->
{
success
->
// Empty
// Empty
},
},
{
throwable
->
{
throwable
->
throwable
.
printStackTrace
()
throwable
.
printStackTrace
()
Logger
.
report
(
throwable
)
Logger
.
report
(
throwable
)
})
})
...
...
app/src/main/java/chat/rocket/android/service/ConnectivityManagerApi.java
View file @
eb3d41bb
package
chat
.
rocket
.
android
.
service
;
package
chat
.
rocket
.
android
.
service
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
java.util.List
;
import
java.util.List
;
...
@@ -22,4 +23,6 @@ public interface ConnectivityManagerApi {
...
@@ -22,4 +23,6 @@ public interface ConnectivityManagerApi {
List
<
ServerInfo
>
getServerList
();
List
<
ServerInfo
>
getServerList
();
Observable
<
ServerConnectivity
>
getServerConnectivityAsObservable
();
Observable
<
ServerConnectivity
>
getServerConnectivityAsObservable
();
int
getConnectivityState
(
@NonNull
String
hostname
);
}
}
app/src/main/java/chat/rocket/android/service/RealmBasedConnectivityManager.java
View file @
eb3d41bb
...
@@ -4,6 +4,7 @@ import android.content.ComponentName;
...
@@ -4,6 +4,7 @@ import android.content.ComponentName;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.ServiceConnection
;
import
android.content.ServiceConnection
;
import
android.os.IBinder
;
import
android.os.IBinder
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -148,6 +149,11 @@ import rx.subjects.PublishSubject;
...
@@ -148,6 +149,11 @@ import rx.subjects.PublishSubject;
return
Observable
.
concat
(
Observable
.
from
(
getCurrentConnectivityList
()),
connectivitySubject
);
return
Observable
.
concat
(
Observable
.
from
(
getCurrentConnectivityList
()),
connectivitySubject
);
}
}
@Override
public
int
getConnectivityState
(
@NonNull
String
hostname
)
{
return
serverConnectivityList
.
get
(
hostname
);
}
@DebugLog
@DebugLog
private
Single
<
Boolean
>
connectToServerIfNeeded
(
String
hostname
,
boolean
forceConnect
)
{
private
Single
<
Boolean
>
connectToServerIfNeeded
(
String
hostname
,
boolean
forceConnect
)
{
return
Single
.
defer
(()
->
{
return
Single
.
defer
(()
->
{
...
...
app/src/main/java/chat/rocket/android/service/RocketChatService.java
View file @
eb3d41bb
...
@@ -105,11 +105,14 @@ public class RocketChatService extends Service implements ConnectivityServiceInt
...
@@ -105,11 +105,14 @@ public class RocketChatService extends Service implements ConnectivityServiceInt
private
Single
<
RocketChatWebSocketThread
>
getOrCreateWebSocketThread
(
String
hostname
)
{
private
Single
<
RocketChatWebSocketThread
>
getOrCreateWebSocketThread
(
String
hostname
)
{
return
Single
.
defer
(()
->
{
return
Single
.
defer
(()
->
{
webSocketThreadLock
.
acquire
();
webSocketThreadLock
.
acquire
();
if
(
webSocketThreads
.
containsKey
(
hostname
))
{
int
connectivityState
=
ConnectivityManager
.
getInstance
(
getApplicationContext
()).
getConnectivityState
(
hostname
);
boolean
isConnected
=
connectivityState
==
ServerConnectivity
.
STATE_CONNECTED
;
if
(
webSocketThreads
.
containsKey
(
hostname
)
&&
isConnected
)
{
RocketChatWebSocketThread
thread
=
webSocketThreads
.
get
(
hostname
);
RocketChatWebSocketThread
thread
=
webSocketThreads
.
get
(
hostname
);
webSocketThreadLock
.
release
();
webSocketThreadLock
.
release
();
return
Single
.
just
(
thread
);
return
Single
.
just
(
thread
);
}
}
connectivityManager
.
notifyConnecting
(
hostname
);
return
RocketChatWebSocketThread
.
getStarted
(
getApplicationContext
(),
hostname
)
return
RocketChatWebSocketThread
.
getStarted
(
getApplicationContext
(),
hostname
)
.
doOnSuccess
(
thread
->
{
.
doOnSuccess
(
thread
->
{
webSocketThreads
.
put
(
hostname
,
thread
);
webSocketThreads
.
put
(
hostname
,
thread
);
...
...
app/src/main/java/chat/rocket/android/service/RocketChatWebSocketThread.java
View file @
eb3d41bb
...
@@ -209,6 +209,8 @@ public class RocketChatWebSocketThread extends HandlerThread {
...
@@ -209,6 +209,8 @@ public class RocketChatWebSocketThread extends HandlerThread {
if
(
task
.
isFaulted
())
{
if
(
task
.
isFaulted
())
{
Exception
error
=
task
.
getError
();
Exception
error
=
task
.
getError
();
RCLog
.
e
(
error
);
RCLog
.
e
(
error
);
connectivityManager
.
notifyConnectionLost
(
hostname
,
ConnectivityManagerInternal
.
REASON_NETWORK_ERROR
);
emitter
.
onError
(
error
);
emitter
.
onError
(
error
);
}
else
{
}
else
{
keepAliveTimer
.
update
();
keepAliveTimer
.
update
();
...
...
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