Merge lp:~michael-sheldon/ubuntu-keyboard/fix-language-button into lp:ubuntu-keyboard
- fix-language-button
- Merge into trunk
Status: | Superseded | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Proposed branch: | lp:~michael-sheldon/ubuntu-keyboard/fix-language-button | ||||||||||||
Merge into: | lp:ubuntu-keyboard | ||||||||||||
Diff against target: |
536 lines (+215/-28) 12 files modified
data/schemas/com.canonical.keyboard.maliit.gschema.xml (+5/-0) qml/Keyboard.qml (+6/-5) qml/KeyboardContainer.qml (+1/-2) qml/keys/LanguageKey.qml (+29/-8) qml/keys/LanguageMenu.qml (+28/-7) src/plugin/inputmethod.cpp (+30/-0) src/plugin/inputmethod.h (+5/-0) src/plugin/inputmethod_p.h (+11/-0) src/plugin/keyboardsettings.cpp (+20/-0) src/plugin/keyboardsettings.h (+3/-0) tests/autopilot/ubuntu_keyboard/emulators/keypad.py (+1/-0) tests/autopilot/ubuntu_keyboard/tests/test_keyboard.py (+76/-6) |
||||||||||||
To merge this branch: | bzr merge lp:~michael-sheldon/ubuntu-keyboard/fix-language-button | ||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Bill Filler (community) | Needs Fixing | ||
Review via email: mp+248948@code.launchpad.net |
This proposal has been superseded by a proposal from 2015-02-24.
Commit message
Always display the language button, even when only one language is enabled (so settings is easily accessible) and modify language button behaviour to toggle between most recently used layouts when tapped and to only show the menu when long pressed.
Description of the change
Always display the language button, even when only one language is enabled (so settings is easily accessible) and modify language button behaviour to toggle between most recently used layouts when tapped and to only show the menu when long pressed.
Michael Sheldon (michael-sheldon) wrote : | # |
- 300. By Michael Sheldon
-
Maintain track of previous language when automatically switching back from Emoji layout on field change
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:300
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Bill Filler (bfiller) wrote : | # |
Couple of things
1) I think we are not clearing the previous-language setting when a keyboard layout is disabled from the system settings. For example, I had English and Spanish enabled and used the key to toggle between them. Then went to the settings and disabled Spanish. The lang key still toggled between them even though Spanish had been disabled. Probably in the case of only where there is only one language we should display the menu when pressing the key.
2) Not sure about having the ... long press hint on the globe key. Looks a bit cluttered even though we have it there for consistency. I think it might be better to remove it.
3) In the menu, could we change the text for "Settings" to "Settings..." and/or change the font style to visually differentiate Settings from the language names? Maybe a thicker separator after the last language name could help. And no separator after Settings entry.
4) If not difficult it would also help to have a check mark (or some visual indication) of the currently selected language in the menu when it is displayed.
- 301. By Michael Sheldon
-
Remove annotation on language key
- 302. By Michael Sheldon
-
Clear previous language if it's been removed from enabled languages
- 303. By Michael Sheldon
-
Show currently active language in menu and fix menu width
- 304. By Michael Sheldon
-
Adjust settings menu height dynamically
- 305. By Michael Sheldon
-
Clean up settings menu item and separate it slightly from other items
- 306. By Michael Sheldon
-
Set previous language when active language updated
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:306
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 307. By Michael Sheldon
-
Fix autopilot tests
- 308. By Michael Sheldon
-
Fix flaky autopilot test
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:308
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Bill Filler (bfiller) wrote : | # |
Code looks good and all working well. But seems autopilot test is failing still in CI (see previous run http://
Please take a look, could be a flaky test or timing related, or perhaps it's a problem with CI.
- 309. By Michael Sheldon
-
Move input area out of the way of notifications in autopilot tests
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:309
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Michael Sheldon (michael-sheldon) wrote : | # |
Looks like this was merged at an earlier revision than the final one, meaning one of the text fixes never made it in, so we may want to remerge this.
Unmerged revisions
Preview Diff
1 | === modified file 'data/schemas/com.canonical.keyboard.maliit.gschema.xml' |
2 | --- data/schemas/com.canonical.keyboard.maliit.gschema.xml 2015-01-14 12:07:03 +0000 |
3 | +++ data/schemas/com.canonical.keyboard.maliit.gschema.xml 2015-02-10 13:49:43 +0000 |
4 | @@ -6,6 +6,11 @@ |
5 | <description>Currently active language, selected by user in the keyboard language menu</description> |
6 | <default>'en'</default> |
7 | </key> |
8 | + <key name="previous-language" type="s"> |
9 | + <summary>Previous language</summary> |
10 | + <description>Language which was in use immediately prior to the current active language</description> |
11 | + <default>''</default> |
12 | + </key> |
13 | <key name="enabled-languages" type="as"> |
14 | <summary>Enabled languages</summary> |
15 | <description>User-defined list of activatable languages.</description> |
16 | |
17 | === modified file 'qml/Keyboard.qml' |
18 | --- qml/Keyboard.qml 2015-01-15 13:24:57 +0000 |
19 | +++ qml/Keyboard.qml 2015-02-10 13:49:43 +0000 |
20 | @@ -191,11 +191,12 @@ |
21 | |
22 | LanguageMenu { |
23 | id: languageMenu |
24 | + objectName: "languageMenu" |
25 | anchors.centerIn: parent |
26 | - width: 400; |
27 | - height: keypad.height; |
28 | + height: contentHeight > keypad.height ? keypad.height : contentHeight |
29 | + width: units.gu(30); |
30 | enabled: canvas.languageMenuShown |
31 | - opacity: canvas.languageMenuShown ? 1.0 : 0.0 |
32 | + visible: canvas.languageMenuShown |
33 | } |
34 | } // keyboardComp |
35 | } |
36 | @@ -261,9 +262,9 @@ |
37 | } |
38 | onKeyboardReset: { |
39 | keypad.state = "CHARACTERS" |
40 | - if (keypad.switchBack && keypad.previousLanguage && !keypad.justChangedLanguage) { |
41 | + if (keypad.switchBack && maliit_input_method.previousLanguage && !keypad.justChangedLanguage) { |
42 | keypad.switchBack = false; |
43 | - maliit_input_method.activeLanguage = keypad.previousLanguage; |
44 | + maliit_input_method.activeLanguage = maliit_input_method.previousLanguage; |
45 | } |
46 | keypad.justChangedLanguage = false; |
47 | } |
48 | |
49 | === modified file 'qml/KeyboardContainer.qml' |
50 | --- qml/KeyboardContainer.qml 2015-01-15 13:24:57 +0000 |
51 | +++ qml/KeyboardContainer.qml 2015-02-10 13:49:43 +0000 |
52 | @@ -33,8 +33,7 @@ |
53 | |
54 | property string activeKeypadState: "NORMAL" |
55 | property alias popoverEnabled: extendedKeysSelector.enabled |
56 | - property string previousLanguage |
57 | - property bool switchBack: false // Switch back to the previous layout without showing the language menu |
58 | + property bool switchBack: false // Switch back to the previous layout when changing fields |
59 | property bool justChangedLanguage: true // Don't switch back languages during language switch process |
60 | |
61 | state: "CHARACTERS" |
62 | |
63 | === modified file 'qml/keys/LanguageKey.qml' |
64 | --- qml/keys/LanguageKey.qml 2015-01-12 13:30:44 +0000 |
65 | +++ qml/keys/LanguageKey.qml 2015-02-10 13:49:43 +0000 |
66 | @@ -21,25 +21,46 @@ |
67 | iconShifted: "language-chooser"; |
68 | iconCapsLock: "language-chooser"; |
69 | |
70 | + property bool held: false; |
71 | + |
72 | padding: 0 |
73 | |
74 | - visible: maliit_input_method.enabledLanguages.length > 1 ? true : false |
75 | - width: visible ? panel.keyWidth : 0 |
76 | + width: panel.keyWidth |
77 | overridePressArea: true |
78 | |
79 | + action: "language" |
80 | + |
81 | onPressed: { |
82 | if (maliit_input_method.useAudioFeedback) |
83 | audioFeedback.play(); |
84 | |
85 | if (maliit_input_method.useHapticFeedback) |
86 | pressEffect.start(); |
87 | - |
88 | - if (panel.switchBack && panel.previousLanguage) { |
89 | - panel.switchBack = false; |
90 | - maliit_input_method.activeLanguage = panel.previousLanguage |
91 | + |
92 | + held = false; |
93 | + } |
94 | + |
95 | + onReleased: { |
96 | + panel.switchBack = false; |
97 | + if (held) { |
98 | + return; |
99 | + } |
100 | + |
101 | + if (maliit_input_method.previousLanguage && maliit_input_method.previousLanguage != maliit_input_method.activeLanguage) { |
102 | + maliit_input_method.activeLanguage = maliit_input_method.previousLanguage |
103 | } else { |
104 | - panel.previousLanguage = maliit_input_method.activeLanguage |
105 | canvas.languageMenuShown = true |
106 | } |
107 | - } |
108 | + } |
109 | + |
110 | + onPressAndHold: { |
111 | + if (maliit_input_method.useAudioFeedback) |
112 | + audioFeedback.play(); |
113 | + |
114 | + if (maliit_input_method.useHapticFeedback) |
115 | + pressEffect.start(); |
116 | + |
117 | + canvas.languageMenuShown = true |
118 | + held = true; |
119 | + } |
120 | } |
121 | |
122 | === modified file 'qml/keys/LanguageMenu.qml' |
123 | --- qml/keys/LanguageMenu.qml 2014-12-05 00:49:11 +0000 |
124 | +++ qml/keys/LanguageMenu.qml 2015-02-10 13:49:43 +0000 |
125 | @@ -22,6 +22,8 @@ |
126 | |
127 | Item { |
128 | |
129 | + property double contentHeight: menuList.contentHeight + units.gu(UI.languageMenuListViewPadding); |
130 | + |
131 | MouseArea { |
132 | width: fullScreenItem.width |
133 | height: fullScreenItem.height |
134 | @@ -49,6 +51,17 @@ |
135 | |
136 | delegate: ListItem.Standard { |
137 | text: languageIdToName(modelData) |
138 | + showDivider: modelData != maliit_input_method.enabledLanguages[maliit_input_method.enabledLanguages.length - 1] |
139 | + control: CheckBox { |
140 | + checked: maliit_input_method.activeLanguage == modelData |
141 | + onVisibleChanged: { |
142 | + checked = maliit_input_method.activeLanguage == modelData |
143 | + } |
144 | + onClicked: { |
145 | + maliit_input_method.activeLanguage = modelData |
146 | + canvas.languageMenuShown = false; |
147 | + } |
148 | + } |
149 | onClicked: { |
150 | maliit_input_method.activeLanguage = modelData |
151 | canvas.languageMenuShown = false; |
152 | @@ -56,17 +69,25 @@ |
153 | } |
154 | |
155 | Component { |
156 | - id: settingsItem |
157 | + id: settingsComp |
158 | + Column { |
159 | + width: parent.width |
160 | + height: settingsItem.height + settingsDiv.height * 2 |
161 | + ListItem.ThinDivider { id: settingsDiv } |
162 | + ListItem.ThinDivider { } |
163 | ListItem.Standard { |
164 | - text: i18n.tr("Settings") |
165 | - onClicked: { |
166 | - Qt.openUrlExternally("settings:///system/language") |
167 | - canvas.languageMenuShown = false; |
168 | - maliit_input_method.hide(); |
169 | + id: settingsItem |
170 | + text: i18n.tr("Settings") + "…" |
171 | + showDivider: false |
172 | + onClicked: { |
173 | + Qt.openUrlExternally("settings:///system/language") |
174 | + canvas.languageMenuShown = false; |
175 | + maliit_input_method.hide(); |
176 | + } |
177 | } |
178 | } |
179 | } |
180 | - footer: greeter_status.greeterActive ? null : settingsItem |
181 | + footer: greeter_status.greeterActive ? null : settingsComp |
182 | } |
183 | |
184 | function languageIdToName(languageId) |
185 | |
186 | === modified file 'src/plugin/inputmethod.cpp' |
187 | --- src/plugin/inputmethod.cpp 2015-02-02 18:18:07 +0000 |
188 | +++ src/plugin/inputmethod.cpp 2015-02-10 13:49:43 +0000 |
189 | @@ -114,6 +114,7 @@ |
190 | d->registerAutoCapsSetting(); |
191 | d->registerWordEngineSetting(); |
192 | d->registerActiveLanguage(); |
193 | + d->registerPreviousLanguage(); |
194 | d->registerEnabledLanguages(); |
195 | d->registerDoubleSpaceFullStop(); |
196 | d->registerStayHidden(); |
197 | @@ -283,6 +284,9 @@ |
198 | { |
199 | Q_D(InputMethod); |
200 | d->enabledLanguages = d->m_settings.enabledLanguages(); |
201 | + if (!d->enabledLanguages.contains(d->previousLanguage)) { |
202 | + setPreviousLanguage(""); |
203 | + } |
204 | Q_EMIT enabledLanguagesChanged(d->enabledLanguages); |
205 | } |
206 | |
207 | @@ -482,6 +486,14 @@ |
208 | return d->activeLanguage; |
209 | } |
210 | |
211 | +//! \brief InputMethod::previousLanguage returns the language that was used |
212 | +//! immediately prior to the current activeLanguage |
213 | +const QString &InputMethod::previousLanguage() const |
214 | +{ |
215 | + Q_D(const InputMethod); |
216 | + return d->previousLanguage; |
217 | +} |
218 | + |
219 | //! \brief InputMethod::useAudioFeedback is true, when keys should play a audio |
220 | //! feedback when pressed |
221 | //! \return |
222 | @@ -531,6 +543,7 @@ |
223 | if (d->activeLanguage == newLanguage) |
224 | return; |
225 | |
226 | + setPreviousLanguage(d->activeLanguage); |
227 | d->activeLanguage = newLanguage; |
228 | d->host->setLanguage(newLanguage); |
229 | d->m_settings.setActiveLanguage(newLanguage); |
230 | @@ -539,6 +552,23 @@ |
231 | Q_EMIT activeLanguageChanged(d->activeLanguage); |
232 | } |
233 | |
234 | +//! \brief InputMethod::setPreviousLanguage |
235 | +//! Set the language used immediately prior to the current active language. |
236 | +//! \param prevLanguage id the previous language used. e.g. "en" or "emoji" |
237 | +void InputMethod::setPreviousLanguage(const QString &prevLanguage) |
238 | +{ |
239 | + Q_D(InputMethod); |
240 | + |
241 | + if (d->previousLanguage == prevLanguage) |
242 | + return; |
243 | + |
244 | + d->previousLanguage = prevLanguage; |
245 | + d->m_settings.setPreviousLanguage(prevLanguage); |
246 | + |
247 | + Q_EMIT previousLanguageChanged(d->previousLanguage); |
248 | +} |
249 | + |
250 | + |
251 | void InputMethod::onWordEnginePluginChanged() |
252 | { |
253 | reset(); |
254 | |
255 | === modified file 'src/plugin/inputmethod.h' |
256 | --- src/plugin/inputmethod.h 2014-11-26 15:02:05 +0000 |
257 | +++ src/plugin/inputmethod.h 2015-02-10 13:49:43 +0000 |
258 | @@ -51,6 +51,7 @@ |
259 | Q_PROPERTY(TextContentType contentType READ contentType WRITE setContentType NOTIFY contentTypeChanged) |
260 | Q_PROPERTY(QStringList enabledLanguages READ enabledLanguages NOTIFY enabledLanguagesChanged) |
261 | Q_PROPERTY(QString activeLanguage READ activeLanguage WRITE setActiveLanguage NOTIFY activeLanguageChanged) |
262 | + Q_PROPERTY(QString previousLanguage READ previousLanguage WRITE setPreviousLanguage NOTIFY previousLanguageChanged) |
263 | Q_PROPERTY(bool useAudioFeedback READ useAudioFeedback NOTIFY useAudioFeedbackChanged) |
264 | Q_PROPERTY(QString audioFeedbackSound READ audioFeedbackSound NOTIFY audioFeedbackSoundChanged) |
265 | Q_PROPERTY(QObject* actionKeyOverride READ actionKeyOverride NOTIFY actionKeyOverrideChanged) |
266 | @@ -108,6 +109,9 @@ |
267 | const QString &activeLanguage() const; |
268 | Q_SLOT void setActiveLanguage(const QString& newLanguage); |
269 | |
270 | + const QString &previousLanguage() const; |
271 | + Q_SLOT void setPreviousLanguage(const QString& prevLanguage); |
272 | + |
273 | Q_SLOT void onVisibleRectChanged(); |
274 | |
275 | bool useAudioFeedback() const; |
276 | @@ -129,6 +133,7 @@ |
277 | void deactivateAutocaps(); |
278 | void enabledLanguagesChanged(QStringList languages); |
279 | void activeLanguageChanged(QString language); |
280 | + void previousLanguageChanged(QString language); |
281 | void useAudioFeedbackChanged(); |
282 | void audioFeedbackSoundChanged(QString sound); |
283 | void useHapticFeedbackChanged(); |
284 | |
285 | === modified file 'src/plugin/inputmethod_p.h' |
286 | --- src/plugin/inputmethod_p.h 2015-01-14 12:07:03 +0000 |
287 | +++ src/plugin/inputmethod_p.h 2015-02-10 13:49:43 +0000 |
288 | @@ -55,6 +55,7 @@ |
289 | bool wordEngineEnabled; |
290 | InputMethod::TextContentType contentType; |
291 | QString activeLanguage; |
292 | + QString previousLanguage; |
293 | QStringList enabledLanguages; |
294 | Qt::ScreenOrientation appsCurrentOrientation; |
295 | QString keyboardState; |
296 | @@ -80,6 +81,7 @@ |
297 | , wordEngineEnabled(false) |
298 | , contentType(InputMethod::FreeTextContentType) |
299 | , activeLanguage("en") |
300 | + , previousLanguage("") |
301 | , enabledLanguages(activeLanguage) |
302 | , appsCurrentOrientation(qGuiApp->primaryScreen()->orientation()) |
303 | , keyboardState("CHARACTERS") |
304 | @@ -238,6 +240,15 @@ |
305 | q->setActiveLanguage(activeLanguage); |
306 | } |
307 | |
308 | + void registerPreviousLanguage() |
309 | + { |
310 | + QObject::connect(&m_settings, SIGNAL(previousLanguageChanged(QString)), |
311 | + q, SLOT(setPreviousLanguage(QString))); |
312 | + |
313 | + previousLanguage = m_settings.previousLanguage(); |
314 | + q->setPreviousLanguage(previousLanguage); |
315 | + } |
316 | + |
317 | void registerEnabledLanguages() |
318 | { |
319 | QObject::connect(&m_settings, SIGNAL(enabledLanguagesChanged(QStringList)), |
320 | |
321 | === modified file 'src/plugin/keyboardsettings.cpp' |
322 | --- src/plugin/keyboardsettings.cpp 2015-01-14 12:07:03 +0000 |
323 | +++ src/plugin/keyboardsettings.cpp 2015-02-10 13:49:43 +0000 |
324 | @@ -35,6 +35,7 @@ |
325 | using namespace MaliitKeyboard; |
326 | |
327 | const QLatin1String ACTIVE_LANGUAGE_KEY = QLatin1String("activeLanguage"); |
328 | +const QLatin1String PREVIOUS_LANGUAGE_KEY = QLatin1String("previousLanguage"); |
329 | const QLatin1String ENABLED_LANGUAGES_KEY = QLatin1String("enabledLanguages"); |
330 | const QLatin1String AUTO_CAPITALIZATION_KEY = QLatin1String("autoCapitalization"); |
331 | const QLatin1String AUTO_COMPLETION_KEY = QLatin1String("autoCompletion"); |
332 | @@ -76,6 +77,22 @@ |
333 | } |
334 | |
335 | /*! |
336 | + * \brief KeyboardSettings::previousLanguage returns the language that was |
337 | + * active immediately before the current one. |
338 | + * \return previously language |
339 | + */ |
340 | + |
341 | +QString KeyboardSettings::previousLanguage() const |
342 | +{ |
343 | + return m_settings->get(PREVIOUS_LANGUAGE_KEY).toString(); |
344 | +} |
345 | + |
346 | +void KeyboardSettings::setPreviousLanguage(const QString& id) |
347 | +{ |
348 | + m_settings->set(PREVIOUS_LANGUAGE_KEY, QVariant(id)); |
349 | +} |
350 | + |
351 | +/*! |
352 | * \brief KeyboardSettings::enabledLanguages returns a list of languages that are |
353 | * active |
354 | * \return |
355 | @@ -182,6 +199,9 @@ |
356 | if (key == ACTIVE_LANGUAGE_KEY) { |
357 | Q_EMIT activeLanguageChanged(activeLanguage()); |
358 | return; |
359 | + } else if (key == PREVIOUS_LANGUAGE_KEY) { |
360 | + Q_EMIT previousLanguageChanged(previousLanguage()); |
361 | + return; |
362 | } else if (key == ENABLED_LANGUAGES_KEY) { |
363 | Q_EMIT enabledLanguagesChanged(enabledLanguages()); |
364 | return; |
365 | |
366 | === modified file 'src/plugin/keyboardsettings.h' |
367 | --- src/plugin/keyboardsettings.h 2015-01-14 12:07:03 +0000 |
368 | +++ src/plugin/keyboardsettings.h 2015-02-10 13:49:43 +0000 |
369 | @@ -45,6 +45,8 @@ |
370 | |
371 | QString activeLanguage() const; |
372 | void setActiveLanguage(const QString& id); |
373 | + QString previousLanguage() const; |
374 | + void setPreviousLanguage(const QString& id); |
375 | QStringList enabledLanguages() const; |
376 | bool autoCapitalization() const; |
377 | bool autoCompletion() const; |
378 | @@ -58,6 +60,7 @@ |
379 | |
380 | Q_SIGNALS: |
381 | void activeLanguageChanged(QString); |
382 | + void previousLanguageChanged(QString); |
383 | void enabledLanguagesChanged(QStringList); |
384 | void autoCapitalizationChanged(bool); |
385 | void autoCompletionChanged(bool); |
386 | |
387 | === modified file 'tests/autopilot/ubuntu_keyboard/emulators/keypad.py' |
388 | --- tests/autopilot/ubuntu_keyboard/emulators/keypad.py 2014-11-18 12:39:54 +0000 |
389 | +++ tests/autopilot/ubuntu_keyboard/emulators/keypad.py 2015-02-10 13:49:43 +0000 |
390 | @@ -55,5 +55,6 @@ |
391 | _iter_keys("CharKey", lambda x: x.label) |
392 | _iter_keys("ActionKey", lambda x: x.action) |
393 | _iter_keys("ShiftKey", lambda x: x.action) |
394 | + _iter_keys("LanguageKey", lambda x: x.action) |
395 | |
396 | return (contained_keys, key_positions) |
397 | |
398 | === modified file 'tests/autopilot/ubuntu_keyboard/tests/test_keyboard.py' |
399 | --- tests/autopilot/ubuntu_keyboard/tests/test_keyboard.py 2015-02-02 18:17:42 +0000 |
400 | +++ tests/autopilot/ubuntu_keyboard/tests/test_keyboard.py 2015-02-10 13:49:43 +0000 |
401 | @@ -61,12 +61,14 @@ |
402 | self.skipTest("Ubuntu Keyboard tests only run on device.") |
403 | super(UbuntuKeyboardTests, self).setUp() |
404 | self.set_test_settings() |
405 | + sleep(1) # Have to give time for gsettings change to propogate |
406 | self.pointer = Pointer(Touch.create()) |
407 | |
408 | def set_test_settings(self): |
409 | gsettings = Gio.Settings.new("com.canonical.keyboard.maliit") |
410 | + gsettings.set_strv("enabled-languages", ["en", "es", "de", "zh", "emoji"]) |
411 | gsettings.set_string("active-language", "en") |
412 | - gsettings.set_strv("enabled-languages", ["en", "es", "de", "zh", "emoji"]) |
413 | + gsettings.set_string("previous-language", "es") |
414 | gsettings.set_boolean("auto-capitalization", True) |
415 | gsettings.set_boolean("auto-completion", True) |
416 | gsettings.set_boolean("predictive-text", True) |
417 | @@ -158,11 +160,7 @@ |
418 | TextField { |
419 | id: input; |
420 | objectName: "input" |
421 | - anchors { |
422 | - top: inputLabel.bottom |
423 | - horizontalCenter: parent.horizontalCenter |
424 | - topMargin: 10 |
425 | - } |
426 | + anchors.centerIn: parent |
427 | inputMethodHints: %(input_method)s |
428 | } |
429 | } |
430 | @@ -377,6 +375,7 @@ |
431 | TextField { |
432 | id: input; |
433 | objectName: "input" |
434 | + anchors.centerIn: parent |
435 | property int visibilityChangeCount: 0 |
436 | } |
437 | |
438 | @@ -746,6 +745,8 @@ |
439 | |
440 | def set_test_settings(self): |
441 | gsettings = Gio.Settings.new("com.canonical.keyboard.maliit") |
442 | + gsettings.set_strv("enabled-languages", ["en", "emoji"]) |
443 | + gsettings.set_string("previous-language", "emoji") |
444 | gsettings.set_string("active-language", "emoji") |
445 | gsettings.set_boolean("auto-capitalization", True) |
446 | gsettings.set_boolean("auto-completion", True) |
447 | @@ -759,6 +760,12 @@ |
448 | keyboard = Keyboard() |
449 | self.addCleanup(keyboard.dismiss) |
450 | |
451 | + keyboard.press_key("language") |
452 | + |
453 | + sleep(1) |
454 | + |
455 | + keyboard = Keyboard() |
456 | + |
457 | keyboard.type('😁😆😃😏') |
458 | |
459 | expected = "😁😆😃😏" |
460 | @@ -777,6 +784,12 @@ |
461 | keyboard = Keyboard() |
462 | self.addCleanup(keyboard.dismiss) |
463 | |
464 | + keyboard.press_key("language") |
465 | + |
466 | + sleep(1) |
467 | + |
468 | + keyboard = Keyboard() |
469 | + |
470 | keyboard.type('😁😆😃😏\b') |
471 | |
472 | expected = "😁😆😃" |
473 | @@ -786,6 +799,63 @@ |
474 | ) |
475 | |
476 | |
477 | +class UbuntuKeyboardLanguageMenu(UbuntuKeyboardTests): |
478 | + |
479 | + def test_tapping(self): |
480 | + """Tapping the language menu key should switch to the previously |
481 | + used language. |
482 | + |
483 | + """ |
484 | + |
485 | + text_area = self.launch_test_input_area() |
486 | + self.ensure_focus_on_input(text_area) |
487 | + keyboard = Keyboard() |
488 | + self.addCleanup(keyboard.dismiss) |
489 | + |
490 | + gsettings = Gio.Settings.new("com.canonical.keyboard.maliit") |
491 | + self.assertThat( |
492 | + gsettings.get_string("active-language"), |
493 | + Equals('en') |
494 | + ) |
495 | + |
496 | + keyboard.press_key("language") |
497 | + |
498 | + sleep(5) |
499 | + |
500 | + self.assertThat( |
501 | + gsettings.get_string("active-language"), |
502 | + Equals('es') |
503 | + ) |
504 | + |
505 | + def test_long_press(self): |
506 | + """Holding down the language menu key should switch display the |
507 | + language switcher menu. |
508 | + |
509 | + """ |
510 | + |
511 | + text_area = self.launch_test_input_area() |
512 | + self.ensure_focus_on_input(text_area) |
513 | + keyboard = Keyboard() |
514 | + self.addCleanup(keyboard.dismiss) |
515 | + |
516 | + gsettings = Gio.Settings.new("com.canonical.keyboard.maliit") |
517 | + self.assertThat( |
518 | + gsettings.get_string("active-language"), |
519 | + Equals('en') |
520 | + ) |
521 | + |
522 | + keyboard.press_key("language", long_press=True) |
523 | + |
524 | + menu = keyboard.maliit.select_single("LanguageMenu") |
525 | + |
526 | + self.assertThat( |
527 | + menu.visible, |
528 | + Eventually(Equals(True)) |
529 | + ) |
530 | + |
531 | + keyboard.press_key("language") |
532 | + |
533 | + |
534 | def maliit_cleanup(): |
535 | presagedir = os.path.expanduser("~/.presage") |
536 | if os.path.exists(presagedir + ".bak") and os.path.exists(presagedir): |
Are there any related MPs required for this MP to build/function as expected? Please list.
* No
Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
* Yes
Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?
* Yes
Did you successfully run all tests found in your component's Test Plan (https:/ /wiki.ubuntu. com/Process/ Merges/ TestPlan/ ubuntu- keyboard) on device or emulator?
* Yes
If you changed the UI, was the change specified/approved by design?
* Changed language button behaviour to match existing design spec
If you changed UI labels, did you update the pot file?
* No change
If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?
* No change