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
a0058ba9
Commit
a0058ba9
authored
Nov 27, 2018
by
Samer Alabi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added requested changes
parent
a0b264a2
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
87 additions
and
51 deletions
+87
-51
OptionItemHolder.kt
...at/rocket/android/chatdetails/adapter/OptionItemHolder.kt
+6
-0
OptionViewHolder.kt
...at/rocket/android/chatdetails/adapter/OptionViewHolder.kt
+35
-0
ChatDetailsFragmentModule.kt
...ocket/android/chatdetails/di/ChatDetailsFragmentModule.kt
+1
-0
ChatDetailsFragmentProvider.kt
...ket/android/chatdetails/di/ChatDetailsFragmentProvider.kt
+1
-0
ChatDetailsModule.kt
...a/chat/rocket/android/chatdetails/di/ChatDetailsModule.kt
+1
-0
Option.kt
...ain/java/chat/rocket/android/chatdetails/domain/Option.kt
+7
-0
ChatDetailsNavigator.kt
.../android/chatdetails/presentation/ChatDetailsNavigator.kt
+1
-0
ChatDetailsPresenter.kt
.../android/chatdetails/presentation/ChatDetailsPresenter.kt
+6
-1
ChatDetailsAdapter.kt
.../chat/rocket/android/chatdetails/ui/ChatDetailsAdapter.kt
+6
-31
ChatDetailsFragment.kt
...chat/rocket/android/chatdetails/ui/ChatDetailsFragment.kt
+21
-19
ChatDetailsViewModel.kt
...ket/android/chatdetails/viewmodel/ChatDetailsViewModel.kt
+1
-0
ChatDetailsViewModelFactory.kt
...roid/chatdetails/viewmodel/ChatDetailsViewModelFactory.kt
+1
-0
No files found.
app/src/main/java/chat/rocket/android/chatdetails/adapter/OptionItemHolder.kt
0 → 100644
View file @
a0058ba9
package
chat.rocket.android.chatdetails.adapter
import
chat.rocket.android.chatdetails.domain.Option
import
chat.rocket.android.chatrooms.adapter.ItemHolder
data class
OptionItemHolder
(
override
val
data
:
Option
):
ItemHolder
<
Option
>
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatdetails/adapter/OptionViewHolder.kt
0 → 100644
View file @
a0058ba9
package
chat.rocket.android.chatdetails.adapter
import
android.content.Context
import
android.view.View
import
android.widget.ImageView
import
android.widget.TextView
import
chat.rocket.android.R
import
chat.rocket.android.chatdetails.domain.Option
import
chat.rocket.android.chatrooms.adapter.ViewHolder
import
kotlinx.android.synthetic.main.item_detail_option.view.*
class
OptionViewHolder
(
itemView
:
View
):
ViewHolder
<
OptionItemHolder
>(
itemView
)
{
override
fun
bindViews
(
data
:
OptionItemHolder
)
{
val
option
=
data
.
data
bindName
(
option
,
itemView
.
name
)
bindIcon
(
option
,
itemView
.
icon
)
itemView
.
setOnClickListener
{
option
.
listener
()
}
}
private
fun
bindIcon
(
option
:
Option
,
view
:
ImageView
)
{
val
drawable
=
DrawableHelper
.
getDrawableFromId
(
option
.
icon
,
itemView
.
context
)
drawable
.
let
{
image
->
val
mutateDrawable
=
DrawableHelper
.
wrapDrawable
(
image
).
mutate
()
DrawableHelper
.
tintDrawable
(
mutateDrawable
,
itemView
.
context
,
R
.
color
.
colorPrimaryText
)
view
.
setImageDrawable
(
mutateDrawable
)
}
}
private
fun
bindName
(
option
:
Option
,
view
:
TextView
)
{
view
.
text
=
option
.
name
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatdetails/di/ChatDetailsFragmentModule.kt
View file @
a0058ba9
...
...
@@ -13,6 +13,7 @@ import kotlinx.coroutines.experimental.Job
@Module
class
ChatDetailsFragmentModule
{
@Provides
@PerFragment
fun
provideJob
()
=
Job
()
...
...
app/src/main/java/chat/rocket/android/chatdetails/di/ChatDetailsFragmentProvider.kt
View file @
a0058ba9
...
...
@@ -7,6 +7,7 @@ import dagger.android.ContributesAndroidInjector
@Module
abstract
class
ChatDetailsFragmentProvider
{
@ContributesAndroidInjector
(
modules
=
[
ChatDetailsFragmentModule
::
class
])
@PerFragment
abstract
fun
providesChatDetailsFragment
():
ChatDetailsFragment
...
...
app/src/main/java/chat/rocket/android/chatdetails/di/ChatDetailsModule.kt
View file @
a0058ba9
...
...
@@ -8,6 +8,7 @@ import dagger.Provides
@Module
class
ChatDetailsModule
{
@Provides
@PerActivity
fun
providesNavigator
(
activity
:
ChatDetailsActivity
)
=
ChatDetailsNavigator
(
activity
)
...
...
app/src/main/java/chat/rocket/android/chatdetails/domain/Option.kt
0 → 100644
View file @
a0058ba9
package
chat.rocket.android.chatdetails.domain
data class
Option
(
val
name
:
String
,
val
icon
:
Int
,
val
listener
:
()
->
Unit
)
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatdetails/presentation/ChatDetailsNavigator.kt
View file @
a0058ba9
...
...
@@ -10,6 +10,7 @@ import chat.rocket.android.pinnedmessages.ui.TAG_PINNED_MESSAGES_FRAGMENT
import
chat.rocket.android.util.extensions.addFragmentBackStack
class
ChatDetailsNavigator
(
internal
val
activity
:
ChatDetailsActivity
)
{
fun
toMembersList
(
chatRoomId
:
String
)
{
activity
.
addFragmentBackStack
(
TAG_MEMBERS_FRAGMENT
,
R
.
id
.
fragment_container
)
{
chat
.
rocket
.
android
.
members
.
ui
.
newInstance
(
chatRoomId
)
...
...
app/src/main/java/chat/rocket/android/chatdetails/presentation/ChatDetailsPresenter.kt
View file @
a0058ba9
...
...
@@ -5,6 +5,7 @@ import chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.retryIO
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.util.ifNull
import
chat.rocket.core.internal.rest.getInfo
...
...
@@ -25,7 +26,11 @@ class ChatDetailsPresenter @Inject constructor(
fun
getDetails
(
chatRoomId
:
String
,
chatRoomType
:
String
)
{
launchUI
(
strategy
)
{
try
{
view
.
displayDetails
(
roomToChatDetails
(
client
.
getInfo
(
chatRoomId
,
null
,
roomTypeOf
(
chatRoomType
))))
val
room
=
retryIO
(
"getInfo($chatRoomId, null, $chatRoomType"
)
{
client
.
getInfo
(
chatRoomId
,
null
,
roomTypeOf
(
chatRoomType
))
}
view
.
displayDetails
(
roomToChatDetails
(
room
))
}
catch
(
e
:
Exception
)
{
e
.
message
.
let
{
view
.
showMessage
(
it
!!
)
...
...
app/src/main/java/chat/rocket/android/chatdetails/ui/ChatDetailsAdapter.kt
View file @
a0058ba9
package
chat.rocket.android.chatdetails.ui
import
android.content.Context
import
android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
android.widget.TextView
import
androidx.recyclerview.widget.RecyclerView
import
chat.rocket.android.R
import
chat.rocket.android.chatdetails.adapter.OptionItemHolder
import
chat.rocket.android.chatdetails.adapter.OptionViewHolder
import
chat.rocket.android.chatdetails.domain.Option
import
chat.rocket.android.util.extensions.inflate
import
kotlinx.android.synthetic.main.item_detail_option.view.*
class
ChatDetailsAdapter
(
private
val
context
:
Context
):
RecyclerView
.
Adapter
<
ChatDetailsAdapter
.
ViewHolder
>()
{
class
ChatDetailsAdapter
:
RecyclerView
.
Adapter
<
Option
ViewHolder
>()
{
private
val
options
:
MutableList
<
Option
>
=
ArrayList
()
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
ViewHolder
=
ViewHolder
(
parent
.
inflate
(
R
.
layout
.
item_detail_option
))
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
OptionViewHolder
=
Option
ViewHolder
(
parent
.
inflate
(
R
.
layout
.
item_detail_option
))
override
fun
onBindViewHolder
(
holder
:
ViewHolder
,
position
:
Int
)
=
holder
.
bind
(
options
[
position
]
)
override
fun
onBindViewHolder
(
holder
:
OptionViewHolder
,
position
:
Int
)
=
holder
.
bindViews
(
OptionItemHolder
(
options
[
position
])
)
override
fun
getItemCount
():
Int
=
options
.
size
inner
class
ViewHolder
(
itemView
:
View
):
RecyclerView
.
ViewHolder
(
itemView
)
{
fun
bind
(
option
:
Option
)
{
bindName
(
option
,
itemView
.
name
)
bindIcon
(
option
,
itemView
.
icon
)
itemView
.
setOnClickListener
{
option
.
listener
()
}
}
}
inner
class
Option
(
val
name
:
String
,
val
icon
:
Int
,
val
listener
:
()
->
Unit
)
fun
addOption
(
name
:
String
,
icon
:
Int
,
listener
:
()
->
Unit
)
{
options
.
add
(
Option
(
name
,
icon
,
listener
))
notifyDataSetChanged
()
}
private
fun
bindName
(
option
:
Option
,
view
:
TextView
)
{
view
.
text
=
option
.
name
}
private
fun
bindIcon
(
option
:
Option
,
view
:
ImageView
)
{
val
drawable
=
DrawableHelper
.
getDrawableFromId
(
option
.
icon
,
context
)
drawable
.
let
{
image
->
val
mutateDrawable
=
DrawableHelper
.
wrapDrawable
(
image
).
mutate
()
DrawableHelper
.
tintDrawable
(
mutateDrawable
,
context
,
R
.
color
.
colorPrimaryText
)
view
.
setImageDrawable
(
mutateDrawable
)
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatdetails/ui/ChatDetailsFragment.kt
View file @
a0058ba9
...
...
@@ -114,27 +114,29 @@ class ChatDetailsFragment: Fragment(), ChatDetailsView {
}
}
private
fun
addOptions
(
adapter
:
ChatDetailsAdapter
)
{
if
(!
disableMenu
)
{
adapter
.
addOption
(
getString
(
R
.
string
.
title_files
),
R
.
drawable
.
ic_files_24dp
)
{
presenter
.
toFiles
(
chatRoomId
!!
)
private
fun
addOptions
(
adapter
:
ChatDetailsAdapter
?)
{
adapter
?.
let
{
if
(!
disableMenu
)
{
it
.
addOption
(
getString
(
R
.
string
.
title_files
),
R
.
drawable
.
ic_files_24dp
)
{
presenter
.
toFiles
(
chatRoomId
!!
)
}
}
}
if
(
chatRoomType
!=
RoomType
.
DIRECT_MESSAGE
&&
!
disableMenu
)
{
adapter
.
addOption
(
getString
(
R
.
string
.
msg_mentions
),
R
.
drawable
.
ic_at_black_20dp
)
{
presenter
.
toMentions
(
chatRoomId
!!
)
}
adapter
.
addOption
(
getString
(
R
.
string
.
title_members
),
R
.
drawable
.
ic_people_outline_black_24dp
)
{
presenter
.
toMembers
(
chatRoomId
!!
)
if
(
chatRoomType
!=
RoomType
.
DIRECT_MESSAGE
&&
!
disableMenu
)
{
it
.
addOption
(
getString
(
R
.
string
.
msg_mentions
),
R
.
drawable
.
ic_at_black_20dp
)
{
presenter
.
toMentions
(
chatRoomId
!!
)
}
it
.
addOption
(
getString
(
R
.
string
.
title_members
),
R
.
drawable
.
ic_people_outline_black_24dp
)
{
presenter
.
toMembers
(
chatRoomId
!!
)
}
}
}
adapter
.
addOption
(
getString
(
R
.
string
.
title_favorite_messages
),
R
.
drawable
.
ic_star_border_white_24dp
)
{
presenter
.
toFavorites
(
chatRoomId
!!
)
}
adapter
.
addOption
(
getString
(
R
.
string
.
title_pinned_messages
),
R
.
drawable
.
ic_action_message_pin_24dp
)
{
presenter
.
toPinned
(
chatRoomId
!!
)
it
.
addOption
(
getString
(
R
.
string
.
title_favorite_messages
),
R
.
drawable
.
ic_star_border_white_24dp
)
{
presenter
.
toFavorites
(
chatRoomId
!!
)
}
it
.
addOption
(
getString
(
R
.
string
.
title_pinned_messages
),
R
.
drawable
.
ic_action_message_pin_24dp
)
{
presenter
.
toPinned
(
chatRoomId
!!
)
}
}
}
...
...
@@ -169,7 +171,7 @@ class ChatDetailsFragment: Fragment(), ChatDetailsView {
private
fun
setupOptions
()
{
ui
{
if
(
options
.
adapter
==
null
)
{
adapter
=
ChatDetailsAdapter
(
context
!!
)
adapter
=
ChatDetailsAdapter
()
options
.
adapter
=
adapter
with
(
options
)
{
...
...
@@ -185,7 +187,7 @@ class ChatDetailsFragment: Fragment(), ChatDetailsView {
isNestedScrollingEnabled
=
false
}
}
addOptions
(
adapter
!!
)
addOptions
(
adapter
)
}
}
...
...
app/src/main/java/chat/rocket/android/chatdetails/viewmodel/ChatDetailsViewModel.kt
View file @
a0058ba9
...
...
@@ -8,6 +8,7 @@ import chat.rocket.android.chatdetails.domain.ChatDetails
import
chat.rocket.android.db.ChatRoomDao
class
ChatDetailsViewModel
(
private
val
chatRoomDao
:
ChatRoomDao
):
ViewModel
()
{
fun
getDetails
(
chatRoomId
:
String
):
LiveData
<
ChatDetails
>
{
return
Transformations
.
switchMap
(
chatRoomDao
.
get
(
chatRoomId
))
{
room
->
val
entity
=
room
.
chatRoom
...
...
app/src/main/java/chat/rocket/android/chatdetails/viewmodel/ChatDetailsViewModelFactory.kt
View file @
a0058ba9
...
...
@@ -6,6 +6,7 @@ import chat.rocket.android.db.ChatRoomDao
import
javax.inject.Inject
class
ChatDetailsViewModelFactory
@Inject
constructor
(
private
val
chatRoomDao
:
ChatRoomDao
)
:
ViewModelProvider
.
NewInstanceFactory
()
{
@Suppress
(
"UNCHECKED_CAST"
)
override
fun
<
T
:
ViewModel
?
>
create
(
modelClass
:
Class
<
T
>)
=
ChatDetailsViewModel
(
chatRoomDao
)
as
T
...
...
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