author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:18:30 +0300 | |
branch | RCL_3 |
changeset 102 | ba63c83f4716 |
parent 93 | b01126ce0bec |
permissions | -rw-r--r-- |
83 | 1 |
/* |
2 |
* Copyright (c) 2008 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: AppUi class |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include "tsappui.h" |
|
20 |
#include "tsappview.h" |
|
21 |
#include "tsapplogging.h" |
|
22 |
#include "tsdevicestate.h" |
|
23 |
#include "tsuid.hrh" |
|
24 |
#include "tscommands.hrh" |
|
25 |
#include <akntitle.h> |
|
26 |
#include <hlplch.h> |
|
27 |
#include <avkon.rsg> |
|
28 |
#include <bautils.h> |
|
29 |
#include <AknUtils.h> |
|
30 |
#include <taskswitcher.rsg> |
|
31 |
#include <pslninternalcrkeys.h> |
|
32 |
#include <oommonitorsession.h> |
|
33 |
#include <hal.h> |
|
34 |
#include <hal_data.h> |
|
35 |
#include <akntranseffect.h> |
|
36 |
#include <UikonInternalPSKeys.h> |
|
37 |
#include <apgwgnam.h> |
|
38 |
||
39 |
||
40 |
// AknCapServer UID, used for P&S category |
|
41 |
const TUid KTaskswitcherStateCategory = { 0x10207218 }; |
|
42 |
||
43 |
// Taskswitcher UI, used as P&S key |
|
44 |
const TInt KTaskswitcherStateKey = KTsAppUidValue; |
|
45 |
||
46 |
const TUid KTransitionsUid = {0x10281F90}; |
|
47 |
||
48 |
// Values for Taskswitcher launching P&S |
|
49 |
const TInt KTaskswitcherBackgroundValue = 1; |
|
50 |
const TInt KTaskswitcherForegroundValue = KTaskswitcherBackgroundValue << 1; |
|
51 |
const TInt KTaskswitcherShortAppKeyPressed = KTaskswitcherForegroundValue << 1; |
|
52 |
const TInt KTaskswitcherLongAppKeyPressed = KTaskswitcherShortAppKeyPressed << 1; |
|
53 |
||
54 |
//short/long App key values |
|
55 |
const TInt KAppKeyTypeShort = 1; |
|
56 |
const TInt KAppKeyTypeLong = 2; |
|
57 |
||
58 |
//values for checking the OOM |
|
59 |
const TInt KMemoryRequestAmountInBytes = 524288; |
|
60 |
const TInt KMinMemoryAmountInBytes = 524288; |
|
61 |
||
62 |
// time to wait before sending the task to background |
|
63 |
// (must give time to animation) |
|
64 |
const TInt KWaitBeforeGoingToBackground = 200000; |
|
65 |
||
66 |
const TUid KTsAppUid = { KTsAppUidValue }; |
|
67 |
||
68 |
const TUid KTsCameraUid = { 0x101F857a }; |
|
69 |
const TUid KTsTelephoneUid = { 0x100058b3 }; |
|
70 |
||
71 |
const TInt KTsMultimediaAppActivationDelay = 1500000; |
|
72 |
||
73 |
// ----------------------------------------------------------------------------- |
|
74 |
// CTsAppUi::ConstructL() |
|
75 |
// ConstructL is called by the application framework |
|
76 |
// ----------------------------------------------------------------------------- |
|
77 |
// |
|
78 |
void CTsAppUi::ConstructL() |
|
79 |
{ |
|
80 |
TSLOG_CONTEXT( CTsAppUi::ConstructL, TSLOG_LOCAL ); |
|
81 |
TSLOG_IN(); |
|
82 |
||
83 |
#ifdef _DEBUG |
|
84 |
// create log folder |
|
85 |
_LIT( KLogPath, "c:\\logs\\taskswitcher\\" ); |
|
86 |
RFs fs; |
|
87 |
if ( fs.Connect() == KErrNone ) |
|
88 |
{ |
|
89 |
fs.MkDirAll( KLogPath ); |
|
90 |
fs.Close(); |
|
91 |
} |
|
92 |
#endif |
|
93 |
||
94 |
// Initialise app UI with standard value. |
|
95 |
BaseConstructL( CAknAppUi::EAknEnableSkin | |
|
96 |
CAknAppUi::EAknEnableMSK | |
|
97 |
CAknAppUi::EAknSingleClickCompatible); |
|
98 |
SetFullScreenApp(EFalse); |
|
99 |
||
100 |
#ifndef _DEBUG |
|
101 |
// set as system application (in release build) so we never get closed |
|
102 |
iEikonEnv->SetSystem( ETrue ); |
|
103 |
#endif |
|
104 |
||
105 |
//Initialize effects change observation |
|
106 |
iThemeEffectsEnabledWatcher = |
|
107 |
CTsCenrepListener::NewL( KCRUidThemes, KThemesTransitionEffects, *this ); |
|
108 |
CenrepChanged( KThemesTransitionEffects, iThemeEffectsEnabledWatcher->Value() ); |
|
109 |
||
110 |
// Hide status pane |
|
111 |
StatusPane()->MakeVisible( EFalse ); |
|
112 |
||
113 |
// Change CBA if needed, default is non-touch in rss |
|
114 |
if ( AknLayoutUtils::PenEnabled() ) |
|
115 |
{ |
|
116 |
Cba()->SetCommandSetL( R_TS_CBA_TOUCH ); |
|
117 |
} |
|
118 |
Cba()->MakeVisible(EFalse); |
|
119 |
||
120 |
// Create timer |
|
121 |
iGoToBackgroundTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
122 |
iForegroundDelayTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
123 |
||
124 |
// Create commonly used instances (device state only?) |
|
125 |
iDeviceState = CTsDeviceState::NewL(); |
|
126 |
||
127 |
// Create custom window group |
|
128 |
iWg = RWindowGroup(CCoeEnv::Static()->WsSession()); |
|
129 |
iWg.Construct((TUint32)&iWg, ETrue); |
|
130 |
iWg.EnableScreenChangeEvents(); |
|
131 |
CApaWindowGroupName* rootWgName = CApaWindowGroupName::NewLC( iEikonEnv->WsSession(), iEikonEnv->RootWin().Identifier() ); |
|
132 |
rootWgName->SetWindowGroupName( iWg ); |
|
133 |
CleanupStack::PopAndDestroy( rootWgName ); |
|
134 |
||
135 |
// Create UI |
|
136 |
iAppView = CTsAppView::NewL( ApplicationRect(), *iDeviceState, iWg ); |
|
137 |
AddToStackL( iAppView ); |
|
138 |
||
139 |
//Enable effects |
|
140 |
GfxTransEffect::Enable(); |
|
141 |
GfxTransEffect::Register(iAppView,KTransitionsUid); |
|
142 |
GfxTransEffect::SetTransitionObserver(this); |
|
143 |
||
144 |
// Listen for change in the value of the ts state property. |
|
145 |
iPropListener = new ( ELeave ) CTsPropertyListener( |
|
146 |
KTaskswitcherStateCategory, KTaskswitcherStateKey, *this ); |
|
147 |
||
148 |
// Listen for layout changes |
|
149 |
iLayoutListener = new ( ELeave ) CTsPropertyListener( |
|
150 |
KPSUidUikon, KUikLayoutState, *this ); |
|
151 |
||
152 |
// Initialise the application task object with the window group id of |
|
153 |
// our application ( so that it represent our app ) |
|
154 |
//iApplicationTask.SetWgId( iCoeEnv->RootWin().Identifier() ); |
|
155 |
iApplicationTask.SetWgId( iWg.Identifier() ); |
|
156 |
||
157 |
// And finally, go to background. |
|
158 |
MoveAppToBackground( ENoneTransition ); |
|
159 |
||
160 |
iEikonEnv->RootWin().SetOrdinalPosition(-1, ECoeWinPriorityNeverAtFront); |
|
161 |
iEikonEnv->RootWin().EnableReceiptOfFocus(EFalse); |
|
162 |
||
163 |
RWindowGroup& windowGroup = CCoeEnv::Static()->RootWin(); |
|
164 |
windowGroup.EnableGroupListChangeEvents(); |
|
165 |
||
166 |
iIsPopUpShown = EFalse; |
|
167 |
iUiStarted = EFalse; |
|
168 |
iDisableAppKeyHandling = EFalse; |
|
169 |
||
170 |
iForegroundDelayed = EFalse; |
|
171 |
iDelayedForegroundInProgress = EFalse; |
|
172 |
||
173 |
TSLOG_OUT(); |
|
174 |
} |
|
175 |
||
176 |
// ----------------------------------------------------------------------------- |
|
177 |
// CTsAppUi::CTsAppUi() |
|
178 |
// Perform the first phase of two phase construction |
|
179 |
// ----------------------------------------------------------------------------- |
|
180 |
// |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
181 |
CTsAppUi::CTsAppUi(): iForeground( ETrue ), |
83 | 182 |
iApplicationTask( iCoeEnv->WsSession() ) |
183 |
{ |
|
184 |
// no implementation required |
|
185 |
} |
|
186 |
||
187 |
// ----------------------------------------------------------------------------- |
|
188 |
// CTsAppUi::~CTsAppUi() |
|
189 |
// Destructor |
|
190 |
// ----------------------------------------------------------------------------- |
|
191 |
// |
|
192 |
CTsAppUi::~CTsAppUi() |
|
193 |
{ |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
194 |
if( GfxTransEffect::IsRegistered( iAppView ) ) |
83 | 195 |
{ |
196 |
GfxTransEffect::Deregister(iAppView); |
|
197 |
||
198 |
} |
|
199 |
GfxTransEffect::SetTransitionObserver(0); |
|
200 |
||
201 |
delete iGoToBackgroundTimer; |
|
202 |
delete iForegroundDelayTimer; |
|
203 |
delete iPropListener; |
|
204 |
delete iLayoutListener; |
|
205 |
||
206 |
// destroy UI first |
|
207 |
if ( iAppView ) |
|
208 |
{ |
|
209 |
RemoveFromStack( iAppView ); |
|
210 |
delete iAppView; |
|
211 |
} |
|
212 |
||
213 |
delete iDeviceState; |
|
214 |
delete iThemeEffectsEnabledWatcher; |
|
215 |
||
216 |
iWg.Close(); |
|
217 |
} |
|
218 |
||
219 |
// ----------------------------------------------------------------------------- |
|
220 |
// CTsAppView::EffectsEnabled |
|
221 |
// ----------------------------------------------------------------------------- |
|
222 |
// |
|
223 |
TBool CTsAppUi::EffectsEnabled() const |
|
224 |
{ |
|
225 |
return iEffectsEnabled; |
|
226 |
} |
|
227 |
||
228 |
// ----------------------------------------------------------------------------- |
|
229 |
// CTsAppUi::StartTransion |
|
230 |
// ----------------------------------------------------------------------------- |
|
231 |
// |
|
232 |
void CTsAppUi::StartTransion( TUint aTransitionType, TUid aNextAppUid, TInt aWgId ) |
|
233 |
{ |
|
234 |
if( !EffectsEnabled() ) |
|
235 |
{ |
|
236 |
return; |
|
237 |
} |
|
238 |
switch(aTransitionType) |
|
239 |
{ |
|
240 |
case EForegroundTransition: |
|
241 |
StartTransition( aTransitionType, |
|
242 |
ETrue, |
|
243 |
EFalse, |
|
244 |
CAknTransitionUtils::EForceVisible); |
|
245 |
break; |
|
246 |
case EBackgroundTransition: |
|
247 |
StartTransition( aTransitionType, |
|
248 |
EFalse, |
|
249 |
EFalse, |
|
250 |
CAknTransitionUtils::EForceInvisible ); |
|
251 |
break; |
|
252 |
case EActivationTransition: |
|
253 |
StartAppActivateTransition( aNextAppUid, aWgId ); |
|
254 |
break; |
|
255 |
} |
|
256 |
} |
|
257 |
||
258 |
// ----------------------------------------------------------------------------- |
|
259 |
// CTsAppUi::StartTransition |
|
260 |
// ----------------------------------------------------------------------------- |
|
261 |
// |
|
262 |
void CTsAppUi::StartTransition( TUint aTranstionId, |
|
263 |
TBool aVisibility, |
|
264 |
TBool /*aLayers*/, |
|
265 |
TUint aSubCom ) |
|
266 |
{ |
|
267 |
const TDesC8* ptr = reinterpret_cast<const TDesC8*>(iAppView); |
|
268 |
GfxTransEffect::Abort(iAppView); |
|
269 |
GfxTransEffect::Begin( iAppView, aTranstionId ); |
|
270 |
GfxTransEffect::SetDemarcation( iAppView, iAppView->Rect() ); |
|
271 |
GfxTransEffect::NotifyExternalState( ECaptureComponentsBegin, ptr ); |
|
272 |
iAppView->MakeVisible( aVisibility ); |
|
273 |
CAknTransitionUtils::MakeVisibleSubComponents( |
|
274 |
iAppView, |
|
275 |
static_cast<CAknTransitionUtils::TMakeVisibleSubComponentsInfo>(aSubCom) ); |
|
276 |
GfxTransEffect::NotifyExternalState( ECaptureComponentsEnd, ptr ); |
|
277 |
GfxTransEffect::End( iAppView ); |
|
278 |
} |
|
279 |
||
280 |
// ----------------------------------------------------------------------------- |
|
281 |
// CTsAppUi::StartAppActivateTransition |
|
282 |
// ----------------------------------------------------------------------------- |
|
283 |
// |
|
284 |
void CTsAppUi::StartAppActivateTransition( TUid aNextAppUid, TInt aWgId ) |
|
285 |
{ |
|
286 |
// Check what type of transition will be trigerred |
|
287 |
if ( aWgId == iUnderAppWgId ) |
|
288 |
{ |
|
289 |
// App under task switcher was launched |
|
290 |
StartTransition( EBackgroundTransition, |
|
291 |
EFalse, |
|
292 |
ETrue, |
|
293 |
CAknTransitionUtils::EForceInvisible ); |
|
294 |
} |
|
295 |
else |
|
296 |
{ |
|
297 |
// App start animation |
|
298 |
const TDesC8* ptr = reinterpret_cast<const TDesC8*>(iAppView); |
|
299 |
GfxTransEffect::Abort(iAppView); |
|
300 |
TInt groupId = GfxTransEffect::BeginGroup(); |
|
301 |
GfxTransEffect::BeginFullScreen( |
|
302 |
EActivationAppShowTransition, ApplicationRect(), |
|
303 |
AknTransEffect::EParameterType, |
|
304 |
AknTransEffect::GfxTransParam( aNextAppUid , KTsAppUid ) ); |
|
305 |
GfxTransEffect::Begin( iAppView, EBackgroundTransition ); |
|
306 |
GfxTransEffect::SetDemarcation( iAppView, iAppView->Rect() ); |
|
307 |
GfxTransEffect::NotifyExternalState( ECaptureComponentsBegin, ptr ); |
|
308 |
iAppView->MakeVisible( EFalse ); |
|
309 |
CAknTransitionUtils::MakeVisibleSubComponents( |
|
310 |
iAppView, |
|
311 |
static_cast<CAknTransitionUtils::TMakeVisibleSubComponentsInfo>(CAknTransitionUtils::EForceInvisible) ); |
|
312 |
GfxTransEffect::NotifyExternalState( ECaptureComponentsEnd, ptr ); |
|
313 |
GfxTransEffect::End( iAppView ); |
|
314 |
GfxTransEffect::EndFullScreen(); |
|
315 |
GfxTransEffect::EndGroup(groupId); |
|
316 |
} |
|
317 |
} |
|
318 |
||
319 |
// ----------------------------------------------------------------------------- |
|
320 |
// CTsAppUi::TransitionFinished |
|
321 |
// ----------------------------------------------------------------------------- |
|
322 |
// |
|
323 |
void CTsAppUi::TransitionFinished(const CCoeControl* /*aControl*/, |
|
324 |
TUint /*aAction*/) |
|
325 |
{ |
|
326 |
} |
|
327 |
||
328 |
// ----------------------------------------------------------------------------- |
|
329 |
// CTsAppUi::HandleCommandL() |
|
330 |
// Takes care of command handling. |
|
331 |
// ----------------------------------------------------------------------------- |
|
332 |
// |
|
333 |
void CTsAppUi::HandleCommandL( TInt aCommand ) |
|
334 |
{ |
|
335 |
switch ( aCommand ) |
|
336 |
{ |
|
337 |
case EAknCmdExit: |
|
338 |
case EEikCmdExit: |
|
339 |
Exit(); |
|
340 |
break; |
|
341 |
||
342 |
case EAknSoftkeyExit: |
|
343 |
case EAknSoftkeyBack: |
|
344 |
// RSK => just hide |
|
345 |
MoveAppToBackground( EBackgroundTransition ); |
|
346 |
break; |
|
347 |
||
348 |
case ETsCmdHelp: |
|
349 |
{ |
|
350 |
MoveAppToBackground( EBackgroundTransition ); |
|
351 |
CArrayFix<TCoeHelpContext>* buf = CCoeAppUi::AppHelpContextL(); |
|
352 |
HlpLauncher::LaunchHelpApplicationL( iCoeEnv->WsSession(), buf ); |
|
353 |
} |
|
354 |
break; |
|
355 |
||
356 |
case EAknSoftkeySelect: |
|
357 |
{ |
|
358 |
// select is generated by lsk and msk (see the resource file) |
|
359 |
// Simulate a middle key press to the controls. |
|
360 |
// Note that SimulateKeyEventL must not be used here or else it |
|
361 |
// will end up in an infinite loop. |
|
362 |
TKeyEvent keyEvent; |
|
363 |
keyEvent.iCode = EKeyOK; |
|
364 |
keyEvent.iScanCode = EStdKeyDevice3; |
|
365 |
keyEvent.iModifiers = keyEvent.iRepeats = 0; |
|
366 |
iAppView->OfferKeyEventL( keyEvent, EEventKeyDown ); |
|
367 |
iAppView->OfferKeyEventL( keyEvent, EEventKey ); |
|
368 |
iAppView->OfferKeyEventL( keyEvent, EEventKeyUp ); |
|
369 |
} |
|
370 |
break; |
|
371 |
||
372 |
default: |
|
373 |
break; |
|
374 |
} |
|
375 |
} |
|
376 |
||
377 |
// ----------------------------------------------------------------------------- |
|
378 |
// CTsAppUi::HandleForegroundEventL |
|
379 |
// Called by the system when the app is moved to foreground or background. |
|
380 |
// ----------------------------------------------------------------------------- |
|
381 |
// |
|
382 |
void CTsAppUi::HandleForegroundEventL( TBool aForeground ) |
|
383 |
{ |
|
384 |
TSLOG_CONTEXT( HandleForegroundEventL, TSLOG_LOCAL ); |
|
385 |
TSLOG1_IN( "aForeground = %d", aForeground ); |
|
386 |
||
387 |
// These calls may be redundant but the functions will do nothing if the |
|
388 |
// state has already been changed. |
|
389 |
// Both this function and the 'manual' MoveAppTo functions must fire the events |
|
390 |
// because in some cases only one of them will run (e.g. when bringing to foreground |
|
391 |
// not with the hw key but by other means etc.) |
|
392 |
iDisableAppKeyHandling = EFalse; |
|
393 |
if ( !iUiStarted ) |
|
394 |
{ |
|
395 |
// Ignore foreground events if UI is starting |
|
396 |
return; |
|
397 |
} |
|
398 |
if ( aForeground ) |
|
399 |
{ |
|
400 |
HandleSwitchToForegroundEvent(); |
|
401 |
} |
|
402 |
// exclude cases with dialogs like power menu, memory card |
|
403 |
else |
|
404 |
{ |
|
405 |
if( !IsFaded() ) |
|
406 |
{ |
|
407 |
HandleSwitchToBackgroundEvent(); |
|
408 |
} |
|
409 |
else |
|
410 |
{ |
|
411 |
iDisableAppKeyHandling = ETrue; |
|
412 |
} |
|
413 |
} |
|
414 |
||
415 |
// Call Base class method |
|
416 |
CAknAppUi::HandleForegroundEventL( aForeground ); |
|
417 |
||
418 |
TSLOG_OUT(); |
|
419 |
} |
|
420 |
||
421 |
// ----------------------------------------------------------------------------- |
|
422 |
// CTsAppUi::PropertyChanged |
|
423 |
// ----------------------------------------------------------------------------- |
|
424 |
// |
|
425 |
void CTsAppUi::PropertyChanged( TUid aCategory, TUint aKey ) |
|
426 |
{ |
|
427 |
TSLOG_CONTEXT( PropertyChanged, TSLOG_LOCAL ); |
|
428 |
TSLOG_IN(); |
|
429 |
||
430 |
TInt value( 0 ); |
|
431 |
||
432 |
if ( aCategory == KTaskswitcherStateCategory ) |
|
433 |
{ |
|
434 |
if ( RProperty::Get( aCategory, aKey, value ) == KErrNone ) |
|
435 |
{ |
|
436 |
if ( iForeground && (value & KTaskswitcherBackgroundValue) ) |
|
437 |
{ |
|
438 |
MoveAppToBackground( EBackgroundTransition ); |
|
439 |
} |
|
440 |
else if ( !iForeground && (value & KTaskswitcherForegroundValue) ) |
|
441 |
{ |
|
442 |
MoveAppToForeground( EForegroundTransition ); |
|
443 |
} |
|
444 |
else if( value & KTaskswitcherLongAppKeyPressed ) |
|
445 |
{ |
|
446 |
if(!iForeground) |
|
447 |
{ |
|
448 |
MoveAppToBackground( EBackgroundTransition ); |
|
449 |
} |
|
450 |
else if( !iDisableAppKeyHandling ) |
|
451 |
{ |
|
452 |
iAppView->HandleAppKey(KAppKeyTypeLong); |
|
453 |
} |
|
454 |
} |
|
455 |
else if( value & KTaskswitcherShortAppKeyPressed && !iDisableAppKeyHandling ) |
|
456 |
{ |
|
457 |
iAppView->HandleAppKey(KAppKeyTypeShort); |
|
458 |
} |
|
459 |
} |
|
460 |
} |
|
461 |
else if ( aCategory == KPSUidUikon && iIsPopUpShown ) |
|
462 |
{ |
|
463 |
TRAP_IGNORE( |
|
464 |
DisablePopUpL(); |
|
465 |
HandleResourceChangeL(KEikDynamicLayoutVariantSwitch) ); |
|
466 |
} |
|
467 |
||
468 |
TSLOG_OUT(); |
|
469 |
} |
|
470 |
||
471 |
// ----------------------------------------------------------------------------- |
|
472 |
// CTsAppUi::HandleResourceChangeL |
|
473 |
// ----------------------------------------------------------------------------- |
|
474 |
// |
|
475 |
void CTsAppUi::HandleResourceChangeL( TInt aType ) |
|
476 |
{ |
|
477 |
TSLOG_CONTEXT( CTsAppUi::HandleResourceChangeL, TSLOG_LOCAL ); |
|
478 |
TSLOG_IN(); |
|
479 |
// Must call base class implementation first, |
|
480 |
// sizes from LayoutMetricsRect etc. will only be correct after this. |
|
481 |
CAknAppUi::HandleResourceChangeL( aType ); |
|
482 |
if( aType == KEikDynamicLayoutVariantSwitch && iAppView && !LayoutChangeAllowed() ) |
|
483 |
{ |
|
484 |
// Keep displayed orientation |
|
485 |
return; |
|
486 |
} |
|
487 |
// forward event |
|
488 |
iDeviceState->HandleResourceChange( aType ); |
|
489 |
if ( iAppView ) |
|
490 |
{ |
|
491 |
iAppView->HandleResourceChange( aType ); |
|
492 |
} |
|
493 |
TSLOG_OUT(); |
|
494 |
} |
|
495 |
||
496 |
// ----------------------------------------------------------------------------- |
|
497 |
// CTsAppUi::MoveAppToBackground() |
|
498 |
// ----------------------------------------------------------------------------- |
|
499 |
// |
|
500 |
void CTsAppUi::MoveAppToBackground( TUint aTransitionType, TUid aAppUid, TInt aWgId ) |
|
501 |
{ |
|
502 |
TSLOG_CONTEXT( MoveAppToBackground, TSLOG_LOCAL ); |
|
503 |
TSLOG_IN(); |
|
504 |
||
505 |
if ( ENoneTransition == aTransitionType || !EffectsEnabled() ) |
|
506 |
{ |
|
507 |
GoToBackgroundTimerCallback( this ); |
|
508 |
} |
|
509 |
else |
|
510 |
{ |
|
511 |
StartTransion(aTransitionType, aAppUid, aWgId); |
|
512 |
iGoToBackgroundTimer->Cancel(); |
|
513 |
iGoToBackgroundTimer->Start( |
|
514 |
KWaitBeforeGoingToBackground, |
|
515 |
0, |
|
516 |
TCallBack( GoToBackgroundTimerCallback, this ) ); |
|
517 |
} |
|
518 |
TSLOG_OUT(); |
|
519 |
} |
|
520 |
||
521 |
// ----------------------------------------------------------------------------- |
|
522 |
// CTsAppUi::CenrepChanged |
|
523 |
// ----------------------------------------------------------------------------- |
|
524 |
// |
|
525 |
void CTsAppUi::CenrepChanged( TUint32 /*aKey*/, TInt aNewValue ) |
|
526 |
{ |
|
527 |
iEffectsEnabled = !(aNewValue & AknTransEffect::EFullScreenTransitionsOff); |
|
528 |
} |
|
529 |
||
530 |
// ----------------------------------------------------------------------------- |
|
531 |
// CTsAppUi::GoToBackgroundTimerCallback |
|
532 |
// ----------------------------------------------------------------------------- |
|
533 |
// |
|
534 |
TInt CTsAppUi::GoToBackgroundTimerCallback( TAny* aParam ) |
|
535 |
{ |
|
536 |
CTsAppUi* self = static_cast<CTsAppUi*>( aParam ); |
|
537 |
if ( self->iGoToBackgroundTimer ) |
|
538 |
{ |
|
539 |
self->iGoToBackgroundTimer->Cancel(); |
|
540 |
} |
|
541 |
||
542 |
// Request window server to bring our application |
|
543 |
// to background |
|
544 |
self->iApplicationTask.SendToBackground(); |
|
545 |
||
546 |
// Notify |
|
547 |
self->HandleSwitchToBackgroundEvent(); |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
548 |
|
83 | 549 |
return 0; |
550 |
} |
|
551 |
||
552 |
// ----------------------------------------------------------------------------- |
|
553 |
// CTsAppUi::DelayedForegroundCallback |
|
554 |
// ----------------------------------------------------------------------------- |
|
555 |
// |
|
556 |
TInt CTsAppUi::DelayedForegroundCallback( TAny* aParam ) |
|
557 |
{ |
|
558 |
CTsAppUi* self = static_cast<CTsAppUi*>( aParam ); |
|
559 |
self->iDelayedForegroundInProgress = ETrue; |
|
560 |
||
561 |
if ( self->iForegroundDelayTimer ) |
|
562 |
{ |
|
563 |
self->iForegroundDelayTimer->Cancel(); |
|
564 |
} |
|
565 |
self->iForegroundDelayed = EFalse; |
|
566 |
self->HandleSwitchToForegroundEvent(); |
|
567 |
||
568 |
self->iDelayedForegroundInProgress = EFalse; |
|
569 |
||
570 |
return 0; |
|
571 |
} |
|
572 |
||
573 |
// ----------------------------------------------------------------------------- |
|
574 |
// CTsAppUi::MoveAppToForeground() |
|
575 |
// ----------------------------------------------------------------------------- |
|
576 |
// |
|
577 |
void CTsAppUi::MoveAppToForeground( TUint /*aTransitionType*/ ) |
|
578 |
{ |
|
579 |
TSLOG_CONTEXT( MoveAppToForeground, TSLOG_LOCAL ); |
|
580 |
TSLOG_IN(); |
|
581 |
||
582 |
iUiStarted = ETrue; |
|
583 |
||
584 |
// Request window server to bring our application |
|
585 |
// to foreground |
|
586 |
iApplicationTask.BringToForeground(); |
|
587 |
||
588 |
// Notify |
|
589 |
TBool delayForeground(EFalse); |
|
590 |
TRAP_IGNORE( delayForeground = IsUnderlyingAppMultimediaL() ); |
|
591 |
if ( delayForeground ) |
|
592 |
{ |
|
593 |
iForegroundDelayed = ETrue; |
|
594 |
iForegroundDelayTimer->Cancel(); |
|
595 |
iForegroundDelayTimer->Start( |
|
596 |
KTsMultimediaAppActivationDelay, |
|
597 |
0, |
|
598 |
TCallBack( DelayedForegroundCallback, this ) ); |
|
599 |
} |
|
600 |
else |
|
601 |
{ |
|
602 |
HandleSwitchToForegroundEvent(); |
|
603 |
} |
|
604 |
||
605 |
TSLOG_OUT(); |
|
606 |
} |
|
607 |
||
608 |
// ----------------------------------------------------------------------------- |
|
609 |
// CTsAppUi::HandleSwitchToBackgroundEvent |
|
610 |
// ----------------------------------------------------------------------------- |
|
611 |
// |
|
612 |
void CTsAppUi::HandleSwitchToBackgroundEvent() |
|
613 |
{ |
|
614 |
TSLOG_CONTEXT( HandleSwitchToBackgroundEvent, TSLOG_LOCAL ); |
|
615 |
TSLOG_IN(); |
|
616 |
||
617 |
// must not do anything if iForeground is already up-to-date |
|
618 |
||
619 |
||
620 |
if( iForeground ) |
|
621 |
{ |
|
622 |
iForeground = EFalse; |
|
623 |
SetTaskswitcherStateProperty( KTaskswitcherBackgroundValue ); |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
624 |
|
83 | 625 |
// notify view |
626 |
iAppView->HandleSwitchToBackgroundEvent(); |
|
627 |
||
628 |
iWg.SetOrdinalPosition(-1, ECoeWinPriorityNormal); |
|
629 |
||
630 |
iForegroundDelayed = EFalse; |
|
631 |
} |
|
632 |
||
633 |
TSLOG_OUT(); |
|
634 |
} |
|
635 |
||
636 |
// ----------------------------------------------------------------------------- |
|
637 |
// CTsAppUi::HandleSwitchToForegroundEvent |
|
638 |
// ----------------------------------------------------------------------------- |
|
639 |
// |
|
640 |
void CTsAppUi::HandleSwitchToForegroundEvent() |
|
641 |
{ |
|
642 |
TSLOG_CONTEXT( HandleSwitchToForegroundEvent, TSLOG_LOCAL ); |
|
643 |
TSLOG_IN(); |
|
644 |
||
645 |
// must not do anything if iForeground is already up-to-date |
|
646 |
if ( !iForeground && !iForegroundDelayed ) |
|
647 |
{ |
|
648 |
TInt freeRamMemory; |
|
649 |
HAL::Get( HALData::EMemoryRAMFree, freeRamMemory ); |
|
650 |
if ( freeRamMemory <= KMinMemoryAmountInBytes ) |
|
651 |
{ |
|
652 |
FreeMemoryRequest(); |
|
653 |
} |
|
654 |
||
655 |
iForeground = ETrue; |
|
656 |
SetTaskswitcherStateProperty( KTaskswitcherForegroundValue ); |
|
657 |
||
658 |
// notify view |
|
659 |
iAppView->HandleSwitchToForegroundEvent(); |
|
660 |
||
661 |
iWg.SetOrdinalPosition(iWg.OrdinalPosition(), ECoeWinPriorityAlwaysAtFront); |
|
662 |
} |
|
663 |
||
664 |
TSLOG_OUT(); |
|
665 |
} |
|
666 |
||
667 |
// ----------------------------------------------------------------------------- |
|
668 |
// CTsAppUi::SetTaskswitcherShowProperty |
|
669 |
// ----------------------------------------------------------------------------- |
|
670 |
// |
|
671 |
void CTsAppUi::SetTaskswitcherStateProperty( TInt aValue ) |
|
672 |
{ |
|
673 |
TSLOG_CONTEXT( CTsAppUi::SetTaskswitcherShowProperty, TSLOG_LOCAL ); |
|
674 |
TSLOG_IN(); |
|
675 |
||
676 |
if ( RProperty::Set( |
|
677 |
KTaskswitcherStateCategory, KTaskswitcherStateKey, aValue ) != KErrNone ) |
|
678 |
{ |
|
679 |
TInt error = RProperty::Define( |
|
680 |
KTaskswitcherStateCategory, KTaskswitcherStateKey, RProperty::EInt ); |
|
681 |
if ( error != KErrNone ) |
|
682 |
{ |
|
683 |
TSLOG1( TSLOG_INFO, "RProperty::Define Error: %d", error ); |
|
684 |
} |
|
685 |
||
686 |
error = RProperty::Set( KTaskswitcherStateCategory, KTaskswitcherStateKey, aValue ); |
|
687 |
if ( error != KErrNone ) |
|
688 |
{ |
|
689 |
TSLOG1( TSLOG_INFO, "RProperty::Set Error: %d", error ); |
|
690 |
} |
|
691 |
} |
|
692 |
||
693 |
TSLOG_OUT(); |
|
694 |
} |
|
695 |
||
696 |
// ----------------------------------------------------------------------------- |
|
697 |
// CTsAppUi::FreeMemoryRequest |
|
698 |
// ----------------------------------------------------------------------------- |
|
699 |
// |
|
700 |
void CTsAppUi::FreeMemoryRequest() |
|
701 |
{ |
|
702 |
TSLOG_CONTEXT( CTsAppUi::FreeMemoryRequest, TSLOG_LOCAL ); |
|
703 |
TSLOG_IN(); |
|
704 |
ROomMonitorSession oomMs; |
|
705 |
TInt error = oomMs.Connect(); |
|
706 |
if ( error != KErrNone) |
|
707 |
{ |
|
708 |
TSLOG1( TSLOG_INFO, "Could not connect to ROomMonitorSession, %d", error ); |
|
709 |
} |
|
710 |
else |
|
711 |
{ |
|
712 |
oomMs.RequestFreeMemory( KMemoryRequestAmountInBytes ); |
|
713 |
oomMs.Close(); |
|
714 |
} |
|
715 |
TSLOG_OUT(); |
|
716 |
} |
|
717 |
||
718 |
||
719 |
// ----------------------------------------------------------------------------- |
|
720 |
// CTsAppUi::RequestPopUpL |
|
721 |
// ----------------------------------------------------------------------------- |
|
722 |
// |
|
723 |
void CTsAppUi::RequestPopUpL() |
|
724 |
{ |
|
725 |
TSLOG_CONTEXT( CTsAppUi::RequestPopUpL, TSLOG_LOCAL ); |
|
726 |
TSLOG_IN(); |
|
727 |
if(!iIsPopUpShown) |
|
728 |
{ |
|
729 |
iIsPopUpShown = ETrue; |
|
730 |
TSizeMode mode = iEikonEnv->ScreenDevice()->GetCurrentScreenModeAttributes(); |
|
731 |
TInt isLandscape = mode.iScreenSize.iWidth > mode.iScreenSize.iHeight; |
|
732 |
SetFullScreenApp(ETrue); |
|
733 |
if(isLandscape) |
|
734 |
{ |
|
735 |
SetOrientationL(EAppUiOrientationLandscape); |
|
736 |
} |
|
737 |
else |
|
738 |
{ |
|
739 |
SetOrientationL(EAppUiOrientationPortrait); |
|
740 |
} |
|
741 |
SetFullScreenApp(EFalse); |
|
742 |
iEikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront); |
|
743 |
} |
|
744 |
TSLOG_OUT(); |
|
745 |
} |
|
746 |
||
747 |
||
748 |
// ----------------------------------------------------------------------------- |
|
749 |
// CTsAppUi::DisablePopUpL |
|
750 |
// ----------------------------------------------------------------------------- |
|
751 |
// |
|
752 |
void CTsAppUi::DisablePopUpL() |
|
753 |
{ |
|
754 |
TSLOG_CONTEXT( CTsAppUi::DisablePopUpL, TSLOG_LOCAL ); |
|
755 |
TSLOG_IN(); |
|
756 |
if(iIsPopUpShown) |
|
757 |
{ |
|
758 |
iIsPopUpShown = EFalse; |
|
759 |
iEikonEnv->RootWin().SetOrdinalPosition(-1, ECoeWinPriorityNeverAtFront); |
|
760 |
SetOrientationL(EAppUiOrientationAutomatic); |
|
761 |
SetFullScreenApp(EFalse); |
|
762 |
} |
|
763 |
TSLOG_OUT(); |
|
764 |
} |
|
765 |
||
766 |
||
767 |
// ----------------------------------------------------------------------------- |
|
768 |
// CTsAppUi::LayoutCanBeChanged |
|
769 |
// ----------------------------------------------------------------------------- |
|
770 |
// |
|
771 |
TBool CTsAppUi::LayoutChangeAllowed() |
|
772 |
{ |
|
773 |
// Check if layout switch is necessary |
|
774 |
TSizeMode mode = iEikonEnv->ScreenDevice()->GetCurrentScreenModeAttributes(); |
|
775 |
TBool isLandscape = mode.iScreenSize.iWidth > mode.iScreenSize.iHeight; |
|
776 |
TRect appRect = ApplicationRect(); |
|
777 |
TBool isAppLandscape = appRect.Width() > appRect.Height(); |
|
778 |
TBool retVal; |
|
779 |
if(isLandscape != isAppLandscape) |
|
780 |
{ |
|
781 |
retVal = EFalse; |
|
782 |
} |
|
783 |
else |
|
784 |
{ |
|
785 |
retVal = ETrue; |
|
786 |
} |
|
787 |
return retVal; |
|
788 |
} |
|
789 |
||
790 |
||
791 |
// ----------------------------------------------------------------------------- |
|
792 |
// CTsAppUi::HandleWsEventL |
|
793 |
// ----------------------------------------------------------------------------- |
|
794 |
// |
|
795 |
void CTsAppUi::HandleWsEventL(const TWsEvent& aEvent, |
|
796 |
CCoeControl* aDestination) |
|
797 |
{ |
|
798 |
CAknAppUi::HandleWsEventL(aEvent, aDestination); |
|
799 |
TInt eventType = aEvent.Type(); |
|
800 |
if ( eventType == EEventWindowGroupListChanged ) |
|
801 |
{ |
|
802 |
TInt wgId = WgIdOfUnderlyingAppL(EFalse); |
|
803 |
if ( iForeground && |
|
804 |
wgId != iUnderAppWgId && |
|
805 |
!iAppView->AppCloseInProgress(iUnderAppWgId) && |
|
806 |
!iAppView->WgOnTaskList(wgId) ) |
|
807 |
{ |
|
808 |
MoveAppToBackground( ENoneTransition ); |
|
809 |
} |
|
810 |
if ( WgIdOfUnderlyingAppL(ETrue) != iUnderAppWgId ) |
|
811 |
{ |
|
812 |
HandleResourceChangeL(KEikDynamicLayoutVariantSwitch); |
|
813 |
} |
|
814 |
iUnderAppWgId = wgId; |
|
815 |
} |
|
816 |
} |
|
817 |
||
818 |
||
819 |
// ----------------------------------------------------------------------------- |
|
820 |
// CTsAppUi::WgIdOfUnderlyingApp |
|
821 |
// ----------------------------------------------------------------------------- |
|
822 |
// |
|
823 |
TInt CTsAppUi::WgIdOfUnderlyingAppL( TBool aIgnoreParentChild ) |
|
824 |
{ |
|
825 |
TInt retVal(0); |
|
826 |
TInt underlyingWg = CheckForUnderlyingHiddenAppsL(); |
|
827 |
if ( !underlyingWg ) |
|
828 |
{ |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
829 |
TApaTaskList taskList( iEikonEnv->WsSession() ); |
83 | 830 |
underlyingWg = taskList.FindByPos(0).WgId(); |
831 |
} |
|
832 |
||
833 |
if ( aIgnoreParentChild ) |
|
834 |
{ |
|
835 |
retVal = underlyingWg; |
|
836 |
} |
|
837 |
else |
|
838 |
{ |
|
839 |
TInt parentWg = GetTopParentWg( underlyingWg ); |
|
840 |
retVal = parentWg ? parentWg : underlyingWg; |
|
841 |
} |
|
842 |
return retVal; |
|
843 |
} |
|
844 |
||
845 |
// ----------------------------------------------------------------------------- |
|
846 |
// CTsAppUi::GetTopParentWg |
|
847 |
// ----------------------------------------------------------------------------- |
|
848 |
// |
|
849 |
TInt CTsAppUi::GetTopParentWg( TInt aChildWg ) |
|
850 |
{ |
|
851 |
TInt parentWg = GetParentWg( aChildWg ); |
|
852 |
if( parentWg ) |
|
853 |
{ |
|
854 |
TInt topParentWg = GetTopParentWg( parentWg ); |
|
855 |
if( topParentWg ) |
|
856 |
{ |
|
857 |
parentWg = topParentWg; |
|
858 |
} |
|
859 |
} |
|
860 |
return parentWg; |
|
861 |
} |
|
862 |
||
863 |
// ----------------------------------------------------------------------------- |
|
864 |
// CTsAppUi::GetParentWg |
|
865 |
// ----------------------------------------------------------------------------- |
|
866 |
// |
|
867 |
TInt CTsAppUi::GetParentWg( TInt aChildWg ) |
|
868 |
{ |
|
869 |
TInt retVal(0); |
|
870 |
RArray<RWsSession::TWindowGroupChainInfo> allWgIds; |
|
871 |
// Ask for window group list from RWsSession |
|
872 |
TInt error = iEikonEnv->WsSession().WindowGroupList( 0, &allWgIds ); |
|
873 |
if ( !error ) |
|
874 |
{ |
|
875 |
TInt count( allWgIds.Count() ); |
|
876 |
for ( TInt i( 0 ); i < count; i++ ) |
|
877 |
{ |
|
878 |
RWsSession::TWindowGroupChainInfo info = allWgIds[i]; |
|
879 |
if ( info.iId == aChildWg && info.iParentId > 0) |
|
880 |
{ |
|
881 |
retVal = info.iParentId; |
|
882 |
break; |
|
883 |
} |
|
884 |
} |
|
885 |
} |
|
886 |
allWgIds.Close(); |
|
887 |
return retVal; |
|
888 |
} |
|
889 |
||
890 |
// ----------------------------------------------------------------------------- |
|
891 |
// CTsAppUi::IsForeground |
|
892 |
// ----------------------------------------------------------------------------- |
|
893 |
// |
|
894 |
TBool CTsAppUi::IsForeground() const |
|
895 |
{ |
|
896 |
return iForeground; |
|
897 |
} |
|
898 |
||
899 |
// ----------------------------------------------------------------------------- |
|
900 |
// CTsAppUi::CheckForUnderlyingCameraL |
|
901 |
// ----------------------------------------------------------------------------- |
|
902 |
// |
|
903 |
TInt CTsAppUi::CheckForUnderlyingHiddenAppsL() |
|
904 |
{ |
|
905 |
TInt wgId(0); |
|
906 |
RArray<RWsSession::TWindowGroupChainInfo> allWgIds; |
|
907 |
CleanupClosePushL(allWgIds); |
|
908 |
User::LeaveIfError(iEikonEnv->WsSession().WindowGroupList(0, &allWgIds)); |
|
909 |
TInt underlyingWg(allWgIds[0].iId); |
|
910 |
CleanupStack::PopAndDestroy(&allWgIds); |
|
911 |
||
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
912 |
CApaWindowGroupName* windowName = |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
913 |
CApaWindowGroupName::NewLC( iEikonEnv->WsSession(), underlyingWg ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
914 |
TUid appUid = windowName->AppUid(); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
915 |
CleanupStack::PopAndDestroy( windowName ); |
83 | 916 |
if( appUid == KTsCameraUid || |
917 |
appUid == KTsTelephoneUid ) |
|
918 |
{ |
|
919 |
wgId = underlyingWg; |
|
920 |
} |
|
921 |
return wgId; |
|
922 |
} |
|
923 |
||
924 |
// ----------------------------------------------------------------------------- |
|
925 |
// CTsAppUi::IsUnderlyingAppMultimediaL |
|
926 |
// ----------------------------------------------------------------------------- |
|
927 |
// |
|
928 |
TBool CTsAppUi::IsUnderlyingAppMultimediaL() |
|
929 |
{ |
|
930 |
TBool retVal(EFalse); |
|
931 |
||
932 |
TApaTaskList taskList( iEikonEnv->WsSession() ); |
|
933 |
TInt underlyingWg = taskList.FindByPos(0).WgId(); |
|
934 |
||
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
935 |
CApaWindowGroupName* windowName = |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
936 |
CApaWindowGroupName::NewLC( iEikonEnv->WsSession(), underlyingWg ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
937 |
TUid appUid = windowName->AppUid(); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
938 |
CleanupStack::PopAndDestroy( windowName ); |
83 | 939 |
if ( appUid == KTsCameraUid ) |
940 |
{ |
|
941 |
retVal = ETrue; |
|
942 |
} |
|
943 |
||
944 |
return retVal; |
|
945 |
} |
|
946 |
||
947 |
||
948 |
// ----------------------------------------------------------------------------- |
|
949 |
// CTsAppUi::DelayedForegroundLaunched |
|
950 |
// ----------------------------------------------------------------------------- |
|
951 |
// |
|
952 |
TBool CTsAppUi::DelayedForegroundLaunched() |
|
953 |
{ |
|
954 |
return iDelayedForegroundInProgress; |
|
955 |
} |
|
956 |
||
957 |
// End of file |