--- /dev/null
+using System.Collections.Generic;
+using Tizen;
+using Tizen.Uix.InputMethod;
+
+namespace ISEDefaultNUI
+{
+ public class Common
+ {
+ public static void SendString(string text)
+ {
+ int ic = -1;
+ KeyboardState keyboardState = KeyboardState.Instance;
+ if (!keyboardState.CheckContextTemporary(keyboardState.Context))
+ ic = keyboardState.Context;
+
+ InputMethodEditor.CommitString(text);
+ Log.Info("NUIIME", "ic : " + ic + ", text : " + text);
+ }
+
+ public static void UpdatePreeditString(string text, bool underline)
+ {
+ int ic = -1;
+ KeyboardState keyboardState = KeyboardState.Instance;
+ if (!keyboardState.CheckContextTemporary(keyboardState.Context))
+ ic = keyboardState.Context;
+
+ if (underline)
+ {
+ List<PreEditAttribute> list = new List<PreEditAttribute>();
+ PreEditAttribute preEditAttribute = new PreEditAttribute();
+ preEditAttribute.Start = 0;
+ preEditAttribute.Length = (uint)text.Length;
+ preEditAttribute.Type = AttributeType.FontStyle;
+ preEditAttribute.Value = ResourceManager.FontStyleUnderline;
+ list.Add(preEditAttribute);
+ InputMethodEditor.UpdatePreEditString(text, list);
+ }
+ else
+ {
+ InputMethodEditor.UpdatePreEditString(text, null);
+ }
+ Log.Info("NUIIME", "ic : " + ic + ", text : " + text);
+ }
+
+ public static void SendKeyEvent(KeyCode code)
+ {
+ int ic = -1;
+ KeyboardState keyboardState = KeyboardState.Instance;
+ if (!keyboardState.CheckContextTemporary(keyboardState.Context))
+ ic = keyboardState.Context;
+
+ InputMethodEditor.SendKeyEvent(code, KeyMask.Pressed, false);
+ InputMethodEditor.SendKeyEvent(code, KeyMask.Released, false);
+ Log.Info("NUIIME", "ic : " + ic + ", key : " + code.ToString());
+ }
+
+ public static void ForwardKeyEvent(KeyCode code)
+ {
+ int ic = -1;
+ KeyboardState keyboardState = KeyboardState.Instance;
+ if (!keyboardState.CheckContextTemporary(keyboardState.Context))
+ ic = keyboardState.Context;
+
+ InputMethodEditor.SendKeyEvent(code, KeyMask.Pressed, true);
+ InputMethodEditor.SendKeyEvent(code, KeyMask.Released, true);
+ Log.Info("NUIIME", "ic : " + ic + ", key : " + code.ToString());
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tizen;
+using Tizen.Uix.InputMethod;
+using static Interop.SclNuiCSharp;
+
+namespace ISEDefaultNUI
+{
+ public enum KeyboardLayout
+ {
+ Normal = 0,
+ Number,
+ Email,
+ URL,
+ PhoneNumber,
+ IP,
+ Month,
+ NumberOnly,
+ Invalid,
+ Hex,
+ Terminal,
+ Password,
+ Datetime,
+ Emoticon,
+ Voice,
+ Sticker,
+ NumberOnlySig,
+ NumberOnlyDec,
+ NumberOnlySigDec,
+ Password_3X4,
+ Max
+ };
+
+ public enum ShiftState
+ {
+ Off = 0,
+ On,
+ Lock,
+ Max
+ }
+
+ public class KeyboardState
+ {
+ private int context;
+ private int focusedContext;
+ private KeyboardLayout layout;
+ private UInt32 layoutVariation;
+ private bool capsMode;
+ private bool capsModePending;
+ private bool needReset;
+ private bool visibleState;
+ private string multitapValue;
+ private UInt32 previousModifier;
+ private bool disableForceLatin;
+ private bool preferLatin;
+ private static KeyboardState instance;
+
+ private KeyboardState()
+ {
+ context = 0;
+ focusedContext = 0;
+ layout = KeyboardLayout.Normal;
+ layoutVariation = 0;
+ capsMode = false;
+ capsModePending = false;
+ needReset = true;
+ visibleState = false;
+ multitapValue = "";
+ previousModifier = 0;
+ disableForceLatin = false;
+ preferLatin = false;
+ }
+
+ public static KeyboardState Instance
+ {
+ get
+ {
+ if (instance == null)
+ instance = new KeyboardState();
+
+ return instance;
+ }
+ }
+
+ public int Context
+ {
+ get => context;
+ set { context = value; }
+ }
+
+ public int FocusedContext
+ {
+ get => focusedContext;
+ set { focusedContext = value; }
+ }
+
+ public KeyboardLayout Layout
+ {
+ get => layout;
+ set { layout = value; }
+ }
+
+ public UInt32 LayoutVariation
+ {
+ get => layoutVariation;
+ set { layoutVariation = value; }
+ }
+
+ public bool CapsMode
+ {
+ get => capsMode;
+ set { capsMode = value; }
+ }
+
+ public bool CapsModePending
+ {
+ get => capsModePending;
+ set { capsModePending = value; }
+ }
+
+ public bool NeedReset
+ {
+ get => needReset;
+ set { needReset = value; }
+ }
+
+ public bool VisibleState
+ {
+ get => visibleState;
+ set { visibleState = value; }
+ }
+
+ public string MultitapValue
+ {
+ get => multitapValue;
+ set { multitapValue = value; }
+ }
+
+ public UInt32 PreviousModifier
+ {
+ get => previousModifier;
+ set { previousModifier = value; }
+ }
+
+ public bool DisableForceLatin
+ {
+ get => disableForceLatin;
+ set { disableForceLatin = value; }
+ }
+
+ public bool PreferLatin
+ {
+ get => preferLatin;
+ set { preferLatin = value; }
+ }
+
+ public bool CheckContextTemporary(int context)
+ {
+ if ((context & 0xFFFF) == 0)
+ return true;
+
+ return false;
+ }
+
+ public void ResetMultitapState(bool skipCommit)
+ {
+ if (previousModifier == (uint)SclNuiKeyModifier.MultitapStart || previousModifier == (uint)SclNuiKeyModifier.MultitapRepeat)
+ {
+ if (!skipCommit)
+ {
+ Common.SendString(multitapValue);
+ }
+
+ Common.UpdatePreeditString("", false);
+ }
+
+ multitapValue = "";
+ previousModifier = 0;
+ if (capsModePending)
+ {
+ capsModePending = false;
+ SetCapsmode(capsMode);
+ }
+ }
+
+ public void SetCapsmode(bool capsmode)
+ {
+ Log.Info("NUIIME", "capsmode : " + capsmode.ToString());
+ uint state;
+ SclNuiGetShiftState(out state);
+
+ if ((ShiftState)state != ShiftState.Lock)
+ {
+ SclNuiSetShiftState(capsmode ? (uint)ShiftState.On : (uint)ShiftState.Off);
+ SclNuiSetAutocapitalShiftState(!capsmode);
+
+ bool loadInIME = false;
+ string currentLanguage = LanguageManager.Instance.GetCurrentLanguage();
+ if (currentLanguage != null)
+ {
+ LanguageInfo languageInfo = LanguageManager.Instance.GetLanguageInfo(currentLanguage);
+ if (languageInfo != null)
+ loadInIME = languageInfo.LoadInIME;
+ }
+
+ if (!loadInIME)
+ SclDbusSendImengineEvent(capsmode ? ResourceManager.MVKShiftOn : ResourceManager.MVKShiftOff, 0);
+ }
+ }
+ }
+}
Specialized,
}
+ public class KeyboardUuidInfo
+ {
+ public string Name;
+ public string Uuid;
+ }
+
public class InputModeInfo
{
public string Name;
public string SelectedInputMode;
public string LocaleString;
public string ResourceFile;
+ public string KeyboardISEUuid;
+ public string CountryCodeURL;
public bool Enabled;
public bool EnabledTemporarily;
public bool IsLatinLanguage;
private static LanguageManager instance;
private int currentLanguage;
private List<LanguageInfo> languageInfoList;
+ private List<KeyboardUuidInfo> uuidInfoList;
private LanguageManager()
{
this.currentLanguage = -1;
this.languageInfoList = new List<LanguageInfo>();
+ this.uuidInfoList = new List<KeyboardUuidInfo>();
}
public static LanguageManager Instance
return true;
}
+ public void AddUuidInfo(KeyboardUuidInfo info)
+ {
+ uuidInfoList.Add(info);
+ }
+
public void SetEnabledLanguages(List<string> languages)
{
List<LanguageInfo> languageInfos = languageInfoList.FindAll(x => x.Enabled == true);
{
currentLanguage = languageInfoList.FindIndex(x => x.Name == language.Name);
}
+
+ public string GetUuid(string name)
+ {
+ return uuidInfoList.Find(x => x.Name == name).Uuid;
+ }
}
}
public const int MinSelectedLanguages = 1;
public const int MaxSelectedLanguages = 4;
public const int BackButtonSize = 50;
+ public const int FontStyleUnderline = 1;
+ public const int FontStyleHighlight = 2;
+ public const int FontStyleReversal = 4;
+ public const int SigDecSize = 2;
+ public const int MVKShiftL = 0xffe1;
+ public const int MVKCapsLock = 0xffe5;
+ public const int MVKShiftOff = 0xffe1;
+ public const int MVKShiftOn = 0xffe2;
+ public const int MVKShiftLock = 0xffe6;
+ public const int MVKShiftEnable = 0x9fe7;
+ public const int MVKShiftDisable = 0x9fe8;
+ public const int MVKSpace = 0x020;
+ public const int MVKDone = 0xff0d;
public const uint MagnifierShowDuration = 300;
- public const string IseConfigKeypadMode = "/ise-default/KeypadMode";
- public const string IseConfigSelectedLanguage = "/ise-default/SelectedLanguage";
- public const string IseConfigEnabledLanguages = "/ise-default/EnabledLanguages";
- public const string IseConfigPredictionOn = "/ise-default/PredictionOn";
- public const string IseConfigAutoCapitalise = "/ise-default/AutoCapitalise";
- public const string IseConfigAutoPunctuate = "/ise-default/AutoPuncuage";
- public const string IseConfigSoundOn = "/ise-default/SoundOn";
- public const string IseConfigVibrationOn = "/ise-default/VibrationOn";
- public const string IseConfigPreviewOn = "/ise-default/PreviewOn";
- public const string IseConfigFloatingMode = "/ise-default/FloatingMode";
- public const string IseConfigFirstGuideSet = "/ise-default/FirstGuideSet";
- public const string IseConfigFirstGuideChange = "/ise-default/FirstGuideChange";
- public const string IseConfigNumberTutorialEnable = "/ise-default/NumberTutorialEnable";
- public const string IseConfigSymbolTutorialEnable = "/ise-default/SymbolTutorialEnable";
- public const string IseConfigDataClear = "/ise-default/DataClear";
+ public const string IseConfigKeypadMode = "/ise-default/keypad_mode";
+ public const string IseConfigSelectedLanguage = "/ise-default/selected_language";
+ public const string IseConfigEnabledLanguages = "/ise-default/enabled_languages";
+ public const string IseConfigPredictionOn = "/ise-default/prediction_on";
+ public const string IseConfigAutoCapitalise = "/ise-default/auto_capitalise";
+ public const string IseConfigAutoPunctuate = "/ise-default/auto_punctuate";
+ public const string IseConfigSoundOn = "/ise-default/sound_on";
+ public const string IseConfigVibrationOn = "/ise-default/vibration_on";
+ public const string IseConfigPreviewOn = "/ise-default/preview_on";
+ public const string IseConfigFloatingMode = "/ise-default/floating_mode";
+ public const string IseConfigFirstGuideSet = "/ise-default/first_guideline_popup_for_setting";
+ public const string IseConfigFirstGuideChange = "/ise-default/first_guideline_popup_for_language_change";
+ public const string IseConfigNumberTutorialEnable = "/ise-default/number_tutorial_enable";
+ public const string IseConfigSymbolTutorialEnable = "/ise-default/symbol_tutorial_enable";
+ public const string IseConfigDataClear = "/ise-default/clear_data_on";
+ public const string IseSettingAppId = "org.tizen.ise-default-setting";
}
}
{
class Program : NUIApplication
{
- static private Navigator navigator = null;
+ private static Navigator navigator = null;
+ private static SCLNUI SclNui = null;
+
public Program(string styleSheet, WindowMode windowMode, Size2D windowSize, Position2D windowPosition, WindowType type) : base(styleSheet, windowMode, windowSize, windowPosition, type)
{
}
{
base.OnCreate();
InputMethodEditor.Create();
+ RegisterCallback();
}
protected override void OnTerminate()
xml.Load(xmlURL);
XmlElement KeyList = xml.DocumentElement;
- XmlNodeList xnList = xml.SelectNodes("/languages/language_table/rec");
+ XmlNodeList uuidList = xml.SelectNodes("/languages/keyboard_uuid_table/rec");
+ XmlNodeList languageList = xml.SelectNodes("/languages/language_table/rec");
+
+ foreach (XmlNode node in uuidList)
+ {
+ KeyboardUuidInfo uuidInfo = new KeyboardUuidInfo();
+ uuidInfo.Name = node.Attributes["name"]?.Value;
+ uuidInfo.Uuid = node.Attributes["uuid"]?.Value;
+ LanguageManager.Instance.AddUuidInfo(uuidInfo);
+ }
- foreach (XmlNode node in xnList)
+ foreach (XmlNode node in languageList)
{
InputModeInfo inputModeInfo = new InputModeInfo();
inputModeInfo.Name = node.Attributes["inputmode_QTY"]?.Value;
languageInfo.Name = node.Attributes["language"]?.Value;
languageInfo.DisplayName = node.Attributes["language_name"]?.Value;
languageInfo.LocaleString = node.Attributes["locale_string"]?.Value;
+ languageInfo.KeyboardISEUuid = node.Attributes["keyboard_ise_uuid"]?.Value;
+ languageInfo.CountryCodeURL = node.Attributes["country_code_URL"]?.Value;
+ if (node.Attributes["load_in_ime"] != null)
+ languageInfo.LoadInIME = bool.Parse(node.Attributes["load_in_ime"].Value);
languageInfo.InputModes = new List<InputModeInfo>();
languageInfo.InputModes.Add(inputModeInfo);
languageInfo.Priority = LanguagePriority.Default;
IseConfig.Instance.ReadIseConfig();
LanguageManager.Instance.SetEnabledLanguages(IseConfig.Instance.EnabledLanguages);
+ SclNuiInit(Application.Current.DirectoryInfo.Resource + "main_entry.xml");
+ SclNuiEnableSound(IseConfig.Instance.SoundOn);
+ SclNuiEnableVibration(IseConfig.Instance.VibrationOn);
+
+ 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);
+ SclDbusSetImengine(uuid, applicationInfo.PackageId);
+ */
+ }
}
private static void Terminate()
{
+ UnregisterCallback();
+ SclNuiFini();
SclDbusShutdown();
InputMethodEditor.Destroy();
}
private static void Show(InputMethodEditor.ContextId a, Tizen.Uix.InputMethod.InputMethodContext b)
{
- SclNuiSetRotation((int)Window.Instance.GetCurrentOrientation());
+ bool returnKeyState = b.ReturnKeyState;
+ bool predictionAllow = b.PredictionMode;
+ bool passwordMode = b.PasswordMode;
+ AutoCapitalization autoCapitalization = b.AutoCapitalization;
+ SclDbusSetInputHint((uint)b.InputHint);
+ SclDbusUpdateBidiDirection((uint)b.BiDirection);
+ SclNuiSetUpdatePending(true);
+ ResetContext();
+
+ if (b.Language == InputPanelLanguage.Alphabet)
+ {
+ Log.Info("NUIIME", "prefer latin");
+ KeyboardState.Instance.PreferLatin = true;
+ }
+ else
+ {
+ Log.Info("NUIIME", "prefer automatic");
+ KeyboardState.Instance.PreferLatin = false;
+ }
+
+ SetLayout((KeyboardLayout)b.Layout, (uint)b.LayoutVariation);
+ SetReturnKeyType(b.ReturnKey);
+ SetReturnKeyDisable(b.ReturnKeyState);
+
+ switch (autoCapitalization)
+ {
+ case AutoCapitalization.Word:
+ case AutoCapitalization.Sentence:
+ case AutoCapitalization.AllCharacter:
+ SetCapsMode(true);
+ break;
+ case AutoCapitalization.None:
+ case AutoCapitalization.Undefined:
+ default:
+ SetCapsMode(false);
+ break;
+ }
+ UpdateCursorPosition(b.CursorPosition);
+
+ SclNui = new SCLNUI(navigator);
LanguageInfo currentLanguage = LanguageManager.Instance.GetLanguageInfo(IseConfig.Instance.SelectedLanguage);
- SCLNUI SclNui = new SCLNUI(navigator, Application.Current.DirectoryInfo.Resource + "main_entry.xml");
- SclNui.SetUpdatePending(true);
SclNui.SetInputMode(currentLanguage.SelectedInputMode);
SclNui.SetCurrentSublayout("DEFAULT");
SclNui.SetStringSubstitution("_LANGUAGE_", currentLanguage.DisplayName);
- SclNui.SetUpdatePending(false);
SclNui.EnableMagnifier(IseConfig.Instance.PreviewOn);
+ SclNuiShow();
+ KeyboardState.Instance.VisibleState = true;
+ SclNuiDisableInputEvent(false);
+ SclNuiSetUpdatePending(false);
navigator.Push(SclNui);
}
private static void Hide(InputMethodEditor.ContextId a)
{
+ if (!KeyboardState.Instance.VisibleState)
+ return;
+
+ IMEHide();
navigator.Pop();
}
+ private static void IMEHide()
+ {
+ SclNui.ClearClickCount();
+ SclNuiSetUpdatePending(true);
+ SclNuiDisableInputEvent(true);
+ SclNuiHide();
+
+ KeyboardState.Instance.VisibleState = false;
+ ResetShiftState();
+ KeyboardState.Instance.ResetMultitapState(true);
+ }
+
+ private static void ResetContext()
+ {
+ KeyboardState.Instance.ResetMultitapState(true);
+ }
+
+ private static void SetLayout(KeyboardLayout layout, UInt32 layoutVariation)
+ {
+ KeyboardState keyboardState = KeyboardState.Instance;
+ if (layout < KeyboardLayout.Max)
+ {
+ if (keyboardState.Layout != layout || keyboardState.LayoutVariation != layoutVariation)
+ keyboardState.NeedReset = true;
+ keyboardState.Layout = layout;
+ keyboardState.LayoutVariation = layoutVariation;
+ Log.Info("NUIIME", "layout : " + layout.ToString() + ", variation : " + layoutVariation.ToString());
+ }
+ }
+
+ private static void SetReturnKeyType(InputPanelReturnKey returnKey)
+ {
+ Log.Info("NUIIME", "return key : " + returnKey.ToString());
+ string label = string.Empty;
+ switch (returnKey)
+ {
+ case InputPanelReturnKey.Done:
+ label = Resource.Resources.IDS_IME_SK_DONE_ABB;
+ break;
+ case InputPanelReturnKey.Go:
+ label = Resource.Resources.IDS_IME_BUTTON_GO_M_KEYBOARD;
+ break;
+ case InputPanelReturnKey.Join:
+ label = Resource.Resources.IDS_IME_BUTTON_JOIN_M_KEYBOARD;
+ break;
+ case InputPanelReturnKey.Login:
+ label = Resource.Resources.IDS_IME_BUTTON_LOG_IN_M_KEYBOARD;
+ break;
+ case InputPanelReturnKey.Next:
+ label = Resource.Resources.IDS_IME_OPT_NEXT_ABB;
+ break;
+ case InputPanelReturnKey.Search:
+ label = Resource.Resources.IDS_IME_BUTTON_SEARCH_M_KEYBOARD;
+ break;
+ case InputPanelReturnKey.Send:
+ label = Resource.Resources.IDS_IME_BUTTON_SEND_M_KEYBOARD;
+ break;
+ case InputPanelReturnKey.SignIn:
+ label = Resource.Resources.IDS_IME_BUTTON_SIGN_IN_M_KEYBOARD;
+ break;
+ case InputPanelReturnKey.Default:
+ break;
+ default:
+ Log.Info("NUIIME", "Unknown return key : " + returnKey.ToString());
+ returnKey = InputPanelReturnKey.Default;
+ break;
+ }
+
+ if (returnKey == InputPanelReturnKey.Default)
+ {
+ SclNuiUnsetPrivateKey("Enter");
+ }
+ else
+ {
+ string[] imageLabel = {" ", " ", " "};
+ SclNuiSetPrivateKey("Enter", label, imageLabel, null, 0, "Enter", true);
+ }
+ Log.Info("NUIIME", "return key label : " + label);
+ }
+
+ private static void SetReturnKeyDisable(bool disable)
+ {
+ Log.Info("NUIIME", "return key disable : " + disable);
+ SclNuiEnableButton("Enter", !disable);
+ }
+
+ private static void SetCapsMode(bool enable)
+ {
+ Log.Info("NUIIME", "capsmode : " + enable.ToString());
+ KeyboardState keyboardState = KeyboardState.Instance;
+ keyboardState.CapsMode = enable;
+ keyboardState.CapsModePending = false;
+
+ string currentLanguage = LanguageManager.Instance.GetCurrentLanguage();
+ if (currentLanguage != null)
+ {
+ LanguageInfo languageInfo = LanguageManager.Instance.GetLanguageInfo(currentLanguage);
+ if (languageInfo != null && languageInfo.AcceptsCapsMode)
+ {
+ if (keyboardState.PreviousModifier != (uint)SclNuiKeyModifier.MultitapStart && keyboardState.PreviousModifier != (uint)SclNuiKeyModifier.MultitapRepeat)
+ keyboardState.SetCapsmode(keyboardState.CapsMode);
+ else
+ keyboardState.CapsModePending = true;
+ }
+ }
+ }
+
+ private static void UpdateCursorPosition(int position)
+ {
+ KeyboardState keyboardState = KeyboardState.Instance;
+ if (keyboardState.Layout == KeyboardLayout.URL)
+ {
+ if (position > 0)
+ SclNuiSetStringSubstitution("www.", ".com");
+ else
+ SclNuiUnsetStringSubstitution("www.");
+ }
+ }
+
+ private static void ResetShiftState()
+ {
+ uint oldState, newState;
+ SclNuiGetShiftState(out oldState);
+ newState = (uint)ShiftState.Off;
+
+ if (oldState != newState)
+ SclNuiSetShiftState(newState);
+ }
+
+ private static void RegisterCallback()
+ {
+ InputMethodEditor.FocusedIn += FocusInEvent;
+ InputMethodEditor.FocusedOut += FocusOutEvent;
+ InputMethodEditor.RotationChanged += RotationChangedEvent;
+ InputMethodEditor.AccessibilityStateChanged += AccessibilityStateChangedEvent;
+ InputMethodEditor.SurroundingTextUpdated += SurroundingTextUpdatedEvent;
+ InputMethodEditor.InputContextReset += InputContextResetEvent;
+ InputMethodEditor.CursorPositionUpdated += CursorPositionUpdatedEvent;
+ InputMethodEditor.LanguageSet += LanguageSetEvent;
+ InputMethodEditor.DataSet += DataSetEvent;
+ InputMethodEditor.LayoutSet += LayoutSetEvent;
+ InputMethodEditor.ReturnKeySet += ReturnKeySetEvent;
+ InputMethodEditor.ReturnKeyStateSet += ReturnKeyStateSetEvent;
+ InputMethodEditor.DisplayLanguageChanged += DisplayLanguageChangedEvent;
+ }
+
+ private static void UnregisterCallback()
+ {
+ InputMethodEditor.FocusedIn -= FocusInEvent;
+ InputMethodEditor.FocusedOut -= FocusOutEvent;
+ InputMethodEditor.RotationChanged -= RotationChangedEvent;
+ InputMethodEditor.AccessibilityStateChanged -= AccessibilityStateChangedEvent;
+ InputMethodEditor.SurroundingTextUpdated -= SurroundingTextUpdatedEvent;
+ InputMethodEditor.InputContextReset -= InputContextResetEvent;
+ InputMethodEditor.CursorPositionUpdated -= CursorPositionUpdatedEvent;
+ InputMethodEditor.LanguageSet -= LanguageSetEvent;
+ InputMethodEditor.DataSet -= DataSetEvent;
+ InputMethodEditor.LayoutSet -= LayoutSetEvent;
+ InputMethodEditor.ReturnKeySet -= ReturnKeySetEvent;
+ InputMethodEditor.ReturnKeyStateSet -= ReturnKeyStateSetEvent;
+ InputMethodEditor.DisplayLanguageChanged -= DisplayLanguageChangedEvent;
+ }
+
+ private static void DisplayLanguageChangedEvent(object sender, DisplayLanguageChangedEventArgs e)
+ {
+ Log.Info("NUIIME", "language : " + e.Language);
+ }
+
+ private static void ReturnKeyStateSetEvent(object sender, ReturnKeyStateSetEventArgs e)
+ {
+ Log.Info("NUIIME", "state : " + e.State.ToString());
+ }
+
+ private static void ReturnKeySetEvent(object sender, ReturnKeySetEventArgs e)
+ {
+ Log.Info("NUIIME", "type : " + e.Type.ToString());
+ }
+
+ private static void LayoutSetEvent(object sender, LayoutSetEventArgs e)
+ {
+ Log.Info("NUIIME", "layout : " + e.Layout.ToString());
+ }
+
+ private static void DataSetEvent(object sender, SetDataEventArgs e)
+ {
+ Log.Info("NUIIME", "data length : " + e.DataLength.ToString());
+ }
+
+ private static void LanguageSetEvent(object sender, LanguageSetEventArgs e)
+ {
+ Log.Info("NUIIME", "language mode : " + e.Language.ToString());
+ }
+
+ private static void CursorPositionUpdatedEvent(object sender, CursorPositionUpdatedEventArgs e)
+ {
+ Log.Info("NUIIME", "cursor position : " + e.CursorPosition.ToString());
+ }
+
+ private static void InputContextResetEvent(object sender, EventArgs e)
+ {
+ Log.Info("NUIIME", "");
+ }
+
+ private static void SurroundingTextUpdatedEvent(object sender, SurroundingTextUpdatedEventArgs e)
+ {
+ Log.Info("NUIIME", "context id : " + e.ContextId.ToString() + ", text : " + e.Text + ", cursor position : " + e.CursorPosition.ToString());
+ }
+
+ private static void AccessibilityStateChangedEvent(object sender, AccessibilityStateChangedEventArgs e)
+ {
+ Log.Info("NUIIME", "state : " + e.State.ToString());
+ }
+
+ private static void RotationChangedEvent(object sender, RotationChangedEventArgs e)
+ {
+ Log.Info("NUIIME", "degree : " + e.Degree.ToString());
+ SclNuiSetRotation(e.Degree);
+ }
+
+ private static void FocusOutEvent(object sender, FocusedOutEventArgs e)
+ {
+ Log.Info("NUIIME", "context id : " + e.ContextId.ToString());
+ KeyboardState.Instance.FocusedContext = 0;
+ KeyboardState.Instance.ResetMultitapState(true);
+ SclDbusFocusOut();
+ }
+
+ private static void FocusInEvent(object sender, FocusedInEventArgs e)
+ {
+ Log.Info("NUIIME", "context id : " + e.ContextId.ToString());
+ KeyboardState keyboardState = KeyboardState.Instance;
+ if (keyboardState.CheckContextTemporary(keyboardState.Context) && !keyboardState.CheckContextTemporary(e.ContextId))
+ keyboardState.Context = e.ContextId;
+ keyboardState.FocusedContext = e.ContextId;
+ SclDbusFocusIn();
+ }
+
static void Main(string[] args)
{
InputMethodEditor.Run(Create, Terminate, Show, Hide);
- Size2D initSize = new Size2D(720, 420);
+ Size2D initSize = new Size2D(720, 442);
Position2D initPosition = new Position2D(0, 0);
var app = new Program("", WindowMode.Opaque, initSize, initPosition, WindowType.Ime);
Done /* We're done with this event, do not call any other default SCL event handlers */
}
- internal struct Point
- {
- internal int x;
- internal int y;
- }
-
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
- internal struct SclNuiEventDesc
- {
- internal string keyValue;
- internal ulong keyEvent;
- internal SclNuiKeyType keyType;
- internal SclNuiKeyModifier keyModifier;
- internal int touchID;
- internal int touchEventOrder;
- internal Point MousePressedPoint;
- internal Point MouseCurrentPoint;
- internal Point MouseFarhestPoint;
- internal SclNuiEventType eventType;
- }
-
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
//internal delegate void DrawTextCallback(IntPtr str, int x, int y, int w, int h, int fontsize, IntPtr userData);
//internal delegate void DrawTextCallback(SclFontInfo fontinfo, SclColor color, IntPtr str, int x, int y, int w, int h, int label_alignment, int padding_x, int padding_y, int inner_width, int inner_height, IntPtr userData);
internal delegate void UpdateWindowCallback(int type, int x, int y, int width, int height, IntPtr user_data);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate int KeyClickEventCallback(IntPtr eventDesc);
+ internal delegate int KeyClickEventCallback(IntPtr key_value, int key_event, int key_type, int key_modifier);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate int DragStateChangedCallback(IntPtr eventDesc);
+ internal delegate int DragStateChangedCallback(IntPtr key_value, int key_event, int key_type, int event_type, int current_x, int current_y);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate int EventNotificationCallback(int notiType, IntPtr notiDesc);
[DllImport(Libraries.SclNui, EntryPoint = "scl_nui_fini")]
internal static extern int SclNuiFini();
+ [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_show")]
+ internal static extern int SclNuiShow();
+
+ [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_hide")]
+ internal static extern int SclNuiHide();
+
[DllImport(Libraries.SclNui, EntryPoint = "scl_nui_get_input_mode")]
internal static extern int SclNuiGetInputMode(out IntPtr mode);
[DllImport(Libraries.SclNui, EntryPoint = "scl_nui_set_string_substitution")]
internal static extern int SclNuiSetStringSubstitution(string original, string substitute);
+ [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_unset_string_substitution")]
+ internal static extern int SclNuiUnsetStringSubstitution(string original);
+
[DllImport(Libraries.SclNui, EntryPoint = "scl_nui_set_draw_text_cb")]
internal static extern int SclNuiSetDrawTextCb(DrawTextCallback callbackFunction, IntPtr userData);
[DllImport(Libraries.SclNui, EntryPoint = "scl_nui_enable_magnifier")]
internal static extern int SclNuiEnableMagnifier(bool enabled);
+ [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_enable_sound")]
+ internal static extern int SclNuiEnableSound(bool enabled);
+
+ [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_enable_vibration")]
+ internal static extern int SclNuiEnableVibration(bool enabled);
+
+ [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_set_private_key")]
+ internal static extern int SclNuiSetPrivateKey(string customId, string label, string[] imageLabel, string[] imageBG, ulong keyEvent, string keyValue, bool redraw);
+
+ [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_unset_private_key")]
+ internal static extern int SclNuiUnsetPrivateKey(string customId);
+
+ [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_enable_button")]
+ internal static extern int SclNuiEnableButton(string customId, bool enabled);
+
+ [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_get_shift_state")]
+ internal static extern int SclNuiGetShiftState(out uint state);
+
+ [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_set_shift_state")]
+ internal static extern int SclNuiSetShiftState(uint state);
+
+ [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_set_autocapital_shift_state")]
+ internal static extern int SclNuiSetAutocapitalShiftState(bool state);
+
+ [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_disable_input_event")]
+ internal static extern int SclNuiDisableInputEvent(bool disable);
+
[DllImport(Libraries.SclNui, EntryPoint = "scl_dbus_init")]
internal static extern int SclDbusInit();
using Tizen.NUI;
using Tizen.NUI.BaseComponents;
using Tizen.NUI.Components;
+using Tizen.Uix.InputMethod;
using static Interop.SclNuiCSharp;
namespace ISEDefaultNUI
private Navigator navigator = null;
private TextLabel keyText;
- private ImageView imageView;
private View rectView;
private int beforePositionX = 0;
private MagnifierWindow magnifier = MagnifierWindow.Instance;
private DimView dim = DimView.Instance;
private PopupWindow popup = PopupWindow.Instance;
+ private KeyboardState keyboardState = KeyboardState.Instance;
+
+ private uint clickCount = 0;
+ private string[] sigDec = {".", "-"};
+ private uint[] sigDecEvent = {'.', '-'};
+ private Timer commitTimer;
enum LabelAlignment
{
Max,
}
- struct SclPoint
- {
- public int x, y;
- };
-
- public SCLNUI(Navigator Navigator, string path) : base()
+ public SCLNUI(Navigator Navigator) : base()
{
Layout = new AbsoluteLayout();
navigator = Navigator;
- SclNuiInit(path);
image_list = new List<ImageView>();
label_list = new List<TextLabel>();
+ commitTimer = new Timer(1000);
+ commitTimer.Tick += CommitTimerTick;
+
/* Draw text callback */
//_draw_text_cb = (IntPtr str, int x, int y, int w, int h, int fontsize, IntPtr userData) =>
};
SclNuiUpdateWindowCb(_update_window_cb, (IntPtr)null);
- _onKeyClickEvent = (IntPtr eventDesc) =>
+ _onKeyClickEvent = (IntPtr key_value, int key_event, int key_type, int key_modifier) =>
{
- IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(eventDesc));
- Marshal.StructureToPtr(eventDesc, pnt, false);
- SclNuiEventDesc eventInfo;
- eventInfo = (SclNuiEventDesc)Marshal.PtrToStructure(pnt, typeof(SclNuiEventDesc));
+ string keyValue = Marshal.PtrToStringAnsi(key_value);
+ SclNuiKeyType keyType = (SclNuiKeyType)key_type;
+ SclNuiKeyModifier keyModifier = (SclNuiKeyModifier)key_modifier;
+
+ IntPtr inputModePtr;
+ SclNuiGetInputMode(out inputModePtr);
+ string inputMode = Marshal.PtrToStringAnsi(inputModePtr);
+ if (keyModifier == SclNuiKeyModifier.MultitapStart)
+ {
+ if (keyboardState.MultitapValue.Length > 0)
+ Common.SendString(keyboardState.MultitapValue);
- if (eventInfo.keyValue.Equals("OPTION"))
+ Common.UpdatePreeditString(keyValue, false);
+ keyboardState.MultitapValue = keyValue;
+ }
+ else if (keyModifier == SclNuiKeyModifier.MultitapRepeat)
{
- navigator.Pop();
- KeyboardSettingPage keyboardSettingPage = new KeyboardSettingPage(navigator);
- navigator.Push(keyboardSettingPage);
+ Common.UpdatePreeditString(keyValue, false);
+ keyboardState.MultitapValue = keyValue;
+ }
+ else
+ {
+ keyboardState.ResetMultitapState(false);
+ }
+
+ keyboardState.PreviousModifier = (uint)keyModifier;
+ switch (keyType)
+ {
+ case SclNuiKeyType.String:
+ {
+ if (keyModifier != SclNuiKeyModifier.MultitapStart && keyModifier != SclNuiKeyModifier.MultitapRepeat)
+ {
+ if (key_event > 0)
+ Common.ForwardKeyEvent((KeyCode)key_event);
+ else
+ Common.SendString(keyValue);
+ }
+ }
+ break;
+ case SclNuiKeyType.Char:
+ {
+ bool needForward = false;
+ if (inputMode.Length > 0)
+ {
+ if (inputMode.Equals("SYM_QTY_1") || inputMode.Equals("SYM_QTY_2") || inputMode.Equals("PHONE_3X4") ||
+ inputMode.Equals("IPv6_3X4_123") || inputMode.Equals("IPv6_3X4_ABC") || inputMode.Equals("NUMBERONLY_3X4") ||
+ inputMode.Equals("NUMBERONLY_3X4_SIG") || inputMode.Equals("NUMBERONLY_3X4_DEC") || inputMode.Equals("NUMBERONLY_3X4_SIGDEC") ||
+ inputMode.Equals("DATETIME_3X4"))
+ needForward = true;
+ }
+
+ if (inputMode.Length > 0 && inputMode.Equals("NUMBERONLY_3X4_SIGDEC") && keyValue.Equals("."))
+ {
+ Common.UpdatePreeditString(sigDec[clickCount%ResourceManager.SigDecSize], false);
+ InputMethodEditor.ShowPreEditString();
+ commitTimer.Start();
+ clickCount++;
+ }
+ else if (key_event > 0)
+ {
+ if (commitTimer.IsRunning())
+ {
+ commitTimer.Stop();
+ CommitTimerTick(null, null);
+ }
+
+ if (needForward)
+ {
+ Common.ForwardKeyEvent((KeyCode)key_event);
+ }
+ else
+ {
+ Common.SendKeyEvent((KeyCode)key_event);
+ }
+ }
+ }
+ break;
+ case SclNuiKeyType.None:
+ break;
+ case SclNuiKeyType.Control:
+ break;
+ case SclNuiKeyType.Modechange:
+ break;
+ case SclNuiKeyType.User:
+ break;
+ case SclNuiKeyType.Max:
+ break;
+ default:
+ break;
}
- IntPtr inputMode;
- SclNuiGetInputMode(out inputMode);
- string mode = Marshal.PtrToStringAnsi(inputMode);
- if (eventInfo.keyValue.Equals("Space") && afterPositionX != 0 && Math.Abs(beforePositionX - afterPositionX) > 100 && !mode.Equals("SYM_QTY_1"))
+ if (keyValue.Equals("OPTION"))
+ {
+ AppControl appControl = new AppControl();
+ appControl.Operation = AppControlOperations.Default;
+ appControl.ApplicationId = ResourceManager.IseSettingAppId;
+ appControl.ExtraData.Add("caller", "NUI_IME");
+ appControl.LaunchMode = AppControlLaunchMode.Group;
+ AppControl.SendLaunchRequest(appControl);
+ }
+
+ if (keyValue.Equals("Space") && afterPositionX != 0 && Math.Abs(beforePositionX - afterPositionX) > 100 && !inputMode.Equals("SYM_QTY_1"))
{
navigator.Pop();
- SCLNUI SclNui = new SCLNUI(navigator, Application.Current.DirectoryInfo.Resource + "main_entry.xml");
+ SCLNUI SclNui = new SCLNUI(navigator);
SclNui.SetUpdatePending(true);
LanguageInfo nextLanguage = beforePositionX < afterPositionX ? LanguageManager.Instance.GetNextLanguage() : LanguageManager.Instance.GetPreviousLanguage();
LanguageManager.Instance.SelectLanguage(nextLanguage);
IseConfig.Instance.SelectedLanguage = nextLanguage.Name;
IseConfig.Instance.WriteIseConfig();
+
+ if (!nextLanguage.LoadInIME)
+ {
+ /* FIXME : This comment should be removed when using IMEngine
+ string uuid = LanguageManager.Instance.GetUuid(nextLanguage.KeyboardISEUuid);
+ ApplicationInfo applicationInfo = new ApplicationInfo(uuid);
+ SclDbusSetImengine(uuid, applicationInfo.PackageId);
+ */
+ }
+
SclNui.SetInputMode(nextLanguage.SelectedInputMode);
SclNui.SetCurrentSublayout("DEFAULT");
SclNui.SetStringSubstitution("_LANGUAGE_", nextLanguage.DisplayName);
navigator.Push(SclNui);
}
- if (eventInfo.keyValue.Equals("CUR_LANG"))
+ if (keyValue.Equals("CUR_LANG"))
{
this.SetUpdatePending(true);
LanguageInfo currentLanguage = LanguageManager.Instance.GetLanguageInfo(LanguageManager.Instance.GetCurrentLanguage());
beforePositionX = 0;
afterPositionX = 0;
- Marshal.FreeHGlobal(pnt);
return (int)SclNuiEventReturnType.PassOn;
};
SclNuiKeyClickEventCb(_onKeyClickEvent);
- _onDragStateChangedEvent = (IntPtr eventDesc) =>
+ _onDragStateChangedEvent = (IntPtr key_value, int key_event, int key_type, int event_type, int current_x, int current_y) =>
{
- IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(eventDesc));
- Marshal.StructureToPtr(eventDesc, pnt, false);
- SclNuiEventDesc eventInfo;
- eventInfo = (SclNuiEventDesc)Marshal.PtrToStructure(pnt, typeof(SclNuiEventDesc));
-
return (int)SclNuiEventReturnType.PassOn;
};
SclNuiDragStateChangedCb(_onDragStateChangedEvent);
SclNuiUpdateWindowPositionCb(_updateWindowPositionChangedEvent, (IntPtr)null);
}
+ private bool CommitTimerTick(object source, Timer.TickEventArgs e)
+ {
+ InputMethodEditor.HidePreEditString();
+ Common.ForwardKeyEvent((KeyCode)sigDecEvent[(clickCount - 1)%ResourceManager.SigDecSize]);
+ clickCount = 0;
+ return true;
+ }
+
//FIXME: This should use RotationChanged of the Inputmethod.
private void OnResized(object sender, Window.ResizedEventArgs e)
{
~SCLNUI()
{
- SclNuiFini();
- }
-
- void UpdateArea(int x, int y, int width, int height)
- {
- //return;
-
- if (x + y + width + height == 0)
- {
- dispose_all_objects();
- }
- else
- {
- Rectangle updateArea = new Rectangle(x, y, width, height);
-
- int idx = 0;
- ImageView image_elem;
- TextLabel label_elem;
- Rectangle obj_rect;
-
- while (idx < image_list.Count)
- {
- image_elem = image_list[idx];
- obj_rect = new Rectangle((int)image_elem.Position.X, (int)image_elem.Position.Y, (int)image_elem.Size.Width, (int)image_elem.Size.Height);
-
- if (obj_rect.Intersects(updateArea))
- {
- Log.Info("NUIIME", "remove image idx:" + idx);
- image_elem.Hide();
- image_elem.Unparent();
- image_elem.Dispose();
- image_elem = null;
- image_list.RemoveAt(idx);
- }
- else
- idx++;
- }
-
- idx = 0;
- while (idx < label_list.Count)
- {
- label_elem = label_list[idx];
- obj_rect = new Rectangle((int)label_elem.Position.X, (int)label_elem.Position.Y, (int)label_elem.Size.Width, (int)label_elem.Size.Height);
-
- if (obj_rect.Intersects(updateArea))
- {
- Log.Info("NUIIME", "remove label idx(" + idx + "), label(" + label_elem.Text + ")");
- label_elem.Hide();
- label_elem.Unparent();
- label_elem.Dispose();
- label_elem = null;
- label_list.RemoveAt(idx);
- }
- else
- idx++;
- }
- }
}
TextLabel draw_text(string FontName, short font_size, bool is_italic, bool is_bold, int r, int g, int b, int a,
{
return SclNuiEnableMagnifier(enabled);
}
+
+ public void ClearClickCount()
+ {
+ clickCount = 0;
+ }
}
}
{
navigator.Pop();
LanguageInfo currentLanguage = LanguageManager.Instance.GetLanguageInfo(LanguageManager.Instance.GetCurrentLanguage());
- SCLNUI SclNui = new SCLNUI(navigator, Application.Current.DirectoryInfo.Resource + "main_entry.xml");
+ SCLNUI SclNui = new SCLNUI(navigator);
SclNui.SetUpdatePending(true);
SclNui.SetInputMode(currentLanguage.SelectedInputMode);
SclNui.SetCurrentSublayout("DEFAULT");
<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns="http://tizen.org/ns/packages" api-version="6.5" package="org.tizen.ISEDefaultNUI" version="1.0.0">
- <profile name="common" />
- <ui-application appid="org.tizen.ISEDefaultNUI"
- exec="ISEDefaultNUI.dll"
- type="dotnet"
- multiple="false"
- taskmanage="false"
- nodisplay="true"
- launch_mode="single"
- >
- <label>ISEDefaultNUI</label>
- <icon>ISEDefaultNUI.png</icon>
- <metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
- <category name="http://tizen.org/category/ime" />
- </ui-application>
- <privileges>
- <privilege>http://tizen.org/privilege/ime</privilege>
- </privileges>
+<manifest package="org.tizen.ISEDefaultNUI" version="1.0.0" api-version="6.5" xmlns="http://tizen.org/ns/packages">
+ <profile name="common" />
+ <ui-application appid="org.tizen.ISEDefaultNUI" exec="ISEDefaultNUI.dll" multiple="false" nodisplay="true" taskmanage="false" type="dotnet" launch_mode="single">
+ <label>ISEDefaultNUI</label>
+ <icon>ISEDefaultNUI.png</icon>
+ <metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
+ <category name="http://tizen.org/category/ime" />
+ <splash-screens />
+ </ui-application>
+ <shortcut-list />
+ <privileges>
+ <privilege>http://tizen.org/privilege/ime</privilege>
+ <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+ </privileges>
+ <dependencies />
+ <provides-appdefined-privileges />
</manifest>