Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-client-android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-client-android
Commits
a34dfc2b
Commit
a34dfc2b
authored
1 year ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
ConversationFragment: use MenuProvider
Change-Id: I17aeb84d5d5362600c9a3eb5b8aa61637205e223
parent
ee121f41
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
jami-android/app/src/main/java/cx/ring/fragments/ConversationFragment.kt
+61
-53
61 additions, 53 deletions
...p/src/main/java/cx/ring/fragments/ConversationFragment.kt
with
61 additions
and
53 deletions
jami-android/app/src/main/java/cx/ring/fragments/ConversationFragment.kt
+
61
−
53
View file @
a34dfc2b
...
...
@@ -207,6 +207,9 @@ class ConversationFragment : BaseSupportFragment<ConversationPresenter, Conversa
mapWidth
=
res
.
getDimensionPixelSize
(
R
.
dimen
.
location_sharing_minmap_width
)
mapHeight
=
res
.
getDimensionPixelSize
(
R
.
dimen
.
location_sharing_minmap_height
)
marginPxTotal
=
marginPx
requireActivity
().
addMenuProvider
(
menuProvider
,
viewLifecycleOwner
)
return
FragConversationBinding
.
inflate
(
inflater
,
container
,
false
).
let
{
binding
->
this
@ConversationFragment
.
binding
=
binding
binding
.
presenter
=
this
@ConversationFragment
...
...
@@ -302,7 +305,6 @@ class ConversationFragment : BaseSupportFragment<ConversationPresenter, Conversa
binding
.
fabLatest
.
setOnClickListener
{
scrollToEnd
()
}
setHasOptionsMenu
(
true
)
binding
.
toolbar
.
setNavigationIcon
(
androidx
.
appcompat
.
R
.
drawable
.
abc_ic_ab_back_material
)
binding
.
toolbar
.
setNavigationOnClickListener
{
activity
?.
onBackPressedDispatcher
?.
onBackPressed
()
...
...
@@ -817,57 +819,59 @@ class ConversationFragment : BaseSupportFragment<ConversationPresenter, Conversa
super
.
onDestroy
()
}
override
fun
onCreateOptionsMenu
(
menu
:
Menu
,
inflater
:
MenuInflater
)
{
if
(!
isVisible
)
return
menu
.
clear
()
inflater
.
inflate
(
R
.
menu
.
conversation_actions
,
menu
)
mAudioCallBtn
=
menu
.
findItem
(
R
.
id
.
conv_action_audiocall
)
mVideoCallBtn
=
menu
.
findItem
(
R
.
id
.
conv_action_videocall
)
val
searchMenuItem
=
menu
.
findItem
(
R
.
id
.
conv_search
)
searchMenuItem
.
setOnActionExpandListener
(
object
:
MenuItem
.
OnActionExpandListener
{
override
fun
onMenuItemActionCollapse
(
item
:
MenuItem
):
Boolean
{
val
binding
=
binding
?:
return
false
presenter
.
stopSearch
()
binding
.
histList
.
adapter
=
mAdapter
updateListPadding
()
currentBottomView
?.
isVisible
=
true
if
(
animation
.
isStarted
)
animation
.
cancel
()
animation
.
setIntValues
(
binding
.
histList
.
paddingBottom
,
(
currentBottomView
?.
height
?:
0
)
+
marginPxTotal
)
animation
.
start
()
return
true
}
override
fun
onMenuItemActionExpand
(
item
:
MenuItem
):
Boolean
{
val
binding
=
binding
?:
return
false
mSearchAdapter
=
ConversationAdapter
(
this
@ConversationFragment
,
presenter
,
true
)
presenter
.
startSearch
()
currentBottomView
?.
isVisible
=
false
binding
.
histList
.
adapter
=
mSearchAdapter
if
(
animation
.
isStarted
)
animation
.
cancel
()
animation
.
setIntValues
(
binding
.
histList
.
paddingBottom
,
marginPxTotal
)
animation
.
start
()
return
true
private
val
menuProvider
=
object
:
MenuProvider
{
override
fun
onCreateMenu
(
menu
:
Menu
,
inflater
:
MenuInflater
)
{
if
(!
isVisible
)
return
menu
.
clear
()
inflater
.
inflate
(
R
.
menu
.
conversation_actions
,
menu
)
mAudioCallBtn
=
menu
.
findItem
(
R
.
id
.
conv_action_audiocall
)
mVideoCallBtn
=
menu
.
findItem
(
R
.
id
.
conv_action_videocall
)
val
searchMenuItem
=
menu
.
findItem
(
R
.
id
.
conv_search
)
searchMenuItem
.
setOnActionExpandListener
(
object
:
MenuItem
.
OnActionExpandListener
{
override
fun
onMenuItemActionCollapse
(
item
:
MenuItem
):
Boolean
{
val
binding
=
binding
?:
return
false
presenter
.
stopSearch
()
binding
.
histList
.
adapter
=
mAdapter
updateListPadding
()
currentBottomView
?.
isVisible
=
true
if
(
animation
.
isStarted
)
animation
.
cancel
()
animation
.
setIntValues
(
binding
.
histList
.
paddingBottom
,
(
currentBottomView
?.
height
?:
0
)
+
marginPxTotal
)
animation
.
start
()
return
true
}
override
fun
onMenuItemActionExpand
(
item
:
MenuItem
):
Boolean
{
val
binding
=
binding
?:
return
false
mSearchAdapter
=
ConversationAdapter
(
this
@ConversationFragment
,
presenter
,
true
)
presenter
.
startSearch
()
currentBottomView
?.
isVisible
=
false
binding
.
histList
.
adapter
=
mSearchAdapter
if
(
animation
.
isStarted
)
animation
.
cancel
()
animation
.
setIntValues
(
binding
.
histList
.
paddingBottom
,
marginPxTotal
)
animation
.
start
()
return
true
}
})
(
searchMenuItem
.
actionView
as
SearchView
).
let
{
it
.
setOnQueryTextListener
(
this
@ConversationFragment
)
it
.
queryHint
=
getString
(
R
.
string
.
conversation_search_hint
)
}
})
(
searchMenuItem
.
actionView
as
SearchView
).
let
{
it
.
setOnQueryTextListener
(
this
)
it
.
queryHint
=
getString
(
R
.
string
.
conversation_search_hint
)
}
}
fun
openContact
()
{
presenter
.
openContact
()
}
override
fun
onOptionsItemSelected
(
item
:
MenuItem
):
Boolean
{
when
(
item
.
itemId
)
{
android
.
R
.
id
.
home
->
startActivity
(
Intent
(
activity
,
HomeActivity
::
class
.
java
))
R
.
id
.
conv_action_audiocall
->
presenter
.
goToCall
(
false
)
R
.
id
.
conv_action_videocall
->
presenter
.
goToCall
(
true
)
R
.
id
.
conv_contact_details
->
presenter
.
openContact
()
else
->
return
super
.
onOptionsItemSelected
(
item
)
override
fun
onMenuItemSelected
(
item
:
MenuItem
):
Boolean
{
when
(
item
.
itemId
)
{
android
.
R
.
id
.
home
->
startActivity
(
Intent
(
activity
,
HomeActivity
::
class
.
java
))
R
.
id
.
conv_action_audiocall
->
presenter
.
goToCall
(
false
)
R
.
id
.
conv_action_videocall
->
presenter
.
goToCall
(
true
)
R
.
id
.
conv_contact_details
->
presenter
.
openContact
()
else
->
return
false
}
return
true
}
return
true
}
override
fun
onQueryTextSubmit
(
query
:
String
):
Boolean
{
...
...
@@ -881,6 +885,10 @@ class ConversationFragment : BaseSupportFragment<ConversationPresenter, Conversa
return
true
}
fun
openContact
()
{
presenter
.
openContact
()
}
override
fun
addSearchResults
(
results
:
List
<
Interaction
>)
{
mSearchAdapter
?.
addSearchResults
(
results
)
}
...
...
@@ -1123,7 +1131,7 @@ class ConversationFragment : BaseSupportFragment<ConversationPresenter, Conversa
trustRequestMessageLayout
.
visibility
=
View
.
VISIBLE
currentBottomView
=
unknownContactPrompt
}
requireActivity
().
invalidate
Options
Menu
()
requireActivity
().
invalidateMenu
()
updateListPadding
()
}
...
...
@@ -1136,7 +1144,7 @@ class ConversationFragment : BaseSupportFragment<ConversationPresenter, Conversa
trustRequestMessageLayout
.
visibility
=
View
.
VISIBLE
currentBottomView
=
trustRequestPrompt
}
requireActivity
().
invalidate
Options
Menu
()
requireActivity
().
invalidateMenu
()
updateListPadding
()
}
...
...
@@ -1148,7 +1156,7 @@ class ConversationFragment : BaseSupportFragment<ConversationPresenter, Conversa
trustRequestMessageLayout
.
visibility
=
View
.
GONE
currentBottomView
=
cvMessageInput
}
requireActivity
().
invalidate
Options
Menu
()
requireActivity
().
invalidateMenu
()
updateListPadding
()
}
...
...
@@ -1161,7 +1169,7 @@ class ConversationFragment : BaseSupportFragment<ConversationPresenter, Conversa
tvTrustRequestMessage
.
text
=
getText
(
R
.
string
.
conversation_syncing
)
}
currentBottomView
=
null
requireActivity
().
invalidate
Options
Menu
()
requireActivity
().
invalidateMenu
()
updateListPadding
()
}
...
...
@@ -1184,7 +1192,7 @@ class ConversationFragment : BaseSupportFragment<ConversationPresenter, Conversa
tvTrustRequestMessage
.
text
=
getText
(
R
.
string
.
conversation_ended
)
}
currentBottomView
=
null
requireActivity
().
invalidate
Options
Menu
()
requireActivity
().
invalidateMenu
()
updateListPadding
()
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment