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: Implementation of the class CFMRadioMainContainer |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include <alf/alfcontrolgroup.h> |
|
22 #include <alf/alfdisplay.h> |
|
23 #include <alf/alfroster.h> |
|
24 #include <alf/alflayoutmetrics.h> |
|
25 #include <AknLayoutFont.h> |
|
26 #include <aknlayoutscalable_apps.cdl.h> |
|
27 #include <AknsBasicBackgroundControlContext.h> |
|
28 #include <AknsDrawUtils.h> |
|
29 #include <AknsSkinInstance.h> |
|
30 #include <AknsUtils.h> |
|
31 #include <aknconsts.h> |
|
32 #include <AknDef.h> |
|
33 #include <StringLoader.h> |
|
34 #include <barsread.h> |
|
35 #include <w32std.h> |
|
36 #include <e32base.h> |
|
37 #include <fontids.hrh> |
|
38 #include <gulfont.h> |
|
39 #include <fmradio.rsg> |
|
40 #include <fmradiouids.h> |
|
41 |
|
42 #include "fmradiomaincontainer.h" |
|
43 #if defined __SERIES60_HELP || defined FF_S60_HELPS_IN_USE |
|
44 #include "radio.hlp.hrh" |
|
45 #endif |
|
46 #include "fmradioengine.h" |
|
47 #include "fmradioalfrdsviewer.h" |
|
48 #include "fmradioalfvisualizer.h" |
|
49 #include "fmradioalfmediaidle.h" |
|
50 #include "fmradioalfindicator.h" |
|
51 #include "fmradiologo.h" |
|
52 #include "fmradiordsreceiverbase.h" |
|
53 #include "fmradioalfrdsviewer.h" |
|
54 #include "fmradiomainview.h" |
|
55 #include "fmradioidlecontroller.h" |
|
56 #include "debug.h" |
|
57 |
|
58 |
|
59 // ~3 seconds, 10 frames / second is used |
|
60 const TInt KFadeFrames = 30; |
|
61 const TInt KTenMilliSecondsInMicroSeconds = 100000; |
|
62 // values from fmradio LAF document |
|
63 const TInt KLAFVarietyRDSViewerPortrait = 0; |
|
64 const TInt KLAFVarietyRDSViewerLandscape = 1; |
|
65 const TInt KLAFVarietyRDSPlusIndicatorPortrait = 0; |
|
66 const TInt KLAFVarietyRDSPlusIndicatorLandscape = 1; |
|
67 const TInt KLAFVarietyAFIndicatorPortrait = 0; |
|
68 const TInt KLAFVarietyAFIndicatorLandscape = 1; |
|
69 const TInt KLAFVarietyRDSIndicatorPortrait = 0; |
|
70 const TInt KLAFVarietyRDSIndicatorLandscape = 1; |
|
71 const TInt KLAFVarietyLogoImagePortrait = 0; |
|
72 const TInt KLAFVarietyLogoImageLandscape = 1; |
|
73 const TInt KLAFVarietyIndicatorPanePortrait = 0; |
|
74 const TInt KLAFVarietyIndicatorPaneLandscape = 1; |
|
75 const TInt KLAFVarietyVisualPanePortrait = 0; |
|
76 const TInt KLAFVarietyVisualPaneLandscape = 1; |
|
77 |
|
78 // ================= MEMBER FUNCTIONS ======================= |
|
79 |
|
80 // --------------------------------------------------------------------------------- |
|
81 // CFMRadioTimer::CFMRadioTimer |
|
82 // --------------------------------------------------------------------------------- |
|
83 CFMRadioTimer::CFMRadioTimer( MFMRadioTimer* aTimerObserver ) : |
|
84 CActive( EPriorityStandard ), |
|
85 iTimerObserver( aTimerObserver ) |
|
86 { |
|
87 CActiveScheduler::Add( this ); |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------------- |
|
91 // CFMRadioTimer::~CFMRadioTimer |
|
92 // --------------------------------------------------------------------------------- |
|
93 CFMRadioTimer::~CFMRadioTimer() |
|
94 { |
|
95 |
|
96 Cancel(); |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------------- |
|
100 // CFMRadioTimer::RunL |
|
101 // --------------------------------------------------------------------------------- |
|
102 void CFMRadioTimer::RunL() |
|
103 { |
|
104 |
|
105 iTimerObserver->TimerTimeOut( iStatus.Int() ); |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------------------------------- |
|
109 // CFMRadioTimer::DoCancel |
|
110 // --------------------------------------------------------------------------------- |
|
111 void CFMRadioTimer::DoCancel() |
|
112 { |
|
113 |
|
114 TInt ret = KErrCancel; |
|
115 iTimerObserver->TimerTimeOut( ret ); |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------------------------------- |
|
119 // CFMRadioTimer::Activate |
|
120 // --------------------------------------------------------------------------------- |
|
121 void CFMRadioTimer::Activate() |
|
122 { |
|
123 SetActive(); |
|
124 } |
|
125 |
|
126 |
|
127 // -------------------------------------------------------------------------------- |
|
128 // CFMRadioMainContainer::NewL |
|
129 // Two-phase constructor of CFMRadioDelayTimer |
|
130 // -------------------------------------------------------------------------------- |
|
131 // |
|
132 CFMRadioMainContainer* CFMRadioMainContainer::NewL( |
|
133 const TRect& aRect, |
|
134 CAlfEnv& aAlfEnv, |
|
135 CRadioEngine& aRadioEngine ) |
|
136 { |
|
137 CFMRadioMainContainer* self = new (ELeave) CFMRadioMainContainer( aAlfEnv, aRadioEngine ); |
|
138 CleanupStack::PushL( self ); |
|
139 self->ConstructL( aRect ); |
|
140 CleanupStack::Pop( self ); |
|
141 return self; |
|
142 } |
|
143 |
|
144 // -------------------------------------------------------------------------------- |
|
145 // CFMRadioMainContainer::CFMRadioMainContainer |
|
146 // Default constructor |
|
147 // -------------------------------------------------------------------------------- |
|
148 // |
|
149 CFMRadioMainContainer::CFMRadioMainContainer( CAlfEnv& aAlfEnv, CRadioEngine& aRadioEngine ) : |
|
150 iAlfEnv ( aAlfEnv ), |
|
151 iRadioEngine (aRadioEngine ), |
|
152 iLightsOffCounter(0) |
|
153 { |
|
154 //No implementation needed |
|
155 } |
|
156 |
|
157 // -------------------------------------------------------------------------------- |
|
158 // CFMRadioMainContainer::ConstructL |
|
159 // EPOC two phased constructor |
|
160 // -------------------------------------------------------------------------------- |
|
161 // |
|
162 void CFMRadioMainContainer::ConstructL( |
|
163 const TRect& aRect ) |
|
164 { |
|
165 iCoeEnv = CCoeEnv::Static(); |
|
166 |
|
167 TRAP_IGNORE( iLight = CHWRMLight::NewL(this) ); |
|
168 iTimer = new(ELeave) CFMRadioTimer( this ); |
|
169 timer.CreateLocal(); |
|
170 |
|
171 // check the layout orientation |
|
172 CFMRadioAppUi* appUi = static_cast<CFMRadioAppUi*>( iCoeEnv->AppUi() ); |
|
173 TBool isLandscape = appUi->IsLandscapeOrientation(); |
|
174 |
|
175 TRgb color; |
|
176 |
|
177 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 ); |
|
178 //CreateWindowL(); // create a window for the container |
|
179 |
|
180 // Create alfred display |
|
181 CAlfDisplay* display = NULL; |
|
182 if ( iAlfEnv.DisplayCount() > 0 ) |
|
183 { |
|
184 display = &(iAlfEnv.PrimaryDisplay()); |
|
185 } |
|
186 else |
|
187 { |
|
188 display = &(iAlfEnv.NewDisplayL( aRect, CAlfEnv::ENewDisplayAsCoeControl )); |
|
189 } |
|
190 |
|
191 // Setup background. |
|
192 display->SetClearBackgroundL( CAlfDisplay::EClearWithSkinBackground ); |
|
193 |
|
194 // Create the control group for HUI visual controls |
|
195 CAlfControlGroup* group; |
|
196 if( display->Roster().Count() > 0) |
|
197 { |
|
198 group = &( iAlfEnv.ControlGroup( KFMRadioVisualControlsGroupId ) ); |
|
199 |
|
200 iVisualControl = static_cast<CFMRadioAlfVisualizer*> |
|
201 ( display->Roster().FindControl( KFMRadioVisualControlId ) ); |
|
202 iMediaIdle = static_cast<CFMRadioAlfMediaIdle*> |
|
203 ( display->Roster().FindControl( KFMRadioMediaIdleId ) ); |
|
204 iRdsIndicator = static_cast<CFMRadioAlfIndicator*> |
|
205 ( display->Roster().FindControl( KFMRadioRdsIndicatorId ) ); |
|
206 iRdsAfIndicator = static_cast<CFMRadioAlfIndicator*> |
|
207 ( display->Roster().FindControl( KFMRadioRdsAfIndicatorId ) ); |
|
208 iRdsViewer = static_cast<CFMRadioAlfRDSViewer*> |
|
209 ( display->Roster().FindControl( KFMRadioRdsViewer ) ); |
|
210 iRdsInteractionIndicator = static_cast<CFMRadioAlfIndicator*> |
|
211 ( display->Roster().FindControl( KFMRadioRdsInteractionIndicatorId ) ); |
|
212 |
|
213 iRadioLogo = static_cast<CFMRadioLogo*> |
|
214 ( display->Roster().FindControl( KFMRadioLogoId ) ); |
|
215 } |
|
216 else |
|
217 { |
|
218 group = &(iAlfEnv.NewControlGroupL( KFMRadioVisualControlsGroupId ) ); |
|
219 // Create the vizualizer control for information of the FMRadio |
|
220 iVisualControl = CFMRadioAlfVisualizer::NewL( iAlfEnv ); |
|
221 iVisualControl->SetId( KFMRadioVisualControlId ); |
|
222 // Create the media idle |
|
223 iMediaIdle = CFMRadioAlfMediaIdle::NewL( iAlfEnv ); |
|
224 iMediaIdle->SetId( KFMRadioMediaIdleId ); |
|
225 |
|
226 // RDS |
|
227 HBufC* rdsText = StringLoader::LoadLC( R_QTN_FMRADIO_RDS, iCoeEnv ); |
|
228 iRdsIndicator = CFMRadioAlfIndicator::NewL( iAlfEnv ); |
|
229 iRdsIndicator->SetId( KFMRadioRdsIndicatorId ); |
|
230 iRdsIndicator->SetTextColor( color ); |
|
231 iRdsIndicator->SetTextL( *rdsText ); |
|
232 iRdsIndicator->SetOpacityInHiddenState( KFMRadioIndicatorOpacityInHiddenState ); |
|
233 CleanupStack::PopAndDestroy( rdsText ); |
|
234 |
|
235 // AF |
|
236 HBufC* afText = StringLoader::LoadLC( R_QTN_FMRADIO_AF, iCoeEnv ); |
|
237 iRdsAfIndicator = CFMRadioAlfIndicator::NewL( iAlfEnv ); |
|
238 iRdsAfIndicator->SetId( KFMRadioRdsAfIndicatorId ); |
|
239 iRdsAfIndicator->SetTextColor( color ); |
|
240 iRdsAfIndicator->SetTextL( *afText ); |
|
241 iRdsAfIndicator->SetOpacityInHiddenState( KFMRadioIndicatorOpacityInHiddenState ); |
|
242 CleanupStack::PopAndDestroy( afText ); |
|
243 |
|
244 iRdsViewer = CFMRadioAlfRDSViewer::NewL( iAlfEnv ); |
|
245 iRdsViewer->SetId( KFMRadioRdsViewer ); |
|
246 iRdsViewer->SetTextColor( color ); |
|
247 iRdsViewer->SetOpacityInHiddenState( KFMRadioRdsViewerOpacityHidden ); |
|
248 |
|
249 // + |
|
250 HBufC* interactionText = StringLoader::LoadLC( R_QTN_FMRADIO_RTPLUS_INDICATOR_TEXT, iCoeEnv ); |
|
251 iRdsInteractionIndicator = CFMRadioAlfIndicator::NewL( iAlfEnv ); |
|
252 iRdsInteractionIndicator->SetId( KFMRadioRdsInteractionIndicatorId ); |
|
253 iRdsInteractionIndicator->SetTextColor( color ); |
|
254 iRdsInteractionIndicator->SetTextL( *interactionText ); |
|
255 iRdsInteractionIndicator->SetOpacityInHiddenState( KFMRadioIndicatorOpacityInHiddenState ); |
|
256 CleanupStack::PopAndDestroy( interactionText ); |
|
257 |
|
258 // radio icon |
|
259 iRadioLogo = CFMRadioLogo::NewL( iAlfEnv ); |
|
260 iRadioLogo->SetId( KFMRadioLogoId ); |
|
261 |
|
262 // Append the controls into the control group. |
|
263 group->AppendL( iMediaIdle ); |
|
264 group->AppendL( iRdsIndicator ); |
|
265 group->AppendL( iRdsAfIndicator ); |
|
266 group->AppendL( iRdsViewer ); |
|
267 group->AppendL( iRdsInteractionIndicator ); |
|
268 group->AppendL( iRadioLogo ); |
|
269 group->AppendL( iVisualControl ); |
|
270 } |
|
271 |
|
272 iIdleController = CFMRadioIdleController::NewL(); |
|
273 // Add media idle visuals to the controller. |
|
274 // Only one of the media idle visuals is visible at a time. |
|
275 iIdleController->AddControlItem( *iRdsViewer ); |
|
276 iIdleController->AddControlItem( *iMediaIdle ); |
|
277 iIdleController->AddControlItem( *iRadioLogo ); |
|
278 |
|
279 iMainPaneRect = aRect; |
|
280 |
|
281 UpdateTextColorFromSkin(); |
|
282 SizeChanged(); |
|
283 // Make the control group active on the display |
|
284 display->Roster().ShowL( *group ); |
|
285 } |
|
286 |
|
287 // -------------------------------------------------------------------------------- |
|
288 // CFMRadioMainContainer::Destructor |
|
289 // -------------------------------------------------------------------------------- |
|
290 // |
|
291 CFMRadioMainContainer::~CFMRadioMainContainer() |
|
292 { |
|
293 if ( iTimer->IsActive() ) |
|
294 { |
|
295 iTimer->Cancel(); |
|
296 } |
|
297 |
|
298 delete iTimer; |
|
299 iTimer = NULL; |
|
300 timer.Close(); |
|
301 |
|
302 delete iLight; |
|
303 iLight = NULL; |
|
304 delete iIdleController; |
|
305 } |
|
306 |
|
307 // -------------------------------------------------------------------------------- |
|
308 // CFMRadioMainContainer::SetFaded |
|
309 // Fades the entire window and controls in the window owned |
|
310 // by this container control. |
|
311 // ------------------------------------------------------------------------------- |
|
312 // |
|
313 void CFMRadioMainContainer::SetFaded( TBool aFaded ) |
|
314 { |
|
315 iFadeStatus = aFaded; |
|
316 } |
|
317 |
|
318 // -------------------------------------------------------------------------------- |
|
319 // CFMRadioMainContainer::DisplayChannelInfoL |
|
320 // Display the channel information |
|
321 // -------------------------------------------------------------------------------- |
|
322 // |
|
323 void CFMRadioMainContainer::DisplayChannelInfoL( |
|
324 TInt aChannelNumber, |
|
325 const TDesC& aStationName, |
|
326 TFMRadioStationChangeType aChangeType, |
|
327 TInt aFrequency ) |
|
328 { |
|
329 HBufC* firstLine = NULL; |
|
330 HBufC* secondLine = NULL; |
|
331 TBool programmeServiceNameExists = iRadioEngine.RdsReceiver().ProgrammeService().Length(); |
|
332 CFMRadioRdsReceiverBase::TFMRadioProgrammeSeviceType PSNameType = |
|
333 iRadioEngine.RdsReceiver().ProgrammeServiceNameType(); |
|
334 |
|
335 TBool useStaticPsName = EFalse; |
|
336 if ( !aStationName.Length() && |
|
337 PSNameType == CFMRadioRdsReceiverBase::EFMRadioPSNameStatic && |
|
338 programmeServiceNameExists ) |
|
339 { |
|
340 useStaticPsName = ETrue; |
|
341 } |
|
342 const TDesC& stationName = useStaticPsName ? iRadioEngine.RdsReceiver().ProgrammeService() : aStationName; |
|
343 |
|
344 if ( !stationName.Length() ) |
|
345 { |
|
346 // PS Name is concidered as dynamic |
|
347 if( aChannelNumber == KErrNotFound ) |
|
348 { |
|
349 firstLine = FormattedFrequencyStringL( aFrequency, R_QTN_FMRADIO_FREQ ); |
|
350 CleanupStack::PushL( firstLine ); |
|
351 if( programmeServiceNameExists ) |
|
352 { |
|
353 secondLine = iRadioEngine.RdsReceiver().ProgrammeService().AllocL(); |
|
354 } |
|
355 } |
|
356 else |
|
357 { |
|
358 TReal frequency = static_cast<TReal>( aFrequency / static_cast<TReal>( KHzConversionFactor )); |
|
359 |
|
360 // Gets locale decimal separator automatically |
|
361 TInt maxDecimalPlaces = iRadioEngine.DecimalCount(); |
|
362 TRealFormat format( KFrequencyMaxLength, maxDecimalPlaces ); |
|
363 TBuf<KFrequencyMaxLength> frequencyString; |
|
364 frequencyString.Num( frequency, format ); |
|
365 AknTextUtils::LanguageSpecificNumberConversion( frequencyString ); |
|
366 |
|
367 firstLine = StringLoader::LoadLC( R_QTN_FMRADIO_MEM_LOCATION_FREQ, |
|
368 frequencyString, aChannelNumber, iCoeEnv ); |
|
369 |
|
370 if( programmeServiceNameExists ) |
|
371 { |
|
372 secondLine = iRadioEngine.RdsReceiver().ProgrammeService().AllocL(); |
|
373 } |
|
374 } |
|
375 } |
|
376 else |
|
377 { |
|
378 if( aChannelNumber == KErrNotFound ) |
|
379 { |
|
380 firstLine = stationName.AllocLC(); |
|
381 } |
|
382 else |
|
383 { |
|
384 firstLine = StringLoader::LoadLC( R_QTN_FMRADIO_MEM_LOCATION_NAME, |
|
385 stationName, aChannelNumber, iCoeEnv ); |
|
386 } |
|
387 |
|
388 if ( programmeServiceNameExists && |
|
389 PSNameType == CFMRadioRdsReceiverBase::EFMRadioPSNameDynamic ) |
|
390 { |
|
391 // PS Name is concidered as dynamic |
|
392 secondLine = iRadioEngine.RdsReceiver().ProgrammeService().AllocL(); |
|
393 } |
|
394 else |
|
395 { |
|
396 secondLine = FormattedFrequencyStringL( aFrequency, R_QTN_FMRADIO_FREQ ); |
|
397 } |
|
398 } |
|
399 CleanupStack::PushL( secondLine ); |
|
400 |
|
401 if( AknLayoutUtils::LayoutMirrored() ) |
|
402 { |
|
403 // Add right to left mark in the beginning so that the text is laid out correctly |
|
404 firstLine = firstLine->ReAllocL( firstLine->Length() + KRightToLeftMark().Length() ); |
|
405 CleanupStack::Pop( 2 ); // secondLine and old firstLine |
|
406 CleanupStack::PushL( firstLine ); |
|
407 CleanupStack::PushL( secondLine ); |
|
408 firstLine->Des().Insert( 0, KRightToLeftMark ); |
|
409 |
|
410 if ( secondLine ) |
|
411 { |
|
412 secondLine = secondLine->ReAllocL( secondLine->Length() + KRightToLeftMark().Length() ); |
|
413 CleanupStack::Pop(); // old secondLine |
|
414 CleanupStack::PushL( secondLine ); |
|
415 secondLine->Des().Insert( 0, KRightToLeftMark ); |
|
416 } |
|
417 } |
|
418 |
|
419 iVisualControl->ChangeStationL( aChangeType, *firstLine, secondLine ); |
|
420 |
|
421 HBufC* frequencyString = FormattedFrequencyStringL( aFrequency, R_QTN_FMRADIO_MEDIA_IDLE_FREQ ); |
|
422 CleanupStack::PushL( frequencyString ); |
|
423 iMediaIdle->AddMediaIdleContentL( *frequencyString ); |
|
424 CleanupStack::PopAndDestroy( frequencyString ); |
|
425 if( aStationName.Length() ) |
|
426 { |
|
427 iMediaIdle->AddMediaIdleContentL( stationName ); |
|
428 } |
|
429 if ( aStationName != iRadioEngine.RdsReceiver().ProgrammeService() && |
|
430 PSNameType == CFMRadioRdsReceiverBase::EFMRadioPSNameStatic ) |
|
431 { |
|
432 iMediaIdle->AddPsNameToMediaIdleL( iRadioEngine.RdsReceiver().ProgrammeService() ); |
|
433 } |
|
434 |
|
435 CleanupStack::PopAndDestroy( 2, firstLine ); |
|
436 } |
|
437 |
|
438 // -------------------------------------------------------------------------------- |
|
439 // CFMRadioMainContainer::FormattedFrequencyStringL |
|
440 // Format the frequency |
|
441 // -------------------------------------------------------------------------------- |
|
442 // |
|
443 HBufC* CFMRadioMainContainer::FormattedFrequencyStringL( TInt aFrequency, TInt aResourceId ) |
|
444 { |
|
445 TReal frequency = static_cast<TReal>( aFrequency / static_cast<TReal>( KHzConversionFactor )); |
|
446 |
|
447 // Gets locale decimal separator automatically |
|
448 TInt maxDecimalPlaces = iRadioEngine.DecimalCount(); |
|
449 TRealFormat format( KFrequencyMaxLength, maxDecimalPlaces ); |
|
450 TBuf<KFrequencyMaxLength> frequencyString; |
|
451 frequencyString.Num( frequency, format ); |
|
452 AknTextUtils::LanguageSpecificNumberConversion( frequencyString ); |
|
453 |
|
454 return StringLoader::LoadL( aResourceId, frequencyString, iCoeEnv );; |
|
455 } |
|
456 |
|
457 // -------------------------------------------------------------------------------- |
|
458 // CFMRadioMainContainer::ShowRTPlusInteractionIndicator |
|
459 // Hide/show the RT+ interaction indicator with optional fade effecct |
|
460 // -------------------------------------------------------------------------------- |
|
461 // |
|
462 void CFMRadioMainContainer::ShowRTPlusInteractionIndicator( TBool aVisible, TBool aFadeEffect) |
|
463 { |
|
464 if (aVisible) |
|
465 iRdsInteractionIndicator->Show( aFadeEffect ); |
|
466 else |
|
467 iRdsInteractionIndicator->Hide( aFadeEffect ); |
|
468 } |
|
469 |
|
470 // --------------------------------------------------------- |
|
471 // CFMRadioMainContainer::ShowRdsInfo |
|
472 // --------------------------------------------------------- |
|
473 // |
|
474 void CFMRadioMainContainer::ShowRdsInfo( TBool aShow, TBool aFade, TBool aShowAfMarquee ) |
|
475 { |
|
476 if( aShow ) |
|
477 { |
|
478 iRdsIndicator->Show( aFade ); |
|
479 |
|
480 if( aShowAfMarquee ) |
|
481 { |
|
482 iRdsAfIndicator->Show( aFade ); |
|
483 } |
|
484 else |
|
485 { |
|
486 iRdsAfIndicator->Hide( aFade ); |
|
487 } |
|
488 } |
|
489 else |
|
490 { |
|
491 iRdsIndicator->Hide( aFade ); |
|
492 |
|
493 iRdsAfIndicator->Hide( aFade ); |
|
494 } |
|
495 } |
|
496 |
|
497 // ---------------------------------------------------------------------------------------------------- |
|
498 // CFMRadioMainContainer::HandleResourceChange |
|
499 // Handles resource changes |
|
500 // ---------------------------------------------------------------------------------------------------- |
|
501 // |
|
502 void CFMRadioMainContainer::HandleResourceChange( TInt aType ) |
|
503 { |
|
504 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
505 { |
|
506 AknLayoutUtils::LayoutMetricsRect( |
|
507 AknLayoutUtils::EMainPane, iMainPaneRect); |
|
508 SizeChanged(); |
|
509 TRAP_IGNORE( iAlfEnv.NotifyLayoutChangedL() ) |
|
510 iIdleController->ShowControl( *iRadioLogo ); |
|
511 } |
|
512 else if ( aType == KAknsMessageSkinChange ) |
|
513 { |
|
514 UpdateTextColorFromSkin(); |
|
515 TRAP_IGNORE( iAlfEnv.NotifySkinChangedL() ); |
|
516 } |
|
517 } |
|
518 |
|
519 // -------------------------------------------------------------------------------- |
|
520 // CFMRadioMainContainer::SetRect |
|
521 // Sets rectangle of the alfred display |
|
522 // -------------------------------------------------------------------------------- |
|
523 // |
|
524 void CFMRadioMainContainer::SetRect( const TRect& aRect ) |
|
525 { |
|
526 iMainPaneRect = aRect; |
|
527 SizeChanged(); |
|
528 } |
|
529 |
|
530 // -------------------------------------------------------------------------------- |
|
531 // CFMRadioMainContainer::SizeChanged |
|
532 // Called when the view size is changed |
|
533 // -------------------------------------------------------------------------------- |
|
534 // |
|
535 void CFMRadioMainContainer::SizeChanged() |
|
536 { |
|
537 CFMRadioAppUi* appUi = static_cast<CFMRadioAppUi*>( iCoeEnv->AppUi() ); |
|
538 |
|
539 iAlfEnv.PrimaryDisplay().ForceSetVisibleArea( iMainPaneRect ); |
|
540 |
|
541 TAknLayoutRect layoutRect; |
|
542 TAknLayoutText textLayout; |
|
543 TAknLayoutRect indicatorLayoutRect; |
|
544 TAknLayoutRect visualPaneLayoutRect; |
|
545 |
|
546 TRect displayRect( iMainPaneRect.Size() ); |
|
547 |
|
548 iVisualControl->SetMirrored( appUi->IsLayoutMirrored() ); |
|
549 TBool isLandscape = appUi->IsLandscapeOrientation(); |
|
550 |
|
551 TDisplayOrientation alfDisplayOrientation = EPortrait; |
|
552 CFMRadioAlfMediaIdle::TOrientation mediaIdleOrientation = CFMRadioAlfMediaIdle::EPortrait; |
|
553 |
|
554 TInt lafVarietyRdsIndicator = 0; |
|
555 TInt lafVarietyAfIndicator = 0; |
|
556 TInt lafVarietyPlusIndicator = 0; |
|
557 TInt lafVarietyRdsText = 0; |
|
558 TInt lafVarietyLogo = 0; |
|
559 TInt lafVarietyIndicatorPane = 0; |
|
560 TInt lafVarietyVisualPane = 0; |
|
561 TBool useLandscapeImage = EFalse; |
|
562 |
|
563 if ( isLandscape ) |
|
564 { |
|
565 alfDisplayOrientation = ELandscape; |
|
566 mediaIdleOrientation = CFMRadioAlfMediaIdle::ELandscape; |
|
567 |
|
568 lafVarietyRdsIndicator = KLAFVarietyRDSIndicatorLandscape; |
|
569 lafVarietyAfIndicator = KLAFVarietyAFIndicatorLandscape; |
|
570 lafVarietyPlusIndicator = KLAFVarietyRDSPlusIndicatorLandscape; |
|
571 lafVarietyRdsText = KLAFVarietyRDSViewerLandscape; |
|
572 lafVarietyLogo = KLAFVarietyLogoImageLandscape; |
|
573 lafVarietyIndicatorPane = KLAFVarietyIndicatorPaneLandscape; |
|
574 lafVarietyVisualPane = KLAFVarietyVisualPaneLandscape; |
|
575 useLandscapeImage = ETrue; |
|
576 } |
|
577 else |
|
578 { |
|
579 lafVarietyRdsIndicator = KLAFVarietyRDSIndicatorPortrait; |
|
580 lafVarietyAfIndicator = KLAFVarietyAFIndicatorPortrait; |
|
581 lafVarietyPlusIndicator = KLAFVarietyRDSPlusIndicatorPortrait; |
|
582 lafVarietyRdsText = KLAFVarietyRDSViewerPortrait; |
|
583 lafVarietyLogo = KLAFVarietyLogoImagePortrait; |
|
584 lafVarietyIndicatorPane = KLAFVarietyIndicatorPanePortrait; |
|
585 lafVarietyVisualPane = KLAFVarietyVisualPanePortrait; |
|
586 } |
|
587 // indicator pane |
|
588 indicatorLayoutRect.LayoutRect( displayRect, |
|
589 AknLayoutScalable_Apps::fmrd2_indi_pane( lafVarietyIndicatorPane ) ); |
|
590 |
|
591 // RDS indicator |
|
592 textLayout.LayoutText( indicatorLayoutRect.Rect(), |
|
593 AknLayoutScalable_Apps::fmrd2_indi_pane_t3( lafVarietyRdsIndicator ).LayoutLine() ); |
|
594 |
|
595 iRdsIndicator->SetRect( textLayout.TextRect() ); |
|
596 |
|
597 // AF indicator |
|
598 textLayout.LayoutText( indicatorLayoutRect.Rect(), |
|
599 AknLayoutScalable_Apps::fmrd2_indi_pane_t2( lafVarietyAfIndicator ).LayoutLine() ); |
|
600 |
|
601 iRdsAfIndicator->SetRect( textLayout.TextRect() ); |
|
602 |
|
603 // + indicator |
|
604 textLayout.LayoutText( indicatorLayoutRect.Rect(), |
|
605 AknLayoutScalable_Apps::fmrd2_indi_pane_t1( lafVarietyPlusIndicator ).LayoutLine() ); |
|
606 |
|
607 iRdsInteractionIndicator->SetRect( textLayout.TextRect() ); |
|
608 |
|
609 // RDS Text pane |
|
610 layoutRect.LayoutRect( displayRect, |
|
611 AknLayoutScalable_Apps::area_fmrd2_visual_pane( lafVarietyRdsText ).LayoutLine() ); |
|
612 |
|
613 iRdsViewer->SetRect( layoutRect.Rect() ); |
|
614 |
|
615 // radio icon |
|
616 visualPaneLayoutRect.LayoutRect( displayRect, |
|
617 AknLayoutScalable_Apps::area_fmrd2_visual_pane( lafVarietyVisualPane ).LayoutLine() ); |
|
618 |
|
619 layoutRect.LayoutRect( visualPaneLayoutRect.Rect(), |
|
620 AknLayoutScalable_Apps::area_fmrd2_visual_pane_g1( lafVarietyLogo ).LayoutLine() ); |
|
621 |
|
622 // change image |
|
623 iRadioLogo->SwitchToLandscapeImage( useLandscapeImage ); |
|
624 iRadioLogo->SetRect( layoutRect.Rect() ); |
|
625 |
|
626 iVisualControl->SetOrientation( alfDisplayOrientation ); |
|
627 iVisualControl->UpdateLayout( ); |
|
628 iMediaIdle->SetOrientation( mediaIdleOrientation ); |
|
629 iMediaIdle->UpdateLayout( ); |
|
630 } |
|
631 |
|
632 // -------------------------------------------------------------------------------------------------- |
|
633 // CFMRadioMainContainer::GetHelpContext |
|
634 // -------------------------------------------------------------------------------------------------- |
|
635 // |
|
636 void CFMRadioMainContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
637 { |
|
638 #if defined __SERIES60_HELP || defined FF_S60_HELPS_IN_USE |
|
639 aContext.iMajor = TUid::Uid( KUidFMRadioApplication ); |
|
640 aContext.iContext = KFMRADIO_HLP_MAIN; |
|
641 #endif |
|
642 } |
|
643 |
|
644 // -------------------------------------------------------------------------------- |
|
645 // CFMRadioMainContainer::UpdateTextColorFromSkin |
|
646 // Handles updating main area text colors using current skin. |
|
647 // -------------------------------------------------------------------------------- |
|
648 // |
|
649 void CFMRadioMainContainer::UpdateTextColorFromSkin() |
|
650 { |
|
651 // Update text using skin color |
|
652 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
653 |
|
654 TRgb color( KRgbBlue ); |
|
655 AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 ); |
|
656 |
|
657 iVisualControl->SetStationInformationTextColor( color ); |
|
658 iMediaIdle->SetPrimaryColor( color ); |
|
659 iRdsViewer->SetTextColor( color ); |
|
660 iRdsIndicator->SetTextColor( color ); |
|
661 iRdsAfIndicator->SetTextColor( color ); |
|
662 iRdsInteractionIndicator->SetTextColor( color ); |
|
663 |
|
664 AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG10 ); |
|
665 |
|
666 iMediaIdle->SetSecondaryColor( color ); |
|
667 } |
|
668 |
|
669 // ---------------------------------------------------------------------------------------------------- |
|
670 // CFMRadioMainContainer::VisualControl |
|
671 // Returns a pointer to the station information visualizer |
|
672 // ---------------------------------------------------------------------------------------------------- |
|
673 // |
|
674 CFMRadioAlfVisualizer* CFMRadioMainContainer::VisualControl() |
|
675 { |
|
676 return iVisualControl; |
|
677 } |
|
678 |
|
679 // ---------------------------------------------------------------------------------------------------- |
|
680 // CFMRadioMainContainer::MediaIdle |
|
681 // Returns a pointer to Media Idle |
|
682 // ---------------------------------------------------------------------------------------------------- |
|
683 // |
|
684 CFMRadioAlfMediaIdle& CFMRadioMainContainer::MediaIdle() |
|
685 { |
|
686 return *iMediaIdle; |
|
687 } |
|
688 |
|
689 // --------------------------------------------------------------------------- |
|
690 // CFMRadioMainContainer::SetRdsRadioTextL |
|
691 // Updates the rds information. |
|
692 // --------------------------------------------------------------------------- |
|
693 // |
|
694 void CFMRadioMainContainer::SetRdsRadioTextL( const TDesC& aRadioText ) |
|
695 { |
|
696 // Trim the text and check if there is actual content before showing it |
|
697 HBufC* text = aRadioText.AllocLC(); |
|
698 text->Des().Trim(); |
|
699 if ( text->Length() ) |
|
700 { |
|
701 if ( iRdsViewer->SetTextL( *text ) ) |
|
702 { |
|
703 iIdleController->ShowControl( *iRdsViewer ); |
|
704 } |
|
705 } |
|
706 CleanupStack::PopAndDestroy( text ); |
|
707 } |
|
708 |
|
709 // ---------------------------------------------------------------------------------------------------- |
|
710 // TimerTimeOut |
|
711 // ---------------------------------------------------------------------------------------------------- |
|
712 void CFMRadioMainContainer::TimerTimeOut( TInt aErrorStatus ) |
|
713 { |
|
714 |
|
715 if ( aErrorStatus == KErrNone && iLightsOffCounter < KFadeFrames ) |
|
716 { |
|
717 iAlfEnv.RefreshCallBack( &( iAlfEnv ) ); |
|
718 TTimeIntervalMicroSeconds32 time( KTenMilliSecondsInMicroSeconds ); |
|
719 |
|
720 timer.After(iTimer->iStatus, time ); |
|
721 |
|
722 iTimer->Activate(); |
|
723 |
|
724 iLightsOffCounter++; |
|
725 |
|
726 } |
|
727 else |
|
728 { |
|
729 timer.Cancel(); |
|
730 } |
|
731 |
|
732 } |
|
733 |
|
734 // --------------------------------------------------------------------------- |
|
735 // CFMRadioAlfMediaIdle::LightStatusChangedL |
|
736 // From MHWRMLightObserver |
|
737 // Prepares media idle to handle new channel information |
|
738 // --------------------------------------------------------------------------- |
|
739 // |
|
740 void CFMRadioMainContainer::LightStatusChanged(TInt aTarget, |
|
741 CHWRMLight::TLightStatus aStatus) |
|
742 { |
|
743 FTRACE( FPrint( _L("CFMRadioMainContainer::LightStatusChanged( Target: %d Lights: %d )"), aTarget, aStatus ) ); |
|
744 if ( CHWRMLight::ELightOff == aStatus && aTarget == 1 ) |
|
745 { |
|
746 CAlfDisplay* display = NULL; |
|
747 |
|
748 if( iAlfEnv.DisplayCount() > 0 ) |
|
749 { |
|
750 display = &(iAlfEnv.PrimaryDisplay()); |
|
751 |
|
752 if ( display->Roster().Count() > 0 ) |
|
753 { |
|
754 iIdleController->DeactivateControls(); |
|
755 |
|
756 |
|
757 iAlfEnv.RefreshCallBack( &(iAlfEnv) ); |
|
758 |
|
759 if ( !iTimer->IsActive() ) |
|
760 { |
|
761 TTimeIntervalMicroSeconds32 time( KTenMilliSecondsInMicroSeconds ); |
|
762 // Just to make sure, that dimming is really happening |
|
763 iLightsOffCounter = 0; |
|
764 timer.After(iTimer->iStatus, time ); |
|
765 iTimer->Activate(); |
|
766 } |
|
767 } |
|
768 } |
|
769 } |
|
770 else if ( CHWRMLight::ELightOn == aStatus && aTarget == 1 ) |
|
771 { |
|
772 if ( iTimer ) |
|
773 { |
|
774 if ( iTimer->IsActive() ) |
|
775 { |
|
776 iTimer->Cancel(); |
|
777 } |
|
778 } |
|
779 |
|
780 if ( iLightsOffCounter != 0 ) |
|
781 { |
|
782 CFMRadioAppUi* appUi = static_cast<CFMRadioAppUi*>( iCoeEnv->AppUi() ); |
|
783 CFMRadioMainView* mainView = static_cast<CFMRadioMainView*>( appUi->View( KFMRadioMainViewId ) ); |
|
784 mainView->DetermineActiveMediaIdleComponent(); |
|
785 |
|
786 iLightsOffCounter = 0; |
|
787 } |
|
788 } |
|
789 } |
|
790 |
|
791 // -------------------------------------------------------------------------------- |
|
792 // CFMRadioMainContainer::RdsViewer |
|
793 // -------------------------------------------------------------------------------- |
|
794 // |
|
795 CFMRadioAlfRDSViewer& CFMRadioMainContainer::RdsViewer() const |
|
796 { |
|
797 return *iRdsViewer; |
|
798 } |
|
799 |
|
800 // -------------------------------------------------------------------------------- |
|
801 // CFMRadioMainContainer::IdleController |
|
802 // -------------------------------------------------------------------------------- |
|
803 // |
|
804 CFMRadioIdleController& CFMRadioMainContainer::IdleController() const |
|
805 { |
|
806 return *iIdleController; |
|
807 } |
|
808 |
|
809 // -------------------------------------------------------------------------------- |
|
810 // CFMRadioMainContainer::Logo |
|
811 // -------------------------------------------------------------------------------- |
|
812 // |
|
813 CFMRadioLogo& CFMRadioMainContainer::Logo() const |
|
814 { |
|
815 return *iRadioLogo; |
|
816 } |
|
817 // End of File |
|