Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Thomas
Fedilab
Commits
b18a1c97
Commit
b18a1c97
authored
Jun 08, 2020
by
Thomas
Browse files
Fix an issue with links
parent
255ee607
Pipeline
#310849
passed with stage
in 8 minutes and 31 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
app/src/main/java/app/fedilab/android/client/Entities/Status.java
View file @
b18a1c97
...
...
@@ -66,6 +66,7 @@ import java.util.ArrayList;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
...
...
@@ -420,7 +421,7 @@ public class Status implements Parcelable {
Matcher
matcher
;
Pattern
linkPattern
=
Pattern
.
compile
(
"<a((?!href).)*href=\"([^\"]*)\"[^>]*(((?!</a).)*)</a>"
);
matcher
=
linkPattern
.
matcher
(
spannableString
);
HashMap
<
String
,
String
>
targetedURL
=
new
HashMap
<>();
Linked
HashMap
<
String
,
String
>
targetedURL
=
new
Linked
HashMap
<>();
HashMap
<
String
,
Account
>
accountsMentionUnknown
=
new
HashMap
<>();
String
liveInstance
=
Helper
.
getLiveInstance
(
context
);
int
i
=
1
;
...
...
@@ -553,9 +554,9 @@ public class Status implements Parcelable {
}
if
(
accountsMentionUnknown
.
size
()
>
0
)
{
Iterator
it
=
accountsMentionUnknown
.
entrySet
().
iterator
();
Iterator
<
Map
.
Entry
<
String
,
Account
>>
it
=
accountsMentionUnknown
.
entrySet
().
iterator
();
while
(
it
.
hasNext
())
{
Map
.
Entry
pair
=
(
Map
.
Entry
)
it
.
next
();
Map
.
Entry
<
String
,
Account
>
pair
=
(
Map
.
Entry
<
String
,
Account
>
)
it
.
next
();
String
key
=
(
String
)
pair
.
getKey
();
Account
account
=
(
Account
)
pair
.
getValue
();
String
targetedAccount
=
"@"
+
account
.
getAcct
();
...
...
@@ -603,19 +604,17 @@ public class Status implements Parcelable {
}
}
if
(
targetedURL
.
size
()
>
0
)
{
Iterator
it
=
targetedURL
.
entrySet
().
iterator
();
Iterator
<
Map
.
Entry
<
String
,
String
>>
it
=
targetedURL
.
entrySet
().
iterator
();
int
endPosition
=
0
;
while
(
it
.
hasNext
())
{
Map
.
Entry
pair
=
(
Map
.
Entry
)
it
.
next
();
Map
.
Entry
<
String
,
String
>
pair
=
(
Map
.
Entry
<
String
,
String
>
)
it
.
next
();
String
key
=
((
String
)
pair
.
getKey
()).
split
(
"\\|"
)[
0
];
String
url
=
(
String
)
pair
.
getValue
();
if
(
spannableStringT
.
toString
().
toLowerCase
().
contains
(
key
.
toLowerCase
()))
{
//Accounts can be mentioned several times so we have to loop
int
startPosition
=
spannableStringT
.
toString
().
toLowerCase
().
indexOf
(
key
.
toLowerCase
(),
endPosition
);
if
(
startPosition
<
0
)
{
startPosition
=
0
;
}
if
(
startPosition
>
0
)
{
endPosition
=
startPosition
+
key
.
length
();
if
(
key
.
contains
(
"…"
)
&&
!
key
.
endsWith
(
"…"
))
{
key
=
key
.
split
(
"…"
)[
0
]
+
"…"
;
...
...
@@ -780,6 +779,8 @@ public class Status implements Parcelable {
Spanned
.
SPAN_INCLUSIVE_EXCLUSIVE
);
}
}
}
it
.
remove
();
}
}
...
...
Write
Preview
Supports
Markdown
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