VirtualKeyboard API for Settings 00/40000/5 accepted/tizen/common/20150529.134105 accepted/tizen/mobile/20150529.134834 accepted/tizen/tv/20150529.134907 accepted/tizen/wearable/20150529.134850 submit/tizen/20150529.084413
authorAgnelo Vaz <agnelo.vaz@samsung.com>
Fri, 22 May 2015 13:23:24 +0000 (14:23 +0100)
committerAgnelo Vaz <agnelo.vaz@samsung.com>
Wed, 27 May 2015 14:35:12 +0000 (15:35 +0100)
Change-Id: Ic16296cf6fe0e8f4b9c67d353dcc12495451c685
Signed-off-by: Agnelo Vaz <agnelo.vaz@samsung.com>
adaptors/common/virtual-keyboard-impl.cpp
adaptors/common/virtual-keyboard-impl.h
adaptors/devel-api/adaptor-framework/virtual-keyboard.cpp
adaptors/devel-api/adaptor-framework/virtual-keyboard.h
adaptors/wayland/virtual-keyboard-impl-wl.cpp
adaptors/x11/virtual-keyboard-impl-x.cpp

index 6ba3924..9fca891 100644 (file)
@@ -29,7 +29,6 @@
 #include <locale-utils.h>
 #include <imf-manager-impl.h>
 
-
 namespace Dali
 {
 
@@ -48,6 +47,8 @@ namespace
 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_VIRTUAL_KEYBOARD");
 #endif
 
+#define TOKEN_STRING(x) #x
+
 //forward declarations
 void InputPanelGeometryChangedCallback ( void *data, Ecore_IMF_Context *context, int value );
 void InputPanelLanguageChangeCallback( void* data, Ecore_IMF_Context* context, int value );
@@ -57,8 +58,6 @@ Dali::VirtualKeyboard::StatusSignalType gKeyboardStatusSignal;
 Dali::VirtualKeyboard::VoidSignalType   gKeyboardResizeSignal;
 Dali::VirtualKeyboard::VoidSignalType   gKeyboardLanguageChangedSignal;
 
-Dali::VirtualKeyboard::ReturnKeyType gReturnKeyType = Dali::VirtualKeyboard::DEFAULT;  // the currently used return key type.
-
 void InputPanelStateChangeCallback( void* data, Ecore_IMF_Context* context, int value )
 {
   switch (value)
@@ -179,23 +178,28 @@ bool IsVisible()
   return false;
 }
 
-void SetReturnKeyType( Dali::VirtualKeyboard::ReturnKeyType type )
+void ApplySettings( const Property::Map& settingsMap )
 {
-  Dali::ImfManager imfManager = ImfManager::Get(); // Create ImfManager instance (if required) when setting values
-  Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+  using namespace InputMethod; // Allows exclusion of namespace in TOKEN_STRING.
 
-  if( imfContext )
+  for ( unsigned int i = 0, count = settingsMap.Count(); i < count; ++i )
   {
-    DALI_LOG_INFO( gLogFilter, Debug::General, "VKB Retrun key type is changed[%d]\n", type );
-
-    gReturnKeyType = type;
-    ecore_imf_context_input_panel_return_key_type_set( imfContext, static_cast<Ecore_IMF_Input_Panel_Return_Key_Type>( type ) );
-  }
-}
+    std::string key = settingsMap.GetKey( i );
+    Property::Value item = settingsMap.GetValue(i);
 
-Dali::VirtualKeyboard::ReturnKeyType GetReturnKeyType()
-{
-  return gReturnKeyType;
+    if ( key == TOKEN_STRING( ACTION_BUTTON ) )
+    {
+      if ( item.GetType() == Property::INTEGER )
+      {
+        int value = item.Get< int >();
+        VirtualKeyboard::SetReturnKeyType( static_cast<InputMethod::ActionButton>(value) );
+      }
+    }
+    else
+    {
+      DALI_LOG_INFO( gLogFilter, Debug::General, "Provided Settings Key not supported\n" );
+    }
+   }
 }
 
 void EnablePrediction(const bool enable)
index 671f399..6acd185 100644 (file)
@@ -69,14 +69,19 @@ void Hide();
 bool IsVisible();
 
 /**
+ * @copydoc Dali::VirtualKeyboard::ApplySettings()
+ */
+void ApplySettings( const Property::Map& settingsMap );
+
+/**
  * @copydoc Dali::VirtualKeyboard::SetReturnKeyType()
  */
-void SetReturnKeyType( Dali::VirtualKeyboard::ReturnKeyType type );
+void SetReturnKeyType( const Dali::InputMethod::ActionButton type );
 
 /**
  * @copydoc Dali::VirtualKeyboard::GetReturnKeyType()
  */
-Dali::VirtualKeyboard::ReturnKeyType GetReturnKeyType();
+Dali::InputMethod::ActionButton GetReturnKeyType();
 
 /**
  * @copydoc Dali::VirtualKeyboard::EnablePrediction()
index 5798ada..50fa03e 100644 (file)
@@ -42,12 +42,17 @@ bool IsVisible()
   return Internal::Adaptor::VirtualKeyboard::IsVisible();
 }
 
-void SetReturnKeyType( ReturnKeyType type )
+void ApplySettings( const Property::Map& settingsMap )
+{
+  Internal::Adaptor::VirtualKeyboard::ApplySettings( settingsMap );
+}
+
+void SetReturnKeyType( const InputMethod::ActionButton type )
 {
   Internal::Adaptor::VirtualKeyboard::SetReturnKeyType( type );
 }
 
-ReturnKeyType GetReturnKeyType()
+InputMethod::ActionButton  GetReturnKeyType()
 {
   return Internal::Adaptor::VirtualKeyboard::GetReturnKeyType();
 }
index ac6da9f..f0e0a94 100644 (file)
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/signals/dali-signal.h>
+#include <dali/public-api/object/property-map.h>
 #include <dali/public-api/math/rect.h>
 
+// INTERNAL INCLUDES
+#ifdef DALI_ADAPTOR_COMPILATION  // full path doesn't exist until adaptor is installed so we have to use relative
+// @todo Make dali-adaptor code folder structure mirror the folder structure installed to dali-env
+#include "input-method.h"
+#else
+#include <dali/public-api/adaptor-framework/input-method.h>
+#endif
+
 namespace Dali
 {
 
@@ -83,16 +92,22 @@ DALI_IMPORT_API void Hide();
 DALI_IMPORT_API bool IsVisible();
 
 /**
+ * @brief Set one or more of the Input Method Settings
+ * @param[in] settingsMap Map of Settings to be applied.
+ */
+DALI_IMPORT_API void ApplySettings( const Property::Map& settingsMap );
+
+/**
  * @brief Set the specific return key into the virtual keyboard.
  * @param[in] type the kind of return key types.
  */
-DALI_IMPORT_API void SetReturnKeyType( ReturnKeyType type );
+DALI_IMPORT_API void SetReturnKeyType( const InputMethod::ActionButton type );
 
 /**
  * @brief Retrieve the current return key type.
  * @return the type of retun key.
  */
-DALI_IMPORT_API ReturnKeyType GetReturnKeyType();
+DALI_IMPORT_API InputMethod::ActionButton GetReturnKeyType();
 
 /**
  * @brief Enable/disable prediction (predictive text).
index 57f87ac..3003364 100644 (file)
@@ -44,10 +44,21 @@ namespace Adaptor
 namespace VirtualKeyboard
 {
 
+Dali::InputMethod::ActionButton gActionButtonFunction = Dali::InputMethod::ACTION_DEFAULT;
+
 void RotateTo(int angle)
 {
 }
 
+void SetReturnKeyType( const InputMethod::ActionButton type )
+{
+}
+
+Dali::InputMethod::ActionButton GetReturnKeyType()
+{
+  return gActionButtonFunction;
+}
+
 } // namespace VirtualKeyboard
 
 } // namespace Adaptor
index 947bad8..b1fdc60 100644 (file)
@@ -44,6 +44,28 @@ namespace Adaptor
 namespace VirtualKeyboard
 {
 
+Dali::InputMethod::ActionButton gActionButtonFunction = Dali::InputMethod::ACTION_DEFAULT;
+
+Ecore_IMF_Input_Panel_Return_Key_Type actionButtonMapping(Dali::InputMethod::ActionButton actionButton )
+{
+  switch( actionButton )
+  {
+    case InputMethod::ACTION_DEFAULT:     return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
+    case InputMethod::ACTION_DONE:        return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
+    case InputMethod::ACTION_GO:          return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO;
+    case InputMethod::ACTION_JOIN:        return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN;
+    case InputMethod::ACTION_LOGIN:       return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN;
+    case InputMethod::ACTION_NEXT:        return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
+    case InputMethod::ACTION_PREVIOUS:    return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
+    case InputMethod::ACTION_SEARCH:      return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH;
+    case InputMethod::ACTION_SEND:        return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND;
+    case InputMethod::ACTION_SIGNIN:      return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
+    case InputMethod::ACTION_UNSPECIFIED: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
+    case InputMethod::ACTION_NONE:        return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
+    default:                              return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
+  }
+}
+
 void RotateTo(int angle)
 {
   // Get focus window used by Keyboard and rotate it
@@ -62,6 +84,23 @@ void RotateTo(int angle)
   }
 }
 
+void SetReturnKeyType( const InputMethod::ActionButton type )
+{
+  Dali::ImfManager imfManager = ImfManager::Get(); // Create ImfManager instance (if required) when setting values
+  Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+
+  if( imfContext )
+  {
+    gActionButtonFunction = type;
+    ecore_imf_context_input_panel_return_key_type_set( imfContext, actionButtonMapping( type ) );
+  }
+}
+
+Dali::InputMethod::ActionButton GetReturnKeyType()
+{
+  return gActionButtonFunction;
+}
+
 } // namespace VirtualKeyboard
 
 } // namespace Adaptor