×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Aug 2012
    Posts
    11

    Vibrate on setting item

    Hi,
    I have a settings view where I have an Binary item, CAknBinaryPopupSettingItem with pop up options as On/Off.
    i want the phone to vibrate for some time when the user selects On option from the settings. How can I do this?
    I have checked the Vibrate API and also made the vibrate function, but I don't know where to put it.

    This below code is from CppExamples of SDK
    _LIT(KBinaryText1, "On");
    _LIT(KBinaryText2, "Off");

    My Settings LoadList() is as follows.
    CAknBinaryPopupSettingItem* item10 = new (ELeave) CAknBinaryPopupSettingItem(10, iBinary);
    CleanupStack::PushL(item10);
    // The same resource id can be used for multiple binary setting pages.
    item10->ConstructL(isNumberedStyle, 10, KName10, icons, R_BINARY_SETTING_PAGE, -1, 0, R_POPUP_SETTING_BINARY_TEXTS);

    // Load texts dynamically.
    texts = item10->EnumeratedTextArray();
    texts->ResetAndDestroy();
    // Text 1
    text = KBinaryText1().AllocLC();
    enumText = new (ELeave) CAknEnumeratedText(0, text);
    CleanupStack::Pop(text);
    CleanupStack::PushL(enumText);
    texts->AppendL(enumText);
    CleanupStack::Pop(enumText);
    // Text 2
    text = KBinaryText2().AllocLC();
    enumText = new (ELeave) CAknEnumeratedText(1, text);
    CleanupStack::Pop(text);
    CleanupStack::PushL(enumText);
    texts->AppendL(enumText);
    CleanupStack::Pop(enumText);

    // Sets the correct text visible
    item10->LoadL();


    void CDynamicSettingListAppView:oVibrateL( TInt aDuration )
    {
    CHWRMVibra* vibra = CHWRMVibra::NewLC();

    if ( CHWRMVibra::EVibraModeON == vibra->VibraSettings() ) // get vibration setting in the user profile
    {
    vibra->StartVibraL( aDuration );
    }
    CleanupStack::PopAndDestroy( vibra );
    }
    Now where should i use DoVibrate() function so that it vibrates when user choses On option

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: Vibrate on setting item

    in general you would not use settings list items to catch user changing them, basically user would change the settings items and then select some otehr action in which you would first load thge setting liost values from the UI components to teh variables associated with them, and then use/save the values.

    So you might want to re-think the UI you want to use for user action here. Basically if you would want to catch the event user pressing the setting list itenm, you could try overwriting the HandleSettingPageEventL function.

  3. #3
    Registered User
    Join Date
    Aug 2012
    Posts
    11

    Re: Vibrate on setting item

    thanks yucca,
    I checked the radiobutton example http://www.developer.nokia.com/Commu..._settings_page
    It is working fine but it has only one setting item(radiobutton), but when the settings page open it directly displays the popup menu of radio button. I have two items ( binarypopup and enumerated ) in my settings page and want them to display and when i click on binarypopup item it should vibrate if it's value is chosen as ON

    (Refer to code below) when I try to use item10->SetSettingPageObserver() or item10->ExecuteLD() I am getting error as undefined idetified on both functions. I have my Settingview inherited from CCoecontrol and MAknSettingPageObserver
    What should I do to resolve it?

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: Vibrate on setting item

    basically just take the example you pointerd to, add your controls into the resource, and check in HandleSettingPageEventL when your selected item is clicked by the user.

  5. #5
    Registered User
    Join Date
    Aug 2012
    Posts
    11

    Re: Vibrate on setting item

    I tried that, but HandleSettingPageEventL is never called. I guess we have to add these 2 lines below ( as in Radiobutton example which is working fine in radio button) but when i put in my code these functions are 'undefined identifier'

    item->SetSettingPageObserver(this);
    item->ExecuteLD(CAknSettingPage::EUpdateWhenChanged);

    I am thinking it's because of the way the item is created
    CAknRadioButtonSettingPage* item=new (ELeave) CAknRadioButtonSettingPage(R_EXAMPLE_SETTING_PAGE,iSelection, array);
    and
    CAknEnumeratedTextPopupSettingItem* item1= new (ELeave) CAknEnumeratedTextPopupSettingItem(9, iEnumText);
    ??

  6. #6
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: Vibrate on setting item

    Uups, gotta say that I missed how the example was made, I have to say that I'm not certain what the person who made that was thinking or going after. I would suggest actually using the HandleSettingPageEventL inside the settings list, and not in any external class. Then it would be called nicely without any additional things.

  7. #7
    Registered User
    Join Date
    Aug 2012
    Posts
    11

    Re: Vibrate on setting item

    It is indeed inside Setting List
    SettingList::ConstructL(){
    ...
    iItemList = new (ELeave) CAknSettingItemList;
    iItemList->ConstructFromResourceL(R_DYNAMIC_LIST);
    LoadListL();
    ...
    }
    SettingList::LoadList(){
    //Radio button from example
    CDesCArrayFlat *array = CreateRadionButtonOptionsLC();
    CAknRadioButtonSettingPage* dialog =
    new (ELeave) CAknRadioButtonSettingPage(R_EXAMPLE_SETTING_PAGE, iSelection, array);
    CleanupStack::PushL(dialog);
    dialog->ConstructL();
    CleanupStack::Pop();//dialog
    dialog->SetSettingPageObserver(this);
    dialog->ExecuteLD(CAknSettingPage::EUpdateWhenChanged);
    CleanupStack::PopAndDestroy(); //array

    //from Dynamic Setting List Example
    TBool isNumberedStyle = iItemList->IsNumberedStyle();
    CArrayPtr<CGulIcon>* icons = iItemList->ListBox()->ItemDrawer()->FormattedCellData()->IconArray();

    //Binary popup setting item
    CAknBinaryPopupSettingItem* item10 = new (ELeave) CAknBinaryPopupSettingItem(10, iBinary);
    CleanupStack::PushL(item10);
    // The same resource id can be used for multiple binary setting pages.
    item10->ConstructL(isNumberedStyle, 10, KName10, icons, R_BINARY_SETTING_PAGE, -1, 0, R_POPUP_SETTING_BINARY_TEXTS);

    // Load texts dynamically.
    texts = item10->EnumeratedTextArray();
    texts->ResetAndDestroy();
    // Text 1
    text = KBinaryText1().AllocLC();
    enumText = new (ELeave) CAknEnumeratedText(0, text);
    CleanupStack::Pop(text);
    CleanupStack::PushL(enumText);
    texts->AppendL(enumText);
    CleanupStack::Pop(enumText);
    // Text 2
    text = KBinaryText2().AllocLC();
    enumText = new (ELeave) CAknEnumeratedText(1, text);
    CleanupStack::Pop(text);
    CleanupStack::PushL(enumText);
    texts->AppendL(enumText);
    CleanupStack::Pop(enumText);

    item10->LoadL();

    iItemList->SettingItemArray()->AppendL(item9);
    CleanupStack::Pop(item9);
    }

    Now when i open this view, radio button options pop up at first and when i select any of the options HandleSettingPageEventL() is indeed called, but when the Binary option window is shown and I change the options On/Off HandleSettingPageEventL () isn't called.
    SettingList.h is inherited from Ccoecontrol and MAknSettingPageObserver

  8. #8
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: Vibrate on setting item

    I would suggest debugging ti again, indeed it should be called for all controls.

  9. #9
    Registered User
    Join Date
    Aug 2012
    Posts
    11

    Re: Vibrate on setting item

    I have debugged it, still can't figure out the problem. Any help ??
    Or if anyone can provide any alternate solution for vibrating the phone when the user selects a option in Settings ( for eg: in CAknBinaryPopupSettingItem)

Similar Threads

  1. Load the setting items based on another setting item
    By yanamaddinaveen in forum Symbian User Interface
    Replies: 1
    Last Post: 2011-09-28, 08:27
  2. Disable a prticular item in my Setting Item list
    By TAHIR in forum Symbian User Interface
    Replies: 2
    Last Post: 2010-03-16, 05:26
  3. Setting list empty type setting item
    By denial347 in forum Symbian User Interface
    Replies: 1
    Last Post: 2009-04-05, 16:23
  4. Replies: 4
    Last Post: 2009-02-17, 21:24
  5. Setting Vibrate on Nokia 6061
    By KOlmstead85 in forum General Development Questions
    Replies: 1
    Last Post: 2007-01-31, 05:22

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×