emailuis/emailui/src/FreestyleEmailUiViewBase.cpp
changeset 0 8466d47a6819
child 1 12c456ceeff2
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     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:  Definition for the common base class for all FsEmailUi views.
       
    15 *                The class is not intended for instantation.
       
    16 *
       
    17 */
       
    18  
       
    19 
       
    20 // <cmail> SF
       
    21 #include "emailtrace.h"
       
    22 #include <alf/alfcontrolgroup.h>
       
    23 #include <alf/alfvisual.h>
       
    24 // </cmail>
       
    25 #include <eikbtgpc.h>
       
    26 #include "FreestyleEmailUiViewBase.h"
       
    27 #include "FreestyleEmailUiAppui.h"
       
    28 #include "FreestyleEmailUiLayoutHandler.h"
       
    29 #include "FreestyleEmailUiStatusIndicator.h"
       
    30 #include "FSEmail.pan"
       
    31 
       
    32 // <cmail> Toolbar
       
    33 #include <AknUtils.h>
       
    34 #include <akntoolbar.h>
       
    35 #include <FreestyleEmailUi.rsg>
       
    36 
       
    37 #include <aknlayoutscalable_avkon.cdl.h>
       
    38 #include <layoutmetadata.cdl.h>
       
    39 
       
    40 // </cmail> Toolbar
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 CFsEmailUiViewBase::CFsEmailUiViewBase( CAlfControlGroup& aControlGroup, 
       
    45         CFreestyleEmailUiAppUi& aAppUi )
       
    46     : iControlGroup( aControlGroup ), iAppUi( aAppUi )
       
    47     {
       
    48     FUNC_LOG;
       
    49     // Set control groups to ignore input by default
       
    50     iControlGroup.SetAcceptInput( EFalse );
       
    51     iKeyboardFlipOpen = aAppUi.IsFlipOpen();
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 TUid CFsEmailUiViewBase::Id() const
       
    57     {
       
    58     FUNC_LOG;
       
    59     // This must be overriden by the inherited class
       
    60     __ASSERT_DEBUG( EFalse, Panic(EFSEmailUiBaseViewMethodNotOverriden) );
       
    61     return TUid::Null();
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 void CFsEmailUiViewBase::DoActivateL( const TVwsViewId& aPrevViewId,
       
    67 	                                  TUid aCustomMessageId,
       
    68 	                                  const TDesC8& aCustomMessage )
       
    69     {
       
    70     FUNC_LOG;    
       
    71     SetViewActive( ETrue );
       
    72     //<cmail>
       
    73     iAppUi.StatusPane()->DrawNow();
       
    74     //</cmail>
       
    75     iFocusVisible = iAppUi.IsTimerFocusShown();
       
    76     
       
    77     // fix view stack in case of external activation
       
    78     if ( aPrevViewId.iAppUid != KFSEmailUiUid )
       
    79         {
       
    80         iActiveMailboxBeforeExternalActivation = iAppUi.GetActiveMailboxId();
       
    81         iAppUi.ViewActivatedExternallyL( Id() );
       
    82         }
       
    83 
       
    84     // hide previous view
       
    85     CFsEmailUiViewBase* previousView = iAppUi.PreviousActiveView();
       
    86     TBool pluginSettingsActive = iAppUi.IsPluginSettingsViewActive();
       
    87     if ( pluginSettingsActive )
       
    88         {
       
    89         iAppUi.ReturnFromPluginSettingsView();
       
    90         }
       
    91     else if ( previousView )
       
    92         {
       
    93         // In case of external activation, hide previous control group
       
    94         // before view activation to avoid screen flickering
       
    95         if ( aPrevViewId.iAppUid != KFSEmailUiUid )
       
    96             {
       
    97             previousView->DeactivateControlGroup();
       
    98             }
       
    99         previousView->DoTransition( ETrue ); // fade out prev view
       
   100         }
       
   101     
       
   102     // Clear the flag of long transition effect
       
   103     SetNextTransitionOutLong( EFalse );
       
   104     UpdateToolbarL();
       
   105 
       
   106     SetStatusBarLayout();
       
   107 
       
   108     // Make sure Alfred display is of correct size (there is some problems with toolbar)
       
   109     TRect metricsRect;
       
   110     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, metricsRect);
       
   111     CAlfEnv::Static()->PrimaryDisplay().ForceSetVisibleArea(metricsRect);
       
   112     
       
   113     // Finally call child classes activation method
       
   114     TRAPD( error, ChildDoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage) );    
       
   115     if ( !error )
       
   116         {
       
   117         // View activated succesfully. Change visible control group, but not
       
   118         // when application is being sent to background.
       
   119         if ( !iAppUi.SwitchingToBackground() )
       
   120             {
       
   121             DoTransition( EFalse );
       
   122             ActivateControlGroup();
       
   123             }
       
   124         }
       
   125     else
       
   126         {
       
   127         // In case of error, navigate to the previous view
       
   128         DeactivateControlGroup();
       
   129         NavigateBackL();
       
   130         }
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 //
       
   135 void CFsEmailUiViewBase::UpdateToolbarL()
       
   136     {
       
   137     FUNC_LOG;
       
   138     if (AknLayoutUtils::PenEnabled())
       
   139         {
       
   140         if (HasToolbar())
       
   141             {
       
   142             const TInt resourceId(ToolbarResourceId());
       
   143             RArray<TInt> dimmedItems;
       
   144             CleanupClosePushL(dimmedItems);
       
   145             GetInitiallyDimmedItemsL(resourceId, dimmedItems);
       
   146             CAknToolbar* toolbar(CAknToolbar::NewL(resourceId));
       
   147             for (TInt i = 0; i < dimmedItems.Count(); i++)
       
   148                 {
       
   149                 toolbar->SetItemDimmed(dimmedItems[i], ETrue, EFalse);
       
   150                 }
       
   151             CleanupStack::PopAndDestroy(); // dimmedItems.Close()
       
   152             toolbar->SetToolbarObserver(this);
       
   153             SetToolbar(toolbar);
       
   154             ShowToolbar();
       
   155             }
       
   156         else
       
   157             {
       
   158             HideToolbar();
       
   159             }
       
   160         }
       
   161     }
       
   162 
       
   163 // ---------------------------------------------------------------------------
       
   164 //
       
   165 void CFsEmailUiViewBase::GetInitiallyDimmedItemsL( 
       
   166         const TInt /*aResourceId*/, RArray<TInt>& aDimmedItems ) const
       
   167     {
       
   168     FUNC_LOG;
       
   169     aDimmedItems.Reset();
       
   170     }
       
   171 
       
   172 // ---------------------------------------------------------------------------
       
   173 //
       
   174 void CFsEmailUiViewBase::HideToolbar()
       
   175     {
       
   176     FUNC_LOG;
       
   177     if (AknLayoutUtils::PenEnabled())
       
   178         {
       
   179         CAknToolbar* toolbar(Toolbar());
       
   180         if (toolbar)
       
   181             {
       
   182             //toolbar->SetToolbarVisibility(EFalse);
       
   183             // Call MakeVisible directly because SetToolbarVisibility never
       
   184             // actually hides fixed toolbar.
       
   185             toolbar->MakeVisible(EFalse);
       
   186             }
       
   187         }
       
   188     }
       
   189 
       
   190 // ---------------------------------------------------------------------------
       
   191 //
       
   192 void CFsEmailUiViewBase::ShowToolbar()
       
   193     {
       
   194     FUNC_LOG;
       
   195     if (AknLayoutUtils::PenEnabled())
       
   196         {
       
   197         CAknToolbar* toolbar(Toolbar());
       
   198         if (toolbar)
       
   199             {
       
   200             toolbar->SetToolbarVisibility(ETrue);
       
   201             }
       
   202         }
       
   203     }
       
   204 
       
   205 // ---------------------------------------------------------------------------
       
   206 //
       
   207 void CFsEmailUiViewBase::SetToolbarItemDimmed( const TInt aCommandId, const TBool aDimmed )
       
   208     {
       
   209     FUNC_LOG;
       
   210     if (AknLayoutUtils::PenEnabled())
       
   211         {
       
   212         CAknToolbar* toolbar(Toolbar());
       
   213         if (toolbar)
       
   214             {
       
   215             toolbar->SetItemDimmed(aCommandId, aDimmed, ETrue);
       
   216             }
       
   217         }
       
   218     }
       
   219 
       
   220 // ---------------------------------------------------------------------------
       
   221 //
       
   222 void CFsEmailUiViewBase::DoDeactivate()
       
   223     {
       
   224     FUNC_LOG;
       
   225     SetViewActive( EFalse );    
       
   226 
       
   227     HideToolbar();
       
   228    
       
   229     // Make control group ignore input and hide it if it's not already fading out.
       
   230     DeactivateControlGroup();
       
   231 
       
   232     // do view specific deactivation
       
   233     ChildDoDeactivate();
       
   234     
       
   235     // Return to another app in case this view was activated externally
       
   236     if ( iSendToBackgroundOnDeactivation )
       
   237         {
       
   238         iSendToBackgroundOnDeactivation = EFalse;
       
   239         
       
   240         // Try to bring calling external app into foreground if found
       
   241         TApaTaskList taskList( iEikonEnv->WsSession() );
       
   242         TApaTask prevAppTask = taskList.FindApp( iPreviousAppUid );
       
   243         TApaTask fsEmailTask = taskList.FindApp( KFSEmailUiUid );
       
   244         if ( prevAppTask.Exists() )
       
   245             {
       
   246             prevAppTask.BringToForeground();
       
   247             }
       
   248         if ( fsEmailTask.Exists() && iPreviousAppUid != KMessageReaderUid )
       
   249             {
       
   250             fsEmailTask.SendToBackground();
       
   251             }
       
   252 
       
   253         iAppUi.SetSwitchingToBackground( EFalse );
       
   254         }
       
   255     }
       
   256 
       
   257 // ---------------------------------------------------------------------------
       
   258 // Check if transition effects are enabled and run the effect if needed.
       
   259 //
       
   260 void CFsEmailUiViewBase::DoTransition( TBool aDirectionOut )
       
   261     {
       
   262     FUNC_LOG;
       
   263     if ( iAppUi.LayoutHandler() && iAppUi.LayoutHandler()->ViewFadeEffectActive() )
       
   264         {
       
   265         DoTransitionEffect( aDirectionOut );
       
   266         }
       
   267     }
       
   268 
       
   269 // ---------------------------------------------------------------------------
       
   270 // Inheriting Alfred views can override these functions, if they need to do
       
   271 // some special tricks for transition effects
       
   272 //
       
   273 void CFsEmailUiViewBase::DoTransitionEffect( TBool aDirectionOut )
       
   274     {  
       
   275     FUNC_LOG;
       
   276     RPointerArray<CAlfVisual> layoutArray;
       
   277     TRAP_IGNORE( GetParentLayoutsL( layoutArray ) );
       
   278     
       
   279     // For views that return valid parent layout(s), use the fade effect,
       
   280     // for all other views, use the showing/hiding of control groups
       
   281     for ( TInt i = 0 ; i < layoutArray.Count() ; i++ )
       
   282         {
       
   283         // Returned parent layout might be NULL, if view construction is not
       
   284         // fully completed
       
   285         if ( layoutArray[i] != NULL )
       
   286             {
       
   287             // Ensure the view is invisible before doing fade in (because views
       
   288             // are automatically visible rigt after construction)
       
   289             if ( !aDirectionOut )
       
   290                 {
       
   291                 FadeVisual( layoutArray[i], ETrue, ETrue );
       
   292                 }
       
   293             
       
   294             FadeVisual( layoutArray[i], aDirectionOut );
       
   295             }
       
   296         }
       
   297 
       
   298     layoutArray.Close();
       
   299     }
       
   300 
       
   301 // ---------------------------------------------------------------------------
       
   302 // Inheriting Alfred views should override this and return their parent
       
   303 // layout(s) in array given as parameter. Default implementation
       
   304 // does nothing, so then the array is empty.
       
   305 //
       
   306 void CFsEmailUiViewBase::GetParentLayoutsL( RPointerArray<CAlfVisual>& /*aLayoutArray*/ ) const
       
   307     {
       
   308     FUNC_LOG;
       
   309     }
       
   310 
       
   311 // ---------------------------------------------------------------------------
       
   312 // Fade given Alfred visual
       
   313 //
       
   314 void CFsEmailUiViewBase::FadeVisual(
       
   315         CAlfVisual* aVisual,
       
   316         TBool aFadeDirectionOut,
       
   317         TBool aImmediate /*= EFalse*/)
       
   318     {   
       
   319     FUNC_LOG;
       
   320     // Check that we are not exiting and is fade effect activated
       
   321     if ( !iAppUi.AppUiExitOngoing() )
       
   322         {
       
   323         TInt effectTime = 0;
       
   324         
       
   325         if ( !aImmediate && iAppUi.LayoutHandler() )
       
   326             {
       
   327             if( aFadeDirectionOut )
       
   328                 {
       
   329                 effectTime = iAppUi.LayoutHandler()->ViewFadeOutEffectTime();
       
   330                 }
       
   331             else
       
   332                 {
       
   333                 effectTime = iAppUi.LayoutHandler()->ViewFadeInEffectTime();
       
   334                 }
       
   335             }
       
   336         
       
   337         if ( aFadeDirectionOut && IsNextTransitionOutLong() )
       
   338             {
       
   339             effectTime = effectTime * 2;
       
   340             }
       
   341     
       
   342         // Initialize for out fading
       
   343         TAlfTimedValue timedValue( 0, effectTime );
       
   344         // Check value and initialze for in fading if set
       
   345         if ( !aFadeDirectionOut )
       
   346             {
       
   347             timedValue.SetTarget( 1, effectTime ); 
       
   348             }
       
   349         aVisual->SetOpacity( timedValue );
       
   350         }
       
   351     }
       
   352 
       
   353 // ---------------------------------------------------------------------------
       
   354 // Used to indicate that the next out transition effect should be long
       
   355 // (some long opening view is opened next)
       
   356 //
       
   357 void CFsEmailUiViewBase::SetNextTransitionOutLong( TBool aLongTransitionOut )
       
   358     {
       
   359     FUNC_LOG;
       
   360     iIsNextTransitionEffectOutLong = aLongTransitionOut;
       
   361     }
       
   362 
       
   363 // ---------------------------------------------------------------------------
       
   364 //
       
   365 TBool CFsEmailUiViewBase::IsNextTransitionOutLong()
       
   366     {
       
   367     FUNC_LOG;
       
   368     return iIsNextTransitionEffectOutLong;
       
   369     }
       
   370 
       
   371 // ---------------------------------------------------------------------------
       
   372 //
       
   373 void CFsEmailUiViewBase::ActivateControlGroup( TInt aDelay /*= 0*/ )
       
   374     {
       
   375     FUNC_LOG;
       
   376     if ( !iAppUi.AppUiExitOngoing() )
       
   377         {
       
   378         TAlfGroupCommand showCmd( ControlGroup(), EAlfOpShow, &iAppUi.Display() );
       
   379         iAppUi.AlfEnv().Send( showCmd, aDelay );            
       
   380         ControlGroup().SetAcceptInput( ETrue );
       
   381     
       
   382         // Status indicator is "always on top" while visible
       
   383         /*if ( iAppUi.StatusIndicator() && iAppUi.StatusIndicator()->IsVisible() )
       
   384             {
       
   385             CAlfControlGroup& indicatorGroup = iAppUi.AlfEnv().ControlGroup( KStatusIndicatorDisplayGroup );
       
   386             TAlfGroupCommand indicShowCmd( indicatorGroup, EAlfOpShow, &iAppUi.Display() );
       
   387             iAppUi.AlfEnv().Send( indicShowCmd, 0 );        
       
   388             indicatorGroup.SetAcceptInput( EFalse ); 
       
   389             }*/
       
   390         }
       
   391     }
       
   392 
       
   393 // ---------------------------------------------------------------------------
       
   394 //
       
   395 void CFsEmailUiViewBase::DeactivateControlGroup( TInt aDelay /*= 0*/ )
       
   396     {
       
   397     FUNC_LOG;
       
   398     const TReal32 KDelta = 0.01; // floating point comparison tolerance
       
   399     
       
   400     if ( !iAppUi.AppUiExitOngoing() )
       
   401         {
       
   402         ControlGroup().SetAcceptInput( EFalse );
       
   403     
       
   404         // Hide the control group immediately only if it's not already faded or 
       
   405         // fading out. This is to not interfere with the cross fading effect.
       
   406         RPointerArray<CAlfVisual> layoutArray;
       
   407         TRAP_IGNORE( GetParentLayoutsL( layoutArray ) );
       
   408         TInt layoutCount = layoutArray.Count();
       
   409         TInt fadingCount = 0;
       
   410         for ( TInt i = 0 ; i < layoutCount ; ++i )
       
   411             {
       
   412             CAlfVisual* layout = layoutArray[i]; 
       
   413             if ( layout && layout->Opacity().Target() < KDelta )
       
   414                 {
       
   415                 fadingCount++;
       
   416                 }
       
   417             }
       
   418         layoutArray.Close();
       
   419         
       
   420         if ( !layoutCount || fadingCount != layoutCount )
       
   421             {
       
   422             iAppUi.AlfEnv().CancelCommands( &ControlGroup(), EAlfOpShow );
       
   423             TAlfGroupCommand hideCmd( ControlGroup(), EAlfOpHide, &iAppUi.Display() );
       
   424             iAppUi.AlfEnv().Send( hideCmd, aDelay );
       
   425             }
       
   426         }
       
   427     }
       
   428 
       
   429 // ---------------------------------------------------------------------------
       
   430 //
       
   431 CAlfControlGroup& CFsEmailUiViewBase::ControlGroup()
       
   432     {
       
   433     FUNC_LOG;
       
   434     return iControlGroup;
       
   435     }
       
   436 
       
   437 // ---------------------------------------------------------------------------
       
   438 // Handles application foreground events.
       
   439 // ---------------------------------------------------------------------------
       
   440 //
       
   441 void CFsEmailUiViewBase::HandleAppForegroundEventL( TBool aForeground )
       
   442     {
       
   443     FUNC_LOG;
       
   444     if ( aForeground )
       
   445         {
       
   446         HandleForegroundEventL();
       
   447 
       
   448         // Activate control group in case the view was activated when
       
   449         // application was being sent to background, and the control group
       
   450         // was left inactive.
       
   451         const TInt KActivationDelay = 200; // ms
       
   452         ActivateControlGroup( KActivationDelay );
       
   453         }
       
   454     }
       
   455 
       
   456 // ---------------------------------------------------------------------------
       
   457 //
       
   458 void CFsEmailUiViewBase::HandleDynamicVariantSwitchL( TDynamicSwitchType aType )
       
   459     {
       
   460     FUNC_LOG;
       
   461 // <cmail> Toolbar    
       
   462     switch (aType)
       
   463         {
       
   464         case EScreenLayoutChanged:
       
   465             UpdateToolbarL();           
       
   466             break;
       
   467         }
       
   468 // </cmail> Toolbar    
       
   469     // Inherited classes should override this to react to skin and layout changes
       
   470     
       
   471 #ifdef __WINSCW__
       
   472     // For emulator testing: landscape mode is "flip open"
       
   473     FlipStateChangedL(  Layout_Meta_Data::IsLandscapeOrientation() );
       
   474 #endif
       
   475     }
       
   476 
       
   477 // ---------------------------------------------------------------------------
       
   478 //
       
   479 void CFsEmailUiViewBase::HandleDynamicVariantSwitchOnBackgroundL( TDynamicSwitchType /*aType*/ )
       
   480     {
       
   481     FUNC_LOG;
       
   482     // Inherited classes should override this to react to skin and layout changes
       
   483     // which happen while the view is on background
       
   484     
       
   485 #ifdef __WINSCW__
       
   486     // For emulator testing: landscape mode is "flip open"
       
   487     FlipStateChangedL(  Layout_Meta_Data::IsLandscapeOrientation() );
       
   488 #endif
       
   489     }
       
   490 
       
   491 // ---------------------------------------------------------------------------
       
   492 //
       
   493 TBool CFsEmailUiViewBase::IsNextMsgAvailable( TFSMailMsgId /*aCurrentMsgId*/, 
       
   494                                               TFSMailMsgId& /*aFoundNextMsgId*/,
       
   495                                               TFSMailMsgId& /*aFoundNextMsgFolderId*/ ) const
       
   496     {
       
   497     FUNC_LOG;
       
   498     return EFalse;
       
   499     }
       
   500 
       
   501 // ---------------------------------------------------------------------------
       
   502 //
       
   503 TBool CFsEmailUiViewBase::IsPreviousMsgAvailable( TFSMailMsgId /*aCurrentMsgId*/, 
       
   504                                                   TFSMailMsgId& /*aFoundPreviousMsgId*/,
       
   505                                                   TFSMailMsgId& /*aFoundPrevMsgFolderId*/ ) const
       
   506     {
       
   507     FUNC_LOG;
       
   508     return EFalse;
       
   509     }
       
   510 
       
   511 // ---------------------------------------------------------------------------
       
   512 //
       
   513 TInt CFsEmailUiViewBase::MoveToNextMsgL( TFSMailMsgId /*aCurrentMsgId*/,
       
   514                                          TFSMailMsgId& /*aFoundNextMsgId*/ )
       
   515     {
       
   516     FUNC_LOG;
       
   517     return KErrNotFound;
       
   518     }
       
   519 
       
   520 // ---------------------------------------------------------------------------
       
   521 //
       
   522 TInt CFsEmailUiViewBase::MoveToPreviousMsgL( TFSMailMsgId /*aCurrentMsgId*/, 
       
   523                                              TFSMailMsgId& /*aFoundPreviousMsgId*/ )
       
   524     {
       
   525     FUNC_LOG;
       
   526     return KErrNotFound;
       
   527     }
       
   528 
       
   529 //---------------------------------------------------------------------------
       
   530 // Concrete view class may override
       
   531 //---------------------------------------------------------------------------
       
   532 void CFsEmailUiViewBase::PrepareExitL()
       
   533     {
       
   534     FUNC_LOG;
       
   535     }
       
   536 
       
   537 //---------------------------------------------------------------------------
       
   538 // CFsEmailUiViewBase::FlipStateChangedL
       
   539 //---------------------------------------------------------------------------
       
   540 void CFsEmailUiViewBase::FlipStateChangedL( TBool aKeyboardFlipOpen )
       
   541 	{
       
   542 	FUNC_LOG;
       
   543 	iKeyboardFlipOpen = aKeyboardFlipOpen;
       
   544 	}
       
   545 
       
   546 // ---------------------------------------------------------------------------
       
   547 //
       
   548 void CFsEmailUiViewBase::HandleForegroundEventL()
       
   549     {
       
   550     FUNC_LOG;
       
   551     }
       
   552 
       
   553 // ---------------------------------------------------------------------------
       
   554 //
       
   555 void CFsEmailUiViewBase::ViewEntered( const TVwsViewId& aPrevViewId )
       
   556     {
       
   557     FUNC_LOG;
       
   558     iPreviousAppUid = aPrevViewId.iAppUid;
       
   559     }
       
   560 
       
   561 // ---------------------------------------------------------------------------
       
   562 // CFsEmailUiViewBase::NavigateBackL
       
   563 // ---------------------------------------------------------------------------
       
   564 void CFsEmailUiViewBase::NavigateBackL()
       
   565     {
       
   566     FUNC_LOG;
       
   567     if ( !iAppUi.ViewSwitchingOngoing() )
       
   568         {
       
   569         TUid prevView = iAppUi.ReturnToPreviousViewL();
       
   570 
       
   571         if ( iPreviousAppUid != KFSEmailUiUid && iPreviousAppUid != KNullUid )
       
   572             {
       
   573             // Email app should be hidden once the view gets deactivated. Note that hiding
       
   574             // should not happen before control group switching is over because that
       
   575             // may cause views of other Alfred apps to get distorted.
       
   576             iSendToBackgroundOnDeactivation = ETrue;
       
   577             iAppUi.SetSwitchingToBackground( ETrue );
       
   578 
       
   579             // Re-activate previously active mailbox if it got changed in the external activation.
       
   580             // As an exception, if previous view is the laucher grid, the previously active
       
   581             // mailbox does not need to be reactivated. This prevents unnecessary mailbox switching
       
   582             // when mailbox is entered from home screen, user returns with Back, and enters the same
       
   583             // mailbox again.
       
   584             if ( prevView != AppGridId &&
       
   585                  iActiveMailboxBeforeExternalActivation != iAppUi.GetActiveMailboxId() &&
       
   586                  !iActiveMailboxBeforeExternalActivation.IsNullId() )
       
   587                 {
       
   588                 iAppUi.SetActiveMailboxL( iActiveMailboxBeforeExternalActivation, EFalse );
       
   589                 }
       
   590             }
       
   591         }
       
   592     }
       
   593 
       
   594 // -----------------------------------------------------------------------------
       
   595 // CFsEmailUiViewBase::ChangeMskCommandL
       
   596 // Utility function to change the command ID and label on the middle soft key
       
   597 // -----------------------------------------------------------------------------
       
   598 void CFsEmailUiViewBase::ChangeMskCommandL( TInt aLabelResourceId )
       
   599     {
       
   600     FUNC_LOG;
       
   601     CEikButtonGroupContainer* cba = Cba();
       
   602     if ( cba ) 
       
   603         {
       
   604         cba->SetCommandL( CEikButtonGroupContainer::EMiddleSoftkeyPosition, 
       
   605                             aLabelResourceId );
       
   606         cba->DrawDeferred();
       
   607         }
       
   608     }
       
   609 
       
   610 // -----------------------------------------------------------------------------
       
   611 // CFsEmailUiViewBase::HasToolbar
       
   612 // Method to check whether the view has toolbar defined or not.
       
   613 // -----------------------------------------------------------------------------
       
   614 TBool CFsEmailUiViewBase::HasToolbar() const
       
   615     {
       
   616     FUNC_LOG;
       
   617     return ToolbarResourceId() != R_FREESTYLE_EMAIL_UI_TOOLBAR_BLANK;
       
   618     }
       
   619 
       
   620 // -----------------------------------------------------------------------------
       
   621 // CFsEmailUiViewBase::ToolbarResourceId
       
   622 // 
       
   623 // -----------------------------------------------------------------------------
       
   624 TInt CFsEmailUiViewBase::ToolbarResourceId() const
       
   625     {
       
   626     FUNC_LOG;    
       
   627     return R_FREESTYLE_EMAIL_UI_TOOLBAR_BLANK;
       
   628     }
       
   629 
       
   630 // -----------------------------------------------------------------------------
       
   631 // CFsEmailUiViewBase::OfferToolbarEventL
       
   632 // -----------------------------------------------------------------------------
       
   633 void CFsEmailUiViewBase::OfferToolbarEventL( TInt /*aCommand*/ )
       
   634     {
       
   635     FUNC_LOG;
       
   636     }
       
   637 
       
   638 // -----------------------------------------------------------------------------
       
   639 // CFsEmailUiViewBase::SetViewActive
       
   640 // -----------------------------------------------------------------------------
       
   641 void CFsEmailUiViewBase::SetViewActive( const TBool aActive )
       
   642     {
       
   643     FUNC_LOG;
       
   644     iViewActive = aActive;
       
   645     }
       
   646 
       
   647 // -----------------------------------------------------------------------------
       
   648 // CFsEmailUiViewBase::IsViewActive
       
   649 // -----------------------------------------------------------------------------
       
   650 TBool CFsEmailUiViewBase::IsViewActive() const
       
   651     {
       
   652     FUNC_LOG;
       
   653     return iViewActive;
       
   654     }
       
   655 
       
   656 // -----------------------------------------------------------------------------
       
   657 // CFsEmailUiViewBase::IsFocusShown
       
   658 // -----------------------------------------------------------------------------
       
   659 TBool CFsEmailUiViewBase::IsFocusShown()
       
   660     {
       
   661     return iFocusVisible;
       
   662     }
       
   663 
       
   664 // -----------------------------------------------------------------------------
       
   665 // CFsEmailUiViewBase::SetStatusBarLayout
       
   666 // -----------------------------------------------------------------------------
       
   667 void CFsEmailUiViewBase::SetStatusBarLayout()
       
   668 	{
       
   669 	if ( StatusPane()->CurrentLayoutResId() != R_AVKON_STATUS_PANE_LAYOUT_USUAL )
       
   670 		{
       
   671 		TRAP_IGNORE( StatusPane()->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL));
       
   672 		}
       
   673 	}
       
   674 
       
   675 // -----------------------------------------------------------------------------
       
   676 // CFsEmailUiViewBase::HandleTimerFocusStateChange
       
   677 // -----------------------------------------------------------------------------
       
   678 void CFsEmailUiViewBase::HandleTimerFocusStateChange(TBool aShow)
       
   679 	{
       
   680     iFocusVisible = aShow;
       
   681 	}
       
   682 
       
   683 
       
   684 // end of file
       
   685