|
1 /* |
|
2 * Copyright (c) 2007 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: FreestyleEmailUi status indicator implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // SYSTEM INCLUDES |
|
21 #include "emailtrace.h" |
|
22 #include <AknUtils.h> |
|
23 #include <StringLoader.h> |
|
24 // <cmail> SF |
|
25 #include <alf/alfdecklayout.h> |
|
26 #include <alf/alfcontrolgroup.h> |
|
27 #include <alf/alfbrusharray.h> |
|
28 // </cmail> |
|
29 #include <FreestyleEmailUi.rsg> |
|
30 |
|
31 // INTERNAL INCLUDES |
|
32 #include "FreestyleEmailUiStatusIndicator.h" |
|
33 #include "FreestyleEmailUiAppui.h" |
|
34 #include "FreestyleEmailUiTextureManager.h" |
|
35 #include "FreestyleEmailUiLayoutHandler.h" |
|
36 |
|
37 const TReal KPopupListBackgroundOpacity(1);//0.94); |
|
38 const TInt KIndicatorDefaultDuration( 3000 ); |
|
39 const TInt KIconArraySize(50); |
|
40 |
|
41 CFSEmailUiStatusIndicator::CFSEmailUiStatusIndicator( CAlfEnv& aEnv, |
|
42 CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aControlGroup ) |
|
43 : CAlfControl(), iEnv(aEnv), iAppUi(aAppUi), iControlGroup(aControlGroup) |
|
44 { |
|
45 FUNC_LOG; |
|
46 } |
|
47 |
|
48 CFSEmailUiStatusIndicator::~CFSEmailUiStatusIndicator() |
|
49 { |
|
50 FUNC_LOG; |
|
51 delete iTimer; |
|
52 iIconArray.Close(); |
|
53 } |
|
54 |
|
55 CFSEmailUiStatusIndicator* CFSEmailUiStatusIndicator::NewL( CAlfEnv& aEnv, |
|
56 CAlfControlGroup& aControlGroup, CFreestyleEmailUiAppUi* aAppUi ) |
|
57 { |
|
58 FUNC_LOG; |
|
59 CFSEmailUiStatusIndicator* self = new (ELeave) CFSEmailUiStatusIndicator( aEnv, aAppUi, aControlGroup ); |
|
60 CleanupStack::PushL( self ); |
|
61 self->ConstructL(); |
|
62 CleanupStack::Pop( self ); |
|
63 return self; |
|
64 } |
|
65 |
|
66 void CFSEmailUiStatusIndicator::ConstructL() |
|
67 { |
|
68 FUNC_LOG; |
|
69 |
|
70 // These are done already here, otherwise the ownership of this |
|
71 // control is not transferred to AlfEnv (AlfEnv deletes only controls that |
|
72 // are added to control groups) -> memory leak if DoFirstStartL not called |
|
73 CAlfControl::ConstructL( iEnv ); |
|
74 iControlGroup.AppendL( this ); |
|
75 |
|
76 iFirstStartCompleted = EFalse; |
|
77 |
|
78 } |
|
79 |
|
80 // CFSEmailUiStatusIndicator::DoFirstStartL() |
|
81 // Purpose of this function is to do first start things only when indicator is |
|
82 // really needed to be shown for the first time. Implemented to make app startup faster. |
|
83 void CFSEmailUiStatusIndicator::DoFirstStartL() |
|
84 { |
|
85 FUNC_LOG; |
|
86 |
|
87 CalculateSizeAttributes(); |
|
88 LoadIconsL(); |
|
89 |
|
90 iParentLayout = CAlfDeckLayout::AddNewL(*this); |
|
91 |
|
92 iParentLayout->SetFlags( EAlfVisualFlagManualLayout ); |
|
93 iParentLayout->SetRect( iParentRect ); |
|
94 |
|
95 // Set list padding |
|
96 //TInt padding = iAppUi->LayoutHandler()->ControlBarListPadding(); |
|
97 iParentLayout->SetPadding( TPoint(iBorderPadding, iBorderPadding) ); |
|
98 |
|
99 // Set list background |
|
100 iParentLayout->EnableBrushesL(); |
|
101 CAlfImageBrush* bgBrush = iAppUi->FsTextureManager()->NewControlBarListBgBrushLC(); |
|
102 iParentLayout->Brushes()->AppendL( bgBrush, EAlfHasOwnership ); |
|
103 CleanupStack::Pop( bgBrush ); |
|
104 |
|
105 iContentLayout = CAlfAnchorLayout::AddNewL( *this, iParentLayout ); |
|
106 |
|
107 // Create new image visual for our control |
|
108 iImageVisual = CAlfImageVisual::AddNewL(*this, iContentLayout); |
|
109 iImageVisual->SetScaleMode( CAlfImageVisual::EScaleFitWidth ); |
|
110 |
|
111 // Working text: |
|
112 iFirstTextVisual = CAlfTextVisual::AddNewL( *this, iContentLayout ); |
|
113 iFirstTextVisual->SetWrapping( CAlfTextVisual::ELineWrapTruncate ); |
|
114 |
|
115 iSecondTextVisual = CAlfTextVisual::AddNewL( *this, iContentLayout ); |
|
116 iSecondTextVisual->SetWrapping( CAlfTextVisual::ELineWrapTruncate ); |
|
117 if ( AknLayoutUtils::LayoutMirrored() ) |
|
118 { |
|
119 iFirstTextVisual->SetAlign( EAlfAlignHRight, EAlfAlignVCenter ); |
|
120 iSecondTextVisual->SetAlign( EAlfAlignHRight, EAlfAlignVCenter ); |
|
121 } |
|
122 else |
|
123 { |
|
124 iFirstTextVisual->SetAlign( EAlfAlignHLeft, EAlfAlignVCenter ); |
|
125 iSecondTextVisual->SetAlign( EAlfAlignHLeft, EAlfAlignVCenter ); |
|
126 } |
|
127 |
|
128 iTimer = CFSEmailUiGenericTimer::NewL( this ); |
|
129 iFirstStartCompleted = ETrue; |
|
130 |
|
131 } |
|
132 |
|
133 |
|
134 void CFSEmailUiStatusIndicator::PositionVisuals() |
|
135 { |
|
136 FUNC_LOG; |
|
137 // Note: the method's bit rewritten for Alfred as the anchors are handled more obnoxiously |
|
138 |
|
139 TReal firstLineTopPos = 0; |
|
140 TReal firstLineBottomPos = 0; |
|
141 TReal secondLineTopPos = 0; |
|
142 TReal secondLineBottomPos = 0; |
|
143 if( iHasSecondTextLine ) |
|
144 { |
|
145 firstLineBottomPos = -0.5; |
|
146 secondLineTopPos = 0.5; |
|
147 } |
|
148 |
|
149 // If mirrored layout in use, flip left and right anchors and their types, |
|
150 // and invert metrics by setting mirrorMultiplier to -1. |
|
151 if ( AknLayoutUtils::LayoutMirrored() ) |
|
152 { |
|
153 // Set anchors for icon image visual |
|
154 iContentLayout->SetAnchor(EAlfAnchorTopLeft, |
|
155 0, |
|
156 EAlfAnchorOriginRight, |
|
157 EAlfAnchorOriginTop, |
|
158 EAlfAnchorMetricAbsolute, |
|
159 EAlfAnchorMetricRelativeToSize, |
|
160 TAlfTimedPoint(-1 * iIconWidth, 0)); |
|
161 iContentLayout->SetAnchor(EAlfAnchorBottomRight, |
|
162 0, |
|
163 EAlfAnchorOriginRight, |
|
164 EAlfAnchorOriginBottom, |
|
165 EAlfAnchorMetricRelativeToSize, |
|
166 EAlfAnchorMetricRelativeToSize, |
|
167 TAlfTimedPoint(0, 0)); |
|
168 |
|
169 // Set anchors for first line text visual |
|
170 iContentLayout->SetAnchor(EAlfAnchorTopLeft, |
|
171 1, |
|
172 EAlfAnchorOriginLeft, |
|
173 EAlfAnchorOriginTop, |
|
174 EAlfAnchorMetricRelativeToSize, |
|
175 EAlfAnchorMetricRelativeToSize, |
|
176 TAlfTimedPoint(0, firstLineTopPos)); |
|
177 iContentLayout->SetAnchor(EAlfAnchorBottomRight, |
|
178 1, |
|
179 EAlfAnchorOriginRight, |
|
180 EAlfAnchorOriginBottom, |
|
181 EAlfAnchorMetricAbsolute, |
|
182 EAlfAnchorMetricRelativeToSize, |
|
183 TAlfTimedPoint(-1 * (iIconWidth+iTextPadding), firstLineBottomPos)); |
|
184 |
|
185 // Set anchors for second line text visual |
|
186 iContentLayout->SetAnchor(EAlfAnchorTopLeft, |
|
187 2, |
|
188 EAlfAnchorOriginLeft, |
|
189 EAlfAnchorOriginTop, |
|
190 EAlfAnchorMetricRelativeToSize, |
|
191 EAlfAnchorMetricRelativeToSize, |
|
192 TAlfTimedPoint(0, secondLineTopPos)); |
|
193 iContentLayout->SetAnchor(EAlfAnchorBottomRight, |
|
194 2, |
|
195 EAlfAnchorOriginRight, |
|
196 EAlfAnchorOriginBottom, |
|
197 EAlfAnchorMetricAbsolute, |
|
198 EAlfAnchorMetricRelativeToSize, |
|
199 TAlfTimedPoint(-1 * (iIconWidth+iTextPadding), secondLineBottomPos)); |
|
200 } |
|
201 else |
|
202 { |
|
203 // Set anchors for icon image visual |
|
204 iContentLayout->SetAnchor(EAlfAnchorTopLeft, |
|
205 0, |
|
206 EAlfAnchorOriginLeft, |
|
207 EAlfAnchorOriginTop, |
|
208 EAlfAnchorMetricRelativeToSize, |
|
209 EAlfAnchorMetricRelativeToSize, |
|
210 TAlfTimedPoint(0, 0)); |
|
211 iContentLayout->SetAnchor(EAlfAnchorBottomRight, |
|
212 0, |
|
213 EAlfAnchorOriginLeft, |
|
214 EAlfAnchorOriginBottom, |
|
215 EAlfAnchorMetricAbsolute, |
|
216 EAlfAnchorMetricRelativeToSize, |
|
217 TAlfTimedPoint(iIconWidth, 0)); |
|
218 |
|
219 // Set anchors for first line text visual |
|
220 iContentLayout->SetAnchor(EAlfAnchorTopLeft, |
|
221 1, |
|
222 EAlfAnchorOriginLeft, |
|
223 EAlfAnchorOriginTop, |
|
224 EAlfAnchorMetricAbsolute, |
|
225 EAlfAnchorMetricRelativeToSize, |
|
226 TAlfTimedPoint((iIconWidth+iTextPadding), firstLineTopPos)); |
|
227 iContentLayout->SetAnchor(EAlfAnchorBottomRight, |
|
228 1, |
|
229 EAlfAnchorOriginRight, |
|
230 EAlfAnchorOriginBottom, |
|
231 EAlfAnchorMetricRelativeToSize, |
|
232 EAlfAnchorMetricRelativeToSize, |
|
233 TAlfTimedPoint(0, firstLineBottomPos)); |
|
234 |
|
235 // Set anchors for second line text visual |
|
236 iContentLayout->SetAnchor(EAlfAnchorTopLeft, |
|
237 2, |
|
238 EAlfAnchorOriginLeft, |
|
239 EAlfAnchorOriginTop, |
|
240 EAlfAnchorMetricAbsolute, |
|
241 EAlfAnchorMetricRelativeToSize, |
|
242 TAlfTimedPoint((iIconWidth+iTextPadding), secondLineTopPos)); |
|
243 iContentLayout->SetAnchor(EAlfAnchorBottomRight, |
|
244 2, |
|
245 EAlfAnchorOriginRight, |
|
246 EAlfAnchorOriginBottom, |
|
247 EAlfAnchorMetricRelativeToSize, |
|
248 EAlfAnchorMetricRelativeToSize, |
|
249 TAlfTimedPoint(0, secondLineBottomPos)); |
|
250 } |
|
251 } |
|
252 |
|
253 |
|
254 void CFSEmailUiStatusIndicator::CalculateSizeAttributes() |
|
255 { |
|
256 FUNC_LOG; |
|
257 iBorderPadding = iAppUi->LayoutHandler()->ControlBarListBorderRoundingSize() / 2; |
|
258 iContentHeight = iAppUi->LayoutHandler()->OneLineListItemHeight(); |
|
259 iIconWidth = iContentHeight; |
|
260 |
|
261 if( iHasSecondTextLine ) |
|
262 { |
|
263 iIconWidth += iIconWidth/2; |
|
264 iContentHeight += iContentHeight; |
|
265 } |
|
266 |
|
267 if( iHasIcon ) |
|
268 { |
|
269 iTextPadding = iBorderPadding; |
|
270 } |
|
271 else |
|
272 { |
|
273 iIconWidth = 0; |
|
274 iTextPadding = 0; |
|
275 } |
|
276 |
|
277 // Calculate size and location for the parent rect |
|
278 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, iParentRect ); |
|
279 TInt popupWidth = iParentRect.Width(); |
|
280 if ( iFirstTextVisual && iSecondTextVisual ) |
|
281 { |
|
282 if ( iUseCompactLayout ) |
|
283 { |
|
284 iFirstTextVisual->SetStyle( EAlfTextStyleSmall ); |
|
285 iSecondTextVisual->SetStyle( EAlfTextStyleSmall ); |
|
286 /* |
|
287 iFirstTextVisual->ReportChanged(); |
|
288 iSecondTextVisual->ReportChanged(); |
|
289 |
|
290 TInt contentWidth = Max( iFirstTextVisual->TextExtents().iWidth, |
|
291 iSecondTextVisual->TextExtents().iWidth ); |
|
292 contentWidth += iIconWidth; |
|
293 contentWidth += 2*iBorderPadding; |
|
294 popupWidth = Min( iParentRect.Width(), contentWidth ); |
|
295 */ |
|
296 popupWidth = popupWidth * 3 / 4; |
|
297 } |
|
298 else |
|
299 { |
|
300 iFirstTextVisual->SetStyle( EAlfTextStyleNormal ); |
|
301 iSecondTextVisual->SetStyle( EAlfTextStyleNormal ); |
|
302 } |
|
303 } |
|
304 TInt leftMargin = ( iParentRect.Width() - popupWidth ) / 2; |
|
305 |
|
306 iParentRect.SetRect( leftMargin, iParentRect.Height() - iContentHeight - 2*iBorderPadding, |
|
307 leftMargin + popupWidth, iParentRect.Height() ); |
|
308 //iParentRect.Shrink(100, 100); |
|
309 //iParentRect.SetHeight(10); |
|
310 //iParentRect.Move(0, 150); |
|
311 } |
|
312 |
|
313 void CFSEmailUiStatusIndicator::SetTextByResourceIdL( TInt aResourceId, CAlfTextVisual* aTextVisual ) |
|
314 { |
|
315 FUNC_LOG; |
|
316 if ( iFirstStartCompleted ) |
|
317 { |
|
318 HBufC* headingText = StringLoader::LoadLC( aResourceId ); |
|
319 aTextVisual->SetTextL( *headingText ); |
|
320 CleanupStack::PopAndDestroy(headingText); |
|
321 } |
|
322 } |
|
323 |
|
324 void CFSEmailUiStatusIndicator::ShowIndicatorL( |
|
325 TDesC* aFirstLineText, |
|
326 TDesC* aSecondLineText, |
|
327 CAlfTexture* aIconTexture, |
|
328 TInt aDuration ) |
|
329 { |
|
330 FUNC_LOG; |
|
331 // Do first construction if not completed |
|
332 if ( !iFirstStartCompleted ) |
|
333 { |
|
334 DoFirstStartL(); |
|
335 } |
|
336 |
|
337 // Set first line of text |
|
338 if( aFirstLineText ) |
|
339 { |
|
340 iFirstTextVisual->SetTextL( *aFirstLineText ); |
|
341 } |
|
342 else |
|
343 { |
|
344 iFirstTextVisual->SetTextL( KNullDesC ); |
|
345 } |
|
346 |
|
347 // Set second line of text |
|
348 if( aSecondLineText ) |
|
349 { |
|
350 iSecondTextVisual->SetTextL( *aSecondLineText ); |
|
351 iHasSecondTextLine = ETrue; |
|
352 } |
|
353 else |
|
354 { |
|
355 iSecondTextVisual->SetTextL( KNullDesC ); |
|
356 iHasSecondTextLine = EFalse; |
|
357 } |
|
358 |
|
359 // Set icon texture |
|
360 if( aIconTexture ) |
|
361 { |
|
362 iHasIcon = ETrue; |
|
363 iImageVisual->SetImage( TAlfImage( *aIconTexture ) ); |
|
364 } |
|
365 else |
|
366 { |
|
367 iHasIcon = EFalse; |
|
368 iImageVisual->SetImage( TAlfImage() ); |
|
369 } |
|
370 |
|
371 DoShowIndicator( aDuration ); |
|
372 } |
|
373 |
|
374 void CFSEmailUiStatusIndicator::ShowIndicatorL( |
|
375 TStatusIndicationTypes aIndicationType, |
|
376 const TDesC* aFirstLineText, |
|
377 TInt aDuration ) |
|
378 { |
|
379 FUNC_LOG; |
|
380 // Do first construction if not completed |
|
381 if ( !iFirstStartCompleted ) |
|
382 { |
|
383 DoFirstStartL(); |
|
384 } |
|
385 |
|
386 iHasIcon = ETrue; |
|
387 iImageVisual->SetImage( TAlfImage( *iIconArray[aIndicationType] ) ); |
|
388 |
|
389 iHasSecondTextLine = EFalse; |
|
390 iUseCompactLayout = EFalse; |
|
391 iSecondTextVisual->SetTextL( KNullDesC ); |
|
392 |
|
393 CAlfTextVisual* textVisual = iFirstTextVisual; |
|
394 if( aFirstLineText ) |
|
395 { |
|
396 iFirstTextVisual->SetTextL( *aFirstLineText ); |
|
397 textVisual = iSecondTextVisual; |
|
398 iHasSecondTextLine = ETrue; |
|
399 } |
|
400 |
|
401 // <cmail> S60 Skin support |
|
402 TRgb textColor = KRgbBlack; |
|
403 textColor = iAppUi->LayoutHandler()->DropdownMenuTextColor(); |
|
404 |
|
405 iFirstTextVisual->SetColor (textColor); |
|
406 iSecondTextVisual->SetColor (textColor); |
|
407 //</cmail> |
|
408 |
|
409 switch( aIndicationType ) |
|
410 { |
|
411 case EIndicationSynchronising: |
|
412 { |
|
413 SetTextByResourceIdL( R_FREESTYLE_EMAIL_UI_STATUS_UPDATING, textVisual ); |
|
414 } |
|
415 break; |
|
416 |
|
417 case EIndicationConnected: |
|
418 { |
|
419 SetTextByResourceIdL( R_FREESTYLE_EMAIL_UI_STATUS_CONNECTED, textVisual ); |
|
420 } |
|
421 break; |
|
422 |
|
423 case EIndicationConnecting: |
|
424 { |
|
425 SetTextByResourceIdL( R_FREESTYLE_EMAIL_UI_STATUS_CONNECTING, textVisual ); |
|
426 } |
|
427 break; |
|
428 |
|
429 case EIndicationDisconnectedGeneral: |
|
430 { |
|
431 SetTextByResourceIdL( R_FREESTYLE_EMAIL_UI_STATUS_DISCONNECTED, textVisual ); |
|
432 } |
|
433 break; |
|
434 |
|
435 case EIndicationDisconnectedError: |
|
436 { |
|
437 SetTextByResourceIdL( R_FREESTYLE_EMAIL_UI_STATUS_DISCONNECTED, textVisual ); |
|
438 } |
|
439 break; |
|
440 |
|
441 case EIndicationDisconnectedLowBattery: |
|
442 { |
|
443 SetTextByResourceIdL( R_FREESTYLE_EMAIL_UI_STATUS_DISCONNECTED, textVisual ); |
|
444 } |
|
445 break; |
|
446 |
|
447 case EIndicationMailSent: |
|
448 { |
|
449 SetTextByResourceIdL( R_FREESTYLE_EMAIL_UI_STATUS_EMAIL_SENT, textVisual ); |
|
450 } |
|
451 break; |
|
452 case EIndicationCancelSynchronising: |
|
453 { |
|
454 iImageVisual->SetImage( TAlfImage() ); |
|
455 iHasIcon = EFalse; |
|
456 SetTextByResourceIdL( R_FREESTYLE_EMAIL_UI_STATUS_CANCEL_SYNC, textVisual ); |
|
457 } |
|
458 break; |
|
459 case EIndicationDownloadStarted: |
|
460 { |
|
461 SetTextByResourceIdL( R_FSE_VIEWER_NOTE_ATTACHMENT_DOWNLOADING, textVisual ); |
|
462 } |
|
463 break; |
|
464 case EIndicationDownloadProgress: |
|
465 { |
|
466 iHasSecondTextLine = EFalse; |
|
467 iUseCompactLayout = ETrue; |
|
468 } |
|
469 break; |
|
470 default: |
|
471 return; |
|
472 } |
|
473 |
|
474 DoShowIndicator( aDuration ); |
|
475 } |
|
476 |
|
477 void CFSEmailUiStatusIndicator::DoShowIndicator( TInt aDuration ) |
|
478 { |
|
479 FUNC_LOG; |
|
480 if ( iFirstStartCompleted ) // Safety |
|
481 { |
|
482 CalculateSizeAttributes(); |
|
483 PositionVisuals(); |
|
484 |
|
485 // Default values used when just updating the view after layout change |
|
486 TInt transitionTime( 0 ); |
|
487 TRect startRect = iParentRect; |
|
488 |
|
489 // Set indicator transparent and out of the screen as a preparation |
|
490 // for transformation effect (fade and slide in). Except if we are |
|
491 // just updating the visuals as a result of layout change. |
|
492 if ( aDuration != EIndicationLayoutUpdated ) |
|
493 { |
|
494 SetOpacity( 0, 0 ); |
|
495 |
|
496 startRect.Move( 0, iContentHeight - 2*iBorderPadding ); |
|
497 |
|
498 transitionTime = iAppUi->LayoutHandler()->StatusIndicatorFadeEffectTime(); |
|
499 } |
|
500 |
|
501 // Show the indicator |
|
502 CAlfControlGroup* group = ControlGroup(); |
|
503 iEnv.Send(TAlfGroupCommand(*group, EAlfOpShow, &iAppUi->Display()), 0); |
|
504 //Display().Roster().ShowL(*group); |
|
505 SetOpacity( KPopupListBackgroundOpacity, transitionTime ); |
|
506 |
|
507 // First set the transformation starting rect immediately, |
|
508 // and then the actual rect with transtition time |
|
509 iParentLayout->SetRect( startRect ); |
|
510 iParentLayout->SetRect( iParentRect, transitionTime ); |
|
511 |
|
512 if( aDuration == EIndicationDefaultDuration ) |
|
513 { |
|
514 aDuration = KIndicatorDefaultDuration; |
|
515 } |
|
516 |
|
517 // Start hiding timer only if some reasonable duration is given. |
|
518 // In other cases the indicator is going to be hided manually, or |
|
519 // the original duration is preserved. |
|
520 if( aDuration >=0 ) |
|
521 { |
|
522 iTimer->Start( aDuration ); |
|
523 } |
|
524 iVisible = ETrue; |
|
525 } |
|
526 } |
|
527 |
|
528 void CFSEmailUiStatusIndicator::SetContentsL( const TDesC* aFirstLineText, |
|
529 const TDesC* aSecondLineText /*= NULL*/, |
|
530 const CAlfTexture* aIconTexture /*= NULL*/ ) |
|
531 { |
|
532 FUNC_LOG; |
|
533 // Do first construction if not completed |
|
534 if ( !iFirstStartCompleted ) |
|
535 { |
|
536 DoFirstStartL(); |
|
537 } |
|
538 if ( aFirstLineText ) |
|
539 { |
|
540 iFirstTextVisual->SetTextL( *aFirstLineText ); |
|
541 } |
|
542 |
|
543 if ( aSecondLineText ) |
|
544 { |
|
545 iSecondTextVisual->SetTextL( *aSecondLineText ); |
|
546 iHasSecondTextLine = ETrue; |
|
547 } |
|
548 |
|
549 if ( aIconTexture ) |
|
550 { |
|
551 iHasIcon = ETrue; |
|
552 iImageVisual->SetImage( TAlfImage( *aIconTexture ) ); |
|
553 } |
|
554 } |
|
555 |
|
556 void CFSEmailUiStatusIndicator::HideIndicator( TInt aDelayBeforeHidingInMs /*= 0*/ ) |
|
557 { |
|
558 FUNC_LOG; |
|
559 if ( iFirstStartCompleted ) // Safety |
|
560 { |
|
561 // Cancel any running hiding timer to prevent indicator being slided off twice. |
|
562 iTimer->Stop(); |
|
563 |
|
564 if ( aDelayBeforeHidingInMs > 0 ) |
|
565 { |
|
566 iTimer->Start( aDelayBeforeHidingInMs ); |
|
567 } |
|
568 else // hide now |
|
569 { |
|
570 CAlfControlGroup* group = ControlGroup(); |
|
571 CAlfDisplay* temp = Display(); |
|
572 Env().Send(TAlfGroupCommand(*group, EAlfOpHide, Display()), iAppUi->LayoutHandler()->StatusIndicatorFadeEffectTime()); |
|
573 //Display().Roster().ShowL(*group); |
|
574 SetOpacity(0, iAppUi->LayoutHandler()->StatusIndicatorFadeEffectTime()); |
|
575 |
|
576 TRect tempRect = iParentRect; |
|
577 tempRect.Move( 0, iContentHeight - 2*iBorderPadding ); |
|
578 iParentLayout->SetRect( tempRect, iAppUi->LayoutHandler()->StatusIndicatorFadeEffectTime() ); |
|
579 |
|
580 iVisible = EFalse; |
|
581 } |
|
582 } |
|
583 } |
|
584 |
|
585 TBool CFSEmailUiStatusIndicator::IsVisible() |
|
586 { |
|
587 FUNC_LOG; |
|
588 return iVisible; |
|
589 } |
|
590 |
|
591 // --------------------------------------------------------------------------- |
|
592 // HandleForegroundEventL |
|
593 // The function is called by Appui or Mail viewer visualiser, to resize the |
|
594 // window correctly after the screensaver, if the status indicator is visible |
|
595 // --------------------------------------------------------------------------- |
|
596 void CFSEmailUiStatusIndicator::HandleForegroundEventL() |
|
597 { |
|
598 FUNC_LOG; |
|
599 if ( iFirstStartCompleted && iVisible ) |
|
600 { |
|
601 DoShowIndicator( EIndicationLayoutUpdated ); |
|
602 } |
|
603 } |
|
604 |
|
605 void CFSEmailUiStatusIndicator::NotifyLayoutChange() |
|
606 { |
|
607 FUNC_LOG; |
|
608 if ( iFirstStartCompleted && iVisible ) |
|
609 { |
|
610 DoShowIndicator( EIndicationLayoutUpdated ); |
|
611 } |
|
612 } |
|
613 |
|
614 void CFSEmailUiStatusIndicator::HandleCommandL(TInt /*aCommand*/) |
|
615 { |
|
616 FUNC_LOG; |
|
617 // Status indicator does not handle any commands. |
|
618 } |
|
619 |
|
620 TBool CFSEmailUiStatusIndicator::OfferEventL(const TAlfEvent& /*aEvent*/) |
|
621 { |
|
622 FUNC_LOG; |
|
623 return EFalse; // Not consumed. Status indicator does not handle any events. |
|
624 } |
|
625 |
|
626 void CFSEmailUiStatusIndicator::SetOpacity( TReal aOpacity, TInt aTransitionTime ) |
|
627 { |
|
628 FUNC_LOG; |
|
629 if ( iFirstStartCompleted ) // Safety |
|
630 { |
|
631 TAlfTimedValue opacity = iParentLayout->Opacity(); |
|
632 opacity.SetTarget( aOpacity, aTransitionTime ); |
|
633 iParentLayout->SetOpacity( opacity ); |
|
634 } |
|
635 } |
|
636 |
|
637 // --------------------------------------------------------------------------- |
|
638 // Load the needed icons |
|
639 // --------------------------------------------------------------------------- |
|
640 // |
|
641 void CFSEmailUiStatusIndicator::LoadIconsL() |
|
642 { |
|
643 FUNC_LOG; |
|
644 iIconArray.Reset(); |
|
645 // NOTE: Must be appended same order as are in TStatusIndicationTypes! |
|
646 iIconArray.AppendL( &iAppUi->FsTextureManager()->TextureByIndex( EStatusTextureSynchronising ) ); // EIndicationSynchronising |
|
647 iIconArray.AppendL( &iAppUi->FsTextureManager()->TextureByIndex( EStatusTextureConnected ) ); // EIndicationConnected |
|
648 // Change to EStatusTextureConnecting when icon available!!! |
|
649 iIconArray.AppendL( &iAppUi->FsTextureManager()->TextureByIndex( EStatusTextureConnecting ) ); // EIndicationConnecting |
|
650 iIconArray.AppendL( &iAppUi->FsTextureManager()->TextureByIndex( EStatusTextureDisconnectedGeneral ) ); // EIndicationDisconnectedGeneral |
|
651 iIconArray.AppendL( &iAppUi->FsTextureManager()->TextureByIndex( EStatusTextureDisconnectedError ) ); // EIndicationDisconnectedError |
|
652 iIconArray.AppendL( &iAppUi->FsTextureManager()->TextureByIndex( EStatusTextureDisconnectedLowBattery ) ); // EIndicationDisconnectedLowBattery |
|
653 iIconArray.AppendL( &iAppUi->FsTextureManager()->TextureByIndex( EStatusTextureMailSent ) ); // EIndicationMailSent |
|
654 iIconArray.AppendL( &iAppUi->FsTextureManager()->TextureByIndex( EStatusTextureDisconnectedGeneral ) ); // EIndicationCancelSynchronising // there's no icon for this but add entry anyway to maintain the array order |
|
655 iIconArray.AppendL( &iAppUi->FsTextureManager()->TextureByIndex( EAttachmentsDownload ) ); //EIndicationDownloadStarted |
|
656 iIconArray.AppendL( &iAppUi->FsTextureManager()->TextureByIndex( EAttachmentsDownload ) ); // EIndicationDownloadProgress |
|
657 |
|
658 for( TInt i = 0; i < iIconArray.Count(); ++i ) |
|
659 { |
|
660 if ( i != EIndicationDownloadProgress && |
|
661 i != EIndicationDownloadStarted ) // attachment icon should use its original (smaller) size |
|
662 { |
|
663 iIconArray[i]->Size().SetSize( KIconArraySize, KIconArraySize ); |
|
664 } |
|
665 } |
|
666 } |
|
667 |
|
668 |
|
669 void CFSEmailUiStatusIndicator::TimerEventL( CFSEmailUiGenericTimer* /*aTriggeredTimer*/ ) |
|
670 { |
|
671 FUNC_LOG; |
|
672 HideIndicator(); |
|
673 } |
|
674 |