summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android/qandroidinputcontext.h
Commit message (Collapse)AuthorAgeFilesLines
* QAndroidInputContext: Improve compatibility with virtual keyboardsVova Mshanetskiy2019-06-051-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit improves QAndroidInputContext's conformance to Android's InputConnection interface and/or consistency of it's behavior with Android's native EditText control. * Composing region is now completely independent from cursor and selection, as required by InputConnection documentation. Also, Qt will now never clear composing region (i.e. call finishComposingText()) without receiving a command to do so from the keyboard. This is important for the following reasons: - Some keyboards misbehave if we change composing region without receiving a command from them. Notably, Samsung Keyboard does (QTBUG-68822). - Due to asynchronous nature of interaction between QAndroidInputContext and the keyboard, when user drags cursor handle quickly, the keyboard may call setComposingRegion() to mark a word, which is no longer under the cursor. This was causing text corruption (QTBUG-43156, QTBUG-59958). Also SwiftKey makes such calls when user presses Enter key (QTBUG-57819). - For similar reasons selecting a word with a double-tap could cause text corruption. The keyboard may call setComposingRegion() in response to the first tap after the second tap has been processed and the word has already been already selected. This is achieved by keeping track of start and end of composing region independently from the editor. Whenever possible (i.e. when there is no selection and the cursor is inside composing region), the composing text is represented as preedit text inside editor. And whenever that is imposible, the editor is told to commit, but QAndroidInputContext keeps information about composing region internally to be able to correctly interract with the keyboard. * deleteSurroundingText() has been re-written to work correctly when there are selection and/or composing region. Some keyboards (e.g Ginger Keyboard) do call deleteSurroundingText() when there is non-empty composing region. * All operations are now performed inside a batch edit (i.e. QAndroidInputContext now calls beginBatchEdit() and endBatchEdit() on itself) to ensure that an intermediate state is never reported to the keyboard, whenever an operation requires more than one QInputMethodEvent. BatchEditLock helper class was added to call begin/endBatchEdit() in RAII style. m_blockUpdateSelection has been removed because m_batchEditNestingLevel is now used instead of it. * Selection start and end positions are now reported to the keyboard so that start <= end. Some keyboards can not handle start > end. * getTextBefore/AfterCursor() now exclude selected text from their return values. While Android docs say "text before/after cursor", what they really mean is "text before/after selection" because "the cursor and the selection are one and the same thing". Some keyboards (e.g. Gboard) were behaving incorrectly when selected text was being returned. * getExtractedText() now tries to obtain and return the whole text from the editor. This is to fix compatibility with some buggy keyboards (e.g. Samsung Keyboard, Minuum) that ignore startOffset field and assume that selectionStart and selectionEnd are absolute values. Then they issue commands with wrong indexes in some cases. Fixes: QTBUG-43156 Fixes: QTBUG-59958 Fixes: QTBUG-57819 Fixes: QTBUG-68822 Change-Id: I7e71f3bcfbb2c32248d653a4197293db03579a79 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Android: Cleanup the threading handlingBogDan Vatra2018-04-151-8/+4
| | | | | | | | Make sure all the call that are coming from Android UI thread are delegate to Qt thread. Change-Id: Ice1a25d01d107d7221b88c65b96dc1459c7f77f0 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Android: rewrite edit context menuBogDan Vatra2018-04-151-0/+8
| | | | | | | | | | | | - get rid of the old tool bar with edit controls which was also dropped by Google after they realized that is not intuitive at all. - we now introduce a nice context menu as we see in modern Android devices. This menu works on all Android devices starting with API 16. [ChangeLog][Android] Say hello to Android edit context menu Change-Id: I00d0d83fe8876335c72d7b183db4c1b53746d6b7 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Hide cursor handle after ~4s on inactivityBogDan Vatra2018-03-141-0/+2
| | | | | | | | | When the VK is hidden keep cursor handle the cursor handle visible for ~4s after user last activity. Task-number: QTBUG-66806 Change-Id: I8122c5886efaeee86bb691ad971aa7a3e3d7f8e1 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Remove text selection handles when keyboard is hiddenBogDan Vatra2018-03-141-0/+1
| | | | | | | Task-number: QTBUG-58700 Change-Id: I094f31250ec879b0f08f27499794946cac2084e6 Reviewed-by: Corey Pendleton <corey.pendleton@garmin.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Refactor cursor & selection handlesBogDan Vatra2018-03-141-8/+10
| | | | | | | | | - turn CursorHandleShowMode in a QFlag for better control - add ScopedValueChangeBack which is useful to control m_blockUpdateSelection - implement longPress word selection Change-Id: Ieed709644db991e10077d5be5d5a59f16f4fc3a8 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Android: fix (partially) text deletion when the cursor is movedBogDan Vatra2016-12-131-1/+1
| | | | | | | | | | | | | | | | - wait until the handle location changes the cursor position - don't update cursor position if: * a batchEdit is in progress * the UpdateSelection is blocked - finish the composing before update the cursor - add the missing .java files There are still corner situations when the text gets deleted/moved, but those are pretty rare and they will be fix in another patch. Task-number: QTBUG-57507 Change-Id: I230d7f64625fb556e1be3069694a71e9bc91323a Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Android: Add missing overrideAlexander Volkov2016-12-091-12/+12
| | | | | | | Change-Id: I70b802517d8f7d129ffb71dc3e92cb2458a55acc Reviewed-by: BogDan Vatra <bogdan@kdab.com> (cherry picked from commit e3ad43843a6ddb20c901b6fba85c12fb0e6c5651) Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Android: Show the edit menu when things are selectedOlivier Goffart2016-08-211-1/+3
| | | | | Change-Id: I3647fa39469c87bcc08bb439546e5e61c535c71d Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Android selection handlesOlivier Goffart2016-08-181-0/+12
| | | | | | | | | This commits implement the cursor and selection handle in the platform plugin. Task-number: QTBUG-34867 Change-Id: Icb3fd9ddfd9f4152e2004078a92a3d9502e9113c Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Updated license headersJani Heikkinen2016-01-151-13/+19
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-6/+6
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Delay showing keyboard until application is activePaul Olav Tvete2014-10-201-0/+3
| | | | | | | | | | Android starts asking lots of questions when the software keyboard pops up, so let's wait until the application is initialized. This works around a deadlock on startup. Task-number: QTBUG-41369 Change-Id: I1c79e32d08c7cc11748ec55efbff3bc25e40f4b2 Reviewed-by: Christian Stromme <christian.stromme@digia.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-18/+10
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Android: fix inputmethod race conditionsPaul Olav Tvete2014-09-101-6/+5
| | | | | | | | | | | focusObjectInputMethodQuery() and sendInputMethodEvent() were not thread safe. Remove them, and replace with thread safe versions based on the same principle as queryFocusObjectThreadSafe(). Task-number: QTBUG-40995 Change-Id: Idb6f0c6d3963b7e8e73e029e83d0367088146ca8 Reviewed-by: Christian Stromme <christian.stromme@digia.com> Reviewed-by: BogDan Vatra <bogdan@kde.org>
* Android input method fixes for SwiftKeyPaul Olav Tvete2014-04-251-0/+2
| | | | | | | | | | | | | | | | | Try to conform to the input method protocol in the way that SwiftKey expects (and the way that the stock android components actually do). * Refactor cursor position logic * fix getExtractedText() so it includes preedit text * ignore the hintMaxChars parameter to getExtractedText(), since it looks like everybody else does * fix setComposingRegion when preedit is active * track the start of the preedit and the preedit cursor position, since the Qt input method query does not give us this information Change-Id: I2ed8797abacd97ca749ca152fab2a2d5446ef603 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Android: Reset input method when focus changesPaul Olav Tvete2014-04-161-0/+2
| | | | | | | | | | | Qt Quick does not have the widgets workaround of explicitly hiding the input method on focus out. This fix copies what happens in the iOS port: Commit the current preedit and reset the IM when we see that the focus object changes. Task-number: QTBUG-38047 Change-Id: I30805265286dc650b3734e2a24807cdc8bfbcd16 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Android: implement batch editing for input methodsPaul Olav Tvete2014-03-281-0/+3
| | | | | | Task-number: QTBUG-37584 Change-Id: I59f063b2e4b6427a66f7b561cfae7193ceafa43c Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Android input method improvementsPaul Olav Tvete2014-03-181-1/+6
| | | | | | | | | | | | | | Use the new inputmethod query API. and get rid of the hack where we would move the cursor back and forwards to make sure that the Android software keyboard noticed that the cursor had moved. The android plugin now uses absolute positions instead of position within the paragraph for all cursor handling (provided that the control supports the new API). Task-number: QTBUG-37511 Change-Id: I03463dbbcb4acbfa41e2eab06889d021d50da01f Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Support multiple native surfaces on Android.BogDan Vatra2014-01-171-0/+135
Support for multiple native surfaces is needed by applications that need to mix raster windows with GL windows. Rework the raster and opengl implementation, get rid of eglfs and fbconvenience dependencies. Create a single android platform plugin. [ChangeLog][Android] Rework the raster and opengl implementation. [ChangeLog][Android] Create a single android platform plugin. Task-number: QTBUG-34650 Change-Id: I9b1ab51554823329dda8cfbf8fef27c38f917c7b Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>