diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2022-03-15 16:24:47 +0100 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2022-03-18 18:35:03 +0100 |
commit | 30830e0cbad58f8efe034256bb2cf094f6f483ae (patch) | |
tree | ccc2e06d8cfbfa6928d5d880faf4df297f25d785 /src/android | |
parent | 9985cc330adb2af1b601e8a77ff5f9b485729577 (diff) | |
download | qtbase-30830e0cbad58f8efe034256bb2cf094f6f483ae.tar.gz |
Android: use empty Intent to clear clipboard data on API < 28
ClipboardManager didn't have any APIs to clear clipboard data before
API level 28.
As a workaround an empty Intent with MIMETYPE_UNKNOWN is created and
inserted into the clipboard for lower API levels.
This makes the QApplication::clipboard()->clear() method work more or
less as expected.
This allows to unblacklist tst_QPlainTextEdit::copyAvailable().
Task-number: QTBUG-87423
Task-number: QTBUG-89402
Pick-to: 6.3 6.2
Change-Id: I454376199cf3b8eed0fa2ecf2f85b87f40892280
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/android')
-rw-r--r-- | src/android/jar/src/org/qtproject/qt/android/QtNative.java | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtNative.java b/src/android/jar/src/org/qtproject/qt/android/QtNative.java index 201c40036c..eb398a7061 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtNative.java @@ -1045,9 +1045,16 @@ public class QtNative private static void clearClipData() { - if (Build.VERSION.SDK_INT >= 28 && m_clipboardManager != null) - m_clipboardManager.clearPrimaryClip(); - m_usePrimaryClip = false; + if (m_clipboardManager != null) { + if (Build.VERSION.SDK_INT >= 28) { + m_clipboardManager.clearPrimaryClip(); + } else { + String[] mimeTypes = { ClipDescription.MIMETYPE_UNKNOWN }; + ClipData data = new ClipData("", mimeTypes, new ClipData.Item(new Intent())); + m_clipboardManager.setPrimaryClip(data); + } + } + m_usePrimaryClip = false; } private static void setClipboardText(String text) { |