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
38a3796f
Unverified
Commit
38a3796f
authored
Oct 22, 2018
by
Filipe de Lima Brito
Committed by
GitHub
Oct 22, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into fix/gif-upload
parents
de006382
8bb8198b
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
61 additions
and
55 deletions
+61
-55
RegisterUsernameFragment.kt
...ntication/registerusername/ui/RegisterUsernameFragment.kt
+3
-3
ResetPasswordFragment.kt
.../authentication/resetpassword/ui/ResetPasswordFragment.kt
+3
-3
MessageInfoFragment.kt
.../rocket/android/chatinformation/ui/MessageInfoFragment.kt
+4
-4
PeopleSuggestionsAdapter.kt
...cket/android/chatroom/adapter/PeopleSuggestionsAdapter.kt
+4
-4
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+5
-8
Menu.kt
app/src/main/java/chat/rocket/android/chatroom/ui/Menu.kt
+11
-0
RoomUiModelMapper.kt
...hat/rocket/android/chatrooms/adapter/RoomUiModelMapper.kt
+12
-10
ChatRoomsAdapter.kt
...java/chat/rocket/android/chatrooms/ui/ChatRoomsAdapter.kt
+8
-7
ChatRoomsFragment.kt
...ava/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
+3
-0
ChatRoomsViewModel.kt
.../rocket/android/chatrooms/viewmodel/ChatRoomsViewModel.kt
+8
-3
Ui.kt
app/src/main/java/chat/rocket/android/util/extensions/Ui.kt
+0
-13
No files found.
app/src/main/java/chat/rocket/android/authentication/registerusername/ui/RegisterUsernameFragment.kt
View file @
38a3796f
...
...
@@ -8,6 +8,7 @@ import android.view.View
import
android.view.ViewGroup
import
androidx.core.content.ContextCompat
import
androidx.core.view.ViewCompat
import
androidx.core.view.isVisible
import
androidx.fragment.app.Fragment
import
chat.rocket.android.R
import
chat.rocket.android.analytics.AnalyticsManager
...
...
@@ -16,7 +17,6 @@ import chat.rocket.android.authentication.registerusername.presentation.Register
import
chat.rocket.android.authentication.registerusername.presentation.RegisterUsernameView
import
chat.rocket.android.util.extension.asObservable
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.android.util.extensions.showKeyboard
import
chat.rocket.android.util.extensions.showToast
import
chat.rocket.android.util.extensions.textContent
...
...
@@ -113,13 +113,13 @@ class RegisterUsernameFragment : Fragment(), RegisterUsernameView {
override
fun
showLoading
()
{
ui
{
disableUserInput
()
view_loading
.
setVisible
(
true
)
view_loading
.
isVisible
=
true
}
}
override
fun
hideLoading
()
{
ui
{
view_loading
.
setVisible
(
false
)
view_loading
.
isVisible
=
false
enableUserInput
()
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/resetpassword/ui/ResetPasswordFragment.kt
View file @
38a3796f
...
...
@@ -6,6 +6,7 @@ import android.view.View
import
android.view.ViewGroup
import
androidx.core.content.ContextCompat
import
androidx.core.view.ViewCompat
import
androidx.core.view.isVisible
import
androidx.fragment.app.Fragment
import
chat.rocket.android.R
import
chat.rocket.android.analytics.AnalyticsManager
...
...
@@ -15,7 +16,6 @@ import chat.rocket.android.authentication.resetpassword.presentation.ResetPasswo
import
chat.rocket.android.util.extension.asObservable
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.util.extensions.isEmail
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.android.util.extensions.showKeyboard
import
chat.rocket.android.util.extensions.showToast
import
chat.rocket.android.util.extensions.textContent
...
...
@@ -93,13 +93,13 @@ class ResetPasswordFragment : Fragment(), ResetPasswordView {
override
fun
showLoading
()
{
ui
{
disableUserInput
()
view_loading
.
setVisible
(
true
)
view_loading
.
isVisible
=
true
}
}
override
fun
hideLoading
()
{
ui
{
view_loading
.
setVisible
(
false
)
view_loading
.
isVisible
=
false
enableUserInput
()
}
}
...
...
app/src/main/java/chat/rocket/android/chatinformation/ui/MessageInfoFragment.kt
View file @
38a3796f
...
...
@@ -4,6 +4,7 @@ import android.os.Bundle
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
androidx.core.view.isVisible
import
androidx.fragment.app.Fragment
import
androidx.recyclerview.widget.DefaultItemAnimator
import
androidx.recyclerview.widget.LinearLayoutManager
...
...
@@ -15,7 +16,6 @@ import chat.rocket.android.chatinformation.adapter.ReadReceiptAdapter
import
chat.rocket.android.chatinformation.presentation.MessageInfoPresenter
import
chat.rocket.android.chatinformation.presentation.MessageInfoView
import
chat.rocket.android.chatinformation.viewmodel.ReadReceiptViewModel
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.android.util.extensions.showToast
import
chat.rocket.android.util.extensions.ui
import
dagger.android.support.AndroidSupportInjection
...
...
@@ -86,15 +86,15 @@ class MessageInfoFragment : Fragment(), MessageInfoView {
override
fun
showLoading
()
{
ui
{
view_loading
.
setVisible
(
true
)
view_loading
.
isVisible
=
true
view_loading
.
show
()
}
}
override
fun
hideLoading
()
{
ui
{
view_loading
.
isVisible
=
false
view_loading
.
hide
()
view_loading
.
setVisible
(
false
)
}
}
...
...
@@ -103,4 +103,4 @@ class MessageInfoFragment : Fragment(), MessageInfoView {
adapter
.
addAll
(
messageReceipts
)
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/adapter/PeopleSuggestionsAdapter.kt
View file @
38a3796f
...
...
@@ -7,10 +7,10 @@ import android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
android.widget.TextView
import
androidx.core.view.isVisible
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.adapter.PeopleSuggestionsAdapter.PeopleSuggestionViewHolder
import
chat.rocket.android.chatroom.uimodel.suggestion.PeopleSuggestionUiModel
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.android.suggestions.model.SuggestionModel
import
chat.rocket.android.suggestions.ui.BaseSuggestionViewHolder
import
chat.rocket.android.suggestions.ui.SuggestionsAdapter
...
...
@@ -58,9 +58,9 @@ class PeopleSuggestionsAdapter(context: Context) : SuggestionsAdapter<PeopleSugg
username
.
text
=
item
.
username
name
.
text
=
item
.
name
if
(
item
.
imageUri
?.
isEmpty
()
!=
false
)
{
avatar
.
setVisible
(
false
)
avatar
.
isVisible
=
false
}
else
{
avatar
.
setVisible
(
true
)
avatar
.
isVisible
=
true
avatar
.
setImageURI
(
item
.
imageUri
)
}
val
status
=
item
.
status
...
...
@@ -68,7 +68,7 @@ class PeopleSuggestionsAdapter(context: Context) : SuggestionsAdapter<PeopleSugg
val
statusDrawable
=
DrawableHelper
.
getUserStatusDrawable
(
status
,
itemView
.
context
)
statusView
.
setImageDrawable
(
statusDrawable
)
}
else
{
statusView
.
setVisible
(
false
)
statusView
.
isVisible
=
false
}
setOnClickListener
{
itemClickListener
?.
onClick
(
item
)
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
38a3796f
...
...
@@ -266,16 +266,16 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
override
fun
onPause
()
{
super
.
onPause
()
setReactionButtonIcon
(
R
.
drawable
.
ic_reaction_24dp
)
dismissEmojiKeyboard
()
activity
?.
invalidateOptionsMenu
()
}
private
fun
dismissEmojiKeyboard
()
{
fun
dismissEmojiKeyboard
()
{
// Check if the keyboard was ever initialized.
// It may be the case when you are looking a not joined room
if
(
::
emojiKeyboardPopup
.
isInitialized
)
{
emojiKeyboardPopup
.
dismiss
()
setReactionButtonIcon
(
R
.
drawable
.
ic_reaction_24dp
)
}
}
...
...
@@ -784,8 +784,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
context
:
Context
)
{
if
(
f
is
MessageActionsBottomSheet
)
{
setReactionButtonIcon
(
R
.
drawable
.
ic_reaction_24dp
)
emojiKeyboardPopup
.
dismiss
()
dismissEmojiKeyboard
()
}
}
},
...
...
@@ -805,9 +804,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
it
.
onBackPressed
()
}
KeyboardHelper
.
hideSoftKeyboard
(
it
)
emojiKeyboardPopup
.
dismiss
()
dismissEmojiKeyboard
()
}
setReactionButtonIcon
(
R
.
drawable
.
ic_reaction_24dp
)
}
}
...
...
@@ -917,8 +915,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
setReactionButtonIcon
(
R
.
drawable
.
ic_keyboard_black_24dp
)
}
else
{
// If popup is showing, simply dismiss it to show the underlying text keyboard
emojiKeyboardPopup
.
dismiss
()
setReactionButtonIcon
(
R
.
drawable
.
ic_reaction_24dp
)
dismissEmojiKeyboard
()
}
}
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/Menu.kt
View file @
38a3796f
...
...
@@ -79,6 +79,17 @@ private fun ChatRoomFragment.setupSearchMessageMenuItem(menu: Menu, context: Con
.
setShowAsActionFlags
(
MenuItem
.
SHOW_AS_ACTION_IF_ROOM
or
MenuItem
.
SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
)
.
setOnActionExpandListener
(
object
:
MenuItem
.
OnActionExpandListener
{
override
fun
onMenuItemActionExpand
(
item
:
MenuItem
?):
Boolean
{
dismissEmojiKeyboard
()
return
true
}
override
fun
onMenuItemActionCollapse
(
item
:
MenuItem
?):
Boolean
{
dismissEmojiKeyboard
()
return
true
}
})
(
searchItem
?.
actionView
as
?
SearchView
)
?.
let
{
// TODO: Check why we need to stylize the search text programmatically instead of by defining it in the styles.xml (ChatRoom.SearchView)
...
...
app/src/main/java/chat/rocket/android/chatrooms/adapter/RoomUiModelMapper.kt
View file @
38a3796f
...
...
@@ -42,27 +42,28 @@ class RoomUiModelMapper(
userInteractor
.
get
()
}
fun
map
(
rooms
:
List
<
ChatRoom
>,
grouped
:
Boolean
=
false
):
List
<
ItemHolder
<*
>>
{
fun
map
(
rooms
:
List
<
ChatRoom
>,
grouped
:
Boolean
=
false
,
showLastMessage
:
Boolean
=
true
):
List
<
ItemHolder
<*
>>
{
val
list
=
ArrayList
<
ItemHolder
<*>>(
rooms
.
size
+
4
)
var
lastType
:
String
?
=
null
rooms
.
forEach
{
room
->
if
(
grouped
&&
lastType
!=
room
.
chatRoom
.
type
)
{
list
.
add
(
HeaderItemHolder
(
roomType
(
room
.
chatRoom
.
type
)))
}
list
.
add
(
RoomItemHolder
(
map
(
room
)))
list
.
add
(
RoomItemHolder
(
map
(
room
,
showLastMessage
)))
lastType
=
room
.
chatRoom
.
type
}
return
list
}
fun
map
(
spotlight
:
SpotlightResult
):
List
<
ItemHolder
<*
>>
{
fun
map
(
spotlight
:
SpotlightResult
,
showLastMessage
:
Boolean
=
true
):
List
<
ItemHolder
<*
>>
{
val
list
=
ArrayList
<
ItemHolder
<*>>(
spotlight
.
users
.
size
+
spotlight
.
rooms
.
size
)
spotlight
.
users
.
filterNot
{
it
.
username
.
isNullOrEmpty
()
}.
forEach
{
user
->
list
.
add
(
RoomItemHolder
(
mapUser
(
user
)))
}
spotlight
.
rooms
.
filterNot
{
it
.
name
.
isNullOrEmpty
()
}.
forEach
{
room
->
list
.
add
(
RoomItemHolder
(
mapRoom
(
room
)))
list
.
add
(
RoomItemHolder
(
mapRoom
(
room
,
showLastMessage
)))
}
return
list
...
...
@@ -86,21 +87,21 @@ class RoomUiModelMapper(
}
}
private
fun
mapRoom
(
room
:
Room
):
RoomUiModel
{
private
fun
mapRoom
(
room
:
Room
,
showLastMessage
:
Boolean
=
true
):
RoomUiModel
{
return
with
(
room
)
{
RoomUiModel
(
id
=
id
,
name
=
name
!!
,
type
=
type
,
avatar
=
serverUrl
.
avatarUrl
(
name
!!
,
isGroupOrChannel
=
true
),
lastMessage
=
mapLastMessage
(
lastMessage
?.
sender
?.
id
,
lastMessage
?.
sender
?.
username
,
lastMessage
=
if
(
showLastMessage
)
{
mapLastMessage
(
lastMessage
?.
sender
?.
id
,
lastMessage
?.
sender
?.
username
,
lastMessage
?.
sender
?.
name
,
lastMessage
?.
message
,
isDirectMessage
=
type
is
RoomType
.
DirectMessage
)
isDirectMessage
=
type
is
RoomType
.
DirectMessage
)
}
else
{
null
}
)
}
}
fun
map
(
chatRoom
:
ChatRoom
):
RoomUiModel
{
fun
map
(
chatRoom
:
ChatRoom
,
showLastMessage
:
Boolean
=
true
):
RoomUiModel
{
return
with
(
chatRoom
.
chatRoom
)
{
val
isUnread
=
alert
||
unread
>
0
val
type
=
roomTypeOf
(
type
)
...
...
@@ -113,9 +114,9 @@ class RoomUiModelMapper(
serverUrl
.
avatarUrl
(
name
,
isGroupOrChannel
=
true
)
}
val
unread
=
mapUnread
(
unread
)
val
lastMessage
=
mapLastMessage
(
lastMessageUserId
,
chatRoom
.
lastMessageUserName
,
val
lastMessage
=
if
(
showLastMessage
)
{
mapLastMessage
(
lastMessageUserId
,
chatRoom
.
lastMessageUserName
,
chatRoom
.
lastMessageUserFullName
,
lastMessageText
,
isUnread
,
type
is
RoomType
.
DirectMessage
)
type
is
RoomType
.
DirectMessage
)
}
else
{
null
}
val
open
=
open
RoomUiModel
(
...
...
@@ -148,6 +149,7 @@ class RoomUiModelMapper(
private
fun
mapLastMessage
(
userId
:
String
?,
name
:
String
?,
fullName
:
String
?,
text
:
String
?,
unread
:
Boolean
=
false
,
isDirectMessage
:
Boolean
=
false
):
CharSequence
?
{
return
if
(!
settings
.
showLastMessage
())
{
null
}
else
if
(
name
!=
null
&&
text
!=
null
)
{
...
...
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsAdapter.kt
View file @
38a3796f
...
...
@@ -12,6 +12,7 @@ import android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
android.widget.TextView
import
androidx.core.view.isVisible
import
chat.rocket.android.R
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.infrastructure.checkIfMyself
...
...
@@ -53,13 +54,13 @@ class ChatRoomsAdapter(
bindName
(
chatRoom
,
text_chat_name
)
bindIcon
(
chatRoom
,
image_chat_icon
)
if
(
settings
.
showLastMessage
())
{
text_last_message
.
setVisible
(
true
)
text_last_message_date_time
.
setVisible
(
true
)
text_last_message
.
isVisible
=
true
text_last_message_date_time
.
isVisible
=
true
bindLastMessageDateTime
(
chatRoom
,
text_last_message_date_time
)
bindLastMessage
(
chatRoom
,
text_last_message
)
}
else
{
text_last_message
.
setVisible
(
false
)
text_last_message_date_time
.
setVisible
(
false
)
text_last_message
.
isVisible
=
false
text_last_message_date_time
.
isVisible
=
false
}
bindUnreadMessages
(
chatRoom
,
text_total_unread_messages
)
...
...
@@ -178,13 +179,13 @@ class ChatRoomsAdapter(
when
{
totalUnreadMessage
in
1
..
99
->
{
textView
.
textContent
=
totalUnreadMessage
.
toString
()
textView
.
setVisible
(
true
)
textView
.
isVisible
=
true
}
totalUnreadMessage
>
99
->
{
textView
.
textContent
=
context
.
getString
(
R
.
string
.
msg_more_than_ninety_nine_unread_messages
)
textView
.
setVisible
(
true
)
textView
.
isVisible
=
true
}
else
->
textView
.
setVisible
(
false
)
else
->
textView
.
isVisible
=
false
}
}
}
...
...
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
View file @
38a3796f
...
...
@@ -178,11 +178,14 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
override
fun
onMenuItemActionCollapse
(
item
:
MenuItem
):
Boolean
{
// Simply setting sortView to visible won't work, so we invalidate the options
// to recreate the entire menu...
viewModel
.
showLastMessage
=
true
activity
?.
invalidateOptionsMenu
()
queryChatRoomsByName
(
null
)
return
true
}
override
fun
onMenuItemActionExpand
(
item
:
MenuItem
):
Boolean
{
viewModel
.
showLastMessage
=
false
sortView
?.
isVisible
=
false
return
true
}
...
...
app/src/main/java/chat/rocket/android/chatrooms/viewmodel/ChatRoomsViewModel.kt
View file @
38a3796f
...
...
@@ -30,6 +30,7 @@ import timber.log.Timber
import
java.security.InvalidParameterException
import
kotlin.coroutines.experimental.coroutineContext
class
ChatRoomsViewModel
(
private
val
connectionManager
:
ConnectionManager
,
private
val
interactor
:
FetchChatRoomsInteractor
,
...
...
@@ -41,9 +42,11 @@ class ChatRoomsViewModel(
private
val
runContext
=
newSingleThreadContext
(
"chat-rooms-view-model"
)
private
val
client
=
connectionManager
.
client
private
var
loaded
=
false
var
showLastMessage
=
true
fun
getChatRooms
():
LiveData
<
RoomsModel
>
{
return
Transformations
.
switchMap
(
query
)
{
query
->
return
@switchMap
if
(
query
.
isSearch
())
{
this
@ChatRoomsViewModel
.
query
.
wrap
(
runContext
)
{
_
,
data
:
MutableLiveData
<
RoomsModel
>
->
val
string
=
(
query
as
Query
.
Search
).
query
...
...
@@ -53,11 +56,13 @@ class ChatRoomsViewModel(
// TODO - find a better way for cancellation checking
if
(!
coroutineContext
.
isActive
)
return
@wrap
val
rooms
=
repository
.
search
(
string
).
let
{
mapper
.
map
(
it
)
}
val
rooms
=
repository
.
search
(
string
).
let
{
mapper
.
map
(
it
,
showLastMessage
=
this
.
showLastMessage
)
}
data
.
postValue
(
rooms
.
toMutableList
()
+
LoadingItemHolder
())
if
(!
coroutineContext
.
isActive
)
return
@wrap
val
spotlight
=
spotlight
(
query
.
query
)
?.
let
{
mapper
.
map
(
it
)
}
val
spotlight
=
spotlight
(
query
.
query
)
?.
let
{
mapper
.
map
(
it
,
showLastMessage
=
this
.
showLastMessage
)
}
if
(!
coroutineContext
.
isActive
)
return
@wrap
spotlight
?.
let
{
...
...
@@ -72,7 +77,7 @@ class ChatRoomsViewModel(
.
distinct
()
.
transform
(
runContext
)
{
rooms
->
val
mappedRooms
=
rooms
?.
let
{
mapper
.
map
(
rooms
,
query
.
isGrouped
())
mapper
.
map
(
rooms
,
query
.
isGrouped
()
,
this
.
showLastMessage
)
}
if
(
loaded
&&
mappedRooms
?.
isEmpty
()
==
true
)
{
loadingState
.
postValue
(
LoadingState
.
Loaded
(
0
))
...
...
app/src/main/java/chat/rocket/android/util/extensions/Ui.kt
View file @
38a3796f
...
...
@@ -37,19 +37,6 @@ fun FragmentActivity.clearLightStatusBar() {
}
}
// TODO: Remove. Use KTX instead.
fun
View
.
setVisible
(
visible
:
Boolean
)
{
visibility
=
if
(
visible
)
{
View
.
VISIBLE
}
else
{
View
.
GONE
}
}
fun
View
.
isVisible
():
Boolean
{
return
visibility
==
View
.
VISIBLE
}
fun
ViewGroup
.
inflate
(
@LayoutRes
resource
:
Int
,
attachToRoot
:
Boolean
=
false
):
View
=
LayoutInflater
.
from
(
context
).
inflate
(
resource
,
this
,
attachToRoot
)
...
...
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