|
1 /* |
|
2 * Copyright (c) 2002 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 * Implements the feature for investigating length of the input. Softkeys |
|
16 * are set based on this information. |
|
17 * |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <eikenv.h> |
|
24 #include <barsread.h> |
|
25 #include <badesca.h> // for descriptor arrays |
|
26 #include <e32std.h> |
|
27 #include <StringLoader.h> |
|
28 #include <AknQueryDialog.h> |
|
29 #include <aknQueryControl.h> |
|
30 #include <eikcapc.h> |
|
31 #include <avkon.hrh> |
|
32 #include <fepbase.h> |
|
33 #include <Aknnumseced.h> |
|
34 #include <aknedsts.h> |
|
35 #include <featmgr.h> // Used for FeatureManager |
|
36 |
|
37 #include "CSatUiTextQueryDialog.h" |
|
38 #include "tflogger.h" |
|
39 |
|
40 const TInt KSatMinTextLengthForT9 = 1; |
|
41 |
|
42 // ================= MEMBER FUNCTIONS ======================= |
|
43 |
|
44 // C++ default constructor can NOT contain any code, that |
|
45 // might leave. |
|
46 // |
|
47 CSatUiTextQueryDialog::CSatUiTextQueryDialog( |
|
48 TDes& aDataText, |
|
49 const TTone aTone, |
|
50 TInt aMinLength, |
|
51 TInt aMaxLength) : |
|
52 CAknTextQueryDialog(aDataText, aTone), |
|
53 iTextMinLength(aMinLength) |
|
54 { |
|
55 SetMaxLength( aMaxLength ); |
|
56 } |
|
57 |
|
58 // Destructor. |
|
59 CSatUiTextQueryDialog::~CSatUiTextQueryDialog() |
|
60 { |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------- |
|
64 // CSatUiTextQueryDialog::HandleQueryEditorStateEventL |
|
65 // Show left CBA only if editor text is valid |
|
66 // (other items were commented in a header). |
|
67 // --------------------------------------------------------- |
|
68 // |
|
69 TBool CSatUiTextQueryDialog::HandleQueryEditorStateEventL( |
|
70 CAknQueryControl* aQueryControl, |
|
71 TQueryControlEvent /*aEventType*/, |
|
72 TQueryValidationStatus /*aStatus*/) |
|
73 { |
|
74 TFLOGSTRING( "CSatUiTextQueryDialog::HandleQueryEditorStateEventL calling" ) |
|
75 if ( aQueryControl->GetTextLength() < iTextMinLength ) |
|
76 { |
|
77 TFLOGSTRING( "CSatUiTextQueryDialog::HandleQueryEditorStateEventL \ |
|
78 hide softkey" ) |
|
79 // Hide both left and middle softkey |
|
80 ButtonGroupContainer().MakeCommandVisibleByPosition( |
|
81 CEikButtonGroupContainer::ELeftSoftkeyPosition, EFalse ); |
|
82 ButtonGroupContainer().MakeCommandVisibleByPosition( |
|
83 CEikButtonGroupContainer::EMiddleSoftkeyPosition, EFalse ); |
|
84 } |
|
85 else |
|
86 { |
|
87 TFLOGSTRING( "CSatUiTextQueryDialog::HandleQueryEditorStateEventL \ |
|
88 reveal softkey" ) |
|
89 // Reveal both left and middle softkey |
|
90 ButtonGroupContainer().MakeCommandVisibleByPosition( |
|
91 CEikButtonGroupContainer::ELeftSoftkeyPosition, ETrue ); |
|
92 ButtonGroupContainer().MakeCommandVisibleByPosition( |
|
93 CEikButtonGroupContainer::EMiddleSoftkeyPosition, ETrue ); |
|
94 } |
|
95 TFLOGSTRING( "CSatUiTextQueryDialog::HandleQueryEditorStateEventL exiting" ) |
|
96 return ETrue; |
|
97 } |
|
98 |
|
99 |
|
100 // --------------------------------------------------------- |
|
101 // CSatUiTextQueryDialog::PostLayoutDynInitL |
|
102 // Checks if min length was 0 and shows the OK key |
|
103 // (other items were commented in a header). |
|
104 // --------------------------------------------------------- |
|
105 // |
|
106 void CSatUiTextQueryDialog::PostLayoutDynInitL() |
|
107 { |
|
108 TFLOGSTRING( "CSatUiTextQueryDialog::PostLayoutDynInitL calling" ) |
|
109 CAknTextQueryDialog::PostLayoutDynInitL(); |
|
110 if ( iTextMinLength == 0 ) |
|
111 { |
|
112 TFLOGSTRING( "CSatUiTextQueryDialog::PostLayoutDynInitL \ |
|
113 reveal softkey" ) |
|
114 // Reveal both left and middle softkey |
|
115 ButtonGroupContainer().MakeCommandVisibleByPosition( |
|
116 CEikButtonGroupContainer::ELeftSoftkeyPosition, ETrue ); |
|
117 ButtonGroupContainer().MakeCommandVisibleByPosition( |
|
118 CEikButtonGroupContainer::EMiddleSoftkeyPosition, ETrue ); |
|
119 } |
|
120 TFLOGSTRING( "CSatUiTextQueryDialog::PostLayoutDynInitL exiting" ) |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------- |
|
124 // CSatUiTextQueryDialog::PreLayoutDynInitL |
|
125 // Initializations needed to accept sathidden keymap |
|
126 // (other items were commented in a header). |
|
127 // --------------------------------------------------------- |
|
128 // |
|
129 void CSatUiTextQueryDialog::PreLayoutDynInitL() |
|
130 { |
|
131 TFLOGSTRING( "CSatUiTextQueryDialog::PreLayoutDynInitL calling" ) |
|
132 CAknTextQueryDialog::PreLayoutDynInitL(); |
|
133 |
|
134 // Get KFeatureIdAvkonApac value |
|
135 FeatureManager::InitializeLibL(); |
|
136 |
|
137 TBool isApac( FeatureManager::FeatureSupported( KFeatureIdAvkonApac ) ); |
|
138 |
|
139 FeatureManager::UnInitializeLib(); |
|
140 |
|
141 CAknQueryControl* control = QueryControl(); |
|
142 |
|
143 if ( control ) |
|
144 { |
|
145 CCoeControl* controlByLayout = NULL; |
|
146 |
|
147 if ( EPinLayout == control->QueryType() ) |
|
148 { |
|
149 TFLOGSTRING( "CSatUiTextQueryDialog::PreLayoutDynInitL \ |
|
150 EPinLayout" ) |
|
151 controlByLayout = |
|
152 QueryControl()->ControlByLayoutOrNull( EPinLayout ); |
|
153 if ( controlByLayout ) |
|
154 { |
|
155 TFLOGSTRING( "CSatUiTextQueryDialog::PreLayoutDynInitL \ |
|
156 controlByLayout" ) |
|
157 CEikSecretEditor* editor = |
|
158 ( CEikSecretEditor* ) controlByLayout; |
|
159 CAknEdwinState* editorState = new(ELeave) CAknEdwinState(); |
|
160 |
|
161 editorState->SetFlags( |
|
162 EAknEditorFlagNoLRNavigation | EAknEditorFlagNoT9 ); |
|
163 editorState->SetDefaultInputMode( EAknEditorNumericInputMode ); |
|
164 editorState->SetCurrentInputMode( EAknEditorNumericInputMode ); |
|
165 editorState->SetPermittedInputModes( |
|
166 EAknEditorNumericInputMode ); |
|
167 editorState->SetDefaultCase( EAknEditorLowerCase ); |
|
168 editorState->SetCurrentCase( EAknEditorLowerCase ); |
|
169 editorState->SetPermittedCases( |
|
170 EAknEditorLowerCase|EAknEditorUpperCase ); |
|
171 editorState->SetSpecialCharacterTableResourceId( 0 ); |
|
172 editorState->SetNumericKeymap( |
|
173 EAknEditorSATHiddenNumberModeKeymap ); |
|
174 editorState->SetObjectProvider( editor ); |
|
175 |
|
176 // ............... |
|
177 MCoeFepAwareTextEditor_Extension1 *ext |
|
178 = ( MCoeFepAwareTextEditor_Extension1* )editor; |
|
179 CleanupStack::PushL( ext ); |
|
180 CleanupStack::PushL( editorState ); |
|
181 ext->SetStateTransferingOwnershipL( editorState, KNullUid ); |
|
182 CleanupStack::Pop( editorState ); // editorState |
|
183 CleanupStack::Pop( ext ); // ext |
|
184 } |
|
185 } |
|
186 else if ( EDataLayout == control->QueryType() ) |
|
187 { |
|
188 TFLOGSTRING( "CSatUiTextQueryDialog::PreLayoutDynInitL \ |
|
189 EDataLayout" ) |
|
190 controlByLayout = |
|
191 QueryControl()->ControlByLayoutOrNull( EDataLayout ); |
|
192 if ( controlByLayout ) |
|
193 { |
|
194 CEikEdwin* editor = ( CEikEdwin* ) controlByLayout; |
|
195 if ( !isApac ) |
|
196 { |
|
197 if ( KSatMinTextLengthForT9 >= iTextMaxLength ) |
|
198 { |
|
199 editor->SetAknEditorFlags( EAknEditorFlagNoT9 ); |
|
200 } |
|
201 editor->AddFlagToUserFlags( EEikEdwinNoHorizScrolling ); |
|
202 editor->AddFlagToUserFlags( EEikEdwinResizable ); |
|
203 editor->SetAknEditorInputMode( EAknEditorTextInputMode ); |
|
204 editor->SetAknEditorAllowedInputModes( |
|
205 EAknEditorTextInputMode ); |
|
206 } |
|
207 else |
|
208 { |
|
209 TFLOGSTRING( "CSatUiTextQueryDialog::PreLayoutDynInitL \ |
|
210 isApac ETrue" ) |
|
211 if ( KSatMinTextLengthForT9 >= iTextMaxLength ) |
|
212 { |
|
213 editor->SetAknEditorFlags( EAknEditorFlagNoT9 ); |
|
214 } |
|
215 else |
|
216 { |
|
217 editor->SetAknEditorFlags( 0 ); |
|
218 } |
|
219 } |
|
220 } |
|
221 } |
|
222 else if ( EPhoneLayout == control->QueryType() ) |
|
223 { |
|
224 TFLOGSTRING( "CSatUiTextQueryDialog::PreLayoutDynInitL \ |
|
225 EPhoneLayout" ) |
|
226 controlByLayout = |
|
227 QueryControl()->ControlByLayoutOrNull( EPhoneLayout ); |
|
228 if ( controlByLayout ) |
|
229 { |
|
230 CEikEdwin* editor = ( CEikEdwin* ) controlByLayout; |
|
231 |
|
232 if ( !isApac ) |
|
233 { |
|
234 editor->AddFlagToUserFlags( EEikEdwinNoHorizScrolling ); |
|
235 editor->AddFlagToUserFlags( EEikEdwinResizable ); |
|
236 editor->AddFlagToUserFlags( EEikEdwinAlternativeWrapping ); |
|
237 } |
|
238 else |
|
239 { |
|
240 TFLOGSTRING( "CSatUiTextQueryDialog::PreLayoutDynInitL \ |
|
241 isApac ETrue" ) |
|
242 editor->SetAknEditorFlags( 0 ); |
|
243 } |
|
244 } |
|
245 } |
|
246 } |
|
247 TFLOGSTRING( "CSatUiTextQueryDialog::PreLayoutDynInitL exiting" ) |
|
248 } |
|
249 |
|
250 // --------------------------------------------------------- |
|
251 // CSatUiTextQueryDialog::NeedToDismissQueryL |
|
252 // Checks for hash key (workaround) |
|
253 // (other items were commented in a header). |
|
254 // --------------------------------------------------------- |
|
255 // |
|
256 TBool CSatUiTextQueryDialog::NeedToDismissQueryL( const TKeyEvent& /* aKeyEvent */ ) |
|
257 { |
|
258 TFLOGSTRING( "CSatUiTextQueryDialog::NeedToDismissQueryL calling-exiting" ) |
|
259 return EFalse; |
|
260 } |
|
261 |
|
262 // --------------------------------------------------------- |
|
263 // CSatUiTextQueryDialog::OfferKeyEventL |
|
264 // Hash key accepted (workaround) |
|
265 // (other items were commented in a header). |
|
266 // --------------------------------------------------------- |
|
267 // |
|
268 TKeyResponse CSatUiTextQueryDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
269 TEventCode aType ) |
|
270 { |
|
271 TFLOGSTRING( "CSatUiTextQueryDialog::OfferKeyEventL calling" ) |
|
272 TKeyEvent keyEvent = aKeyEvent; |
|
273 if ( aKeyEvent.iScanCode == EStdKeyHash && aType==EEventKey ) |
|
274 { |
|
275 keyEvent.iScanCode = 0; |
|
276 } |
|
277 |
|
278 TFLOGSTRING( "CSatUiTextQueryDialog::OfferKeyEventL exiting" ) |
|
279 return CAknTextQueryDialog::OfferKeyEventL( keyEvent, aType ); |
|
280 } |
|
281 |
|
282 |
|
283 // End of File |