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
f1dd4424
Commit
f1dd4424
authored
Feb 24, 2017
by
Tiago Cunha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix crashes
parent
9120eea0
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
79 additions
and
28 deletions
+79
-28
AbstractFragmentActivity.java
...hat/rocket/android/activity/AbstractFragmentActivity.java
+1
-2
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+3
-1
MainPresenter.java
...main/java/chat/rocket/android/activity/MainPresenter.java
+19
-3
RoomPresenter.java
.../chat/rocket/android/fragment/chatroom/RoomPresenter.java
+2
-0
SidebarMainContract.java
.../rocket/android/fragment/sidebar/SidebarMainContract.java
+2
-0
SidebarMainFragment.java
.../rocket/android/fragment/sidebar/SidebarMainFragment.java
+7
-10
SidebarMainPresenter.java
...rocket/android/fragment/sidebar/SidebarMainPresenter.java
+11
-1
gradle-wrapper.properties
gradle/wrapper/gradle-wrapper.properties
+1
-1
RealmRoomRepository.java
...t/persistence/realm/repositories/RealmRoomRepository.java
+26
-9
MessageInteractor.java
.../java/chat/rocket/core/interactors/MessageInteractor.java
+3
-0
Preferences.java
...re/src/main/java/chat/rocket/core/models/Preferences.java
+1
-0
User.java
...chat-core/src/main/java/chat/rocket/core/models/User.java
+1
-0
RoomRepository.java
...in/java/chat/rocket/core/repositories/RoomRepository.java
+2
-1
No files found.
app/src/main/java/chat/rocket/android/activity/AbstractFragmentActivity.java
View file @
f1dd4424
...
...
@@ -25,9 +25,8 @@ abstract class AbstractFragmentActivity extends RxAppCompatActivity {
Icepick
.
saveInstanceState
(
this
,
outState
);
}
protected
abstract
@IdRes
int
getLayoutContainerForFragment
();
protected
abstract
int
getLayoutContainerForFragment
();
@Override
public
final
void
onBackPressed
()
{
...
...
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
f1dd4424
...
...
@@ -10,6 +10,7 @@ import android.view.View;
import
chat.rocket.android.LaunchUtil
;
import
chat.rocket.android.R
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.fragment.chatroom.HomeFragment
;
import
chat.rocket.android.fragment.chatroom.RoomFragment
;
...
...
@@ -136,7 +137,8 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
createRoomInteractor
,
sessionInteractor
,
new
MethodCallHelper
(
this
,
hostname
),
ConnectivityManager
.
getInstance
(
getApplicationContext
())
ConnectivityManager
.
getInstance
(
getApplicationContext
()),
new
RocketChatCache
(
this
)
);
updateSidebarMainFragment
();
...
...
app/src/main/java/chat/rocket/android/activity/MainPresenter.java
View file @
f1dd4424
...
...
@@ -8,6 +8,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import
io.reactivex.disposables.Disposable
;
import
chat.rocket.android.BackgroundLooper
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.helper.LogIfError
;
import
chat.rocket.android.service.ConnectivityManagerApi
;
...
...
@@ -26,30 +27,33 @@ public class MainPresenter extends BasePresenter<MainContract.View>
private
final
SessionInteractor
sessionInteractor
;
private
final
MethodCallHelper
methodCallHelper
;
private
final
ConnectivityManagerApi
connectivityManagerApi
;
private
final
RocketChatCache
rocketChatCache
;
public
MainPresenter
(
RoomInteractor
roomInteractor
,
CanCreateRoomInteractor
canCreateRoomInteractor
,
SessionInteractor
sessionInteractor
,
MethodCallHelper
methodCallHelper
,
ConnectivityManagerApi
connectivityManagerApi
)
{
ConnectivityManagerApi
connectivityManagerApi
,
RocketChatCache
rocketChatCache
)
{
this
.
roomInteractor
=
roomInteractor
;
this
.
canCreateRoomInteractor
=
canCreateRoomInteractor
;
this
.
sessionInteractor
=
sessionInteractor
;
this
.
methodCallHelper
=
methodCallHelper
;
this
.
connectivityManagerApi
=
connectivityManagerApi
;
this
.
rocketChatCache
=
rocketChatCache
;
}
@Override
public
void
bindView
(
@NonNull
MainContract
.
View
view
)
{
super
.
bindView
(
view
);
view
.
showHome
();
if
(
shouldLaunchAddServerActivity
())
{
view
.
showAddServerScreen
();
return
;
}
openRoom
();
subscribeToUnreadCount
();
subscribeToSession
();
setUserOnline
();
...
...
@@ -86,6 +90,18 @@ public class MainPresenter extends BasePresenter<MainContract.View>
addSubscription
(
subscription
);
}
private
void
openRoom
()
{
String
hostname
=
rocketChatCache
.
getSelectedServerHostname
();
String
roomId
=
rocketChatCache
.
getSelectedRoomId
();
if
(
roomId
==
null
||
roomId
.
length
()
==
0
)
{
view
.
showHome
();
return
;
}
onOpenRoom
(
hostname
,
roomId
);
}
private
void
subscribeToUnreadCount
()
{
final
Disposable
subscription
=
Flowable
.
combineLatest
(
roomInteractor
.
getTotalUnreadRoomsCount
(),
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomPresenter.java
View file @
f1dd4424
...
...
@@ -179,6 +179,8 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
private
void
getRoomHistoryStateInfo
()
{
final
Disposable
subscription
=
roomRepository
.
getHistoryStateByRoomId
(
roomId
)
.
distinctUntilChanged
()
.
filter
(
Optional:
:
isPresent
)
.
map
(
Optional:
:
get
)
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
...
...
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainContract.java
View file @
f1dd4424
...
...
@@ -22,6 +22,8 @@ public interface SidebarMainContract {
interface
Presenter
extends
BaseContract
.
Presenter
<
View
>
{
void
onRoomSelected
(
Room
room
);
void
onUserOnline
();
void
onUserAway
();
...
...
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainFragment.java
View file @
f1dd4424
...
...
@@ -19,7 +19,6 @@ import chat.rocket.android.R;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.fragment.AbstractFragment
;
import
chat.rocket.android.fragment.sidebar.dialog.AbstractAddRoomDialogFragment
;
import
chat.rocket.android.fragment.sidebar.dialog.AddChannelDialogFragment
;
import
chat.rocket.android.fragment.sidebar.dialog.AddDirectMessageDialogFragment
;
import
chat.rocket.android.helper.TextUtils
;
...
...
@@ -47,8 +46,6 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
private
String
hostname
;
private
RocketChatCache
rocketChatCache
;
public
SidebarMainFragment
()
{
}
...
...
@@ -72,12 +69,11 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
Bundle
args
=
getArguments
();
hostname
=
args
==
null
?
null
:
args
.
getString
(
HOSTNAME
);
rocketChatCache
=
new
RocketChatCache
(
getContext
());
presenter
=
new
SidebarMainPresenter
(
hostname
,
new
RoomInteractor
(
new
RealmRoomRepository
(
hostname
)),
new
RealmUserRepository
(
hostname
),
new
RocketChatCache
(
getContext
()),
TextUtils
.
isEmpty
(
hostname
)
?
null
:
new
MethodCallHelper
(
getContext
(),
hostname
)
);
}
...
...
@@ -107,7 +103,7 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
setupVersionInfo
();
adapter
=
new
RoomListAdapter
();
adapter
.
setOnItemClickListener
(
room
->
rocketChatCache
.
setSelectedRoomId
(
room
.
getRoomId
()
));
adapter
.
setOnItemClickListener
(
room
->
presenter
.
onRoomSelected
(
room
));
RecyclerView
recyclerView
=
(
RecyclerView
)
rootView
.
findViewById
(
R
.
id
.
room_list_container
);
recyclerView
.
setLayoutManager
(
...
...
@@ -119,9 +115,10 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
final
CompoundButton
toggleUserAction
=
((
CompoundButton
)
rootView
.
findViewById
(
R
.
id
.
toggle_user_action
));
toggleUserAction
.
setFocusableInTouchMode
(
false
);
rootView
.
findViewById
(
R
.
id
.
user_info_container
).
setOnClickListener
(
view
->
{
toggleUserAction
.
toggle
();
});
rootView
.
findViewById
(
R
.
id
.
user_info_container
)
.
setOnClickListener
(
view
->
toggleUserAction
.
toggle
());
RxJavaInterop
.
toV2Flowable
(
RxCompoundButton
.
checkedChanges
(
toggleUserAction
))
.
compose
(
bindToLifecycle
())
.
subscribe
(
aBoolean
->
{
...
...
@@ -201,7 +198,7 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
}
private
void
showAddRoomDialog
(
DialogFragment
dialog
)
{
dialog
.
show
(
getFragmentManager
(),
AbstractAddRoomDialogFragment
.
class
.
getSimpleName
()
);
dialog
.
show
(
getFragmentManager
(),
"AbstractAddRoomDialogFragment"
);
}
@Override
...
...
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainPresenter.java
View file @
f1dd4424
...
...
@@ -6,11 +6,13 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import
io.reactivex.disposables.Disposable
;
import
chat.rocket.android.BackgroundLooper
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.helper.LogIfError
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.shared.BasePresenter
;
import
chat.rocket.core.interactors.RoomInteractor
;
import
chat.rocket.core.models.Room
;
import
chat.rocket.core.models.User
;
import
chat.rocket.core.repositories.UserRepository
;
...
...
@@ -20,13 +22,16 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
private
final
String
hostname
;
private
final
RoomInteractor
roomInteractor
;
private
final
UserRepository
userRepository
;
private
final
RocketChatCache
rocketChatCache
;
private
final
MethodCallHelper
methodCallHelper
;
public
SidebarMainPresenter
(
String
hostname
,
RoomInteractor
roomInteractor
,
UserRepository
userRepository
,
MethodCallHelper
methodCallHelper
)
{
UserRepository
userRepository
,
RocketChatCache
rocketChatCache
,
MethodCallHelper
methodCallHelper
)
{
this
.
hostname
=
hostname
;
this
.
roomInteractor
=
roomInteractor
;
this
.
userRepository
=
userRepository
;
this
.
rocketChatCache
=
rocketChatCache
;
this
.
methodCallHelper
=
methodCallHelper
;
}
...
...
@@ -45,6 +50,11 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
subscribeToUser
();
}
@Override
public
void
onRoomSelected
(
Room
room
)
{
rocketChatCache
.
setSelectedRoomId
(
room
.
getRoomId
());
}
@Override
public
void
onUserOnline
()
{
updateCurrentUserStatus
(
User
.
STATUS_ONLINE
);
...
...
gradle/wrapper/gradle-wrapper.properties
View file @
f1dd4424
...
...
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath
=
wrapper/dists
zipStoreBase
=
GRADLE_USER_HOME
zipStorePath
=
wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-
2.14.1
-all.zip
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-
3.4
-all.zip
persistence-realm/src/main/java/chat/rocket/persistence/realm/repositories/RealmRoomRepository.java
View file @
f1dd4424
...
...
@@ -2,6 +2,7 @@ package chat.rocket.persistence.realm.repositories;
import
android.os.Looper
;
import
android.support.v4.util.Pair
;
import
com.fernandocejas.arrow.optional.Optional
;
import
io.reactivex.Flowable
;
import
io.reactivex.Single
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
...
...
@@ -60,20 +61,36 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
}
@Override
public
Flowable
<
RoomHistoryState
>
getHistoryStateByRoomId
(
String
roomId
)
{
public
Flowable
<
Optional
<
RoomHistoryState
>
>
getHistoryStateByRoomId
(
String
roomId
)
{
return
Flowable
.
defer
(()
->
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
RxJavaInterop
.
toV2Flowable
(
pair
.
first
.
where
(
LoadMessageProcedure
.
class
)
.
equalTo
(
LoadMessageProcedure
.
ID
,
roomId
)
.
findFirst
()
.<
LoadMessageProcedure
>
asObservable
()
.
filter
(
loadMessageProcedure
->
loadMessageProcedure
!=
null
&&
loadMessageProcedure
.
isLoaded
()
&&
loadMessageProcedure
.
isValid
())),
pair
->
{
LoadMessageProcedure
messageProcedure
=
pair
.
first
.
where
(
LoadMessageProcedure
.
class
)
.
equalTo
(
LoadMessageProcedure
.
ID
,
roomId
)
.
findFirst
();
if
(
messageProcedure
==
null
)
{
return
Flowable
.
just
(
Optional
.<
LoadMessageProcedure
>
absent
());
}
return
RxJavaInterop
.
toV2Flowable
(
messageProcedure
.<
LoadMessageProcedure
>
asObservable
()
.
filter
(
loadMessageProcedure
->
loadMessageProcedure
.
isLoaded
()
&&
loadMessageProcedure
.
isValid
())
.
map
(
Optional:
:
of
));
},
pair
->
close
(
pair
.
first
,
pair
.
second
)
)
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
.
map
(
LoadMessageProcedure:
:
asRoomHistoryState
));
.
map
(
optional
->
{
if
(
optional
.
isPresent
())
{
return
Optional
.
of
(
optional
.
get
().
asRoomHistoryState
());
}
return
Optional
.
absent
();
}));
}
@Override
...
...
rocket-chat-core/src/main/java/chat/rocket/core/interactors/MessageInteractor.java
View file @
f1dd4424
package
chat
.
rocket
.
core
.
interactors
;
import
com.fernandocejas.arrow.optional.Optional
;
import
io.reactivex.Flowable
;
import
io.reactivex.Single
;
...
...
@@ -38,6 +39,8 @@ public class MessageInteractor {
public
Single
<
Boolean
>
loadMoreMessages
(
Room
room
)
{
return
roomRepository
.
getHistoryStateByRoomId
(
room
.
getRoomId
())
.
filter
(
Optional:
:
isPresent
)
.
map
(
Optional:
:
get
)
.
filter
(
roomHistoryState
->
{
int
syncState
=
roomHistoryState
.
getSyncState
();
return
!
roomHistoryState
.
isComplete
()
...
...
rocket-chat-core/src/main/java/chat/rocket/core/models/Preferences.java
View file @
f1dd4424
...
...
@@ -27,6 +27,7 @@ public abstract class Preferences {
public
abstract
boolean
isAutoImageLoad
();
@Nullable
public
abstract
String
getEmailNotificationMode
();
public
abstract
boolean
isUnreadAlert
();
...
...
rocket-chat-core/src/main/java/chat/rocket/core/models/User.java
View file @
f1dd4424
...
...
@@ -15,6 +15,7 @@ public abstract class User {
public
abstract
String
getId
();
@Nullable
public
abstract
String
getUsername
();
@Nullable
...
...
rocket-chat-core/src/main/java/chat/rocket/core/repositories/RoomRepository.java
View file @
f1dd4424
package
chat
.
rocket
.
core
.
repositories
;
import
com.fernandocejas.arrow.optional.Optional
;
import
io.reactivex.Flowable
;
import
io.reactivex.Single
;
...
...
@@ -13,7 +14,7 @@ public interface RoomRepository {
Flowable
<
Room
>
getById
(
String
roomId
);
Flowable
<
RoomHistoryState
>
getHistoryStateByRoomId
(
String
roomId
);
Flowable
<
Optional
<
RoomHistoryState
>
>
getHistoryStateByRoomId
(
String
roomId
);
Single
<
Boolean
>
setHistoryState
(
RoomHistoryState
roomHistoryState
);
}
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