fmradio/fmradio/src/fmradioalfvisualizer.cpp
branchRCL_3
changeset 15 04aa446da81c
parent 13 4f2584af5a29
equal deleted inserted replaced
13:4f2584af5a29 15:04aa446da81c
   537 void CFMRadioAlfVisualizer::HandleGestureL( const MGestureEvent& aEvent )
   537 void CFMRadioAlfVisualizer::HandleGestureL( const MGestureEvent& aEvent )
   538     {
   538     {
   539     TGestureCode eventCode( aEvent.Code( MGestureEvent::EAxisBoth ) );
   539     TGestureCode eventCode( aEvent.Code( MGestureEvent::EAxisBoth ) );
   540     FTRACE( FPrint( _L("CFMRadioAlfVisualizer::HandleGestureL(eventCode=%d)"), eventCode ) );
   540     FTRACE( FPrint( _L("CFMRadioAlfVisualizer::HandleGestureL(eventCode=%d)"), eventCode ) );
   541     
   541     
   542     CFMRadioAppUi* appUi = static_cast<CFMRadioAppUi*>( CCoeEnv::Static()->AppUi() );
       
   543     // handle gestures only if there is no call or tuning ongoing
   542     // handle gestures only if there is no call or tuning ongoing
   544     if ( !appUi->RadioEngine()->IsInCall() &&
   543     if ( !iAppUi->RadioEngine()->IsInCall() &&
   545             appUi->RadioState() != CFMRadioAppUi::EFMRadioStateBusySeek )
   544             iAppUi->RadioState() != CFMRadioAppUi::EFMRadioStateBusySeek )
   546         {
   545         {
   547         switch ( eventCode )
   546         switch ( eventCode )
   548             {
   547             {
   549             case EGestureTap:
   548             case EGestureTap:
   550                 {
   549                 {
   551                 CAknVolumePopup* volPopup = appUi->ActiveVolumePopup();
   550                 CAknVolumePopup* volPopup = iAppUi->ActiveVolumePopup();
   552                 if ( volPopup )
   551                 if ( volPopup )
   553                     {
   552                     {
   554                     if ( volPopup->IsVisible() )
   553                     if ( volPopup->IsVisible() )
   555                         {
   554                         {
   556                         volPopup->CloseVolumePopup();
   555                         volPopup->CloseVolumePopup();
   565                 }
   564                 }
   566             case EGestureSwipeLeft:
   565             case EGestureSwipeLeft:
   567                 {
   566                 {
   568                 if ( iDragAxis == EFMRadioDragAxisX )
   567                 if ( iDragAxis == EFMRadioDragAxisX )
   569                     {
   568                     {
   570                     if ( appUi->NumberOfChannelsStored() )
   569                     if ( iAppUi->NumberOfChannelsStored() )
   571                         {
   570                         {
   572                         iRevertGestureDrag = EFalse;
   571                         iRevertGestureDrag = EFalse;
   573                         }
   572                         }
   574                     appUi->HandleCommandL( EFMRadioCmdNextChannel );
   573                     iAppUi->HandleCommandL( EFMRadioCmdNextChannel );
   575                     }
   574                     }
   576                 break;
   575                 break;
   577                 }
   576                 }
   578             case EGestureSwipeRight:
   577             case EGestureSwipeRight:
   579                 {
   578                 {
   580                 if ( iDragAxis == EFMRadioDragAxisX )
   579                 if ( iDragAxis == EFMRadioDragAxisX )
   581                     {
   580                     {
   582                     if ( appUi->NumberOfChannelsStored() )
   581                     if ( iAppUi->NumberOfChannelsStored() )
   583                         {
   582                         {
   584                         iRevertGestureDrag = EFalse;
   583                         iRevertGestureDrag = EFalse;
   585                         }
   584                         }
   586                     appUi->HandleCommandL( EFMRadioCmdPrevChannel );
   585                     iAppUi->HandleCommandL( EFMRadioCmdPrevChannel );
   587                     }
   586                     }
   588                 break;
   587                 break;
   589                 }
   588                 }
   590             case EGestureSwipeUp:
   589             case EGestureSwipeUp:
   591                 {
   590                 {
   592                 if ( iDragAxis == EFMRadioDragAxisY )
   591                 if ( iDragAxis == EFMRadioDragAxisY )
   593                     {
   592                     {
   594                     iRevertGestureDrag = EFalse;
   593                     iRevertGestureDrag = EFalse;
   595                     appUi->HandleCommandL( EFMRadioCmdSeekUp );
   594                     iAppUi->HandleCommandL( EFMRadioCmdSeekUp );
   596                     }
   595                     }
   597                 break;
   596                 break;
   598                 }
   597                 }
   599             case EGestureSwipeDown:
   598             case EGestureSwipeDown:
   600                 {
   599                 {
   601                 if ( iDragAxis == EFMRadioDragAxisY )
   600                 if ( iDragAxis == EFMRadioDragAxisY )
   602                     {
   601                     {
   603                     iRevertGestureDrag = EFalse;
   602                     iRevertGestureDrag = EFalse;
   604                     appUi->HandleCommandL( EFMRadioCmdSeekDown );
   603                     iAppUi->HandleCommandL( EFMRadioCmdSeekDown );
   605                     }
   604                     }
   606                 break;
   605                 break;
   607                 }
   606                 }
   608             case EGestureStart:
   607             case EGestureStart:
   609                 {
   608                 {
   697 //
   696 //
   698 TBool CFMRadioAlfVisualizer::OfferEventL( const TAlfEvent& aEvent )
   697 TBool CFMRadioAlfVisualizer::OfferEventL( const TAlfEvent& aEvent )
   699     {
   698     {
   700     TBool keyHandled = EFalse;
   699     TBool keyHandled = EFalse;
   701     
   700     
   702     if ( aEvent.IsKeyEvent() && AknLayoutUtils::PenEnabled() )
   701     if ( !iAppUi->RadioEngine()->IsInCall() )
   703         {
   702         {
   704         const TKeyEvent& kEvent = aEvent.KeyEvent();
   703         if ( aEvent.IsKeyEvent() && AknLayoutUtils::PenEnabled() )
       
   704             {
       
   705             const TKeyEvent& kEvent = aEvent.KeyEvent();
       
   706             
       
   707             if ( kEvent.iCode == EKeyEnter || kEvent.iCode == EKeyOK )
       
   708                 {
       
   709                 TriggerCommandL( EFMRadioCmdChannelList );
       
   710                 keyHandled = ETrue;
       
   711                 }
       
   712             
       
   713             switch ( kEvent.iScanCode )
       
   714                 {
       
   715                 case EStdKeyRightArrow: // check arrow keys
       
   716                 case EStdKeyLeftArrow:
       
   717                 case EStdKeyUpArrow:
       
   718                 case EStdKeyDownArrow:
       
   719                     {
       
   720                     iKeyScanCode = kEvent.iScanCode;
   705         
   721         
   706         if ( kEvent.iCode == EKeyEnter || kEvent.iCode == EKeyOK )
   722                     if ( aEvent.Code() == EEventKeyUp )
   707             {
   723                         {
   708             iAppUi->ActivateLocalViewL( KFMRadioChannelListViewId );
   724                         iLongPressTimer->Cancel();
   709             keyHandled = ETrue;
   725                         if ( !iLongKeyTriggered )
   710             }
   726                             {
   711         
   727                             TriggerCommandL();
   712         switch ( kEvent.iScanCode )
   728                             }
   713             {
   729                         }
   714             case EStdKeyRightArrow: // check arrow keys
   730                     else if ( aEvent.Code() == EEventKeyDown )
   715             case EStdKeyLeftArrow:
   731                         {
   716             case EStdKeyUpArrow:
   732                         iLongKeyTriggered = EFalse;
   717             case EStdKeyDownArrow:
   733                         // Start the long key press timer
   718                 {
   734                         iLongPressTimer->Cancel();
   719                 iKeyScanCode = kEvent.iScanCode;
   735                         iLongPressTimer->Start( KFMRadioRockerLongPressDelay, 
       
   736                                                 0, 
       
   737                                                 TCallBack( CFMRadioAlfVisualizer::StaticLongPressCallBack, this ) );
       
   738                         
       
   739                         }
       
   740                     keyHandled = ETrue;
       
   741                     break;
       
   742                     }
       
   743                 default:
       
   744                     {
       
   745                     break;
       
   746                     }
       
   747                 }
       
   748             }
       
   749         if ( aEvent.IsPointerEvent() )
       
   750             {
       
   751             return CGestureControl::OfferEventL( aEvent );
       
   752             }
       
   753         }
   720     
   754     
   721                 if ( aEvent.Code() == EEventKeyUp )
       
   722                     {
       
   723                     iLongPressTimer->Cancel();
       
   724                     if ( !iLongKeyTriggered )
       
   725                         {
       
   726                         TriggerCommandL();
       
   727                         }
       
   728                     }
       
   729                 else if ( aEvent.Code() == EEventKeyDown )
       
   730                     {
       
   731                     iLongKeyTriggered = EFalse;
       
   732                     // Start the long key press timer
       
   733                     iLongPressTimer->Cancel();
       
   734                     iLongPressTimer->Start( KFMRadioRockerLongPressDelay, 
       
   735                                             0, 
       
   736                                             TCallBack( CFMRadioAlfVisualizer::StaticLongPressCallBack, this ) );
       
   737                     
       
   738                     }
       
   739                 keyHandled = ETrue;
       
   740                 break;
       
   741                 }
       
   742             default:
       
   743                 {
       
   744                 break;
       
   745                 }
       
   746             }
       
   747         }
       
   748     if ( aEvent.IsPointerEvent() )
       
   749         {
       
   750         return CGestureControl::OfferEventL( aEvent );
       
   751         }
       
   752     return keyHandled;
   755     return keyHandled;
   753     }
   756     }
   754 
   757 
   755 // ---------------------------------------------------------------------------
   758 // ---------------------------------------------------------------------------
   756 // Sets the display style in use.
   759 // Sets the display style in use.
  1083 
  1086 
  1084 // ---------------------------------------------------------------------------
  1087 // ---------------------------------------------------------------------------
  1085 // Triggers the command to view handling
  1088 // Triggers the command to view handling
  1086 // ---------------------------------------------------------------------------
  1089 // ---------------------------------------------------------------------------
  1087 //
  1090 //
  1088 void CFMRadioAlfVisualizer::TriggerCommandL()
  1091 void CFMRadioAlfVisualizer::TriggerCommandL( TInt aCommand )
  1089     {
  1092     {
  1090     TVwsViewId viewId( KNullUid, KNullUid );
  1093     TVwsViewId viewId( KNullUid, KNullUid );
  1091     TInt err = iAppUi->GetActiveViewId( viewId );
  1094     TInt err = iAppUi->GetActiveViewId( viewId );
  1092     RProcess process;
  1095     RProcess process;
  1093     TSecureId id = process.SecureId();
  1096     TSecureId id = process.SecureId();
  1135                 case EStdKeyDownArrow:
  1138                 case EStdKeyDownArrow:
  1136                     {
  1139                     {
  1137                     commandId = EFMRadioRockerButtonKeyDown;
  1140                     commandId = EFMRadioRockerButtonKeyDown;
  1138                     break;
  1141                     break;
  1139                     }
  1142                     }
       
  1143                 }
       
  1144             if ( aCommand == EFMRadioCmdChannelList )
       
  1145                 {
       
  1146                 commandId = EFMRadioCmdChannelList;
  1140                 }
  1147                 }
  1141             // send command to view
  1148             // send command to view
  1142             view->ProcessCommandL( commandId );
  1149             view->ProcessCommandL( commandId );
  1143             }
  1150             }
  1144         }
  1151         }