From: Kimmo Hoikka Date: Fri, 3 Mar 2017 18:03:05 +0000 (-0800) Subject: Merge "Changed to use ImfManager for virtual keyboard APIs" into devel/master X-Git-Tag: dali_1.2.30~14 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=dfebb1e3da197e21bd7f4424ab65884b98f42fea;hp=-c Merge "Changed to use ImfManager for virtual keyboard APIs" into devel/master --- dfebb1e3da197e21bd7f4424ab65884b98f42fea diff --combined automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index 1ea11be,c1fc637..a4b3c70 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@@ -118,9 -118,15 +118,9 @@@ static Dali::Toolkit::TextField::InputS static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height) { - Integration::ResourceRequest* request = platform.GetRequest(); Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD ); Integration::ResourcePointer resource(bitmap); bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height); - - if(request) - { - platform.SetResourceLoaded(request->GetId(), request->GetType()->id, resource); - } } static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField) @@@ -648,6 -654,38 +648,38 @@@ int UtcDaliTextFieldSetPropertyP(void field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect( 0, 0, 1, 1 ) ); DALI_TEST_EQUALS( field.GetProperty >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect( 0, 0, 1, 1 ), TEST_LOCATION ); + // Check the input method setting + Property::Map propertyMap; + InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER; + InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD; + InputMethod::ActionButtonTitle::Type actionButton = InputMethod::ActionButtonTitle::GO; + int inputVariation = 1; + propertyMap["PANEL_LAYOUT"] = panelLayout; + propertyMap["AUTO_CAPITALISE"] = autoCapital; + propertyMap["ACTION_BUTTON"] = actionButton; + propertyMap["VARIATION"] = inputVariation; + field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap ); + + Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS ); + Property::Map map; + DALI_TEST_CHECK( value.Get( map ) ); + + int layout = 0; + DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) ); + DALI_TEST_EQUALS( static_cast(panelLayout), layout, TEST_LOCATION ); + + int capital = 0; + DALI_TEST_CHECK( map[ "AUTO_CAPITALISE" ].Get( capital ) ); + DALI_TEST_EQUALS( static_cast(autoCapital), capital, TEST_LOCATION ); + + int action = 0; + DALI_TEST_CHECK( map[ "ACTION_BUTTON" ].Get( action ) ); + DALI_TEST_EQUALS( static_cast(actionButton), action, TEST_LOCATION ); + + int variation = 0; + DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) ); + DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION ); + // Check input color property. field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW ); DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION ); @@@ -1834,6 -1872,9 +1866,9 @@@ int utcDaliTextFieldEvent07(void field.SetSize( 300.f, 50.f ); field.SetParentOrigin( ParentOrigin::TOP_LEFT ); field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + Property::Map propertyMap; + propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD; + field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@@ -2014,12 -2055,5 +2049,12 @@@ int utcDaliTextFieldStyleWhilstSelected DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION ); DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION ); + // Press Escape to increase coverage + application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up ) ); + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( !field.HasKeyInputFocus() ); + END_TEST; } diff --combined dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp index 469ea3e,e7dcd62..a5aa7ff --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@@ -24,7 -24,6 +24,6 @@@ #include #include #include - #include #include #include #include @@@ -995,6 -994,8 +994,8 @@@ void TextEditor::OnInitialize( EnableGestureDetection( static_cast( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) ); GetTapGestureDetector().SetMaximumTapsRequired( 2 ); + mImfManager = ImfManager::Get(); + self.TouchSignal().Connect( this, &TextEditor::OnTouched ); // Set BoundingBox to stage size if not already set. @@@ -1162,20 -1163,15 +1163,15 @@@ void TextEditor::OnKeyInputFocusGained( { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnKeyInputFocusGained %p\n", mController.Get() ); - VirtualKeyboard::StatusChangedSignal().Connect( this, &TextEditor::KeyboardStatusChanged ); + mImfManager.StatusChangedSignal().Connect( this, &TextEditor::KeyboardStatusChanged ); - ImfManager imfManager = ImfManager::Get(); + mImfManager.EventReceivedSignal().Connect( this, &TextEditor::OnImfEvent ); - if ( imfManager ) - { - imfManager.EventReceivedSignal().Connect( this, &TextEditor::OnImfEvent ); + // Notify that the text editing start. + mImfManager.Activate(); - // Notify that the text editing start. - imfManager.Activate(); - - // When window gain lost focus, the imf manager is deactivated. Thus when window gain focus again, the imf manager must be activated. - imfManager.SetRestoreAfterFocusLost( true ); - } + // When window gain lost focus, the imf manager is deactivated. Thus when window gain focus again, the imf manager must be activated. + mImfManager.SetRestoreAfterFocusLost( true ); ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() ); @@@ -1193,19 -1189,15 +1189,15 @@@ void TextEditor::OnKeyInputFocusLost( { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor:OnKeyInputFocusLost %p\n", mController.Get() ); - VirtualKeyboard::StatusChangedSignal().Disconnect( this, &TextEditor::KeyboardStatusChanged ); + mImfManager.StatusChangedSignal().Disconnect( this, &TextEditor::KeyboardStatusChanged ); - ImfManager imfManager = ImfManager::Get(); - if ( imfManager ) - { - // The text editing is finished. Therefore the imf manager don't have restore activation. - imfManager.SetRestoreAfterFocusLost( false ); + // The text editing is finished. Therefore the imf manager don't have restore activation. + mImfManager.SetRestoreAfterFocusLost( false ); - // Notify that the text editing finish. - imfManager.Deactivate(); + // Notify that the text editing finish. + mImfManager.Deactivate(); - imfManager.EventReceivedSignal().Disconnect( this, &TextEditor::OnImfEvent ); - } + mImfManager.EventReceivedSignal().Disconnect( this, &TextEditor::OnImfEvent ); ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() ); @@@ -1223,11 -1215,7 +1215,7 @@@ void TextEditor::OnTap( const TapGestur { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnTap %p\n", mController.Get() ); - // Show the keyboard if it was hidden. - if (!VirtualKeyboard::IsVisible()) - { - VirtualKeyboard::Show(); - } + mImfManager.Activate(); // Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x, gesture.localPoint.y ); @@@ -1242,11 -1230,7 +1230,7 @@@ void TextEditor::OnPan( const PanGestur void TextEditor::OnLongPress( const LongPressGesture& gesture ) { - // Show the keyboard if it was hidden. - if (!VirtualKeyboard::IsVisible()) - { - VirtualKeyboard::Show(); - } + mImfManager.Activate(); mController->LongPressEvent( gesture.state, gesture.localPoint.x, gesture.localPoint.y ); @@@ -1259,12 -1243,7 +1243,12 @@@ bool TextEditor::OnKeyEvent( const KeyE if( Dali::DALI_KEY_ESCAPE == event.keyCode ) // Make a Dali key code for this { - ClearKeyInputFocus(); + // Make sure ClearKeyInputFocus when only key is up + if( event.state == KeyEvent::Up ) + { + ClearKeyInputFocus(); + } + return true; } diff --combined dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index a32e7f5,2aff8e4..3e2c606 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@@ -23,7 -23,6 +23,6 @@@ #include #include #include - #include #include #include #include @@@ -32,6 -31,7 +31,7 @@@ #include #include #include + #include #include #include #include @@@ -590,8 -590,18 +590,18 @@@ void TextField::SetProperty( BaseObject } case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS: { - const Property::Map map = value.Get(); - VirtualKeyboard::ApplySettings( map ); + const Property::Map* map = value.GetMap(); + if (map) + { + impl.mInputMethodOptions.ApplyProperty( *map ); + } + impl.mController->SetInputModePassword( impl.mInputMethodOptions.IsPassword() ); + + Toolkit::Control control = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl(); + if (control == textField) + { + impl.mImfManager.ApplyOptions( impl.mInputMethodOptions ); + } break; } case Toolkit::TextField::Property::INPUT_COLOR: @@@ -994,6 -1004,9 +1004,9 @@@ Property::Value TextField::GetProperty } case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS: { + Property::Map map; + impl.mInputMethodOptions.RetrieveProperty( map ); + value = map; break; } case Toolkit::TextField::Property::INPUT_COLOR: @@@ -1153,6 -1166,8 +1166,8 @@@ void TextField::OnInitialize( EnableGestureDetection( static_cast( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) ); GetTapGestureDetector().SetMaximumTapsRequired( 2 ); + mImfManager = ImfManager::Get(); + self.TouchSignal().Connect( this, &TextField::OnTouched ); // Set BoundingBox to stage size if not already set. @@@ -1308,20 -1323,17 +1323,17 @@@ void TextField::OnKeyInputFocusGained( { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get() ); - VirtualKeyboard::StatusChangedSignal().Connect( this, &TextField::KeyboardStatusChanged ); + mImfManager.ApplyOptions( mInputMethodOptions ); - ImfManager imfManager = ImfManager::Get(); + mImfManager.StatusChangedSignal().Connect( this, &TextField::KeyboardStatusChanged ); - if ( imfManager ) - { - imfManager.EventReceivedSignal().Connect( this, &TextField::OnImfEvent ); + mImfManager.EventReceivedSignal().Connect( this, &TextField::OnImfEvent ); - // Notify that the text editing start. - imfManager.Activate(); + // Notify that the text editing start. + mImfManager.Activate(); - // When window gain lost focus, the imf manager is deactivated. Thus when window gain focus again, the imf manager must be activated. - imfManager.SetRestoreAfterFocusLost( true ); - } + // When window gain lost focus, the imf manager is deactivated. Thus when window gain focus again, the imf manager must be activated. + mImfManager.SetRestoreAfterFocusLost( true ); ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() ); @@@ -1339,19 -1351,14 +1351,14 @@@ void TextField::OnKeyInputFocusLost( { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField:OnKeyInputFocusLost %p\n", mController.Get() ); - VirtualKeyboard::StatusChangedSignal().Disconnect( this, &TextField::KeyboardStatusChanged ); + mImfManager.StatusChangedSignal().Disconnect( this, &TextField::KeyboardStatusChanged ); + // The text editing is finished. Therefore the imf manager don't have restore activation. + mImfManager.SetRestoreAfterFocusLost( false ); - ImfManager imfManager = ImfManager::Get(); - if ( imfManager ) - { - // The text editing is finished. Therefore the imf manager don't have restore activation. - imfManager.SetRestoreAfterFocusLost( false ); - - // Notify that the text editing finish. - imfManager.Deactivate(); + // Notify that the text editing finish. + mImfManager.Deactivate(); - imfManager.EventReceivedSignal().Disconnect( this, &TextField::OnImfEvent ); - } + mImfManager.EventReceivedSignal().Disconnect( this, &TextField::OnImfEvent ); ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() ); @@@ -1369,11 -1376,7 +1376,7 @@@ void TextField::OnTap( const TapGesture { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnTap %p\n", mController.Get() ); - // Show the keyboard if it was hidden. - if (!VirtualKeyboard::IsVisible()) - { - VirtualKeyboard::Show(); - } + mImfManager.Activate(); // Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x, gesture.localPoint.y ); @@@ -1388,11 -1391,7 +1391,7 @@@ void TextField::OnPan( const PanGesture void TextField::OnLongPress( const LongPressGesture& gesture ) { - // Show the keyboard if it was hidden. - if (!VirtualKeyboard::IsVisible()) - { - VirtualKeyboard::Show(); - } + mImfManager.Activate(); mController->LongPressEvent( gesture.state, gesture.localPoint.x, gesture.localPoint.y ); @@@ -1403,14 -1402,10 +1402,14 @@@ bool TextField::OnKeyEvent( const KeyEv { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyEvent %p keyCode %d\n", mController.Get(), event.keyCode ); - if( Dali::DALI_KEY_ESCAPE == event.keyCode || - "Return" == event.keyPressedName ) // Make a Dali key code for this + if( Dali::DALI_KEY_ESCAPE == event.keyCode || "Return" == event.keyPressedName ) // Make a Dali key code for this { - ClearKeyInputFocus(); + // Make sure ClearKeyInputFocus when only key is up + if( event.state == KeyEvent::Up ) + { + ClearKeyInputFocus(); + } + return true; } diff --combined dali-toolkit/internal/text/text-controller-impl.cpp index e250542,c7adc7b..2c1b772 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@@ -55,6 -55,7 +55,7 @@@ struct SelectionBoxInf const float MAX_FLOAT = std::numeric_limits::max(); const float MIN_FLOAT = std::numeric_limits::min(); const Dali::Toolkit::Text::CharacterDirection LTR = false; ///< Left To Right direction + const uint32_t STAR = 0x2A; } // namespace @@@ -100,7 -101,8 +101,8 @@@ EventData::EventData( DecoratorPtr deco mScrollAfterUpdatePosition( false ), mScrollAfterDelete( false ), mAllTextSelected( false ), - mUpdateInputStyle( false ) + mUpdateInputStyle( false ), + mPasswordInput( false ) { mImfManager = ImfManager::Get(); } @@@ -767,8 -769,24 +769,24 @@@ bool Controller::Impl::UpdateModel( Ope return false; } - Vector& utf32Characters = mModel->mLogicalModel->mText; + Vector utf32CharactersStar; + const Length characterCount = mModel->mLogicalModel->mText.Count(); + const bool isPasswordInput = ( mEventData != NULL && mEventData->mPasswordInput && + !mEventData->mIsShowingPlaceholderText && characterCount > 0 ); + + if (isPasswordInput) + { + utf32CharactersStar.Resize( characterCount ); + + uint32_t* begin = utf32CharactersStar.Begin(); + uint32_t* end = begin + characterCount; + while ( begin < end ) + { + *begin++ = STAR; + } + } + Vector& utf32Characters = isPasswordInput ? utf32CharactersStar : mModel->mLogicalModel->mText; const Length numberOfCharacters = utf32Characters.Count(); // Index to the first character of the first paragraph to be updated. @@@ -2198,12 -2216,6 +2216,12 @@@ void Controller::Impl::RepositionSelect mEventData->mUpdateRightSelectionPosition = true; mEventData->mUpdateHighlightBox = true; + // It may happen an IMF commit event arrives before the selection event + // if the IMF manager is in pre-edit state. The commit event will set the + // mEventData->mUpdateCursorPosition flag to true. If it's not set back + // to false, the highlight box won't be updated. + mEventData->mUpdateCursorPosition = false; + mEventData->mScrollAfterUpdatePosition = ( mEventData->mLeftSelectionPosition != mEventData->mRightSelectionPosition ); } else @@@ -2562,7 -2574,7 +2580,7 @@@ CharacterIndex Controller::Impl::Calcul const Script script = mModel->mLogicalModel->GetScript( index ); if( HasLigatureMustBreak( script ) ) { - // Prevents to jump the whole Latin ligatures like fi, ff, or Arabic ï»», ... + // Prevents to jump the whole Latin ligatures like fi, ff, or Arabic ï»», ... numberOfCharacters = 1u; } }