phoneuis/dialer/src/cdialernumberentry.cpp
branchRCL_3
changeset 23 40a3f856b14d
parent 20 3c221667e687
equal deleted inserted replaced
22:94dc1107e8b2 23:40a3f856b14d
    23 #include <w32std.h>
    23 #include <w32std.h>
    24 #include <baclipb.h>            // CClipboard
    24 #include <baclipb.h>            // CClipboard
    25 #include <dialer.rsg>
    25 #include <dialer.rsg>
    26 #include <eikimage.h>           // CEikImage
    26 #include <eikimage.h>           // CEikImage
    27 #include <barsread.h>           // TResourceReader
    27 #include <barsread.h>           // TResourceReader
       
    28 #include <featmgr.h>
    28 #include <eiklabel.h> 
    29 #include <eiklabel.h> 
    29 #include <aknappui.h>
    30 #include <aknappui.h>
    30 #include <AknUtils.h>
    31 #include <AknUtils.h>
    31 #include <AknsDrawUtils.h>
    32 #include <AknsDrawUtils.h>
    32 #include <applayout.cdl.h>
    33 #include <applayout.cdl.h>
    33 #include <AknLayoutFont.h>
    34 #include <AknLayoutFont.h>
    34 #include <aknlayout2def.h>
    35 #include <AknLayout2Def.h>
    35 #include <AknPhoneNumberEditor.h>
    36 #include <AknPhoneNumberEditor.h>
    36 #include <aknlayout2scalabledef.h>
    37 #include <AknLayout2ScalableDef.h>
    37 #include <AknsBasicBackgroundControlContext.h>
    38 #include <AknsBasicBackgroundControlContext.h>
    38 #include <AknsFrameBackgroundControlContext.h>
    39 #include <AknsFrameBackgroundControlContext.h>
    39 #include <aknlayoutscalable_apps.cdl.h>
    40 #include <aknlayoutscalable_apps.cdl.h>
    40 #include <layoutmetadata.cdl.h>
    41 #include <layoutmetadata.cdl.h>
    41 
    42 
    48 #include    <phoneappcommands.hrh>
    49 #include    <phoneappcommands.hrh>
    49 
    50 
    50 const TInt KNumberEntryControlCount = 2; //  = number entry, label
    51 const TInt KNumberEntryControlCount = 2; //  = number entry, label
    51 
    52 
    52 _LIT( KPhoneValidChars, "0123456789*#+pwPW" );
    53 _LIT( KPhoneValidChars, "0123456789*#+pwPW" );
       
    54 _LIT( KPhoneVanityValidChars, "0123456789*#+pwABCDEFGHIJKLMNOPQRSTUVWXYZ" );
       
    55 
    53 const TInt KKeyCtrlA( 1 );
    56 const TInt KKeyCtrlA( 1 );
    54 const TInt KKeyCtrlC( 3 );
    57 const TInt KKeyCtrlC( 3 );
    55 const TInt KKeyCtrlV( 22 );
    58 const TInt KKeyCtrlV( 22 );
    56 const TInt KKeyCtrlX( 24 );
    59 const TInt KKeyCtrlX( 24 );
    57 
    60 
   114     iLabel->MakeVisible( EFalse );
   117     iLabel->MakeVisible( EFalse );
   115     CheckLabelSkinningColor();
   118     CheckLabelSkinningColor();
   116     
   119     
   117     iAppUi = iEikonEnv->EikAppUi();
   120     iAppUi = iEikonEnv->EikAppUi();
   118     __ASSERT_ALWAYS( iAppUi, DialerPanic( EDialerPanicNoApplicationInstance ) );
   121     __ASSERT_ALWAYS( iAppUi, DialerPanic( EDialerPanicNoApplicationInstance ) );
   119      
   122     
       
   123     iLateFocuser = CIdle::NewL( CActive::EPriorityIdle );
       
   124     
   120     ActivateL();
   125     ActivateL();
   121     DIALER_PRINT("numberentry::ConstructL>");
   126     DIALER_PRINT("numberentry::ConstructL>");
   122     }
   127     }
   123 
   128 
   124 
   129 
   136     AknsUtils::DeregisterControlPosition( this );
   141     AknsUtils::DeregisterControlPosition( this );
   137     
   142     
   138     delete iEditor;
   143     delete iEditor;
   139     delete iFrameContext;
   144     delete iFrameContext;
   140     delete iLabel;
   145     delete iLabel;
       
   146     
       
   147     if ( iLateFocuser ) 
       
   148         {
       
   149         iLateFocuser->Cancel();
       
   150         }
       
   151     delete iLateFocuser;
       
   152     
   141     }
   153     }
   142 
   154 
   143 
   155 
   144 // ---------------------------------------------------------------------------
   156 // ---------------------------------------------------------------------------
   145 // CDialerNumberEntry::SetNumberEntryObserver 
   157 // CDialerNumberEntry::SetNumberEntryObserver 
   150     {
   162     {
   151     iObserver = &aObserver;
   163     iObserver = &aObserver;
   152     }
   164     }
   153         
   165         
   154 // ---------------------------------------------------------------------------
   166 // ---------------------------------------------------------------------------
   155 // CDialerNumberEntry::SetFocus
   167 // Delays the setting of focus or removes the focus
       
   168 // ---------------------------------------------------------------------------
       
   169 //
       
   170 void CDialerNumberEntry::SetFocus( TBool aFocus, TDrawNow aDrawNow )
       
   171     {
       
   172     DIALER_PRINT("numberentry::SetFocus<");  
       
   173     
       
   174     TBool vkbOpen = ( iEditor->AknEditorFlags() & EAknEditorFlagTouchInputModeOpened );
       
   175     
       
   176     iLateFocuser->Cancel(); 
       
   177     if ( aFocus && !vkbOpen )
       
   178         {
       
   179         // The setting of focus needs to be delayed, because otherwise
       
   180         // editors cursor is drawn first. Cursor can be seen clearly
       
   181         // when going from landscape mode homescreen to dialer (when
       
   182         // dialer's support for landscape mode has been removed)
       
   183         // The reason behind this is that giving a focus to editor will cause 
       
   184         // enabling of cursor in window server and the window server's
       
   185         // render plugin will draw the cursor first, before the 
       
   186         // dialer gets drawn. The delay in dialer drawing is caused by the
       
   187         // screen rotation from landscape to portrait.
       
   188         iLateFocuser->Start( TCallBack( SetLateFocus, this ) );
       
   189         }
       
   190     else 
       
   191         {       
       
   192         DoSetFocus( aFocus, aDrawNow );
       
   193         }
       
   194     DIALER_PRINT("numberentry::SetFocus>");
       
   195     }
       
   196     
       
   197 // ---------------------------------------------------------------------------
       
   198 // CDialerNumberEntry::SetLateFocus 
       
   199 // ---------------------------------------------------------------------------
       
   200 //
       
   201 TInt CDialerNumberEntry::SetLateFocus( TAny* aThis )
       
   202     {  
       
   203     DIALER_PRINT("numberentry::SetLateFocus<");
       
   204     CDialerNumberEntry* self = static_cast<CDialerNumberEntry*>( aThis );
       
   205 
       
   206     self->DoSetFocus( ETrue, ENoDrawNow );
       
   207     
       
   208     DIALER_PRINT("numberentry::SetLateFocus>");
       
   209     return KErrNone;
       
   210     }
       
   211     
       
   212 // ---------------------------------------------------------------------------
       
   213 // Set the focuss
       
   214 // ---------------------------------------------------------------------------
   156 // 
   215 // 
   157 // IsFocused() and iEditor->IsFocused() may return other values besides ETrue
   216 void CDialerNumberEntry::DoSetFocus( TBool aFocus, TDrawNow aDrawNow )
   158 // and EFalse. This is why we need to check their return values against zero
   217     {
   159 // and use the result in comparison against aFocus.
   218     DIALER_PRINT("numberentry::DoSetFocus<");  
   160 // ---------------------------------------------------------------------------
   219     // IsFocused() and iEditor->IsFocused() may return other values besides ETrue
   161 //
   220     // and EFalse. This is why we need to check their return values against zero
   162 void CDialerNumberEntry::SetFocus( TBool aFocus, TDrawNow aDrawNow )
   221     // and use the result in comparison against aFocus.
   163     {
   222     if ( aFocus != (IsFocused() ? ETrue : EFalse) )
   164     DIALER_PRINT("numberentry::SetFocus<");
       
   165     
       
   166     if ( aFocus != ( IsFocused() ? ETrue : EFalse ) )
       
   167         {
   223         {
   168         CCoeControl::SetFocus( aFocus, aDrawNow );
   224         CCoeControl::SetFocus( aFocus, aDrawNow );
   169         }
   225         }
   170     
   226     
   171     if ( aFocus != ( iEditor->IsFocused() ? ETrue : EFalse ) )
   227     if ( aFocus != (iEditor-> IsFocused() ? ETrue : EFalse ) )
   172         {
   228         {
   173         iEditor->SetFocus( aFocus );
   229         iEditor->SetFocus( aFocus );
   174         }
   230         }   
   175     
   231     DIALER_PRINT("numberentry::DoSetFocus>");  
   176     DIALER_PRINT("numberentry::SetFocus>");
   232     }
   177     }
       
   178 
       
   179 
   233 
   180 // ---------------------------------------------------------------------------
   234 // ---------------------------------------------------------------------------
   181 // CDialerNumberEntry::TextLength 
   235 // CDialerNumberEntry::TextLength 
   182 // ---------------------------------------------------------------------------
   236 // ---------------------------------------------------------------------------
   183 //
   237 //
   707 // ---------------------------------------------------------------------------
   761 // ---------------------------------------------------------------------------
   708 //
   762 //
   709 void CDialerNumberEntry::StartVirtualKeyBoard( )
   763 void CDialerNumberEntry::StartVirtualKeyBoard( )
   710     {
   764     {
   711     // To change focus to VKB, if not called VKB will not come visible
   765     // To change focus to VKB, if not called VKB will not come visible
       
   766     iLateFocuser->Cancel();
       
   767     DoSetFocus( ETrue, ENoDrawNow );
   712     iEikonEnv->SyncNotifyFocusObserversOfChangeInFocus();
   768     iEikonEnv->SyncNotifyFocusObserversOfChangeInFocus();
   713     iEditor->OpenVKB();
   769     iEditor->OpenVKB();
   714     }
   770     }
   715   
   771   
   716 // ---------------------------------------------------------------------------
   772 // ---------------------------------------------------------------------------
   891     iOperationMode = aMode;
   947     iOperationMode = aMode;
   892     }
   948     }
   893 
   949 
   894 // -----------------------------------------------------------------------------
   950 // -----------------------------------------------------------------------------
   895 // CDialerNumberEntry::Validate
   951 // CDialerNumberEntry::Validate
   896 //
       
   897 // Copied from cphonekeys.
       
   898 // -----------------------------------------------------------------------------
   952 // -----------------------------------------------------------------------------
   899 //
   953 //
   900 TBool CDialerNumberEntry::Validate( const TDesC& aString )
   954 TBool CDialerNumberEntry::Validate( const TDesC& aString )
   901     {
   955     {
   902     DIALER_PRINT("numberentry::Validate");
   956     DIALER_PRINT("numberentry::Validate");
   903     TLex input( aString );
   957     
       
   958     if ( aString.Length() == 0 )
       
   959         {
       
   960         return EFalse;
       
   961         }
       
   962     
       
   963     // check first character
   904     TPtrC valid( KPhoneValidChars );
   964     TPtrC valid( KPhoneValidChars );
   905 
   965     if ( valid.Locate( aString[0] ) == KErrNotFound )
   906     while ( valid.Locate( input.Peek() ) != KErrNotFound )
   966         {
   907         {
   967         return EFalse;
   908         input.Inc();
   968         }
   909         }
   969     
   910     
   970     // if vanitydialing feature is enabled, also capital A-Z are accepted after first character
   911     return !input.Remainder().Length();
   971     if ( FeatureManager::FeatureSupported( KFeatureIdFfHomeScreenVanityDialing ) )
       
   972         {
       
   973         valid.Set( KPhoneVanityValidChars );
       
   974         }
       
   975     
       
   976     // check rest of the string
       
   977     for ( TInt i = 1; i < aString.Length(); i++ )
       
   978         {
       
   979         if ( valid.Locate( aString[i] ) == KErrNotFound )
       
   980             {
       
   981             return EFalse;
       
   982             }
       
   983         }
       
   984     
       
   985     return ETrue;
   912     }
   986     }
   913 
   987 
   914 // End of File
   988 // End of File