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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-client-android
Commits
11584579
Commit
11584579
authored
Mar 14, 2023
by
Pierre Nicolas
Browse files
Options
Downloads
Patches
Plain Diff
Add sequence break with previous interaction when current is a reply
Change-Id: Ic514492571b4bea54372147e512ccb7284049c1a
parent
fae192eb
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
jami-android/app/src/main/java/cx/ring/adapters/ConversationAdapter.kt
+43
-8
43 additions, 8 deletions
...app/src/main/java/cx/ring/adapters/ConversationAdapter.kt
with
43 additions
and
8 deletions
jami-android/app/src/main/java/cx/ring/adapters/ConversationAdapter.kt
+
43
−
8
View file @
11584579
...
@@ -1138,42 +1138,65 @@ class ConversationAdapter(
...
@@ -1138,42 +1138,65 @@ class ConversationAdapter(
mInteractions
[
position
+
1
]
mInteractions
[
position
+
1
]
else
null
else
null
/**
* Returns a SequenceType object which tell what type is the Interaction.
*
* @param i index of the interaction to analyse from interactions array.
* @param isTimeShown meta data of the interaction telling if the time is shown.
* @return the SequenceType of the analyzed interaction.
*/
private
fun
getMsgSequencing
(
i
:
Int
,
isTimeShown
:
Boolean
):
SequenceType
{
private
fun
getMsgSequencing
(
i
:
Int
,
isTimeShown
:
Boolean
):
SequenceType
{
val
msg
=
mInteractions
[
i
]
val
msg
=
mInteractions
[
i
]
// Manage specific interaction which are always single (ex : emoji).
if
(
isAlwaysSingleMsg
(
msg
))
{
if
(
isAlwaysSingleMsg
(
msg
))
{
return
SequenceType
.
SINGLE
return
SequenceType
.
SINGLE
}
}
// If there is only one interaction in the conversation
// OR if this is the first interaction.
if
(
mInteractions
.
size
==
1
||
i
==
0
)
{
if
(
mInteractions
.
size
==
1
||
i
==
0
)
{
// If this interaction is the last.
if
(
mInteractions
.
size
==
i
+
1
)
{
if
(
mInteractions
.
size
==
i
+
1
)
{
return
SequenceType
.
SINGLE
return
SequenceType
.
SINGLE
}
}
// Get the next interaction and if exists check if sequence break needed.
val
nextMsg
=
getNextMessageFromPosition
(
i
)
val
nextMsg
=
getNextMessageFromPosition
(
i
)
if
(
nextMsg
!=
null
)
{
if
(
nextMsg
!=
null
)
{
return
if
(
isSeqBreak
(
msg
,
nextMsg
)
||
hasPermanentTimeString
(
nextMsg
,
i
+
1
))
{
return
if
(
isSeqBreak
(
msg
,
nextMsg
)
||
hasPermanentTimeString
(
nextMsg
,
i
+
1
)
)
{
SequenceType
.
SINGLE
SequenceType
.
SINGLE
}
else
{
}
else
{
SequenceType
.
FIRST
SequenceType
.
FIRST
}
}
}
}
}
else
if
(
mInteractions
.
size
==
i
+
1
)
{
}
else
if
(
mInteractions
.
size
==
i
+
1
)
{
// If this is the last interaction.
// Get the previous interaction and if exists check if sequence break needed.
val
prevMsg
=
getPreviousMessageFromPosition
(
i
)
val
prevMsg
=
getPreviousMessageFromPosition
(
i
)
if
(
prevMsg
!=
null
)
{
if
(
prevMsg
!=
null
)
{
return
if
(
isSeqBreak
(
msg
,
prevMsg
)
||
isTimeShown
)
{
return
if
(
isSeqBreak
(
prevM
sg
,
m
sg
)
||
isTimeShown
)
{
SequenceType
.
SINGLE
SequenceType
.
SINGLE
}
else
{
}
else
{
SequenceType
.
LAST
SequenceType
.
LAST
}
}
}
}
}
}
// If not the first, nor the last and if there is not only one interaction.
// Get the next and previous interactions and if exists check if sequence break needed.
val
prevMsg
=
getPreviousMessageFromPosition
(
i
)
val
prevMsg
=
getPreviousMessageFromPosition
(
i
)
val
nextMsg
=
getNextMessageFromPosition
(
i
)
val
nextMsg
=
getNextMessageFromPosition
(
i
)
if
(
prevMsg
!=
null
&&
nextMsg
!=
null
)
{
if
(
prevMsg
!=
null
&&
nextMsg
!=
null
)
{
val
nextMsgHasTime
=
hasPermanentTimeString
(
nextMsg
,
i
+
1
)
val
nextMsgHasTime
=
hasPermanentTimeString
(
nextMsg
,
i
+
1
)
return
if
((
isSeqBreak
(
msg
,
prevMsg
)
||
isTimeShown
)
&&
!(
isSeqBreak
(
msg
,
nextMsg
)
||
nextMsgHasTime
))
{
return
if
((
isSeqBreak
(
prevMsg
,
msg
)
||
isTimeShown
)
&&
!(
isSeqBreak
(
msg
,
nextMsg
)
||
nextMsgHasTime
)
)
{
SequenceType
.
FIRST
SequenceType
.
FIRST
}
else
if
(!
isSeqBreak
(
msg
,
prevMsg
)
&&
!
isTimeShown
&&
isSeqBreak
(
msg
,
nextMsg
))
{
}
else
if
(!
isSeqBreak
(
prevM
sg
,
m
sg
)
&&
!
isTimeShown
&&
isSeqBreak
(
msg
,
nextMsg
))
{
SequenceType
.
LAST
SequenceType
.
LAST
}
else
if
(!
isSeqBreak
(
msg
,
prevMsg
)
&&
!
isTimeShown
&&
!
isSeqBreak
(
msg
,
nextMsg
))
{
}
else
if
(!
isSeqBreak
(
prevM
sg
,
m
sg
)
&&
!
isTimeShown
&&
!
isSeqBreak
(
msg
,
nextMsg
))
{
if
(
nextMsgHasTime
)
SequenceType
.
LAST
else
SequenceType
.
MIDDLE
if
(
nextMsgHasTime
)
SequenceType
.
LAST
else
SequenceType
.
MIDDLE
}
else
{
}
else
{
SequenceType
.
SINGLE
SequenceType
.
SINGLE
...
@@ -1253,8 +1276,20 @@ class ConversationAdapter(
...
@@ -1253,8 +1276,20 @@ class ConversationAdapter(
params
.
bottomMargin
=
targetSize
params
.
bottomMargin
=
targetSize
}
}
/**
* Tells if a break should be added in the sequence.
* The first interaction must be before the second interaction.
*
* @param first first interaction
* @param second second interaction
* @return True if a sequence break is needed. Else false.
*/
private
fun
isSeqBreak
(
first
:
Interaction
,
second
:
Interaction
):
Boolean
=
private
fun
isSeqBreak
(
first
:
Interaction
,
second
:
Interaction
):
Boolean
=
StringUtils
.
isOnlyEmoji
(
first
.
body
)
!=
StringUtils
.
isOnlyEmoji
(
second
.
body
)
||
first
.
isIncoming
!=
second
.
isIncoming
||
first
.
type
!==
Interaction
.
InteractionType
.
TEXT
||
second
.
type
!==
Interaction
.
InteractionType
.
TEXT
StringUtils
.
isOnlyEmoji
(
first
.
body
)
!=
StringUtils
.
isOnlyEmoji
(
second
.
body
)
||
first
.
isIncoming
!=
second
.
isIncoming
||
first
.
type
!==
Interaction
.
InteractionType
.
TEXT
||
second
.
type
!==
Interaction
.
InteractionType
.
TEXT
||
second
.
replyTo
!=
null
private
fun
isAlwaysSingleMsg
(
msg
:
Interaction
):
Boolean
=
private
fun
isAlwaysSingleMsg
(
msg
:
Interaction
):
Boolean
=
(
msg
.
type
!==
Interaction
.
InteractionType
.
TEXT
(
msg
.
type
!==
Interaction
.
InteractionType
.
TEXT
...
...
This diff is collapsed.
Click to expand it.
Pierre Nicolas
@pnicolas
mentioned in issue
#1193 (closed)
·
Mar 20, 2023
mentioned in issue
#1193 (closed)
mentioned in issue #1193
Toggle commit list
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