From: Alexis Laferrière Date: Thu, 3 Mar 2016 16:11:04 +0000 (-0500) Subject: lib/android: implement `TextInput::is_password` X-Git-Url: http://nitlanguage.org lib/android: implement `TextInput::is_password` Signed-off-by: Alexis Laferrière --- diff --git a/lib/android/ui/ui.nit b/lib/android/ui/ui.nit index 476ad82..d6cb45e 100644 --- a/lib/android/ui/ui.nit +++ b/lib/android/ui/ui.nit @@ -169,6 +169,26 @@ end redef class TextInput redef type NATIVE: NativeEditText redef var native = (new NativeEditText(app.native_activity)).new_global_ref + + redef fun is_password=(value) + do + native.is_password = value or else false + super + end +end + +redef class NativeEditText + + # Configure this view to hide passwords + fun is_password=(value: Bool) in "Java" `{ + if (value) { + self.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD); + self.setTransformationMethod(android.text.method.PasswordTransformationMethod.getInstance()); + } else { + self.setInputType(android.text.InputType.TYPE_CLASS_TEXT); + self.setTransformationMethod(null); + } + `} end redef class Button