@@ -170,8 +170,53 @@ def get_dpi():
170170cdef extern void android_show_keyboard(int )
171171cdef extern void android_hide_keyboard()
172172
173- def show_keyboard (input_type ):
174- android_show_keyboard(input_type)
173+ # Flags for input_type, for requesting a particular type of keyboard
174+ # android FLAGS
175+ TYPE_CLASS_DATETIME = 4
176+ TYPE_CLASS_NUMBER = 2
177+ TYPE_NUMBER_VARIATION_NORMAL = 0
178+ TYPE_NUMBER_VARIATION_PASSWORD = 16
179+ TYPE_CLASS_TEXT = 1
180+ TYPE_TEXT_FLAG_AUTO_COMPLETE = 65536
181+ TYPE_TEXT_FLAG_AUTO_CORRECT = 32768
182+ TYPE_TEXT_FLAG_NO_SUGGESTIONS = 524288
183+ TYPE_TEXT_VARIATION_EMAIL_ADDRESS = 32
184+ TYPE_TEXT_VARIATION_NORMAL = 0
185+ TYPE_TEXT_VARIATION_PASSWORD = 128
186+ TYPE_TEXT_VARIATION_POSTAL_ADDRESS = 112
187+ TYPE_TEXT_VARIATION_URI = 16
188+ TYPE_CLASS_PHONE = 3
189+
190+ def show_keyboard (target , input_type ):
191+ if input_type == ' text' :
192+ _input_type = TYPE_CLASS_TEXT
193+ elif input_type == ' number' :
194+ _input_type = TYPE_CLASS_NUMBER
195+ elif input_type == ' url' :
196+ _input_type = \
197+ TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_URI
198+ elif input_type == ' mail' :
199+ _input_type = \
200+ TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_EMAIL_ADDRESS
201+ elif input_type == ' datetime' :
202+ _input_type = TYPE_CLASS_DATETIME
203+ elif input_type == ' tel' :
204+ _input_type = TYPE_CLASS_PHONE
205+ elif input_type == ' address' :
206+ _input_type = TYPE_TEXT_VARIATION_POSTAL_ADDRESS
207+
208+ if target.password:
209+ if _input_type == TYPE_CLASS_TEXT:
210+ _input_type |= TYPE_TEXT_VARIATION_PASSWORD
211+ elif _input_type == TYPE_CLASS_NUMBER:
212+ _input_type |= TYPE_NUMBER_VARIATION_PASSWORD
213+
214+ if not target.keyboard_suggestions:
215+ if _input_type == TYPE_CLASS_TEXT:
216+ _input_type = TYPE_CLASS_TEXT | \
217+ TYPE_TEXT_FLAG_NO_SUGGESTIONS
218+
219+ android_show_keyboard(_input_type)
175220
176221def hide_keyboard ():
177222 android_hide_keyboard()
0 commit comments