Skip to content

Commit

Permalink
Android: Fix clipboard issue with urls
Browse files Browse the repository at this point in the history
Both hasUrls() and hasText() can return true when containing urls, as
hasText() checks hasUrls() as well.

Pick-to: 6.4 6.2 5.15
Fixes: QTBUG-85773
Change-Id: I91a34f151e7de17ab5b9a2f24bc0b6e6c097d7f9
Reviewed-by: Assam Boudjelthia <[email protected]>
  • Loading branch information
cstatic committed Oct 20, 2022
1 parent fffea48 commit 5f9591b
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/plugins/platforms/android/androidjniclipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@ namespace QtAndroidClipboard
void setClipboardMimeData(QMimeData *data)
{
clearClipboardData();
if (data->hasText()) {
QJniObject::callStaticMethod<void>(applicationClass(),
"setClipboardText", "(Ljava/lang/String;)V",
QJniObject::fromString(data->text()).object());
}
if (data->hasHtml()) {
QJniObject::callStaticMethod<void>(applicationClass(),
"setClipboardHtml",
"(Ljava/lang/String;Ljava/lang/String;)V",
QJniObject::fromString(data->text()).object(),
QJniObject::fromString(data->html()).object());
}
if (data->hasUrls()) {
QList<QUrl> urls = data->urls();
for (const auto &u : std::as_const(urls)) {
Expand All @@ -55,6 +43,16 @@ namespace QtAndroidClipboard
"(Ljava/lang/String;)V",
QJniObject::fromString(u.toEncoded()).object());
}
} else if (data->hasText()) { // hasText || hasUrls, so the order matter here.
QJniObject::callStaticMethod<void>(applicationClass(),
"setClipboardText", "(Ljava/lang/String;)V",
QJniObject::fromString(data->text()).object());
} else if (data->hasHtml()) {
QJniObject::callStaticMethod<void>(applicationClass(),
"setClipboardHtml",
"(Ljava/lang/String;Ljava/lang/String;)V",
QJniObject::fromString(data->text()).object(),
QJniObject::fromString(data->html()).object());
}
}

Expand Down

0 comments on commit 5f9591b

Please sign in to comment.