Support Korean input 81/282981/1
authorInHong Han <inhong1.han@samsung.com>
Thu, 6 Oct 2022 10:23:26 +0000 (19:23 +0900)
committerInHong Han <inhong1.han@samsung.com>
Fri, 14 Oct 2022 06:59:41 +0000 (15:59 +0900)
Change-Id: I9ce34ef42fd1d48fc9b1ffbe60b4e9e3e6415a2e

ISEDefaultNUI/Common/LanguageManager.cs
ISEDefaultNUI/ISEDefaultNUI.cs
ISEDefaultNUI/ISEDefaultNUI.sln
ISEDefaultNUI/Interop/Interop.SclNui.cs
ISEDefaultNUI/SCLNUI.cs

index be768a2..99f236c 100644 (file)
@@ -1,9 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Collections.Generic;
 using Tizen;
+using static Interop.SclNuiCSharp;
 
 namespace ISEDefaultNUI
 {
@@ -162,9 +159,9 @@ namespace ISEDefaultNUI
         {
             List<LanguageInfo> languageInfos = languageInfoList.FindAll(x => x.Enabled == true);
             int index = languageInfos.FindIndex(x => x.Name == languageInfoList[currentLanguage].Name);
-            if (index == languageInfos.Count - 1)
+            if (index == languageInfos.Count - 1)\r
                 return languageInfos[0];
-            else
+            else\r
                 return languageInfos[index + 1];
         }
 
@@ -172,9 +169,9 @@ namespace ISEDefaultNUI
         {
             List<LanguageInfo> languageInfos = languageInfoList.FindAll(x => x.Enabled == true);
             int index = languageInfos.FindIndex(x => x.Name == languageInfoList[currentLanguage].Name);
-            if (index == 0)
+            if (index == 0)\r
                 return languageInfos[languageInfos.Count - 1];
-            else
+            else\r
                 return languageInfos[index - 1];
         }
 
@@ -183,9 +180,11 @@ namespace ISEDefaultNUI
             int index = -1;
             index = languageInfoList.FindIndex(x => x.Name == language.Name);
             if (index == -1)
-                return false;
-            else
-                return true;
+                return false;\r
+\r
+            Log.Info("NUIIME", "Current Language : " + languageInfoList[index].Name);\r
+            currentLanguage = index;
+            return true;
         }
 
         public string GetUuid(string name)
@@ -204,9 +203,32 @@ namespace ISEDefaultNUI
             if (!languageInfo.Enabled && !languageInfo.EnabledTemporarily)
                 return false;
 
-            //Reset Language (flush imengine)
+            Log.Info("NUIIME", "Reset Language : " + GetCurrentLanguage());
+            if (languageInfo.Name.Equals(name))
+                FlushImengine(languageInfo.Name);
 
             return true;
         }
+
+        public void FlushImengine(string language)\r
+        {\r
+            Log.Info("NUIIME", "Flush Imengine : " + language);\r
+\r
+            KeyboardState keyboardState = KeyboardState.Instance;\r
+            if (keyboardState.PreviousModifier == (uint)SclNuiKeyModifier.MultitapStart || keyboardState.PreviousModifier == (uint)SclNuiKeyModifier.MultitapRepeat)\r
+                Common.SendString(keyboardState.MultitapValue);\r
+\r
+            keyboardState.MultitapValue = "";\r
+            keyboardState.PreviousModifier = (uint)SclNuiKeyModifier.None;\r
+\r
+            LanguageInfo currentLanguage = GetLanguageInfo(language);\r
+            if (currentLanguage != null)\r
+            {\r
+                if (currentLanguage.LoadInIME)\r
+                    SclResetImengine();\r
+                else\r
+                    SclDbusResetImengine();\r
+            }\r
+        }
     }
 }
index ab24bdb..5fcc79b 100644 (file)
@@ -79,6 +79,9 @@ namespace ISEDefaultNUI
                     if (node.Attributes["accepts_caps_mode"] != null)
                         languageInfo.AcceptsCapsMode = Convert.ToBoolean(node.Attributes["accepts_caps_mode"].Value);
 
+                    if (node.Attributes["need_surrounding_text"] != null)\r
+                        languageInfo.NeedSurroundingText = Convert.ToBoolean(node.Attributes["need_surrounding_text"].Value);\r
+\r
                     languageInfo.Enabled = false;
                     languageInfo.SelectedInputMode = inputModeInfo.Name;
 
@@ -135,16 +138,6 @@ namespace ISEDefaultNUI
             SclNui.EnableSound(false);
             SclNui.EnableVibration(false);
             SclNui.EnableMagnifier(false);
-
-            LanguageInfo currentLanguage = LanguageManager.Instance.GetLanguageInfo(IseConfig.Instance.SelectedLanguage);
-            if (!currentLanguage.LoadInIME)
-            {
-                /* FIXME : This comment should be removed when using IMEngine
-                string uuid = LanguageManager.Instance.GetUuid(currentLanguage.KeyboardISEUuid);
-                ApplicationInfo applicationInfo = new ApplicationInfo(uuid);
-                SclDbus.SetImengine(uuid, applicationInfo.PackageId);
-                */
-            }
         }
 
         private static void Terminate()
@@ -225,15 +218,18 @@ namespace ISEDefaultNUI
 
         private static void IMEShow(int ic)
         {
+            IseConfig.Instance.ReadIseConfig();
+            LanguageManager.Instance.SetEnabledLanguages(IseConfig.Instance.EnabledLanguages);
+
             switch (KeyboardState.Instance.Layout)
             {
                 case KeyboardLayout.PhoneNumber:
                 case KeyboardLayout.IP:
                 case KeyboardLayout.Month:
                 case KeyboardLayout.NumberOnly:
-                    /* FIXME : This comment should be removed when using IMEngine
-                     * InputMethodEditor.SetIMEngine(ResourceManager.DefaultKeyboardUuid);
-                    */
+
+                    ApplicationInfo applicationInfo = new ApplicationInfo(ResourceManager.DefaultKeyboardUuid);
+                    SclDbusSetImengine(ResourceManager.DefaultKeyboardUuid, applicationInfo.PackageId);
                     break;
                 default:
                     break;
@@ -335,6 +331,24 @@ namespace ISEDefaultNUI
                     {
                         SclNui.SetInputMode(defaultValue.Values[(int)layoutIndex].InputMode);
                     }
+                    else\r
+                    {\r
+                        LanguageInfo selectLanguage = LanguageManager.Instance.GetLanguageInfo(IseConfig.Instance.SelectedLanguage);\r
+                        LanguageManager.Instance.SelectLanguage(selectLanguage);\r
+                        if (forcePrimaryLatin || selectLanguage.LoadInIME)\r
+                        {\r
+                            SclSetEngineLoaderFlag(false);\r
+                            SclSetImengine(LanguageManager.Instance.GetUuid(selectLanguage.KeyboardISEUuid));\r
+                        }\r
+                        else\r
+                        {\r
+                            SclSetImengine(ResourceManager.DefaultKeyboardUuid);\r
+                            SclSetEngineLoaderFlag(true);\r
+                            string uuid = LanguageManager.Instance.GetUuid(selectLanguage.KeyboardISEUuid);\r
+                            ApplicationInfo applicationInfo = new ApplicationInfo(uuid);\r
+                            SclDbusSetImengine(uuid, applicationInfo.PackageId);\r
+                        }\r
+                    }
 
                     SclNui.SetCurrentSublayout(defaultValue.Values[(int)layoutIndex].SublayoutName);
                 }
index 6828a1f..6dff342 100644 (file)
@@ -1,31 +1,31 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.31129.286
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ISEDefaultNUI", "ISEDefaultNUI.csproj", "{0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingKeyboard", "..\SettingKeyboard\SettingKeyboard.csproj", "{D3191982-0DF3-4E08-A4BD-5AADC746BC7C}"
-EndProject
-Global
-       GlobalSection(SolutionConfigurationPlatforms) = preSolution
-               Debug|Any CPU = Debug|Any CPU
-               Release|Any CPU = Release|Any CPU
-       EndGlobalSection
-       GlobalSection(ProjectConfigurationPlatforms) = postSolution
-               {0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-               {0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}.Debug|Any CPU.Build.0 = Debug|Any CPU
-               {0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}.Release|Any CPU.ActiveCfg = Release|Any CPU
-               {0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}.Release|Any CPU.Build.0 = Release|Any CPU
-               {D3191982-0DF3-4E08-A4BD-5AADC746BC7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-               {D3191982-0DF3-4E08-A4BD-5AADC746BC7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
-               {D3191982-0DF3-4E08-A4BD-5AADC746BC7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
-               {D3191982-0DF3-4E08-A4BD-5AADC746BC7C}.Release|Any CPU.Build.0 = Release|Any CPU
-       EndGlobalSection
-       GlobalSection(SolutionProperties) = preSolution
-               HideSolutionNode = FALSE
-       EndGlobalSection
-       GlobalSection(ExtensibilityGlobals) = postSolution
-               SolutionGuid = {90570B69-2C91-4F6C-8751-2BD5B81E11D6}
-       EndGlobalSection
-EndGlobal
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Visual Studio Version 16\r
+VisualStudioVersion = 16.0.31129.286\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ISEDefaultNUI", "ISEDefaultNUI.csproj", "{0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}"\r
+EndProject\r
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SettingKeyboard", "..\SettingKeyboard\SettingKeyboard.csproj", "{D3191982-0DF3-4E08-A4BD-5AADC746BC7C}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Any CPU = Debug|Any CPU\r
+               Release|Any CPU = Release|Any CPU\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}.Release|Any CPU.Build.0 = Release|Any CPU\r
+               {D3191982-0DF3-4E08-A4BD-5AADC746BC7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {D3191982-0DF3-4E08-A4BD-5AADC746BC7C}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {D3191982-0DF3-4E08-A4BD-5AADC746BC7C}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {D3191982-0DF3-4E08-A4BD-5AADC746BC7C}.Release|Any CPU.Build.0 = Release|Any CPU\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+       GlobalSection(ExtensibilityGlobals) = postSolution\r
+               SolutionGuid = {90570B69-2C91-4F6C-8751-2BD5B81E11D6}\r
+       EndGlobalSection\r
+EndGlobal\r
index dce7326..97c50e6 100644 (file)
@@ -135,6 +135,9 @@ internal static partial class Interop
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         internal delegate void UpdateWindowPositionCallback(int type, int x, int y, int rotationX, int rotationY, IntPtr user_data);
 
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void ProcessKeyEventWithImengineCallback(UInt32 code, UInt32 mask, UInt32 layout, UInt32 devClass, UInt32 devSubclass, string devName, UInt32 serial, IntPtr user_data);
+
         [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_init")]
         internal static extern int SclNuiInit(string entry_filepath);
 
@@ -320,5 +323,23 @@ internal static partial class Interop
 
         [DllImport(Libraries.SclNui, EntryPoint = "scl_dbus_long_press_candidate_item")]
         internal static extern void SclDbusLongPressCandidateItem(UInt32 index);
+
+        [DllImport(Libraries.SclNui, EntryPoint = "scl_set_imengine")]
+        internal static extern int SclSetImengine(string engineId);
+
+        [DllImport(Libraries.SclNui, EntryPoint = "scl_flush_imengine")]
+        internal static extern int SclFlushImengine();
+
+        [DllImport(Libraries.SclNui, EntryPoint = "scl_reset_imengine")]
+        internal static extern int SclResetImengine();
+
+        [DllImport(Libraries.SclNui, EntryPoint = "scl_send_imengine_event")]
+        internal static extern int SclSendImengineEvent(int command, UInt32 value);
+
+        [DllImport(Libraries.SclNui, EntryPoint = "scl_set_engine_loader_flag")]
+        internal static extern int SclSetEngineLoaderFlag(bool flag);
+
+        [DllImport(Libraries.SclNui, EntryPoint = "scl_set_process_key_event_with_imengine_cb")]
+        internal static extern int SclSetProcessKeyEventWithImengineCb(ProcessKeyEventWithImengineCallback callbackFunction, IntPtr userData);
     }
 }
index 17e836b..ade5b5a 100644 (file)
@@ -9,7 +9,7 @@ using Tizen.NUI.BaseComponents;
 using Tizen.NUI.Components;
 using Tizen.Uix.InputMethod;
 using static Interop.SclNuiCSharp;
-\r
+
 namespace ISEDefaultNUI
 {
     class SCLNUI : Page
@@ -22,6 +22,7 @@ namespace ISEDefaultNUI
         private DragStateChangedCallback _onDragStateChangedEvent = null;
         private EventNotificationCallback _onEventNotification = null;
         private UpdateWindowPositionCallback _updateWindowPositionChangedEvent = null;
+        private ProcessKeyEventWithImengineCallback _onProcessKeyEventWithImengineEvent = null;
 
         private List<ImageView> image_list;
         private List<TextLabel> label_list;
@@ -44,7 +45,7 @@ namespace ISEDefaultNUI
         private Timer commitTimer;
         private Timer showEmoticonTimer;
         private View emoticonView = null;
-        private EmoticonPage emoticonPage = null;\r
+        private EmoticonPage emoticonPage = null;
 
         enum LabelAlignment
         {
@@ -82,9 +83,9 @@ namespace ISEDefaultNUI
             label_list = new List<TextLabel>();
 
             commitTimer = new Timer(1000);
-            commitTimer.Tick += CommitTimerTick;\r
-\r
-            showEmoticonTimer = new Timer(10);\r
+            commitTimer.Tick += CommitTimerTick;
+
+            showEmoticonTimer = new Timer(10);
             showEmoticonTimer.Tick += showEmoticonTimerTick;
 
             /* Draw text callback */
@@ -378,8 +379,8 @@ namespace ISEDefaultNUI
                             SclNuiSetShiftState((uint)ShiftState.Off);
                             KeyboardState.Instance.ResetMultitapState(true);
                             InputMethodEditor.RequestHide();
-                        }\r
-\r
+                        }
+
                         else if (key_event > 0)
                         {
                             Common.SendKeyEvent((KeyCode)key_event);
@@ -387,13 +388,13 @@ namespace ISEDefaultNUI
                         break;
                     case SclNuiKeyType.Modechange:
                         break;
-                    case SclNuiKeyType.User:\r
+                    case SclNuiKeyType.User:
                         {
                             String substring = keyValue.Substring(0, 15);
                             Log.Info("NUIIME", "key substring " + substring);
-                            if (substring.Equals("EMOTICON_GROUP_"))\r
-                                emoticonPage?.SetEmoticonGroup(keyValue);\r
-                        }\r
+                            if (substring.Equals("EMOTICON_GROUP_"))
+                                emoticonPage?.SetEmoticonGroup(keyValue);
+                        }
                         break;
                     case SclNuiKeyType.Max:
                         break;
@@ -410,9 +411,9 @@ namespace ISEDefaultNUI
                     appControl.LaunchMode = AppControlLaunchMode.Group;
                     AppControl.SendLaunchRequest(appControl);
                 }
-                else if (keyValue.Equals("EMOTICON_LAYOUT"))\r
-                {\r
-                    ShowEmoticonLayout();\r
+                else if (keyValue.Equals("EMOTICON_LAYOUT"))
+                {
+                    ShowEmoticonLayout();
                 }
 
                 if (keyValue.Equals("Space") && afterPositionX != 0 && Math.Abs(beforePositionX - afterPositionX) > 100 && !inputMode.Equals("SYM_QTY_1"))
@@ -425,15 +426,21 @@ namespace ISEDefaultNUI
                     IseConfig.Instance.SelectedLanguage = nextLanguage.Name;
                     IseConfig.Instance.WriteIseConfig();
 
-                    if (!nextLanguage.LoadInIME)
+                    if (nextLanguage.LoadInIME)
+                    {
+                        SclSetEngineLoaderFlag(false);
+                        SclSetImengine(LanguageManager.Instance.GetUuid(nextLanguage.KeyboardISEUuid));
+                    }
+                    else
                     {
-                        /* FIXME : This comment should be removed when using IMEngine
+                        SclSetImengine(ResourceManager.DefaultKeyboardUuid);
+                        SclSetEngineLoaderFlag(true);
                         string uuid = LanguageManager.Instance.GetUuid(nextLanguage.KeyboardISEUuid);
                         ApplicationInfo applicationInfo = new ApplicationInfo(uuid);
                         SclDbusSetImengine(uuid, applicationInfo.PackageId);
-                        */
                     }
 
+                    LanguageManager.Instance.FlushImengine(nextLanguage.Name);
                     SclNui.SetInputMode(nextLanguage.SelectedInputMode);
                     SclNui.SetCurrentSublayout("DEFAULT");
                     SclNui.SetStringSubstitution("_LANGUAGE_", nextLanguage.DisplayName);
@@ -460,6 +467,22 @@ namespace ISEDefaultNUI
             };
             SclNuiKeyClickEventCb(_onKeyClickEvent);
 
+            InputMethodEditor.SetProcessKeyCallback((KeyCode code, KeyMask mask, InputMethodDeviceInformation device) => {
+                if (keyboardState.VisibleState)
+                {
+
+                }
+
+                return false;
+            });
+
+            _onProcessKeyEventWithImengineEvent = (UInt32 code, UInt32 mask, UInt32 layout, UInt32 devClass, UInt32 devSubclass, string devName, UInt32 serial, IntPtr user_data) =>
+            {
+                LanguageInfo currentLanguage = LanguageManager.Instance.GetLanguageInfo(LanguageManager.Instance.GetCurrentLanguage());
+                SclDbusProcessKeyEvent(code, mask, layout, devClass, devSubclass, devName, serial, currentLanguage.NeedSurroundingText);
+            };
+            SclSetProcessKeyEventWithImengineCb(_onProcessKeyEventWithImengineEvent, (IntPtr)null);
+
             _onDragStateChangedEvent = (IntPtr key_value, int key_event, int key_type, int event_type, int current_x, int current_y) =>
             {
                 return (int)SclNuiEventReturnType.PassOn;
@@ -525,19 +548,19 @@ namespace ISEDefaultNUI
             return true;
         }
 
-        private void ShowEmoticonLayout()\r
+        private void ShowEmoticonLayout()
         {
-            if (showEmoticonTimer.IsRunning())\r
-                showEmoticonTimer.Stop();\r
-\r
-            showEmoticonTimer.Start();\r
+            if (showEmoticonTimer.IsRunning())
+                showEmoticonTimer.Stop();
+
+            showEmoticonTimer.Start();
         }
 
         private bool showEmoticonTimerTick(object source, Timer.TickEventArgs e)
-        {\r
-            Log.Info("NUIIME", "emoticon layout timer");\r
+        {
+            Log.Info("NUIIME", "emoticon layout timer");
             OnShowEmoticonLayoutTimer();
-            return false;\r
+            return false;
         }
 
         private void OnResized(object sender, Window.ResizedEventArgs e)