Merge lp:~om26er/notes-app/remove_autopilot_workaround into lp:notes-app

Proposed by Omer Akram
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 161
Merged at revision: 165
Proposed branch: lp:~om26er/notes-app/remove_autopilot_workaround
Merge into: lp:notes-app
Diff against target: 209 lines (+102/-38)
5 files modified
KeyboardRectangle.qml (+81/-0)
NotesApp.qml (+1/-35)
tests/autopilot/notes_app/emulators/main_window.py (+3/-0)
tests/autopilot/notes_app/tests/__init__.py (+14/-0)
tests/autopilot/notes_app/tests/test_parts.py (+3/-3)
To merge this branch: bzr merge lp:~om26er/notes-app/remove_autopilot_workaround
Reviewer Review Type Date Requested Status
Olivier Tilloy Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+176788@code.launchpad.net

Commit message

added the functionality to make sure the keyboard appears before changing focus to another field.

Description of the change

added the functionality to make sure the keyboard appears before changing focus to another field.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

199 + if model() != 'Desktop':

209 + if model() != 'Desktop':

Those are not needed, as the check on model() is done already in assert_osk_eventually_shown() and assert_osk_eventually_hidden().

review: Needs Fixing
159. By Omer Akram

fix per suggestions

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Omer Akram (om26er) wrote :

> 199 + if model() != 'Desktop':
>
> 209 + if model() != 'Desktop':
>
> Those are not needed, as the check on model() is done already in
> assert_osk_eventually_shown() and assert_osk_eventually_hidden().

fixed.

Revision history for this message
Olivier Tilloy (osomon) wrote :

There is a conflict when merging in the latest trunk. Please merge and resolve.

review: Needs Fixing
160. By Omer Akram

merge trunk, fix conflicts

Revision history for this message
Omer Akram (om26er) wrote :

> There is a conflict when merging in the latest trunk. Please merge and
> resolve.

Done. Thanks

Revision history for this message
Olivier Tilloy (osomon) wrote :

129 + KeyboardRectangle {
130 + id: osk
131 }

The id is not needed, as it’s not used anywhere, so it can be safely removed.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
161. By Omer Akram

remove id for KeyboardRectangle, we don't use it

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

Looks good now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'KeyboardRectangle.qml'
2--- KeyboardRectangle.qml 1970-01-01 00:00:00 +0000
3+++ KeyboardRectangle.qml 2013-07-26 18:20:36 +0000
4@@ -0,0 +1,81 @@
5+/*
6+ * Copyright 2013 Canonical Ltd.
7+ *
8+ * This file is part of notes-app.
9+ *
10+ * webbrowser-app is free software; you can redistribute it and/or modify
11+ * it under the terms of the GNU General Public License as published by
12+ * the Free Software Foundation; version 3.
13+ *
14+ * webbrowser-app is distributed in the hope that it will be useful,
15+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+ * GNU General Public License for more details.
18+ *
19+ * You should have received a copy of the GNU General Public License
20+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
21+ */
22+
23+// This file was originally part of the telephony application.
24+// It is a workaround required to handle interaction with the OSK,
25+// until the shell/WM takes care of that on behalf of the applications.
26+
27+import QtQuick 2.0
28+import Ubuntu.Components 0.1
29+
30+Item {
31+ id: keyboardRect
32+ anchors.left: parent.left
33+ anchors.right: parent.right
34+ anchors.bottom: parent.bottom
35+ height: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0
36+
37+ Behavior on height {
38+ UbuntuNumberAnimation {}
39+ }
40+
41+ states: [
42+ State {
43+ name: "hidden"
44+ when: keyboardRect.height == 0
45+ },
46+ State {
47+ name: "shown"
48+ when: keyboardRect.height == Qt.inputMethod.keyboardRectangle.height
49+ }
50+ ]
51+
52+ function recursiveFindFocusedItem(parent) {
53+ if (parent.activeFocus) {
54+ return parent;
55+ }
56+
57+ for (var i in parent.children) {
58+ var child = parent.children[i];
59+ if (child.activeFocus) {
60+ return child;
61+ }
62+
63+ var item = recursiveFindFocusedItem(child);
64+
65+ if (item != null) {
66+ return item;
67+ }
68+ }
69+
70+ return null;
71+ }
72+
73+ Connections {
74+ target: Qt.inputMethod
75+
76+ onVisibleChanged: {
77+ if (!Qt.inputMethod.visible) {
78+ var focusedItem = recursiveFindFocusedItem(keyboardRect.parent);
79+ if (focusedItem != null) {
80+ focusedItem.focus = false;
81+ }
82+ }
83+ }
84+ }
85+}
86
87=== modified file 'NotesApp.qml'
88--- NotesApp.qml 2013-07-24 14:52:07 +0000
89+++ NotesApp.qml 2013-07-26 18:20:36 +0000
90@@ -118,40 +118,6 @@
91 noteList.setActiveIndex(0);
92 }
93
94- // Workaround for https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1201400.
95- // Inspired by the KeyboardRectangle component, originally written for the
96- // telephony application.
97- Connections {
98- target: Qt.inputMethod
99-
100- onVisibleChanged: {
101- if (!Qt.inputMethod.visible) {
102- var focusedItem = recursiveFindFocusedItem(window);
103- if (focusedItem != null) {
104- focusedItem.focus = false;
105- }
106- }
107- }
108-
109- function recursiveFindFocusedItem(parent) {
110- if (parent.activeFocus) {
111- return parent;
112- }
113-
114- for (var i in parent.children) {
115- var child = parent.children[i];
116- if (child.activeFocus) {
117- return child;
118- }
119-
120- var item = recursiveFindFocusedItem(child);
121-
122- if (item != null) {
123- return item;
124- }
125- }
126-
127- return null;
128- }
129+ KeyboardRectangle {
130 }
131 }
132
133=== modified file 'tests/autopilot/notes_app/emulators/main_window.py'
134--- tests/autopilot/notes_app/emulators/main_window.py 2013-04-08 11:22:07 +0000
135+++ tests/autopilot/notes_app/emulators/main_window.py 2013-07-26 18:20:36 +0000
136@@ -27,3 +27,6 @@
137 edit = note_item.select_single("MixedEdit")
138 parts = edit.select_single("QQuickColumn").get_children_by_type("QQuickLoader")
139 return parts
140+
141+ def get_keyboard_rectangle(self):
142+ return self.app.select_single("KeyboardRectangle")
143
144=== modified file 'tests/autopilot/notes_app/tests/__init__.py'
145--- tests/autopilot/notes_app/tests/__init__.py 2013-07-23 12:04:26 +0000
146+++ tests/autopilot/notes_app/tests/__init__.py 2013-07-26 18:20:36 +0000
147@@ -14,8 +14,10 @@
148 import base64
149
150 from autopilot.input import Mouse, Touch, Pointer
151+from autopilot.matchers import Eventually
152 from autopilot.platform import model
153 from autopilot.testcase import AutopilotTestCase
154+from testtools.matchers import Equals
155
156 from notes_app.emulators.main_window import MainWindow
157 import imagedata
158@@ -77,6 +79,18 @@
159 # the process during regular test setup.
160 self.doCleanups()
161
162+ def assert_osk_eventually_shown(self):
163+ if model() != 'Desktop':
164+ keyboardRectangle = self.main_window.get_keyboard_rectangle()
165+ self.assertThat(keyboardRectangle.state,
166+ Eventually(Equals("shown")))
167+
168+ def assert_osk_eventually_hidden(self):
169+ if model() != 'Desktop':
170+ keyboardRectangle = self.main_window.get_keyboard_rectangle()
171+ self.assertThat(keyboardRectangle.state,
172+ Eventually(Equals("hidden")))
173+
174 @property
175 def main_window(self):
176 return MainWindow(self.app)
177
178=== modified file 'tests/autopilot/notes_app/tests/test_parts.py'
179--- tests/autopilot/notes_app/tests/test_parts.py 2013-07-23 12:21:36 +0000
180+++ tests/autopilot/notes_app/tests/test_parts.py 2013-07-26 18:20:36 +0000
181@@ -16,7 +16,6 @@
182 from notes_app.tests import NotesTestCaseBaseWithHTTPServer, DatabaseMixin
183
184 import sqlite3
185-from time import sleep
186
187
188 class TestFocus(NotesTestCaseBaseWithHTTPServer, DatabaseMixin):
189@@ -80,17 +79,18 @@
190 part_x, part_y, part_w, part_h = image.globalRect
191 self.pointing_device.move(part_x + part_w / 2, part_y + 1)
192 self.pointing_device.click()
193+ self.assert_osk_eventually_shown()
194 self.assertThat(text.activeFocus, Eventually(Equals(True)))
195
196 # Clicking on the lower half of the image should create a new text area below
197 # the image and focus it
198 self.pointing_device.move(part_x + part_w / 2, part_y + part_h - 1)
199 self.pointing_device.click()
200+ self.assert_osk_eventually_hidden()
201 # On the phone input focus is lost when the OSK appears so
202 # we click the input box to gain focus again. LP: #1204084
203 if model() != 'Desktop':
204- sleep(1)
205- self.pointing_device.click()
206+ self.pointing_device.click()
207 self.assertThat(text.activeFocus, Eventually(Equals(False)))
208
209 parts = self.main_window.get_note_parts(note)

Subscribers

People subscribed via source and target branches