|
1 /* |
|
2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0"" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 #include "AknFepHashKeyManager.h" |
|
30 #include "AknFepManager.h" |
|
31 #include "AknFepCaseManager.h" |
|
32 #include "AknFepUiIndicInputManager.h" |
|
33 |
|
34 #include <aknedsts.h> |
|
35 #include <uikon.hrh> |
|
36 #include <coedef.h> |
|
37 |
|
38 #include <PtiEngine.h> |
|
39 |
|
40 //move to class definition |
|
41 #define EHashKeyTimeout 700000 // 0.7s |
|
42 |
|
43 CAknFepHashKeyManager* CAknFepHashKeyManager::NewL(CAknFepManager& aFepMan, |
|
44 CAknFepCaseManager* aCaseMan) |
|
45 { |
|
46 CAknFepHashKeyManager* self = new(ELeave) CAknFepHashKeyManager(aFepMan, aCaseMan); |
|
47 CleanupStack::PushL(self); |
|
48 self->ConstructL(); |
|
49 CleanupStack::Pop(); |
|
50 return self; |
|
51 } |
|
52 |
|
53 CAknFepHashKeyManager::~CAknFepHashKeyManager() |
|
54 { |
|
55 delete iHashKeyTimer; |
|
56 } |
|
57 |
|
58 TKeyResponse CAknFepHashKeyManager::HandleKeyEventL(TKeyPressLength aLength) |
|
59 { |
|
60 TKeyResponse response = EKeyWasNotConsumed; |
|
61 |
|
62 switch (iHashKeyStyle) |
|
63 { |
|
64 case EHashKeyStyleWestern: |
|
65 response = HandleKeyWesternL(aLength); |
|
66 break; |
|
67 case EHashKeyStyleChineseWithWestern: |
|
68 response = HandleKeyWesternWithChineseL(aLength); |
|
69 break; |
|
70 case EHashKeyStyleJapanese: |
|
71 response = HandleKeyJapaneseL(aLength); |
|
72 break; |
|
73 case EHashKeyStyleKoreanWithWestern: |
|
74 response = HandleKeyWesternWithKoreanL(aLength); |
|
75 break; |
|
76 default: |
|
77 break; |
|
78 } |
|
79 return response; |
|
80 } |
|
81 |
|
82 void CAknFepHashKeyManager::SetMode(TInt aMode, TBool aWesternPredictive) |
|
83 { |
|
84 iMode = aMode; |
|
85 iWesternPredictive = aWesternPredictive; |
|
86 } |
|
87 |
|
88 void CAknFepHashKeyManager::SetHashKeyStyle(THashKeyStyle aHashKeyStyle) |
|
89 { |
|
90 iHashKeyStyle = aHashKeyStyle; |
|
91 } |
|
92 |
|
93 void CAknFepHashKeyManager::CancelHashKeyTimer() |
|
94 { |
|
95 if (iHashKeyTimer->IsActive()) |
|
96 { |
|
97 iHashKeyTimer->Cancel(); |
|
98 } |
|
99 } |
|
100 |
|
101 CAknFepHashKeyManager::CAknFepHashKeyManager(CAknFepManager& aFepMan, CAknFepCaseManager* aCaseMan) |
|
102 :iHashKeyStyle(EHashKeyStyleWestern), |
|
103 iFepMan(aFepMan), |
|
104 iCaseMan(aCaseMan) |
|
105 { |
|
106 iLanguageChangedOrChangeFromNumberMode = EFalse; |
|
107 iIndicSelectionLoopIndex = -1; // Cannot use 'iFepMan.WesternPredictive(ELatin);' since FepMan is not completely constructed at the construction of this |
|
108 } |
|
109 |
|
110 void CAknFepHashKeyManager::ConstructL() |
|
111 { |
|
112 iHashKeyTimer = CPeriodic::NewL(CActive::EPriorityStandard); |
|
113 } |
|
114 |
|
115 TInt CAknFepHashKeyManager::HashKeyTimerTimeoutCallback(TAny* aObj) |
|
116 { |
|
117 STATIC_CAST(CAknFepHashKeyManager*, aObj)->HashKeyTimerTimeout(); |
|
118 return KErrNone; |
|
119 } |
|
120 |
|
121 void CAknFepHashKeyManager::HashKeyTimerTimeout() |
|
122 { |
|
123 iHashKeyTimer->Cancel(); |
|
124 } |
|
125 |
|
126 void CAknFepHashKeyManager::RevertPredictiveTextSettingChangeL() |
|
127 { |
|
128 if ( !iFepMan.InputLanguageSupportsCaseChanges() && iFepMan.EditorState()&& |
|
129 !( iFepMan.EditorState()->Flags() & EAknEditorFlagNoT9) ) |
|
130 { |
|
131 // Reverts predictive text settings change made with short key press. |
|
132 iFepMan.SetWesternPredictive( !iFepMan.WesternPredictive(ELatin) ); |
|
133 iFepMan.TryChangeModeL(ELatin); |
|
134 } |
|
135 } |
|
136 |
|
137 TKeyResponse CAknFepHashKeyManager::HandleKeyWesternL(TKeyPressLength aLength) |
|
138 { |
|
139 TKeyResponse response = EKeyWasNotConsumed; |
|
140 TBool phoneIdle = (iFepMan.EditorType() == CAknExtendedInputCapabilities::EPhoneNumberEditor); |
|
141 // Don't handle hash key unless it comes from virtual keyboard. |
|
142 if( phoneIdle && !iFepMan.PluginInputMode() ) |
|
143 { |
|
144 return response; |
|
145 } |
|
146 iLastModeNumber = (iMode == ENumber || iMode == ENativeNumber); |
|
147 |
|
148 if ( (iMode == ENumber || iMode == ENativeNumber) && !iFepMan.HashKeySelectionInUse()) |
|
149 { |
|
150 if (aLength == ELongKeyPress) |
|
151 { |
|
152 // Clear the EExtendedFlagShortPressHashKey, only for non numeric only editors |
|
153 // so as to indicate we are in a long press of hash key event. |
|
154 // In case of numeric only editor, we should re-simulate hash and let application |
|
155 // handle it. |
|
156 |
|
157 if ( !iFepMan.IsOnlyNumericPermitted() ) |
|
158 { |
|
159 iFepMan.ClearExtendedFlag(CAknFepManager::EExtendedFlagShortPressHashKey); |
|
160 |
|
161 // Long press of hash key switches to alpha mode |
|
162 // if it is permitted mode in the editor. |
|
163 iFepMan.TryChangeToModeBeforeL(); |
|
164 ResetIndicHashKeyStateL(); |
|
165 } |
|
166 response = EKeyWasConsumed; |
|
167 } |
|
168 else if (!iFepMan.IsExtendedFlagSet(CAknFepManager::EExtendedFlagShortPressHashKey)) |
|
169 { |
|
170 // Set the flag to indicate its a short press of key event |
|
171 iFepMan.SetExtendedFlag(CAknFepManager::EExtendedFlagShortPressHashKey); |
|
172 response = EKeyWasConsumed; |
|
173 } |
|
174 else |
|
175 { |
|
176 // We are not suppose to be here. Just a fail safe check to guard us against |
|
177 // erroneous situations. |
|
178 |
|
179 iFepMan.ClearExtendedFlag(CAknFepManager::EExtendedFlagShortPressHashKey); |
|
180 } |
|
181 } |
|
182 else |
|
183 { |
|
184 if ( aLength == EShortKeyPress ) |
|
185 { |
|
186 if (iFepMan.HashKeySelectionInUse()) |
|
187 { |
|
188 // New style hash key loop when long hash-key press is used for text selection. |
|
189 #ifndef RD_INTELLIGENT_TEXT_INPUT |
|
190 // To rip off suggested word completion when user wants to |
|
191 // switch to number or multitap mode |
|
192 if(iFepMan.IsAutoCompleteOn()) |
|
193 { |
|
194 iFepMan.RemoveSuggestedCompletionL(); |
|
195 } |
|
196 #endif //RD_INTELLIGENT_TEXT_INPUT |
|
197 return HandleKeyWesternSelectionStyleL(aLength); |
|
198 } |
|
199 |
|
200 if ( iLastModeNumber ) |
|
201 { |
|
202 // The key should not be consumed in number mode? FEP Manager may |
|
203 // put special chars into the editor or the key event |
|
204 // is passed to the editor. |
|
205 |
|
206 // But now the event is consumed. Same happens also in |
|
207 // Chinese languages because # key is reserved for |
|
208 // other purpose. |
|
209 response = EKeyWasConsumed; |
|
210 } |
|
211 |
|
212 if(IsIndicHashKeyStyleRequired()) |
|
213 { |
|
214 return (SetIndicStateL()); |
|
215 } |
|
216 // Traditional hash key loop |
|
217 if ( iFepMan.InputLanguageSupportsCaseChanges() ) |
|
218 { |
|
219 if (iHashKeyTimer->IsActive()) |
|
220 { |
|
221 iHashKeyTimer->Cancel(); |
|
222 iCaseMan->RevertCaseChange(); |
|
223 // Toggle predictive setting. |
|
224 #ifndef RD_INTELLIGENT_TEXT_INPUT |
|
225 // To rip off suggested word completion when user wants to |
|
226 // switch to number or multitap mode |
|
227 if(iFepMan.IsAutoCompleteOn()) |
|
228 { |
|
229 iFepMan.RemoveSuggestedCompletionL(); |
|
230 } |
|
231 |
|
232 #endif //RD_INTELLIGENT_TEXT_INPUT |
|
233 iFepMan.SetCcpuFlag(CAknFepManager::ECcpuStataCommitPredictiveWord); |
|
234 iFepMan.SetWesternPredictive( !iFepMan.WesternPredictive(ELatin) ); |
|
235 iFepMan.TryChangeModeL(ELatin); |
|
236 } |
|
237 else |
|
238 { |
|
239 iCaseMan->ManualCaseUpdate(); |
|
240 iHashKeyTimer->Start(EHashKeyTimeout, EHashKeyTimeout, |
|
241 TCallBack(HashKeyTimerTimeoutCallback, this)); |
|
242 } |
|
243 } |
|
244 else // Case changes are not allowed. |
|
245 { |
|
246 if (iHashKeyTimer->IsActive()) |
|
247 { |
|
248 iHashKeyTimer->Cancel(); |
|
249 // Double press of hash key does not have functionality. |
|
250 } |
|
251 else |
|
252 { |
|
253 // Toggle predictive setting. |
|
254 #ifndef RD_INTELLIGENT_TEXT_INPUT |
|
255 // AutoComplete - Fix - Begin |
|
256 if(iFepMan.IsAutoCompleteOn()) |
|
257 { |
|
258 iFepMan.RemoveSuggestedCompletionL(); |
|
259 } |
|
260 // AutoComplete - Fix - End |
|
261 |
|
262 #endif //RD_INTELLIGENT_TEXT_INPUT |
|
263 iFepMan.SetWesternPredictive( !iFepMan.WesternPredictive(ELatin) ); |
|
264 iFepMan.TryChangeModeL(ELatin); |
|
265 iHashKeyTimer->Start(EHashKeyTimeout, EHashKeyTimeout, |
|
266 TCallBack(HashKeyTimerTimeoutCallback, this)); |
|
267 } |
|
268 } |
|
269 response = EKeyWasConsumed; |
|
270 } |
|
271 else // Long key press of hash key |
|
272 { |
|
273 // Clear EExtendedFlagShortPressHashKey flag as soon as long press happens |
|
274 iFepMan.ClearExtendedFlag(CAknFepManager::EExtendedFlagShortPressHashKey); |
|
275 |
|
276 // Toggle number mode / alpha mode |
|
277 if (iLastModeNumber && !IsIndicHashKeyStyleRequired() && |
|
278 !iFepMan.HashKeySelectionInUse()) // For Indic it is handled in SetIndicPreviousStateL() |
|
279 { |
|
280 // If short hash key press event is passed to the editor, it |
|
281 // needs to be removed here from the editor. |
|
282 |
|
283 iFepMan.TryChangeToModeBeforeL(); |
|
284 } |
|
285 else |
|
286 { |
|
287 // Input mode is incremented. |
|
288 if (!iFepMan.HashKeySelectionInUse()) |
|
289 { |
|
290 #ifndef RD_INTELLIGENT_TEXT_INPUT |
|
291 // To rip off suggested word completion when user wants to switch to number mode |
|
292 if(iFepMan.IsAutoCompleteOn()) |
|
293 { |
|
294 iFepMan.RemoveSuggestedCompletionL(); |
|
295 } |
|
296 |
|
297 #endif //RD_INTELLIGENT_TEXT_INPUT |
|
298 if(IsIndicHashKeyStyleRequired()) |
|
299 { |
|
300 SetIndicPreviousStateL(); |
|
301 } |
|
302 else |
|
303 { |
|
304 RevertPredictiveTextSettingChangeL(); |
|
305 } |
|
306 if( iFepMan.IsSupportNativeNumber()) |
|
307 { |
|
308 iFepMan.TryChangeModeL( ENativeNumber ); |
|
309 } |
|
310 else |
|
311 { |
|
312 iFepMan.TryChangeModeL( ENumber ); |
|
313 } |
|
314 } |
|
315 else if (!iFepMan.IsCcpuFlagSet(CAknFepManager::ECcpuStateEdwinInSelectionMode) && |
|
316 iFepMan.OkToActivateSelectionMode()) |
|
317 { |
|
318 // User wants to select and not to change mode, so cancel the mode change |
|
319 // caused by initial hash key press. |
|
320 if(iLastModeNumber && !IsIndicHashKeyStyleRequired()) |
|
321 { |
|
322 iFepMan.TryChangeToModeBeforeL(); |
|
323 } |
|
324 else |
|
325 { |
|
326 SetPreviousSelectionStyleModeL(); |
|
327 } |
|
328 iFepMan.SetCcpuFlag(CAknFepManager::ECcpuStateHashDown | |
|
329 CAknFepManager::ECcpuStateEdwinInSelectionMode | |
|
330 CAknFepManager::ECcpuStateHashKeyDeleteDone ); |
|
331 TKeyEvent ccpuStart = {EKeyF21, EStdKeyF21, 0, 0}; |
|
332 // to enable copy/paste support on cba. We simulate via CCoeEnv |
|
333 // to avoid fep SimulateKeyEventL adding shift modifiers |
|
334 CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, EEventKey); |
|
335 } |
|
336 } |
|
337 response = EKeyWasConsumed; |
|
338 } |
|
339 } |
|
340 return response; |
|
341 } |
|
342 |
|
343 |
|
344 TKeyResponse CAknFepHashKeyManager::HandleKeyWesternWithChineseL(TKeyPressLength aLength) |
|
345 { |
|
346 TKeyResponse response = EKeyWasNotConsumed; |
|
347 if ( iFepMan.IsOnlyNumericPermitted() ) |
|
348 { |
|
349 if ( aLength == ELongKeyPress ) |
|
350 { |
|
351 response = EKeyWasConsumed; |
|
352 if ( iFepMan.HashKeySelectionInUse() ) |
|
353 { |
|
354 TText prevCh = iFepMan.PreviousChar(); |
|
355 if (prevCh == '#') |
|
356 { |
|
357 iFepMan.RemovePreviousCharacterL(); |
|
358 } |
|
359 } |
|
360 |
|
361 iFepMan.SetCcpuFlag( CAknFepManager::ECcpuStateHashDown | |
|
362 CAknFepManager::ECcpuStateEdwinInSelectionMode ); |
|
363 TKeyEvent ccpuStart = { EKeyF21, EStdKeyF21, 0, 0 }; |
|
364 // to enable copy/paste support on cba. We simulate via CCoeEnv |
|
365 // to avoid fep SimulateKeyEventL adding shift modifiers |
|
366 CCoeEnv::Static()->SimulateKeyEventL( ccpuStart, EEventKey ); |
|
367 } |
|
368 //else let the FEP Man put special chars into the editor |
|
369 } |
|
370 else |
|
371 { |
|
372 if (aLength == EShortKeyPress) |
|
373 { |
|
374 if (iMode == ENumber || iMode == ENativeNumber) |
|
375 { |
|
376 iLastModeNumber = ETrue; |
|
377 } |
|
378 else |
|
379 { |
|
380 iLastModeNumber = EFalse; |
|
381 } |
|
382 CAknEdwinState* editorState = iFepMan.EditorState(); |
|
383 TInt permittedCases = editorState->PermittedCases(); |
|
384 permittedCases = permittedCases == 0 ? |
|
385 EAknEditorLowerCase | EAknEditorUpperCase : permittedCases; |
|
386 if ( iMode == ELatin && (permittedCases & EAknEditorTextCase)) |
|
387 { |
|
388 // Latin case update is changed back to automatic if latin |
|
389 // text case is allowed and the case is changed manually from #-key. |
|
390 iFepMan.ClearFlag(CAknFepManager::EFlagSupressAutoUpdate); |
|
391 } |
|
392 TInt currentCase = iCaseMan->CurrentCase(); |
|
393 |
|
394 // Is current latin case last available case. |
|
395 TBool lastCase = ( ( !(permittedCases & EAknEditorTextCase) && |
|
396 (( currentCase == EAknEditorLowerCase) || |
|
397 ( currentCase == EAknEditorUpperCase && |
|
398 !(permittedCases & EAknEditorLowerCase)) ) || |
|
399 ( editorState->Flags() & EAknEditorFlagFixedCase) ) || |
|
400 ( editorState->Flags() & EAknEditorFlagForceTransparentFepModes) ); |
|
401 |
|
402 if (iMode == ELatin && |
|
403 !iFepMan.IsFlagSet(CAknFepManager::EFlagChangeInputMode) && |
|
404 !lastCase ) |
|
405 { |
|
406 // Input mode is still Latin. Only case is updated. |
|
407 if (permittedCases & EAknEditorTextCase) |
|
408 { |
|
409 iCaseMan->ManualCaseUpdate(); |
|
410 } |
|
411 else |
|
412 { |
|
413 iCaseMan->SetCurrentCase(EAknEditorLowerCase); |
|
414 } |
|
415 |
|
416 // Next time input mode is changed if any text is not entered before. |
|
417 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
418 } |
|
419 else |
|
420 { |
|
421 // Input mode is incremented. |
|
422 iFepMan.TryIncrementModeL(iMode); |
|
423 |
|
424 iFepMan.ClearFlag(CAknFepManager::EFlagChangeInputMode); |
|
425 |
|
426 if (iMode == ELatin) // New mode after Increment. |
|
427 { |
|
428 if (editorState->Flags() & EAknEditorFlagFixedCase) |
|
429 { |
|
430 // Only one fixed case is available. Use it. |
|
431 iCaseMan->ConfigureCaseStateFromEditorState(); |
|
432 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
433 } |
|
434 else if (editorState->Flags() & EAknEditorFlagForceTransparentFepModes) |
|
435 { |
|
436 // Only lower case is used with find pane. |
|
437 iCaseMan->SetCurrentCase(EAknEditorLowerCase); |
|
438 iFepMan.SetFlag(CAknFepManager::EFlagSupressAutoUpdate); |
|
439 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
440 } |
|
441 else if (permittedCases & EAknEditorTextCase) |
|
442 { |
|
443 iCaseMan->SetCurrentCase(EAknEditorTextCase); |
|
444 iCaseMan->UpdateCase(ENullNaviEvent); |
|
445 } |
|
446 else |
|
447 { |
|
448 if (permittedCases & EAknEditorUpperCase) |
|
449 { |
|
450 iCaseMan->SetCurrentCase(EAknEditorUpperCase); |
|
451 if ( !(permittedCases & EAknEditorLowerCase)) |
|
452 { |
|
453 // We need to move to next input mode since only upper case |
|
454 // is permitted in Latin input mode. |
|
455 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
456 } |
|
457 } |
|
458 else |
|
459 { |
|
460 iCaseMan->SetCurrentCase(EAknEditorLowerCase); |
|
461 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
462 } |
|
463 } |
|
464 } |
|
465 } |
|
466 } |
|
467 else // Long keypress |
|
468 { |
|
469 if (!iFepMan.HashKeySelectionInUse()) |
|
470 { |
|
471 if (iLastModeNumber) |
|
472 { |
|
473 iFepMan.TryChangeToModeBeforeL(); |
|
474 } |
|
475 else |
|
476 { |
|
477 if( iFepMan.IsSupportNativeNumber()) |
|
478 { |
|
479 iFepMan.TryChangeModeL( ENativeNumber ); |
|
480 } |
|
481 else |
|
482 { |
|
483 iFepMan.TryChangeModeL(ENumber); |
|
484 } |
|
485 } |
|
486 } |
|
487 else if (!iFepMan.IsCcpuFlagSet(CAknFepManager::ECcpuStateEdwinInSelectionMode) && |
|
488 iFepMan.OkToActivateSelectionMode()) |
|
489 { |
|
490 // User wants to select and not to change mode, so cancel the mode change |
|
491 // caused by initial hash key press. |
|
492 MPtiLanguage* lang = iFepMan.PtiEngine()->CurrentLanguage(); |
|
493 TInt inputLang = ELangTest; |
|
494 if (lang) |
|
495 { |
|
496 inputLang = lang->LanguageCode(); |
|
497 } |
|
498 const TInt inputMode = iFepMan.InputMode(); |
|
499 |
|
500 if ((inputLang == ELangPrcChinese && inputMode == EPinyin) || |
|
501 (inputLang == ELangTaiwanChinese && inputMode == EZhuyin) || |
|
502 (inputLang == ELangHongKongChinese && inputMode == EStroke)) |
|
503 { |
|
504 // Hash key selection was initiated from number mode, |
|
505 // return there. |
|
506 iFepMan.TryChangeModeL(ENumber); |
|
507 } |
|
508 else |
|
509 { |
|
510 iFepMan.TryChangeToModeBeforeL(); |
|
511 } |
|
512 |
|
513 iFepMan.SetCcpuFlag(CAknFepManager::ECcpuStateHashDown | |
|
514 CAknFepManager::ECcpuStateEdwinInSelectionMode ); |
|
515 TKeyEvent ccpuStart = {EKeyF21, EStdKeyF21, 0, 0}; |
|
516 // to enable copy/paste support on cba. We simulate via CCoeEnv |
|
517 // to avoid fep SimulateKeyEventL adding shift modifiers |
|
518 CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, EEventKey); |
|
519 } |
|
520 } |
|
521 response = EKeyWasConsumed; |
|
522 } |
|
523 return response; |
|
524 } |
|
525 |
|
526 |
|
527 TKeyResponse CAknFepHashKeyManager::HandleKeyJapaneseL(TKeyPressLength aLength) |
|
528 { |
|
529 TKeyResponse response = EKeyWasNotConsumed; |
|
530 if (aLength == ELongKeyPress) |
|
531 { |
|
532 response = HandleLongKeypressJapaneseL(); |
|
533 } |
|
534 else |
|
535 { |
|
536 response = HandleSortKeypressJapaneseL(); |
|
537 } |
|
538 return response; |
|
539 } |
|
540 |
|
541 TKeyResponse CAknFepHashKeyManager::HandleLongKeypressJapaneseL() |
|
542 { |
|
543 TKeyResponse response = EKeyWasConsumed; |
|
544 |
|
545 if (iFepMan.IsOnlyNumericPermitted()) |
|
546 { |
|
547 if (iFepMan.HashKeySelectionInUse()) |
|
548 { |
|
549 TText prevCh = iFepMan.PreviousChar(); |
|
550 if (prevCh == '#') |
|
551 { |
|
552 iFepMan.RemovePreviousCharacterL(); |
|
553 } |
|
554 } |
|
555 } |
|
556 |
|
557 if (iMode == EHiraganaKanji || iMode == ELatin) |
|
558 { |
|
559 // predictive input is turned on/off |
|
560 // Commit string on transitory input |
|
561 iFepMan.TryCloseUiL(); |
|
562 |
|
563 if(iWesternPredictive) |
|
564 { |
|
565 iFepMan.TryChangePredictiveInputModeL(EFalse); |
|
566 } |
|
567 else |
|
568 { |
|
569 iFepMan.TryChangePredictiveInputModeL(ETrue); |
|
570 } |
|
571 iFepMan.SetCcpuFlag(CAknFepManager::ECcpuStateChangeToPredictionMode); |
|
572 } |
|
573 else if (iMode == EHiragana) |
|
574 { |
|
575 // nothing to do |
|
576 } |
|
577 else |
|
578 { |
|
579 // Input mode is incremented. |
|
580 iFepMan.TryIncrementModeL(iMode); |
|
581 if ( iMode == ELatin ) |
|
582 { |
|
583 if (iCaseMan->IsAbleChangeCase()) |
|
584 { |
|
585 CAknEdwinState* editorState = iFepMan.EditorState(); |
|
586 TInt permittedCases = editorState->PermittedCases(); |
|
587 if (permittedCases & EAknEditorTextCase) |
|
588 { |
|
589 iCaseMan->SetCurrentCase(EAknEditorTextCase); |
|
590 iCaseMan->UpdateCase(ENullNaviEvent); |
|
591 } |
|
592 else |
|
593 { |
|
594 if ( iFepMan.CaseBefore() ) |
|
595 { |
|
596 iCaseMan->SetCurrentCase(iFepMan.CaseBefore()); |
|
597 } |
|
598 else if (permittedCases & EAknEditorUpperCase) |
|
599 { |
|
600 iCaseMan->SetCurrentCase(EAknEditorUpperCase); |
|
601 if ( !(permittedCases & EAknEditorLowerCase)) |
|
602 { |
|
603 // We need to move to next input mode since only upper case |
|
604 // is permitted in Latin input mode. |
|
605 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
606 } |
|
607 } |
|
608 else |
|
609 { |
|
610 iCaseMan->SetCurrentCase(EAknEditorLowerCase); |
|
611 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
612 } |
|
613 } |
|
614 } |
|
615 } |
|
616 iFepMan.SetCcpuFlag(CAknFepManager::ECcpuStateChangeToPredictionMode); |
|
617 } |
|
618 |
|
619 if (iFepMan.HashKeySelectionInUse() |
|
620 && !iFepMan.IsCcpuFlagSet(CAknFepManager::ECcpuStateEdwinInSelectionMode) |
|
621 && iFepMan.OkToActivateSelectionMode()) |
|
622 { |
|
623 // User wants to select and not to change mode, so cancel the mode change |
|
624 // caused by initial hash key press. |
|
625 SetPreviousSelectionStyleModeL(); |
|
626 |
|
627 iFepMan.SetCcpuFlag(CAknFepManager::ECcpuStateHashDown | |
|
628 CAknFepManager::ECcpuStateEdwinInSelectionMode ); |
|
629 TKeyEvent ccpuStart = {EKeyF21, EStdKeyF21, 0, 0}; |
|
630 // to enable copy/paste support on cba. We simulate via CCoeEnv |
|
631 // to avoid fep SimulateKeyEventL adding shift modifiers |
|
632 CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, EEventKey); |
|
633 } |
|
634 |
|
635 return response; |
|
636 } |
|
637 |
|
638 TKeyResponse CAknFepHashKeyManager::HandleSortKeypressJapaneseL() |
|
639 { |
|
640 TKeyResponse response = EKeyWasConsumed; |
|
641 if (iFepMan.IsOnlyNumericPermitted()) |
|
642 { |
|
643 response = EKeyWasNotConsumed; |
|
644 } |
|
645 else if (iMode == EHiragana) |
|
646 { |
|
647 response = EKeyWasConsumed; |
|
648 } |
|
649 else if (iFepMan.HashKeySelectionInUse() |
|
650 && iPreviousSelection) |
|
651 { |
|
652 // User wants to select and not to change mode, so not change to input mode |
|
653 response = EKeyWasConsumed; |
|
654 iPreviousSelection = EFalse; |
|
655 } |
|
656 else |
|
657 { |
|
658 CancelHashKeyTimer(); |
|
659 if ( iMode == ELatin && iCaseMan->IsAbleChangeCase()) |
|
660 { |
|
661 // Input mode is incremented. |
|
662 iFepMan.TryIncrementModeL(iMode); |
|
663 if (iFepMan.IsQwerty()) |
|
664 { |
|
665 if ( iMode == ELatin ) |
|
666 { |
|
667 iFepMan.TryIncrementModeL(ENumber); |
|
668 } |
|
669 } |
|
670 } |
|
671 else if ( iMode == ELatin && !iCaseMan->IsAbleChangeCase() && iFepMan.IsQwerty()) |
|
672 { |
|
673 // In Qwerty input and not be able to change case mode, |
|
674 // Number mode must be skipped. |
|
675 iFepMan.TryIncrementModeL(ENumber); |
|
676 } |
|
677 else |
|
678 { |
|
679 // Input mode is incremented. |
|
680 iFepMan.TryIncrementModeL(iMode); |
|
681 if ( iMode == ELatin ) |
|
682 { |
|
683 if (iCaseMan->IsAbleChangeCase()) |
|
684 { |
|
685 CAknEdwinState* editorState = iFepMan.EditorState(); |
|
686 TInt permittedCases = editorState->PermittedCases(); |
|
687 if (permittedCases & EAknEditorTextCase) |
|
688 { |
|
689 iCaseMan->SetCurrentCase(EAknEditorTextCase); |
|
690 iCaseMan->UpdateCase(ENullNaviEvent); |
|
691 } |
|
692 else |
|
693 { |
|
694 if ( iFepMan.CaseBefore() ) |
|
695 { |
|
696 iCaseMan->SetCurrentCase(iFepMan.CaseBefore()); |
|
697 } |
|
698 else if (permittedCases & EAknEditorUpperCase) |
|
699 { |
|
700 iCaseMan->SetCurrentCase(EAknEditorUpperCase); |
|
701 if ( !(permittedCases & EAknEditorLowerCase)) |
|
702 { |
|
703 // We need to move to next input mode since only upper case |
|
704 // is permitted in Latin input mode. |
|
705 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
706 } |
|
707 } |
|
708 else |
|
709 { |
|
710 iCaseMan->SetCurrentCase(EAknEditorLowerCase); |
|
711 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
712 } |
|
713 } |
|
714 } |
|
715 } |
|
716 } |
|
717 } |
|
718 |
|
719 return response; |
|
720 } |
|
721 |
|
722 |
|
723 enum |
|
724 { |
|
725 EHashPredictionBit = 0x01, |
|
726 EHashTextCaseBit = 0x02, |
|
727 EHashUpperCaseBit = 0x04, |
|
728 EHashLowerCaseBit = 0x08, |
|
729 EHashNumberModeBit = 0x10, |
|
730 }; |
|
731 |
|
732 enum |
|
733 { |
|
734 EHashLatinLowerMode = EHashLowerCaseBit, |
|
735 EHashLatinUpperMode = EHashUpperCaseBit, |
|
736 EHashLatinTextMode = EHashTextCaseBit, |
|
737 EHashPredLowerMode = EHashLowerCaseBit | EHashPredictionBit, |
|
738 EHashPredUpperMode = EHashUpperCaseBit | EHashPredictionBit, |
|
739 EHashPredTextMode = EHashTextCaseBit | EHashPredictionBit |
|
740 }; |
|
741 |
|
742 enum |
|
743 { |
|
744 EHashIndicMultitapMode, |
|
745 EHashIndicPredictiveMode, |
|
746 #ifdef RD_HINDI_PHONETIC_INPUT |
|
747 EHashIndicPhoneticLowerMode, |
|
748 EHashIndicPhoneticUpperMode, |
|
749 #endif |
|
750 EHashIndicLatinTextMode, |
|
751 EHashIndicLatinLowerMode, |
|
752 EHashIndicLatinUpperMode, |
|
753 EHashNumberMode |
|
754 |
|
755 }; |
|
756 // Here we enumerate possible mode sequences for selection style has key loop. |
|
757 // Number mode is handled as a special case. This only consumes 24 bytes. |
|
758 const TInt KNumModesInLoop = 4; |
|
759 const TUint8 allHashKeyLoops[] = |
|
760 { |
|
761 EHashLatinLowerMode, EHashLatinUpperMode, EHashPredLowerMode, EHashPredUpperMode, |
|
762 EHashLatinUpperMode, EHashLatinLowerMode, EHashPredUpperMode, EHashPredLowerMode, |
|
763 EHashLatinTextMode, EHashLatinLowerMode, EHashPredTextMode, EHashPredLowerMode, |
|
764 EHashPredLowerMode, EHashPredUpperMode, EHashLatinLowerMode, EHashLatinUpperMode, |
|
765 EHashPredUpperMode, EHashPredLowerMode, EHashLatinUpperMode, EHashLatinLowerMode, |
|
766 EHashPredTextMode, EHashPredLowerMode, EHashLatinTextMode, EHashLatinLowerMode |
|
767 }; |
|
768 |
|
769 |
|
770 TKeyResponse CAknFepHashKeyManager::HandleKeyWesternSelectionStyleL(TKeyPressLength aLength) |
|
771 { |
|
772 TKeyResponse response = EKeyWasNotConsumed; |
|
773 |
|
774 if (aLength == EShortKeyPress) |
|
775 { |
|
776 if (iFepMan.IsOnlyNumericPermitted()) |
|
777 { |
|
778 if (!iFepMan.IsExtendedFlagSet(CAknFepManager::EExtendedFlagShortPressHashKey)) |
|
779 { |
|
780 // Set the flag to indicate its a short press of key event |
|
781 iFepMan.SetExtendedFlag(CAknFepManager::EExtendedFlagShortPressHashKey); |
|
782 response = EKeyWasConsumed; |
|
783 } |
|
784 else |
|
785 { |
|
786 iFepMan.ClearExtendedFlag(CAknFepManager::EExtendedFlagShortPressHashKey); |
|
787 } |
|
788 return response; |
|
789 } |
|
790 |
|
791 if(IsIndicHashKeyStyleRequired()) |
|
792 { |
|
793 return (SetIndicStateL()); |
|
794 } |
|
795 |
|
796 if (!iSelectionLoop) |
|
797 { |
|
798 TInt index = 0; |
|
799 if (iFepMan.WesternPredictive(ELatin)) |
|
800 { |
|
801 index += (3 * KNumModesInLoop); |
|
802 } |
|
803 |
|
804 switch (iCaseMan->CurrentCase()) |
|
805 { |
|
806 case EAknEditorUpperCase: |
|
807 index += KNumModesInLoop; |
|
808 break; |
|
809 case EAknEditorTextCase: |
|
810 index += (2 * KNumModesInLoop); |
|
811 break; |
|
812 default: |
|
813 break; |
|
814 } |
|
815 |
|
816 iSelectionLoop = &allHashKeyLoops[index]; |
|
817 |
|
818 if (iMode == ENumber || iMode == ENativeNumber) |
|
819 { |
|
820 iSelectionLoopIndex = -1; |
|
821 } |
|
822 } |
|
823 |
|
824 if (!iFepMan.InputLanguageSupportsCaseChanges()) |
|
825 { |
|
826 // Jumping by 2 always ignores case change. |
|
827 iSelectionLoopIndex += 2; |
|
828 } |
|
829 else |
|
830 { |
|
831 iSelectionLoopIndex++; |
|
832 } |
|
833 |
|
834 if (iSelectionLoopIndex >= 0 && (iSelectionLoop[iSelectionLoopIndex] & EHashPredictionBit) != 0) |
|
835 { |
|
836 MPtiLanguage* curLang = iFepMan.PtiEngine()->CurrentLanguage(); |
|
837 if(!iFepMan.InputLanguageSupportsCaseChanges()) |
|
838 { |
|
839 MCoeFepAwareTextEditor* edit = iFepMan.FepAwareTextEditor(); |
|
840 if(edit && edit->DocumentLengthForFep() > 0) |
|
841 { |
|
842 edit->GetCursorSelectionForFep(iPreviousIndicCursorPosition); |
|
843 } |
|
844 |
|
845 } |
|
846 if ((curLang && curLang->HasInputMode(EPtiEnginePredictive) == EFalse) || |
|
847 (iFepMan.EditorState()->Flags() & EAknEditorFlagNoT9)) |
|
848 { |
|
849 // If next one would be prediction, but prediction is not allowed, |
|
850 // skip modes. |
|
851 iSelectionLoopIndex += 2; |
|
852 } |
|
853 } |
|
854 |
|
855 if (iSelectionLoopIndex >= KNumModesInLoop) |
|
856 { |
|
857 iSelectionLoopIndex = -1; |
|
858 } |
|
859 |
|
860 SetSelectionStyleModeL(); |
|
861 |
|
862 response = EKeyWasConsumed; |
|
863 } |
|
864 |
|
865 return response; |
|
866 } |
|
867 |
|
868 |
|
869 void CAknFepHashKeyManager::SetPreviousSelectionStyleModeL() |
|
870 { |
|
871 if(IsIndicHashKeyStyleRequired()) |
|
872 { |
|
873 SetIndicPreviousStateL(); |
|
874 return; |
|
875 } |
|
876 if (iFepMan.IsOnlyNumericPermitted() || !iSelectionLoop) |
|
877 { |
|
878 // iSelectionLoop is not used in Japanese variant, |
|
879 // so, it keeps previous selection. |
|
880 if (!iSelectionLoop) |
|
881 { |
|
882 iPreviousSelection = ETrue; |
|
883 } |
|
884 return; |
|
885 } |
|
886 |
|
887 if (!iFepMan.InputLanguageSupportsCaseChanges()) |
|
888 { |
|
889 // Jumping by 2 always ignores case change. |
|
890 iSelectionLoopIndex -= 2; |
|
891 if (iSelectionLoopIndex >= 0 && |
|
892 (iSelectionLoop[iSelectionLoopIndex] & EHashPredictionBit) == 0 ) |
|
893 { |
|
894 |
|
895 MCoeFepAwareTextEditor* edit = iFepMan.FepAwareTextEditor(); |
|
896 if(edit && edit->DocumentLengthForFep() > 0) |
|
897 { |
|
898 edit->SetCursorSelectionForFepL(iPreviousIndicCursorPosition); |
|
899 } |
|
900 } |
|
901 } |
|
902 else |
|
903 { |
|
904 iSelectionLoopIndex--; |
|
905 } |
|
906 |
|
907 if (iSelectionLoopIndex >= 0 && |
|
908 (iSelectionLoop[iSelectionLoopIndex] & EHashPredictionBit) != 0 && |
|
909 (iFepMan.EditorState()->Flags() & EAknEditorFlagNoT9)) |
|
910 { |
|
911 // If next one would be prediction, but prediction is not allowed, |
|
912 // skip modes. |
|
913 iSelectionLoopIndex -= 2; |
|
914 } |
|
915 |
|
916 if (iSelectionLoopIndex < -1) |
|
917 { |
|
918 // Jump over to the end of list |
|
919 iSelectionLoopIndex = KNumModesInLoop - 1; |
|
920 } |
|
921 |
|
922 SetSelectionStyleModeL(); |
|
923 } |
|
924 |
|
925 |
|
926 |
|
927 void CAknFepHashKeyManager::SetSelectionStyleModeL() |
|
928 { |
|
929 TBool wasPredictive = iFepMan.WesternPredictive(); |
|
930 TBool willBePredictive = EFalse; |
|
931 |
|
932 if (iSelectionLoopIndex == -1) |
|
933 { |
|
934 // Set number mode. |
|
935 if( iFepMan.IsSupportNativeNumber()) |
|
936 { |
|
937 iFepMan.TryChangeModeL( ENativeNumber ); |
|
938 } |
|
939 else |
|
940 { |
|
941 iFepMan.TryChangeModeL(ENumber); |
|
942 } |
|
943 } |
|
944 else |
|
945 { |
|
946 willBePredictive = (iSelectionLoop[iSelectionLoopIndex] & EHashPredictionBit) != 0; |
|
947 iFepMan.SetWesternPredictive(willBePredictive); |
|
948 if (iSelectionLoop[iSelectionLoopIndex] & EHashLowerCaseBit) |
|
949 { |
|
950 iCaseMan->SetCurrentCase(EAknEditorLowerCase, ETrue); |
|
951 } |
|
952 else if (iSelectionLoop[iSelectionLoopIndex] & EHashUpperCaseBit) |
|
953 { |
|
954 // Let case manager to decide whether we use text case or |
|
955 // upper case. |
|
956 CAknEdwinState* editorState = iFepMan.EditorState(); |
|
957 TInt permittedCases = EAknEditorAllCaseModes; |
|
958 if(editorState) |
|
959 permittedCases = editorState->PermittedCases(); |
|
960 if (!(permittedCases&EAknEditorTextCase ) || |
|
961 iCaseMan->CapsLockRequired(EAknEditorLowerCase)) |
|
962 { |
|
963 iCaseMan->SetCurrentCase(EAknEditorUpperCase, ETrue); |
|
964 } |
|
965 else |
|
966 { |
|
967 iCaseMan->SetCurrentCase(EAknEditorTextCase, ETrue); |
|
968 } |
|
969 } |
|
970 else |
|
971 { |
|
972 iCaseMan->SetCurrentCase(EAknEditorTextCase, ETrue); |
|
973 } |
|
974 iFepMan.SetFlag(CAknFepManager::EFlagSupressAutoUpdate); |
|
975 if (!(wasPredictive && willBePredictive)) |
|
976 { |
|
977 // Do not do this if this is just case change inside predictive mode, |
|
978 // otherwise active word will be committed. |
|
979 iFepMan.SetCcpuFlag(CAknFepManager::ECcpuStataCommitPredictiveWord); |
|
980 iFepMan.TryChangeModeL(ELatin); |
|
981 } |
|
982 iFepMan.ClearFlag(CAknFepManager::EFlagSupressAutoUpdate); |
|
983 } |
|
984 } |
|
985 void CAknFepHashKeyManager::UpdateCaseForIndicHashLoop() |
|
986 { |
|
987 switch (iCaseMan->CurrentCase()) |
|
988 { |
|
989 case EAknEditorUpperCase: |
|
990 iIndicSelectionLoopIndex = EHashIndicLatinUpperMode; |
|
991 break; |
|
992 case EAknEditorTextCase: |
|
993 iIndicSelectionLoopIndex = EHashIndicLatinTextMode; |
|
994 break; |
|
995 case EAknEditorLowerCase: |
|
996 iIndicSelectionLoopIndex = EHashIndicLatinLowerMode; |
|
997 break; |
|
998 default: |
|
999 break; |
|
1000 } |
|
1001 } |
|
1002 |
|
1003 |
|
1004 TBool CAknFepHashKeyManager::IsIndicHashKeyStyleRequired() |
|
1005 { |
|
1006 if(TAknFepUiIndicInputManager::IsIndicLangauge(iFepMan.GetInputLanguageFromSharedDataInterface()) |
|
1007 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1008 || TAknFepUiIndicInputManager :: IsIndicPhoneticLanguage( |
|
1009 iFepMan.GetInputLanguageFromSharedDataInterface()) |
|
1010 #endif |
|
1011 ) |
|
1012 { |
|
1013 CAknEdwinState* editorState = iFepMan.EditorState(); |
|
1014 if (editorState && !(editorState->Flags() & EAknEditorFlagLatinInputModesOnly)) |
|
1015 { |
|
1016 return ETrue; |
|
1017 } |
|
1018 } |
|
1019 return EFalse; |
|
1020 } |
|
1021 |
|
1022 |
|
1023 TKeyResponse CAknFepHashKeyManager::SetIndicPreviousStateL() |
|
1024 { |
|
1025 TKeyResponse response = EKeyWasNotConsumed; |
|
1026 if (iFepMan.IsOnlyNumericPermitted()) |
|
1027 { |
|
1028 return response; |
|
1029 } |
|
1030 switch(iIndicSelectionLoopIndex) |
|
1031 { |
|
1032 case EHashIndicMultitapMode: |
|
1033 case EHashIndicPredictiveMode: // fall through |
|
1034 if(iLanguageChangedOrChangeFromNumberMode) |
|
1035 { |
|
1036 if(iFepMan.HashKeySelectionInUse()) |
|
1037 { |
|
1038 iIndicSelectionLoopIndex = EHashNumberMode; |
|
1039 } |
|
1040 else |
|
1041 { |
|
1042 iFepMan.ChangeInputLanguageL(ELangEnglish); |
|
1043 if(iIndicSelectionLoopIndex) // if hindi predictive is on, turn off for english |
|
1044 { |
|
1045 iFepMan.SetWesternPredictive(EFalse); |
|
1046 iFepMan.TryChangeModeL(ELatin); |
|
1047 } |
|
1048 UpdateCaseForIndicHashLoop(); |
|
1049 } |
|
1050 } |
|
1051 else |
|
1052 { |
|
1053 // Reverts predictive text settings change made with short key press. |
|
1054 if(iIndicSelectionLoopIndex) // Meaning predictive state |
|
1055 { |
|
1056 iIndicSelectionLoopIndex = EHashIndicMultitapMode; // change to multitap |
|
1057 MCoeFepAwareTextEditor* edit = iFepMan.FepAwareTextEditor(); |
|
1058 if(edit && edit->DocumentLengthForFep() > 0) |
|
1059 { |
|
1060 edit->SetCursorSelectionForFepL(iPreviousIndicCursorPosition); |
|
1061 } |
|
1062 } |
|
1063 else |
|
1064 { |
|
1065 iIndicSelectionLoopIndex = EHashIndicPredictiveMode; // change to predictive |
|
1066 } |
|
1067 } |
|
1068 break; |
|
1069 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1070 case EHashIndicPhoneticLowerMode: |
|
1071 case EHashIndicPhoneticUpperMode: |
|
1072 if(iFepMan.WasLastKeyPressAHashKey()) |
|
1073 { |
|
1074 iFepMan.ChangeInputLanguageL(ELangEnglish); |
|
1075 iFepMan.SetWesternPredictive(EFalse); |
|
1076 iFepMan.TryChangeModeL(ELatin); |
|
1077 iLanguageChangedOrChangeFromNumberMode = ETrue; |
|
1078 iIndicSelectionLoopIndex = EHashIndicLatinLowerMode; |
|
1079 } |
|
1080 else |
|
1081 { |
|
1082 if(iIndicSelectionLoopIndex == EHashIndicPhoneticUpperMode) |
|
1083 { |
|
1084 iIndicSelectionLoopIndex = EHashIndicPhoneticLowerMode; |
|
1085 } |
|
1086 else if(iIndicSelectionLoopIndex == EHashIndicPhoneticLowerMode) |
|
1087 { |
|
1088 iIndicSelectionLoopIndex = EHashIndicPhoneticUpperMode; |
|
1089 } |
|
1090 } |
|
1091 break; |
|
1092 #endif |
|
1093 case EHashIndicLatinTextMode: // Text Case |
|
1094 case EHashIndicLatinUpperMode: // Upper Case |
|
1095 case EHashIndicLatinLowerMode: // Lower Case |
|
1096 if(iLanguageChangedOrChangeFromNumberMode) |
|
1097 { |
|
1098 iFepMan.ChangeInputLanguageL(iFepMan.GetInputLanguageFromSharedDataInterface()); |
|
1099 iIndicSelectionLoopIndex = iIndicPredictiveState; |
|
1100 } |
|
1101 else |
|
1102 { |
|
1103 if (iIndicSelectionLoopIndex == EHashIndicLatinLowerMode) |
|
1104 { |
|
1105 iIndicSelectionLoopIndex = EHashIndicLatinUpperMode; |
|
1106 } |
|
1107 else |
|
1108 { |
|
1109 iIndicSelectionLoopIndex = EHashIndicLatinLowerMode; |
|
1110 } |
|
1111 iCaseMan->UpdateCase(ENullNaviEvent); |
|
1112 if(iCaseMan->CurrentCase() == EAknEditorTextCase) |
|
1113 { |
|
1114 iIndicSelectionLoopIndex = EHashIndicLatinTextMode; |
|
1115 } |
|
1116 else |
|
1117 { |
|
1118 iCaseMan->RevertCaseChange(); |
|
1119 } |
|
1120 } |
|
1121 break; |
|
1122 |
|
1123 case EHashNumberMode: |
|
1124 if(iFepMan.HashKeySelectionInUse()) |
|
1125 { |
|
1126 iFepMan.ChangeInputLanguageL(ELangEnglish); |
|
1127 iFepMan.SetWesternPredictive(EFalse); |
|
1128 iFepMan.TryChangeModeL(ELatin); |
|
1129 UpdateCaseForIndicHashLoop(); |
|
1130 } |
|
1131 break; |
|
1132 } |
|
1133 SetIndicSelectionStateL(); |
|
1134 return EKeyWasConsumed; |
|
1135 } |
|
1136 |
|
1137 void CAknFepHashKeyManager::ResetIndicHashKeyStateL() |
|
1138 { |
|
1139 if(IsIndicHashKeyStyleRequired()) |
|
1140 { |
|
1141 TInt editorMode = iFepMan.EditorState()->CurrentInputMode(); |
|
1142 if(editorMode == EAknEditorNumericInputMode) |
|
1143 { |
|
1144 iIndicSelectionLoopIndex = EHashNumberMode; |
|
1145 } |
|
1146 else |
|
1147 { |
|
1148 MPtiLanguage* curLang = iFepMan.PtiEngine()->CurrentLanguage(); |
|
1149 if(curLang && curLang->LanguageCode()!=ELangEnglish ) |
|
1150 { |
|
1151 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1152 if(iFepMan.IsIndicPhoneticInputLanguage()) |
|
1153 { |
|
1154 if(iCaseMan->CurrentCase() == EAknEditorUpperCase) |
|
1155 iIndicSelectionLoopIndex = EHashIndicPhoneticUpperMode; |
|
1156 else |
|
1157 iIndicSelectionLoopIndex = EHashIndicPhoneticLowerMode; |
|
1158 } |
|
1159 else |
|
1160 { |
|
1161 #endif |
|
1162 iIndicPredictiveState = iIndicSelectionLoopIndex = iFepMan.WesternPredictive(ELatin); |
|
1163 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1164 } |
|
1165 #endif |
|
1166 } |
|
1167 else |
|
1168 { |
|
1169 UpdateCaseForIndicHashLoop(); |
|
1170 } |
|
1171 } |
|
1172 } |
|
1173 } |
|
1174 |
|
1175 TKeyResponse CAknFepHashKeyManager::SetIndicStateL() |
|
1176 { |
|
1177 TKeyResponse response = EKeyWasNotConsumed; |
|
1178 |
|
1179 if (iFepMan.IsOnlyNumericPermitted()) |
|
1180 { |
|
1181 return response; |
|
1182 } |
|
1183 |
|
1184 iLanguageChangedOrChangeFromNumberMode = EFalse; |
|
1185 if(iIndicSelectionLoopIndex == -1) |
|
1186 { |
|
1187 iIndicPredictiveState = iIndicSelectionLoopIndex = |
|
1188 (iFepMan.WesternPredictive(ELatin) && |
|
1189 (!( iFepMan.EditorState()->Flags() & EAknEditorFlagNoT9))); |
|
1190 // Cannot be done in constructor as FepMan is not completely initialized |
|
1191 } |
|
1192 |
|
1193 switch(iIndicSelectionLoopIndex) |
|
1194 { |
|
1195 case EHashIndicMultitapMode: |
|
1196 case EHashIndicPredictiveMode: //fall through |
|
1197 |
|
1198 iIndicPredictiveState = iIndicSelectionLoopIndex; // 0 for multitap and 1 for predictive |
|
1199 if(iFepMan.WasLastKeyPressAHashKey() || |
|
1200 ( iFepMan.EditorState()->Flags() & EAknEditorFlagNoT9)) |
|
1201 { |
|
1202 //iFepMan.ChangeInputLanguageL(ELangEnglish); |
|
1203 iFepMan.SetWesternPredictive(EFalse); |
|
1204 iFepMan.TryChangeModeL(ELatin); |
|
1205 iLanguageChangedOrChangeFromNumberMode = ETrue; |
|
1206 iIndicSelectionLoopIndex = EHashIndicLatinLowerMode; |
|
1207 iCaseMan->UpdateCase(ENullNaviEvent); |
|
1208 if(iCaseMan->CurrentCase() == EAknEditorTextCase) |
|
1209 { |
|
1210 iIndicSelectionLoopIndex = EHashIndicLatinTextMode; |
|
1211 } |
|
1212 else |
|
1213 { |
|
1214 iCaseMan->RevertCaseChange(); |
|
1215 } |
|
1216 } |
|
1217 else |
|
1218 { |
|
1219 if(iIndicSelectionLoopIndex) // Meaning predictive state |
|
1220 { |
|
1221 iIndicSelectionLoopIndex = EHashIndicMultitapMode; // change to multitap |
|
1222 } |
|
1223 else |
|
1224 { |
|
1225 if(!( iFepMan.EditorState()->Flags() & EAknEditorFlagNoT9)) |
|
1226 { |
|
1227 iIndicSelectionLoopIndex = EHashIndicPredictiveMode; // change to predictive |
|
1228 MCoeFepAwareTextEditor* edit = iFepMan.FepAwareTextEditor(); |
|
1229 if(edit && edit->DocumentLengthForFep() > 0) |
|
1230 { |
|
1231 edit->GetCursorSelectionForFep(iPreviousIndicCursorPosition); |
|
1232 } |
|
1233 } |
|
1234 } |
|
1235 } |
|
1236 break; |
|
1237 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1238 case EHashIndicPhoneticLowerMode: |
|
1239 case EHashIndicPhoneticUpperMode: |
|
1240 if(iFepMan.WasLastKeyPressAHashKey()) |
|
1241 { |
|
1242 //iFepMan.ChangeInputLanguageL(ELangEnglish); |
|
1243 iFepMan.SetWesternPredictive(EFalse); |
|
1244 iFepMan.TryChangeModeL(ELatin); |
|
1245 iLanguageChangedOrChangeFromNumberMode = ETrue; |
|
1246 iIndicSelectionLoopIndex = EHashIndicLatinLowerMode; |
|
1247 } |
|
1248 else |
|
1249 { |
|
1250 if(iIndicSelectionLoopIndex == EHashIndicPhoneticUpperMode) |
|
1251 { |
|
1252 iIndicSelectionLoopIndex = EHashIndicPhoneticLowerMode; |
|
1253 } |
|
1254 else if(iIndicSelectionLoopIndex == EHashIndicPhoneticLowerMode) |
|
1255 { |
|
1256 iIndicSelectionLoopIndex = EHashIndicPhoneticUpperMode; |
|
1257 } |
|
1258 } |
|
1259 break; |
|
1260 #endif |
|
1261 case EHashIndicLatinTextMode: // Text Case |
|
1262 case EHashIndicLatinLowerMode: // Lower Case |
|
1263 case EHashIndicLatinUpperMode: // Upper Case |
|
1264 if(iFepMan.WasLastKeyPressAHashKey()) |
|
1265 { |
|
1266 //iFepMan.ChangeInputLanguageL(iFepMan.GetInputLanguageFromSharedDataInterface()); |
|
1267 iLanguageChangedOrChangeFromNumberMode = ETrue; |
|
1268 if(iFepMan.HashKeySelectionInUse()) |
|
1269 { |
|
1270 iIndicSelectionLoopIndex = EHashNumberMode; // change to number |
|
1271 } |
|
1272 else |
|
1273 { |
|
1274 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1275 if(TAknFepUiIndicInputManager :: IsIndicPhoneticLanguage( |
|
1276 iFepMan.GetInputLanguageFromSharedDataInterface())) |
|
1277 { |
|
1278 iIndicSelectionLoopIndex = EHashIndicPhoneticLowerMode; |
|
1279 } |
|
1280 else |
|
1281 { |
|
1282 #endif |
|
1283 iIndicSelectionLoopIndex = iIndicPredictiveState; // change to hindi [multitap or predictive based on previous setting] |
|
1284 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1285 } |
|
1286 #endif |
|
1287 } |
|
1288 } |
|
1289 else |
|
1290 { |
|
1291 switch (iCaseMan->CurrentCase()) |
|
1292 { |
|
1293 case EAknEditorUpperCase: |
|
1294 case EAknEditorTextCase: //fall through |
|
1295 iIndicSelectionLoopIndex = EHashIndicLatinLowerMode; |
|
1296 break; |
|
1297 case EAknEditorLowerCase: |
|
1298 iIndicSelectionLoopIndex = EHashIndicLatinUpperMode; |
|
1299 break; |
|
1300 default: |
|
1301 break; |
|
1302 } |
|
1303 } |
|
1304 break; |
|
1305 |
|
1306 case EHashNumberMode: |
|
1307 if(iFepMan.HashKeySelectionInUse()) |
|
1308 { |
|
1309 iLanguageChangedOrChangeFromNumberMode = ETrue; |
|
1310 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1311 if(TAknFepUiIndicInputManager :: IsIndicPhoneticLanguage( |
|
1312 iFepMan.GetInputLanguageFromSharedDataInterface())) |
|
1313 { |
|
1314 iIndicSelectionLoopIndex = EHashIndicPhoneticLowerMode; |
|
1315 iFepMan.TryChangeModeL(ELatin); |
|
1316 } |
|
1317 else |
|
1318 { |
|
1319 #endif |
|
1320 iIndicSelectionLoopIndex = iIndicPredictiveState; // change to hindi [multitap or predictive based on previous setting] |
|
1321 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1322 } |
|
1323 #endif |
|
1324 } |
|
1325 break; |
|
1326 |
|
1327 default: |
|
1328 break; |
|
1329 } |
|
1330 |
|
1331 SetIndicSelectionStateL(); |
|
1332 return EKeyWasConsumed; |
|
1333 } |
|
1334 |
|
1335 |
|
1336 |
|
1337 |
|
1338 void CAknFepHashKeyManager::SetIndicSelectionStateL() |
|
1339 { |
|
1340 switch(iIndicSelectionLoopIndex) |
|
1341 { |
|
1342 |
|
1343 case EHashIndicMultitapMode: |
|
1344 { |
|
1345 iFepMan.SetWesternPredictive(EFalse); |
|
1346 iFepMan.TryChangeModeL(EHindi); |
|
1347 } |
|
1348 break; |
|
1349 |
|
1350 case EHashIndicPredictiveMode: |
|
1351 if(!( iFepMan.EditorState()->Flags() & EAknEditorFlagNoT9)) // make sure predictive is supported for editor |
|
1352 { |
|
1353 iFepMan.SetWesternPredictive(ETrue); |
|
1354 iFepMan.TryChangeModeL(EHindi); |
|
1355 } |
|
1356 break; |
|
1357 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1358 case EHashIndicPhoneticLowerMode: |
|
1359 iCaseMan->SetCurrentCase(EAknEditorLowerCase, ETrue); |
|
1360 break; |
|
1361 |
|
1362 case EHashIndicPhoneticUpperMode: |
|
1363 iCaseMan->SetCurrentCase(EAknEditorUpperCase, ETrue); |
|
1364 break; |
|
1365 #endif |
|
1366 case EHashIndicLatinTextMode: |
|
1367 iCaseMan->SetCurrentCase(EAknEditorTextCase, ETrue); |
|
1368 break; |
|
1369 |
|
1370 case EHashIndicLatinUpperMode: |
|
1371 iCaseMan->SetCurrentCase(EAknEditorUpperCase, ETrue); |
|
1372 break; |
|
1373 |
|
1374 case EHashIndicLatinLowerMode: |
|
1375 iCaseMan->SetCurrentCase(EAknEditorLowerCase, ETrue); |
|
1376 break; |
|
1377 |
|
1378 case EHashNumberMode: |
|
1379 if( iFepMan.IsSupportNativeNumber()) |
|
1380 { |
|
1381 iFepMan.TryChangeModeL(ENativeNumber); |
|
1382 } |
|
1383 else |
|
1384 { |
|
1385 iFepMan.TryChangeModeL(ENumber); |
|
1386 } |
|
1387 break; |
|
1388 default: |
|
1389 break; |
|
1390 } |
|
1391 } |
|
1392 |
|
1393 void CAknFepHashKeyManager::ResetPreviousSelectionStyleMode() |
|
1394 { |
|
1395 iPreviousSelection = EFalse; |
|
1396 } |
|
1397 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1398 void CAknFepHashKeyManager::HandleSetIndicStateL() |
|
1399 { |
|
1400 //calling SetIndicStateL only if currently it is in upper mode |
|
1401 if(iIndicSelectionLoopIndex == EHashIndicPhoneticUpperMode) |
|
1402 SetIndicStateL(); |
|
1403 } |
|
1404 #endif |
|
1405 |
|
1406 TKeyResponse CAknFepHashKeyManager::HandleKeyWesternWithKoreanL(TKeyPressLength aLength) |
|
1407 { |
|
1408 TKeyResponse response = EKeyWasNotConsumed; |
|
1409 |
|
1410 if(iMode == ELatin) |
|
1411 { |
|
1412 iFepMan.SetWesternPredictive(EFalse); |
|
1413 } |
|
1414 |
|
1415 if (iFepMan.IsOnlyNumericPermitted()) |
|
1416 { |
|
1417 if (aLength == ELongKeyPress) |
|
1418 { |
|
1419 TText prevCh = iFepMan.PreviousChar(); |
|
1420 if (prevCh == '#') |
|
1421 { |
|
1422 iFepMan.RemovePreviousCharacterL(); |
|
1423 } |
|
1424 |
|
1425 response = EKeyWasConsumed; |
|
1426 } |
|
1427 //else let the FEP Man put special chars into the editor |
|
1428 } |
|
1429 else |
|
1430 { |
|
1431 if (aLength == EShortKeyPress) |
|
1432 { |
|
1433 if (iMode == ENumber) |
|
1434 { |
|
1435 response = EKeyWasNotConsumed; |
|
1436 return response; |
|
1437 } |
|
1438 } |
|
1439 else // Long keypress |
|
1440 { |
|
1441 if (iMode == ENumber) |
|
1442 { |
|
1443 iLastModeNumber = ETrue; |
|
1444 |
|
1445 TText prevCh = iFepMan.PreviousChar(); |
|
1446 if (prevCh == '#') |
|
1447 { |
|
1448 iFepMan.RemovePreviousCharacterL(); |
|
1449 } |
|
1450 } |
|
1451 else |
|
1452 { |
|
1453 iLastModeNumber = EFalse; |
|
1454 } |
|
1455 |
|
1456 CAknEdwinState* editorState = iFepMan.EditorState(); |
|
1457 TInt permittedCases = editorState->PermittedCases(); |
|
1458 permittedCases = permittedCases == 0 ? |
|
1459 EAknEditorLowerCase | EAknEditorUpperCase : permittedCases; |
|
1460 if ( iMode == ELatin && (permittedCases & EAknEditorTextCase)) |
|
1461 { |
|
1462 // Latin case update is changed back to automatic if latin |
|
1463 // text case is allowed and the case is changed manually from #-key. |
|
1464 iFepMan.ClearFlag(CAknFepManager::EFlagSupressAutoUpdate); |
|
1465 } |
|
1466 TInt currentCase = iCaseMan->CurrentCase(); |
|
1467 |
|
1468 // Is current latin case last available case. |
|
1469 TBool lastCase = ( ( !(permittedCases & EAknEditorTextCase) && |
|
1470 (( currentCase == EAknEditorLowerCase) || |
|
1471 ( currentCase == EAknEditorUpperCase && |
|
1472 !(permittedCases & EAknEditorLowerCase)) ) || |
|
1473 ( editorState->Flags() & EAknEditorFlagFixedCase) ) || |
|
1474 ( editorState->Flags() & EAknEditorFlagForceTransparentFepModes) ); |
|
1475 |
|
1476 if (iMode == ELatin && |
|
1477 !iFepMan.IsFlagSet(CAknFepManager::EFlagChangeInputMode) && |
|
1478 !lastCase ) |
|
1479 { |
|
1480 // Input mode is still Latin. Only case is updated. |
|
1481 if (permittedCases & EAknEditorTextCase) |
|
1482 { |
|
1483 iCaseMan->ManualCaseUpdate(); |
|
1484 } |
|
1485 else |
|
1486 { |
|
1487 iCaseMan->SetCurrentCase(EAknEditorLowerCase); |
|
1488 } |
|
1489 |
|
1490 // Next time input mode is changed if any text is not entered before. |
|
1491 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
1492 } |
|
1493 else |
|
1494 { |
|
1495 // Do not change mode, if text selection is ongoing. |
|
1496 if(!iFepMan.IsCcpuFlagSet(CAknFepManager::ECcpuStateEdwinInSelectionMode)) |
|
1497 { |
|
1498 // Input mode is incremented. |
|
1499 iFepMan.TryIncrementModeL(iMode); |
|
1500 |
|
1501 |
|
1502 iFepMan.ClearFlag(CAknFepManager::EFlagChangeInputMode); |
|
1503 |
|
1504 if (iMode == ELatin) // New mode after Increment. |
|
1505 { |
|
1506 if (editorState->Flags() & EAknEditorFlagFixedCase) |
|
1507 { |
|
1508 // Only one fixed case is available. Use it. |
|
1509 iCaseMan->ConfigureCaseStateFromEditorState(); |
|
1510 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
1511 } |
|
1512 else if (editorState->Flags() & EAknEditorFlagForceTransparentFepModes) |
|
1513 { |
|
1514 // Only lower case is used with find pane. |
|
1515 iCaseMan->SetCurrentCase(EAknEditorLowerCase); |
|
1516 iFepMan.SetFlag(CAknFepManager::EFlagSupressAutoUpdate); |
|
1517 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
1518 } |
|
1519 else if (permittedCases & EAknEditorTextCase) |
|
1520 { |
|
1521 iCaseMan->SetCurrentCase(EAknEditorTextCase); |
|
1522 iCaseMan->UpdateCase(ENullNaviEvent); |
|
1523 } |
|
1524 else |
|
1525 { |
|
1526 if (permittedCases & EAknEditorUpperCase) |
|
1527 { |
|
1528 iCaseMan->SetCurrentCase(EAknEditorUpperCase); |
|
1529 if ( !(permittedCases & EAknEditorLowerCase)) |
|
1530 { |
|
1531 // We need to move to next input mode since only upper case |
|
1532 // is permitted in Latin input mode. |
|
1533 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
1534 } |
|
1535 } |
|
1536 else |
|
1537 { |
|
1538 iCaseMan->SetCurrentCase(EAknEditorLowerCase); |
|
1539 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
1540 } |
|
1541 } |
|
1542 } |
|
1543 } |
|
1544 } |
|
1545 } |
|
1546 response = EKeyWasConsumed; |
|
1547 } |
|
1548 return response; |
|
1549 } |
|
1550 // End of File |