|
1 /* |
|
2 * Copyright (c) 2007-2010 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 main grid implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // SYSTEM INCLUDE FILES |
|
20 #include "emailtrace.h" |
|
21 #include <coemain.h> |
|
22 #include <StringLoader.h> |
|
23 #include <AknUtils.h> |
|
24 #include <AknsUtils.h> |
|
25 #include <AknsSkinInstance.h> |
|
26 #include <apgcli.h> // RApaLsSession |
|
27 #include <e32math.h> |
|
28 #include <FreestyleEmailUi.rsg> |
|
29 #include <touchlogicalfeedback.h> |
|
30 #include <alf/alfutil.h> |
|
31 #include <alf/alfenv.h> |
|
32 #include <alf/alfevent.h> |
|
33 #include <alf/alftextvisual.h> |
|
34 #include <aknnotewrappers.h> |
|
35 #include <freestyleemailui.mbg> |
|
36 #include <gulicon.h> |
|
37 #include <akntoolbar.h> |
|
38 #include "cfsmailmessage.h" |
|
39 #include <alf/alfframebrush.h> |
|
40 #include "cfsmailbox.h" |
|
41 #include "cfsmailclient.h" |
|
42 #include <hlplch.h> |
|
43 #include <akntitle.h> |
|
44 #include <centralrepository.h> |
|
45 #include <alf/alfanchorlayout.h> |
|
46 #include <alf/alfbrusharray.h> |
|
47 #include <alf/alfstatic.h> |
|
48 #include <alf/alfgencomponent.h> |
|
49 #include <alf/alfconstants.h> |
|
50 #include "fsalfscrollbarlayout.h" |
|
51 #include <csxhelp/cmail.hlp.hrh> |
|
52 #include <featmgr.h> |
|
53 #include <coecntrl.h> |
|
54 |
|
55 #include <aknmessagequerydialog.h> |
|
56 #include <aknstyluspopupmenu.h> |
|
57 #include <aknlayoutscalable_avkon.cdl.h> |
|
58 #include <aknlayoutscalable_apps.cdl.h> |
|
59 #include <layoutmetadata.cdl.h> |
|
60 #include <touchfeedback.h> |
|
61 #include <aknphysics.h> |
|
62 |
|
63 // INTERNAL INCLUDE FILES |
|
64 #include "FSEmailBuildFlags.h" |
|
65 #include "FreestyleEmailUiConstants.h" |
|
66 #include "FreestyleEmailUiLiterals.h" |
|
67 #include "FreestyleEmailUiLauncherGrid.h" |
|
68 #include "FreestyleEmailUiLauncherGridVisualiser.h" |
|
69 #include "FreestyleEmailUi.hrh" |
|
70 #include "FreestyleEmailUiLayoutHandler.h" |
|
71 #include "FreestyleEmailUiTextureManager.h" |
|
72 #include "FreestyleEmailUiMailListVisualiser.h" |
|
73 #include "FreestyleEmailUiShortcutBinding.h" |
|
74 #include "FSDelayedLoader.h" |
|
75 |
|
76 // Utility clean up function |
|
77 void CleanupEComArray( TAny* aArray ); |
|
78 |
|
79 // CONSTANT VALUES |
|
80 const TReal KDefaultCaptionOpacity = 1.0; |
|
81 const TInt KDefaultSelection = 0; |
|
82 const TInt KSelectTransitionTimeMs = 300; |
|
83 const TInt KIconScalingTransitionTimeMs = 350; |
|
84 const TInt KStartupAnimationTime = 0; |
|
85 const TReal KScaleSelected = 1.0; |
|
86 const TReal KScaleNotSelected = 0.77; |
|
87 |
|
88 |
|
89 CFSEmailUiLauncherGridVisualiser* CFSEmailUiLauncherGridVisualiser::NewL(CAlfEnv& aEnv, |
|
90 CFSEmailUiLauncherGrid* aControl, |
|
91 CFreestyleEmailUiAppUi* aAppUi, |
|
92 CAlfControlGroup& aControlGroup, |
|
93 TInt aColumns, TInt aRows) |
|
94 { |
|
95 FUNC_LOG; |
|
96 CFSEmailUiLauncherGridVisualiser* self = CFSEmailUiLauncherGridVisualiser::NewLC(aEnv, aControl, aAppUi, aControlGroup, aRows, aColumns); |
|
97 CleanupStack::Pop(self); |
|
98 return self; |
|
99 } |
|
100 |
|
101 CFSEmailUiLauncherGridVisualiser* CFSEmailUiLauncherGridVisualiser::NewLC(CAlfEnv& aEnv, |
|
102 CFSEmailUiLauncherGrid* aControl, |
|
103 CFreestyleEmailUiAppUi* aAppUi, |
|
104 CAlfControlGroup& aControlGroup, |
|
105 TInt aColumns, TInt aRows) |
|
106 { |
|
107 FUNC_LOG; |
|
108 CFSEmailUiLauncherGridVisualiser* self = new (ELeave) CFSEmailUiLauncherGridVisualiser(aEnv, aControl, aAppUi, aControlGroup); |
|
109 CleanupStack::PushL(self); |
|
110 self->ConstructL(aColumns, aRows); |
|
111 return self; |
|
112 } |
|
113 |
|
114 CFSEmailUiLauncherGridVisualiser::CFSEmailUiLauncherGridVisualiser(CAlfEnv& aEnv, |
|
115 CFSEmailUiLauncherGrid* aControl, |
|
116 CFreestyleEmailUiAppUi* aAppUi, |
|
117 CAlfControlGroup& aControlGroup) |
|
118 : CFsEmailUiViewBase(aControlGroup, *aAppUi), |
|
119 iEnv( aEnv ), |
|
120 iVisibleRows( 0 ), |
|
121 iVisibleColumns( 0 ), |
|
122 iRowCount( 0 ), |
|
123 iFirstVisibleRow( 0 ), |
|
124 iRowHeight( 0 ), |
|
125 iColumnWidth( 0 ), |
|
126 iSelector( 0 ), |
|
127 iStartupAnimation( 0 ), |
|
128 iStartupEffectStyle( 0 ), |
|
129 iWizardWaitnoteShown( EFalse ), |
|
130 iPointerAction( EFalse ), |
|
131 iIsDragging( EFalse ), |
|
132 iScrolled( EFalse ), |
|
133 iLaunchWizardExecuted( EFalse ) |
|
134 { |
|
135 FUNC_LOG; |
|
136 iItemIdInButtonDownEvent.iItemId = KErrNotFound; |
|
137 iItemIdInButtonDownEvent.iLaunchSelection = EFalse; |
|
138 iControl = aControl; |
|
139 } |
|
140 |
|
141 void CFSEmailUiLauncherGridVisualiser::ConstructL( TInt aColumns, TInt aRows ) |
|
142 { |
|
143 FUNC_LOG; |
|
144 BaseConstructL( R_FSEMAILUI_MAINUI_VIEW ); |
|
145 iVisibleRows = aRows; |
|
146 iVisibleColumns = aColumns; |
|
147 iConstructionCompleted = EFalse; |
|
148 iDoubleClickLock = EFalse; |
|
149 iUiOperationLaunched = EFalse; |
|
150 |
|
151 iMailboxDeleter = CFSEmailUiMailboxDeleter::NewL( *iAppUi.GetMailClient(), *this ); |
|
152 |
|
153 // Create startup timer |
|
154 iStartupCallbackTimer = CFSEmailUiGenericTimer::NewL( this ); |
|
155 |
|
156 iCurrentLevel.iParentPos.iY = 0; |
|
157 iCurrentLevel.iParentPos.iX = 0; |
|
158 |
|
159 if ( CAknPhysics::FeatureEnabled() ) |
|
160 { |
|
161 iPhysics = CAknPhysics::NewL(*this, NULL); |
|
162 } |
|
163 } |
|
164 |
|
165 // ---------------------------------------------------------------------------- |
|
166 // CFSEmailUiLauncherGridVisualiser::DoFirstStartL() |
|
167 // Purpose of this function is to do first start only when grid is really |
|
168 // needed to be shown. Implemented to make app startup faster. |
|
169 // ---------------------------------------------------------------------------- |
|
170 // |
|
171 void CFSEmailUiLauncherGridVisualiser::DoFirstStartL() |
|
172 { |
|
173 FUNC_LOG; |
|
174 iPluginIdIconIdPairs.Reset(); |
|
175 |
|
176 TRect mainPaneRect; |
|
177 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, |
|
178 mainPaneRect ); |
|
179 |
|
180 TAknLayoutRect scrollBarRect; |
|
181 scrollBarRect.LayoutRect( mainPaneRect, |
|
182 AknLayoutScalable_Avkon::aid_size_touch_scroll_bar() ); |
|
183 TRect gridRect = mainPaneRect; |
|
184 gridRect.iBr.iX -= scrollBarRect.Rect().Width(); |
|
185 |
|
186 iVisibleRows = iAppUi.LayoutHandler()->GridRowsInThisResolution(); |
|
187 iVisibleColumns = iAppUi.LayoutHandler()->GridColumnsInThisResolution(); |
|
188 |
|
189 iStartupAnimation = ETrue; |
|
190 iCurrentLevel.iSelected = KDefaultSelection; |
|
191 CAlfTextureManager& manager = iEnv.TextureManager(); |
|
192 |
|
193 iParentLayout = CAlfDeckLayout::AddNewL( *iControl ); |
|
194 iParentLayout->SetFlags( EAlfVisualFlagLayoutUpdateNotification ); |
|
195 |
|
196 // Widget layout divides the screen between grid and scroll bar |
|
197 iWidgetLayout = CAlfAnchorLayout::AddNewL( *iControl, iParentLayout ); |
|
198 TSize displaySize = mainPaneRect.Size(); |
|
199 iWidgetLayout->SetSize( displaySize ); |
|
200 |
|
201 // Constructed here, updated later, #0 item in iWidgetLayout |
|
202 ConstructScrollbarL( iWidgetLayout ); |
|
203 |
|
204 // Grid layout is constructed here, #1 item in iWidgetLayout |
|
205 iCurrentLevel.iGridLayout = |
|
206 CAlfGridLayout::AddNewL( *iControl, iVisibleColumns, iVisibleRows, |
|
207 iWidgetLayout ); |
|
208 iCurrentLevel.iGridLayout->EnableScrollingL( ETrue ); |
|
209 iCurrentLevel.iGridLayout->SetFlags( EAlfVisualFlagAutomaticLocaleMirroringEnabled ); |
|
210 |
|
211 // Selector is added to iGridLayout |
|
212 iSelector = iControl->AppendLayoutL( EAlfLayoutTypeLayout, |
|
213 iCurrentLevel.iGridLayout ); |
|
214 iSelector->SetFlags( EAlfVisualFlagManualLayout ); |
|
215 |
|
216 iRingMovementXFunc = CAlfTableMappingFunction::NewL( iEnv ); |
|
217 iRingMovementYFunc = CAlfTableMappingFunction::NewL( iEnv ); |
|
218 |
|
219 TAlfTimedPoint selectorPos = iSelector->Pos(); |
|
220 selectorPos.iX.SetMappingFunctionIdentifier( iRingMovementXFunc->MappingFunctionIdentifier() ); |
|
221 selectorPos.iY.SetMappingFunctionIdentifier( iRingMovementYFunc->MappingFunctionIdentifier() ); |
|
222 iSelector->SetPos( selectorPos ); |
|
223 |
|
224 UpdateFocusVisibility(); |
|
225 iSelectorImageVisual = CAlfImageVisual::AddNewL( *iControl, iSelector ); |
|
226 iSelectorImageVisual->SetScaleMode( CAlfImageVisual::EScaleFit ); |
|
227 |
|
228 const TInt var( Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0 ); |
|
229 |
|
230 // Use layout data instead of hard-coded values |
|
231 TAknLayoutRect itemRect; |
|
232 itemRect.LayoutRect( gridRect, |
|
233 AknLayoutScalable_Apps::cell_cmail_l_pane( var, 0, 0 ) ); |
|
234 iSelectorImageVisual->SetSize( itemRect.Rect().Size() ); |
|
235 iSelectorImageVisual->EnableBrushesL(); |
|
236 CAlfFrameBrush* brush = iAppUi.FsTextureManager()->GridSelectorBrushL(); |
|
237 iSelectorImageVisual->Brushes()->AppendL( brush, EAlfDoesNotHaveOwnership ); |
|
238 iStartupEffectStyle = EFalse; |
|
239 |
|
240 iAiwSHandler = CAiwServiceHandler::NewL(); |
|
241 iAiwSHandler->AttachL( R_AIW_INTEREST_LAUNCH_SETUP_WIZARD ); |
|
242 |
|
243 if( !iStylusPopUpMenu ) |
|
244 { |
|
245 // Construct the long tap pop-up menu. |
|
246 TPoint point( 0, 0 ); |
|
247 iStylusPopUpMenu = CAknStylusPopUpMenu::NewL( this , point ); |
|
248 TResourceReader reader; |
|
249 iCoeEnv->CreateResourceReaderLC( reader, |
|
250 R_STYLUS_POPUP_MENU_LAUNCHER_GRID_VIEW ); |
|
251 iStylusPopUpMenu->ConstructFromResourceL( reader ); |
|
252 CleanupStack::PopAndDestroy(); // reader |
|
253 } |
|
254 |
|
255 iCoeControl = new( ELeave )CCoeControl; |
|
256 // Initial visual layout update is done when the view gets activated. |
|
257 iRefreshNeeded = ETrue; |
|
258 |
|
259 UpdatePhysicsL(); // init sizes for scrooling |
|
260 |
|
261 // First start toggle |
|
262 iConstructionCompleted = ETrue; |
|
263 } |
|
264 |
|
265 // --------------------------------------------------------------------------- |
|
266 // HandleButtonReleaseEventL is called when Launcher grid visualiser |
|
267 // gets pointer event that indicates that button is released. |
|
268 // function should decide if focus should still be drawn or not. |
|
269 // --------------------------------------------------------------------------- |
|
270 // |
|
271 void CFSEmailUiLauncherGridVisualiser::HandleButtonReleaseEvent() |
|
272 { |
|
273 iItemIdInButtonDownEvent.iItemId = KErrNotFound; |
|
274 iItemIdInButtonDownEvent.iLaunchSelection = EFalse; |
|
275 |
|
276 UpdateFocusVisibility(); |
|
277 |
|
278 if( !IsFocusShown() ) |
|
279 { |
|
280 // No items are focused anymore. Shrink the icon. |
|
281 ResizeItemIcon( ETrue ); |
|
282 } |
|
283 else |
|
284 { |
|
285 // Reset selected icon size back to normal |
|
286 ResizeItemIcon( EFalse ); |
|
287 } |
|
288 } |
|
289 |
|
290 // --------------------------------------------------------------------------- |
|
291 // Reduces icon size of seleceted item |
|
292 // Called when grag event is made. |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 void CFSEmailUiLauncherGridVisualiser::ResizeItemIcon( TBool aReduce ) |
|
296 { |
|
297 TInt selectedItem( iCurrentLevel.iSelected ); |
|
298 TInt count = iCurrentLevel.iItemVisualData.Count(); |
|
299 if ( selectedItem < 0 || selectedItem >= count ) |
|
300 { |
|
301 return; // incorrect index |
|
302 } |
|
303 |
|
304 if( selectedItem >= 0 ) |
|
305 { |
|
306 TReal transition( KScaleNotSelected ); |
|
307 if( !aReduce ) |
|
308 { |
|
309 transition = KScaleSelected; |
|
310 } |
|
311 TAlfTimedValue scaleValue; |
|
312 scaleValue.SetTarget( transition, KIconScalingTransitionTimeMs * 2 ); |
|
313 iCurrentLevel.iItemVisualData[selectedItem].iImage->SetScale( scaleValue ); |
|
314 if ( !iScrolled ) |
|
315 { |
|
316 HandleRowMovement( EDirectionTouch, selectedItem ); |
|
317 } |
|
318 } |
|
319 } |
|
320 |
|
321 CFSEmailUiLauncherGridVisualiser::~CFSEmailUiLauncherGridVisualiser() |
|
322 { |
|
323 FUNC_LOG; |
|
324 |
|
325 if ( iStartupCallbackTimer ) |
|
326 { |
|
327 iStartupCallbackTimer->Cancel(); |
|
328 delete iStartupCallbackTimer; |
|
329 } |
|
330 |
|
331 iPluginIdIconIdPairs.Reset(); |
|
332 iIconArray.Close(); |
|
333 iMailboxRequestIds.Close(); |
|
334 iLauncherItems.ResetAndDestroy(); |
|
335 iLauncherItemUids.Close(); |
|
336 iCurrentLevel.iItemVisualData.Close(); |
|
337 iCurrentLevel.iItems.Close(); |
|
338 DetachSelectorMappingFunctions(); |
|
339 delete iRingMovementXFunc; |
|
340 delete iRingMovementYFunc; |
|
341 delete iModel; |
|
342 delete iAiwSHandler; |
|
343 delete iScrollbar; |
|
344 delete iMailboxDeleter; |
|
345 delete iStylusPopUpMenu; |
|
346 delete iCoeControl; |
|
347 delete iPhysics; |
|
348 } |
|
349 |
|
350 void CFSEmailUiLauncherGridVisualiser::CreateModelL() |
|
351 { |
|
352 FUNC_LOG; |
|
353 |
|
354 RArray<TBool> itemInModel; |
|
355 CleanupClosePushL( itemInModel ); |
|
356 iIconArray.Reset(); |
|
357 |
|
358 iPluginTextureId = EGridPluginIconFirst; |
|
359 iPluginIdIconIdPairs.Reset(); |
|
360 |
|
361 delete iModel; |
|
362 iModel = NULL; |
|
363 iModel = new (ELeave) CFSEmailUiLauncherGridModel(); |
|
364 iModel->ConstructL(); |
|
365 CAlfTexture* iconTexture = 0; |
|
366 |
|
367 // Get item ordering from resources |
|
368 TResourceReader reader; |
|
369 iEikonEnv->CreateResourceReaderLC( reader, R_FSEMAILUI_LAUNCHER_GRID ); |
|
370 |
|
371 UpdateLauncherItemListL(); |
|
372 MFSMailBrandManager& brandManager = iAppUi.GetMailClient()->GetBrandManagerL(); |
|
373 |
|
374 for ( TInt i = 0; i < iLauncherItems.Count(); i++ ) |
|
375 { |
|
376 itemInModel.Append( EFalse ); |
|
377 } |
|
378 |
|
379 TInt count = reader.ReadInt16(); |
|
380 |
|
381 TRect mainPaneRect; |
|
382 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); |
|
383 |
|
384 TAknLayoutRect scrollBarRect; |
|
385 scrollBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar()); |
|
386 TRect gridRect = mainPaneRect; |
|
387 gridRect.iBr.iX -= scrollBarRect.Rect().Width(); |
|
388 |
|
389 TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
|
390 TAknLayoutRect itemRect; |
|
391 itemRect.LayoutRect(gridRect, AknLayoutScalable_Apps::cell_cmail_l_pane(var,0,0)); |
|
392 |
|
393 TAknLayoutRect gridIconLRect; |
|
394 gridIconLRect.LayoutRect(itemRect.Rect(), AknLayoutScalable_Apps::cell_cmail_l_pane_g1(var)); |
|
395 TSize iconSize = gridIconLRect.Rect().Size(); |
|
396 |
|
397 for ( TInt itemIndex = 0; itemIndex < count; itemIndex++ ) |
|
398 { |
|
399 TInt itemId = reader.ReadInt16(); |
|
400 switch ( itemId ) |
|
401 { |
|
402 case EDefaultMailboxItem: |
|
403 { |
|
404 |
|
405 RPointerArray<CFSMailBox> mailBoxes; |
|
406 CleanupResetAndDestroyClosePushL( mailBoxes ); |
|
407 TFSMailMsgId id; |
|
408 TInt err = iAppUi.GetMailClient()->ListMailBoxes( |
|
409 id, |
|
410 mailBoxes ); |
|
411 |
|
412 if ( mailBoxes.Count() > 0 ) |
|
413 { |
|
414 // Try to get branded graphic |
|
415 CGulIcon* mbIcon(0); |
|
416 TRAPD( err, mbIcon = brandManager.GetGraphicL( EFSMailboxIcon, mailBoxes[0]->GetId() ) ); |
|
417 if ( err == KErrNone && mbIcon ) |
|
418 { |
|
419 CleanupStack::PushL( mbIcon ); |
|
420 AknIconUtils::SetSize(mbIcon->Bitmap(), iconSize); |
|
421 AknIconUtils::SetSize(mbIcon->Mask(), iconSize); |
|
422 |
|
423 // Create texture into TextureManager, If not already existing |
|
424 // Note: size(0,0) means original icon size |
|
425 iAppUi.FsTextureManager()->CreateBrandedMailboxTexture( mbIcon, |
|
426 mailBoxes[0]->GetId().PluginId(), |
|
427 mailBoxes[0]->GetId().Id(), |
|
428 TSize(0,0)); |
|
429 // Get branded mailbox icon |
|
430 iconTexture = &iAppUi.FsTextureManager()->TextureByMailboxIdL( mailBoxes[0]->GetId().PluginId(), |
|
431 mailBoxes[0]->GetId().Id(), |
|
432 TSize(0,0)); |
|
433 |
|
434 CleanupStack::PopAndDestroy( mbIcon ); |
|
435 } |
|
436 else |
|
437 { |
|
438 iconTexture = &iAppUi.FsTextureManager()->TextureByIndex( EGridInboxTexture ); |
|
439 } |
|
440 |
|
441 iIconArray.AppendL( iconTexture ); |
|
442 |
|
443 // Branded mailbox name is nowadays set in new mailbox event |
|
444 // handling, so we don't need to use brand manager here anymore. |
|
445 iModel->AddL( |
|
446 EShortcut, |
|
447 EDefaultMailboxItem, |
|
448 mailBoxes[0]->GetName(), |
|
449 *iconTexture, |
|
450 mailBoxes[0]->GetId(), |
|
451 mailBoxes[0]->GetStandardFolderId( EFSInbox ) ); |
|
452 |
|
453 iAppUi.SubscribeMailboxL( mailBoxes[0]->GetId() ); |
|
454 } |
|
455 |
|
456 CleanupStack::PopAndDestroy( &mailBoxes ); |
|
457 } |
|
458 break; |
|
459 case EOtherMailboxItems: |
|
460 { |
|
461 RPointerArray<CFSMailBox> mailBoxes; |
|
462 CleanupResetAndDestroyClosePushL( mailBoxes ); |
|
463 TFSMailMsgId id; |
|
464 TInt err = iAppUi.GetMailClient()->ListMailBoxes( |
|
465 id, |
|
466 mailBoxes ); |
|
467 |
|
468 for ( TInt i = 1; i < mailBoxes.Count(); i++ ) |
|
469 { |
|
470 // Try to get branded graphic |
|
471 CGulIcon* mbIcon(0); |
|
472 TRAPD( err, mbIcon = brandManager.GetGraphicL( EFSMailboxIcon, mailBoxes[i]->GetId() ) ); |
|
473 if ( err == KErrNone && mbIcon ) |
|
474 { |
|
475 CleanupStack::PushL( mbIcon ); |
|
476 AknIconUtils::SetSize(mbIcon->Bitmap(), iconSize); |
|
477 AknIconUtils::SetSize(mbIcon->Mask(), iconSize); |
|
478 |
|
479 // Create texture into TextureManager, If not already existing |
|
480 iAppUi.FsTextureManager()->CreateBrandedMailboxTexture( mbIcon, |
|
481 mailBoxes[i]->GetId().PluginId(), |
|
482 mailBoxes[i]->GetId().Id(), |
|
483 TSize(0,0)); |
|
484 // Get branded mailbox icon |
|
485 iconTexture = &iAppUi.FsTextureManager()->TextureByMailboxIdL( mailBoxes[i]->GetId().PluginId(), |
|
486 mailBoxes[i]->GetId().Id(), |
|
487 TSize(0,0)); |
|
488 CleanupStack::PopAndDestroy( mbIcon ); |
|
489 } |
|
490 else |
|
491 { |
|
492 iconTexture = &iAppUi.FsTextureManager()->TextureByIndex( EGridInboxTexture ); |
|
493 } |
|
494 iIconArray.AppendL( iconTexture ); |
|
495 // Branded mailbox name is nowadays set in new mailbox event |
|
496 // handling, so we don't need to use brand manager here anymore. |
|
497 iModel->AddL( |
|
498 EShortcut, |
|
499 EDefaultMailboxItem, |
|
500 mailBoxes[i]->GetName(), |
|
501 *iconTexture, |
|
502 mailBoxes[i]->GetId(), |
|
503 mailBoxes[i]->GetStandardFolderId( EFSInbox ) ); |
|
504 |
|
505 iAppUi.SubscribeMailboxL( mailBoxes[i]->GetId() ); |
|
506 } |
|
507 |
|
508 CleanupStack::PopAndDestroy( &mailBoxes ); |
|
509 } |
|
510 break; |
|
511 case EDirectoryItem: |
|
512 { |
|
513 RPointerArray<CFSMailBox> mailBoxes; |
|
514 CleanupResetAndDestroyClosePushL( mailBoxes ); |
|
515 TFSMailMsgId id; |
|
516 TInt err = iAppUi.GetMailClient()->ListMailBoxes( |
|
517 id, |
|
518 mailBoxes ); |
|
519 |
|
520 for ( TInt i = 0; i < mailBoxes.Count(); i++ ) |
|
521 { |
|
522 if ( TFsEmailUiUtility::IsRemoteLookupSupported( *mailBoxes[i] ) ) |
|
523 { |
|
524 HBufC* text = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_GRIDITEM_DIRECTORY ); |
|
525 iconTexture = &iAppUi.FsTextureManager()->TextureByIndex( EGridDirectoryTexture ); |
|
526 iModel->AddL(EShortcut, EDirectoryItem, *text, *iconTexture ); |
|
527 CleanupStack::PopAndDestroy( text ); |
|
528 iIconArray.AppendL( iconTexture ); |
|
529 break; |
|
530 } |
|
531 } |
|
532 |
|
533 CleanupStack::PopAndDestroy( &mailBoxes ); |
|
534 } |
|
535 break; |
|
536 case ESettingsItem: |
|
537 { |
|
538 HBufC* text = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_GRIDITEM_SETTINGS ); |
|
539 iconTexture = &iAppUi.FsTextureManager()->TextureByIndex( EGridSettingsTexture ); |
|
540 iModel->AddL(EShortcut, ESettingsItem, *text, *iconTexture ); |
|
541 CleanupStack::PopAndDestroy( text ); |
|
542 iIconArray.AppendL( iconTexture ); |
|
543 } |
|
544 break; |
|
545 case EAddNewMailboxItem: |
|
546 { |
|
547 HBufC* text = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_GRIDITEM_ADD_NEW_MAILBOX ); |
|
548 iconTexture = &iAppUi.FsTextureManager()->TextureByIndex( EGridAddNewBoxTexture ); |
|
549 iModel->AddL(EShortcut, EAddNewMailboxItem, *text, *iconTexture ); |
|
550 CleanupStack::PopAndDestroy( text ); |
|
551 iIconArray.AppendL( iconTexture ); |
|
552 } |
|
553 break; |
|
554 case EHelpItem: |
|
555 { |
|
556 // remove help support in pf5250 |
|
557 if (! FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) ) |
|
558 { |
|
559 HBufC* text = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_GRIDITEM_HELP ); |
|
560 iconTexture = &iAppUi.FsTextureManager()->TextureByIndex( EGridHelpTexture ); |
|
561 iModel->AddL(EShortcut, EHelpItem, *text, *iconTexture ); |
|
562 CleanupStack::PopAndDestroy( text ); |
|
563 iIconArray.AppendL( iconTexture ); |
|
564 } |
|
565 } |
|
566 break; |
|
567 case EIntellisyncFileSyncItem: |
|
568 case EIntellisyncTravelInfoItem: |
|
569 case EIntellisyncBackupItem: |
|
570 case EIntellisyncRestoreItem: |
|
571 case EIntellisyncUpgradeItem: |
|
572 case EIntellisyncRemoteControlItem: |
|
573 { |
|
574 for ( TInt i = 0; i < iLauncherItems.Count(); i++ ) |
|
575 { |
|
576 if ( iLauncherItems[i]->Id() == itemId ) |
|
577 { |
|
578 itemInModel[i] = ETrue; |
|
579 AddItemToModelL( iLauncherItems[i], i ); |
|
580 break; |
|
581 } |
|
582 } |
|
583 } |
|
584 break; |
|
585 default: |
|
586 break; |
|
587 } |
|
588 } |
|
589 |
|
590 CleanupStack::PopAndDestroy(); // reader internal state |
|
591 |
|
592 // Rest of the launcher items |
|
593 for ( TInt i = 0; i < iLauncherItems.Count(); i++ ) |
|
594 { |
|
595 if ( ! itemInModel[i] ) |
|
596 { |
|
597 AddItemToModelL( iLauncherItems[i], i ); |
|
598 } |
|
599 } |
|
600 |
|
601 CleanupStack::PopAndDestroy( &itemInModel ); |
|
602 } |
|
603 |
|
604 void CFSEmailUiLauncherGridVisualiser::CreateCaptionForApplicationL(TUid aUid, |
|
605 TDes& aCaption, |
|
606 TBool aShortCaption) |
|
607 { |
|
608 FUNC_LOG; |
|
609 RApaLsSession ls; |
|
610 User::LeaveIfError( ls.Connect() ); |
|
611 TApaAppInfo appInfo; |
|
612 TInt ret = ls.GetAppInfo( appInfo, aUid ); |
|
613 if ( ret == KErrNone ) |
|
614 { |
|
615 if ( !aShortCaption ) |
|
616 { |
|
617 aCaption = appInfo.iCaption; |
|
618 } |
|
619 else |
|
620 { |
|
621 aCaption = appInfo.iShortCaption; |
|
622 } |
|
623 } |
|
624 ls.Close(); |
|
625 } |
|
626 |
|
627 |
|
628 TUid CFSEmailUiLauncherGridVisualiser::Id() const |
|
629 { |
|
630 FUNC_LOG; |
|
631 return AppGridId; |
|
632 } |
|
633 |
|
634 void CFSEmailUiLauncherGridVisualiser::ChildDoActivateL(const TVwsViewId& aPrevViewId, |
|
635 TUid /*aCustomMessageId*/, |
|
636 const TDesC8& /*aCustomMessage*/) |
|
637 { |
|
638 FUNC_LOG; |
|
639 if ( !iConstructionCompleted ) |
|
640 { |
|
641 DoFirstStartL(); |
|
642 } |
|
643 |
|
644 if( iAppUi.CurrentFixedToolbar() ) |
|
645 { |
|
646 iAppUi.CurrentFixedToolbar()->SetToolbarVisibility( EFalse ); |
|
647 } |
|
648 |
|
649 // For initial mailbox query |
|
650 TBool startedFromOds = EFalse; |
|
651 // NULL wizard started parameter every time when activated again. |
|
652 iDoubleClickLock = EFalse; |
|
653 |
|
654 if ( aPrevViewId.iAppUid.iUid == 0 && |
|
655 iAppUi.CurrentActiveView() != this ) |
|
656 { |
|
657 // Started from wizard do not show query |
|
658 startedFromOds = ETrue; |
|
659 // This view activation has not come through according normal view |
|
660 // activation procedure, so we should ignore this by activating |
|
661 // the currently active view again. This has been made to |
|
662 // avoid problems when ODS setup is completed. |
|
663 if ( iAppUi.CurrentActiveView()->Id() == MailListId ) |
|
664 { |
|
665 TMailListActivationData tmp; |
|
666 tmp.iReturnAfterWizard = ETrue; |
|
667 const TPckgBuf<TMailListActivationData> pkgOut( tmp ); |
|
668 iAppUi.EnterFsEmailViewL( MailListId, KStartListReturnToPreviousFolder, pkgOut ); |
|
669 } |
|
670 else if ( iAppUi.CurrentActiveView()->Id() == MailViewerId ) |
|
671 { |
|
672 TMsgViewerActivationData tmp; |
|
673 const TPckgBuf<TMsgViewerActivationData> pkgOut( tmp ); |
|
674 iAppUi.EnterFsEmailViewL( MailViewerId, KStartViewerReturnToPreviousMsg, pkgOut); |
|
675 } |
|
676 else |
|
677 { |
|
678 iAppUi.EnterFsEmailViewL( iAppUi.CurrentActiveView()->Id() ); |
|
679 } |
|
680 |
|
681 return; |
|
682 } |
|
683 |
|
684 if ( iRefreshNeeded ) |
|
685 { |
|
686 CreateModelL(); |
|
687 RescaleIconsL(); |
|
688 VisualLayoutUpdatedL(); |
|
689 } |
|
690 else |
|
691 { |
|
692 // scroll bar needs to be updated manually anyway |
|
693 UpdateScrollBarRangeL(); |
|
694 } |
|
695 |
|
696 SetDefaultStatusPaneTextL(); |
|
697 |
|
698 // Mailbox query is called here but shown only once in appui if needed |
|
699 // doNotshowQuery is ETrue when started from wizard |
|
700 if ( !iFirstStartComplete ) |
|
701 { |
|
702 iFirstStartComplete = ETrue; |
|
703 iAppUi.GridStarted( startedFromOds ); |
|
704 iAppUi.ShowMailboxQueryL(); |
|
705 } |
|
706 else |
|
707 { |
|
708 // Ensure that FSMailServer is running, but don't do it on first |
|
709 // activation, as it's done anyway in AppUi's ConstructL |
|
710 TFsEmailUiUtility::EnsureFsMailServerIsRunning( iEikonEnv->WsSession() ); |
|
711 } |
|
712 |
|
713 if( iRowCount > iVisibleRows ) |
|
714 { |
|
715 iScrollbar->MakeVisible(ETrue); |
|
716 } |
|
717 else |
|
718 { |
|
719 iScrollbar->MakeVisible(EFalse); |
|
720 } |
|
721 |
|
722 iAppUi.HideTitlePaneConnectionStatus(); |
|
723 |
|
724 // Erase the navigation history when main grid activated. This is the default view |
|
725 // of the application and back navigation is never possible from here. The view stack |
|
726 // might be in inconsistent state because of some unexpected error in view switching. |
|
727 // Erasing the history helps recovering from such situations. |
|
728 iAppUi.EraseViewHistory(); |
|
729 FocusVisibilityChange( iAppUi.IsFocusShown() ); |
|
730 UpdateFocusVisibility(); |
|
731 } |
|
732 |
|
733 void CFSEmailUiLauncherGridVisualiser::ChildDoDeactivate() |
|
734 { |
|
735 FUNC_LOG; |
|
736 iScrollbar->MakeVisible(EFalse); |
|
737 } |
|
738 |
|
739 void CFSEmailUiLauncherGridVisualiser::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) |
|
740 { |
|
741 FUNC_LOG; |
|
742 |
|
743 if ( aResourceId == R_FSEMAILUI_MAINUIGRID_MENUPANE ) |
|
744 { |
|
745 if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) ) |
|
746 { |
|
747 // remove help support in pf5250 |
|
748 aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue); |
|
749 } |
|
750 |
|
751 TFSLauncherGridMailboxStatus mbStatus = CheckMailboxStatusL(); |
|
752 |
|
753 // Checks if a device has a keyboard or not. |
|
754 if( !IsFocusShown() ) |
|
755 { |
|
756 if( mbStatus.iMailboxCount <= 0 ) |
|
757 { |
|
758 // If no mailboxes configured, dim all mailbox related items. |
|
759 aMenuPane->SetItemDimmed( EFsEmailUiCmdDeleteMailbox, ETrue ); |
|
760 } |
|
761 |
|
762 aMenuPane->SetItemDimmed( EFsEmailUiCmdOpen, ETrue ); |
|
763 aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, ETrue ); |
|
764 aMenuPane->SetItemDimmed( EFsEmailUiCmdSyncAll, ETrue ); |
|
765 aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelSync, ETrue ); |
|
766 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOffline, ETrue ); |
|
767 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOfflineAll, ETrue ); |
|
768 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnline, ETrue ); |
|
769 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnlineAll, ETrue ); |
|
770 aMenuPane->SetItemDimmed( EFsEmailUiCmdAbout, ETrue ); |
|
771 } |
|
772 else |
|
773 { |
|
774 aMenuPane->SetItemDimmed( EFsEmailUiCmdAbout, ETrue ); |
|
775 |
|
776 if( mbStatus.iMailboxCount <= 0 ) |
|
777 { |
|
778 // If no mailboxes configured, dimm all mailbox related items |
|
779 aMenuPane->SetItemDimmed( EFsEmailUiCmdDeleteMailbox, ETrue ); |
|
780 aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelSync, ETrue); |
|
781 aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, ETrue ); |
|
782 aMenuPane->SetItemDimmed( EFsEmailUiCmdSyncAll, ETrue ); |
|
783 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnline, ETrue ); |
|
784 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnlineAll, ETrue ); |
|
785 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOffline, ETrue ); |
|
786 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOfflineAll, ETrue ); |
|
787 } |
|
788 else |
|
789 { |
|
790 // Handle items related to sync cancelling |
|
791 if( mbStatus.iMailboxesSyncing == 0 ) |
|
792 { |
|
793 // All mailboxes are already not syncing |
|
794 aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelSync, ETrue ); |
|
795 } |
|
796 |
|
797 // Handle items related to sync starting |
|
798 if( mbStatus.iMailboxesSyncing == mbStatus.iMailboxCount ) |
|
799 { |
|
800 // All mailboxes are already syncing |
|
801 aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, ETrue ); |
|
802 aMenuPane->SetItemDimmed( EFsEmailUiCmdSyncAll, ETrue ); |
|
803 } |
|
804 else if( mbStatus.iMailboxCount == 1 ) |
|
805 { |
|
806 // Only one mailbox configured, dimm "Synchronise all" |
|
807 aMenuPane->SetItemDimmed( EFsEmailUiCmdSyncAll, ETrue ); |
|
808 } |
|
809 else |
|
810 { |
|
811 // Several mailboxes configured, dimm "Synchronise" |
|
812 aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, ETrue ); |
|
813 } |
|
814 |
|
815 // Handle items related to online |
|
816 if( mbStatus.iMailboxesOnline == mbStatus.iMailboxCount ) |
|
817 { |
|
818 // All mailboxes are already online |
|
819 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnline, ETrue ); |
|
820 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnlineAll, ETrue ); |
|
821 } |
|
822 else if( mbStatus.iMailboxCount == 1 ) |
|
823 { |
|
824 // Only one mailbox configured, dimm "Connect all" |
|
825 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnlineAll, ETrue ); |
|
826 } |
|
827 else |
|
828 { |
|
829 // Several mailboxes configured, dimm "Connect" |
|
830 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnline, ETrue ); |
|
831 } |
|
832 |
|
833 // Handle pop accounts that can't sync |
|
834 RPointerArray<CFSMailBox> mailBoxes; |
|
835 CleanupResetAndDestroyClosePushL( mailBoxes ); |
|
836 TFSMailMsgId id; |
|
837 bool onlyPop = true; |
|
838 TInt err = iAppUi.GetMailClient()->ListMailBoxes( |
|
839 id, |
|
840 mailBoxes ); |
|
841 |
|
842 for ( TInt i = 0; i < mailBoxes.Count(); i++ ) |
|
843 { |
|
844 if (mailBoxes[i]->HasCapability( EFSMBoxCapaSupportsSync )) |
|
845 { |
|
846 onlyPop = false; |
|
847 } |
|
848 } |
|
849 |
|
850 if (onlyPop) |
|
851 { |
|
852 aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, ETrue ); |
|
853 aMenuPane->SetItemDimmed( EFsEmailUiCmdSyncAll, ETrue ); |
|
854 } |
|
855 |
|
856 CleanupStack::PopAndDestroy( &mailBoxes ); |
|
857 |
|
858 // Handle items related to offline |
|
859 if( mbStatus.iMailboxesOffline == mbStatus.iMailboxCount ) |
|
860 { |
|
861 // All mailboxes are already offline |
|
862 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOffline, ETrue ); |
|
863 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOfflineAll, ETrue ); |
|
864 } |
|
865 else if( mbStatus.iMailboxCount == 1 ) |
|
866 { |
|
867 // Only one mailbox configured, dimm "Disconnect all" |
|
868 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOfflineAll, ETrue ); |
|
869 } |
|
870 else |
|
871 { |
|
872 // Several mailboxes configured, dimm "Disconnect" |
|
873 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOffline, ETrue ); |
|
874 } |
|
875 } |
|
876 |
|
877 // Add shortcut hints |
|
878 iAppUi.ShortcutBinding().AppendShortcutHintsL( *aMenuPane, |
|
879 CFSEmailUiShortcutBinding::EContextMainGrid ); |
|
880 } |
|
881 } |
|
882 } |
|
883 |
|
884 void CFSEmailUiLauncherGridVisualiser::HandleCommandL( TInt aCommand ) |
|
885 { |
|
886 FUNC_LOG; |
|
887 |
|
888 switch ( aCommand ) |
|
889 { |
|
890 case EAknSoftkeyOpen: |
|
891 { |
|
892 if( !iAppUi.IsFocusShown() ) |
|
893 { |
|
894 // No need to handle return value |
|
895 iAppUi.SetFocusVisibility( ETrue ); |
|
896 UpdateFocusVisibility(); |
|
897 ResizeItemIcon( EFalse ); |
|
898 break; |
|
899 } |
|
900 } |
|
901 case EFsEmailUiCmdOpen: |
|
902 { |
|
903 SelectL(); |
|
904 break; |
|
905 } |
|
906 case EFsEmailUiCmdDeleteMailbox: |
|
907 { |
|
908 // Deletion by using the option menu. |
|
909 iMailboxDeleter->DeleteMailboxL(); |
|
910 break; |
|
911 } |
|
912 case EFsEmailUiCmdDeleteSelectedMailbox: |
|
913 { |
|
914 // Deletion by using the long tap pop-up menu. |
|
915 iMailboxDeleter->DeleteMailboxL( iMailboxToDelete ); |
|
916 |
|
917 // Hide the focus. |
|
918 iAppUi.SetFocusVisibility( EFalse ); |
|
919 HandleButtonReleaseEvent(); // Finishes the focus removal. |
|
920 iStylusPopUpMenuLaunched = EFalse; |
|
921 UpdateGridOffset(); |
|
922 break; |
|
923 } |
|
924 case EFsEmailUiCmdSync: |
|
925 case EFsEmailUiCmdSyncAll: |
|
926 { |
|
927 RPointerArray<CFSMailBox> mailBoxes; |
|
928 CleanupResetAndDestroyClosePushL( mailBoxes ); |
|
929 TFSMailMsgId id; |
|
930 TInt err = iAppUi.GetMailClient()->ListMailBoxes( |
|
931 id, |
|
932 mailBoxes ); |
|
933 |
|
934 for ( TInt i = 0; i < mailBoxes.Count(); i++ ) |
|
935 { |
|
936 iAppUi.SubscribeMailboxL( mailBoxes[i]->GetId() ); |
|
937 mailBoxes[i]->GetMailBoxStatus(); |
|
938 mailBoxes[i]->RefreshNowL( iAppUi ); |
|
939 } |
|
940 |
|
941 CleanupStack::PopAndDestroy( &mailBoxes ); |
|
942 } |
|
943 break; |
|
944 case EFsEmailUiCmdCancelSync: |
|
945 { |
|
946 RPointerArray<CFSMailBox> mailBoxes; |
|
947 CleanupResetAndDestroyClosePushL( mailBoxes ); |
|
948 TFSMailMsgId id; |
|
949 TInt err = iAppUi.GetMailClient()->ListMailBoxes( |
|
950 id, |
|
951 mailBoxes ); |
|
952 |
|
953 for ( TInt i = 0; i < mailBoxes.Count(); i++ ) |
|
954 { |
|
955 iAppUi.SubscribeMailboxL( mailBoxes[i]->GetId() ); |
|
956 mailBoxes[i]->CancelSyncL(); |
|
957 } |
|
958 |
|
959 CleanupStack::PopAndDestroy( &mailBoxes ); |
|
960 } |
|
961 break; |
|
962 |
|
963 case EFsEmailUiCmdGoOffline: |
|
964 case EFsEmailUiCmdGoOfflineAll: |
|
965 { |
|
966 if (aCommand == EFsEmailUiCmdGoOfflineAll) |
|
967 { |
|
968 iAppUi.ManualMailBoxDisconnectAll(ETrue); |
|
969 } |
|
970 RPointerArray<CFSMailBox> mailBoxes; |
|
971 CleanupResetAndDestroyClosePushL( mailBoxes ); |
|
972 TFSMailMsgId id; |
|
973 TInt err = iAppUi.GetMailClient()->ListMailBoxes( |
|
974 id, |
|
975 mailBoxes ); |
|
976 |
|
977 for ( TInt i = 0; i < mailBoxes.Count(); i++ ) |
|
978 { |
|
979 iAppUi.SubscribeMailboxL( mailBoxes[i]->GetId() ); |
|
980 mailBoxes[i]->GoOfflineL(); |
|
981 } |
|
982 |
|
983 CleanupStack::PopAndDestroy( &mailBoxes ); |
|
984 } |
|
985 break; |
|
986 case EFsEmailUiCmdGoOnline: |
|
987 case EFsEmailUiCmdGoOnlineAll: |
|
988 { |
|
989 if (aCommand == EFsEmailUiCmdGoOnlineAll) |
|
990 { |
|
991 iAppUi.ManualMailBoxConnectAll(ETrue); |
|
992 } |
|
993 RPointerArray<CFSMailBox> mailBoxes; |
|
994 CleanupResetAndDestroyClosePushL( mailBoxes ); |
|
995 TFSMailMsgId id; |
|
996 TInt err = iAppUi.GetMailClient()->ListMailBoxes( |
|
997 id, |
|
998 mailBoxes ); |
|
999 |
|
1000 for ( TInt i = 0; i < mailBoxes.Count(); i++ ) |
|
1001 { |
|
1002 iAppUi.SubscribeMailboxL( mailBoxes[i]->GetId() ); |
|
1003 mailBoxes[i]->GoOnlineL(); |
|
1004 } |
|
1005 |
|
1006 CleanupStack::PopAndDestroy( &mailBoxes ); |
|
1007 } |
|
1008 break; |
|
1009 case EFsEmailUiCmdAbout: |
|
1010 { |
|
1011 DisplayProductInfoL(); |
|
1012 } |
|
1013 break; |
|
1014 case EFsEmailUiCmdHelp: |
|
1015 { |
|
1016 TFsEmailUiUtility::LaunchHelpL( KFSE_HLP_LAUNCHER_GRID ); |
|
1017 } |
|
1018 break; |
|
1019 case KErrCancel: |
|
1020 { |
|
1021 // The pop-up menu was closed. Hide the focus. |
|
1022 iAppUi.SetFocusVisibility( EFalse ); |
|
1023 HandleButtonReleaseEvent(); // Finishes the focus removal. |
|
1024 iStylusPopUpMenuLaunched = EFalse; |
|
1025 break; |
|
1026 } |
|
1027 case EFsEmailUiCmdHide: |
|
1028 case EEikCmdExit: |
|
1029 case EAknSoftkeyExit: |
|
1030 case EFsEmailUiCmdExit: |
|
1031 { |
|
1032 iAppUi.Exit(); |
|
1033 } |
|
1034 break; |
|
1035 default: |
|
1036 break; |
|
1037 } // switch ( aCommand ) |
|
1038 } |
|
1039 |
|
1040 TBool CFSEmailUiLauncherGridVisualiser::OfferEventL(const TAlfEvent& aEvent) |
|
1041 { |
|
1042 FUNC_LOG; |
|
1043 if ( aEvent.IsKeyEvent() && aEvent.Code() == EEventKey ) |
|
1044 { |
|
1045 // If wait note is being shown while a mailbox is being created, |
|
1046 // then do not react to key presses. |
|
1047 if ( iWizardWaitnoteShown ) |
|
1048 { |
|
1049 return ETrue; // key consumed |
|
1050 } |
|
1051 |
|
1052 // Swap right and left controls in mirrored layout |
|
1053 TInt scanCode = aEvent.KeyEvent().iScanCode; |
|
1054 if ( AknLayoutUtils::LayoutMirrored() ) |
|
1055 { |
|
1056 if (scanCode == EStdKeyRightArrow) scanCode = EStdKeyLeftArrow; |
|
1057 else if (scanCode == EStdKeyLeftArrow ) scanCode = EStdKeyRightArrow; |
|
1058 } |
|
1059 |
|
1060 if ((scanCode == EStdKeyRightArrow) |
|
1061 || (scanCode == EStdKeyLeftArrow) |
|
1062 || (scanCode == EStdKeyUpArrow) |
|
1063 || (scanCode == EStdKeyDownArrow) |
|
1064 || (scanCode == EStdKeyEnter) |
|
1065 || (scanCode == EStdKeyDeviceA) |
|
1066 || (scanCode ==EStdKeyDevice3)) |
|
1067 { |
|
1068 TBool scrolled = iScrolled; |
|
1069 if ( iScrolled ) |
|
1070 { |
|
1071 iScrolled = EFalse; |
|
1072 SetFocusedItemL( iFirstVisibleRow * iVisibleColumns ); |
|
1073 } |
|
1074 |
|
1075 //iCurrentLevel.iSelected = |
|
1076 if ( !iAppUi.SetFocusVisibility( ETrue ) || |
|
1077 scrolled ) |
|
1078 { |
|
1079 // focus is now activated. ignore key press. |
|
1080 UpdateFocusVisibility(); |
|
1081 ResizeItemIcon( EFalse ); |
|
1082 return ETrue; |
|
1083 } |
|
1084 } |
|
1085 |
|
1086 switch(scanCode) |
|
1087 { |
|
1088 case EStdKeyRightArrow: |
|
1089 MoveSelection(EDirectionRight); |
|
1090 return ETrue; |
|
1091 case EStdKeyLeftArrow: |
|
1092 MoveSelection(EDirectionLeft); |
|
1093 return ETrue; |
|
1094 case EStdKeyUpArrow: |
|
1095 MoveSelection(EDirectionUp); |
|
1096 return ETrue; |
|
1097 case EStdKeyDownArrow: |
|
1098 MoveSelection(EDirectionDown); |
|
1099 return ETrue; |
|
1100 case EStdKeyEnter: |
|
1101 case EStdKeyDeviceA: |
|
1102 case EStdKeyDevice3: |
|
1103 HandleButtonReleaseEvent(); |
|
1104 SelectL(); |
|
1105 return ETrue; |
|
1106 default: |
|
1107 // Check keyboard shortcuts. |
|
1108 TInt shortcutCommand = |
|
1109 iAppUi.ShortcutBinding().CommandForShortcutKey( aEvent.KeyEvent(), |
|
1110 CFSEmailUiShortcutBinding::EContextMainGrid ); |
|
1111 if ( shortcutCommand != KErrNotFound ) |
|
1112 { |
|
1113 HandleCommandL( shortcutCommand ); |
|
1114 return ETrue; |
|
1115 } |
|
1116 return EFalse; |
|
1117 } |
|
1118 } |
|
1119 return EFalse; // was not consumed |
|
1120 } |
|
1121 |
|
1122 |
|
1123 // --------------------------------------------------------------------------- |
|
1124 // CFSEmailUiLauncherGridVisualiser::HandlePointerEventL |
|
1125 // |
|
1126 // --------------------------------------------------------------------------- |
|
1127 // |
|
1128 TBool CFSEmailUiLauncherGridVisualiser::HandlePointerEventL( |
|
1129 const TAlfEvent& aEvent ) |
|
1130 { |
|
1131 FUNC_LOG; |
|
1132 if( !IsViewActive() ) |
|
1133 { |
|
1134 return EFalse; |
|
1135 } |
|
1136 TPointerEvent::TType type = aEvent.PointerEvent().iType; |
|
1137 TInt id = FindPointedItem( aEvent ); |
|
1138 |
|
1139 switch( type ) |
|
1140 { |
|
1141 case TPointerEvent::EButton1Down: |
|
1142 { |
|
1143 iPreviousPosition = iOriginalPosition = aEvent.PointerEvent().iParentPosition; |
|
1144 iPointerAction = ETrue; |
|
1145 iIsDragging = EFalse; |
|
1146 |
|
1147 if( iPhysics ) |
|
1148 { |
|
1149 iPhysics->StopPhysics(); |
|
1150 iPhysics->ResetFriction(); |
|
1151 iStartTime.HomeTime(); |
|
1152 UpdatePhysicsL(); |
|
1153 iTotalDragging = 0; |
|
1154 } |
|
1155 if ( id != KErrNotFound) |
|
1156 { |
|
1157 // tactile feedback |
|
1158 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
1159 if ( feedback ) |
|
1160 { |
|
1161 feedback->InstantFeedback( ETouchFeedbackBasic ); |
|
1162 } |
|
1163 |
|
1164 iItemIdInButtonDownEvent.iItemId = id; |
|
1165 iItemIdInButtonDownEvent.iLaunchSelection = ETrue; |
|
1166 SetFocusedItemL( id ); |
|
1167 UpdateFocusVisibility(); |
|
1168 } |
|
1169 break; |
|
1170 } |
|
1171 case TPointerEvent::EButton1Up: |
|
1172 { |
|
1173 if( iIsDragging && iPhysics ) |
|
1174 { |
|
1175 TPoint drag( iOriginalPosition - aEvent.PointerEvent().iParentPosition ); |
|
1176 iPhysics->StartPhysics( drag, iStartTime ); |
|
1177 iIsDragging = EFalse; |
|
1178 iPointerAction = EFalse; |
|
1179 iTotalDragging = 0; |
|
1180 } |
|
1181 else if ( id != KErrNotFound ) |
|
1182 { |
|
1183 if ( iStylusPopUpMenuLaunched ) |
|
1184 { |
|
1185 // A pop-up menu was launched. Do not open the selected |
|
1186 // item. |
|
1187 iItemIdInButtonDownEvent.iLaunchSelection = EFalse; |
|
1188 break; |
|
1189 } |
|
1190 |
|
1191 // Hide focus always after pointer up event. |
|
1192 iAppUi.SetFocusVisibility( EFalse ); |
|
1193 |
|
1194 // If key was released on item that had focus |
|
1195 // trigger selection. |
|
1196 if( iItemIdInButtonDownEvent.iItemId == id && |
|
1197 iItemIdInButtonDownEvent.iLaunchSelection ) |
|
1198 { |
|
1199 HandleButtonReleaseEvent(); |
|
1200 // LAUNCH OPENING. This may leave if user cancels the |
|
1201 // operation |
|
1202 SelectL(); |
|
1203 } |
|
1204 else |
|
1205 { |
|
1206 HandleButtonReleaseEvent(); |
|
1207 } |
|
1208 } |
|
1209 else if( iItemIdInButtonDownEvent.iItemId != KErrNotFound ) |
|
1210 { |
|
1211 iItemIdInButtonDownEvent.iLaunchSelection = EFalse; |
|
1212 ResizeItemIcon( ETrue ); |
|
1213 |
|
1214 // Hide focus always after pointer up event. |
|
1215 iAppUi.SetFocusVisibility( EFalse ); |
|
1216 iItemIdInButtonDownEvent.iItemId = KErrNotFound; |
|
1217 HandleButtonReleaseEvent(); |
|
1218 } |
|
1219 else |
|
1220 { |
|
1221 iAppUi.SetFocusVisibility( EFalse ); |
|
1222 } |
|
1223 break; |
|
1224 } |
|
1225 case TPointerEvent::EDrag: |
|
1226 { |
|
1227 if( iPhysics ) |
|
1228 { |
|
1229 TPoint position = aEvent.PointerEvent().iParentPosition; |
|
1230 TPoint delta( 0, iPreviousPosition.iY - position.iY ); |
|
1231 iTotalDragging = iTotalDragging + delta.iY; |
|
1232 if (Abs(iTotalDragging) >= iPhysics->DragThreshold() || iIsDragging ) |
|
1233 { |
|
1234 // Hide focus always when dragging. |
|
1235 HandleButtonReleaseEvent(); |
|
1236 |
|
1237 iIsDragging = ETrue; |
|
1238 |
|
1239 iPhysics->RegisterPanningPosition( delta ); |
|
1240 iScrolled = ETrue; |
|
1241 } |
|
1242 // Save current position as previous pos for future calculations |
|
1243 iPreviousPosition = position; |
|
1244 } |
|
1245 break; |
|
1246 } |
|
1247 case TPointerEvent::EButtonRepeat: |
|
1248 { |
|
1249 if (!iIsDragging && id != KErrNotFound ) |
|
1250 { |
|
1251 // Check the type of the currently selected item. |
|
1252 TInt itemType = iCurrentLevel.iItems[id].iId; |
|
1253 |
|
1254 if ( itemType == EDefaultMailboxItem || |
|
1255 itemType == EOtherMailboxItems ) |
|
1256 { |
|
1257 // The selected item is a mail box. Launch the pop-up |
|
1258 // menu. |
|
1259 LaunchStylusPopupMenu( id ); |
|
1260 } |
|
1261 } |
|
1262 break; |
|
1263 } |
|
1264 default: |
|
1265 { |
|
1266 break; |
|
1267 } |
|
1268 } |
|
1269 return ETrue; |
|
1270 } |
|
1271 |
|
1272 // --------------------------------------------------------------------------- |
|
1273 // CFSEmailUiLauncherGridVisualiser::FindPointedItem |
|
1274 // |
|
1275 // --------------------------------------------------------------------------- |
|
1276 // |
|
1277 TInt CFSEmailUiLauncherGridVisualiser::FindPointedItem( const TAlfEvent& aEvent ) |
|
1278 { |
|
1279 FUNC_LOG; |
|
1280 TInt result = KErrNotFound; |
|
1281 |
|
1282 TInt count = iCurrentLevel.iItemVisualData.Count(); |
|
1283 const TPoint pos = aEvent.PointerEvent().iParentPosition; |
|
1284 |
|
1285 for ( TInt a = 0; count > a; a++ ) |
|
1286 { |
|
1287 const TRect rect( iCurrentLevel.iItemVisualData[a].iBase->DisplayRect() ); |
|
1288 if ( rect.Contains( pos ) ) |
|
1289 { |
|
1290 result = a; |
|
1291 break; |
|
1292 } |
|
1293 } |
|
1294 |
|
1295 return result; |
|
1296 } |
|
1297 |
|
1298 // --------------------------------------------------------------------------- |
|
1299 // CFSEmailUiLauncherGridVisualiser::SetFocusedItemL |
|
1300 // |
|
1301 // --------------------------------------------------------------------------- |
|
1302 // |
|
1303 void CFSEmailUiLauncherGridVisualiser::SetFocusedItemL( TInt aId ) |
|
1304 { |
|
1305 FUNC_LOG; |
|
1306 TInt oldSelection = iCurrentLevel.iSelected; |
|
1307 |
|
1308 HandleRowMovement( EDirectionTouch, aId ); |
|
1309 |
|
1310 FocusItem( EFalse, oldSelection ); |
|
1311 FocusItem( ETrue, iCurrentLevel.iSelected ); |
|
1312 MoveSelectorToCurrentItem( EDirectionTouch ); |
|
1313 } |
|
1314 |
|
1315 void CFSEmailUiLauncherGridVisualiser::MoveSelection( TDirection aDir ) |
|
1316 { |
|
1317 FUNC_LOG; |
|
1318 // NULL double click flag just be sure that the UI does not |
|
1319 // go into state that wizard cannot be started. |
|
1320 iDoubleClickLock = EFalse; |
|
1321 // Store old selection |
|
1322 TInt oldSelection = iCurrentLevel.iSelected; |
|
1323 TInt itemCount = iCurrentLevel.iItemVisualData.Count(); |
|
1324 |
|
1325 HandleRowMovement( aDir, iCurrentLevel.iSelected ); |
|
1326 |
|
1327 // Set the correct icon focuses (i.e. enlarged) |
|
1328 if ( aDir != EDirectionNone && oldSelection >= 0 && oldSelection < itemCount ) |
|
1329 { |
|
1330 FocusItem( EFalse, oldSelection ); |
|
1331 } |
|
1332 FocusItem( ETrue, iCurrentLevel.iSelected ); |
|
1333 |
|
1334 // Move the selector over the newly focused icon |
|
1335 MoveSelectorToCurrentItem( aDir ); |
|
1336 UpdateFocusVisibility(); |
|
1337 } |
|
1338 |
|
1339 |
|
1340 void CFSEmailUiLauncherGridVisualiser::HandleRowMovement( TDirection aDir, TInt aSelected ) |
|
1341 { |
|
1342 FUNC_LOG; |
|
1343 // NULL double click flag just be sure that the UI does not |
|
1344 // go into state that wizard cannot be started. |
|
1345 iDoubleClickLock = EFalse; |
|
1346 // Store old selection |
|
1347 TInt oldSelection = iCurrentLevel.iSelected; |
|
1348 TInt itemCount = iCurrentLevel.iItemVisualData.Count(); |
|
1349 TInt oldX = 0; |
|
1350 TInt oldY = 0; |
|
1351 if (itemCount <= 1) |
|
1352 { |
|
1353 iCurrentLevel.iSelected = 0; |
|
1354 } |
|
1355 else |
|
1356 { |
|
1357 oldX = oldSelection % iVisibleColumns; |
|
1358 oldY = (oldSelection-oldX) / iVisibleColumns; |
|
1359 |
|
1360 switch( aDir ) |
|
1361 { |
|
1362 case EDirectionRight: |
|
1363 iCurrentLevel.iSelected++; |
|
1364 if ( iCurrentLevel.iSelected >= itemCount ) |
|
1365 { |
|
1366 iCurrentLevel.iSelected = 0; |
|
1367 } |
|
1368 break; |
|
1369 |
|
1370 case EDirectionLeft: |
|
1371 iCurrentLevel.iSelected--; |
|
1372 if ( iCurrentLevel.iSelected < 0 ) |
|
1373 { |
|
1374 iCurrentLevel.iSelected = itemCount-1; |
|
1375 } |
|
1376 break; |
|
1377 |
|
1378 case EDirectionUp: |
|
1379 iCurrentLevel.iSelected -= iVisibleColumns; // one row up |
|
1380 if ( iCurrentLevel.iSelected < 0 ) |
|
1381 { |
|
1382 iCurrentLevel.iSelected += (iRowCount*iVisibleColumns); |
|
1383 if ( iCurrentLevel.iSelected >= itemCount ) |
|
1384 { |
|
1385 // Wrapping is about to move the cursor on empty spot. |
|
1386 // To be consistent with S60 app grid, move selection to the last item. |
|
1387 iCurrentLevel.iSelected = itemCount-1; |
|
1388 } |
|
1389 } |
|
1390 break; |
|
1391 |
|
1392 case EDirectionDown: |
|
1393 iCurrentLevel.iSelected += iVisibleColumns; // one row down |
|
1394 if ( iCurrentLevel.iSelected >= itemCount ) |
|
1395 { |
|
1396 if ( oldY < iRowCount-1 ) |
|
1397 { |
|
1398 iCurrentLevel.iSelected = itemCount-1; |
|
1399 } |
|
1400 else |
|
1401 { |
|
1402 iCurrentLevel.iSelected %= (iRowCount*iVisibleColumns); |
|
1403 } |
|
1404 } |
|
1405 break; |
|
1406 |
|
1407 case EDirectionReset: |
|
1408 iCurrentLevel.iSelected = KDefaultSelection; |
|
1409 break; |
|
1410 |
|
1411 case EDirectionNone: |
|
1412 break; |
|
1413 |
|
1414 case EDirectionTouch: |
|
1415 iCurrentLevel.iSelected = aSelected; |
|
1416 break; |
|
1417 |
|
1418 } |
|
1419 |
|
1420 if ( iCurrentLevel.iSelected < 0 ) |
|
1421 { |
|
1422 iCurrentLevel.iSelected = 0; |
|
1423 } |
|
1424 if ( iCurrentLevel.iSelected >= itemCount ) |
|
1425 { |
|
1426 iCurrentLevel.iSelected = itemCount - 1; |
|
1427 } |
|
1428 } |
|
1429 if (!iPointerAction) |
|
1430 { |
|
1431 TInt x = iCurrentLevel.iSelected % iVisibleColumns; |
|
1432 TInt y = (iCurrentLevel.iSelected-x) / iVisibleColumns; |
|
1433 ScrollToRow( y ); |
|
1434 } |
|
1435 } |
|
1436 |
|
1437 |
|
1438 void CFSEmailUiLauncherGridVisualiser::MoveSelectorToCurrentItem( TDirection aDir ) |
|
1439 { |
|
1440 FUNC_LOG; |
|
1441 TInt count = iCurrentLevel.iItemVisualData.Count(); |
|
1442 if ( iCurrentLevel.iSelected < 0 || iCurrentLevel.iSelected >= count ) |
|
1443 { |
|
1444 return; // incorrect index |
|
1445 } |
|
1446 |
|
1447 TAlfRealPoint curPos = iSelector->Pos().ValueNow(); // this is the wrapped value of the current position |
|
1448 iSelector->SetPos( curPos, 0 ); // wrap position now |
|
1449 |
|
1450 // Calculate where are we heading |
|
1451 CAlfVisual* selectedBase = iCurrentLevel.iItemVisualData[iCurrentLevel.iSelected].iBase; |
|
1452 TPoint displayPos = selectedBase->LocalToDisplay( selectedBase->Pos().Target() ); |
|
1453 TPoint targetPos = iSelector->DisplayToLocal( displayPos ); |
|
1454 |
|
1455 // Check if we need to wrap the selector over the edge of the screen |
|
1456 TPoint ringWrapOffset( 0, 0 ); |
|
1457 const TInt KGridWrapWidth = (iVisibleColumns+2)*iColumnWidth; |
|
1458 const TInt KGridWrapHeight = (iRowCount+2)*iRowHeight; |
|
1459 |
|
1460 if ( aDir == EDirectionRight && ( targetPos.iX <= curPos.iX || iCurrentLevel.iSelected == 0 ) ) |
|
1461 { |
|
1462 ringWrapOffset.iX = KGridWrapWidth; |
|
1463 } |
|
1464 else if ( aDir == EDirectionLeft && ( targetPos.iX >= curPos.iX || iCurrentLevel.iSelected == iCurrentLevel.iItems.Count()-1 ) ) |
|
1465 { |
|
1466 ringWrapOffset.iX = -KGridWrapWidth; |
|
1467 } |
|
1468 else if ( aDir == EDirectionUp && targetPos.iY > curPos.iY ) |
|
1469 { |
|
1470 ringWrapOffset.iY = -KGridWrapHeight; |
|
1471 } |
|
1472 else if ( aDir == EDirectionDown && targetPos.iY < curPos.iY ) |
|
1473 { |
|
1474 ringWrapOffset.iY = KGridWrapHeight; |
|
1475 } |
|
1476 targetPos += ringWrapOffset; |
|
1477 |
|
1478 // Animate the movement to the new position |
|
1479 TInt animTime = KSelectTransitionTimeMs; |
|
1480 if ( aDir == EDirectionReset || aDir == EDirectionNone || aDir == EDirectionTouch ) |
|
1481 { |
|
1482 animTime = KStartupAnimationTime; |
|
1483 } |
|
1484 iSelector->SetPos( targetPos, animTime ); |
|
1485 } |
|
1486 |
|
1487 void CFSEmailUiLauncherGridVisualiser::FocusItem( TBool aHasFocus, TInt aItem ) |
|
1488 { |
|
1489 FUNC_LOG; |
|
1490 if ( iCurrentLevel.iItemVisualData.Count() <= aItem || |
|
1491 aItem < 0 ) |
|
1492 { |
|
1493 // Invalid item index |
|
1494 return; |
|
1495 } |
|
1496 |
|
1497 if( aHasFocus && ( IsFocusShown() || iItemIdInButtonDownEvent.iItemId >= 0 ) ) |
|
1498 { |
|
1499 TAlfTimedValue scaleValue; |
|
1500 scaleValue.SetTarget( KScaleSelected, KIconScalingTransitionTimeMs ); |
|
1501 iCurrentLevel.iItemVisualData[aItem].iImage->SetScale( scaleValue ); |
|
1502 } |
|
1503 else |
|
1504 { |
|
1505 TAlfTimedValue scaleValue; |
|
1506 scaleValue.SetTarget( KScaleNotSelected, KIconScalingTransitionTimeMs * 2 ); |
|
1507 iCurrentLevel.iItemVisualData[aItem].iImage->SetScale( scaleValue ); |
|
1508 } |
|
1509 } |
|
1510 |
|
1511 |
|
1512 void CFSEmailUiLauncherGridVisualiser::ScrollToRow( TInt aRow ) |
|
1513 { |
|
1514 FUNC_LOG; |
|
1515 const TInt KScrollTransitionTimeMs = KSelectTransitionTimeMs; |
|
1516 TReal offset( 0.0 ); |
|
1517 |
|
1518 if ( aRow >= iRowCount || aRow < 0 ) |
|
1519 { |
|
1520 // Invalid row |
|
1521 return; |
|
1522 } |
|
1523 |
|
1524 if ( iFirstVisibleRow + iVisibleRows - 1 < aRow ) |
|
1525 { |
|
1526 // Scroll downwards |
|
1527 iFirstVisibleRow = aRow - iVisibleRows + 1 ; |
|
1528 } |
|
1529 else if ( iFirstVisibleRow > aRow ) |
|
1530 { |
|
1531 // Scroll upwards |
|
1532 if ( aRow == 0 ) |
|
1533 { |
|
1534 iFirstVisibleRow = 0; |
|
1535 } |
|
1536 else |
|
1537 { |
|
1538 iFirstVisibleRow = aRow; |
|
1539 } |
|
1540 } |
|
1541 |
|
1542 |
|
1543 offset = iFirstVisibleRow * iRowHeight; |
|
1544 |
|
1545 TAlfTimedPoint alfScrollOffset; |
|
1546 alfScrollOffset.iY.SetTarget( offset , KScrollTransitionTimeMs ); |
|
1547 iCurrentLevel.iGridLayout->SetScrollOffset(alfScrollOffset); |
|
1548 iScrollbarModel.SetFocusPosition(offset); |
|
1549 TRAP_IGNORE( iScrollbar->SetModelL(&iScrollbarModel) ); |
|
1550 iScrollbar->DrawNow(); |
|
1551 } |
|
1552 |
|
1553 void CFSEmailUiLauncherGridVisualiser::RefreshLauncherViewL() |
|
1554 { |
|
1555 FUNC_LOG; |
|
1556 if ( iConstructionCompleted ) |
|
1557 { |
|
1558 iDoubleClickLock = EFalse; |
|
1559 TInt count = iCurrentLevel.iItemVisualData.Count(); |
|
1560 |
|
1561 CreateModelL(); |
|
1562 PopulateL( iCurrentLevel ); |
|
1563 SetRingWrapLimits(); |
|
1564 if ( count != iCurrentLevel.iItemVisualData.Count() ) |
|
1565 { |
|
1566 MoveSelection( EDirectionReset ); |
|
1567 } |
|
1568 else |
|
1569 { |
|
1570 FocusItem( ETrue, iCurrentLevel.iSelected ); |
|
1571 } |
|
1572 UpdateScrollBarRangeL(); |
|
1573 } |
|
1574 } |
|
1575 |
|
1576 TBool CFSEmailUiLauncherGridVisualiser::UiOperationLaunched() |
|
1577 { |
|
1578 FUNC_LOG; |
|
1579 return iUiOperationLaunched; |
|
1580 } |
|
1581 |
|
1582 void CFSEmailUiLauncherGridVisualiser::PopulateL( TLevel& aLevel ) |
|
1583 { |
|
1584 FUNC_LOG; |
|
1585 |
|
1586 if ( iConstructionCompleted ) |
|
1587 { |
|
1588 for( TInt i = 0; i < aLevel.iItemVisualData.Count(); i++ ) |
|
1589 { |
|
1590 aLevel.iItemVisualData[i].iBase->RemoveAndDestroyAllD(); |
|
1591 } |
|
1592 |
|
1593 aLevel.iItemVisualData.Reset(); |
|
1594 aLevel.iItems.Reset(); |
|
1595 |
|
1596 TRect mainPaneRect; |
|
1597 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); |
|
1598 |
|
1599 TAknLayoutRect scrollBarRect; |
|
1600 scrollBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar()); |
|
1601 TRect gridRect = mainPaneRect; |
|
1602 gridRect.iBr.iX -= scrollBarRect.Rect().Width(); |
|
1603 |
|
1604 TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
|
1605 |
|
1606 TAknLayoutRect itemRect; |
|
1607 itemRect.LayoutRect(gridRect, AknLayoutScalable_Apps::cell_cmail_l_pane(var, 0, 0)); |
|
1608 |
|
1609 TRect itemrc = itemRect.Rect(); |
|
1610 itemrc.SetRect(TPoint(0,0), itemRect.Rect().Size()); |
|
1611 |
|
1612 TAknLayoutRect gridIconRect; |
|
1613 gridIconRect.LayoutRect(itemrc, AknLayoutScalable_Apps::cell_cmail_l_pane_g1(var)); |
|
1614 |
|
1615 TAknLayoutText gridText; |
|
1616 gridText.LayoutText(itemrc, AknLayoutScalable_Apps::cell_cmail_l_pane_t1(0)); |
|
1617 |
|
1618 if ( aLevel.iParent >= 0 ) |
|
1619 { |
|
1620 iModel->FindChildren( aLevel.iParent, aLevel.iItems ); |
|
1621 |
|
1622 for ( TInt i = 0; i < aLevel.iItems.Count(); i++ ) |
|
1623 { |
|
1624 TItemVisualData newItem; |
|
1625 |
|
1626 newItem.iBase = CAlfAnchorLayout::AddNewL( *iControl, aLevel.iGridLayout ); |
|
1627 newItem.iBase->SetTactileFeedbackL( ETouchEventStylusDown, ETouchFeedbackBasic ); |
|
1628 |
|
1629 // Set anchors for text. |
|
1630 newItem.iBase->SetAnchor( |
|
1631 EAlfAnchorTopLeft, |
|
1632 0, |
|
1633 EAlfAnchorOriginLeft, |
|
1634 EAlfAnchorOriginTop, |
|
1635 EAlfAnchorMetricAbsolute, |
|
1636 EAlfAnchorMetricAbsolute, |
|
1637 TAlfTimedPoint( gridText.TextRect().iTl.iX, gridText.TextRect().iTl.iY ) );// 0, gridIconSize+KTopMargin ) ); |
|
1638 newItem.iBase->SetAnchor( |
|
1639 EAlfAnchorBottomRight, |
|
1640 0, |
|
1641 EAlfAnchorOriginLeft, |
|
1642 EAlfAnchorOriginTop, |
|
1643 EAlfAnchorMetricAbsolute, |
|
1644 EAlfAnchorMetricAbsolute, |
|
1645 TAlfTimedPoint( gridText.TextRect().iBr.iX, gridText.TextRect().iBr.iY ) );//0, iRowHeight ) ); |
|
1646 |
|
1647 // Set anchors for image |
|
1648 newItem.iBase->SetAnchor( |
|
1649 EAlfAnchorTopLeft, |
|
1650 1, |
|
1651 EAlfAnchorOriginLeft, |
|
1652 EAlfAnchorOriginTop, |
|
1653 EAlfAnchorMetricAbsolute, |
|
1654 EAlfAnchorMetricAbsolute, |
|
1655 TAlfTimedPoint( gridIconRect.Rect().iTl.iX, gridIconRect.Rect().iTl.iY ) ); //-gridIconSize/2, KTopMargin ) ); |
|
1656 newItem.iBase->SetAnchor( |
|
1657 EAlfAnchorBottomRight, |
|
1658 1, |
|
1659 EAlfAnchorOriginLeft, |
|
1660 EAlfAnchorOriginTop, |
|
1661 EAlfAnchorMetricAbsolute, |
|
1662 EAlfAnchorMetricAbsolute, |
|
1663 TAlfTimedPoint( gridIconRect.Rect().iBr.iX, gridIconRect.Rect().iBr.iY ) ); //gridIconSize/2, gridIconSize+KTopMargin ) ); |
|
1664 |
|
1665 newItem.iText = CAlfTextVisual::AddNewL( *iControl, newItem.iBase ); |
|
1666 newItem.iText->EnableShadow( EFalse ); |
|
1667 |
|
1668 TRgb itemColor( KRgbGray ); |
|
1669 |
|
1670 // text #9 application grid unfocused application title texts #215 |
|
1671 if( AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), |
|
1672 itemColor, KAknsIIDQsnTextColors, |
|
1673 EAknsCIQsnTextColorsCG9 ) != KErrNone ) |
|
1674 { |
|
1675 itemColor = gridText.Color(); |
|
1676 } |
|
1677 |
|
1678 newItem.iText->SetColor( itemColor ); |
|
1679 newItem.iText->SetTextL( *aLevel.iItems[i].iCaption ); |
|
1680 |
|
1681 TAlfTimedValue opacity; |
|
1682 opacity.SetValueNow ( KDefaultCaptionOpacity ); |
|
1683 newItem.iText->SetOpacity( opacity ); |
|
1684 |
|
1685 newItem.iText->SetTextStyle( iAppUi.LayoutHandler()->FSTextStyleFromLayoutL(AknLayoutScalable_Apps::cell_cmail_l_pane_t1(var)).Id() );//FSTextStyleFromIdL( EFSFontTypeSmall )->Id() ); |
|
1686 newItem.iText->SetWrapping( CAlfTextVisual::ELineWrapTruncate ); |
|
1687 TAlfAlignHorizontal alfAlign; |
|
1688 switch( gridText.Align() ) |
|
1689 { |
|
1690 case ELeft: |
|
1691 alfAlign = EAlfAlignHLeft; |
|
1692 break; |
|
1693 case ECenter: |
|
1694 alfAlign = EAlfAlignHCenter; |
|
1695 break; |
|
1696 case ERight: |
|
1697 alfAlign = EAlfAlignHRight; |
|
1698 break; |
|
1699 default: |
|
1700 alfAlign = EAlfAlignHCenter; |
|
1701 } |
|
1702 newItem.iText->SetAlign( alfAlign, EAlfAlignVCenter ); |
|
1703 |
|
1704 newItem.iImage = CAlfImageVisual::AddNewL( *iControl, newItem.iBase ); |
|
1705 newItem.iImage->SetScaleMode( CAlfImageVisual::EScaleFit ); |
|
1706 newItem.iImage->SetImage( TAlfImage( *aLevel.iItems[i].iIconTexture ) ); |
|
1707 newItem.iImage->SetFlag( EAlfVisualFlagManualSize ); |
|
1708 |
|
1709 newItem.iImage->SetSize( gridIconRect.Rect().Size() ); |
|
1710 newItem.iImage->SetScale( KScaleNotSelected ); |
|
1711 |
|
1712 User::LeaveIfError( aLevel.iItemVisualData.Append( newItem ) ); |
|
1713 } |
|
1714 } |
|
1715 |
|
1716 // Set columns and rows |
|
1717 iVisibleRows = AknLayoutScalable_Apps::cell_cmail_l_pane_ParamLimits(var).LastRow() + 1; |
|
1718 iVisibleColumns = AknLayoutScalable_Apps::cell_cmail_l_pane_ParamLimits(var).LastColumn() + 1; |
|
1719 |
|
1720 iRowCount = ( iCurrentLevel.iItemVisualData.Count() + iVisibleColumns - 1 ) / iVisibleColumns; |
|
1721 |
|
1722 aLevel.iGridLayout->MoveToFront(); |
|
1723 } |
|
1724 } |
|
1725 |
|
1726 void CFSEmailUiLauncherGridVisualiser::SelectL() |
|
1727 { |
|
1728 FUNC_LOG; |
|
1729 if ( !iAppUi.ViewSwitchingOngoing() ) |
|
1730 { |
|
1731 iPointerAction = EFalse; |
|
1732 iItemIdInButtonDownEvent.iItemId = KErrNotFound; |
|
1733 UpdateFocusVisibility(); |
|
1734 |
|
1735 CFSEmailLauncherItem* launcherItem = |
|
1736 iCurrentLevel.iItems[iCurrentLevel.iSelected].iLauncherItem; |
|
1737 if ( launcherItem ) |
|
1738 { |
|
1739 launcherItem->ExecuteActionL(); |
|
1740 } |
|
1741 else |
|
1742 { |
|
1743 iUiOperationLaunched = ETrue; |
|
1744 switch ( iCurrentLevel.iItems[iCurrentLevel.iSelected].iId ) |
|
1745 { |
|
1746 case EDefaultMailboxItem: |
|
1747 case EOtherMailboxItems: |
|
1748 { |
|
1749 TMailListActivationData tmp; |
|
1750 tmp.iFolderId = iCurrentLevel.iItems[iCurrentLevel.iSelected].iMailBoxInboxId; |
|
1751 tmp.iMailBoxId = iCurrentLevel.iItems[iCurrentLevel.iSelected].iMailBoxId; |
|
1752 const TPckgBuf<TMailListActivationData> pkgOut( tmp ); |
|
1753 iAppUi.ShowTitlePaneConnectionStatus(); |
|
1754 iAppUi.EnterFsEmailViewL( MailListId, KStartListWithFolderId, pkgOut ); |
|
1755 } |
|
1756 break; |
|
1757 case EDirectoryItem: |
|
1758 { |
|
1759 // TO prevent accidental double clicks of the directory item, |
|
1760 // prevents multiple RCL windows to be seen |
|
1761 if ( !iDoubleClickLock ) |
|
1762 { |
|
1763 // Lock to make sure that wizard is not started twice in a row |
|
1764 iDoubleClickLock = ETrue; |
|
1765 RPointerArray<CFSMailBox> mailBoxes; |
|
1766 CleanupResetAndDestroyClosePushL( mailBoxes ); |
|
1767 TFSMailMsgId id; |
|
1768 TInt err = iAppUi.GetMailClient()->ListMailBoxes( |
|
1769 id, |
|
1770 mailBoxes ); |
|
1771 |
|
1772 // Remove mailboxes that doesn't support RCL |
|
1773 for ( TInt i = mailBoxes.Count()-1; i >= 0 ; i-- ) |
|
1774 { |
|
1775 if ( !TFsEmailUiUtility::IsRemoteLookupSupported( *mailBoxes[i] ) ) |
|
1776 { |
|
1777 delete mailBoxes[i]; |
|
1778 mailBoxes.Remove( i ); |
|
1779 } |
|
1780 } |
|
1781 |
|
1782 CFSMailBox* mailBox = NULL; |
|
1783 if( mailBoxes.Count() == 1 ) |
|
1784 { |
|
1785 // Only one mailbox with RCL support so we use that |
|
1786 mailBox = mailBoxes[0]; |
|
1787 } |
|
1788 else if( mailBoxes.Count() > 1 ) |
|
1789 { |
|
1790 // Several mailboxes that support RCL so we need to |
|
1791 // ask the user which one to use |
|
1792 mailBox = ShowMailboxSelectionQueryL( mailBoxes ); |
|
1793 } |
|
1794 |
|
1795 if ( mailBox ) |
|
1796 { |
|
1797 CFsDelayedLoader::InstanceL()->GetContactHandlerL()->LaunchRemoteLookupL( *mailBox ); |
|
1798 } |
|
1799 iDoubleClickLock = EFalse; |
|
1800 CleanupStack::PopAndDestroy( &mailBoxes ); |
|
1801 } |
|
1802 } |
|
1803 break; |
|
1804 case ESettingsItem: |
|
1805 { |
|
1806 TInt tmp = 0; |
|
1807 const TPckgBuf<TInt> pkgBuf( tmp ); |
|
1808 iAppUi.EnterFsEmailViewL( |
|
1809 SettingsViewId, |
|
1810 TUid::Uid(KMailSettingsOpenMainList), |
|
1811 pkgBuf ); |
|
1812 } |
|
1813 break; |
|
1814 case EAddNewMailboxItem: |
|
1815 { |
|
1816 // To prevent accidental double clicks of the wizard item |
|
1817 // wizard would crash without this - moved to function |
|
1818 LaunchWizardL(); |
|
1819 } |
|
1820 break; |
|
1821 case EHelpItem: |
|
1822 { |
|
1823 // To prevent accidental double clicks of the help item |
|
1824 // Help app might crash without this |
|
1825 if ( !iDoubleClickLock ) |
|
1826 { |
|
1827 iDoubleClickLock = ETrue; |
|
1828 TFsEmailUiUtility::LaunchHelpL( KFSE_HLP_LAUNCHER_GRID ); |
|
1829 } |
|
1830 } |
|
1831 break; |
|
1832 default: |
|
1833 return; |
|
1834 } |
|
1835 } |
|
1836 } |
|
1837 } |
|
1838 |
|
1839 |
|
1840 void CFSEmailUiLauncherGridVisualiser::HandleForegroundEventL( TBool aForeground ) |
|
1841 { |
|
1842 FUNC_LOG; |
|
1843 |
|
1844 UpdateFocusVisibility(); |
|
1845 |
|
1846 // Toggle safety lock always when receiving foreground back. |
|
1847 if ( aForeground && iDoubleClickLock && iFirstStartComplete ) |
|
1848 { |
|
1849 iDoubleClickLock = EFalse; |
|
1850 } |
|
1851 UpdateGridOffset(); |
|
1852 } |
|
1853 |
|
1854 void CFSEmailUiLauncherGridVisualiser::GetParentLayoutsL( |
|
1855 RPointerArray<CAlfVisual>& aLayoutArray ) const |
|
1856 { |
|
1857 aLayoutArray.AppendL( iParentLayout ); |
|
1858 } |
|
1859 |
|
1860 // hide or show CAlfVisuals ( used for activation or deactivation ) |
|
1861 void CFSEmailUiLauncherGridVisualiser::FadeOut(TBool aDirectionOut) |
|
1862 { |
|
1863 if ( iParentLayout != NULL ) |
|
1864 { |
|
1865 TAlfTimedValue timedValue( 0, 0 ); |
|
1866 if ( !aDirectionOut ) |
|
1867 { |
|
1868 timedValue.SetTarget( 1, 0 ); |
|
1869 } |
|
1870 iParentLayout->SetOpacity( timedValue ); |
|
1871 } |
|
1872 } |
|
1873 |
|
1874 // ----------------------------------------------------------------------------- |
|
1875 // CFSEmailUiLauncherGridVisualiser::ShowMailboxSelectionQueryL |
|
1876 // ----------------------------------------------------------------------------- |
|
1877 CFSMailBox* CFSEmailUiLauncherGridVisualiser::ShowMailboxSelectionQueryL( |
|
1878 const RPointerArray<CFSMailBox>& aMailBoxes ) |
|
1879 { |
|
1880 FUNC_LOG; |
|
1881 CDesCArrayFlat* array = new (ELeave) CDesCArrayFlat( 2 ); |
|
1882 CleanupStack::PushL( array ); |
|
1883 |
|
1884 for( TInt i = 0; i < aMailBoxes.Count(); i++ ) |
|
1885 { |
|
1886 array->AppendL( aMailBoxes[i]->GetName() ); |
|
1887 } |
|
1888 |
|
1889 TInt selectedOption; |
|
1890 CAknListQueryDialog* dlg = new ( ELeave ) CAknListQueryDialog( &selectedOption ); |
|
1891 dlg->PrepareLC( R_FSEMAILUI_LAUNCHER_GRID_MAILBOX_SELECTION_DIALOG ); |
|
1892 |
|
1893 dlg->SetItemTextArray( array ); |
|
1894 dlg->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
1895 |
|
1896 CFSMailBox* mailbox = NULL; |
|
1897 if( dlg->RunLD() ) |
|
1898 { |
|
1899 // safety check. |
|
1900 if( selectedOption >= 0 && |
|
1901 selectedOption < aMailBoxes.Count() ) |
|
1902 { |
|
1903 mailbox = aMailBoxes[selectedOption]; |
|
1904 } |
|
1905 } |
|
1906 |
|
1907 CleanupStack::PopAndDestroy( array ); |
|
1908 return mailbox; |
|
1909 } |
|
1910 |
|
1911 void CFSEmailUiLauncherGridVisualiser::LaunchWizardL() |
|
1912 { |
|
1913 FUNC_LOG; |
|
1914 // Start wizard. |
|
1915 |
|
1916 // Make sure that FSMailServer is running, so that the mailbox is added |
|
1917 // also to MCE. It should be enough to do it here, because it takes some |
|
1918 // time from wizard startup until the actual mailbox is created, so the |
|
1919 // serve has some time to get itself up and running before that. |
|
1920 TFsEmailUiUtility::EnsureFsMailServerIsRunning( iEikonEnv->WsSession() ); |
|
1921 //we are calling DoFirstStarL() method because in case User goes to GeneralSettings->Email |
|
1922 //iAiwSHandler isnt constructed and in that case EmailUi panics |
|
1923 if ( !iConstructionCompleted ) |
|
1924 { |
|
1925 DoFirstStartL(); |
|
1926 } |
|
1927 |
|
1928 if ( ! iLaunchWizardExecuted ) // prevent reentrant calling |
|
1929 { |
|
1930 iLaunchWizardExecuted = ETrue; |
|
1931 TRAPD( err, iAiwSHandler->ExecuteServiceCmdL( KAiwCmdSettingWizardFsEmail.iUid, |
|
1932 iAiwSHandler->InParamListL(), |
|
1933 iAiwSHandler->OutParamListL() ) ); |
|
1934 // ExecuteServiceCmdL is synchronous - uses CActiveSchedulerWait |
|
1935 iLaunchWizardExecuted = EFalse; |
|
1936 User::LeaveIfError( err ); |
|
1937 } |
|
1938 |
|
1939 } |
|
1940 |
|
1941 void CFSEmailUiLauncherGridVisualiser::GoToInboxL( TFSMailMsgId& aMailboxId, TFSMailMsgId& aMailboxInboxId ) |
|
1942 { |
|
1943 FUNC_LOG; |
|
1944 TMailListActivationData tmp; |
|
1945 |
|
1946 tmp.iMailBoxId = aMailboxId; |
|
1947 tmp.iFolderId = aMailboxInboxId; |
|
1948 |
|
1949 const TPckgBuf<TMailListActivationData> pkgOut( tmp ); |
|
1950 |
|
1951 iAppUi.EnterFsEmailViewL( MailListId, KStartListWithFolderId, pkgOut ); |
|
1952 } |
|
1953 |
|
1954 void CFSEmailUiLauncherGridVisualiser::RescaleIconsL() |
|
1955 { |
|
1956 FUNC_LOG; |
|
1957 if ( iConstructionCompleted ) |
|
1958 { |
|
1959 TRect mainPaneRect; |
|
1960 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); |
|
1961 TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
|
1962 |
|
1963 TAknLayoutRect scrollBarRect; |
|
1964 scrollBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar()); |
|
1965 TRect gridRect = mainPaneRect; |
|
1966 gridRect.iBr.iX -= scrollBarRect.Rect().Width(); |
|
1967 |
|
1968 TAknLayoutRect itemRect; |
|
1969 itemRect.LayoutRect(gridRect, AknLayoutScalable_Apps::cell_cmail_l_pane(var, 0, 0)); |
|
1970 |
|
1971 TAknLayoutRect gridIconRect; |
|
1972 gridIconRect.LayoutRect(itemRect.Rect(), AknLayoutScalable_Apps::cell_cmail_l_pane_g1(var)); |
|
1973 |
|
1974 //TInt gridIconSize = iAppUi.LayoutHandler()->GridIconSize(); |
|
1975 TSize iconSize = gridIconRect.Rect().Size(); |
|
1976 //iconSize.SetSize( gridIconSize, gridIconSize ); |
|
1977 |
|
1978 // Scale bitmaps |
|
1979 for( TInt i = 0 ; i < iIconArray.Count() ; i++ ) |
|
1980 { |
|
1981 iIconArray[i]->Size().SetSize( iconSize.iWidth, iconSize.iHeight ); |
|
1982 } |
|
1983 // Scale visuals |
|
1984 for ( TInt item = 0; item < iCurrentLevel.iItemVisualData.Count() ; item++ ) |
|
1985 { |
|
1986 iCurrentLevel.iItemVisualData[item].iImage->SetSize( iconSize ); |
|
1987 } |
|
1988 } |
|
1989 } |
|
1990 |
|
1991 void CFSEmailUiLauncherGridVisualiser::AddItemToModelL( CFSEmailLauncherItem* aItem, TInt aPluginArrayIndex ) |
|
1992 { |
|
1993 FUNC_LOG; |
|
1994 if ( iConstructionCompleted && aItem->IsVisible() ) |
|
1995 { |
|
1996 HBufC* launcherItemText = aItem->Caption( EFalse ).AllocLC(); |
|
1997 CAknIcon* launcherItemIcon = aItem->Icon(); |
|
1998 |
|
1999 if ( launcherItemIcon ) |
|
2000 { |
|
2001 TRect mainPaneRect; |
|
2002 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); |
|
2003 |
|
2004 TAknLayoutRect scrollBarRect; |
|
2005 scrollBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar()); |
|
2006 TRect gridRect = mainPaneRect; |
|
2007 gridRect.iBr.iX -= scrollBarRect.Rect().Width(); |
|
2008 |
|
2009 TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
|
2010 |
|
2011 TAknLayoutRect itemRect; |
|
2012 itemRect.LayoutRect(gridRect, AknLayoutScalable_Apps::cell_cmail_l_pane(var, 0, 0)); |
|
2013 |
|
2014 TAknLayoutRect gridIconRect; |
|
2015 gridIconRect.LayoutRect(itemRect.Rect(), AknLayoutScalable_Apps::cell_cmail_l_pane_g1(var)); |
|
2016 |
|
2017 TSize iconSize = gridIconRect.Rect().Size(); |
|
2018 |
|
2019 const CFbsBitmap* bitmap = launcherItemIcon->Bitmap(); |
|
2020 const CFbsBitmap* mask = launcherItemIcon->Mask(); |
|
2021 |
|
2022 // First add plugin id and icon id pair to array, needed in provide bitmap |
|
2023 TPluginIdIconIdPair idPair; |
|
2024 idPair.iPluginArrayIndex = aPluginArrayIndex; |
|
2025 idPair.iIconId = iPluginTextureId; |
|
2026 iPluginIdIconIdPairs.Append( idPair ); |
|
2027 |
|
2028 // Create texture, goes to provide bitmap |
|
2029 CAlfTexture* texture = &CAlfStatic::Env().TextureManager().CreateTextureL( iPluginTextureId, this, EAlfTextureFlagDefault ); |
|
2030 // Update texture id |
|
2031 iPluginTextureId++; // Id is updated dynamically |
|
2032 // Set initial size |
|
2033 texture->Size().SetSize( iconSize.iHeight, iconSize.iWidth ); |
|
2034 iModel->AddL( |
|
2035 EShortcut, |
|
2036 aItem->Id(), |
|
2037 *launcherItemText, |
|
2038 *texture, |
|
2039 0, |
|
2040 aItem ); |
|
2041 iIconArray.AppendL( texture ); |
|
2042 } |
|
2043 else |
|
2044 { |
|
2045 CAlfTexture* texture = &iAppUi.FsTextureManager()->TextureByIndex( EGridInboxTexture ); |
|
2046 |
|
2047 iModel->AddL( |
|
2048 EShortcut, |
|
2049 aItem->Id(), |
|
2050 *launcherItemText, |
|
2051 *texture, |
|
2052 0, |
|
2053 aItem ); |
|
2054 iIconArray.AppendL( texture ); |
|
2055 } |
|
2056 |
|
2057 CleanupStack::PopAndDestroy( launcherItemText ); |
|
2058 } |
|
2059 } |
|
2060 |
|
2061 void CFSEmailUiLauncherGridVisualiser::VisualLayoutUpdatedL() |
|
2062 { |
|
2063 FUNC_LOG; |
|
2064 if ( iConstructionCompleted ) |
|
2065 { |
|
2066 iCurrentLevel.iParent = 0; |
|
2067 |
|
2068 TRect mainPaneRect; |
|
2069 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); |
|
2070 TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
|
2071 |
|
2072 TAknLayoutRect scrollBarRect; |
|
2073 |
|
2074 scrollBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Apps::scroll_pane_cp03()); |
|
2075 |
|
2076 TRect gridRect = mainPaneRect; |
|
2077 gridRect.iBr.iX -= scrollBarRect.Rect().Width(); |
|
2078 |
|
2079 TAknLayoutRect cellRect; |
|
2080 cellRect.LayoutRect(gridRect, AknLayoutScalable_Apps::aid_size_cell_cmail_l(var, 0, 0)); |
|
2081 |
|
2082 TAknLayoutRect itemRect; |
|
2083 itemRect.LayoutRect(gridRect, AknLayoutScalable_Apps::cell_cmail_l_pane(var, 0, 0)); |
|
2084 |
|
2085 TAknLayoutRect gridIconRect; |
|
2086 gridIconRect.LayoutRect(itemRect.Rect(), AknLayoutScalable_Apps::cell_cmail_l_pane_g1(var)); |
|
2087 |
|
2088 TAknLayoutRect selectorRect; |
|
2089 selectorRect.LayoutRect(itemRect.Rect(), AknLayoutScalable_Apps::grid_highlight_pane_cp018(var)); |
|
2090 |
|
2091 CFSEmailUiLayoutHandler* layoutHandler = iAppUi.LayoutHandler(); |
|
2092 iSelectorImageVisual->SetSize( selectorRect.Rect().Size() ); |
|
2093 |
|
2094 TSize displaySize = mainPaneRect.Size(); |
|
2095 |
|
2096 TInt columns = iVisibleColumns = AknLayoutScalable_Apps::cell_cmail_l_pane_ParamLimits(var).LastColumn() + 1; |
|
2097 TInt rows = iVisibleRows = AknLayoutScalable_Apps::cell_cmail_l_pane_ParamLimits(var).LastRow() + 1; |
|
2098 |
|
2099 iCurrentLevel.iGridLayout->SetSize( gridRect.Size() ); |
|
2100 iCurrentLevel.iGridLayout->SetColumnsL( columns ); |
|
2101 iCurrentLevel.iGridLayout->SetRowsL( rows ); |
|
2102 |
|
2103 PopulateL( iCurrentLevel ); |
|
2104 UpdateScrollBarRangeL(); |
|
2105 |
|
2106 TInt scrollbarWidth = scrollBarRect.Rect().Width(); |
|
2107 if( iRowCount > iVisibleRows ) |
|
2108 { |
|
2109 iScrollbar->MakeVisible(ETrue); |
|
2110 } |
|
2111 else |
|
2112 { |
|
2113 iScrollbar->MakeVisible(EFalse); |
|
2114 } |
|
2115 |
|
2116 TInt scrollbarTopLeftX = displaySize.iWidth - scrollbarWidth; |
|
2117 TInt scrollbarTopLeftY = 0; |
|
2118 TInt scrollbarBottomRightX = displaySize.iWidth; |
|
2119 TInt scrollbarBottomRightY = displaySize.iHeight; |
|
2120 TInt gridTopLeftX = 0; |
|
2121 TInt gridTopLeftY = 0; |
|
2122 TInt gridBottomRightX = displaySize.iWidth - scrollbarWidth; |
|
2123 TInt gridBottomRightY = displaySize.iHeight; |
|
2124 |
|
2125 if ( AknLayoutUtils::LayoutMirrored() ) |
|
2126 { |
|
2127 // Mirrored layout |
|
2128 scrollbarTopLeftX = 0; |
|
2129 scrollbarTopLeftY = 0; |
|
2130 scrollbarBottomRightX = scrollbarWidth; |
|
2131 scrollbarBottomRightY = displaySize.iHeight; |
|
2132 gridTopLeftX = scrollbarWidth; |
|
2133 gridTopLeftY = 0; |
|
2134 gridBottomRightX = displaySize.iWidth; |
|
2135 gridBottomRightY = displaySize.iHeight; |
|
2136 } |
|
2137 |
|
2138 // Set anchors for the scroll bar |
|
2139 iWidgetLayout->SetAnchor( |
|
2140 EAlfAnchorTopLeft, |
|
2141 0, |
|
2142 EAlfAnchorOriginLeft, |
|
2143 EAlfAnchorOriginTop, |
|
2144 EAlfAnchorMetricAbsolute, |
|
2145 EAlfAnchorMetricAbsolute, |
|
2146 TAlfTimedPoint( scrollbarTopLeftX, scrollbarTopLeftY ) ); |
|
2147 iWidgetLayout->SetAnchor( |
|
2148 EAlfAnchorBottomRight, |
|
2149 0, |
|
2150 EAlfAnchorOriginLeft, |
|
2151 EAlfAnchorOriginTop, |
|
2152 EAlfAnchorMetricAbsolute, |
|
2153 EAlfAnchorMetricAbsolute, |
|
2154 TAlfTimedPoint( scrollbarBottomRightX, scrollbarBottomRightY ) ); |
|
2155 |
|
2156 // Set anchors for the grid |
|
2157 iWidgetLayout->SetAnchor( |
|
2158 EAlfAnchorTopLeft, |
|
2159 1, |
|
2160 EAlfAnchorOriginLeft, |
|
2161 EAlfAnchorOriginTop, |
|
2162 EAlfAnchorMetricAbsolute, |
|
2163 EAlfAnchorMetricAbsolute, |
|
2164 TAlfTimedPoint( gridTopLeftX, gridTopLeftY ) ); |
|
2165 iWidgetLayout->SetAnchor( |
|
2166 EAlfAnchorBottomRight, |
|
2167 1, |
|
2168 EAlfAnchorOriginLeft, |
|
2169 EAlfAnchorOriginTop, |
|
2170 EAlfAnchorMetricAbsolute, |
|
2171 EAlfAnchorMetricAbsolute, |
|
2172 TAlfTimedPoint( gridBottomRightX, gridBottomRightY ) ); |
|
2173 |
|
2174 iParentLayout->UpdateChildrenLayout(); |
|
2175 |
|
2176 TSize gridSize = iCurrentLevel.iGridLayout->Size().IntTarget().AsSize(); |
|
2177 iColumnWidth = gridSize.iWidth / iVisibleColumns; |
|
2178 iRowHeight = gridSize.iHeight / iVisibleRows; |
|
2179 |
|
2180 // Selector ring wrap limits can be calculated when row and column sizes are known. |
|
2181 SetRingWrapLimits(); |
|
2182 MoveSelection( EDirectionNone ); |
|
2183 |
|
2184 TRect scrollbarRect; |
|
2185 scrollbarRect.SetRect(scrollbarTopLeftX, scrollbarTopLeftY, scrollbarBottomRightX, scrollbarBottomRightY); |
|
2186 scrollbarRect.Move(mainPaneRect.iTl); |
|
2187 iScrollbar->SetRect(scrollbarRect); |
|
2188 iScrollbar->DrawDeferred(); |
|
2189 iRefreshNeeded = EFalse; |
|
2190 } |
|
2191 } |
|
2192 |
|
2193 void CFSEmailUiLauncherGridVisualiser::SetRingWrapLimits() |
|
2194 { |
|
2195 FUNC_LOG; |
|
2196 if ( iConstructionCompleted ) |
|
2197 { |
|
2198 iRingMovementXFuncMappingDataProvider.SetStart(-iColumnWidth); |
|
2199 iRingMovementXFuncMappingDataProvider.SetEnd((iVisibleColumns+1)*iColumnWidth); |
|
2200 iRingMovementYFuncMappingDataProvider.SetStart(-iRowHeight); |
|
2201 iRingMovementYFuncMappingDataProvider.SetEnd((iRowCount+1)*iRowHeight); |
|
2202 |
|
2203 iRingMovementXFunc->SetMappingTableValues( -(iVisibleColumns+2)*iColumnWidth, (iVisibleColumns*2+2)*iColumnWidth, &iRingMovementXFuncMappingDataProvider ); |
|
2204 iRingMovementYFunc->SetMappingTableValues( -(iRowCount+2)*iRowHeight, (iRowCount*2+2)*iRowHeight, &iRingMovementYFuncMappingDataProvider ); |
|
2205 } |
|
2206 } |
|
2207 |
|
2208 void CFSEmailUiLauncherGridVisualiser::DisplayProductInfoL() |
|
2209 { |
|
2210 FUNC_LOG; |
|
2211 //Load the texts from resource |
|
2212 HBufC* text_1 = StringLoader::LoadLC( R_DISCLAIMER_PART_1 ); |
|
2213 HBufC* text_2 = StringLoader::LoadLC( R_DISCLAIMER_PART_2 ); |
|
2214 HBufC* text_3 = StringLoader::LoadLC( R_DISCLAIMER_PART_3 ); |
|
2215 HBufC* text_4 = StringLoader::LoadLC( R_DISCLAIMER_PART_4 ); |
|
2216 HBufC* text_5 = StringLoader::LoadLC( R_DISCLAIMER_PART_5 ); |
|
2217 HBufC* text_6 = StringLoader::LoadLC( R_DISCLAIMER_PART_6 ); |
|
2218 HBufC* text_7 = StringLoader::LoadLC( R_DISCLAIMER_PART_7 ); |
|
2219 HBufC* text_8 = StringLoader::LoadLC( R_DISCLAIMER_PART_8 ); |
|
2220 HBufC* text_9 = StringLoader::LoadLC( R_DISCLAIMER_PART_9 ); |
|
2221 HBufC* text_10 = StringLoader::LoadLC( R_DISCLAIMER_PART_10 ); |
|
2222 HBufC* text_11 = StringLoader::LoadLC( R_DISCLAIMER_PART_11 ); |
|
2223 |
|
2224 //Create a buffer for dialog content |
|
2225 HBufC* text = HBufC::NewLC( text_1->Length() + text_2->Length() + text_3->Length() + |
|
2226 text_4->Length() + text_5->Length() + text_6->Length() + |
|
2227 text_7->Length() + text_8->Length() + text_9->Length() + |
|
2228 text_10->Length() + text_11->Length() ); |
|
2229 //Copy the disclaimer text parts to dialog content |
|
2230 text->Des() += *text_1; |
|
2231 text->Des() += *text_2; |
|
2232 text->Des() += *text_3; |
|
2233 text->Des() += *text_4; |
|
2234 text->Des() += *text_5; |
|
2235 text->Des() += *text_6; |
|
2236 text->Des() += *text_7; |
|
2237 text->Des() += *text_8; |
|
2238 text->Des() += *text_9; |
|
2239 text->Des() += *text_10; |
|
2240 text->Des() += *text_11; |
|
2241 |
|
2242 CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( *text ); |
|
2243 CleanupStack::PopAndDestroy( text ); |
|
2244 CleanupStack::PopAndDestroy( text_11 ); |
|
2245 CleanupStack::PopAndDestroy( text_10 ); |
|
2246 CleanupStack::PopAndDestroy( text_9 ); |
|
2247 CleanupStack::PopAndDestroy( text_8 ); |
|
2248 CleanupStack::PopAndDestroy( text_7 ); |
|
2249 CleanupStack::PopAndDestroy( text_6 ); |
|
2250 CleanupStack::PopAndDestroy( text_5 ); |
|
2251 CleanupStack::PopAndDestroy( text_4 ); |
|
2252 CleanupStack::PopAndDestroy( text_3 ); |
|
2253 CleanupStack::PopAndDestroy( text_2 ); |
|
2254 CleanupStack::PopAndDestroy( text_1 ); |
|
2255 dlg->PrepareLC( R_DISCLAIMER_MESSAGE ); |
|
2256 |
|
2257 //Create heading for the dialog, load and create the heading text |
|
2258 CAknPopupHeadingPane* headingPane = dlg->Heading(); |
|
2259 HBufC* appName = StringLoader::LoadLC(R_FSEMAIL_APP_NAME ); |
|
2260 HBufC* version = StringLoader::LoadLC( R_DISCLAIMER_FSEMAIL_VERSION ); |
|
2261 HBufC* title = HBufC::NewLC(version->Length() + appName->Length() + 1); |
|
2262 title->Des() += *appName; |
|
2263 title->Des() += KSpace; |
|
2264 title->Des() += *version; |
|
2265 headingPane->SetTextL( *title ); |
|
2266 CleanupStack::PopAndDestroy( title ); |
|
2267 CleanupStack::PopAndDestroy( version ); |
|
2268 CleanupStack::PopAndDestroy( appName ); |
|
2269 dlg->ButtonGroupContainer().SetCommandSetL( R_AVKON_SOFTKEYS_OK_EMPTY ); |
|
2270 //show dialog |
|
2271 TInt ret = dlg->RunLD(); |
|
2272 } |
|
2273 |
|
2274 void CFSEmailUiLauncherGridVisualiser::HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType aType ) |
|
2275 { |
|
2276 FUNC_LOG; |
|
2277 |
|
2278 CFsEmailUiViewBase::HandleDynamicVariantSwitchL( aType ); |
|
2279 |
|
2280 if ( iConstructionCompleted ) |
|
2281 { |
|
2282 iItemIdInButtonDownEvent.iItemId = KErrNotFound; |
|
2283 |
|
2284 TRect mainPaneRect; |
|
2285 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); |
|
2286 TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
|
2287 |
|
2288 TAknLayoutRect scrollBarRect; |
|
2289 scrollBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar()); |
|
2290 TRect gridRect = mainPaneRect; |
|
2291 gridRect.iBr.iX -= scrollBarRect.Rect().Width(); |
|
2292 |
|
2293 TAknLayoutRect cellRect; |
|
2294 cellRect.LayoutRect(gridRect, AknLayoutScalable_Apps::aid_size_cell_cmail_l(var, 0, 0)); |
|
2295 |
|
2296 TSize displaySize = cellRect.Rect().Size(); |
|
2297 iParentLayout->SetSize( displaySize ); |
|
2298 RescaleIconsL(); |
|
2299 VisualLayoutUpdatedL(); |
|
2300 |
|
2301 UpdateFocusVisibility(); |
|
2302 |
|
2303 // Stylus pop-up menu is closed during Layout switching |
|
2304 if( iStylusPopUpMenuLaunched ) |
|
2305 { |
|
2306 TRAP_IGNORE(iStylusPopUpMenu->HandleControlEventL(iCoeControl, |
|
2307 MCoeControlObserver::EEventRequestExit )); |
|
2308 |
|
2309 iStylusPopUpMenuLaunched = EFalse; |
|
2310 } |
|
2311 |
|
2312 } |
|
2313 } |
|
2314 |
|
2315 void CFSEmailUiLauncherGridVisualiser::HandleDynamicVariantSwitchOnBackgroundL( CFsEmailUiViewBase::TDynamicSwitchType aType ) |
|
2316 { |
|
2317 FUNC_LOG; |
|
2318 iRefreshNeeded = ETrue; |
|
2319 |
|
2320 CFsEmailUiViewBase::HandleDynamicVariantSwitchOnBackgroundL( aType ); |
|
2321 } |
|
2322 |
|
2323 void CFSEmailUiLauncherGridVisualiser::HandleContentChangeL() |
|
2324 { |
|
2325 FUNC_LOG; |
|
2326 if ( iConstructionCompleted ) |
|
2327 { |
|
2328 CreateModelL(); |
|
2329 if ( iAppUi.CurrentActiveView() == this ) |
|
2330 { |
|
2331 VisualLayoutUpdatedL(); |
|
2332 } |
|
2333 else |
|
2334 { |
|
2335 iRefreshNeeded = ETrue; |
|
2336 } |
|
2337 } |
|
2338 } |
|
2339 |
|
2340 void CFSEmailUiLauncherGridVisualiser::ConstructScrollbarL( CAlfLayout* aParent ) |
|
2341 { |
|
2342 FUNC_LOG; |
|
2343 CAlfLayout::AddNewL(*iControl, aParent); |
|
2344 iScrollbar = new (ELeave) CAknDoubleSpanScrollBar(0); |
|
2345 iScrollbar->ConstructL(ETrue, this, 0, CEikScrollBar::EVertical, 1000); |
|
2346 TRect mainPaneRect; |
|
2347 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); |
|
2348 TRect scrollbarRect = aParent->DisplayRectTarget(); |
|
2349 scrollbarRect.Move(mainPaneRect.iTl); |
|
2350 iScrollbar->SetRect(scrollbarRect); |
|
2351 |
|
2352 iScrollbar->MakeVisible(EFalse); |
|
2353 iScrollbar->SetModelL(&iScrollbarModel); |
|
2354 } |
|
2355 |
|
2356 void CFSEmailUiLauncherGridVisualiser::UpdateScrollBarRangeL() |
|
2357 { |
|
2358 FUNC_LOG; |
|
2359 |
|
2360 TRect mainPaneRect; |
|
2361 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); |
|
2362 TAknLayoutRect scrollBarRect; |
|
2363 scrollBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar()); |
|
2364 |
|
2365 iScrollbarModel.SetScrollSpan(iRowCount * (scrollBarRect.Rect().Height() / iVisibleRows)); |
|
2366 iScrollbarModel.SetWindowSize(scrollBarRect.Rect().Height()); |
|
2367 iScrollbarModel.SetFocusPosition(iFirstVisibleRow); |
|
2368 iScrollbar->SetModelL(&iScrollbarModel); |
|
2369 iScrollbar->DrawNow(); |
|
2370 } |
|
2371 |
|
2372 void CFSEmailUiLauncherGridVisualiser::HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType) |
|
2373 { |
|
2374 FUNC_LOG; |
|
2375 if( iPhysics ) |
|
2376 { |
|
2377 iPhysics->StopPhysics(); |
|
2378 iPhysics->ResetFriction(); |
|
2379 } |
|
2380 |
|
2381 if (aScrollBar == iScrollbar) |
|
2382 { |
|
2383 switch( aEventType ) |
|
2384 { |
|
2385 case EEikScrollHome : |
|
2386 //Jump to beginning |
|
2387 break; |
|
2388 case EEikScrollEnd : |
|
2389 //Jump to end |
|
2390 break; |
|
2391 default: |
|
2392 iScrolled = ETrue; |
|
2393 iAppUi.SetFocusVisibility( EFalse ); |
|
2394 if ( iSelector ) |
|
2395 { |
|
2396 TAlfTimedValue selectorOpacity; |
|
2397 selectorOpacity.SetValueNow( 0 ); |
|
2398 iSelector->SetOpacity( selectorOpacity ); |
|
2399 } |
|
2400 iFirstVisibleRow = iCurrentLevel.iParentPos.iY/iRowHeight; |
|
2401 TReal offset = aScrollBar->ThumbPosition() + 1; |
|
2402 TAlfTimedPoint alfScrollOffset; |
|
2403 alfScrollOffset.iY.SetTarget( offset , 0); |
|
2404 iCurrentLevel.iGridLayout->SetScrollOffset(alfScrollOffset); |
|
2405 iCurrentLevel.iParentPos.iY = offset; |
|
2406 break; |
|
2407 } |
|
2408 } |
|
2409 } |
|
2410 |
|
2411 void CFSEmailUiLauncherGridVisualiser::UpdateLauncherItemListL() |
|
2412 { |
|
2413 FUNC_LOG; |
|
2414 |
|
2415 // Read info about all implementations into infoArray |
|
2416 RImplInfoPtrArray infoArray; |
|
2417 CleanupResetAndDestroyClosePushL( infoArray ); |
|
2418 CFSEmailLauncherItem::ListAllImplementationsL( infoArray ); |
|
2419 |
|
2420 RArray<TBool> itemsFoundArray; |
|
2421 CleanupClosePushL( itemsFoundArray ); |
|
2422 |
|
2423 itemsFoundArray.ReserveL( iLauncherItemUids.Count() ); |
|
2424 for ( TInt i = 0; i < iLauncherItemUids.Count(); i++ ) |
|
2425 { |
|
2426 itemsFoundArray.Append( EFalse ); |
|
2427 } |
|
2428 |
|
2429 // Iterate through all launcher item implementations in info array |
|
2430 TInt const infoCount = infoArray.Count(); |
|
2431 for ( TInt infoIndex = 0; infoIndex < infoCount; infoIndex++ ) |
|
2432 { |
|
2433 TUid implementationUid = infoArray[infoIndex]->ImplementationUid(); |
|
2434 |
|
2435 // Check whether item can be found from current laucher items |
|
2436 TBool itemFound = EFalse; |
|
2437 for ( TInt itemIndex = 0; itemIndex < iLauncherItemUids.Count(); itemIndex++ ) |
|
2438 { |
|
2439 if ( iLauncherItemUids[itemIndex] == implementationUid ) |
|
2440 { |
|
2441 itemsFoundArray[itemIndex] = ETrue; |
|
2442 itemFound = ETrue; |
|
2443 break; |
|
2444 } |
|
2445 } |
|
2446 |
|
2447 if ( !itemFound ) |
|
2448 { |
|
2449 // Add new item to the end of the laucher item array |
|
2450 CFSEmailLauncherItem* launcherItem = NULL; |
|
2451 TRAPD( error, launcherItem = CFSEmailLauncherItem::NewL( implementationUid, this ) ); |
|
2452 if ( error == KErrNone ) |
|
2453 { |
|
2454 iLauncherItems.Append( launcherItem ); |
|
2455 iLauncherItemUids.Append( implementationUid ); |
|
2456 } |
|
2457 } |
|
2458 } |
|
2459 |
|
2460 // Remove all launcher items not found from the info array |
|
2461 for ( TInt i = itemsFoundArray.Count() - 1 ; i >= 0; --i ) |
|
2462 { |
|
2463 if ( !itemsFoundArray[i] ) |
|
2464 { |
|
2465 delete iLauncherItems[i]; |
|
2466 iLauncherItems.Remove( i ); |
|
2467 iLauncherItemUids.Remove( i ); |
|
2468 } |
|
2469 } |
|
2470 |
|
2471 // Clean up |
|
2472 CleanupStack::Pop( &itemsFoundArray ); |
|
2473 itemsFoundArray.Close(); |
|
2474 CleanupStack::PopAndDestroy( &infoArray ); |
|
2475 } |
|
2476 |
|
2477 /** |
|
2478 * Sets application title when leaving this view |
|
2479 */ |
|
2480 void CFSEmailUiLauncherGridVisualiser::SetDefaultStatusPaneTextL() |
|
2481 { |
|
2482 FUNC_LOG; |
|
2483 iAppUi.ResetTitlePaneTextL(); |
|
2484 } |
|
2485 |
|
2486 void CFSEmailUiLauncherGridVisualiser::SetWizardWaitnoteShown( TBool aWaitnoteShown ) |
|
2487 { |
|
2488 FUNC_LOG; |
|
2489 iWizardWaitnoteShown = aWaitnoteShown; |
|
2490 } |
|
2491 |
|
2492 /** |
|
2493 * Check status of all configured mailboxes |
|
2494 */ |
|
2495 TFSLauncherGridMailboxStatus CFSEmailUiLauncherGridVisualiser::CheckMailboxStatusL() |
|
2496 { |
|
2497 FUNC_LOG; |
|
2498 RPointerArray<CFSMailBox> mailBoxes; |
|
2499 CleanupResetAndDestroyClosePushL( mailBoxes ); |
|
2500 TFSMailMsgId id; |
|
2501 TInt err = iAppUi.GetMailClient()->ListMailBoxes( |
|
2502 id, |
|
2503 mailBoxes ); |
|
2504 |
|
2505 TFSLauncherGridMailboxStatus returnStatus; |
|
2506 returnStatus.iMailboxCount = mailBoxes.Count(); |
|
2507 // Reset counters |
|
2508 returnStatus.iMailboxesOnline = returnStatus.iMailboxesOffline = returnStatus.iMailboxesSyncing = 0; |
|
2509 |
|
2510 for ( TInt i = 0; i < mailBoxes.Count(); i++ ) |
|
2511 { |
|
2512 // First check online/offline status |
|
2513 TFSMailBoxStatus onOffStatus = mailBoxes[i]->GetMailBoxStatus(); |
|
2514 if( onOffStatus == EFSMailBoxOffline ) |
|
2515 { |
|
2516 returnStatus.iMailboxesOffline++; |
|
2517 } |
|
2518 else if( onOffStatus == EFSMailBoxOnline ) |
|
2519 { |
|
2520 returnStatus.iMailboxesOnline++; |
|
2521 } |
|
2522 |
|
2523 // Then check sync state |
|
2524 TSSMailSyncState latestSyncstate = mailBoxes[i]->CurrentSyncState(); |
|
2525 if( latestSyncstate == InboxSyncing || |
|
2526 latestSyncstate == StartingSync || |
|
2527 latestSyncstate == EmailSyncing ) |
|
2528 { |
|
2529 returnStatus.iMailboxesSyncing++; |
|
2530 } |
|
2531 } |
|
2532 |
|
2533 CleanupStack::PopAndDestroy( &mailBoxes ); |
|
2534 return returnStatus; |
|
2535 } |
|
2536 |
|
2537 // Bitmap provider for grid ecom plugins icons |
|
2538 void CFSEmailUiLauncherGridVisualiser::ProvideBitmapL(TInt aId, CFbsBitmap*& aBitmap, CFbsBitmap*& aMaskBitmap) |
|
2539 { |
|
2540 FUNC_LOG; |
|
2541 TRect mainPaneRect; |
|
2542 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); |
|
2543 TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
|
2544 |
|
2545 TAknLayoutRect scrollBarRect; |
|
2546 scrollBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar()); |
|
2547 TRect gridRect = mainPaneRect; |
|
2548 gridRect.iBr.iX -= scrollBarRect.Rect().Width(); |
|
2549 |
|
2550 TAknLayoutRect itemRect; |
|
2551 itemRect.LayoutRect(gridRect, AknLayoutScalable_Apps::cell_cmail_l_pane(var, 0, 0)); |
|
2552 |
|
2553 TAknLayoutRect gridIconRect; |
|
2554 gridIconRect.LayoutRect(itemRect.Rect(), AknLayoutScalable_Apps::cell_cmail_l_pane_g1(var)); |
|
2555 |
|
2556 CAknIcon* launcherItemIcon(0); |
|
2557 for ( TInt i=0; i<iPluginIdIconIdPairs.Count(); i++ ) |
|
2558 { |
|
2559 if ( aId == iPluginIdIconIdPairs[i].iIconId ) |
|
2560 { |
|
2561 launcherItemIcon = iLauncherItems[iPluginIdIconIdPairs[i].iPluginArrayIndex]->Icon(); |
|
2562 } |
|
2563 } |
|
2564 |
|
2565 if ( launcherItemIcon ) |
|
2566 { |
|
2567 // Set bitmap size |
|
2568 TSize iconSize = gridIconRect.Rect().Size(); |
|
2569 if( launcherItemIcon->Bitmap() ) |
|
2570 { |
|
2571 AknIconUtils::DisableCompression( launcherItemIcon->Bitmap() ); |
|
2572 AknIconUtils::SetSize( launcherItemIcon->Bitmap(), iconSize, EAspectRatioPreserved ); |
|
2573 } |
|
2574 if( launcherItemIcon->Mask() ) |
|
2575 { |
|
2576 AknIconUtils::DisableCompression( launcherItemIcon->Mask()); |
|
2577 AknIconUtils::SetSize( launcherItemIcon->Mask(), iconSize, EAspectRatioPreserved ); |
|
2578 } |
|
2579 // Create duplicate sof original for alf |
|
2580 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; |
|
2581 bitmap->Duplicate( launcherItemIcon->Bitmap()->Handle() ); |
|
2582 CFbsBitmap* mask = new (ELeave) CFbsBitmap; |
|
2583 mask->Duplicate( launcherItemIcon->Mask()->Handle() ); |
|
2584 |
|
2585 aBitmap = bitmap; |
|
2586 aMaskBitmap = mask; |
|
2587 } |
|
2588 else |
|
2589 { |
|
2590 User::Leave(KErrNotFound); // Leave as icon is not found, should not go here |
|
2591 } |
|
2592 } |
|
2593 |
|
2594 void CFSEmailUiLauncherGridVisualiser::SetRefreshNeeded() |
|
2595 { |
|
2596 FUNC_LOG; |
|
2597 iRefreshNeeded = ETrue; |
|
2598 iDoubleClickLock = EFalse; |
|
2599 } |
|
2600 |
|
2601 TReal32 CFSEmailUiLauncherGridVisualiser::TRingMovementFuncMappingDataProvider::MapValue(TReal32 aValue, TInt /*aMode*/) const |
|
2602 { |
|
2603 FUNC_LOG; |
|
2604 AlfUtil::WrapValue(aValue, iStart, iEnd); |
|
2605 return aValue; |
|
2606 } |
|
2607 |
|
2608 void CFSEmailUiLauncherGridVisualiser::DetachSelectorMappingFunctions() |
|
2609 { |
|
2610 FUNC_LOG; |
|
2611 if ( iSelector ) |
|
2612 { |
|
2613 TAlfTimedPoint selectorPos; |
|
2614 selectorPos.iX.SetMappingFunctionIdentifier( 0 ); |
|
2615 selectorPos.iY.SetMappingFunctionIdentifier( 0 ); |
|
2616 iSelector->SetPos( selectorPos ); |
|
2617 } |
|
2618 } |
|
2619 |
|
2620 |
|
2621 // ----------------------------------------------------------------------------- |
|
2622 // CFSEmailUiLauncherGridVisualiser::UpdateFocusVisibility() |
|
2623 // Updates the selector and the text color of a focused item. |
|
2624 // ----------------------------------------------------------------------------- |
|
2625 // |
|
2626 void CFSEmailUiLauncherGridVisualiser::UpdateFocusVisibility() |
|
2627 { |
|
2628 const TBool showFocus = ( IsFocusShown() || |
|
2629 iItemIdInButtonDownEvent.iItemId >= 0 ); |
|
2630 |
|
2631 // Update the selector. |
|
2632 if ( iSelector ) |
|
2633 { |
|
2634 TAlfTimedValue selectorOpacity; |
|
2635 |
|
2636 if ( showFocus ) |
|
2637 { |
|
2638 selectorOpacity.SetValueNow( 1 ); |
|
2639 } |
|
2640 else |
|
2641 { |
|
2642 selectorOpacity.SetValueNow( 0 ); |
|
2643 } |
|
2644 |
|
2645 iSelector->SetOpacity( selectorOpacity ); |
|
2646 } |
|
2647 |
|
2648 // Update the text color of the previously and newly selected items. |
|
2649 TRgb normalColor( KRgbGray ); |
|
2650 TRgb focusedColor( KRgbGray ); |
|
2651 |
|
2652 if ( ( AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), normalColor, |
|
2653 KAknsIIDQsnTextColors, |
|
2654 EAknsCIQsnTextColorsCG9 ) != KErrNone ) || |
|
2655 ( AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), focusedColor, |
|
2656 KAknsIIDQsnTextColors, |
|
2657 EAknsCIQsnTextColorsCG11 ) != KErrNone ) ) |
|
2658 { |
|
2659 // No colors available. |
|
2660 return; |
|
2661 } |
|
2662 |
|
2663 CAlfTextVisual* textVisual = NULL; |
|
2664 const TInt itemCount( iCurrentLevel.iItemVisualData.Count() ); |
|
2665 |
|
2666 // Set the colors of the captions not focused to normal and if an item is |
|
2667 // focused, set the color of its caption using the highlighted theme color. |
|
2668 for ( TInt i = 0; i < itemCount; ++i ) |
|
2669 { |
|
2670 textVisual = iCurrentLevel.iItemVisualData[i].iText; |
|
2671 |
|
2672 if ( textVisual ) |
|
2673 { |
|
2674 if ( showFocus && iCurrentLevel.iSelected == i ) |
|
2675 { |
|
2676 textVisual->SetColor( focusedColor ); |
|
2677 } |
|
2678 else |
|
2679 { |
|
2680 textVisual->SetColor( normalColor ); |
|
2681 } |
|
2682 } |
|
2683 } |
|
2684 } |
|
2685 |
|
2686 |
|
2687 void CFSEmailUiLauncherGridVisualiser::FlipStateChangedL( TBool aKeyboardFlipOpen ) |
|
2688 { |
|
2689 CFsEmailUiViewBase::FlipStateChangedL( aKeyboardFlipOpen ); |
|
2690 UpdateFocusVisibility(); |
|
2691 } |
|
2692 |
|
2693 void CFSEmailUiLauncherGridVisualiser::MailboxDeletionComplete() |
|
2694 { |
|
2695 TRAP_IGNORE( HandleContentChangeL() ); |
|
2696 } |
|
2697 |
|
2698 void CFSEmailUiLauncherGridVisualiser::FocusVisibilityChange( TBool aVisible ) |
|
2699 { |
|
2700 CFsEmailUiViewBase::FocusVisibilityChange( aVisible ); |
|
2701 UpdateFocusVisibility(); |
|
2702 ResizeItemIcon( !aVisible ); |
|
2703 } |
|
2704 |
|
2705 // ----------------------------------------------------------------------------- |
|
2706 // CFSEmailUiLauncherGridVisualiser::ViewPositionChanged |
|
2707 // From MAknPhysicsObserver |
|
2708 // ----------------------------------------------------------------------------- |
|
2709 // |
|
2710 void CFSEmailUiLauncherGridVisualiser::ViewPositionChanged( |
|
2711 const TPoint& aNewPosition, |
|
2712 TBool /*aDrawNow*/, |
|
2713 TUint /*aFlags*/ ) |
|
2714 { |
|
2715 FUNC_LOG; |
|
2716 |
|
2717 // controls must be created first |
|
2718 if ( !iConstructionCompleted ) |
|
2719 { |
|
2720 return; |
|
2721 } |
|
2722 |
|
2723 TRect mainPaneRect; |
|
2724 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); |
|
2725 iCurrentLevel.iParentPos.iY = aNewPosition.iY - mainPaneRect.Height()/2; |
|
2726 TAlfTimedPoint alfScrollOffset; |
|
2727 alfScrollOffset.iY.SetTarget( iCurrentLevel.iParentPos.iY , 0 ); |
|
2728 iCurrentLevel.iGridLayout->SetScrollOffset(alfScrollOffset); |
|
2729 iScrollbarModel.SetFocusPosition( iCurrentLevel.iParentPos.iY ); |
|
2730 TRAP_IGNORE( iScrollbar->SetModelL(&iScrollbarModel) ); |
|
2731 iScrollbar->DrawNow(); |
|
2732 iFirstVisibleRow = iCurrentLevel.iParentPos.iY/iRowHeight; |
|
2733 if ( iFirstVisibleRow < 0 ) |
|
2734 { |
|
2735 iFirstVisibleRow = 0; |
|
2736 } |
|
2737 else if ( iFirstVisibleRow > iRowCount ) |
|
2738 { |
|
2739 iFirstVisibleRow = iRowCount; |
|
2740 } |
|
2741 } |
|
2742 |
|
2743 // ----------------------------------------------------------------------------- |
|
2744 // CNcsComposeViewContainer::PhysicEmulationEnded |
|
2745 // From MAknPhysicsObserver |
|
2746 // ----------------------------------------------------------------------------- |
|
2747 // |
|
2748 void CFSEmailUiLauncherGridVisualiser::PhysicEmulationEnded() |
|
2749 { |
|
2750 FUNC_LOG; |
|
2751 } |
|
2752 |
|
2753 // ----------------------------------------------------------------------------- |
|
2754 // CNcsComposeViewContainer::ViewPosition |
|
2755 // From MAknPhysicsObserver |
|
2756 // ----------------------------------------------------------------------------- |
|
2757 // |
|
2758 TPoint CFSEmailUiLauncherGridVisualiser::ViewPosition() const |
|
2759 { |
|
2760 FUNC_LOG; |
|
2761 TRect mainPaneRect; |
|
2762 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); |
|
2763 TInt current = iCurrentLevel.iParentPos.iY; |
|
2764 TInt viewCentre = mainPaneRect.Size().iHeight / 2; |
|
2765 TPoint point( 0, current + viewCentre ); |
|
2766 return point; |
|
2767 } |
|
2768 |
|
2769 // ---------------------------------------------------------------------------- |
|
2770 // LaunchStylusPopupMenuL() |
|
2771 // Launches and displays the pop-up menu invoked by a long tap event. |
|
2772 // ---------------------------------------------------------------------------- |
|
2773 // |
|
2774 void CFSEmailUiLauncherGridVisualiser::LaunchStylusPopupMenu( |
|
2775 const TInt aItemId ) |
|
2776 { |
|
2777 TInt count = iCurrentLevel.iItemVisualData.Count(); |
|
2778 if ( aItemId < 0 || aItemId >= count ) |
|
2779 { |
|
2780 return; // incorrect index |
|
2781 } |
|
2782 |
|
2783 count = iCurrentLevel.iItems.Count(); |
|
2784 if ( aItemId < 0 || aItemId >= count ) |
|
2785 { |
|
2786 return; // incorrect index |
|
2787 } |
|
2788 // Get the ID of the mailbox in case the user wants to delete it. |
|
2789 iMailboxToDelete = iCurrentLevel.iItems[aItemId].iMailBoxId; |
|
2790 |
|
2791 // Get the item position and use it to determine the position of the menu. |
|
2792 const TRect rect( |
|
2793 iCurrentLevel.iItemVisualData[aItemId].iBase->DisplayRect() ); |
|
2794 TPoint position( rect.iTl.iX + rect.Width() / 2, |
|
2795 rect.iTl.iY + rect.Height() / 2 ); |
|
2796 iStylusPopUpMenu->SetPosition( position ); |
|
2797 |
|
2798 // Display the menu. |
|
2799 iStylusPopUpMenu->ShowMenu(); |
|
2800 iStylusPopUpMenuLaunched = ETrue; |
|
2801 } |
|
2802 |
|
2803 void CFSEmailUiLauncherGridVisualiser::HandleAppForegroundEventL( TBool aForeground ) |
|
2804 { |
|
2805 FUNC_LOG; |
|
2806 |
|
2807 // If the view is not visible try to visualise it after a while |
|
2808 if ( aForeground && !iWasActiveControlGroup ) |
|
2809 { |
|
2810 iStartupCallbackTimer->Cancel(); // just in case |
|
2811 iStartupCallbackTimer->SetPriority( CActive::EPriorityIdle ); |
|
2812 iStartupCallbackTimer->Start( 200 ); |
|
2813 } |
|
2814 |
|
2815 UpdateGridOffset(); |
|
2816 CFsEmailUiViewBase::HandleAppForegroundEventL( aForeground ); |
|
2817 } |
|
2818 |
|
2819 // ---------------------------------------------------------------------------- |
|
2820 // CFSEmailUiLauncherGridVisualiser::TimerEventL() |
|
2821 // Fire timer callback |
|
2822 // ---------------------------------------------------------------------------- |
|
2823 void CFSEmailUiLauncherGridVisualiser::TimerEventL( CFSEmailUiGenericTimer* /* aTriggeredTimer */ ) |
|
2824 { |
|
2825 FUNC_LOG; |
|
2826 |
|
2827 // if view is still active then |
|
2828 if ( iAppUi.CurrentActiveView() && iAppUi.CurrentActiveView()->Id() == Id() ) |
|
2829 { |
|
2830 iWasActiveControlGroup = ETrue; |
|
2831 CFsEmailUiViewBase::HandleAppForegroundEventL( ETrue ); |
|
2832 } |
|
2833 |
|
2834 iStartupCallbackTimer->Cancel(); |
|
2835 } |
|
2836 |
|
2837 // --------------------------------------------------------------------------- |
|
2838 // CFSEmailUiLauncherGridVisualiser::UpdatePhysicsL() |
|
2839 // --------------------------------------------------------------------------- |
|
2840 // |
|
2841 void CFSEmailUiLauncherGridVisualiser::UpdatePhysicsL() |
|
2842 { |
|
2843 FUNC_LOG; |
|
2844 if ( iPhysics ) |
|
2845 { |
|
2846 TRect mainPaneRect; |
|
2847 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
2848 const TSize viewSize( mainPaneRect.Size() ); |
|
2849 const TSize worldSize( 0, iRowCount * iRowHeight ); |
|
2850 iPhysics->InitPhysicsL( worldSize, viewSize, EFalse ); |
|
2851 } |
|
2852 } |
|
2853 |
|
2854 // --------------------------------------------------------------------------- |
|
2855 // CFSEmailUiLauncherGridVisualiser::UpdateGridOffset() |
|
2856 // --------------------------------------------------------------------------- |
|
2857 // |
|
2858 void CFSEmailUiLauncherGridVisualiser::UpdateGridOffset() |
|
2859 { |
|
2860 if ( iConstructionCompleted ) |
|
2861 { |
|
2862 TAlfTimedPoint alfScrollOffset; |
|
2863 alfScrollOffset.iY.SetTarget( 1.0 , 0); |
|
2864 iCurrentLevel.iGridLayout->SetScrollOffset(alfScrollOffset); |
|
2865 iCurrentLevel.iParentPos.iY = 1.0; |
|
2866 } |
|
2867 } |
|
2868 |