1 /* |
|
2 * Copyright (c) 2005 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: Provides Blid request view class methods. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <aknlists.h> |
|
21 #include <aknViewAppUi.h> |
|
22 #include <akntextsettingpage.h> |
|
23 #include <Blid.rsg> |
|
24 #include <aknradiobuttonsettingpage.h> |
|
25 #include <sysutil.h> |
|
26 #include <driveinfo.h> |
|
27 #include <CFLDFileListContainer.h> |
|
28 #include <aknnotedialog.h> |
|
29 |
|
30 #include "CBlidSettingsView.h" |
|
31 #include "Blid.hrh" |
|
32 #include "CBlidSettingsContainer.h" |
|
33 #include "CBlidDocument.h" |
|
34 #include "CBlidEng.h" |
|
35 #include "MBlidSettings.h" |
|
36 #include "bliduiconsts.h" |
|
37 #include "Blidutils.h" |
|
38 #include "CBlidAppUi.h" |
|
39 |
|
40 // CONSTANTS |
|
41 enum TPanicCode |
|
42 { |
|
43 KBlidNullPointer = 1 |
|
44 }; |
|
45 |
|
46 |
|
47 // ================= MEMBER FUNCTIONS ======================= |
|
48 // --------------------------------------------------------- |
|
49 // CBlidSettingsView::NewLC |
|
50 // --------------------------------------------------------- |
|
51 // |
|
52 CBlidSettingsView* CBlidSettingsView::NewLC( MKeyProcessor& aKeyProcessor ) |
|
53 { |
|
54 CBlidSettingsView* self = new (ELeave) CBlidSettingsView( aKeyProcessor ); |
|
55 CleanupStack::PushL( self ); |
|
56 self->ConstructL(); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------- |
|
61 // CBlidSettingsView::CBlidSettingsView |
|
62 // --------------------------------------------------------- |
|
63 // |
|
64 CBlidSettingsView::CBlidSettingsView( MKeyProcessor& aKeyProcessor ): |
|
65 CBlidBaseView( aKeyProcessor ) |
|
66 { |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // CBlidSettingsView::ConstructL |
|
71 // Symbian two-phased constructor |
|
72 // --------------------------------------------------------- |
|
73 // |
|
74 void CBlidSettingsView::ConstructL() |
|
75 { |
|
76 CBlidEng* eng = static_cast<CBlidDocument*>(AppUi()->Document())->Engine(); |
|
77 BaseConstructL( R_BLID_SETTINGS_VIEW ); |
|
78 iLocale = new(ELeave)TLocale(); |
|
79 |
|
80 eng->CreateModelL( CBlidEng::EBlidSettings ); |
|
81 iSettingsModel = eng->SettingsModel(); |
|
82 __ASSERT_DEBUG(iSettingsModel,User::Panic(_L("CBlidMainView"), |
|
83 KBlidNullPointer)); |
|
84 iBlidBacklightNormal = iCoeEnv->AllocReadResourceL( |
|
85 R_BLID_BACKLIGHT_NORMAL); |
|
86 iBlidBacklightOn = iCoeEnv->AllocReadResourceL( |
|
87 R_BLID_BACKLIGHT_ON); |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------- |
|
91 // CBlidSettingsView::~CBlidSettingsView |
|
92 // --------------------------------------------------------- |
|
93 // |
|
94 CBlidSettingsView::~CBlidSettingsView() |
|
95 { |
|
96 if ( iContainer ) |
|
97 { |
|
98 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
99 } |
|
100 |
|
101 delete iContainer; |
|
102 delete iLocale; |
|
103 delete iBlidBacklightNormal; |
|
104 delete iBlidBacklightOn; |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------- |
|
108 // CBlidSettingsView::Id |
|
109 // --------------------------------------------------------- |
|
110 // |
|
111 TUid CBlidSettingsView::Id() const |
|
112 { |
|
113 return TUid::Uid(EBlidSettingsView); |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------- |
|
117 // CBlidSettingsView::HandleCommandL |
|
118 // --------------------------------------------------------- |
|
119 // |
|
120 void CBlidSettingsView::HandleCommandL(TInt aCommand) |
|
121 { |
|
122 switch (aCommand) |
|
123 { |
|
124 case EBlidCmdChangeSetting: |
|
125 case EBlidCmdResetSetting: |
|
126 { |
|
127 // Get the index in location functionality settings view |
|
128 TInt indexLocationSetting=iContainer->ListBox()->CurrentItemIndex(); |
|
129 switch( indexLocationSetting ) |
|
130 { |
|
131 case EBlidSettingsCalibration: |
|
132 { |
|
133 ChangeAltitudeCalibrationL(); |
|
134 break; |
|
135 } |
|
136 case EBlidSettingsBacklight: |
|
137 { |
|
138 ChangeBacklightSettingsL(); |
|
139 break; |
|
140 } |
|
141 case EBlidSettingsArrivalTone: |
|
142 { |
|
143 OpenArrivalToneDialogL(); |
|
144 break; |
|
145 } |
|
146 case EBlidSettingsResetOdometer: |
|
147 { |
|
148 CheckResetOdometerOptionL(); |
|
149 break; |
|
150 } |
|
151 default: |
|
152 { |
|
153 User::Leave( KErrBadHandle ); |
|
154 break; |
|
155 } |
|
156 } |
|
157 break; |
|
158 } |
|
159 case EBlidCmdMskChangeSetting: |
|
160 case EBlidCmdMskResetSetting: |
|
161 { |
|
162 // Get the index in location functionality settings view |
|
163 TInt indexLocationSetting=iContainer->ListBox()->CurrentItemIndex(); |
|
164 switch( indexLocationSetting ) |
|
165 { |
|
166 case EBlidSettingsCalibration: |
|
167 { |
|
168 ChangeAltitudeCalibrationL(); |
|
169 break; |
|
170 } |
|
171 case EBlidSettingsBacklight: |
|
172 { |
|
173 if ( iSettingsModel->GetBacklightOption() == EBlidBackLightNormal ) |
|
174 { |
|
175 ChangeBacklightSettingsValueL(EBlidBackLightOnDuringNavigation); |
|
176 } |
|
177 else |
|
178 { |
|
179 ChangeBacklightSettingsValueL(EBlidBackLightNormal); |
|
180 } |
|
181 break; |
|
182 } |
|
183 case EBlidSettingsArrivalTone: |
|
184 { |
|
185 OpenArrivalToneDialogL(); |
|
186 break; |
|
187 } |
|
188 case EBlidSettingsResetOdometer: |
|
189 { |
|
190 CheckResetOdometerOptionL(); |
|
191 break; |
|
192 } |
|
193 default: |
|
194 { |
|
195 User::Leave( KErrBadHandle ); |
|
196 break; |
|
197 } |
|
198 } |
|
199 break; |
|
200 } |
|
201 case EBlidSettingsArrivalTone: |
|
202 { |
|
203 OpenArrivalToneDialogL(); |
|
204 break; |
|
205 } |
|
206 case EBlidSettingsResetOdometer: |
|
207 { |
|
208 CheckResetOdometerOptionL(); |
|
209 break; |
|
210 } |
|
211 case EBlidSettingsCalibration: |
|
212 { |
|
213 ChangeAltitudeCalibrationL(); |
|
214 break; |
|
215 } |
|
216 case EAknSoftkeyBack: |
|
217 { |
|
218 AppUi()->ActivateLocalViewL(TUid::Uid(iPrevViewId) ); |
|
219 break; |
|
220 } |
|
221 default: |
|
222 { |
|
223 static_cast<CBlidAppUi*>(AppUi())->HandleCommandL( aCommand ); |
|
224 break; |
|
225 } |
|
226 }// switch |
|
227 } |
|
228 |
|
229 // --------------------------------------------------------- |
|
230 // CBlidSettingsView::DynInitMenuPaneL |
|
231 // --------------------------------------------------------- |
|
232 // |
|
233 void CBlidSettingsView::DynInitMenuPaneL( TInt aResourceId, |
|
234 CEikMenuPane* aMenuPane ) |
|
235 { |
|
236 switch( aResourceId ) |
|
237 { |
|
238 case R_BLID_MAIN_MENU: |
|
239 { |
|
240 CBlidBaseView::HandleHelpFeature( aMenuPane ); |
|
241 break; |
|
242 } |
|
243 case R_BLID_SETTINGS_MENU: |
|
244 { |
|
245 // Get the index in location functionality settings view |
|
246 TInt indexLocationSetting= |
|
247 iContainer->ListBox()->CurrentItemIndex(); |
|
248 switch( indexLocationSetting ) |
|
249 { |
|
250 case EBlidSettingsResetOdometer: |
|
251 { |
|
252 aMenuPane->SetItemDimmed( EBlidCmdChangeSetting, ETrue ); |
|
253 break; |
|
254 } |
|
255 // Other values are not accepted. |
|
256 default: |
|
257 { |
|
258 aMenuPane->SetItemDimmed( EBlidCmdResetSetting, ETrue ); |
|
259 break; |
|
260 } |
|
261 } |
|
262 break; |
|
263 } |
|
264 default: |
|
265 { |
|
266 break; |
|
267 } |
|
268 } |
|
269 } |
|
270 |
|
271 // --------------------------------------------------------- |
|
272 // CBlidSettingsView::ProcessKeyEventL |
|
273 // --------------------------------------------------------- |
|
274 // |
|
275 TBool CBlidSettingsView::ProcessKeyEventL( const TKeyEvent& aKeyEvent, |
|
276 TEventCode aType ) |
|
277 { |
|
278 if( (aType == EEventKey) ) |
|
279 { |
|
280 if ( aKeyEvent.iCode == EKeyOK ) |
|
281 { |
|
282 // Get the index in location functionality settings view |
|
283 TInt indexLocationSetting= |
|
284 iContainer->ListBox()->CurrentItemIndex(); |
|
285 switch( indexLocationSetting ) |
|
286 { |
|
287 case EBlidSettingsCalibration: |
|
288 { |
|
289 HandleCommandL( EBlidSettingsCalibration ); |
|
290 break; |
|
291 } |
|
292 // Other values are not accepted. |
|
293 default: |
|
294 { |
|
295 break; |
|
296 } |
|
297 } |
|
298 return ETrue; |
|
299 } |
|
300 } |
|
301 |
|
302 return CBlidBaseView::ProcessKeyEventL( aKeyEvent,aType ); |
|
303 } |
|
304 |
|
305 // --------------------------------------------------------- |
|
306 // CBlidSettingsView::DoActivateL |
|
307 // --------------------------------------------------------- |
|
308 // |
|
309 void CBlidSettingsView::DoActivateL( |
|
310 const TVwsViewId& aPrevViewId,TUid /*aCustomMessageId*/, |
|
311 const TDesC8& /*aCustomMessage*/) |
|
312 { |
|
313 iPrevViewId = aPrevViewId.iViewUid.iUid; |
|
314 if (!iContainer) |
|
315 { |
|
316 iContainer = CBlidSettingsContainer::NewL(*this, this, ClientRect(), |
|
317 iSettingsModel, *this); |
|
318 AppUi()->AddToStackL( *this, iContainer ); |
|
319 SetMiddleSoftKeyLabelL(R_BLID_MSK_CHANGE,EBlidCmdMskChangeSetting); |
|
320 |
|
321 #ifdef RD_SCALABLE_UI_V2 |
|
322 iContainer->SetListBoxObserver(this); |
|
323 #endif //RD_SCALABLE_UI_V2 |
|
324 } |
|
325 } |
|
326 |
|
327 // --------------------------------------------------------- |
|
328 // CBlidSettingsView::DoDeactivate |
|
329 // --------------------------------------------------------- |
|
330 // |
|
331 void CBlidSettingsView::DoDeactivate() |
|
332 { |
|
333 if ( iContainer ) |
|
334 { |
|
335 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
336 } |
|
337 |
|
338 delete iContainer; |
|
339 iContainer = NULL; |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------- |
|
343 // CBlidSettingsView::ChangeAltitudeCalibrationL |
|
344 // --------------------------------------------------------- |
|
345 // |
|
346 void CBlidSettingsView::ChangeAltitudeCalibrationL() |
|
347 { |
|
348 TInt AltCalibration( 0 ); |
|
349 TInt error(0); |
|
350 TReal altitude( iSettingsModel->AltCalibration() ); |
|
351 if ( iSettingsModel->UnitOfMeasurement() != EUnitsMetric ) |
|
352 { |
|
353 altitude *= KMetreToFoot; |
|
354 } |
|
355 |
|
356 error = BlidUtils::TRealToTInt( altitude, AltCalibration ); |
|
357 User::LeaveIfError( error ); |
|
358 |
|
359 /*CBlidSettingsPage* dlg = new ( ELeave ) |
|
360 CBlidSettingsPage( *(AppUi()->EventMonitor()), |
|
361 R_BLID_ALTITUDE_CALIBRATION_SETTINGS_PAGE, AltCalibration );*/ |
|
362 |
|
363 TInt resourceId; |
|
364 if(iSettingsModel->UnitOfMeasurement() == EUnitsMetric) |
|
365 { |
|
366 resourceId = R_BLID_ALTITUDE_CALIBRATION_METRIC_SETTINGS_PAGE; |
|
367 } |
|
368 else |
|
369 { |
|
370 resourceId = R_BLID_ALTITUDE_CALIBRATION_IMPERIAL_SETTINGS_PAGE; |
|
371 } |
|
372 |
|
373 CAknIntegerSettingPage* dlg = new (ELeave) |
|
374 CAknIntegerSettingPage(resourceId, |
|
375 AltCalibration, |
|
376 0); |
|
377 |
|
378 if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) ) |
|
379 { |
|
380 RFs fs; |
|
381 User::LeaveIfError(fs.Connect()); |
|
382 CleanupClosePushL( fs ); |
|
383 |
|
384 if ( SysUtil::DiskSpaceBelowCriticalLevelL( &fs, 0, DriveInfo::EDefaultPhoneMemory ) ) |
|
385 { |
|
386 BlidNotes::OutOfMemoryNoteL(); |
|
387 } |
|
388 else |
|
389 { |
|
390 TReal32 newCalibration = static_cast<TReal32>(AltCalibration); |
|
391 |
|
392 if ( iSettingsModel->UnitOfMeasurement() != EUnitsMetric ) |
|
393 { |
|
394 newCalibration /= static_cast<TReal32>(KMetreToFoot); |
|
395 } |
|
396 iSettingsModel->SetAltCalibration(newCalibration); |
|
397 iContainer->DrawNow(); |
|
398 } |
|
399 CleanupStack::PopAndDestroy(); //fs |
|
400 } |
|
401 } |
|
402 |
|
403 // ----------------------------------------------------------------------------- |
|
404 // CBlidSettingsView::ChangeBacklightSettingsL |
|
405 // Change the backlight option in between Normal/On During Navigation |
|
406 // ----------------------------------------------------------------------------- |
|
407 // |
|
408 void CBlidSettingsView::ChangeBacklightSettingsL() |
|
409 { |
|
410 // number of options in query |
|
411 CDesCArrayFlat* items = |
|
412 new( ELeave ) CDesCArrayFlat( 2 ); |
|
413 CleanupStack::PushL( items ); |
|
414 items->AppendL( *(iBlidBacklightNormal) ); |
|
415 items->AppendL( *(iBlidBacklightOn )); |
|
416 |
|
417 TInt indexForNewValue; |
|
418 if ( iSettingsModel->GetBacklightOption() == EBlidBackLightNormal ) |
|
419 { |
|
420 indexForNewValue = 0; |
|
421 } |
|
422 else |
|
423 { |
|
424 indexForNewValue = 1; |
|
425 } |
|
426 CAknRadioButtonSettingPage* dlg = new ( ELeave ) |
|
427 CAknRadioButtonSettingPage( R_BLID_SETTINGS_BACKLIGHT_PAGE, |
|
428 indexForNewValue, |
|
429 items ); |
|
430 if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) ) |
|
431 { |
|
432 RFs fs; |
|
433 User::LeaveIfError(fs.Connect()); |
|
434 CleanupClosePushL( fs ); |
|
435 |
|
436 if ( SysUtil::DiskSpaceBelowCriticalLevelL( &fs, 0, DriveInfo::EDefaultPhoneMemory ) ) |
|
437 { |
|
438 BlidNotes::OutOfMemoryNoteL(); |
|
439 } |
|
440 else |
|
441 { |
|
442 // Change value if a new value given in radio button page. |
|
443 iSettingsModel->SetBacklightOption(indexForNewValue); |
|
444 iContainer->DrawNow(); |
|
445 } |
|
446 CleanupStack::PopAndDestroy();// fs |
|
447 } |
|
448 CleanupStack::PopAndDestroy(); // items |
|
449 } |
|
450 |
|
451 |
|
452 // --------------------------------------------------------------------------- |
|
453 // CBlidSettingsView::ChangeBacklightSettingsValue |
|
454 // --------------------------------------------------------------------------- |
|
455 // |
|
456 void CBlidSettingsView::ChangeBacklightSettingsValueL(TInt aValue) |
|
457 { |
|
458 RFs fs; |
|
459 User::LeaveIfError(fs.Connect()); |
|
460 CleanupClosePushL( fs ); |
|
461 |
|
462 if ( SysUtil::DiskSpaceBelowCriticalLevelL( &fs, 0, DriveInfo::EDefaultPhoneMemory ) ) |
|
463 { |
|
464 BlidNotes::OutOfMemoryNoteL(); |
|
465 } |
|
466 else |
|
467 { |
|
468 // Change value if a new value given in radio button page. |
|
469 iSettingsModel->SetBacklightOption(aValue); |
|
470 iContainer->DrawNow(); |
|
471 } |
|
472 CleanupStack::PopAndDestroy();// fs |
|
473 } |
|
474 |
|
475 // --------------------------------------------------------------------------- |
|
476 // CBlidSettingsView::OpenArrivalToneDialogL |
|
477 // --------------------------------------------------------------------------- |
|
478 // |
|
479 void CBlidSettingsView::OpenArrivalToneDialogL( ) |
|
480 { |
|
481 TFileName iToneFile; |
|
482 // Create instance of FileList using new FileList API |
|
483 CFLDFileListContainer* filelist = CFLDFileListContainer::NewLC(); |
|
484 |
|
485 filelist->InsertEndNullItemL( _L( "Off" ) ); |
|
486 // Do not show videos, use new FileList API |
|
487 filelist->AddExclusiveMediaTypeL( ECLFMediaTypeVideo ); |
|
488 |
|
489 if( iSettingsModel->GetArrivedToneName().Length() > 0 ) |
|
490 { |
|
491 iToneFile.Copy( iSettingsModel->GetArrivedToneName() ); |
|
492 } |
|
493 |
|
494 TBool ok( filelist->LaunchL( iToneFile ) ); |
|
495 |
|
496 if( ok ) |
|
497 { |
|
498 HBufC8* lFileName = HBufC8::NewLC( iToneFile.Length() + 1 ); |
|
499 lFileName->Des().Copy( iToneFile ); |
|
500 // Change value if a new value given in radio button page. |
|
501 iSettingsModel->SetArrivedToneName( *lFileName ); |
|
502 iContainer->DrawNow(); |
|
503 CleanupStack::PopAndDestroy( lFileName ); |
|
504 } |
|
505 |
|
506 CleanupStack::PopAndDestroy( filelist ); // filelist |
|
507 } |
|
508 |
|
509 // --------------------------------------------------------------------------- |
|
510 // CBlidSettingsView::CheckResetOdometerOptionL |
|
511 // --------------------------------------------------------------------------- |
|
512 // |
|
513 void CBlidSettingsView::CheckResetOdometerOptionL( ) |
|
514 { |
|
515 CAknNoteDialog* dlg; |
|
516 dlg = new (ELeave) CAknNoteDialog(CAknNoteDialog::EConfirmationTone,CAknNoteDialog::ENoTimeout); |
|
517 TBool result = dlg->ExecuteLD( R_SETTINGS_ODOMETER_RESET_CONFIRMATION_NOTE ); |
|
518 if( result ) |
|
519 { |
|
520 // Change value if a new value given in radio button page. |
|
521 iSettingsModel->SetResetOdometerOption( result ); |
|
522 static_cast<CBlidAppUi*>(AppUi())->ResetOdoMeterValueL( ); |
|
523 iContainer->DrawNow(); |
|
524 } |
|
525 dlg = NULL; |
|
526 } |
|
527 |
|
528 #ifdef RD_SCALABLE_UI_V2 |
|
529 // --------------------------------------------------------------------------- |
|
530 // CBlidSettingsView::HandleListBoxSelectionL |
|
531 // --------------------------------------------------------------------------- |
|
532 // |
|
533 void CBlidSettingsView::HandleListBoxSelectionL() |
|
534 { |
|
535 // Get the index in location functionality settings view |
|
536 TInt indexLocationSetting=iContainer->ListBox()->CurrentItemIndex(); |
|
537 switch( indexLocationSetting ) |
|
538 { |
|
539 case EBlidSettingsCalibration: |
|
540 { |
|
541 ChangeAltitudeCalibrationL(); |
|
542 break; |
|
543 } |
|
544 case EBlidSettingsBacklight: |
|
545 { |
|
546 if ( iSettingsModel->GetBacklightOption() == EBlidBackLightNormal ) |
|
547 { |
|
548 ChangeBacklightSettingsValueL(EBlidBackLightOnDuringNavigation); |
|
549 } |
|
550 else |
|
551 { |
|
552 ChangeBacklightSettingsValueL(EBlidBackLightNormal); |
|
553 } |
|
554 break; |
|
555 } |
|
556 case EBlidSettingsArrivalTone: |
|
557 { |
|
558 OpenArrivalToneDialogL(); |
|
559 break; |
|
560 } |
|
561 case EBlidSettingsResetOdometer: |
|
562 { |
|
563 CheckResetOdometerOptionL(); |
|
564 break; |
|
565 } |
|
566 default: |
|
567 { |
|
568 User::Leave( KErrBadHandle ); |
|
569 break; |
|
570 } |
|
571 } |
|
572 } |
|
573 |
|
574 #endif //RD_SCALABLE_UI_V2 |
|
575 |
|
576 // End of File |
|