44
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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 |
* Name : CGSPredictiveSettingList from AknFepPredictiveSettingList
|
|
20 |
* ============================================================================
|
|
21 |
*/
|
|
22 |
|
|
23 |
#include <barsread.h>
|
|
24 |
#include <AvkonInternalCRKeys.h>
|
|
25 |
#include <e32property.h>
|
|
26 |
#include <PtiDefs.h>
|
|
27 |
#include <aknfep.rsg>
|
|
28 |
#include <AknFepGlobalEnums.h>
|
|
29 |
#include "PredictiveSettingList.h"
|
|
30 |
#include "PredictiveSettingData.h"
|
|
31 |
#include "PredictiveSettingDialog.h"
|
|
32 |
|
|
33 |
CGSMultiSelectionSettingItem::CGSMultiSelectionSettingItem (
|
|
34 |
TInt aResourceId, CGSPredictiveSettingData &aData, CCoeEnv* aCoeEnv )
|
|
35 |
: CAknBigSettingItemBase(aResourceId), iData(aData), iCoeEnv(aCoeEnv)
|
|
36 |
{
|
|
37 |
}
|
|
38 |
|
|
39 |
CGSMultiSelectionSettingItem::~CGSMultiSelectionSettingItem()
|
|
40 |
{
|
|
41 |
if(iSelection)
|
|
42 |
iSelection->ResetAndDestroy();
|
|
43 |
delete iSelection;
|
|
44 |
iSelection = NULL;
|
|
45 |
}
|
|
46 |
|
|
47 |
void CGSMultiSelectionSettingItem::EditItemL( TBool /*aCalledFromMenu*/ )
|
|
48 |
{
|
|
49 |
if(!iSelection)
|
|
50 |
{
|
|
51 |
iSelection = CreateSelectionItemListL();
|
|
52 |
}
|
|
53 |
CAknCheckBoxSettingPage* settingPage =
|
|
54 |
new( ELeave) CAknCheckBoxSettingPage( R_AUTOWORDCOMPLMULTI_PAGE, iSelection);
|
|
55 |
|
|
56 |
if( settingPage->ExecuteLD(CAknSettingPage::EUpdateWhenAccepted))
|
|
57 |
{
|
|
58 |
StoreL();
|
|
59 |
}
|
|
60 |
else
|
|
61 |
{
|
|
62 |
TInt physicalKeyboards = iData.PhysicalKeyboards();
|
|
63 |
|
|
64 |
if(physicalKeyboards & EPhysicalKeyboard12key)
|
|
65 |
{
|
|
66 |
iSelection->At(iItutIndex)->SetSelectionStatus(iData.AWCBitmask() & EKeyboardStyle12Key);
|
|
67 |
}
|
|
68 |
if((physicalKeyboards & EPhysicalKeyboardQwerty4x10) || (physicalKeyboards & EPhysicalKeyboardQwerty4x12) || (physicalKeyboards & EPhysicalKeyboardQwerty3x11))
|
|
69 |
{
|
|
70 |
iSelection->At(iQwertyIndex)->SetSelectionStatus(iData.AWCBitmask() & EKeyboardStyleQwerty);
|
|
71 |
}
|
|
72 |
else if(physicalKeyboards & EPhysicalKeyboardHalfQwerty)
|
|
73 |
{
|
|
74 |
iSelection->At(iHalfQwertyIndex)->SetSelectionStatus(iData.AWCBitmask() & EKeyboardStyleHalfQwerty);
|
|
75 |
}
|
|
76 |
}
|
|
77 |
SetSettingPage(0);
|
|
78 |
}
|
|
79 |
|
|
80 |
void CGSMultiSelectionSettingItem::StoreL()
|
|
81 |
{
|
|
82 |
if(iSelection)
|
|
83 |
{
|
|
84 |
TInt physicalKeyboards = iData.PhysicalKeyboards();
|
|
85 |
for(TUint i = 0x01; i <= 0xF0; i = i << 1)
|
|
86 |
{
|
|
87 |
if(physicalKeyboards & i)
|
|
88 |
{
|
|
89 |
switch(i)
|
|
90 |
{
|
|
91 |
case 0x01: // itut
|
|
92 |
if(iSelection->At(iItutIndex)->SelectionStatus())
|
|
93 |
{
|
|
94 |
iData.AWCBitmask() |= EKeyboardStyle12Key;
|
|
95 |
}
|
|
96 |
else
|
|
97 |
{
|
|
98 |
iData.AWCBitmask() &= ~EKeyboardStyle12Key;
|
|
99 |
}
|
|
100 |
break;
|
|
101 |
case 0x10: // half
|
|
102 |
if(iSelection->At(iHalfQwertyIndex)->SelectionStatus())
|
|
103 |
{
|
|
104 |
iData.AWCBitmask() |= EKeyboardStyleHalfQwerty;
|
|
105 |
}
|
|
106 |
else
|
|
107 |
{
|
|
108 |
iData.AWCBitmask() &= ~EKeyboardStyleHalfQwerty;
|
|
109 |
}
|
|
110 |
break;
|
|
111 |
|
|
112 |
case 0x02: // 4x12
|
|
113 |
case 0x04: // 4x10
|
|
114 |
case 0x08: // 3x11
|
|
115 |
case 0x20: // custom
|
|
116 |
if(iSelection->At(iQwertyIndex)->SelectionStatus())
|
|
117 |
{
|
|
118 |
iData.AWCBitmask() |= EKeyboardStyleQwerty;
|
|
119 |
}
|
|
120 |
else
|
|
121 |
{
|
|
122 |
iData.AWCBitmask() &= ~EKeyboardStyleQwerty;
|
|
123 |
}
|
|
124 |
i = 0x20; // Skip rest of qwerty checks
|
|
125 |
break;
|
|
126 |
default:
|
|
127 |
break;
|
|
128 |
}
|
|
129 |
}
|
|
130 |
}
|
|
131 |
}
|
|
132 |
}
|
|
133 |
|
|
134 |
void CGSMultiSelectionSettingItem::LoadL()
|
|
135 |
{
|
|
136 |
if(iSelection)
|
|
137 |
{
|
|
138 |
iSelection->ResetAndDestroy();
|
|
139 |
delete iSelection;
|
|
140 |
iSelection = NULL;
|
|
141 |
}
|
|
142 |
iSelection = CreateSelectionItemListL();
|
|
143 |
}
|
|
144 |
|
|
145 |
CSelectionItemList* CGSMultiSelectionSettingItem::CreateSelectionItemListL()
|
|
146 |
{
|
|
147 |
CSelectionItemList* selection = new (ELeave) CSelectionItemList(2);
|
|
148 |
TInt physicalKeyboards = iData.PhysicalKeyboards();
|
|
149 |
TBool settingActive = EFalse;
|
|
150 |
HBufC* selectionText = 0;
|
|
151 |
TInt count = 0;
|
|
152 |
for(TUint i = 0x01; i <= 0xF0; i = i << 1)
|
|
153 |
{
|
|
154 |
if(physicalKeyboards & i)
|
|
155 |
{
|
|
156 |
switch(i)
|
|
157 |
{
|
|
158 |
case 0x01: // itut
|
|
159 |
settingActive = ( iData.AWCBitmask() & EKeyboardStyle12Key ? 1 : 0 );
|
|
160 |
selectionText = iCoeEnv->AllocReadResourceLC(R_AKNFEP_PRED_SETTING_ITUT);
|
|
161 |
iItutIndex = count++;
|
|
162 |
break;
|
|
163 |
case 0x10: // half
|
|
164 |
settingActive = ( iData.AWCBitmask() & EKeyboardStyleHalfQwerty ? 1 : 0 );
|
|
165 |
selectionText = iCoeEnv->AllocReadResourceLC( R_AKNFEP_PRED_SETTING_HALF_QWERTY );
|
|
166 |
iHalfQwertyIndex = count++;
|
|
167 |
break;
|
|
168 |
case 0x02: // 4x12
|
|
169 |
case 0x04: // 4x10
|
|
170 |
case 0x08: // 3x11
|
|
171 |
case 0x20: // custom
|
|
172 |
settingActive = ( iData.AWCBitmask() & EKeyboardStyleQwerty ? 1: 0);
|
|
173 |
selectionText = iCoeEnv->AllocReadResourceLC(R_AKNFEP_PRED_SETTING_QWERTY);
|
|
174 |
iQwertyIndex = count++;
|
|
175 |
i = 0x20; // Skip rest of qwerty checks
|
|
176 |
break;
|
|
177 |
default:
|
|
178 |
break;
|
|
179 |
}
|
|
180 |
|
|
181 |
CSelectableItem* item = new (ELeave) CSelectableItem( *selectionText, settingActive );
|
|
182 |
item->ConstructL();
|
|
183 |
selection->AppendL(item);
|
|
184 |
CleanupStack::PopAndDestroy(); // selectionText
|
|
185 |
}
|
|
186 |
}
|
|
187 |
return selection;
|
|
188 |
}
|
|
189 |
|
|
190 |
CGSPredictiveSettingList *CGSPredictiveSettingList::NewL(CGSPredictiveSettingData &aData, CGSPredictiveSettingDialog &aDialog)
|
|
191 |
{
|
|
192 |
CGSPredictiveSettingList* self = CGSPredictiveSettingList::NewLC(aData, aDialog);
|
|
193 |
CleanupStack::Pop(self);
|
|
194 |
return self;
|
|
195 |
}
|
|
196 |
|
|
197 |
CGSPredictiveSettingList *CGSPredictiveSettingList::NewLC(CGSPredictiveSettingData &aData, CGSPredictiveSettingDialog &aDialog)
|
|
198 |
{
|
|
199 |
CGSPredictiveSettingList* self = new (ELeave) CGSPredictiveSettingList(aData, aDialog);
|
|
200 |
CleanupStack::PushL(self);
|
|
201 |
return self;
|
|
202 |
}
|
|
203 |
|
|
204 |
CGSPredictiveSettingList::CGSPredictiveSettingList(CGSPredictiveSettingData &aData, CGSPredictiveSettingDialog &aDialog) :
|
|
205 |
CAknSettingItemList(),
|
|
206 |
iSettingsData(aData),
|
|
207 |
iSettingsDialog(aDialog)
|
|
208 |
{
|
|
209 |
}
|
|
210 |
|
|
211 |
CGSPredictiveSettingList::~CGSPredictiveSettingList()
|
|
212 |
{
|
|
213 |
// no specific destruction code required - no owned data
|
|
214 |
}
|
|
215 |
|
|
216 |
|
|
217 |
void CGSPredictiveSettingList::SizeChanged()
|
|
218 |
{
|
|
219 |
// if size changes, make sure component takes whole available space
|
|
220 |
CEikFormattedCellListBox *listbox = ListBox();
|
|
221 |
|
|
222 |
if (listbox)
|
|
223 |
{
|
|
224 |
listbox->SetRect(Rect());
|
|
225 |
}
|
|
226 |
}
|
|
227 |
|
|
228 |
void CGSPredictiveSettingList::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
|
|
229 |
{
|
|
230 |
TBool isSingleClick = iAvkonAppUi->IsSingleClickCompatible();
|
|
231 |
if( aEventType == EEventEnterKeyPressed || aEventType == EEventItemDoubleClicked
|
|
232 |
|| ( isSingleClick && ( aEventType == EEventItemSingleClicked )))
|
|
233 |
{
|
|
234 |
iSettingsDialog.EditItemL(EFalse);//EditCurrentItemL(EFalse);
|
|
235 |
}
|
|
236 |
else
|
|
237 |
{
|
|
238 |
CAknSettingItemList::HandleListBoxEventL( aListBox,aEventType );
|
|
239 |
}
|
|
240 |
}
|
|
241 |
|
|
242 |
void CGSPredictiveSettingList::EditCurrentItemL(TBool aCalledFromMenu)
|
|
243 |
{
|
|
244 |
// invoke EditItemL on the current item
|
|
245 |
TInt index = SettingItemArray()->ItemIndexFromVisibleIndex(ListBox()->CurrentItemIndex());
|
|
246 |
|
|
247 |
EditItemL(index, aCalledFromMenu); // invoked from menu,or not
|
|
248 |
|
|
249 |
StoreSettingsL();
|
|
250 |
}
|
|
251 |
|
|
252 |
CAknSettingItem * CGSPredictiveSettingList::CreateSettingItemL (TInt aIdentifier)
|
|
253 |
{
|
|
254 |
// method is used to create specific setting item as required at run-time.
|
|
255 |
// aIdentifier is used to determine what kind of setting item should be
|
|
256 |
// created
|
|
257 |
CAknSettingItem* settingItem = NULL;
|
|
258 |
TInt keyboardLayout = 0;
|
|
259 |
RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout);
|
|
260 |
switch (aIdentifier)
|
|
261 |
{
|
|
262 |
case EAknFepCmdPredAutoComplSetting:
|
|
263 |
settingItem = new (ELeave) CAknBinaryPopupSettingItem (
|
|
264 |
aIdentifier, iSettingsData.AutoWordCompl());
|
|
265 |
if(DeviceHasMultipleKeyboards())
|
|
266 |
{
|
|
267 |
settingItem->SetHidden(ETrue);
|
|
268 |
}
|
|
269 |
break;
|
|
270 |
case EAknFepCmdPredAutoComplMultiSetting:
|
|
271 |
settingItem = new (ELeave) CGSMultiSelectionSettingItem (
|
|
272 |
aIdentifier, iSettingsData, iCoeEnv );
|
|
273 |
if(!DeviceHasMultipleKeyboards())
|
|
274 |
{
|
|
275 |
settingItem->SetHidden(ETrue);
|
|
276 |
}
|
|
277 |
break;
|
|
278 |
case EAknFepCmdPredNumberCandidateSetting:
|
|
279 |
settingItem = new (ELeave) CAknBinaryPopupSettingItem (
|
|
280 |
aIdentifier,
|
|
281 |
iSettingsData.NumberCandidates());
|
|
282 |
if((keyboardLayout == EPtiKeyboard12Key )||
|
|
283 |
(keyboardLayout == EPtiKeyboardHalfQwerty)||
|
|
284 |
(!DeviceHasQwertyKeyboard()))
|
|
285 |
settingItem->SetHidden(ETrue);
|
|
286 |
break;
|
|
287 |
case EAknFepCmdPredTypingCorrectionSetting:
|
|
288 |
settingItem = new (ELeave) CAknEnumeratedTextPopupSettingItem (
|
|
289 |
aIdentifier,
|
|
290 |
iSettingsData.TypingCorrection());
|
|
291 |
// Disabled for ITU-T
|
|
292 |
if((keyboardLayout == EPtiKeyboard12Key )||
|
|
293 |
(keyboardLayout == EPtiKeyboardHalfQwerty)||
|
|
294 |
(!DeviceHasQwertyKeyboard()))
|
|
295 |
settingItem->SetHidden(ETrue);
|
|
296 |
break;
|
|
297 |
case EAknFepCmdPredPrimaryCandidateSetting:
|
|
298 |
settingItem = new (ELeave) CAknBinaryPopupSettingItem (
|
|
299 |
aIdentifier,
|
|
300 |
iSettingsData.PrimaryCandidate());
|
|
301 |
// Disabled for Half Qwerty and ITU-T
|
|
302 |
if((keyboardLayout == EPtiKeyboard12Key )||
|
|
303 |
(keyboardLayout == EPtiKeyboardHalfQwerty)||
|
|
304 |
(!DeviceHasNonHalfQwertyKeyboard()))
|
|
305 |
settingItem->SetHidden(ETrue);
|
|
306 |
break;
|
|
307 |
default:
|
|
308 |
break;
|
|
309 |
}
|
|
310 |
|
|
311 |
return settingItem;
|
|
312 |
}
|
|
313 |
|
|
314 |
TBool CGSPredictiveSettingList::DeviceHasMultipleKeyboards()
|
|
315 |
{
|
|
316 |
TInt physicalKeyboards = iSettingsData.PhysicalKeyboards();
|
|
317 |
TBool firstFound = EFalse;
|
|
318 |
for(TUint i = 0x01; i <= 0xF0; i = i << 1)
|
|
319 |
{
|
|
320 |
if(physicalKeyboards & i)
|
|
321 |
{
|
|
322 |
if (firstFound)
|
|
323 |
{
|
|
324 |
return ETrue;
|
|
325 |
}
|
|
326 |
else
|
|
327 |
{
|
|
328 |
firstFound = ETrue;
|
|
329 |
}
|
|
330 |
}
|
|
331 |
}
|
|
332 |
return EFalse;
|
|
333 |
}
|
|
334 |
|
|
335 |
TBool CGSPredictiveSettingList::DeviceHasQwertyKeyboard()
|
|
336 |
{
|
|
337 |
TInt physicalKeyboards = iSettingsData.PhysicalKeyboards();
|
|
338 |
if(physicalKeyboards & 0x02 || // 4x12
|
|
339 |
physicalKeyboards & 0x04 || // 4x10
|
|
340 |
physicalKeyboards & 0x08 || // 3x11
|
|
341 |
physicalKeyboards & 0x10 || // half
|
|
342 |
physicalKeyboards & 0x20) // custom
|
|
343 |
{
|
|
344 |
return ETrue;
|
|
345 |
}
|
|
346 |
return EFalse;
|
|
347 |
}
|
|
348 |
|
|
349 |
TBool CGSPredictiveSettingList::DeviceHasNonHalfQwertyKeyboard()
|
|
350 |
{
|
|
351 |
TInt physicalKeyboards = iSettingsData.PhysicalKeyboards();
|
|
352 |
if(physicalKeyboards & 0x02 || // 4x12
|
|
353 |
physicalKeyboards & 0x04 || // 4x10
|
|
354 |
physicalKeyboards & 0x08 || // 3x11
|
|
355 |
physicalKeyboards & 0x20) // custom
|
|
356 |
{
|
|
357 |
return ETrue;
|
|
358 |
}
|
|
359 |
return EFalse;
|
|
360 |
}
|
|
361 |
// This part of code for error fixing multiple layout.Whenever you switch from one keyboard
|
|
362 |
// Layout to another keyboard layout HandleResourceChange is getting called and displays or
|
|
363 |
// hides the Input Option Settings information specific to keyboard layout
|
|
364 |
void CGSPredictiveSettingList::HandleResourceChange(TInt aType)
|
|
365 |
{
|
|
366 |
CAknSettingItemList::HandleResourceChange(aType);
|
|
367 |
// Check for keyboard layout change
|
|
368 |
// If layout is changed, close settings with information note
|
|
369 |
if(aType==KEikDynamicLayoutVariantSwitch)
|
|
370 |
{
|
|
371 |
TInt keyboardLayout = 0;
|
|
372 |
RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout);
|
|
373 |
if(keyboardLayout == EPtiKeyboard12Key)
|
|
374 |
{
|
|
375 |
//Returning as Hiding for Touch Input for Virtual Input is not required
|
|
376 |
#ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
|
|
377 |
return;
|
|
378 |
#else
|
|
379 |
// Number candidate
|
|
380 |
SettingItemArray()->At(2)->SetHidden(ETrue);
|
|
381 |
// Typing correction
|
|
382 |
SettingItemArray()->At(3)->SetHidden(ETrue);
|
|
383 |
// Primary Candidate
|
|
384 |
SettingItemArray()->At(4)->SetHidden(ETrue);
|
|
385 |
#endif //__ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
|
|
386 |
}
|
|
387 |
else if (keyboardLayout == EPtiKeyboardHalfQwerty)
|
|
388 |
{
|
|
389 |
// Number candidate
|
|
390 |
SettingItemArray()->At(2)->SetHidden(ETrue);
|
|
391 |
// Typing correction
|
|
392 |
SettingItemArray()->At(3)->SetHidden(ETrue);
|
|
393 |
// Primary Candidate
|
|
394 |
SettingItemArray()->At(4)->SetHidden(ETrue);
|
|
395 |
}
|
|
396 |
else
|
|
397 |
{
|
|
398 |
// Number candidate
|
|
399 |
SettingItemArray()->At(2)->SetHidden(EFalse);
|
|
400 |
// Typing correction
|
|
401 |
SettingItemArray()->At(3)->SetHidden(EFalse);
|
|
402 |
// Primary Candidate
|
|
403 |
SettingItemArray()->At(4)->SetHidden(EFalse);
|
|
404 |
}
|
|
405 |
TRAP_IGNORE(HandleChangeInItemArrayOrVisibilityL());
|
|
406 |
}
|
|
407 |
}
|
|
408 |
|