[Tizen] Add AutofillContainer class and autofill implementation
authorSunghyun Kim <scholb.kim@samsung.com>
Mon, 26 Apr 2021 06:50:07 +0000 (15:50 +0900)
committerSunghyun Kim <scholb.kim@samsung.com>
Mon, 26 Apr 2021 06:50:12 +0000 (15:50 +0900)
This reverts commit 63befc6c39700bcb25a6819d97ec0d045645e0a5.

Change-Id: I3acff87bf3c1e7dafcb3639040838182c60c066c

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

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 f583d3c457942ceb36f6327005134b9255b1c063..d35add36fdc894c77f7643dc77c30ee898aa4cc4 100755 (executable)
@@ -32,6 +32,7 @@ SET( devel_api_src_files
   ${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/table-view/table-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-label-devel.cpp
@@ -215,6 +216,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 070fa82cc480b8e9be1aa10049cf3ddc1d979297..8aa43d47a1f7b2be73ba74f5b8529e5de8c958ae 100644 (file)
@@ -451,11 +451,14 @@ Control::Impl::Impl(Control& controlImpl)
   mTooltip(NULL),
   mInputMethodContext(),
   mIdleCallback(nullptr),
+  mAutofillItem(),
+  mAutofillContainer(),
   mFlags(Control::ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)),
   mIsKeyboardNavigationSupported(false),
   mIsKeyboardFocusGroup(false),
   mIsEmittingResourceReadySignal(false),
-  mNeedToEmitResourceReady(false)
+  mNeedToEmitResourceReady(false),
+  mIsAutofillEnabled(false)
 {
   Dali::Accessibility::Accessible::RegisterControlAccessibilityGetter(
     [](Dali::Actor actor) -> Dali::Accessibility::Accessible* {
@@ -1973,6 +1976,36 @@ void Control::Impl::AccessibilityDeregister(bool remove)
   }
 }
 
+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 a3ab6c0c05573be5d84b74f5030095b295198fa5..b0e94123bb5cd0b9b8dc8280774505560d48aa3a 100644 (file)
 // EXTERNAL INCLUDES
 #include <dali-toolkit/devel-api/controls/control-devel.h>
 #include <dali/devel-api/adaptor-framework/accessibility.h>
+#include <dali/devel-api/adaptor-framework/autofill-item.h>
+#include <dali/devel-api/adaptor-framework/autofill-manager.h>
 #include <dali/public-api/object/property-notification.h>
 #include <dali/public-api/object/type-registry.h>
 #include <string>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
+#include <dali-toolkit/devel-api/controls/text-controls/autofill-container.h>
 #include <dali-toolkit/internal/builder/dictionary.h>
 #include <dali-toolkit/internal/builder/style.h>
 #include <dali-toolkit/internal/controls/tooltip/tooltip.h>
@@ -388,6 +391,42 @@ public:
    */
   void ClearShadow();
 
+  /**
+   * @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();
+
   /**
    * @copydoc DevelControl::GetVisualProperty()
    */
@@ -502,12 +541,15 @@ public:
 
   InputMethodContext mInputMethodContext;
   CallbackBase*      mIdleCallback; ///< The idle callback to emit the resource ready signal.
+  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             mIsEmittingResourceReadySignal : 1;    ///< True during ResourceReady().
   bool             mNeedToEmitResourceReady : 1;          ///< True if need to emit the resource ready signal again.
+  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 7fc3eca9c72c073b620c1064c05e26bf32be08a9..ceb40f97ee92a0c65bb4311ed735ae06ce68cbfa 100644 (file)
@@ -37,6 +37,8 @@
 #include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
 #include <dali-toolkit/devel-api/text/rendering-backend.h>
 #include <dali-toolkit/internal/styling/style-manager-impl.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/rendering/text-backend.h>
 #include <dali-toolkit/internal/text/text-effects-style.h>
 #include <dali-toolkit/internal/text/text-enumerations-impl.h>
@@ -1584,6 +1586,23 @@ void TextField::OnKeyInputFocusGained()
     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 670b81c9db67de5ea325803d81c8ef4cb4f8bb3b..a82eb97f166b505560694a2ea198ba84c6f27337 100644 (file)
@@ -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/devel-api/controls/control-devel.h>
@@ -367,6 +368,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 35ac87bdbdfb1a6c8d5ac98b1a917de2c817b10b..39eed404484b0869b03e915352e80f40c51aaab2 100644 (file)
@@ -98,6 +98,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