2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using static Interop.InputMethodManager;
20 namespace Tizen.Uix.InputMethodManager
23 /// This class provides the function for launching the input method editor (IME) list and selector settings. A user can manage the installed IMEs in the system.
24 /// The input method editor (IME) is an input panel that lets users provide an input and the platform to receive the text data entered.
25 /// The manager is a module for managing the installed IMEs.
26 /// IME developers can use this module to open the installed IME list or the selector menu after their IME installation, and then guide to select the installed IME.
28 /// <since_tizen> 3 </since_tizen>
29 public static class Manager
32 /// Requests to open the installed IME list menu.
33 /// This API provides the installed IME list menu for IME developers who might want to open it to enable their IME.
36 /// http://tizen.org/privilege/imemanager
38 /// <exception cref="T:System.InvalidOperationException">
39 /// This exception can occur if:
40 /// 1) The application does not have the privilege to call this function.
41 /// 2) Operation failed.
43 /// <since_tizen> 3 </since_tizen>
44 public static void ShowIMEList()
46 ErrorCode error = ImeManagerShowImeList();
47 if (error != ErrorCode.None)
49 Log.Error(LogTag, "ShowIMEList Failed with error " + error);
50 throw InputMethodManagerExceptionFactory.CreateException(error);
55 /// Requests to open the IME selector menu.
56 /// This API provides the IME selector menu for the IME or other application developers who might want to change the default IME.
59 /// http://tizen.org/privilege/imemanager
61 /// <exception cref="T:System.InvalidOperationException">
62 /// This exception can occur if:
63 /// 1) The application does not have the privilege to call this function.
64 /// 2) Operation failed.
66 /// <since_tizen> 3 </since_tizen>
67 public static void ShowIMESelector()
69 ErrorCode error = ImeManagerShowImeSelector();
70 if (error != ErrorCode.None)
72 Log.Error(LogTag, "ShowIMESelector Failed with error " + error);
73 throw InputMethodManagerExceptionFactory.CreateException(error);
78 /// Checks if the specific IME is enabled or disabled in the system keyboard setting.
79 /// The IME developers can use this property to check if their IME is enabled or not.
82 /// http://tizen.org/privilege/imemanager
84 /// <param name="appId">The application ID of the IME.</param>
85 /// <returns>The On (enabled) and Off (disabled) state of the IME.</returns>
86 /// <exception cref="T:System.ArgumentException">
87 /// This exception can occur if an invalid parameter is provided.
89 /// <exception cref="T:System.InvalidOperationException">
90 /// This exception can occur if:
91 /// 1) The application does not have the privilege to call this function.
92 /// 2) Operation failed.
94 /// <since_tizen> 3 </since_tizen>
95 public static bool IsIMEEnabled(string appId)
98 ErrorCode error = ImeManagerIsImeEnabled(appId, out isIMEEnabled);
99 if (error != ErrorCode.None)
101 Log.Error(LogTag, "IsIMEEnabled Failed with error " + error);
102 throw InputMethodManagerExceptionFactory.CreateException(error);
109 /// Checks which IME is the current activated (selected) IME.
112 /// http://tizen.org/privilege/imemanager
115 /// The current activated (selected) IME.
117 /// <exception cref="T:System.InvalidOperationException">
118 /// This exception can occur if:
119 /// 1) The application does not have the privilege to call this function.
120 /// 2) Operation failed.
122 /// <since_tizen> 3 </since_tizen>
123 public static string GetActiveIME()
126 ErrorCode error = ImeManagerGetActiveIme(out activeIME);
127 if (error != ErrorCode.None)
129 Log.Error(LogTag, "GetActiveIME Failed with error " + error);
130 throw InputMethodManagerExceptionFactory.CreateException(error);
137 /// Gets the number of IMEs that are enabled (usable).
140 /// http://tizen.org/privilege/imemanager
143 /// The number of enabled IMEs.
145 /// <exception cref="T:System.InvalidOperationException">
146 /// This exception can occur if:
147 /// 1) The application does not have the privilege to call this function.
148 /// 2) Operation failed.
150 /// <since_tizen> 3 </since_tizen>
151 public static int GetEnabledIMECount()
153 int activeIME = ImeManagerGetEnabledImeCount();
154 ErrorCode error = (ErrorCode)Tizen.Internals.Errors.ErrorFacts.GetLastResult();
155 if (error != ErrorCode.None)
157 Log.Error(LogTag, "GetEnabledIMECount Failed with error " + error);
158 throw InputMethodManagerExceptionFactory.CreateException(error);
165 /// Requests to pre-launch the IME.
166 /// The developers can use this function to launch the IME in on-demand mode.
169 /// http://tizen.org/privilege/imemanager
171 /// <exception cref="T:System.InvalidOperationException">
172 /// This exception can occur if:
173 /// 1) The application does not have the privilege to call this function.
174 /// 2) Operation failed.
176 /// <since_tizen> 5 </since_tizen>
177 public static void PrelaunchIME()
179 ErrorCode error = ImeManagerPrelaunchIme();
180 if (error != ErrorCode.None)
182 Log.Error(LogTag, "PrelaunchIME Failed with error " + error);
183 throw InputMethodManagerExceptionFactory.CreateException(error);