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
058899ff
Commit
058899ff
authored
Sep 29, 2017
by
Rafael Kellermann Streit
Committed by
GitHub
Sep 29, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into fix/possible-blink-in-members-list
parents
b1ede845
5a8a9a47
Changes
36
Hide whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
610 additions
and
280 deletions
+610
-280
build.gradle
app/build.gradle
+3
-1
RocketChatApplicationDebug.java
.../java/chat/rocket/android/RocketChatApplicationDebug.java
+6
-0
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+2
-1
LaunchUtil.java
app/src/main/java/chat/rocket/android/LaunchUtil.java
+3
-3
RocketChatApplication.java
.../main/java/chat/rocket/android/RocketChatApplication.java
+8
-0
RocketChatCache.java
app/src/main/java/chat/rocket/android/RocketChatCache.java
+79
-6
AbstractAuthedActivity.java
.../chat/rocket/android/activity/AbstractAuthedActivity.java
+14
-1
AbstractFragmentActivity.java
...hat/rocket/android/activity/AbstractFragmentActivity.java
+18
-0
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+56
-17
MainContract.java
.../main/java/chat/rocket/android/activity/MainContract.java
+2
-0
MainPresenter.java
...main/java/chat/rocket/android/activity/MainPresenter.java
+5
-0
MethodCallHelper.java
...c/main/java/chat/rocket/android/api/MethodCallHelper.java
+8
-14
InputHostnamePresenter.java
...t/android/fragment/add_server/InputHostnamePresenter.java
+5
-1
AbstractChatRoomFragment.java
...t/android/fragment/chatroom/AbstractChatRoomFragment.java
+1
-0
RoomListPresenter.kt
...ocket/android/fragment/chatroom/list/RoomListPresenter.kt
+69
-52
SidebarMainContract.java
.../rocket/android/fragment/sidebar/SidebarMainContract.java
+6
-1
SidebarMainFragment.java
.../rocket/android/fragment/sidebar/SidebarMainFragment.java
+54
-13
SidebarMainPresenter.java
...rocket/android/fragment/sidebar/SidebarMainPresenter.java
+32
-2
RealmBasedConnectivityManager.java
...rocket/android/service/RealmBasedConnectivityManager.java
+3
-2
RocketChatService.java
...n/java/chat/rocket/android/service/RocketChatService.java
+0
-7
RocketChatWebSocketThread.java
...hat/rocket/android/service/RocketChatWebSocketThread.java
+4
-0
dialog_users_of_room.xml
app/src/main/res/layout/dialog_users_of_room.xml
+0
-47
fragment_room_list.xml
app/src/main/res/layout/fragment_room_list.xml
+6
-0
strings.xml
app/src/main/res/values/strings.xml
+2
-6
RealmLoginServiceConfigurationRepository.java
...epositories/RealmLoginServiceConfigurationRepository.java
+21
-9
RealmMessageRepository.java
...ersistence/realm/repositories/RealmMessageRepository.java
+34
-16
RealmPermissionRepository.java
...istence/realm/repositories/RealmPermissionRepository.java
+10
-5
RealmPublicSettingRepository.java
...ence/realm/repositories/RealmPublicSettingRepository.java
+10
-5
RealmRoomRepository.java
...t/persistence/realm/repositories/RealmRoomRepository.java
+47
-24
RealmRoomRoleRepository.java
...rsistence/realm/repositories/RealmRoomRoleRepository.java
+11
-6
RealmSessionRepository.java
...ersistence/realm/repositories/RealmSessionRepository.java
+11
-5
RealmSpotlightRepository.kt
...ersistence/realm/repositories/RealmSpotlightRepository.kt
+6
-1
RealmSpotlightRoomRepository.java
...ence/realm/repositories/RealmSpotlightRoomRepository.java
+16
-10
RealmSpotlightUserRepository.java
...ence/realm/repositories/RealmSpotlightUserRepository.java
+20
-14
RealmUserRepository.java
...t/persistence/realm/repositories/RealmUserRepository.java
+33
-11
RoomToolbar.java
...src/main/java/chat/rocket/android/widget/RoomToolbar.java
+5
-0
No files found.
app/build.gradle
View file @
058899ff
...
@@ -46,7 +46,7 @@ android {
...
@@ -46,7 +46,7 @@ android {
applicationId
"chat.rocket.android"
applicationId
"chat.rocket.android"
minSdkVersion
16
minSdkVersion
16
targetSdkVersion
rootProject
.
ext
.
targetSdkVersion
targetSdkVersion
rootProject
.
ext
.
targetSdkVersion
versionCode
3
8
versionCode
3
9
versionName
"1.0.20"
versionName
"1.0.20"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
vectorDrawables
.
useSupportLibrary
=
true
vectorDrawables
.
useSupportLibrary
=
true
...
@@ -177,6 +177,8 @@ dependencies {
...
@@ -177,6 +177,8 @@ dependencies {
transitive
=
true
;
transitive
=
true
;
}
}
debugCompile
"com.tspoon.traceur:traceur:1.0.1"
provided
'com.parse.bolts:bolts-tasks:1.4.0'
provided
'com.parse.bolts:bolts-tasks:1.4.0'
provided
'io.reactivex.rxjava2:rxjava:2.1.0'
provided
'io.reactivex.rxjava2:rxjava:2.1.0'
provided
'io.reactivex:rxjava:1.3.0'
provided
'io.reactivex:rxjava:1.3.0'
...
...
app/src/debug/java/chat/rocket/android/RocketChatApplicationDebug.java
View file @
058899ff
...
@@ -2,6 +2,7 @@ package chat.rocket.android;
...
@@ -2,6 +2,7 @@ package chat.rocket.android;
import
android.os.StrictMode
;
import
android.os.StrictMode
;
import
com.facebook.stetho.Stetho
;
import
com.facebook.stetho.Stetho
;
import
com.tspoon.traceur.Traceur
;
import
com.uphyca.stetho_realm.RealmInspectorModulesProvider
;
import
com.uphyca.stetho_realm.RealmInspectorModulesProvider
;
public
class
RocketChatApplicationDebug
extends
RocketChatApplication
{
public
class
RocketChatApplicationDebug
extends
RocketChatApplication
{
...
@@ -11,6 +12,11 @@ public class RocketChatApplicationDebug extends RocketChatApplication {
...
@@ -11,6 +12,11 @@ public class RocketChatApplicationDebug extends RocketChatApplication {
super
.
onCreate
();
super
.
onCreate
();
enableStrictMode
();
enableStrictMode
();
enableStetho
();
enableStetho
();
enableTraceur
();
}
private
void
enableTraceur
()
{
Traceur
.
enableLogging
();
}
}
private
void
enableStrictMode
()
{
private
void
enableStrictMode
()
{
...
...
app/src/main/AndroidManifest.xml
View file @
058899ff
...
@@ -40,7 +40,8 @@
...
@@ -40,7 +40,8 @@
<activity
<activity
android:name=
".activity.AddServerActivity"
android:name=
".activity.AddServerActivity"
android:configChanges=
"orientation|screenSize"
android:configChanges=
"orientation|screenSize"
android:windowSoftInputMode=
"adjustResize"
/>
android:windowSoftInputMode=
"adjustResize"
android:launchMode=
"singleTop"
/>
<activity
<activity
android:name=
".activity.LoginActivity"
android:name=
".activity.LoginActivity"
...
...
app/src/main/java/chat/rocket/android/LaunchUtil.java
View file @
058899ff
...
@@ -17,7 +17,7 @@ public class LaunchUtil {
...
@@ -17,7 +17,7 @@ public class LaunchUtil {
*/
*/
public
static
void
showMainActivity
(
Context
context
)
{
public
static
void
showMainActivity
(
Context
context
)
{
Intent
intent
=
new
Intent
(
context
,
MainActivity
.
class
);
Intent
intent
=
new
Intent
(
context
,
MainActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
|
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
|
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
|
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
context
.
startActivity
(
intent
);
context
.
startActivity
(
intent
);
}
}
...
@@ -26,7 +26,7 @@ public class LaunchUtil {
...
@@ -26,7 +26,7 @@ public class LaunchUtil {
*/
*/
public
static
void
showAddServerActivity
(
Context
context
)
{
public
static
void
showAddServerActivity
(
Context
context
)
{
Intent
intent
=
new
Intent
(
context
,
AddServerActivity
.
class
);
Intent
intent
=
new
Intent
(
context
,
AddServerActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
|
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
|
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
|
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
context
.
startActivity
(
intent
);
context
.
startActivity
(
intent
);
}
}
...
@@ -35,7 +35,7 @@ public class LaunchUtil {
...
@@ -35,7 +35,7 @@ public class LaunchUtil {
*/
*/
public
static
void
showLoginActivity
(
Context
context
,
String
hostname
)
{
public
static
void
showLoginActivity
(
Context
context
,
String
hostname
)
{
Intent
intent
=
new
Intent
(
context
,
LoginActivity
.
class
);
Intent
intent
=
new
Intent
(
context
,
LoginActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
|
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
|
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
|
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
intent
.
putExtra
(
LoginActivity
.
KEY_HOSTNAME
,
hostname
);
intent
.
putExtra
(
LoginActivity
.
KEY_HOSTNAME
,
hostname
);
context
.
startActivity
(
intent
);
context
.
startActivity
(
intent
);
}
}
...
...
app/src/main/java/chat/rocket/android/RocketChatApplication.java
View file @
058899ff
...
@@ -20,6 +20,12 @@ import chat.rocket.persistence.realm.RocketChatPersistenceRealm;
...
@@ -20,6 +20,12 @@ import chat.rocket.persistence.realm.RocketChatPersistenceRealm;
*/
*/
public
class
RocketChatApplication
extends
MultiDexApplication
{
public
class
RocketChatApplication
extends
MultiDexApplication
{
private
static
RocketChatApplication
instance
;
public
static
RocketChatApplication
getInstance
()
{
return
instance
;
}
@Override
@Override
public
void
onCreate
()
{
public
void
onCreate
()
{
super
.
onCreate
();
super
.
onCreate
();
...
@@ -37,5 +43,7 @@ public class RocketChatApplication extends MultiDexApplication {
...
@@ -37,5 +43,7 @@ public class RocketChatApplication extends MultiDexApplication {
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
AppCompatDelegate
.
setCompatVectorFromResourcesEnabled
(
true
);
AppCompatDelegate
.
setCompatVectorFromResourcesEnabled
(
true
);
}
}
instance
=
this
;
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/RocketChatCache.java
View file @
058899ff
...
@@ -14,6 +14,8 @@ import java.util.Iterator;
...
@@ -14,6 +14,8 @@ import java.util.Iterator;
import
java.util.List
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.UUID
;
import
chat.rocket.android.helper.Logger
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.log.RCLog
;
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
;
...
@@ -41,7 +43,11 @@ public class RocketChatCache {
...
@@ -41,7 +43,11 @@ public class RocketChatCache {
}
}
public
void
setSelectedServerHostname
(
String
hostname
)
{
public
void
setSelectedServerHostname
(
String
hostname
)
{
setString
(
KEY_SELECTED_SERVER_HOSTNAME
,
hostname
.
toLowerCase
());
String
newHostname
=
null
;
if
(
hostname
!=
null
)
{
newHostname
=
hostname
.
toLowerCase
();
}
setString
(
KEY_SELECTED_SERVER_HOSTNAME
,
newHostname
);
}
}
public
void
addHostname
(
@NonNull
String
hostname
,
@Nullable
String
hostnameAvatarUri
,
String
siteName
)
{
public
void
addHostname
(
@NonNull
String
hostname
,
@Nullable
String
hostnameAvatarUri
,
String
siteName
)
{
...
@@ -54,7 +60,7 @@ public class RocketChatCache {
...
@@ -54,7 +60,7 @@ public class RocketChatCache {
json
=
new
JSONObject
(
hostnameList
);
json
=
new
JSONObject
(
hostnameList
);
}
}
JSONObject
serverInfoJson
=
new
JSONObject
();
JSONObject
serverInfoJson
=
new
JSONObject
();
serverInfoJson
.
put
(
"
hostname
"
,
hostnameAvatarUri
);
serverInfoJson
.
put
(
"
avatar
"
,
hostnameAvatarUri
);
serverInfoJson
.
put
(
"sitename"
,
siteName
);
serverInfoJson
.
put
(
"sitename"
,
siteName
);
// Replace server avatar uri if exists.
// Replace server avatar uri if exists.
json
.
put
(
hostname
,
hostnameAvatarUri
==
null
?
JSONObject
.
NULL
:
serverInfoJson
);
json
.
put
(
hostname
,
hostnameAvatarUri
==
null
?
JSONObject
.
NULL
:
serverInfoJson
);
...
@@ -76,7 +82,7 @@ public class RocketChatCache {
...
@@ -76,7 +82,7 @@ public class RocketChatCache {
String
hostname
=
iter
.
next
();
String
hostname
=
iter
.
next
();
JSONObject
serverInfoJson
=
jsonObj
.
getJSONObject
(
hostname
);
JSONObject
serverInfoJson
=
jsonObj
.
getJSONObject
(
hostname
);
serverList
.
add
(
new
Pair
<>(
hostname
,
new
Pair
<>(
serverList
.
add
(
new
Pair
<>(
hostname
,
new
Pair
<>(
"http://"
+
hostname
+
"/"
+
serverInfoJson
.
getString
(
"
hostname
"
),
"http://"
+
hostname
+
"/"
+
serverInfoJson
.
getString
(
"
avatar
"
),
serverInfoJson
.
getString
(
"sitename"
))));
serverInfoJson
.
getString
(
"sitename"
))));
}
}
return
serverList
;
return
serverList
;
...
@@ -86,12 +92,66 @@ public class RocketChatCache {
...
@@ -86,12 +92,66 @@ public class RocketChatCache {
return
Collections
.
emptyList
();
return
Collections
.
emptyList
();
}
}
public
void
removeHostname
(
String
hostname
)
{
String
json
=
getString
(
KEY_HOSTNAME_LIST
,
null
);
if
(
TextUtils
.
isEmpty
(
json
))
{
return
;
}
try
{
JSONObject
jsonObj
=
new
JSONObject
(
json
);
jsonObj
.
remove
(
hostname
);
String
result
=
jsonObj
.
length
()
==
0
?
null
:
jsonObj
.
toString
();
setString
(
KEY_HOSTNAME_LIST
,
result
);
}
catch
(
JSONException
e
)
{
RCLog
.
e
(
e
);
}
}
@Nullable
public
String
getFirstLoggedHostnameIfAny
()
{
String
json
=
getString
(
KEY_HOSTNAME_LIST
,
null
);
if
(
json
!=
null
)
{
try
{
JSONObject
jsonObj
=
new
JSONObject
(
json
);
if
(
jsonObj
.
length
()
>
0
&&
jsonObj
.
keys
().
hasNext
())
{
// Returns the first hostname on the list.
return
jsonObj
.
keys
().
next
();
}
}
catch
(
JSONException
e
)
{
RCLog
.
e
(
e
);
}
}
return
null
;
}
public
String
getSelectedRoomId
()
{
public
String
getSelectedRoomId
()
{
return
getString
(
getSelectedServerHostname
()
+
KEY_SELECTED_ROOM_ID
,
null
);
try
{
JSONObject
jsonObject
=
getSelectedRoomIdJsonObject
();
return
jsonObject
.
optString
(
getSelectedServerHostname
(),
null
);
}
catch
(
JSONException
e
)
{
RCLog
.
e
(
e
);
Logger
.
report
(
e
);
}
return
null
;
}
}
public
void
setSelectedRoomId
(
String
roomId
)
{
public
void
setSelectedRoomId
(
String
roomId
)
{
setString
(
getSelectedServerHostname
()
+
KEY_SELECTED_ROOM_ID
,
roomId
);
try
{
JSONObject
jsonObject
=
getSelectedRoomIdJsonObject
();
jsonObject
.
put
(
getSelectedServerHostname
(),
roomId
);
setString
(
KEY_SELECTED_ROOM_ID
,
jsonObject
.
toString
());
}
catch
(
JSONException
e
)
{
RCLog
.
e
(
e
);
Logger
.
report
(
e
);
}
}
private
JSONObject
getSelectedRoomIdJsonObject
()
throws
JSONException
{
String
json
=
getString
(
KEY_SELECTED_ROOM_ID
,
null
);
if
(
json
==
null
)
{
return
new
JSONObject
();
}
return
new
JSONObject
(
json
);
}
}
public
String
getOrCreatePushId
()
{
public
String
getOrCreatePushId
()
{
...
@@ -112,7 +172,7 @@ public class RocketChatCache {
...
@@ -112,7 +172,7 @@ public class RocketChatCache {
}
}
public
Flowable
<
Optional
<
String
>>
getSelectedRoomIdPublisher
()
{
public
Flowable
<
Optional
<
String
>>
getSelectedRoomIdPublisher
()
{
return
getValuePublisher
(
getSelectedServerHostname
()
+
KEY_SELECTED_ROOM_ID
);
return
getValuePublisher
(
KEY_SELECTED_ROOM_ID
);
}
}
private
SharedPreferences
getSharedPreferences
()
{
private
SharedPreferences
getSharedPreferences
()
{
...
@@ -147,4 +207,17 @@ public class RocketChatCache {
...
@@ -147,4 +207,17 @@ public class RocketChatCache {
getSharedPreferences
().
registerOnSharedPreferenceChangeListener
(
listener
);
getSharedPreferences
().
registerOnSharedPreferenceChangeListener
(
listener
);
},
BackpressureStrategy
.
LATEST
);
},
BackpressureStrategy
.
LATEST
);
}
}
public
void
removeSelectedRoomId
(
String
currentHostname
)
{
try
{
JSONObject
selectedRoomIdJsonObject
=
getSelectedRoomIdJsonObject
();
selectedRoomIdJsonObject
.
remove
(
currentHostname
);
String
result
=
selectedRoomIdJsonObject
.
length
()
==
0
?
null
:
selectedRoomIdJsonObject
.
toString
();
setString
(
KEY_SELECTED_ROOM_ID
,
result
);
}
catch
(
JSONException
e
)
{
Logger
.
report
(
e
);
RCLog
.
e
(
e
);
}
}
}
}
app/src/main/java/chat/rocket/android/activity/AbstractAuthedActivity.java
View file @
058899ff
...
@@ -6,6 +6,9 @@ import android.support.annotation.Nullable;
...
@@ -6,6 +6,9 @@ import android.support.annotation.Nullable;
import
com.hadisatrio.optional.Optional
;
import
com.hadisatrio.optional.Optional
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.util.List
;
import
java.util.List
;
import
chat.rocket.android.LaunchUtil
;
import
chat.rocket.android.LaunchUtil
;
...
@@ -61,6 +64,8 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
...
@@ -61,6 +64,8 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
if
(
intent
.
hasExtra
(
PushConstants
.
ROOM_ID
))
{
if
(
intent
.
hasExtra
(
PushConstants
.
ROOM_ID
))
{
rocketChatCache
.
setSelectedRoomId
(
intent
.
getStringExtra
(
PushConstants
.
ROOM_ID
));
rocketChatCache
.
setSelectedRoomId
(
intent
.
getStringExtra
(
PushConstants
.
ROOM_ID
));
}
}
}
else
{
updateHostnameIfNeeded
(
rocketChatCache
.
getSelectedServerHostname
());
}
}
if
(
intent
.
hasExtra
(
PushConstants
.
NOT_ID
))
{
if
(
intent
.
hasExtra
(
PushConstants
.
NOT_ID
))
{
...
@@ -194,7 +199,8 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
...
@@ -194,7 +199,8 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
compositeDisposable
.
add
(
compositeDisposable
.
add
(
rocketChatCache
.
getSelectedRoomIdPublisher
()
rocketChatCache
.
getSelectedRoomIdPublisher
()
.
map
(
Optional:
:
get
)
.
map
(
Optional:
:
get
)
.
distinctUntilChanged
()
.
map
(
this
::
convertStringToJsonObject
)
.
map
(
jsonObject
->
jsonObject
.
optString
(
rocketChatCache
.
getSelectedServerHostname
(),
null
))
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
.
subscribe
(
...
@@ -203,4 +209,11 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
...
@@ -203,4 +209,11 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
)
)
);
);
}
}
private
JSONObject
convertStringToJsonObject
(
String
json
)
throws
JSONException
{
if
(
json
==
null
)
{
return
new
JSONObject
();
}
return
new
JSONObject
(
json
);
}
}
}
app/src/main/java/chat/rocket/android/activity/AbstractFragmentActivity.java
View file @
058899ff
...
@@ -75,10 +75,28 @@ abstract class AbstractFragmentActivity extends RxAppCompatActivity {
...
@@ -75,10 +75,28 @@ abstract class AbstractFragmentActivity extends RxAppCompatActivity {
.
commit
();
.
commit
();
}
}
protected
void
showFragmentWithTagWithBackStack
(
Fragment
fragment
,
String
tag
)
{
getSupportFragmentManager
().
beginTransaction
()
.
replace
(
getLayoutContainerForFragment
(),
fragment
,
tag
)
.
addToBackStack
(
null
)
.
commit
();
}
protected
void
showFragmentWithTag
(
Fragment
fragment
,
String
tag
)
{
getSupportFragmentManager
().
beginTransaction
()
.
replace
(
getLayoutContainerForFragment
(),
fragment
,
tag
)
.
commit
();
}
protected
void
showFragmentWithBackStack
(
Fragment
fragment
)
{
protected
void
showFragmentWithBackStack
(
Fragment
fragment
)
{
getSupportFragmentManager
().
beginTransaction
()
getSupportFragmentManager
().
beginTransaction
()
.
replace
(
getLayoutContainerForFragment
(),
fragment
)
.
replace
(
getLayoutContainerForFragment
(),
fragment
)
.
addToBackStack
(
null
)
.
addToBackStack
(
null
)
.
commit
();
.
commit
();
}
}
@Nullable
protected
Fragment
findFragmentByTag
(
String
tag
)
{
return
getSupportFragmentManager
().
findFragmentByTag
(
tag
);
}
}
}
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
058899ff
...
@@ -88,7 +88,9 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -88,7 +88,9 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
}
}
private
void
showAddServerActivity
()
{
private
void
showAddServerActivity
()
{
closeSidebarIfNeeded
();
Intent
intent
=
new
Intent
(
this
,
AddServerActivity
.
class
);
Intent
intent
=
new
Intent
(
this
,
AddServerActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
|
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
|
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
intent
.
putExtra
(
AddServerActivity
.
EXTRA_FINISH_ON_BACK_PRESS
,
true
);
intent
.
putExtra
(
AddServerActivity
.
EXTRA_FINISH_ON_BACK_PRESS
,
true
);
startActivity
(
intent
);
startActivity
(
intent
);
}
}
...
@@ -161,13 +163,15 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -161,13 +163,15 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
PublicSettingRepository
publicSettingRepository
=
new
RealmPublicSettingRepository
(
hostname
);
PublicSettingRepository
publicSettingRepository
=
new
RealmPublicSettingRepository
(
hostname
);
RocketChatCache
rocketChatCache
=
new
RocketChatCache
(
this
);
presenter
=
new
MainPresenter
(
presenter
=
new
MainPresenter
(
roomInteractor
,
roomInteractor
,
createRoomInteractor
,
createRoomInteractor
,
sessionInteractor
,
sessionInteractor
,
new
MethodCallHelper
(
this
,
hostname
),
new
MethodCallHelper
(
this
,
hostname
),
ConnectivityManager
.
getInstance
(
getApplicationContext
()),
ConnectivityManager
.
getInstance
(
getApplicationContext
()),
new
RocketChatCache
(
this
)
,
rocketChatCache
,
publicSettingRepository
publicSettingRepository
);
);
...
@@ -175,13 +179,21 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -175,13 +179,21 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
presenter
.
bindView
(
this
);
presenter
.
bindView
(
this
);
presenter
.
loadSignedInServers
(
hostname
);
presenter
.
loadSignedInServers
(
hostname
);
roomId
=
rocketChatCache
.
getSelectedRoomId
();
}
}
private
void
updateSidebarMainFragment
()
{
private
void
updateSidebarMainFragment
()
{
closeSidebarIfNeeded
();
closeSidebarIfNeeded
();
String
selectedServerHostname
=
new
RocketChatCache
(
this
).
getSelectedServerHostname
();
Fragment
sidebarFragment
=
findFragmentByTag
(
selectedServerHostname
);
if
(
sidebarFragment
==
null
)
{
sidebarFragment
=
SidebarMainFragment
.
create
(
selectedServerHostname
);
}
getSupportFragmentManager
().
beginTransaction
()
getSupportFragmentManager
().
beginTransaction
()
.
replace
(
R
.
id
.
sidebar_fragment_container
,
SidebarMainFragment
.
create
(
hostname
)
)
.
replace
(
R
.
id
.
sidebar_fragment_container
,
sidebarFragment
,
selectedServerHostname
)
.
commit
();
.
commit
();
getSupportFragmentManager
().
executePendingTransactions
();
}
}
@Override
@Override
...
@@ -239,6 +251,12 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -239,6 +251,12 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
R
.
string
.
server_config_activity_authenticating
,
Snackbar
.
LENGTH_INDEFINITE
));
R
.
string
.
server_config_activity_authenticating
,
Snackbar
.
LENGTH_INDEFINITE
));
}
}
public
void
showLogoutMessage
()
{
statusTicker
.
updateStatus
(
StatusTicker
.
STATUS_LOGGING_OUT
,
Snackbar
.
make
(
findViewById
(
getLayoutContainerForFragment
()),
"Logging Out..."
,
Snackbar
.
LENGTH_INDEFINITE
));
}
@Override
@Override
public
void
showConnectionOk
()
{
public
void
showConnectionOk
()
{
statusTicker
.
updateStatus
(
StatusTicker
.
STATUS_DISMISS
,
null
);
statusTicker
.
updateStatus
(
StatusTicker
.
STATUS_DISMISS
,
null
);
...
@@ -251,39 +269,41 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -251,39 +269,41 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
LinearLayout
serverListContainer
=
subPane
.
findViewById
(
R
.
id
.
server_list_bar
);
LinearLayout
serverListContainer
=
subPane
.
findViewById
(
R
.
id
.
server_list_bar
);
View
addServerButton
=
subPane
.
findViewById
(
R
.
id
.
btn_add_server
);
View
addServerButton
=
subPane
.
findViewById
(
R
.
id
.
btn_add_server
);
addServerButton
.
setOnClickListener
(
view
->
showAddServerActivity
());
addServerButton
.
setOnClickListener
(
view
->
showAddServerActivity
());
serverListContainer
.
removeAllViews
();
for
(
Pair
<
String
,
Pair
<
String
,
String
>>
server
:
serverList
)
{
for
(
Pair
<
String
,
Pair
<
String
,
String
>>
server
:
serverList
)
{
String
serverHostname
=
server
.
first
;
String
serverHostname
=
server
.
first
;
Pair
<
String
,
String
>
serverInfoPair
=
server
.
second
;
Pair
<
String
,
String
>
serverInfoPair
=
server
.
second
;
String
logoUrl
=
serverInfoPair
.
first
;
String
logoUrl
=
serverInfoPair
.
first
;
String
siteName
=
serverInfoPair
.
second
;
String
siteName
=
serverInfoPair
.
second
;
if
(
serverListContainer
.
findViewWithTag
(
serverHostname
)
==
null
)
{
View
serverView
=
serverListContainer
.
findViewWithTag
(
serverHostname
);
int
serverCount
=
serverListContainer
.
getChildCount
();
if
(
serverView
==
null
)
{
View
newServerView
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
server_row
,
serverListContainer
,
false
);
View
serverRow
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
server_row
,
serverListContainer
,
false
);
SimpleDraweeView
serverButton
=
newServerView
.
findViewById
(
R
.
id
.
drawee_server_button
);
SimpleDraweeView
serverButton
=
serverRow
.
findViewById
(
R
.
id
.
drawee_server_button
);
TextView
hostnameLabel
=
newServerView
.
findViewById
(
R
.
id
.
text_view_server_label
);
TextView
hostnameLabel
=
serverRow
.
findViewById
(
R
.
id
.
text_view_server_label
);
TextView
siteNameLabel
=
newServerView
.
findViewById
(
R
.
id
.
text_view_site_name_label
);
TextView
siteNameLabel
=
serverRow
.
findViewById
(
R
.
id
.
text_view_site_name_label
);
ImageView
dotView
=
newServerView
.
findViewById
(
R
.
id
.
selected_server_dot
);
ImageView
dotView
=
serverRow
.
findViewById
(
R
.
id
.
selected_server_dot
);
newServerView
.
setTag
(
serverHostname
);
serverButton
.
setTag
(
serverHostname
);
hostnameLabel
.
setText
(
serverHostname
);
hostnameLabel
.
setText
(
serverHostname
);
siteNameLabel
.
setText
(
siteName
);
siteNameLabel
.
setText
(
siteName
);
// Currently selected server
// Currently selected server
if
(
serverHostname
.
equalsIgnoreCase
(
h
ostname
))
{
if
(
hostname
.
equalsIgnoreCase
(
serverH
ostname
))
{
serverRo
w
.
setSelected
(
true
);
newServerVie
w
.
setSelected
(
true
);
dotView
.
setVisibility
(
View
.
VISIBLE
);
dotView
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
}
else
{
newServerView
.
setSelected
(
false
);
dotView
.
setVisibility
(
View
.
GONE
);
dotView
.
setVisibility
(
View
.
GONE
);
}
}
serverRo
w
.
setOnClickListener
(
view
->
changeServerIfNeeded
(
serverHostname
));
newServerVie
w
.
setOnClickListener
(
view
->
changeServerIfNeeded
(
serverHostname
));
FrescoHelper
.
INSTANCE
.
loadImage
(
serverButton
,
logoUrl
,
ContextCompat
.
getDrawable
(
this
,
R
.
mipmap
.
ic_launcher
));
FrescoHelper
.
INSTANCE
.
loadImage
(
serverButton
,
logoUrl
,
ContextCompat
.
getDrawable
(
this
,
R
.
mipmap
.
ic_launcher
));
serverListContainer
.
addView
(
serverRow
,
serverCount
-
1
);
serverListContainer
.
addView
(
newServerView
);
}
}
}
}
serverListContainer
.
addView
(
addServerButton
);
}
}
}
}
...
@@ -291,15 +311,34 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -291,15 +311,34 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
if
(!
hostname
.
equalsIgnoreCase
(
serverHostname
))
{
if
(!
hostname
.
equalsIgnoreCase
(
serverHostname
))
{
RocketChatCache
rocketChatCache
=
new
RocketChatCache
(
getApplicationContext
());
RocketChatCache
rocketChatCache
=
new
RocketChatCache
(
getApplicationContext
());
rocketChatCache
.
setSelectedServerHostname
(
serverHostname
);
rocketChatCache
.
setSelectedServerHostname
(
serverHostname
);
recreate
();
}
}
}
}
@DebugLog
public
void
hideLogoutMessage
()
{
statusTicker
.
updateStatus
(
StatusTicker
.
STATUS_DISMISS
,
null
);
}
@DebugLog
public
void
onLogout
()
{
if
(
new
RocketChatCache
(
getApplicationContext
()).
getSelectedServerHostname
()
==
null
)
{
LaunchUtil
.
showMainActivity
(
this
);
}
else
{
onHostnameUpdated
();
}
}
@DebugLog
public
void
beforeLogoutCleanUp
()
{
presenter
.
beforeLogoutCleanUp
();
}
//TODO: consider this class to define in layouthelper for more complicated operation.
//TODO: consider this class to define in layouthelper for more complicated operation.
private
static
class
StatusTicker
{
private
static
class
StatusTicker
{
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 @
058899ff
...
@@ -37,5 +37,7 @@ public interface MainContract {
...
@@ -37,5 +37,7 @@ public interface MainContract {
void
bindViewOnly
(
View
view
);
void
bindViewOnly
(
View
view
);
void
loadSignedInServers
(
String
hostname
);
void
loadSignedInServers
(
String
hostname
);
void
beforeLogoutCleanUp
();
}
}
}
}
app/src/main/java/chat/rocket/android/activity/MainPresenter.java
View file @
058899ff
...
@@ -133,6 +133,11 @@ public class MainPresenter extends BasePresenter<MainContract.View>
...
@@ -133,6 +133,11 @@ public class MainPresenter extends BasePresenter<MainContract.View>
addSubscription
(
subscription
);
addSubscription
(
subscription
);
}
}
@Override
public
void
beforeLogoutCleanUp
()
{
clearSubscriptions
();
}
private
Pair
<
String
,
String
>
getLogoAndSiteNamePair
(
Pair
<
Optional
<
PublicSetting
>,
Optional
<
PublicSetting
>>
settingsPair
)
{
private
Pair
<
String
,
String
>
getLogoAndSiteNamePair
(
Pair
<
Optional
<
PublicSetting
>,
Optional
<
PublicSetting
>>
settingsPair
)
{
String
logoUrl
=
""
;
String
logoUrl
=
""
;
String
siteName
=
""
;
String
siteName
=
""
;
...
...
app/src/main/java/chat/rocket/android/api/MethodCallHelper.java
View file @
058899ff
...
@@ -2,7 +2,7 @@ package chat.rocket.android.api;
...
@@ -2,7 +2,7 @@ package chat.rocket.android.api;
import
android.content.Context
;
import
android.content.Context
;
import
android.util.Patterns
;
import
android.util.Patterns
;
import
chat.rocket.persistence.realm.models.ddp.RealmSpotlight
;
import
org.json.JSONArray
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
...
@@ -17,7 +17,6 @@ import chat.rocket.android.service.ConnectivityManager;
...
@@ -17,7 +17,6 @@ import chat.rocket.android.service.ConnectivityManager;
import
chat.rocket.android.service.DDPClientRef
;
import
chat.rocket.android.service.DDPClientRef
;
import
chat.rocket.android_ddp.DDPClientCallback
;
import
chat.rocket.android_ddp.DDPClientCallback
;
import
chat.rocket.core.SyncState
;
import
chat.rocket.core.SyncState
;
import
chat.rocket.core.models.ServerInfo
;
import
chat.rocket.persistence.realm.RealmHelper
;
import
chat.rocket.persistence.realm.RealmHelper
;
import
chat.rocket.persistence.realm.RealmStore
;
import
chat.rocket.persistence.realm.RealmStore
;
import
chat.rocket.persistence.realm.models.ddp.RealmMessage
;
import
chat.rocket.persistence.realm.models.ddp.RealmMessage
;
...
@@ -25,6 +24,7 @@ import chat.rocket.persistence.realm.models.ddp.RealmPermission;
...
@@ -25,6 +24,7 @@ import chat.rocket.persistence.realm.models.ddp.RealmPermission;
import
chat.rocket.persistence.realm.models.ddp.RealmPublicSetting
;
import
chat.rocket.persistence.realm.models.ddp.RealmPublicSetting
;
import
chat.rocket.persistence.realm.models.ddp.RealmRoom
;
import
chat.rocket.persistence.realm.models.ddp.RealmRoom
;
import
chat.rocket.persistence.realm.models.ddp.RealmRoomRole
;
import
chat.rocket.persistence.realm.models.ddp.RealmRoomRole
;
import
chat.rocket.persistence.realm.models.ddp.RealmSpotlight
;
import
chat.rocket.persistence.realm.models.ddp.RealmSpotlightRoom
;
import
chat.rocket.persistence.realm.models.ddp.RealmSpotlightRoom
;
import
chat.rocket.persistence.realm.models.ddp.RealmSpotlightUser
;
import
chat.rocket.persistence.realm.models.ddp.RealmSpotlightUser
;
import
chat.rocket.persistence.realm.models.internal.MethodCall
;
import
chat.rocket.persistence.realm.models.internal.MethodCall
;
...
@@ -260,18 +260,12 @@ public class MethodCallHelper {
...
@@ -260,18 +260,12 @@ public class MethodCallHelper {
* Logout.
* Logout.
*/
*/
public
Task
<
Void
>
logout
()
{
public
Task
<
Void
>
logout
()
{
return
call
(
"logout"
,
TIMEOUT_MS
).
onSuccessTask
(
task
->
return
call
(
"logout"
,
TIMEOUT_MS
).
onSuccessTask
(
task
->
{
realmHelper
.
executeTransaction
(
realm
->
{
if
(
task
.
isFaulted
())
{
realm
.
delete
(
RealmSession
.
class
);
return
Task
.
forError
(
task
.
getError
());
//check whether the server list is empty
}
if
(!
ConnectivityManager
.
getInstance
(
context
).
getServerList
().
isEmpty
()){
return
null
;
//for each server in serverList -> remove the server
});
for
(
ServerInfo
server:
ConnectivityManager
.
getInstance
(
context
).
getServerList
())
{
ConnectivityManager
.
getInstance
(
context
.
getApplicationContext
()).
removeServer
(
server
.
getHostname
());
}
}
return
null
;
}));
}
}
/**
/**
...
...
app/src/main/java/chat/rocket/android/fragment/add_server/InputHostnamePresenter.java
View file @
058899ff
package
chat
.
rocket
.
android
.
fragment
.
add_server
;
package
chat
.
rocket
.
android
.
fragment
.
add_server
;
import
chat.rocket.android.BackgroundLooper
;
import
chat.rocket.android.BackgroundLooper
;
import
chat.rocket.android.helper.Logger
;
import
chat.rocket.android.helper.OkHttpHelper
;
import
chat.rocket.android.helper.OkHttpHelper
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.disposables.Disposable
;
import
io.reactivex.disposables.Disposable
;
...
@@ -46,7 +47,10 @@ public class InputHostnamePresenter extends BasePresenter<InputHostnameContract.
...
@@ -46,7 +47,10 @@ public class InputHostnamePresenter extends BasePresenter<InputHostnameContract.
view
.
showInvalidServerError
();
view
.
showInvalidServerError
();
}
}
},
},
throwable
->
view
.
showConnectionError
());
throwable
->
{
Logger
.
report
(
throwable
);
view
.
showConnectionError
();
});
addSubscription
(
subscription
);
addSubscription
(
subscription
);
}
}
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/AbstractChatRoomFragment.java
View file @
058899ff
...
@@ -22,6 +22,7 @@ abstract class AbstractChatRoomFragment extends AbstractFragment {
...
@@ -22,6 +22,7 @@ abstract class AbstractChatRoomFragment extends AbstractFragment {
}
}
protected
void
setToolbarTitle
(
CharSequence
title
)
{
protected
void
setToolbarTitle
(
CharSequence
title
)
{
roomToolbar
.
hideChannelIcons
();
roomToolbar
.
setTitle
(
title
);
roomToolbar
.
setTitle
(
title
);
}
}
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/list/RoomListPresenter.kt
View file @
058899ff
...
@@ -2,6 +2,7 @@ package chat.rocket.android.fragment.chatroom.list
...
@@ -2,6 +2,7 @@ package chat.rocket.android.fragment.chatroom.list
import
android.content.Context
import
android.content.Context
import
android.os.Handler
import
android.os.Handler
import
android.util.Log
import
chat.rocket.android.R
import
chat.rocket.android.R
import
chat.rocket.android.api.rest.RestApiHelper
import
chat.rocket.android.api.rest.RestApiHelper
import
chat.rocket.android.helper.OkHttpHelper
import
chat.rocket.android.helper.OkHttpHelper
...
@@ -11,6 +12,7 @@ import chat.rocket.core.models.User
...
@@ -11,6 +12,7 @@ import chat.rocket.core.models.User
import
okhttp3.Call
import
okhttp3.Call
import
okhttp3.Callback
import
okhttp3.Callback
import
okhttp3.Response
import
okhttp3.Response
import
org.json.JSONException
import
org.json.JSONObject
import
org.json.JSONObject
import
java.io.IOException
import
java.io.IOException
import
java.sql.Timestamp
import
java.sql.Timestamp
...
@@ -147,72 +149,80 @@ class RoomListPresenter(val context: Context, val view: RoomListContract.View) :
...
@@ -147,72 +149,80 @@ class RoomListPresenter(val context: Context, val view: RoomListContract.View) :
}
}
private
fun
handleMessagesJson
(
json
:
String
,
isPinnedMessage
:
Boolean
)
{
private
fun
handleMessagesJson
(
json
:
String
,
isPinnedMessage
:
Boolean
)
{
val
jSONObject
=
JSONObject
(
json
)
try
{
val
messagesJSONArray
=
jSONObject
.
getJSONArray
(
"messages"
)
val
jSONObject
=
JSONObject
(
json
)
val
messagesJSONArray
=
jSONObject
.
getJSONArray
(
"messages"
)
val
total
=
messagesJSONArray
.
length
()
val
total
=
messagesJSONArray
.
length
()
val
dataSet
=
ArrayList
<
Message
>(
total
)
val
dataSet
=
ArrayList
<
Message
>(
total
)
(
0
until
total
).
mapTo
(
dataSet
)
{
(
0
until
total
).
mapTo
(
dataSet
)
{
val
messageJsonObject
=
messagesJSONArray
.
getJSONObject
(
it
)
val
messageJsonObject
=
messagesJSONArray
.
getJSONObject
(
it
)
val
userJsonObject
=
messageJsonObject
.
getJSONObject
(
"u"
)
val
userJsonObject
=
messageJsonObject
.
getJSONObject
(
"u"
)
val
timestampString
=
messageJsonObject
.
optString
(
"ts"
)
val
timestampString
=
messageJsonObject
.
optString
(
"ts"
)
val
timestamp
=
if
(
timestampString
.
isBlank
())
{
val
timestamp
=
if
(
timestampString
.
isBlank
())
{
0
0
}
else
{
}
else
{
Timestamp
.
valueOf
(
timestampString
.
replace
(
"T"
,
" "
).
replace
(
"Z"
,
""
)).
time
Timestamp
.
valueOf
(
timestampString
.
replace
(
"T"
,
" "
).
replace
(
"Z"
,
""
)).
time
}
}
val
editedAtString
=
messageJsonObject
.
optString
(
"_updatedAt"
)
val
editedAtString
=
messageJsonObject
.
optString
(
"_updatedAt"
)
val
editedAt
=
if
(
editedAtString
.
isBlank
())
{
val
editedAt
=
if
(
editedAtString
.
isBlank
())
{
0
0
}
else
{
}
else
{
Timestamp
.
valueOf
(
editedAtString
.
replace
(
"T"
,
" "
).
replace
(
"Z"
,
""
)).
time
Timestamp
.
valueOf
(
editedAtString
.
replace
(
"T"
,
" "
).
replace
(
"Z"
,
""
)).
time
}
}
Message
.
builder
()
Message
.
builder
()
.
setId
(
messageJsonObject
.
optString
(
"_id"
))
.
setId
(
messageJsonObject
.
optString
(
"_id"
))
.
setRoomId
(
messageJsonObject
.
optString
(
"rid"
))
.
setRoomId
(
messageJsonObject
.
optString
(
"rid"
))
.
setMessage
(
messageJsonObject
.
optString
(
"msg"
))
.
setMessage
(
messageJsonObject
.
optString
(
"msg"
))
.
setUser
(
getUserFromJsonObject
(
userJsonObject
))
.
setUser
(
getUserFromJsonObject
(
userJsonObject
))
.
setTimestamp
(
timestamp
)
.
setTimestamp
(
timestamp
)
.
setEditedAt
(
editedAt
)
.
setEditedAt
(
editedAt
)
.
setGroupable
(
messageJsonObject
.
optBoolean
(
"groupable"
))
.
setGroupable
(
messageJsonObject
.
optBoolean
(
"groupable"
))
.
setSyncState
(
SyncState
.
SYNCED
)
.
setSyncState
(
SyncState
.
SYNCED
)
.
build
()
.
build
()
}
}
if
(
dataSet
.
isEmpty
()
&&
!
hasItem
)
{
if
(
dataSet
.
isEmpty
()
&&
!
hasItem
)
{
showEmptyViewMessage
(
context
.
getString
(
R
.
string
.
fragment_room_list_no_favorite_message_to_show
))
showEmptyViewMessage
(
context
.
getString
(
R
.
string
.
fragment_room_list_no_favorite_message_to_show
))
}
else
{
}
else
{
if
(
dataSet
.
isNotEmpty
())
{
if
(
dataSet
.
isNotEmpty
())
{
hasItem
=
true
hasItem
=
true
if
(
isPinnedMessage
)
{
if
(
isPinnedMessage
)
{
showPinnedMessageList
(
dataSet
,
jSONObject
.
optString
(
"total"
))
showPinnedMessageList
(
dataSet
,
jSONObject
.
optString
(
"total"
))
}
else
{
}
else
{
showFavoriteMessageList
(
dataSet
,
jSONObject
.
optString
(
"total"
))
showFavoriteMessageList
(
dataSet
,
jSONObject
.
optString
(
"total"
))
}
}
}
}
}
}
catch
(
exception
:
JSONException
)
{
showInvalidRequest
()
}
}
}
}
private
fun
handleMembersJson
(
json
:
String
)
{
private
fun
handleMembersJson
(
json
:
String
)
{
val
jsonObject
=
JSONObject
(
json
)
try
{
val
membersJsonArray
=
jsonObject
.
getJSONArray
(
"members"
)
val
jsonObject
=
JSONObject
(
json
)
val
membersJsonArray
=
jsonObject
.
getJSONArray
(
"members"
)
val
total
=
membersJsonArray
.
length
()
val
total
=
membersJsonArray
.
length
()
val
dataSet
=
ArrayList
<
User
>(
total
)
val
dataSet
=
ArrayList
<
User
>(
total
)
(
0
until
total
).
mapTo
(
dataSet
)
{
(
0
until
total
).
mapTo
(
dataSet
)
{
getUserFromJsonObject
(
membersJsonArray
.
getJSONObject
(
it
))
getUserFromJsonObject
(
membersJsonArray
.
getJSONObject
(
it
))
}
}
if
(
dataSet
.
isEmpty
()
&&
!
hasItem
)
{
if
(
dataSet
.
isEmpty
()
&&
!
hasItem
)
{
showEmptyViewMessage
(
context
.
getString
(
R
.
string
.
fragment_room_list_no_member_list_to_show
))
showEmptyViewMessage
(
context
.
getString
(
R
.
string
.
fragment_room_list_no_member_list_to_show
))
}
else
{
}
else
{
if
(
dataSet
.
isNotEmpty
())
{
if
(
dataSet
.
isNotEmpty
())
{
hasItem
=
true
hasItem
=
true
showMemberList
(
dataSet
,
jsonObject
.
optString
(
"total"
))
showMemberList
(
dataSet
,
jsonObject
.
optString
(
"total"
))
}
}
}
}
catch
(
exception
:
JSONException
)
{
showInvalidRequest
()
}
}
}
}
...
@@ -247,6 +257,13 @@ class RoomListPresenter(val context: Context, val view: RoomListContract.View) :
...
@@ -247,6 +257,13 @@ class RoomListPresenter(val context: Context, val view: RoomListContract.View) :
}
}
}
}
private
fun
showInvalidRequest
()
{
mainHandler
.
post
{
view
.
showWaitingView
(
false
)
view
.
showMessage
(
context
.
getString
(
R
.
string
.
fragment_room_list_could_not_load_your_request
,
context
.
getString
(
R
.
string
.
make_sure_your_server_version_is_up_to_date
)))
}
}
private
fun
showEmptyViewMessage
(
message
:
String
)
{
private
fun
showEmptyViewMessage
(
message
:
String
)
{
mainHandler
.
post
{
mainHandler
.
post
{
view
.
showWaitingView
(
false
)
view
.
showWaitingView
(
false
)
...
...
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainContract.java
View file @
058899ff
...
@@ -2,6 +2,7 @@ package chat.rocket.android.fragment.sidebar;
...
@@ -2,6 +2,7 @@ package chat.rocket.android.fragment.sidebar;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
bolts.Continuation
;
import
chat.rocket.core.models.RoomSidebar
;
import
chat.rocket.core.models.RoomSidebar
;
import
io.reactivex.Flowable
;
import
io.reactivex.Flowable
;
import
java.util.List
;
import
java.util.List
;
...
@@ -22,6 +23,8 @@ public interface SidebarMainContract {
...
@@ -22,6 +23,8 @@ public interface SidebarMainContract {
void
filterRoomSidebarList
(
CharSequence
term
);
void
filterRoomSidebarList
(
CharSequence
term
);
void
show
(
User
user
);
void
show
(
User
user
);
void
onLogoutCleanUp
();
}
}
interface
Presenter
extends
BaseContract
.
Presenter
<
View
>
{
interface
Presenter
extends
BaseContract
.
Presenter
<
View
>
{
...
@@ -42,6 +45,8 @@ public interface SidebarMainContract {
...
@@ -42,6 +45,8 @@ public interface SidebarMainContract {
void
onUserOffline
();
void
onUserOffline
();
void
onLogout
();
void
onLogout
(
Continuation
<
Void
,
Object
>
continuation
);
void
beforeLogoutCleanUp
();
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainFragment.java
View file @
058899ff
package
chat
.
rocket
.
android
.
fragment
.
sidebar
;
package
chat
.
rocket
.
android
.
fragment
.
sidebar
;
import
android.annotation.SuppressLint
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
...
@@ -8,13 +9,23 @@ import android.support.v4.app.DialogFragment;
...
@@ -8,13 +9,23 @@ import android.support.v4.app.DialogFragment;
import
android.support.v7.widget.LinearLayoutManager
;
import
android.support.v7.widget.LinearLayoutManager
;
import
android.support.v7.widget.RecyclerView
;
import
android.support.v7.widget.RecyclerView
;
import
android.support.v7.widget.SearchView
;
import
android.support.v7.widget.SearchView
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.CompoundButton
;
import
android.widget.CompoundButton
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.jakewharton.rxbinding2.support.v7.widget.RxSearchView
;
import
com.jakewharton.rxbinding2.widget.RxCompoundButton
;
import
java.util.ArrayList
;
import
java.util.List
;
import
bolts.Task
;
import
chat.rocket.android.BuildConfig
;
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.api.MethodCallHelper
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.fragment.AbstractFragment
;
import
chat.rocket.android.fragment.AbstractFragment
;
import
chat.rocket.android.fragment.sidebar.dialog.AddChannelDialogFragment
;
import
chat.rocket.android.fragment.sidebar.dialog.AddChannelDialogFragment
;
...
@@ -39,15 +50,9 @@ import chat.rocket.persistence.realm.repositories.RealmServerInfoRepository;
...
@@ -39,15 +50,9 @@ import chat.rocket.persistence.realm.repositories.RealmServerInfoRepository;
import
chat.rocket.persistence.realm.repositories.RealmSessionRepository
;
import
chat.rocket.persistence.realm.repositories.RealmSessionRepository
;
import
chat.rocket.persistence.realm.repositories.RealmSpotlightRepository
;
import
chat.rocket.persistence.realm.repositories.RealmSpotlightRepository
;
import
chat.rocket.persistence.realm.repositories.RealmUserRepository
;
import
chat.rocket.persistence.realm.repositories.RealmUserRepository
;
import
com.jakewharton.rxbinding2.support.v7.widget.RxSearchView
;
import
com.jakewharton.rxbinding2.widget.RxCompoundButton
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.disposables.Disposable
;
import
io.reactivex.disposables.Disposable
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
SidebarMainFragment
extends
AbstractFragment
implements
SidebarMainContract
.
View
{
public
class
SidebarMainFragment
extends
AbstractFragment
implements
SidebarMainContract
.
View
{
private
SidebarMainContract
.
Presenter
presenter
;
private
SidebarMainContract
.
Presenter
presenter
;
private
RoomListAdapter
adapter
;
private
RoomListAdapter
adapter
;
...
@@ -87,26 +92,42 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
...
@@ -87,26 +92,42 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
new
SessionInteractor
(
new
RealmSessionRepository
(
hostname
))
new
SessionInteractor
(
new
RealmSessionRepository
(
hostname
))
);
);
RocketChatCache
rocketChatCache
=
new
RocketChatCache
(
getContext
().
getApplicationContext
());
presenter
=
new
SidebarMainPresenter
(
presenter
=
new
SidebarMainPresenter
(
hostname
,
hostname
,
new
RoomInteractor
(
new
RealmRoomRepository
(
hostname
)),
new
RoomInteractor
(
new
RealmRoomRepository
(
hostname
)),
userRepository
,
userRepository
,
new
RocketChatCache
(
getContext
())
,
rocketChatCache
,
absoluteUrlHelper
,
absoluteUrlHelper
,
new
MethodCallHelper
(
getContext
(),
hostname
),
new
MethodCallHelper
(
getContext
(),
hostname
),
new
RealmSpotlightRepository
(
hostname
)
new
RealmSpotlightRepository
(
hostname
)
);
);
}
}
@Nullable
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
View
view
=
super
.
onCreateView
(
inflater
,
container
,
savedInstanceState
);
presenter
.
bindView
(
this
);
return
view
;
}
@Override
public
void
onDestroyView
()
{
presenter
.
release
();
super
.
onDestroyView
();
}
@Override
@Override
public
void
onResume
()
{
public
void
onResume
()
{
super
.
onResume
();
super
.
onResume
();
presenter
.
bindView
(
this
);
}
}
@Override
@Override
public
void
onPause
()
{
public
void
onPause
()
{
presenter
.
release
();
super
.
onPause
();
super
.
onPause
();
}
}
...
@@ -285,7 +306,7 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
...
@@ -285,7 +306,7 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
));
));
roomListHeaders
.
add
(
new
LivechatRoomListHeader
(
roomListHeaders
.
add
(
new
LivechatRoomListHeader
(
getString
(
R
.
string
.
fragment_sidebar_main_livechat_title
)
getString
(
R
.
string
.
fragment_sidebar_main_livechat_title
)
));
));
roomListHeaders
.
add
(
new
ChannelRoomListHeader
(
roomListHeaders
.
add
(
new
ChannelRoomListHeader
(
...
@@ -300,12 +321,32 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
...
@@ -300,12 +321,32 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
adapter
.
setRoomListHeaders
(
roomListHeaders
);
adapter
.
setRoomListHeaders
(
roomListHeaders
);
}
}
@Override
public
void
onLogoutCleanUp
()
{
Activity
activity
=
getActivity
();
if
(
activity
!=
null
&&
activity
instanceof
MainActivity
)
{
((
MainActivity
)
activity
).
hideLogoutMessage
();
((
MainActivity
)
activity
).
onLogout
();
presenter
.
onLogout
(
task
->
{
if
(
task
.
isFaulted
())
{
return
Task
.
forError
(
task
.
getError
());
}
return
null
;
});
}
}
private
void
setupLogoutButton
()
{
private
void
setupLogoutButton
()
{
rootView
.
findViewById
(
R
.
id
.
btn_logout
).
setOnClickListener
(
view
->
{
rootView
.
findViewById
(
R
.
id
.
btn_logout
).
setOnClickListener
(
view
->
{
presenter
.
onLogout
();
closeUserActionContainer
();
closeUserActionContainer
();
// destroy Activity on logout to be able to recreate most of the environment
// Clear relative data and set new hostname if any.
this
.
getActivity
().
finish
();
presenter
.
beforeLogoutCleanUp
();
final
Activity
activity
=
getActivity
();
if
(
activity
!=
null
&&
activity
instanceof
MainActivity
)
{
((
MainActivity
)
activity
).
showLogoutMessage
();
// Clear subscriptions on MainPresenter.
((
MainActivity
)
activity
).
beforeLogoutCleanUp
();
}
});
});
}
}
...
...
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainPresenter.java
View file @
058899ff
...
@@ -6,13 +6,18 @@ import android.support.v4.util.Pair;
...
@@ -6,13 +6,18 @@ import android.support.v4.util.Pair;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
bolts.Continuation
;
import
bolts.Task
;
import
chat.rocket.android.BackgroundLooper
;
import
chat.rocket.android.BackgroundLooper
;
import
chat.rocket.android.RocketChatApplication
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.helper.AbsoluteUrlHelper
;
import
chat.rocket.android.helper.AbsoluteUrlHelper
;
import
chat.rocket.android.helper.LogIfError
;
import
chat.rocket.android.helper.LogIfError
;
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.service.ConnectivityManagerApi
;
import
chat.rocket.android.shared.BasePresenter
;
import
chat.rocket.android.shared.BasePresenter
;
import
chat.rocket.core.interactors.RoomInteractor
;
import
chat.rocket.core.interactors.RoomInteractor
;
import
chat.rocket.core.models.Room
;
import
chat.rocket.core.models.Room
;
...
@@ -21,6 +26,8 @@ import chat.rocket.core.models.Spotlight;
...
@@ -21,6 +26,8 @@ import chat.rocket.core.models.Spotlight;
import
chat.rocket.core.models.User
;
import
chat.rocket.core.models.User
;
import
chat.rocket.core.repositories.SpotlightRepository
;
import
chat.rocket.core.repositories.SpotlightRepository
;
import
chat.rocket.core.repositories.UserRepository
;
import
chat.rocket.core.repositories.UserRepository
;
import
chat.rocket.persistence.realm.RealmHelper
;
import
chat.rocket.persistence.realm.RealmStore
;
import
chat.rocket.persistence.realm.repositories.RealmSpotlightRepository
;
import
chat.rocket.persistence.realm.repositories.RealmSpotlightRepository
;
import
io.reactivex.Flowable
;
import
io.reactivex.Flowable
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
...
@@ -131,8 +138,31 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
...
@@ -131,8 +138,31 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
}
}
@Override
@Override
public
void
onLogout
()
{
public
void
onLogout
(
Continuation
<
Void
,
Object
>
continuation
)
{
methodCallHelper
.
logout
().
continueWith
(
new
LogIfError
());
methodCallHelper
.
logout
().
continueWith
(
task
->
{
if
(
task
.
isFaulted
())
{
Logger
.
report
(
task
.
getError
());
return
Task
.
forError
(
task
.
getError
());
}
return
task
.
onSuccess
(
continuation
);
});
}
@Override
public
void
beforeLogoutCleanUp
()
{
clearSubscriptions
();
String
currentHostname
=
rocketChatCache
.
getSelectedServerHostname
();
RealmHelper
realmHelper
=
RealmStore
.
getOrCreate
(
currentHostname
);
realmHelper
.
executeTransaction
(
realm
->
{
realm
.
deleteAll
();
ConnectivityManagerApi
connectivityManagerApi
=
ConnectivityManager
.
getInstance
(
RocketChatApplication
.
getInstance
());
connectivityManagerApi
.
removeServer
(
currentHostname
);
rocketChatCache
.
removeHostname
(
currentHostname
);
rocketChatCache
.
removeSelectedRoomId
(
currentHostname
);
rocketChatCache
.
setSelectedServerHostname
(
rocketChatCache
.
getFirstLoggedHostnameIfAny
());
view
.
onLogoutCleanUp
();
return
null
;
});
}
}
@Override
@Override
...
...
app/src/main/java/chat/rocket/android/service/RealmBasedConnectivityManager.java
View file @
058899ff
...
@@ -7,10 +7,11 @@ import android.os.IBinder;
...
@@ -7,10 +7,11 @@ import android.os.IBinder;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
chat.rocket.android.helper.RxHelper
;
import
chat.rocket.android.helper.RxHelper
;
import
chat.rocket.android.log.RCLog
;
import
chat.rocket.android.log.RCLog
;
import
chat.rocket.core.models.ServerInfo
;
import
chat.rocket.core.models.ServerInfo
;
...
@@ -25,7 +26,7 @@ import rx.subjects.PublishSubject;
...
@@ -25,7 +26,7 @@ import rx.subjects.PublishSubject;
*/
*/
/*package*/
class
RealmBasedConnectivityManager
/*package*/
class
RealmBasedConnectivityManager
implements
ConnectivityManagerApi
,
ConnectivityManagerInternal
{
implements
ConnectivityManagerApi
,
ConnectivityManagerInternal
{
private
final
HashMap
<
String
,
Integer
>
serverConnectivityList
=
new
HashMap
<>();
private
final
ConcurrentHashMap
<
String
,
Integer
>
serverConnectivityList
=
new
Concurrent
HashMap
<>();
private
final
PublishSubject
<
ServerConnectivity
>
connectivitySubject
=
PublishSubject
.
create
();
private
final
PublishSubject
<
ServerConnectivity
>
connectivitySubject
=
PublishSubject
.
create
();
private
Context
appContext
;
private
Context
appContext
;
private
final
ServiceConnection
serviceConnection
=
new
ServiceConnection
()
{
private
final
ServiceConnection
serviceConnection
=
new
ServiceConnection
()
{
...
...
app/src/main/java/chat/rocket/android/service/RocketChatService.java
View file @
058899ff
...
@@ -12,7 +12,6 @@ import java.util.HashMap;
...
@@ -12,7 +12,6 @@ import java.util.HashMap;
import
java.util.concurrent.Semaphore
;
import
java.util.concurrent.Semaphore
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
chat.rocket.android.activity.MainActivity
;
import
chat.rocket.persistence.realm.RealmStore
;
import
chat.rocket.persistence.realm.RealmStore
;
import
hugo.weaving.DebugLog
;
import
hugo.weaving.DebugLog
;
import
rx.Observable
;
import
rx.Observable
;
...
@@ -93,12 +92,6 @@ public class RocketChatService extends Service implements ConnectivityServiceInt
...
@@ -93,12 +92,6 @@ public class RocketChatService extends Service implements ConnectivityServiceInt
webSocketThreads
.
remove
(
hostname
);
webSocketThreads
.
remove
(
hostname
);
// remove RealmConfiguration key from HashMap
// remove RealmConfiguration key from HashMap
RealmStore
.
sStore
.
remove
(
hostname
);
RealmStore
.
sStore
.
remove
(
hostname
);
// clear "cache" SharedPreference
this
.
getSharedPreferences
(
"cache"
,
0
).
edit
().
clear
().
apply
();
// start a fresh new MainActivity
Intent
intent
=
new
Intent
(
this
,
MainActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TASK
|
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
this
.
startActivity
(
intent
);
});
});
}
else
{
}
else
{
return
Observable
.
timer
(
1
,
TimeUnit
.
SECONDS
).
toSingle
()
return
Observable
.
timer
(
1
,
TimeUnit
.
SECONDS
).
toSingle
()
...
...
app/src/main/java/chat/rocket/android/service/RocketChatWebSocketThread.java
View file @
058899ff
...
@@ -255,6 +255,10 @@ public class RocketChatWebSocketThread extends HandlerThread {
...
@@ -255,6 +255,10 @@ public class RocketChatWebSocketThread extends HandlerThread {
return
prepareDDPClient
()
return
prepareDDPClient
()
.
flatMap
(
_val
->
Single
.
fromEmitter
(
emitter
->
{
.
flatMap
(
_val
->
Single
.
fromEmitter
(
emitter
->
{
ServerInfo
info
=
connectivityManager
.
getServerInfoForHost
(
hostname
);
ServerInfo
info
=
connectivityManager
.
getServerInfoForHost
(
hostname
);
if
(
info
==
null
)
{
emitter
.
onSuccess
(
false
);
return
;
}
RCLog
.
d
(
"DDPClient#connect"
);
RCLog
.
d
(
"DDPClient#connect"
);
ddpClient
.
connect
(
info
.
getSession
(),
info
.
isSecure
())
ddpClient
.
connect
(
info
.
getSession
(),
info
.
isSecure
())
.
onSuccessTask
(
task
->
{
.
onSuccessTask
(
task
->
{
...
...
app/src/main/res/layout/dialog_users_of_room.xml
deleted
100644 → 0
View file @
b1ede845
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<FrameLayout
android:id=
"@+id/room_user_titlebar"
android:layout_width=
"match_parent"
android:layout_height=
"?attr/actionBarSize"
android:paddingEnd=
"@dimen/margin_16"
android:paddingStart=
"@dimen/margin_16"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"start|center_vertical"
android:text=
"@string/users_of_room_title"
android:textAppearance=
"@style/TextAppearance.AppCompat.Title"
/>
<TextView
android:id=
"@+id/room_user_count"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"end|center_vertical"
android:textAppearance=
"@style/TextAppearance.AppCompat.Small"
/>
</FrameLayout>
<android.support.v7.widget.RecyclerView
android:id=
"@+id/recyclerview"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
/>
</LinearLayout>
<chat.rocket.android.widget.WaitingView
android:id=
"@+id/waiting"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
/>
</FrameLayout>
\ No newline at end of file
app/src/main/res/layout/fragment_room_list.xml
View file @
058899ff
...
@@ -14,7 +14,13 @@
...
@@ -14,7 +14,13 @@
android:id=
"@+id/messageText"
android:id=
"@+id/messageText"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"@dimen/margin_16"
android:layout_marginStart=
"@dimen/margin_16"
android:layout_marginRight=
"@dimen/margin_16"
android:layout_marginEnd=
"@dimen/margin_16"
android:layout_centerInParent=
"true"
android:layout_centerInParent=
"true"
android:gravity=
"center"
android:textAppearance=
"@style/TextAppearance.AppCompat.Body1"
android:visibility=
"gone"
/>
android:visibility=
"gone"
/>
<android.support.v7.widget.RecyclerView
<android.support.v7.widget.RecyclerView
...
...
app/src/main/res/values/strings.xml
View file @
058899ff
...
@@ -17,18 +17,13 @@
...
@@ -17,18 +17,13 @@
<string
name=
"fragment_room_list_favorite_message_title"
>
Favorite Messages (%s)
</string>
<string
name=
"fragment_room_list_favorite_message_title"
>
Favorite Messages (%s)
</string>
<string
name=
"fragment_room_list_file_list_title"
>
File list (%s)
</string>
<string
name=
"fragment_room_list_file_list_title"
>
File list (%s)
</string>
<string
name=
"fragment_room_list_member_list_title"
>
Member list (%s)
</string>
<string
name=
"fragment_room_list_member_list_title"
>
Member list (%s)
</string>
<string
name=
"fragment_room_list_could_not_load_your_request"
>
Could not load your request.\n
Response was: %s
</string>
<string
name=
"fragment_room_list_could_not_load_your_request"
>
Could not load your request.\n
%s.
</string>
<string
name=
"fragment_room_list_no_pinned_message_to_show"
>
No pinned message to show
</string>
<string
name=
"fragment_room_list_no_pinned_message_to_show"
>
No pinned message to show
</string>
<string
name=
"fragment_room_list_no_favorite_message_to_show"
>
No favorite message to show
</string>
<string
name=
"fragment_room_list_no_favorite_message_to_show"
>
No favorite message to show
</string>
<string
name=
"fragment_room_list_no_file_list_to_show"
>
No file list to show
</string>
<string
name=
"fragment_room_list_no_file_list_to_show"
>
No file list to show
</string>
<string
name=
"fragment_room_list_no_member_list_to_show"
>
No member list to show
</string>
<string
name=
"fragment_room_list_no_member_list_to_show"
>
No member list to show
</string>
<string
name=
"start_of_conversation"
>
Start of conversation
</string>
<string
name=
"start_of_conversation"
>
Start of conversation
</string>
<string
name=
"users_of_room_title"
>
Members List
</string>
<plurals
name=
"fmt_room_user_count"
>
<item
quantity=
"one"
>
Total: %,d user
</item>
<item
quantity=
"other"
>
Total: %,d users
</item>
</plurals>
<string
name=
"sending"
>
Sending…
</string>
<string
name=
"sending"
>
Sending…
</string>
<string
name=
"not_synced"
>
Not synced
</string>
<string
name=
"not_synced"
>
Not synced
</string>
<string
name=
"failed_to_sync"
>
Failed to sync
</string>
<string
name=
"failed_to_sync"
>
Failed to sync
</string>
...
@@ -68,6 +63,7 @@
...
@@ -68,6 +63,7 @@
<string
name=
"video_upload_message_spec_title"
>
Attach video
</string>
<string
name=
"video_upload_message_spec_title"
>
Attach video
</string>
<string
name=
"input_hostname_invalid_server_message"
>
Invalid server version
</string>
<string
name=
"input_hostname_invalid_server_message"
>
Invalid server version
</string>
<string
name=
"make_sure_your_server_version_is_up_to_date"
>
Make sure your Rocket.Chat server version is up to date
</string>
<string
name=
"connection_error_try_later"
>
There\'s a connection error. Please try later.
</string>
<string
name=
"connection_error_try_later"
>
There\'s a connection error. Please try later.
</string>
<string
name=
"version_info_text"
>
Version: %s
</string>
<string
name=
"version_info_text"
>
Version: %s
</string>
...
...
persistence-realm/src/main/java/chat/rocket/persistence/realm/repositories/RealmLoginServiceConfigurationRepository.java
View file @
058899ff
...
@@ -29,11 +29,17 @@ public class RealmLoginServiceConfigurationRepository extends RealmRepository
...
@@ -29,11 +29,17 @@ public class RealmLoginServiceConfigurationRepository extends RealmRepository
public
Single
<
Optional
<
LoginServiceConfiguration
>>
getByName
(
String
serviceName
)
{
public
Single
<
Optional
<
LoginServiceConfiguration
>>
getByName
(
String
serviceName
)
{
return
Single
.
defer
(()
->
Flowable
.
using
(
return
Single
.
defer
(()
->
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
RxJavaInterop
.
toV2Flowable
(
pair
->
{
pair
.
first
.
where
(
RealmMeteorLoginServiceConfiguration
.
class
)
if
(
pair
.
first
==
null
)
{
.
equalTo
(
RealmMeteorLoginServiceConfiguration
.
SERVICE
,
serviceName
)
return
Flowable
.
empty
();
.
findAll
()
}
.<
RealmResults
<
RealmMeteorLoginServiceConfiguration
>>
asObservable
()),
return
RxJavaInterop
.
toV2Flowable
(
pair
.
first
.
where
(
RealmMeteorLoginServiceConfiguration
.
class
)
.
equalTo
(
RealmMeteorLoginServiceConfiguration
.
SERVICE
,
serviceName
)
.
findAll
()
.<
RealmResults
<
RealmMeteorLoginServiceConfiguration
>>
asObservable
());
},
pair
->
close
(
pair
.
first
,
pair
.
second
)
pair
->
close
(
pair
.
first
,
pair
.
second
)
)
)
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
...
@@ -46,10 +52,16 @@ public class RealmLoginServiceConfigurationRepository extends RealmRepository
...
@@ -46,10 +52,16 @@ public class RealmLoginServiceConfigurationRepository extends RealmRepository
public
Flowable
<
List
<
LoginServiceConfiguration
>>
getAll
()
{
public
Flowable
<
List
<
LoginServiceConfiguration
>>
getAll
()
{
return
Flowable
.
defer
(()
->
Flowable
.
using
(
return
Flowable
.
defer
(()
->
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
RxJavaInterop
pair
->
{
.
toV2Flowable
(
pair
.
first
.
where
(
RealmMeteorLoginServiceConfiguration
.
class
)
if
(
pair
.
first
==
null
)
{
.
findAll
()
return
Flowable
.
empty
();
.
asObservable
()),
}
return
RxJavaInterop
.
toV2Flowable
(
pair
.
first
.
where
(
RealmMeteorLoginServiceConfiguration
.
class
)
.
findAll
()
.
asObservable
());
},
pair
->
close
(
pair
.
first
,
pair
.
second
)
pair
->
close
(
pair
.
first
,
pair
.
second
)
)
)
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
...
...
persistence-realm/src/main/java/chat/rocket/persistence/realm/repositories/RealmMessageRepository.java
View file @
058899ff
...
@@ -36,11 +36,17 @@ public class RealmMessageRepository extends RealmRepository implements MessageRe
...
@@ -36,11 +36,17 @@ public class RealmMessageRepository extends RealmRepository implements MessageRe
public
Single
<
Optional
<
Message
>>
getById
(
String
messageId
)
{
public
Single
<
Optional
<
Message
>>
getById
(
String
messageId
)
{
return
Single
.
defer
(()
->
Flowable
.
using
(
return
Single
.
defer
(()
->
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
RxJavaInterop
.
toV2Flowable
(
pair
->
{
pair
.
first
.
where
(
RealmMessage
.
class
)
if
(
pair
.
first
==
null
)
{
.
equalTo
(
RealmMessage
.
ID
,
messageId
)
return
Flowable
.
empty
();
.
findAll
()
}
.<
RealmResults
<
RealmMessage
>>
asObservable
()),
return
RxJavaInterop
.
toV2Flowable
(
pair
.
first
.
where
(
RealmMessage
.
class
)
.
equalTo
(
RealmMessage
.
ID
,
messageId
)
.
findAll
()
.<
RealmResults
<
RealmMessage
>>
asObservable
());
},
pair
->
close
(
pair
.
first
,
pair
.
second
)
pair
->
close
(
pair
.
first
,
pair
.
second
)
)
)
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
...
@@ -133,11 +139,17 @@ public class RealmMessageRepository extends RealmRepository implements MessageRe
...
@@ -133,11 +139,17 @@ public class RealmMessageRepository extends RealmRepository implements MessageRe
public
Flowable
<
List
<
Message
>>
getAllFrom
(
Room
room
)
{
public
Flowable
<
List
<
Message
>>
getAllFrom
(
Room
room
)
{
return
Flowable
.
defer
(()
->
Flowable
.
using
(
return
Flowable
.
defer
(()
->
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
RxJavaInterop
.
toV2Flowable
(
pair
.
first
.
where
(
RealmMessage
.
class
)
pair
->
{
.
equalTo
(
RealmMessage
.
ROOM_ID
,
room
.
getRoomId
())
if
(
pair
.
first
==
null
)
{
.
isNotNull
(
RealmMessage
.
USER
)
return
Flowable
.
empty
();
.
findAllSorted
(
RealmMessage
.
TIMESTAMP
,
Sort
.
DESCENDING
)
}
.
asObservable
()),
return
RxJavaInterop
.
toV2Flowable
(
pair
.
first
.
where
(
RealmMessage
.
class
)
.
equalTo
(
RealmMessage
.
ROOM_ID
,
room
.
getRoomId
())
.
isNotNull
(
RealmMessage
.
USER
)
.
findAllSorted
(
RealmMessage
.
TIMESTAMP
,
Sort
.
DESCENDING
)
.
asObservable
());
},
pair
->
close
(
pair
.
first
,
pair
.
second
)
pair
->
close
(
pair
.
first
,
pair
.
second
)
)
)
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
...
@@ -150,12 +162,18 @@ public class RealmMessageRepository extends RealmRepository implements MessageRe
...
@@ -150,12 +162,18 @@ public class RealmMessageRepository extends RealmRepository implements MessageRe
public
Single
<
Integer
>
unreadCountFor
(
Room
room
,
User
user
)
{
public
Single
<
Integer
>
unreadCountFor
(
Room
room
,
User
user
)
{
return
Single
.
defer
(()
->
Flowable
.
using
(
return
Single
.
defer
(()
->
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
RxJavaInterop
.
toV2Flowable
(
pair
.
first
.
where
(
RealmMessage
.
class
)
pair
->
{
.
equalTo
(
RealmMessage
.
ROOM_ID
,
room
.
getId
())
if
(
pair
.
first
==
null
)
{
.
greaterThanOrEqualTo
(
RealmMessage
.
TIMESTAMP
,
room
.
getLastSeen
())
return
Flowable
.
empty
();
.
notEqualTo
(
RealmMessage
.
USER_ID
,
user
.
getId
())
}
.
findAll
()
.
asObservable
()),
return
RxJavaInterop
.
toV2Flowable
(
pair
.
first
.
where
(
RealmMessage
.
class
)
.
equalTo
(
RealmMessage
.
ROOM_ID
,
room
.
getId
())
.
greaterThanOrEqualTo
(
RealmMessage
.
TIMESTAMP
,
room
.
getLastSeen
())
.
notEqualTo
(
RealmMessage
.
USER_ID
,
user
.
getId
())
.
findAll
()
.
asObservable
());
},
pair
->
close
(
pair
.
first
,
pair
.
second
)
pair
->
close
(
pair
.
first
,
pair
.
second
)
)
)
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
...
...
persistence-realm/src/main/java/chat/rocket/persistence/realm/repositories/RealmPermissionRepository.java
View file @
058899ff
...
@@ -26,11 +26,16 @@ public class RealmPermissionRepository extends RealmRepository implements Permis
...
@@ -26,11 +26,16 @@ public class RealmPermissionRepository extends RealmRepository implements Permis
public
Single
<
Optional
<
Permission
>>
getById
(
String
id
)
{
public
Single
<
Optional
<
Permission
>>
getById
(
String
id
)
{
return
Single
.
defer
(()
->
Flowable
.
using
(
return
Single
.
defer
(()
->
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
RxJavaInterop
.
toV2Flowable
(
pair
->
{
pair
.
first
.
where
(
RealmPermission
.
class
)
if
(
pair
.
first
==
null
)
{
.
equalTo
(
RealmPermission
.
Columns
.
ID
,
id
)
return
Flowable
.
empty
();
.
findAll
()
}
.<
RealmResults
<
RealmPermission
>>
asObservable
()),
return
RxJavaInterop
.
toV2Flowable
(
pair
.
first
.
where
(
RealmPermission
.
class
)
.
equalTo
(
RealmPermission
.
Columns
.
ID
,
id
)
.
findAll
()
.<
RealmResults
<
RealmPermission
>>
asObservable
());
},
pair
->
close
(
pair
.
first
,
pair
.
second
)
pair
->
close
(
pair
.
first
,
pair
.
second
)
)
)
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
...
...
persistence-realm/src/main/java/chat/rocket/persistence/realm/repositories/RealmPublicSettingRepository.java
View file @
058899ff
...
@@ -27,11 +27,16 @@ public class RealmPublicSettingRepository extends RealmRepository
...
@@ -27,11 +27,16 @@ public class RealmPublicSettingRepository extends RealmRepository
public
Single
<
Optional
<
PublicSetting
>>
getById
(
String
id
)
{
public
Single
<
Optional
<
PublicSetting
>>
getById
(
String
id
)
{
return
Single
.
defer
(()
->
Flowable
.
using
(
return
Single
.
defer
(()
->
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
RxJavaInterop
.
toV2Flowable
(
pair
->
{
pair
.
first
.
where
(
RealmPublicSetting
.
class
)
if
(
pair
.
first
==
null
)
{
.
equalTo
(
RealmPublicSetting
.
ID
,
id
)
return
Flowable
.
empty
();
.
findAll
()
}
.<
RealmResults
<
RealmPublicSetting
>>
asObservable
()),
return
RxJavaInterop
.
toV2Flowable
(
pair
.
first
.
where
(
RealmPublicSetting
.
class
)
.
equalTo
(
RealmPublicSetting
.
ID
,
id
)
.
findAll
()
.<
RealmResults
<
RealmPublicSetting
>>
asObservable
());
},
pair
->
close
(
pair
.
first
,
pair
.
second
)
pair
->
close
(
pair
.
first
,
pair
.
second
)
)
)
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
...
...
persistence-realm/src/main/java/chat/rocket/persistence/realm/repositories/RealmRoomRepository.java
View file @
058899ff
...
@@ -34,10 +34,16 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
...
@@ -34,10 +34,16 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
public
Flowable
<
List
<
Room
>>
getAll
()
{
public
Flowable
<
List
<
Room
>>
getAll
()
{
return
Flowable
.
defer
(()
->
Flowable
.
using
(
return
Flowable
.
defer
(()
->
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
RxJavaInterop
.
toV2Flowable
(
pair
->
{
pair
.
first
.
where
(
RealmRoom
.
class
)
if
(
pair
.
first
==
null
)
{
.
findAll
()
return
Flowable
.
empty
();
.
asObservable
()),
}
return
RxJavaInterop
.
toV2Flowable
(
pair
.
first
.
where
(
RealmRoom
.
class
)
.
findAll
()
.
asObservable
());
},
pair
->
close
(
pair
.
first
,
pair
.
second
)
pair
->
close
(
pair
.
first
,
pair
.
second
)
)
)
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
...
@@ -51,6 +57,10 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
...
@@ -51,6 +57,10 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
return
Flowable
.
defer
(()
->
Flowable
.
using
(
return
Flowable
.
defer
(()
->
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
{
pair
->
{
if
(
pair
.
first
==
null
)
{
return
Flowable
.
empty
();
}
RealmRoom
realmRoom
=
pair
.
first
.
where
(
RealmRoom
.
class
)
RealmRoom
realmRoom
=
pair
.
first
.
where
(
RealmRoom
.
class
)
.
equalTo
(
RealmRoom
.
ROOM_ID
,
roomId
)
.
equalTo
(
RealmRoom
.
ROOM_ID
,
roomId
)
.
findFirst
();
.
findFirst
();
...
@@ -84,6 +94,9 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
...
@@ -84,6 +94,9 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
return
Flowable
.
defer
(()
->
Flowable
.
using
(
return
Flowable
.
defer
(()
->
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
{
pair
->
{
if
(
pair
.
first
==
null
)
{
return
Flowable
.
empty
();
}
LoadMessageProcedure
messageProcedure
=
pair
.
first
.
where
(
LoadMessageProcedure
.
class
)
LoadMessageProcedure
messageProcedure
=
pair
.
first
.
where
(
LoadMessageProcedure
.
class
)
.
equalTo
(
LoadMessageProcedure
.
ID
,
roomId
)
.
equalTo
(
LoadMessageProcedure
.
ID
,
roomId
)
...
@@ -147,17 +160,22 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
...
@@ -147,17 +160,22 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
public
Flowable
<
List
<
Room
>>
getSortedLikeName
(
String
name
,
SortDirection
direction
,
int
limit
)
{
public
Flowable
<
List
<
Room
>>
getSortedLikeName
(
String
name
,
SortDirection
direction
,
int
limit
)
{
return
Flowable
.
defer
(()
->
Flowable
.
using
(
return
Flowable
.
defer
(()
->
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
RxJavaInterop
.
toV2Flowable
(
pair
->
{
pair
.
first
.
where
(
RealmRoom
.
class
)
if
(
pair
.
first
==
null
)
{
.
like
(
RealmRoom
.
NAME
,
"*"
+
name
+
"*"
,
Case
.
INSENSITIVE
)
return
Flowable
.
empty
();
.
beginGroup
()
}
.
equalTo
(
RealmRoom
.
TYPE
,
RealmRoom
.
TYPE_CHANNEL
)
return
RxJavaInterop
.
toV2Flowable
(
.
or
()
pair
.
first
.
where
(
RealmRoom
.
class
)
.
equalTo
(
RealmRoom
.
TYPE
,
RealmRoom
.
TYPE_PRIVATE
)
.
like
(
RealmRoom
.
NAME
,
"*"
+
name
+
"*"
,
Case
.
INSENSITIVE
)
.
endGroup
()
.
beginGroup
()
.
findAllSorted
(
RealmRoom
.
NAME
,
.
equalTo
(
RealmRoom
.
TYPE
,
RealmRoom
.
TYPE_CHANNEL
)
direction
.
equals
(
SortDirection
.
ASC
)
?
Sort
.
ASCENDING
:
Sort
.
DESCENDING
)
.
or
()
.
asObservable
()),
.
equalTo
(
RealmRoom
.
TYPE
,
RealmRoom
.
TYPE_PRIVATE
)
.
endGroup
()
.
findAllSorted
(
RealmRoom
.
NAME
,
direction
.
equals
(
SortDirection
.
ASC
)
?
Sort
.
ASCENDING
:
Sort
.
DESCENDING
)
.
asObservable
());
},
pair
->
close
(
pair
.
first
,
pair
.
second
)
pair
->
close
(
pair
.
first
,
pair
.
second
)
)
)
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
...
@@ -170,15 +188,20 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
...
@@ -170,15 +188,20 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
public
Flowable
<
List
<
Room
>>
getLatestSeen
(
int
limit
)
{
public
Flowable
<
List
<
Room
>>
getLatestSeen
(
int
limit
)
{
return
Flowable
.
defer
(()
->
Flowable
.
using
(
return
Flowable
.
defer
(()
->
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
RxJavaInterop
.
toV2Flowable
(
pair
->
{
pair
.
first
.
where
(
RealmRoom
.
class
)
if
(
pair
.
first
==
null
)
{
.
beginGroup
()
return
Flowable
.
empty
();
.
equalTo
(
RealmRoom
.
TYPE
,
RealmRoom
.
TYPE_CHANNEL
)
}
.
or
()
return
RxJavaInterop
.
toV2Flowable
(
.
equalTo
(
RealmRoom
.
TYPE
,
RealmRoom
.
TYPE_PRIVATE
)
pair
.
first
.
where
(
RealmRoom
.
class
)
.
endGroup
()
.
beginGroup
()
.
findAllSorted
(
RealmRoom
.
LAST_SEEN
,
Sort
.
ASCENDING
)
.
equalTo
(
RealmRoom
.
TYPE
,
RealmRoom
.
TYPE_CHANNEL
)
.
asObservable
()),
.
or
()
.
equalTo
(
RealmRoom
.
TYPE
,
RealmRoom
.
TYPE_PRIVATE
)
.
endGroup
()
.
findAllSorted
(
RealmRoom
.
LAST_SEEN
,
Sort
.
ASCENDING
)
.
asObservable
());
},
pair
->
close
(
pair
.
first
,
pair
.
second
)
pair
->
close
(
pair
.
first
,
pair
.
second
)
)
)
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
...
...
persistence-realm/src/main/java/chat/rocket/persistence/realm/repositories/RealmRoomRoleRepository.java
View file @
058899ff
...
@@ -29,12 +29,17 @@ public class RealmRoomRoleRepository extends RealmRepository implements RoomRole
...
@@ -29,12 +29,17 @@ public class RealmRoomRoleRepository extends RealmRepository implements RoomRole
public
Single
<
Optional
<
RoomRole
>>
getFor
(
Room
room
,
User
user
)
{
public
Single
<
Optional
<
RoomRole
>>
getFor
(
Room
room
,
User
user
)
{
return
Single
.
defer
(()
->
Flowable
.
using
(
return
Single
.
defer
(()
->
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
RxJavaInterop
.
toV2Flowable
(
pair
->
{
pair
.
first
.
where
(
RealmRoomRole
.
class
)
if
(
pair
.
first
==
null
)
{
.
equalTo
(
RealmRoomRole
.
Columns
.
ROOM_ID
,
room
.
getId
())
return
Flowable
.
empty
();
.
equalTo
(
RealmRoomRole
.
Columns
.
USER
+
"."
+
RealmUser
.
ID
,
user
.
getId
())
}
.
findAll
()
return
RxJavaInterop
.
toV2Flowable
(
.<
RealmResults
<
RealmRoomRole
>>
asObservable
()),
pair
.
first
.
where
(
RealmRoomRole
.
class
)
.
equalTo
(
RealmRoomRole
.
Columns
.
ROOM_ID
,
room
.
getId
())
.
equalTo
(
RealmRoomRole
.
Columns
.
USER
+
"."
+
RealmUser
.
ID
,
user
.
getId
())
.
findAll
()
.<
RealmResults
<
RealmRoomRole
>>
asObservable
());
},
pair
->
close
(
pair
.
first
,
pair
.
second
)
pair
->
close
(
pair
.
first
,
pair
.
second
)
)
)
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
...
...
persistence-realm/src/main/java/chat/rocket/persistence/realm/repositories/RealmSessionRepository.java
View file @
058899ff
...
@@ -26,11 +26,17 @@ public class RealmSessionRepository extends RealmRepository implements SessionRe
...
@@ -26,11 +26,17 @@ public class RealmSessionRepository extends RealmRepository implements SessionRe
public
Flowable
<
Optional
<
Session
>>
getById
(
int
id
)
{
public
Flowable
<
Optional
<
Session
>>
getById
(
int
id
)
{
return
Flowable
.
defer
(()
->
Flowable
.
using
(
return
Flowable
.
defer
(()
->
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
RxJavaInterop
.
toV2Flowable
(
pair
->
{
pair
.
first
.
where
(
RealmSession
.
class
)
if
(
pair
.
first
==
null
)
{
.
equalTo
(
RealmSession
.
ID
,
id
)
return
Flowable
.
empty
();
.
findAll
()
}
.<
RealmSession
>
asObservable
()),
return
RxJavaInterop
.
toV2Flowable
(
pair
.
first
.
where
(
RealmSession
.
class
)
.
equalTo
(
RealmSession
.
ID
,
id
)
.
findAll
()
.<
RealmSession
>
asObservable
());
},
pair
->
close
(
pair
.
first
,
pair
.
second
)
pair
->
close
(
pair
.
first
,
pair
.
second
)
)
)
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
...
...
persistence-realm/src/main/java/chat/rocket/persistence/realm/repositories/RealmSpotlightRepository.kt
View file @
058899ff
...
@@ -20,7 +20,12 @@ class RealmSpotlightRepository(private val hostname: String) : RealmRepository()
...
@@ -20,7 +20,12 @@ class RealmSpotlightRepository(private val hostname: String) : RealmRepository()
override
fun
getSuggestionsFor
(
term
:
String
,
limit
:
Int
):
Flowable
<
List
<
Spotlight
>>
{
override
fun
getSuggestionsFor
(
term
:
String
,
limit
:
Int
):
Flowable
<
List
<
Spotlight
>>
{
return
Flowable
.
defer
{
Flowable
.
using
<
RealmResults
<
RealmSpotlight
>,
Pair
<
Realm
,
Looper
>>({
return
Flowable
.
defer
{
Flowable
.
using
<
RealmResults
<
RealmSpotlight
>,
Pair
<
Realm
,
Looper
>>({
Pair
(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
())
Pair
(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
())
},
{
pair
->
RxJavaInterop
.
toV2Flowable
<
RealmResults
<
RealmSpotlight
>>(
pair
.
first
.
where
(
RealmSpotlight
::
class
.
java
)
},
{
pair
->
if
(
pair
.
first
==
null
)
{
return
@using
Flowable
.
empty
()
}
return
@using
RxJavaInterop
.
toV2Flowable
<
RealmResults
<
RealmSpotlight
>>(
pair
.
first
.
where
(
RealmSpotlight
::
class
.
java
)
.
findAllSorted
(
Columns
.
TYPE
,
Sort
.
DESCENDING
)
.
findAllSorted
(
Columns
.
TYPE
,
Sort
.
DESCENDING
)
.
asObservable
())
.
asObservable
())
})
{
pair
->
close
(
pair
.
first
,
pair
.
second
)
}
})
{
pair
->
close
(
pair
.
first
,
pair
.
second
)
}
...
...
persistence-realm/src/main/java/chat/rocket/persistence/realm/repositories/RealmSpotlightRoomRepository.java
View file @
058899ff
...
@@ -29,16 +29,22 @@ public class RealmSpotlightRoomRepository extends RealmRepository implements Spo
...
@@ -29,16 +29,22 @@ public class RealmSpotlightRoomRepository extends RealmRepository implements Spo
public
Flowable
<
List
<
SpotlightRoom
>>
getSuggestionsFor
(
String
name
,
SortDirection
direction
,
int
limit
)
{
public
Flowable
<
List
<
SpotlightRoom
>>
getSuggestionsFor
(
String
name
,
SortDirection
direction
,
int
limit
)
{
return
Flowable
.
defer
(()
->
Flowable
.
using
(
return
Flowable
.
defer
(()
->
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
RxJavaInterop
.
toV2Flowable
(
pair
->
{
pair
.
first
.
where
(
RealmSpotlightRoom
.
class
)
if
(
pair
.
first
==
null
)
{
.
like
(
RealmSpotlightRoom
.
Columns
.
NAME
,
"*"
+
name
+
"*"
,
Case
.
INSENSITIVE
)
return
Flowable
.
empty
();
.
beginGroup
()
}
.
equalTo
(
RealmSpotlightRoom
.
Columns
.
TYPE
,
RealmRoom
.
TYPE_CHANNEL
)
.
or
()
return
RxJavaInterop
.
toV2Flowable
(
.
equalTo
(
RealmSpotlightRoom
.
Columns
.
TYPE
,
RealmRoom
.
TYPE_PRIVATE
)
pair
.
first
.
where
(
RealmSpotlightRoom
.
class
)
.
endGroup
()
.
like
(
RealmSpotlightRoom
.
Columns
.
NAME
,
"*"
+
name
+
"*"
,
Case
.
INSENSITIVE
)
.
findAllSorted
(
RealmSpotlightRoom
.
Columns
.
NAME
,
direction
.
equals
(
SortDirection
.
ASC
)
?
Sort
.
ASCENDING
:
Sort
.
DESCENDING
)
.
beginGroup
()
.
asObservable
()),
.
equalTo
(
RealmSpotlightRoom
.
Columns
.
TYPE
,
RealmRoom
.
TYPE_CHANNEL
)
.
or
()
.
equalTo
(
RealmSpotlightRoom
.
Columns
.
TYPE
,
RealmRoom
.
TYPE_PRIVATE
)
.
endGroup
()
.
findAllSorted
(
RealmSpotlightRoom
.
Columns
.
NAME
,
direction
.
equals
(
SortDirection
.
ASC
)
?
Sort
.
ASCENDING
:
Sort
.
DESCENDING
)
.
asObservable
());
},
pair
->
close
(
pair
.
first
,
pair
.
second
)
pair
->
close
(
pair
.
first
,
pair
.
second
)
)
)
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
...
...
persistence-realm/src/main/java/chat/rocket/persistence/realm/repositories/RealmSpotlightUserRepository.java
View file @
058899ff
...
@@ -28,20 +28,26 @@ public class RealmSpotlightUserRepository extends RealmRepository implements Spo
...
@@ -28,20 +28,26 @@ public class RealmSpotlightUserRepository extends RealmRepository implements Spo
public
Flowable
<
List
<
SpotlightUser
>>
getSuggestionsFor
(
String
name
,
SortDirection
direction
,
int
limit
)
{
public
Flowable
<
List
<
SpotlightUser
>>
getSuggestionsFor
(
String
name
,
SortDirection
direction
,
int
limit
)
{
return
Flowable
.
defer
(()
->
Flowable
.
using
(
return
Flowable
.
defer
(()
->
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
RxJavaInterop
.
toV2Flowable
(
pair
->
{
pair
.
first
.
where
(
RealmSpotlightUser
.
class
)
if
(
pair
.
first
==
null
)
{
.
beginGroup
()
return
Flowable
.
empty
();
.
like
(
RealmSpotlightUser
.
Columns
.
USERNAME
,
"*"
+
name
+
"*"
,
Case
.
INSENSITIVE
)
}
.
isNull
(
RealmSpotlightUser
.
Columns
.
NAME
)
.
endGroup
()
return
RxJavaInterop
.
toV2Flowable
(
.
or
()
pair
.
first
.
where
(
RealmSpotlightUser
.
class
)
.
beginGroup
()
.
beginGroup
()
.
like
(
RealmSpotlightUser
.
Columns
.
NAME
,
"*"
+
name
+
"*"
,
Case
.
INSENSITIVE
)
.
like
(
RealmSpotlightUser
.
Columns
.
USERNAME
,
"*"
+
name
+
"*"
,
Case
.
INSENSITIVE
)
.
isNotNull
(
RealmSpotlightUser
.
Columns
.
USERNAME
)
.
isNull
(
RealmSpotlightUser
.
Columns
.
NAME
)
.
endGroup
()
.
endGroup
()
.
findAllSorted
(
RealmSpotlightUser
.
Columns
.
USERNAME
,
.
or
()
direction
.
equals
(
SortDirection
.
ASC
)
?
Sort
.
ASCENDING
:
Sort
.
DESCENDING
)
.
beginGroup
()
.
asObservable
()),
.
like
(
RealmSpotlightUser
.
Columns
.
NAME
,
"*"
+
name
+
"*"
,
Case
.
INSENSITIVE
)
.
isNotNull
(
RealmSpotlightUser
.
Columns
.
USERNAME
)
.
endGroup
()
.
findAllSorted
(
RealmSpotlightUser
.
Columns
.
USERNAME
,
direction
.
equals
(
SortDirection
.
ASC
)
?
Sort
.
ASCENDING
:
Sort
.
DESCENDING
)
.
asObservable
());
},
pair
->
close
(
pair
.
first
,
pair
.
second
)
pair
->
close
(
pair
.
first
,
pair
.
second
)
)
)
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
...
...
persistence-realm/src/main/java/chat/rocket/persistence/realm/repositories/RealmUserRepository.java
View file @
058899ff
...
@@ -31,10 +31,16 @@ public class RealmUserRepository extends RealmRepository implements UserReposito
...
@@ -31,10 +31,16 @@ public class RealmUserRepository extends RealmRepository implements UserReposito
public
Flowable
<
List
<
User
>>
getAll
()
{
public
Flowable
<
List
<
User
>>
getAll
()
{
return
Flowable
.
defer
(()
->
Flowable
.
using
(
return
Flowable
.
defer
(()
->
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
RxJavaInterop
.
toV2Flowable
(
pair
->
{
pair
.
first
.
where
(
RealmUser
.
class
)
if
(
pair
.
first
==
null
)
{
.
findAll
()
return
Flowable
.
empty
();
.
asObservable
()),
}
return
RxJavaInterop
.
toV2Flowable
(
pair
.
first
.
where
(
RealmUser
.
class
)
.
findAll
()
.
asObservable
());
},
pair
->
close
(
pair
.
first
,
pair
.
second
))
pair
->
close
(
pair
.
first
,
pair
.
second
))
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
.
filter
(
roomSubscriptions
->
roomSubscriptions
!=
null
&&
roomSubscriptions
.
isLoaded
()
.
filter
(
roomSubscriptions
->
roomSubscriptions
!=
null
&&
roomSubscriptions
.
isLoaded
()
...
@@ -60,11 +66,17 @@ public class RealmUserRepository extends RealmRepository implements UserReposito
...
@@ -60,11 +66,17 @@ public class RealmUserRepository extends RealmRepository implements UserReposito
private
Flowable
<
RealmResults
<
RealmUser
>>
realmGetCurrent
()
{
private
Flowable
<
RealmResults
<
RealmUser
>>
realmGetCurrent
()
{
return
Flowable
.
using
(
return
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
RxJavaInterop
.
toV2Flowable
(
pair
->
{
if
(
pair
.
first
==
null
)
{
return
Flowable
.
empty
();
}
return
RxJavaInterop
.
toV2Flowable
(
pair
.
first
.
where
(
RealmUser
.
class
)
pair
.
first
.
where
(
RealmUser
.
class
)
.
isNotEmpty
(
RealmUser
.
EMAILS
)
.
isNotEmpty
(
RealmUser
.
EMAILS
)
.
findAll
()
.
findAll
()
.<
RealmResults
<
RealmUser
>>
asObservable
()),
.<
RealmResults
<
RealmUser
>>
asObservable
());
},
pair
->
close
(
pair
.
first
,
pair
.
second
));
pair
->
close
(
pair
.
first
,
pair
.
second
));
}
}
...
@@ -90,6 +102,10 @@ public class RealmUserRepository extends RealmRepository implements UserReposito
...
@@ -90,6 +102,10 @@ public class RealmUserRepository extends RealmRepository implements UserReposito
}
}
private
Flowable
<
Optional
<
RealmUser
>>
realmQueryUsername
(
Realm
realm
,
String
username
)
{
private
Flowable
<
Optional
<
RealmUser
>>
realmQueryUsername
(
Realm
realm
,
String
username
)
{
if
(
realm
==
null
)
{
return
Flowable
.
empty
();
}
RealmUser
realmUser
=
realm
.
where
(
RealmUser
.
class
)
RealmUser
realmUser
=
realm
.
where
(
RealmUser
.
class
)
.
equalTo
(
RealmUser
.
USERNAME
,
username
)
.
equalTo
(
RealmUser
.
USERNAME
,
username
)
.
findFirst
();
.
findFirst
();
...
@@ -118,11 +134,17 @@ public class RealmUserRepository extends RealmRepository implements UserReposito
...
@@ -118,11 +134,17 @@ public class RealmUserRepository extends RealmRepository implements UserReposito
private
Flowable
<
RealmResults
<
RealmUser
>>
realmGetSortedLikeName
(
String
name
)
{
private
Flowable
<
RealmResults
<
RealmUser
>>
realmGetSortedLikeName
(
String
name
)
{
return
Flowable
.
using
(
return
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
RxJavaInterop
.
toV2Flowable
(
pair
->
{
pair
.
first
.
where
(
RealmUser
.
class
)
if
(
pair
.
first
==
null
)
{
.
like
(
RealmUser
.
USERNAME
,
"*"
+
name
+
"*"
,
Case
.
INSENSITIVE
)
return
Flowable
.
empty
();
.
findAllSorted
(
RealmUser
.
USERNAME
,
Sort
.
DESCENDING
)
}
.
asObservable
()),
return
RxJavaInterop
.
toV2Flowable
(
pair
.
first
.
where
(
RealmUser
.
class
)
.
like
(
RealmUser
.
USERNAME
,
"*"
+
name
+
"*"
,
Case
.
INSENSITIVE
)
.
findAllSorted
(
RealmUser
.
USERNAME
,
Sort
.
DESCENDING
)
.
asObservable
());
},
pair
->
close
(
pair
.
first
,
pair
.
second
));
pair
->
close
(
pair
.
first
,
pair
.
second
));
}
}
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/RoomToolbar.java
View file @
058899ff
...
@@ -92,6 +92,11 @@ public class RoomToolbar extends Toolbar {
...
@@ -92,6 +92,11 @@ public class RoomToolbar extends Toolbar {
toolbarText
.
setText
(
title
);
toolbarText
.
setText
(
title
);
}
}
public
void
hideChannelIcons
()
{
roomTypeImage
.
setVisibility
(
GONE
);
userStatusImage
.
setVisibility
(
GONE
);
}
public
void
showPrivateChannelIcon
()
{
public
void
showPrivateChannelIcon
()
{
roomTypeImage
.
setImageDrawable
(
privateChannelDrawable
);
roomTypeImage
.
setImageDrawable
(
privateChannelDrawable
);
userStatusImage
.
setVisibility
(
GONE
);
userStatusImage
.
setVisibility
(
GONE
);
...
...
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