[Tizen] Add AutofillContainer class and autofill implementation 82/217482/2 accepted/tizen/unified/20191113.123440 submit/tizen/20191113.050030
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Tue, 8 Oct 2019 05:42:29 +0000 (14:42 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Wed, 13 Nov 2019 04:58:49 +0000 (04:58 +0000)
- Created AutofillContainer to connect with AutofillGroup and AutofillItem.
- Added some Autofill implementation in Control and TextField.

Change-Id: I6df583273aa9c91eafd3de8ea44193b9bb199523

CMakeLists.txt
dali-toolkit/devel-api/controls/text-controls/autofill-container.cpp [new file with mode: 0644]
dali-toolkit/devel-api/controls/text-controls/autofill-container.h [new file with mode: 0644]
dali-toolkit/devel-api/file.list
dali-toolkit/internal/controls/control/control-data-impl.cpp
dali-toolkit/internal/controls/control/control-data-impl.h
dali-toolkit/internal/controls/text-controls/autofill-container-impl.cpp [new file with mode: 0755]
dali-toolkit/internal/controls/text-controls/autofill-container-impl.h [new file with mode: 0644]
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.h
dali-toolkit/internal/file.list

index ff17e64..dbd38b4 100755 (executable)
@@ -51,6 +51,7 @@ SET ( SOURCES ${SOURCES}
   ${devel_api_src_dir}/controls/popup/popup.cpp\r
   ${devel_api_src_dir}/controls/shadow-view/shadow-view.cpp\r
   ${devel_api_src_dir}/controls/super-blur-view/super-blur-view.cpp\r
+  ${devel_api_src_dir}/controls/text-controls/autofill-container.cpp\r
   ${devel_api_src_dir}/controls/text-controls/text-editor-devel.cpp\r
   ${devel_api_src_dir}/controls/text-controls/text-field-devel.cpp\r
   ${devel_api_src_dir}/controls/text-controls/text-selection-popup.cpp\r
@@ -161,6 +162,7 @@ SET( SOURCES ${SOURCES}
    ${internal_src_dir}/controls/slider/slider-impl.cpp\r
    ${internal_src_dir}/controls/super-blur-view/super-blur-view-impl.cpp\r
    ${internal_src_dir}/controls/table-view/table-view-impl.cpp\r
+   ${internal_src_dir}/controls/text-controls/autofill-container-impl.cpp\r
    ${internal_src_dir}/controls/text-controls/text-editor-impl.cpp\r
    ${internal_src_dir}/controls/text-controls/text-field-impl.cpp\r
    ${internal_src_dir}/controls/text-controls/text-label-impl.cpp\r
diff --git a/dali-toolkit/devel-api/controls/text-controls/autofill-container.cpp b/dali-toolkit/devel-api/controls/text-controls/autofill-container.cpp
new file mode 100644 (file)
index 0000000..e75ca6f
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2019 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/text-controls/autofill-container.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/text-controls/autofill-container-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+AutofillContainer AutofillContainer::New( const std::string& name )
+{
+  return Internal::AutofillContainer::New( name );
+}
+
+AutofillContainer::AutofillContainer()
+{
+}
+
+AutofillContainer::AutofillContainer( const AutofillContainer& handle )
+: BaseHandle(handle)
+{
+}
+
+AutofillContainer& AutofillContainer::operator=( const AutofillContainer& handle )
+{
+  BaseHandle::operator=(handle);
+  return *this;
+}
+
+AutofillContainer::~AutofillContainer()
+{
+}
+
+AutofillContainer AutofillContainer::DownCast( BaseHandle handle )
+{
+  return AutofillContainer( dynamic_cast<Internal::AutofillContainer*>( handle.GetObjectPtr() ) );
+}
+
+
+void AutofillContainer::AddAutofillItem( Control control, Property::Index propertyIndex, const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool isSensitive )
+{
+  GetImpl(*this).AddAutofillItem( control, propertyIndex, id, label, hint, isSensitive );
+}
+
+void AutofillContainer::RemoveAutofillItem( Control control )
+{
+  GetImpl(*this).RemoveAutofillItem( control );
+}
+
+void AutofillContainer::SetFocusedControl( Toolkit::Control focused )
+{
+  GetImpl(*this).SetFocusedControl( focused );
+}
+
+Toolkit::Control AutofillContainer::GetFocusedControl()
+{
+  return GetImpl(*this).GetFocusedControl();
+}
+
+void AutofillContainer::SaveAutofillData()
+{
+  GetImpl(*this).SaveAutofillData();
+}
+
+void AutofillContainer::RequestFillData()
+{
+  GetImpl(*this).RequestFillData();
+}
+
+const std::string& AutofillContainer::GetAutofillServiceName() const
+{
+  return GetImpl(*this).GetAutofillServiceName();
+}
+
+const std::string& AutofillContainer::GetAutofillServiceMessage() const
+{
+  return GetImpl(*this).GetAutofillServiceMessage();
+}
+
+const std::string& AutofillContainer::GetAutofillServiceImagePath() const
+{
+  return GetImpl(*this).GetAutofillServiceImagePath();
+}
+
+unsigned int AutofillContainer::GetListCount()
+{
+  return GetImpl(*this).GetListCount();
+}
+
+const std::string& AutofillContainer::GetListItem( unsigned int index ) const
+{
+  return GetImpl(*this).GetListItem( index );
+}
+
+void AutofillContainer::SetSelectedItem( const std::string& selected )
+{
+  GetImpl(*this).SetSelectedItem( selected );
+}
+
+AutofillContainer::AutofillContainer( Internal::AutofillContainer* implementation )
+: BaseHandle(implementation)
+{
+}
+
+AutofillContainer::AuthenticationSignalType& AutofillContainer::AutofillServiceShownSignal()
+{
+  return GetImpl(*this).AutofillServiceShownSignal();
+}
+
+AutofillContainer::ListShownSignalType& AutofillContainer::AutofillListShownSignal()
+{
+  return GetImpl(*this).AutofillListShownSignal();
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/devel-api/controls/text-controls/autofill-container.h b/dali-toolkit/devel-api/controls/text-controls/autofill-container.h
new file mode 100644 (file)
index 0000000..eecad1a
--- /dev/null
@@ -0,0 +1,219 @@
+#ifndef DALI_TOOLKIT_AUTO_FILL_CONTAINER_H
+#define DALI_TOOLKIT_AUTO_FILL_CONTAINER_H
+
+/*
+ * Copyright (c) 2019 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/autofill-item.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal DALI_INTERNAL
+{
+class AutofillContainer;
+}
+
+/**
+ * @brief AutofillContainer controls several text input boxes (Dali::Toolkit::TextField and Dali::Toolkit::TextEditor).
+ *
+ * It can make these editors a group of text boxes.
+ */
+class DALI_TOOLKIT_API AutofillContainer : public BaseHandle
+{
+public:
+
+  // TODO : Need to update parameter and return value according to each Signal
+  typedef Signal< void (AutofillContainer&) > AuthenticationSignalType;  ///< Authentication Signal Type
+  typedef Signal< void (Control&) > ListShownSignalType;                 ///<  List Shown Signal Type
+
+public:
+
+  /**
+   * @brief Creates the AutofillContainer.
+   *
+   * @param[in] name The AutofillContainer name
+   * @return A handle to the AutofillContainer
+   */
+  static AutofillContainer New( const std::string& name );
+
+  /**
+   * @brief Creates an empty handle.
+   */
+  AutofillContainer();
+
+  /**
+   * @brief Copy constructor.
+   *
+   * @param[in] handle The handle to copy from
+   */
+  AutofillContainer( const AutofillContainer& handle );
+
+  /**
+   * @brief Assignment operator.
+   *
+   * @param[in] handle The handle to copy from
+   * @return A reference to this
+   */
+  AutofillContainer& operator=( const AutofillContainer& handle );
+
+  /**
+   * @brief Destructor.
+   *
+   * This is non-virtual since derived Handle types must not contain data or virtual methods.
+   */
+  ~AutofillContainer();
+
+  /**
+   * @brief Downcasts a handle to AutofillContainer.
+   *
+   * If the BaseHandle points is a AutofillContainer, the downcast returns a valid handle.
+   * If not, the returned handle is left empty.
+   *
+   * @param[in] handle Handle to an object
+   * @return Handle to a AutofillContainer or an empty handle
+   */
+  static AutofillContainer DownCast( BaseHandle handle );
+
+  /**
+   * @brief Adds Control and AutofillItem information to Autofill Container.
+   *
+   * @param[in] control The control to be added to Autofill Container
+   * @param[in] propertyIndex The Property to be filled automatically of each Control
+   * @param[in] id A unique ID that does not always change on each launching
+   * @param[in] label An auxiliary means to guess heuristically what data is
+   * @param[in] hint The Hint - id (username), name, password, phone, credit card number, organization, and so on
+   * @param[in] isSensitive Whether this information is a sensitive data or not
+   */
+  void AddAutofillItem( Control control, Property::Index propertyIndex, const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool isSensitive );
+
+  /**
+   * @brief Removes Control and its AutofillItem information to Autofill Container.
+   *
+   * @param[in] control The control to be removed
+   */
+  void RemoveAutofillItem( Control control );
+
+  /**
+   * @brief Sets that a control is focused.
+   *
+   * @param focused The focused control
+   */
+  void SetFocusedControl( Toolkit::Control focused );
+
+  /**
+   * @brief Gets the focused control.
+   *
+   * @return The focused control
+   */
+  Toolkit::Control GetFocusedControl();
+
+  /**
+   * @brief Stores autofill data.
+   */
+  void SaveAutofillData();
+
+  /**
+   * @brief Sends a request for filling the data.
+   */
+  void RequestFillData();
+
+  /**
+   * @brief Gets the Autofill Service Name.
+   *
+   * @return Autofill Service Name
+   */
+  const std::string& GetAutofillServiceName() const;
+
+  /**
+   * @brief Gets the Autofill Service Message.
+   *
+   * @return Autofill Service Message
+   */
+  const std::string& GetAutofillServiceMessage() const;
+
+  /**
+   * @brief Gets the Autofill Service Image Path.
+   *
+   * @return Autofill Service Image Path
+   */
+  const std::string& GetAutofillServiceImagePath() const;
+
+  /**
+   * @brief Gets the number of list items. (The presentation text of Autofill)
+   *
+   * @return The number of list items
+   */
+  unsigned int GetListCount();
+
+  /**
+   * @brief Gets the list item of the index.
+   *
+   * @param[in] index The index for the list
+   * @return The list item of the index
+   */
+  const std::string& GetListItem( unsigned int index ) const;
+
+  /**
+   * @brief Sets the selected item to fill out.
+   *
+   * @param[in] selected The selected item
+   */
+  void SetSelectedItem( const std::string& selected );
+
+public:
+  // Signals
+
+  /**
+   * @brief AutofillServiceShownSignal
+   *
+   * @return The signal containing the received data
+   */
+  AuthenticationSignalType& AutofillServiceShownSignal();
+
+  /**
+   * @brief AutofillListShownSignal
+   *
+   * @return The signal containing the received data
+   */
+  ListShownSignalType& AutofillListShownSignal();
+
+
+public: // Not intended for application developers
+
+  /**
+   * @brief Creates a handle using the Toolkit::Internal implementation.
+   *
+   * @param[in] implementation The Control implementation
+   */
+  DALI_INTERNAL AutofillContainer( Internal::AutofillContainer* implementation );
+
+};
+
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_AUTO_FILL_CONTAINER_H
index 41fae57..fb09d46 100644 (file)
@@ -24,6 +24,7 @@ SET( devel_api_src_files
   ${devel_api_src_dir}/controls/scene3d-view/scene3d-view.cpp
   ${devel_api_src_dir}/controls/shadow-view/shadow-view.cpp
   ${devel_api_src_dir}/controls/super-blur-view/super-blur-view.cpp
+  ${devel_api_src_dir}/controls/text-controls/autofill-container.cpp
   ${devel_api_src_dir}/controls/text-controls/text-editor-devel.cpp
   ${devel_api_src_dir}/controls/text-controls/text-field-devel.cpp
   ${devel_api_src_dir}/controls/text-controls/text-selection-popup.cpp
@@ -169,6 +170,7 @@ SET( devel_api_super_blur_view_header_files
 )
 
 SET( devel_api_text_controls_header_files
+  ${devel_api_src_dir}/controls/text-controls/autofill-container.h
   ${devel_api_src_dir}/controls/text-controls/text-editor-devel.h
   ${devel_api_src_dir}/controls/text-controls/text-field-devel.h
   ${devel_api_src_dir}/controls/text-controls/text-label-devel.h
index aa11d14..72fd212 100755 (executable)
@@ -312,7 +312,6 @@ const PropertyRegistration Control::Impl::PROPERTY_12( typeRegistration, "rightF
 const PropertyRegistration Control::Impl::PROPERTY_13( typeRegistration, "upFocusableActorId",    Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID,   Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
 const PropertyRegistration Control::Impl::PROPERTY_14( typeRegistration, "downFocusableActorId",  Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
 
-
 Control::Impl::Impl( Control& controlImpl )
 : mControlImpl( controlImpl ),
   mState( Toolkit::DevelControl::NORMAL ),
@@ -337,9 +336,12 @@ Control::Impl::Impl( Control& controlImpl )
   mLongPressGestureDetector(),
   mTooltip( NULL ),
   mInputMethodContext(),
+  mAutofillItem(),
+  mAutofillContainer(),
   mFlags( Control::ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
   mIsKeyboardNavigationSupported( false ),
-  mIsKeyboardFocusGroup( false )
+  mIsKeyboardFocusGroup( false ),
+  mIsAutofillEnabled( false )
 {
 }
 
@@ -1400,6 +1402,36 @@ DevelControl::VisualEventSignalType& Control::Impl::VisualEventSignal()
   return mVisualEventSignal;
 }
 
+void Control::Impl::SetAutofillEnabled( bool autofillEnabled )
+{
+  mIsAutofillEnabled = autofillEnabled;
+}
+
+bool Control::Impl::IsAutofillEnabled()
+{
+  return mIsAutofillEnabled;
+}
+
+void Control::Impl::SetAutofillItemHandle( Dali::AutofillItem item )
+{
+  mAutofillItem = item;
+}
+
+Dali::AutofillItem Control::Impl::GetAutofillItemHandle()
+{
+  return mAutofillItem;
+}
+
+void Control::Impl::SetAutofillContainer( Toolkit::AutofillContainer container )
+{
+  mAutofillContainer = container;
+}
+
+Toolkit::AutofillContainer Control::Impl::GetAutofillContainer()
+{
+  return mAutofillContainer;
+}
+
 } // namespace Internal
 
 } // namespace Toolkit
index 2223215..561460f 100755 (executable)
 // EXTERNAL INCLUDES
 #include <dali/public-api/object/type-registry.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali/devel-api/adaptor-framework/autofill-item.h>
+#include <dali/devel-api/adaptor-framework/autofill-manager.h>
 #include <string>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/visuals/visual-event-observer.h>
 #include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali-toolkit/devel-api/controls/text-controls/autofill-container.h>
 #include <dali/devel-api/common/owner-container.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
 #include <dali-toolkit/internal/controls/tooltip/tooltip.h>
@@ -336,6 +339,42 @@ public:
    */
   DevelControl::VisualEventSignalType& VisualEventSignal();
 
+  /**
+   * @brief Sets whether the Autofill functionality is enabled.
+   * @param[in] autofillEnabled Set true when Autofill should be enabled.
+   */
+  void SetAutofillEnabled( bool autofillEnabled );
+
+  /**
+   * @brief Check if the Autofill framework is enabled.
+   * @return True if Autofill is enabled
+   */
+  bool IsAutofillEnabled();
+
+  /**
+   * @brief Sets AutofillItemHandle
+   * @param item AutofillItem handle
+   */
+  void SetAutofillItemHandle( Dali::AutofillItem item );
+
+  /**
+   * @brief Gets AutofillItemHandle
+   * @return AutofillItem handle
+   */
+  Dali::AutofillItem GetAutofillItemHandle();
+
+  /**
+   * @brief Sets AutofillContainer which this control belongs to.
+   * @param[in] container
+   */
+  void SetAutofillContainer( Toolkit::AutofillContainer container );
+
+  /**
+   * @brief Gets AutofillContainer that the control belongs to.
+   * @return AutofillContainer handle
+   */
+  Toolkit::AutofillContainer GetAutofillContainer();
+
 private:
 
   /**
@@ -408,10 +447,13 @@ public:
   TooltipPtr mTooltip;
 
   InputMethodContext mInputMethodContext;
+  AutofillItem mAutofillItem;
+  Toolkit::AutofillContainer mAutofillContainer;
 
   ControlBehaviour mFlags : CONTROL_BEHAVIOUR_FLAG_COUNT;    ///< Flags passed in from constructor.
   bool mIsKeyboardNavigationSupported :1;  ///< Stores whether keyboard navigation is supported by the control.
   bool mIsKeyboardFocusGroup :1;           ///< Stores whether the control is a focus group.
+  bool mIsAutofillEnabled : 1;             ///< Stroes whether the Autofill functionality is enabled.
 
   RegisteredVisualContainer mRemoveVisuals;         ///< List of visuals that are being replaced by another visual once ready
 
diff --git a/dali-toolkit/internal/controls/text-controls/autofill-container-impl.cpp b/dali-toolkit/internal/controls/text-controls/autofill-container-impl.cpp
new file mode 100755 (executable)
index 0000000..6c9628b
--- /dev/null
@@ -0,0 +1,332 @@
+/*
+ * Copyright (c) 2019 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/internal/controls/text-controls/autofill-container-impl.h>
+
+// EXTERNAL INCLUDES
+#include <cstring> // for strcmp
+#include <dali/public-api/object/type-registry-helper.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/control/control-data-impl.h>
+#include <dali-toolkit/internal/controls/text-controls/text-field-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace
+{
+
+#if defined ( DEBUG_ENABLED )
+  Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_AUTOFILL_CONTAINER");
+#endif
+
+// Type registration
+BaseHandle Create()
+{
+  return Toolkit::AutofillContainer::New( "" );
+}
+
+// Setup properties, signals and actions using the type-registry.
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::AutofillContainer, Dali::BaseHandle, Create );
+
+DALI_SIGNAL_REGISTRATION( Toolkit, AutofillContainer, "serviceShown",   SIGNAL_SERVICE_SHOWN )
+DALI_SIGNAL_REGISTRATION( Toolkit, AutofillContainer, "listShown",      SIGNAL_LIST_SHOWN )
+
+DALI_TYPE_REGISTRATION_END()
+
+} // namespace
+
+Toolkit::AutofillContainer AutofillContainer::New( const std::string& name )
+{
+  // Create the implementation, temporarily owned by this handle on stack
+  Internal::AutofillContainer* impl = new AutofillContainer();
+
+  // Pass ownership to CustomActor handle
+  Toolkit::AutofillContainer handle( impl );
+  impl->Initialize( name );
+
+  return handle;
+}
+
+void AutofillContainer::Initialize( const std::string& name )
+{
+  mAutofillManager = Dali::AutofillManager::Get();
+  mAutofillGroup = mAutofillManager.CreateAutofillGroup( name );
+
+  // If the authentication is needed, AuthenticationReceivedSignal would be emitted.
+  mAutofillManager.AuthenticationReceivedSignal().Connect( mSlotDelegate, &AutofillContainer::OnAutofillAuthReceived );
+
+  // If the data to be filled is present, FillResponseReceivedSignal would be emitted.
+  mAutofillManager.FillResponseReceivedSignal().Connect( mSlotDelegate, &AutofillContainer::OnDataFillReceived );
+
+  // If the values to be filled are multiple, ListEventSignal would be emitted.
+  mAutofillManager.ListEventSignal().Connect( mSlotDelegate, &AutofillContainer::OnListReceived );
+}
+
+void AutofillContainer::AddAutofillItem( Dali::Toolkit::Control control, Dali::Property::Index propertyIndex, const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool isSensitive )
+{
+  if( control )
+  {
+    Dali::AutofillItem item = mAutofillManager.CreateAutofillItem( id, label, static_cast<Dali::AutofillItem::Hint>(hint), isSensitive );
+
+    Internal::Control& controlImpl = GetImplementation( control );
+    Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
+    controlDataImpl.SetAutofillContainer( this );
+    controlDataImpl.SetAutofillEnabled( true );
+    controlDataImpl.SetAutofillItemHandle( item ); // TODO : This instance would be here as... std::map or pair
+
+    mAutofillGroup.AddAutofillItem( item );
+
+    mPropertyIndex = propertyIndex;
+
+    // TODO : Remove the mControlItemList below and replace it.
+    mControlList.push_back( std::pair< Dali::Toolkit::Control, Dali::AutofillItem >( control, item ) );
+
+    // Push back a Control to the list
+    mControlItemList.push_back( control );
+  }
+}
+
+void AutofillContainer::RemoveAutofillItem( Dali::Toolkit::Control control )
+{
+  if( control )
+  {
+    Internal::Control& controlImpl = GetImplementation( control );
+    Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
+    controlDataImpl.SetAutofillEnabled( false );
+    // TODO : Put the control out the list
+  }
+}
+
+Dali::AutofillGroup AutofillContainer::GetAutofillGroup()
+{
+  return mAutofillGroup;
+}
+
+void AutofillContainer::SetFocusedControl( Toolkit::Control focused )
+{
+  mCurrentFocused = focused;
+}
+
+Toolkit::Control AutofillContainer::GetFocusedControl()
+{
+  return mCurrentFocused;
+}
+
+void AutofillContainer::SaveAutofillData()
+{
+  for( std::vector<Dali::Toolkit::Control>::iterator iter = mControlItemList.begin(), endIter = mControlItemList.end(); iter != endIter; ++iter )
+  {
+    std::string controlValue = (*iter).GetProperty<std::string>( mPropertyIndex );
+    Internal::Control& controlImpl = GetImplementation( *iter );
+    Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
+    controlDataImpl.GetAutofillItemHandle().SetSaveValue( controlValue );
+  }
+
+  // Sends request to save the current autofill data
+  mAutofillGroup.SaveAutofillData();
+  mAutofillManager.SaveAutofillData( mAutofillGroup );
+}
+
+void AutofillContainer::RequestFillData()
+{
+  // Sends fill request to fill out the data.
+  mAutofillGroup.SendFillRequest();
+}
+
+void AutofillContainer::SetAutofillServiceName( const std::string& serviceName )
+{
+  mAutofillServiceName = serviceName;
+}
+
+const std::string& AutofillContainer::GetAutofillServiceName() const
+{
+  return mAutofillServiceName;
+}
+
+void AutofillContainer::SetAutofillServiceMessage( const std::string& serviceMessage )
+{
+  mAutofillServiceMessage = serviceMessage;
+}
+
+const std::string& AutofillContainer::GetAutofillServiceMessage() const
+{
+  return mAutofillServiceMessage;
+}
+
+void AutofillContainer::SetAutofillServiceImagePath( const std::string& serviceImagePath )
+{
+  mAutofillServiceImagePath = serviceImagePath;
+}
+
+const std::string& AutofillContainer::GetAutofillServiceImagePath() const
+{
+  return mAutofillServiceImagePath;
+}
+
+unsigned int AutofillContainer::GetListCount()
+{
+  Toolkit::Control control = mCurrentFocused;
+  Internal::Control& controlImpl = GetImplementation( control );
+  Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
+  return controlDataImpl.GetAutofillItemHandle().GetFillValueCount();
+}
+
+const std::string& AutofillContainer::GetListItem( unsigned int index ) const
+{
+  Toolkit::Control control = mCurrentFocused;
+  Internal::Control& controlImpl = GetImplementation( control );
+  Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
+  return controlDataImpl.GetAutofillItemHandle().GetPresentationText( index );
+}
+
+void AutofillContainer::SetSelectedItem( const std::string& selected )
+{
+  Toolkit::Control control = mCurrentFocused;
+  Internal::Control& controlImpl = GetImplementation( control );
+  Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
+  unsigned int count = controlDataImpl.GetAutofillItemHandle().GetFillValueCount();
+  unsigned int index = 0;
+  for( index = 0; index < count; index++ )
+  {
+    std::string presentationText =  controlDataImpl.GetAutofillItemHandle().GetPresentationText( index );
+    if( 0 == strcmp( presentationText.c_str(), selected.c_str() ) )
+    {
+      break;
+    }
+  }
+
+  for( std::vector<Dali::Toolkit::Control>::iterator iter = mControlItemList.begin(), endIter = mControlItemList.end(); iter != endIter; ++iter )
+  {
+    Internal::Control& controlImpl = GetImplementation( *iter );
+    Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
+    std::string fillValue = controlDataImpl.GetAutofillItemHandle().GetFillValue( index );
+    (*iter).SetProperty( Toolkit::TextField::Property::TEXT, fillValue );
+  }
+}
+
+//
+void AutofillContainer::OnAutofillAuthReceived()
+{
+  SetAutofillServiceName( mAutofillManager.GetAuthenticationServiceName() );
+  SetAutofillServiceMessage( mAutofillManager.GetAuthenticationServiceMessage() );
+  SetAutofillServiceImagePath( mAutofillManager.GetAuthenticationServiceImagePath() );
+
+  Dali::Toolkit::AutofillContainer handle( this );
+  mAuthenticationEventSignal.Emit( handle );
+
+  DALI_LOG_ERROR(" [ Emit DALi signal to receive the auth information ] \n");
+
+}
+
+void AutofillContainer::OnDataFillReceived( Dali::AutofillItem item )
+{
+  for( std::vector<Dali::Toolkit::Control>::iterator iter = mControlItemList.begin(), endIter = mControlItemList.end(); iter != endIter; ++iter )
+  {
+    Internal::Control& controlImpl = GetImplementation( *iter );
+    Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
+
+    if( 0 == strcmp( controlDataImpl.GetAutofillItemHandle().GetId().c_str(), item.GetId().c_str() ) )
+    {
+      // TODO : Is the index for fill data always 0 in this case?
+      std::string itemText = controlDataImpl.GetAutofillItemHandle().GetFillValue( 0 );
+      (*iter).SetProperty( Toolkit::TextField::Property::TEXT, itemText );
+    }
+  }
+
+}
+
+void AutofillContainer::OnListReceived()
+{
+  mListEventSignal.Emit( mCurrentFocused );
+
+}
+
+
+AutofillContainer::AutofillContainer()
+: mAutofillManager(),
+  mAutofillGroup(),
+  mControlItemList(),
+  mControlList(),
+  mSlotDelegate( this ),
+  mPropertyIndex( Property::INVALID_INDEX ),
+  mAutofillServiceName( "" ),
+  mAutofillServiceMessage( "" ),
+  mAutofillServiceImagePath( "" ),
+  mCurrentFocused()
+{
+}
+
+AutofillContainer::~AutofillContainer()
+{
+  mAutofillManager.AuthenticationReceivedSignal().Disconnect( mSlotDelegate, &AutofillContainer::OnAutofillAuthReceived );
+  mAutofillManager.FillResponseReceivedSignal().Disconnect( mSlotDelegate, &AutofillContainer::OnDataFillReceived );
+  mAutofillManager.ListEventSignal().Disconnect( mSlotDelegate, &AutofillContainer::OnListReceived );
+}
+
+// Signals
+Toolkit::AutofillContainer::AuthenticationSignalType& AutofillContainer::AutofillServiceShownSignal()
+{
+  return mAuthenticationEventSignal;
+}
+
+Toolkit::AutofillContainer::ListShownSignalType& AutofillContainer::AutofillListShownSignal()
+{
+  return mListEventSignal;
+}
+
+bool AutofillContainer::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+{
+  Dali::BaseHandle handle( object );
+
+  bool connected( true );
+  Toolkit::AutofillContainer container = Toolkit::AutofillContainer::DownCast( handle );
+
+  if( container )
+  {
+    if( 0 == signalName.compare( SIGNAL_SERVICE_SHOWN ) )
+    {
+      container.AutofillServiceShownSignal().Connect( tracker, functor );
+    }
+    else if( 0 == signalName.compare( SIGNAL_LIST_SHOWN ) )
+    {
+      container.AutofillListShownSignal().Connect( tracker, functor );
+    }
+    else
+    {
+      // signalName does not match any signal
+      connected = false;
+    }
+  }
+
+  return connected;
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/internal/controls/text-controls/autofill-container-impl.h b/dali-toolkit/internal/controls/text-controls/autofill-container-impl.h
new file mode 100644 (file)
index 0000000..1ef8262
--- /dev/null
@@ -0,0 +1,249 @@
+#ifndef DALI_TOOLKIT_INTERNAL_AUTOFILL_CONTAINER_H
+#define DALI_TOOLKIT_INTERNAL_AUTOFILL_CONTAINER_H
+
+/*
+ * Copyright (c) 2019 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-object.h>
+#include <dali/devel-api/adaptor-framework/autofill-manager.h>
+#include <map>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali-toolkit/devel-api/controls/text-controls/autofill-container.h>
+
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+/**
+ * @copydoc Toolkit::AutofillContainer
+ */
+class AutofillContainer : public Dali::BaseObject
+{
+public:
+
+  /**
+   * @copydoc Dali::Toollkit::AutofillContainer::New()
+   */
+  static Toolkit::AutofillContainer New( const std::string& name );
+
+  /**
+   * @brief Initialize AutofillContainer
+   */
+  void Initialize( const std::string& name );
+
+  /**
+   * @copydoc Dali::Toollkit::AutofillContainer::AddAutofillItem()
+   */
+  void AddAutofillItem( Dali::Toolkit::Control control, Dali::Property::Index propertyIndex, const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool isSensitive );
+
+  /**
+   * @copydoc Dali::Toollkit::AutofillContainer::RemoveAutofillItem()
+   */
+  void RemoveAutofillItem( Dali::Toolkit::Control control );
+
+  /**
+   * @brief Gets AutofillGroup setting to AutofillContainer.
+   *
+   * @return The AutofillGroup instance
+   */
+  Dali::AutofillGroup GetAutofillGroup();
+
+  /**
+   * @copydoc Dali::Toollkit::AutofillContainer::SetFocusedControl()
+   */
+  void SetFocusedControl( Toolkit::Control focused );
+
+  /**
+   * @copydoc Dali::Toollkit::AutofillContainer::GetFocusedControl()
+   */
+  Toolkit::Control GetFocusedControl();
+
+  /**
+   * @copydoc Dali::Toollkit::AutofillContainer::SaveAutofillData()
+   */
+  void SaveAutofillData();
+
+  /**
+   * @copydoc Dali::Toollkit::AutofillContainer::RequestFillData()
+   */
+  void RequestFillData();
+
+  /**
+   * @brief Sets the Autofill Service Name
+   *
+   * @param serviceName Autofill Service Name
+   */
+  void SetAutofillServiceName( const std::string& serviceName );
+
+  /**
+   * @copydoc Dali::Toollkit::AutofillContainer::GetAutofillServiceName()
+   */
+  const std::string& GetAutofillServiceName() const;
+
+  /**
+   * @brief Sets the Autofill Service Message
+   *
+   * @param serviceMessage Autofill Service Message
+   */
+  void SetAutofillServiceMessage( const std::string& serviceMessage );
+
+  /**
+   * @copydoc Dali::Toollkit::AutofillContainer::GetAutofillServiceMessage()
+   */
+  const std::string& GetAutofillServiceMessage() const;
+
+  /**
+   * @brief Sets the Autofill Service Image Path
+   *
+   * @param serviceImagePath Autofill Service Image Path
+   */
+  void SetAutofillServiceImagePath( const std::string& serviceImagePath );
+
+  /**
+   * @copydoc Dali::Toollkit::AutofillContainer::GetAutofillServiceImagePath()
+   */
+  const std::string& GetAutofillServiceImagePath() const;
+
+  /**
+   * @copydoc Dali::Toollkit::AutofillContainer::GetListCount()
+   */
+  unsigned int GetListCount();
+
+  /**
+   * @copydoc Dali::Toollkit::AutofillContainer::GetListItem()
+   */
+  const std::string& GetListItem( unsigned int index ) const;
+
+  /**
+   * @copydoc Dali::Toollkit::AutofillContainer::SetSelectedItem()
+   */
+  void SetSelectedItem( const std::string& selected );
+
+  /**
+   * @brief Callback when Autofill Authentication information is recieved.
+   */
+  void OnAutofillAuthReceived();
+
+  /**
+   * @brief Callback when Autofill Fill Response is recieved.
+   * @param[in] item The callback parameter
+   */
+  void OnDataFillReceived( Dali::AutofillItem item );
+
+  /**
+   * @brief Callback when the values to be filled are multiple.
+   */
+  void OnListReceived();
+
+  /**
+   * @copydoc Dali::Toollkit::AutofillContainer::AutofillServiceShownSignal()
+   */
+  Toolkit::AutofillContainer::AuthenticationSignalType& AutofillServiceShownSignal();
+
+  /**
+   * @copydoc Dali::Toollkit::AutofillContainer::AutofillListShownSignal()
+   */
+  Toolkit::AutofillContainer::ListShownSignalType& AutofillListShownSignal();
+
+  /**
+   * Connects a callback function with the object's signals.
+   * @param[in] object The object providing the signal.
+   * @param[in] tracker Used to disconnect the signal.
+   * @param[in] signalName The signal to connect to.
+   * @param[in] functor A newly allocated FunctorDelegate.
+   * @return True if the signal was connected.
+   * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
+   */
+  static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+
+
+private: // Implementation
+
+  /**
+   * Construct a new AutofillContainer.
+   */
+  AutofillContainer();
+
+  /**
+   * A reference counted object may only be deleted by calling Unreference()
+   */
+  virtual ~AutofillContainer();
+
+private:
+
+  // Undefined copy constructor and assignment operators
+  AutofillContainer(const AutofillContainer&);
+  AutofillContainer& operator=(const AutofillContainer& rhs);
+
+private: // Data
+
+  Dali::AutofillManager mAutofillManager;
+  Dali::AutofillGroup mAutofillGroup;
+  std::vector<Dali::Toolkit::Control> mControlItemList; ///< The List of Control adding to AutofillContainer
+  //std::map<Dali::Toolkit::Control, Dali::AutofillItem> mControlList;
+  std::vector< std::pair< Dali::Toolkit::Control, Dali::AutofillItem > > mControlList;
+
+  SlotDelegate< AutofillContainer > mSlotDelegate;
+
+  Property::Index mPropertyIndex;  ///< The index of property registered by each control
+
+  Toolkit::AutofillContainer::AuthenticationSignalType mAuthenticationEventSignal;
+  Toolkit::AutofillContainer::ListShownSignalType mListEventSignal;
+
+  std::string mAutofillServiceName;
+  std::string mAutofillServiceMessage;
+  std::string mAutofillServiceImagePath;
+
+  Toolkit::Control mCurrentFocused;
+};
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Toolkit::Internal::AutofillContainer& GetImpl( Toolkit::AutofillContainer& autofillContainer )
+{
+  DALI_ASSERT_ALWAYS(autofillContainer);
+
+  Dali::BaseObject& handle = autofillContainer.GetBaseObject();
+
+  return static_cast<Toolkit::Internal::AutofillContainer&>(handle);
+}
+
+inline const Toolkit::Internal::AutofillContainer& GetImpl( const Toolkit::AutofillContainer& autofillContainer )
+{
+  DALI_ASSERT_ALWAYS(autofillContainer);
+
+  const Dali::BaseObject& handle = autofillContainer.GetBaseObject();
+
+  return static_cast<const Toolkit::Internal::AutofillContainer&>(handle);
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_INTERNAL_AUTOFILL_CONTAINER_H
index 0def1bc..4a05923 100755 (executable)
@@ -37,6 +37,8 @@
 #include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
 #include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/controls/control/control-data-impl.h>
+#include <dali-toolkit/internal/controls/text-controls/autofill-container-impl.h>
 #include <dali-toolkit/internal/text/text-enumerations-impl.h>
 #include <dali-toolkit/internal/text/rendering/text-backend.h>
 #include <dali-toolkit/internal/text/text-effects-style.h>
@@ -1512,7 +1514,7 @@ void TextField::RenderText( Text::Controller::UpdateTextType updateTextType )
 void TextField::OnKeyInputFocusGained()
 {
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get() );
-  if ( mInputMethodContext )
+  if( mInputMethodContext )
   {
     mInputMethodContext.ApplyOptions( mInputMethodOptions );
 
@@ -1526,13 +1528,30 @@ void TextField::OnKeyInputFocusGained()
     // When window gain lost focus, the inputMethodContext is deactivated. Thus when window gain focus again, the inputMethodContext must be activated.
     mInputMethodContext.SetRestoreAfterFocusLost( true );
   }
-  ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
 
-  if ( notifier )
+  ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
+  if( notifier )
   {
     notifier.ContentSelectedSignal().Connect( this, &TextField::OnClipboardTextSelected );
   }
 
+  Toolkit::Control control = Toolkit::Control::DownCast( Self() );
+  Internal::Control& controlImpl = GetImplementation( control );
+  Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
+  bool enableAutofill = controlDataImpl.IsAutofillEnabled();
+  if( enableAutofill )
+  {
+    Toolkit::AutofillContainer container = controlDataImpl.GetAutofillContainer();
+    container.SetFocusedControl( control );
+
+    Internal::AutofillContainer& containerImpl = GetImpl( container );
+    Dali::AutofillGroup containerGroup = containerImpl.GetAutofillGroup();
+    if( containerGroup != nullptr )
+    {
+      containerGroup.RequestAuthentication();
+    }
+
+  }
   mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event
 
   EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.
index 3b1062e..7f0a5d9 100755 (executable)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/clipboard-event-notifier.h>
 #include <dali/devel-api/adaptor-framework/input-method-context.h>
+#include <dali/devel-api/adaptor-framework/autofill-item.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/control-impl.h>
@@ -282,6 +283,7 @@ private: // Data
   Toolkit::Control mStencil; ///< For EXCEED_POLICY_CLIP
   std::vector<Actor> mClippingDecorationActors;   ///< Decoration actors which need clipping.
   Dali::InputMethodOptions mInputMethodOptions;
+  Dali::AutofillItem mAutofillItem;
 
   Actor mRenderableActor;
   Actor mActiveLayer;
index 9642ef8..dbfbe75 100644 (file)
@@ -94,6 +94,7 @@ SET( toolkit_src_files
    ${toolkit_src_dir}/controls/slider/slider-impl.cpp
    ${toolkit_src_dir}/controls/super-blur-view/super-blur-view-impl.cpp
    ${toolkit_src_dir}/controls/table-view/table-view-impl.cpp
+   ${toolkit_src_dir}/controls/text-controls/autofill-container-impl.cpp
    ${toolkit_src_dir}/controls/text-controls/text-editor-impl.cpp
    ${toolkit_src_dir}/controls/text-controls/text-field-impl.cpp
    ${toolkit_src_dir}/controls/text-controls/text-label-impl.cpp