|
1 /* |
|
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ALFTK utilities |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 // Class header |
|
24 |
|
25 // USER INCLUDE FILES |
|
26 #include "glxuiutility.h" |
|
27 #include "glxscreenfurniture.h" |
|
28 #include "glxskinchangemonitor.h" |
|
29 |
|
30 // SYSTEM INCLUDE FILES |
|
31 #include <aknappui.h> |
|
32 #include <AknUtils.h> |
|
33 #include <alf/alfcontrolgroup.h> |
|
34 #include <alf/alfdisplay.h> |
|
35 #include <alf/alfutil.h> |
|
36 #include <alf/alfenv.h> |
|
37 #include <alf/alftexture.h> |
|
38 #include <alf/alftextstyle.h> |
|
39 #include <alf/alftextstylemanager.h> |
|
40 #include <featmgr.h> |
|
41 #include <bldvariant.hrh> // For feature constants |
|
42 #include <eikenv.h> |
|
43 #include <eikappui.h> |
|
44 #include <aknclearer.h> |
|
45 #include <avkondomainpskeys.h> // Keyguard Status |
|
46 // Internal incudes |
|
47 #include <glxresolutionmanager.h> // for CGlxResolutionManager |
|
48 #include <glxsingletonstore.h> |
|
49 #include <glxpanic.h> |
|
50 #include <glxassert.h> // for GLX_ASSERT_DEBUG |
|
51 #include <glxtvconstants.h> // for ETvConnectionChanged |
|
52 #include <glxtv.h> // for CGlxTv |
|
53 #include <glxthumbnail.h> |
|
54 #include <glxsettingsmodel.h> |
|
55 #include <glxsingletonstore.h> |
|
56 #include <glxtexturemanager.h> |
|
57 #include <glxtracer.h> |
|
58 |
|
59 #include <e32property.h> |
|
60 |
|
61 //For animation Effects |
|
62 #include <akntranseffect.h> |
|
63 #include <akntransitionutils.h> |
|
64 |
|
65 //Publish-Subscribe from Thumbnail manager |
|
66 const TUid KTAGDPSNotification = { 0x2001FD51 }; //PS category |
|
67 const TInt KForceBackgroundGeneration = 0x00000010; //PS Key |
|
68 const TInt KItemsleft = 0x00000008; //PS key value |
|
69 /** |
|
70 * Start Delay for the periodic timer, in microseconds |
|
71 */ |
|
72 const TInt KPeriodicStartDelay = 1000000; |
|
73 const TInt KIgnoreItemsLeftCount = 5; |
|
74 //Hg |
|
75 //#include <hg/hgcontextutility.h> |
|
76 |
|
77 // TV size constants |
|
78 using namespace glxTvOut; |
|
79 |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // UtilityL |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 EXPORT_C CGlxUiUtility* CGlxUiUtility::UtilityL() |
|
86 { |
|
87 TRACER("CGlxUiUtility::UtilityL()"); |
|
88 return CGlxSingletonStore::InstanceL(&NewL); |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // Close |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 EXPORT_C void CGlxUiUtility::Close() |
|
96 { |
|
97 TRACER("CGlxUiUtility::Close()"); |
|
98 CGlxSingletonStore::Close(this); |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // 2-phase constructor |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 CGlxUiUtility* CGlxUiUtility::NewL() |
|
106 { |
|
107 TRACER("CGlxUiUtility::NewL()"); |
|
108 CGlxUiUtility* obj = new (ELeave) CGlxUiUtility(); |
|
109 CleanupStack::PushL(obj); |
|
110 obj->ConstructL(); |
|
111 CleanupStack::Pop(obj); |
|
112 return obj; |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // Constructor |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 CGlxUiUtility::CGlxUiUtility() |
|
120 : iEnv(NULL),iNavigationDirection( EGlxNavigationForwards ), |
|
121 iOrientation( EGlxOrientationUninitialised ) |
|
122 { |
|
123 TRACER("CGlxUiUtility::CGlxUiUtility()"); |
|
124 iAppUi = CCoeEnv::Static()->AppUi(); |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // ConstructL |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 void CGlxUiUtility::ConstructL() |
|
132 { |
|
133 TRACER("CGlxUiUtility::ConstructL()"); |
|
134 iSettingsModel = CGlxSettingsModel::InstanceL(); |
|
135 |
|
136 iOrientation = EGlxOrientationDefault; // Always start in default orientation |
|
137 |
|
138 if (!iPeriodic) |
|
139 { |
|
140 iPeriodic = CPeriodic::NewL(CActive::EPriorityStandard); |
|
141 } |
|
142 |
|
143 if (!iPeriodic->IsActive()) |
|
144 { |
|
145 iPeriodic->Start(KPeriodicStartDelay, KMaxTInt, |
|
146 TCallBack(&PeriodicCallback, static_cast<TAny*> (this))); |
|
147 } |
|
148 |
|
149 GridIconSizeL(); |
|
150 iScreenFurniture = CGlxScreenFurniture::NewL(*this); |
|
151 iIsForeground = EFalse; |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // Callback from periodic timer |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 TInt CGlxUiUtility::PeriodicCallback(TAny* aPtr ) |
|
159 { |
|
160 TRACER("CGlxUiUtility::PeriodicCallback"); |
|
161 static_cast< CGlxUiUtility* >( aPtr )->CreateAlfEnvCallbackL(); |
|
162 return KErrNone; |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // Callback from periodic timer-- non static |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 void CGlxUiUtility::CreateAlfEnvCallbackL() |
|
170 { |
|
171 TRACER("CGlxUiUtility::CreateAlfEnvCallbackL"); |
|
172 CreateAlfEnvL(); |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // Create ALF env |
|
177 // ----------------------------------------------------------------------------- |
|
178 // |
|
179 void CGlxUiUtility::CreateAlfEnvL() |
|
180 { |
|
181 TRACER("CGlxUiUtility::CreateAlfEnvL"); |
|
182 if (iPeriodic->IsActive()) |
|
183 { |
|
184 iPeriodic->Cancel(); |
|
185 } |
|
186 |
|
187 iEnv = CAlfEnv::Static(); |
|
188 if (!iEnv) |
|
189 { |
|
190 iEnv = CAlfEnv::NewL(); |
|
191 } |
|
192 else |
|
193 { |
|
194 iShared = ETrue; |
|
195 } |
|
196 iGlxTextureManager = CGlxTextureManager::NewL(iEnv->TextureManager()); |
|
197 |
|
198 //Skin change observer |
|
199 iGlxSkinChangeMonitor = CGlxSkinChangeMonitor::NewL(); |
|
200 iAppUi->AddToStackL(iGlxSkinChangeMonitor); |
|
201 |
|
202 // Add TextureManager as a skin change event observer here itself because |
|
203 // calling CGlxHuiUtility::Utility() in CGlxTextureManager creates a recursive call |
|
204 // to CGlxTextureManager::NewL which again calls CGlxHuiUtility::Utility() and so on. |
|
205 AddSkinChangeObserverL( *iGlxTextureManager ); |
|
206 |
|
207 TRect rect; |
|
208 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, rect ); |
|
209 iAlfDisplay = &iEnv->NewDisplayL(rect, |
|
210 CAlfEnv::ENewDisplayAsCoeControl | CAlfEnv::ENewDisplayFullScreen ); |
|
211 |
|
212 iEnv->AddActionObserverL (this); |
|
213 |
|
214 // create the resoltuion manager - needs to be informed when screen size |
|
215 // changes |
|
216 iGlxResolutionManager = CGlxResolutionManager::NewL(); |
|
217 |
|
218 iGlxTvOut = CGlxTv::NewL(*this); |
|
219 |
|
220 // Is the TV Out display on |
|
221 // Note that this also sets the initial size for the resolution manager |
|
222 HandleTvStatusChangedL( ETvConnectionChanged ); |
|
223 } |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // Destructor |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 CGlxUiUtility::~CGlxUiUtility() |
|
230 { |
|
231 TRACER("CGlxUiUtility::~CGlxUiUtility()"); |
|
232 GLX_LOG_INFO("~CGlxUiUtility"); |
|
233 |
|
234 if(iClearer) |
|
235 { |
|
236 delete iClearer; |
|
237 } |
|
238 |
|
239 if(iScreenFurniture) |
|
240 { |
|
241 delete iScreenFurniture; |
|
242 } |
|
243 |
|
244 if(iGlxTvOut) |
|
245 { |
|
246 // Destroy TV Out related objects |
|
247 delete iGlxTvOut; |
|
248 } |
|
249 |
|
250 if(iGlxResolutionManager) |
|
251 { |
|
252 delete iGlxResolutionManager; |
|
253 } |
|
254 |
|
255 DestroyTvOutDisplay(); |
|
256 |
|
257 if( iGlxTextureManager ) |
|
258 { |
|
259 RemoveSkinChangeObserver( *iGlxTextureManager ); |
|
260 delete iGlxTextureManager; |
|
261 } |
|
262 |
|
263 if(iAlfDisplay) |
|
264 { |
|
265 delete iAlfDisplay; |
|
266 } |
|
267 if(iEnv) |
|
268 { |
|
269 iEnv->RemoveActionObserver(this); |
|
270 } |
|
271 |
|
272 if ( iGlxSkinChangeMonitor ) |
|
273 { |
|
274 iAppUi->RemoveFromStack(iGlxSkinChangeMonitor); |
|
275 delete iGlxSkinChangeMonitor; |
|
276 } |
|
277 |
|
278 if (!iShared) |
|
279 { |
|
280 delete iEnv; |
|
281 } |
|
282 iTextStyles.Close(); |
|
283 if ( iSettingsModel ) |
|
284 { |
|
285 iSettingsModel->Close(); |
|
286 } |
|
287 |
|
288 if (iPeriodic) |
|
289 { |
|
290 iPeriodic->Cancel(); |
|
291 delete iPeriodic; |
|
292 } |
|
293 } |
|
294 |
|
295 // ----------------------------------------------------------------------------- |
|
296 // Env |
|
297 // ----------------------------------------------------------------------------- |
|
298 // |
|
299 EXPORT_C CAlfEnv* CGlxUiUtility::Env() |
|
300 { |
|
301 TRACER("CGlxUiUtility::EnvL()"); |
|
302 if(!iEnv) |
|
303 { |
|
304 TRAP_IGNORE(CreateAlfEnvL()); |
|
305 } |
|
306 return iEnv; |
|
307 } |
|
308 |
|
309 |
|
310 // ----------------------------------------------------------------------------- |
|
311 // Display |
|
312 // ----------------------------------------------------------------------------- |
|
313 // |
|
314 EXPORT_C CAlfDisplay* CGlxUiUtility::Display() const |
|
315 { |
|
316 TRACER("CGlxUiUtility::Display()"); |
|
317 return iAlfDisplay; |
|
318 } |
|
319 |
|
320 // ----------------------------------------------------------------------------- |
|
321 // ShowAlfDisplay |
|
322 // ----------------------------------------------------------------------------- |
|
323 EXPORT_C void CGlxUiUtility::ShowAlfDisplayL() |
|
324 { |
|
325 TRACER("CGlxUiUtility::ShowAlfDisplayL()"); |
|
326 // make it visible as well |
|
327 CGlxUiUtility* uiUtility = CGlxUiUtility::UtilityL(); |
|
328 |
|
329 CCoeControl* contl = |
|
330 (CCoeControl*) uiUtility->Display()->ObjectProvider(); |
|
331 contl->MakeVisible(ETrue); |
|
332 |
|
333 uiUtility->Close(); |
|
334 // no need to do anything else, the coecontrol handles the visibility |
|
335 } |
|
336 |
|
337 // ----------------------------------------------------------------------------- |
|
338 // HideAlfDisplay |
|
339 // ----------------------------------------------------------------------------- |
|
340 EXPORT_C void CGlxUiUtility::HideAlfDisplayL() |
|
341 { |
|
342 TRACER("CGlxUiUtility::HideAlfDisplayL()"); |
|
343 // make it invisible as well (this might be all that is needed) |
|
344 CGlxUiUtility* uiUtility = CGlxUiUtility::UtilityL(); |
|
345 |
|
346 CCoeControl* contl = |
|
347 (CCoeControl*) uiUtility->Display()->ObjectProvider(); |
|
348 contl->MakeVisible (EFalse); |
|
349 |
|
350 uiUtility->Close(); |
|
351 // no need to do anything else, the coecontrol handles the visibility |
|
352 } |
|
353 |
|
354 // ----------------------------------------------------------------------------- |
|
355 // GlxTextureManager |
|
356 // ----------------------------------------------------------------------------- |
|
357 // |
|
358 EXPORT_C CGlxTextureManager& CGlxUiUtility::GlxTextureManager() |
|
359 { |
|
360 TRACER("CGlxUiUtility::GlxTextureManager()"); |
|
361 __ASSERT_ALWAYS(iGlxTextureManager, Panic(EGlxPanicLogicError)); |
|
362 return *iGlxTextureManager; |
|
363 } |
|
364 |
|
365 // ----------------------------------------------------------------------------- |
|
366 // ViewNavigationDirection |
|
367 // ----------------------------------------------------------------------------- |
|
368 // |
|
369 EXPORT_C TGlxNavigationDirection CGlxUiUtility::ViewNavigationDirection() |
|
370 { |
|
371 TRACER("CGlxUiUtility::ViewNavigationDirection()"); |
|
372 return iNavigationDirection; |
|
373 } |
|
374 |
|
375 // ----------------------------------------------------------------------------- |
|
376 // SetViewNavigationDirection |
|
377 // ----------------------------------------------------------------------------- |
|
378 // |
|
379 EXPORT_C void CGlxUiUtility::SetViewNavigationDirection( |
|
380 TGlxNavigationDirection aDirection) |
|
381 { |
|
382 TRACER("CGlxUiUtility::SetViewNavigationDirection()"); |
|
383 iNavigationDirection = aDirection; |
|
384 } |
|
385 |
|
386 // ----------------------------------------------------------------------------- |
|
387 // DisplaySize |
|
388 // ----------------------------------------------------------------------------- |
|
389 // |
|
390 EXPORT_C TSize CGlxUiUtility::DisplaySize() const |
|
391 { |
|
392 TRACER("CGlxUiUtility::DisplaySize()"); |
|
393 const TRect& rect = CEikonEnv::Static()->EikAppUi()->ApplicationRect(); |
|
394 return rect.Size(); |
|
395 } |
|
396 |
|
397 // ----------------------------------------------------------------------------- |
|
398 // TextStyleIdL |
|
399 // ----------------------------------------------------------------------------- |
|
400 // |
|
401 EXPORT_C TInt CGlxUiUtility::TextStyleIdL(TInt aFontId, TInt aSizeInPixels) |
|
402 { |
|
403 TRACER("CGlxUiUtility::TextStyleIdL()"); |
|
404 TInt id = 0; |
|
405 TBool found = EFalse; |
|
406 TInt index = 0; |
|
407 TInt count = iTextStyles.Count(); |
|
408 // Look for existing style with this font and size |
|
409 while(index < count && !found) |
|
410 { |
|
411 if(iTextStyles[index].iSizeInPixels == aSizeInPixels && |
|
412 iTextStyles[index].iFontId == aFontId) |
|
413 { |
|
414 // found it. Prepare to return found id |
|
415 id = iTextStyles[index].iStyleId; |
|
416 found = ETrue; |
|
417 } |
|
418 else |
|
419 { |
|
420 // check next style |
|
421 index++; |
|
422 } |
|
423 } |
|
424 if(!found) |
|
425 { |
|
426 // Create a new style based on the required font |
|
427 CAlfTextStyleManager& styleMan = iEnv->TextStyleManager(); |
|
428 |
|
429 // remember its id for return later |
|
430 id = styleMan.CreatePlatformTextStyleL(aFontId); |
|
431 |
|
432 // Get style. It is not owned |
|
433 CAlfTextStyle* style = styleMan.TextStyle(id); |
|
434 |
|
435 // Set this style to have required size and to be normal weight |
|
436 style->SetTextSizeInPixels(aSizeInPixels); |
|
437 |
|
438 style->SetBold(EFalse); |
|
439 |
|
440 // Add this style to list |
|
441 TGlxTextStyle textStyle(aFontId, aSizeInPixels, id); |
|
442 iTextStyles.AppendL(textStyle); |
|
443 } |
|
444 return id; |
|
445 } |
|
446 |
|
447 // --------------------------------------------------------------------------- |
|
448 // SetAppOrientationL |
|
449 // --------------------------------------------------------------------------- |
|
450 // |
|
451 EXPORT_C void CGlxUiUtility::SetAppOrientationL(TGlxOrientation aOrientation) |
|
452 { |
|
453 TRACER("CGlxUiUtility::SetAppOrientationL()"); |
|
454 GLX_LOG_INFO1( "CGlxUiUtility::SetAppOrientationL(%d)", aOrientation ); |
|
455 |
|
456 if ( iOrientation != aOrientation ) |
|
457 { |
|
458 CAknAppUiBase::TAppUiOrientation orientation( |
|
459 CAknAppUiBase::EAppUiOrientationUnspecified); |
|
460 |
|
461 switch ( aOrientation ) |
|
462 { |
|
463 case EGlxOrientationTextEntry: |
|
464 if ( iSettingsModel->IsTextEntryPortrait() ) |
|
465 { |
|
466 orientation = CAknAppUiBase::EAppUiOrientationPortrait; |
|
467 break; |
|
468 } |
|
469 // else fall through to EGlxOrientationDefault |
|
470 |
|
471 case EGlxOrientationDefault: |
|
472 { |
|
473 if ( CGlxSettingsModel::ELandscape |
|
474 == iSettingsModel->SupportedOrientations() ) |
|
475 { |
|
476 orientation = CAknAppUiBase::EAppUiOrientationLandscape; |
|
477 } |
|
478 else |
|
479 { |
|
480 orientation = CAknAppUiBase::EAppUiOrientationAutomatic; |
|
481 } |
|
482 } |
|
483 break; |
|
484 |
|
485 case EGlxOrientationLandscape: |
|
486 orientation = CAknAppUiBase::EAppUiOrientationLandscape; |
|
487 break; |
|
488 |
|
489 default: |
|
490 Panic(EGlxPanicIllegalArgument); |
|
491 break; |
|
492 } |
|
493 |
|
494 static_cast<CAknAppUiBase*>(iAppUi)->SetOrientationL(orientation); |
|
495 iOrientation = aOrientation; |
|
496 } |
|
497 } |
|
498 |
|
499 // --------------------------------------------------------------------------- |
|
500 // AppOrientation |
|
501 // --------------------------------------------------------------------------- |
|
502 // |
|
503 EXPORT_C TGlxOrientation CGlxUiUtility::AppOrientation() const |
|
504 { |
|
505 TRACER("CGlxUiUtility::AppOrientation()"); |
|
506 return iOrientation; |
|
507 } |
|
508 // ----------------------------------------------------------------------------- |
|
509 // GetGridIconSize |
|
510 // ----------------------------------------------------------------------------- |
|
511 // |
|
512 EXPORT_C TSize CGlxUiUtility::GetGridIconSize() |
|
513 { |
|
514 TRACER("CGlxUiUtility::GetGridIconSize()"); |
|
515 return iGridIconSize; |
|
516 } |
|
517 |
|
518 // ----------------------------------------------------------------------------- |
|
519 // SetGridToolBar |
|
520 // ----------------------------------------------------------------------------- |
|
521 // |
|
522 EXPORT_C void CGlxUiUtility::SetGridToolBar(CAknToolbar* aToolbar) |
|
523 { |
|
524 TRACER("CGlxUiUtility::SetGridToolBar()"); |
|
525 iToolbar = aToolbar; |
|
526 } |
|
527 |
|
528 // ----------------------------------------------------------------------------- |
|
529 // GetGridToolBar |
|
530 // ----------------------------------------------------------------------------- |
|
531 // |
|
532 EXPORT_C CAknToolbar* CGlxUiUtility::GetGridToolBar() |
|
533 { |
|
534 TRACER("CGlxUiUtility::GetGridToolBar()"); |
|
535 if(iToolbar) |
|
536 { |
|
537 return iToolbar; |
|
538 } |
|
539 return NULL; |
|
540 } |
|
541 |
|
542 // ----------------------------------------------------------------------------- |
|
543 // HandleTvStatusChangedL |
|
544 // ----------------------------------------------------------------------------- |
|
545 // |
|
546 EXPORT_C void CGlxUiUtility::HandleTvStatusChangedL( TTvChangeType aChangeType ) |
|
547 { |
|
548 TRACER("CGlxUiUtility::HandleTvStatusChangedL()"); |
|
549 |
|
550 if (aChangeType == ETvDisplayNotVisible) // Visibility event |
|
551 { |
|
552 iEnv->Release(); |
|
553 return; // don't redraw the display |
|
554 } |
|
555 else if (aChangeType == ETvDisplayIsVisible) // Visibility event |
|
556 { |
|
557 iEnv->RestoreL(); |
|
558 } |
|
559 else // TV Connection event |
|
560 { |
|
561 GLX_ASSERT_DEBUG( (aChangeType == ETvConnectionChanged), |
|
562 Panic( EGlxPanicLogicError ), |
|
563 "Expected TV Connection Changed" ); |
|
564 |
|
565 if ( iGlxTvOut->IsConnected() ) |
|
566 { |
|
567 // Remove the TV Diplay - a ETvConnectionChanged may result from |
|
568 // the user changing the central repository TV values. |
|
569 DestroyTvOutDisplay(); |
|
570 CreateTvOutDisplayL(); |
|
571 } |
|
572 else |
|
573 { |
|
574 DestroyTvOutDisplay(); |
|
575 // Set the display size to that of the phone |
|
576 iGlxResolutionManager->SetScreenSizeL( DisplaySize() ); |
|
577 } |
|
578 } |
|
579 |
|
580 if (iTvDisplay) |
|
581 { |
|
582 iTvDisplay->SetDirty(); // redraw |
|
583 } |
|
584 } |
|
585 |
|
586 // ----------------------------------------------------------------------------- |
|
587 // SetRotatedImageSize |
|
588 // ----------------------------------------------------------------------------- |
|
589 // |
|
590 EXPORT_C void CGlxUiUtility::SetRotatedImageSize(TSize aRotatedImageSize) |
|
591 { |
|
592 iRotatedImageSize = aRotatedImageSize; |
|
593 } |
|
594 |
|
595 // ----------------------------------------------------------------------------- |
|
596 // SetForegroundStatus |
|
597 // ----------------------------------------------------------------------------- |
|
598 // |
|
599 EXPORT_C void CGlxUiUtility::SetForegroundStatus(TBool aForeground) |
|
600 { |
|
601 TRACER("CGlxUiUtility::SetForegroundStatus()"); |
|
602 iIsForeground = aForeground; |
|
603 } |
|
604 |
|
605 // ----------------------------------------------------------------------------- |
|
606 // GetForegroundStatus |
|
607 // ----------------------------------------------------------------------------- |
|
608 // |
|
609 EXPORT_C TBool CGlxUiUtility::GetForegroundStatus() |
|
610 { |
|
611 TRACER("CGlxUiUtility::GetForegroundStatus()"); |
|
612 GLX_DEBUG2("CGlxUiUtility::GetForegroundStatus() iIsForeground=%d", iIsForeground); |
|
613 return iIsForeground; |
|
614 } |
|
615 |
|
616 // ----------------------------------------------------------------------------- |
|
617 // SetRotatedImageSize |
|
618 // ----------------------------------------------------------------------------- |
|
619 // |
|
620 EXPORT_C TSize CGlxUiUtility::GetRotatedImageSize() |
|
621 { |
|
622 return iRotatedImageSize; |
|
623 } |
|
624 |
|
625 void CGlxUiUtility::HandleActionL (const TAlfActionCommand &aActionCommand) |
|
626 { |
|
627 TRACER("CGlxUiUtility::HandleActionL()"); |
|
628 |
|
629 if(aActionCommand.Id() == KAlfActionIdDeviceLayoutChanged ) |
|
630 { |
|
631 // check if tv-out is connected |
|
632 if ( iGlxTvOut->IsConnected() ) |
|
633 { |
|
634 // The primary (phone) display has changed orientation |
|
635 DestroyTvOutDisplay(); |
|
636 CreateTvOutDisplayL(); //@ will generate false positive in codescanner |
|
637 } |
|
638 else |
|
639 { |
|
640 // reset the screen size in case the orientation changed for example |
|
641 iGlxResolutionManager->SetScreenSizeL( DisplaySize() ); |
|
642 } |
|
643 } |
|
644 } |
|
645 |
|
646 // ----------------------------------------------------------------------------- |
|
647 // DestroyTvOutDisplay |
|
648 // ----------------------------------------------------------------------------- |
|
649 // |
|
650 void CGlxUiUtility::DestroyTvOutDisplay() |
|
651 { |
|
652 TRACER("CGlxUiUtility::DestroyTvOutDisplay()"); |
|
653 if (iTvDisplay) |
|
654 { |
|
655 delete iTvDisplay; |
|
656 iTvDisplay = NULL; |
|
657 |
|
658 iEnv->PauseRefresh(); |
|
659 |
|
660 // Disable Primary Window Visibility events |
|
661 CCoeControl* contl = |
|
662 (CCoeControl*) iEnv->PrimaryDisplay().ObjectProvider(); |
|
663 contl->DrawableWindow()->DisableVisibilityChangeEvents(); |
|
664 } |
|
665 } |
|
666 |
|
667 |
|
668 // ----------------------------------------------------------------------------- |
|
669 // CreateTvOutDisplayL |
|
670 // ----------------------------------------------------------------------------- |
|
671 // |
|
672 void CGlxUiUtility::CreateTvOutDisplayL() |
|
673 { |
|
674 TRACER("CGlxUiUtility::CreateTvOutDisplayL()"); |
|
675 |
|
676 // Get the TV Out display size buffer in pixels |
|
677 TSize tvOutDisplaySz = iGlxTvOut->ScreenSizeL(); |
|
678 |
|
679 // Calculate the TV Out buffer by using |
|
680 // A) aspect ratio that matches the phone screen and |
|
681 // B) size that fills the TV so that either width or height of TV is fully |
|
682 // used (in practice height is always restricting dimension). |
|
683 TSize phoneDisplaySz = DisplaySize(); |
|
684 |
|
685 // Scale the tv display size to match that of the phone display size |
|
686 tvOutDisplaySz = TSize (tvOutDisplaySz.iHeight * phoneDisplaySz.iWidth |
|
687 / phoneDisplaySz.iHeight, tvOutDisplaySz.iHeight ); |
|
688 const TRect tvOutDisplayBuffer( tvOutDisplaySz ); |
|
689 |
|
690 // Set the TV screen size |
|
691 iGlxResolutionManager->SetScreenSizeL( tvOutDisplaySz ); |
|
692 } |
|
693 |
|
694 // ----------------------------------------------------------------------------- |
|
695 // AddSkinChangeObserverL |
|
696 // ----------------------------------------------------------------------------- |
|
697 // |
|
698 EXPORT_C void CGlxUiUtility::AddSkinChangeObserverL( |
|
699 MGlxSkinChangeObserver& aObserver) |
|
700 { |
|
701 TRACER("CGlxUiUtility::AddSkinChangeObserverL()"); |
|
702 iGlxSkinChangeMonitor->AddSkinChangeObserverL( aObserver ); |
|
703 } |
|
704 |
|
705 // ----------------------------------------------------------------------------- |
|
706 // RemoveSkinChangeObserver |
|
707 // ----------------------------------------------------------------------------- |
|
708 // |
|
709 EXPORT_C void CGlxUiUtility::RemoveSkinChangeObserver( |
|
710 MGlxSkinChangeObserver& aObserver) |
|
711 { |
|
712 TRACER("CGlxUiUtility::RemoveSkinChangeObserver()"); |
|
713 iGlxSkinChangeMonitor->RemoveSkinChangeObserver( aObserver ); |
|
714 } |
|
715 |
|
716 // ----------------------------------------------------------------------------- |
|
717 // ScreenFurniture |
|
718 // ----------------------------------------------------------------------------- |
|
719 // |
|
720 EXPORT_C CGlxScreenFurniture* CGlxUiUtility::ScreenFurniture() |
|
721 { |
|
722 return iScreenFurniture; |
|
723 } |
|
724 |
|
725 // ----------------------------------------------------------------------------- |
|
726 // Context Utility for Teleport |
|
727 // ----------------------------------------------------------------------------- |
|
728 // |
|
729 /*EXPORT_C CHgContextUtility* CGlxUiUtility::ContextUtility() |
|
730 { |
|
731 return iContextUtility; |
|
732 } |
|
733 */ |
|
734 // ----------------------------------------------------------------------------- |
|
735 // IsPenSupported |
|
736 // ----------------------------------------------------------------------------- |
|
737 // |
|
738 EXPORT_C TBool CGlxUiUtility::IsPenSupported() |
|
739 { |
|
740 TRACER("CGlxUiUtility::IsPenSupported"); |
|
741 |
|
742 return AknLayoutUtils::PenEnabled(); |
|
743 } |
|
744 |
|
745 // ----------------------------------------------------------------------------- |
|
746 // GridIconSize |
|
747 // ----------------------------------------------------------------------------- |
|
748 // |
|
749 void CGlxUiUtility::GridIconSizeL() |
|
750 { |
|
751 TRACER("CGlxUiUtility::GridIconSize()"); |
|
752 // Sets up TLS, must be done before FeatureManager is used. |
|
753 FeatureManager::InitializeLibL(); |
|
754 |
|
755 if (FeatureManager::FeatureSupported(KFeatureIdLayout640_360_Touch) |
|
756 || FeatureManager::FeatureSupported(KFeatureIdLayout360_640_Touch)) |
|
757 { |
|
758 iGridIconSize = TSize(111, 83); |
|
759 } |
|
760 else if (FeatureManager::FeatureSupported(KFeatureIdLayout640_480_Touch) |
|
761 || FeatureManager::FeatureSupported(KFeatureIdLayout480_640_Touch) |
|
762 || FeatureManager::FeatureSupported(KFeatureIdLayout640_480) |
|
763 || FeatureManager::FeatureSupported(KFeatureIdLayout480_640)) |
|
764 { |
|
765 iGridIconSize = TSize(146, 110); |
|
766 } |
|
767 else |
|
768 { |
|
769 iGridIconSize = TSize(146, 110); |
|
770 } |
|
771 // Frees the TLS. Must be done after FeatureManager is used. |
|
772 FeatureManager::UnInitializeLib(); |
|
773 } |
|
774 |
|
775 |
|
776 |
|
777 EXPORT_C TBool CGlxUiUtility::IsExitingState() |
|
778 { |
|
779 TRACER("CGlxUiUtility::ExitingState"); |
|
780 return iIsExiting; |
|
781 } |
|
782 |
|
783 EXPORT_C void CGlxUiUtility::SetExitingState(TBool aIsExiting) |
|
784 { |
|
785 TRACER("CGlxUiUtility::SetExitingState"); |
|
786 iIsExiting = aIsExiting; |
|
787 } |
|
788 |
|
789 |
|
790 // ----------------------------------------------------------------------------- |
|
791 // VisibleItemsInPageGranularityL |
|
792 // ----------------------------------------------------------------------------- |
|
793 // |
|
794 EXPORT_C TInt CGlxUiUtility::VisibleItemsInPageGranularityL() |
|
795 { |
|
796 TRACER("CGlxUiUtility::VisibleItemsInPageGranularityL"); |
|
797 |
|
798 //TBD: In MCL 9.1/Corolla env currently the feature flags |
|
799 //KFeatureIdLayout640_480 and KFeatureIdLayout480_640 are not defined. |
|
800 //so making the default granularity as 21 instead of 15. |
|
801 //Need to replace with KGlxDefaultVisibleItemsGranularity after |
|
802 //getting the feature flag. |
|
803 TInt ret = KGlxVGAVisibleItemsGranularity; |
|
804 FeatureManager::InitializeLibL(); |
|
805 |
|
806 if (FeatureManager::FeatureSupported(KFeatureIdLayout640_360_Touch) |
|
807 || FeatureManager::FeatureSupported(KFeatureIdLayout360_640_Touch)) |
|
808 { |
|
809 ret = KGlxQHDVisibleItemsGranularity; |
|
810 } |
|
811 else if (FeatureManager::FeatureSupported(KFeatureIdLayout640_480_Touch) |
|
812 || FeatureManager::FeatureSupported(KFeatureIdLayout480_640_Touch) |
|
813 || FeatureManager::FeatureSupported(KFeatureIdLayout640_480) |
|
814 || FeatureManager::FeatureSupported(KFeatureIdLayout480_640)) |
|
815 { |
|
816 ret = KGlxVGAVisibleItemsGranularity; |
|
817 } |
|
818 FeatureManager::UnInitializeLib(); |
|
819 return ret; |
|
820 } |
|
821 |
|
822 // ----------------------------------------------------------------------------- |
|
823 // StartTNMDaemon |
|
824 // ----------------------------------------------------------------------------- |
|
825 // |
|
826 EXPORT_C TInt CGlxUiUtility::StartTNMDaemon() |
|
827 { |
|
828 TRACER("CGlxUiUtility::StartTNMDaemon"); |
|
829 return RProperty::Set(KTAGDPSNotification, KForceBackgroundGeneration, |
|
830 ETrue); |
|
831 } |
|
832 |
|
833 // ----------------------------------------------------------------------------- |
|
834 // StopTNMDaemon |
|
835 // ----------------------------------------------------------------------------- |
|
836 // |
|
837 EXPORT_C TInt CGlxUiUtility::StopTNMDaemon() |
|
838 { |
|
839 TRACER("CGlxUiUtility:: StopTNMDaemon"); |
|
840 return RProperty::Set(KTAGDPSNotification, KForceBackgroundGeneration, |
|
841 EFalse); |
|
842 } |
|
843 |
|
844 // ----------------------------------------------------------------------------- |
|
845 // GetItemsLeftCount |
|
846 // ----------------------------------------------------------------------------- |
|
847 // |
|
848 EXPORT_C TInt CGlxUiUtility::GetItemsLeftCount() |
|
849 { |
|
850 TRACER("CGlxUiUtility::GetItemsLeftCount"); |
|
851 TInt itemsLeftCount = 0; |
|
852 TInt err = |
|
853 RProperty::Get(KTAGDPSNotification, KItemsleft, itemsLeftCount); |
|
854 GLX_LOG_INFO1("GetItemsLeftCount: GetItemsLeftCount %d", itemsLeftCount); |
|
855 |
|
856 // In case of error, enter in the next view. Don't block photos permanently. |
|
857 // [Though this use case is very unlikely] |
|
858 if (err != KErrNone) |
|
859 { |
|
860 GLX_LOG_INFO1("GetItemsLeftCount: RProperty::Get errorcode %d", err); |
|
861 itemsLeftCount = 0; |
|
862 } |
|
863 |
|
864 // This case is added as per UI-Improvements. |
|
865 // Use case: Take a pic. open photos from Menu (not "Goto photos") |
|
866 // Progress bar SHOULD NOT be displayed. |
|
867 if ((itemsLeftCount != KErrNotReady) && (itemsLeftCount |
|
868 <= KIgnoreItemsLeftCount)) |
|
869 { |
|
870 GLX_LOG_INFO("GetItemsLeftCount( < KIgnoreItemsLeftCount )"); |
|
871 itemsLeftCount = 0; |
|
872 } |
|
873 |
|
874 return itemsLeftCount; |
|
875 } |
|
876 |
|
877 // ----------------------------------------------------------------------------- |
|
878 // DisplayScreenClearer |
|
879 // ----------------------------------------------------------------------------- |
|
880 // |
|
881 EXPORT_C void CGlxUiUtility::DisplayScreenClearerL() |
|
882 { |
|
883 TRACER("CGlxUiUtility::DisplayScreenClearerL"); |
|
884 if(!iClearer && CAknTransitionUtils::TransitionsEnabled( |
|
885 AknTransEffect::EFullScreenTransitionsOff)) |
|
886 { |
|
887 iClearer = CAknLocalScreenClearer::NewL( ETrue ); |
|
888 } |
|
889 } |
|
890 |
|
891 // ----------------------------------------------------------------------------- |
|
892 // DisplayScreenClearer |
|
893 // ----------------------------------------------------------------------------- |
|
894 // |
|
895 EXPORT_C void CGlxUiUtility::DestroyScreenClearer() |
|
896 { |
|
897 TRACER("CGlxUiUtility::DestroyScreenClearer"); |
|
898 if(iClearer) |
|
899 { |
|
900 delete iClearer; |
|
901 iClearer = NULL; |
|
902 } |
|
903 } |
|
904 |
|
905 // ----------------------------------------------------------------------------- |
|
906 // SetTNMDaemonPSKeyvalue |
|
907 // ----------------------------------------------------------------------------- |
|
908 // |
|
909 EXPORT_C TInt CGlxUiUtility::SetTNMDaemonPSKeyvalue() |
|
910 { |
|
911 TRACER("CGlxUiUtility::SetTNMDaemonPSKeyvalue"); |
|
912 TInt ret = RProperty::Define(KTAGDPSNotification, KItemsleft, |
|
913 RProperty::EInt); |
|
914 GLX_LOG_INFO1("CGlxUiUtility::SetTNMDaemon()RProperty::Define %d", ret); |
|
915 if (ret == KErrNone) |
|
916 { |
|
917 ret = RProperty::Set(KTAGDPSNotification, KItemsleft, KErrNotReady); |
|
918 GLX_LOG_INFO1("CGlxUiUtility::SetTNMDaemon() RProperty::Set %d", ret); |
|
919 } |
|
920 return ret; |
|
921 } |
|
922 |
|
923 // ----------------------------------------------------------------------------- |
|
924 // GetKeyguardStatus |
|
925 // ----------------------------------------------------------------------------- |
|
926 // |
|
927 EXPORT_C TInt CGlxUiUtility::GetKeyguardStatus() |
|
928 { |
|
929 TRACER("CGlxUiUtility::GetKeyguardStatus"); |
|
930 TInt keyguardStatus = KErrNone; |
|
931 RProperty::Get(KPSUidAvkonDomain, KAknKeyguardStatus, keyguardStatus); |
|
932 GLX_LOG_INFO1("CGlxUiUtility::GetKeyguardStatus() keyguardStatus=%d", keyguardStatus); |
|
933 return keyguardStatus; |
|
934 } |
|
935 // End of file |