From b883979fbaf98b4b91ddd2f9e582e0636d4678e6 Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 2 Aug 2017 14:00:42 +0200 Subject: [PATCH] Option to make password visible when entering (#3040) * Option to make password visible when entering --- frontend/ui/widget/inputdialog.lua | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/frontend/ui/widget/inputdialog.lua b/frontend/ui/widget/inputdialog.lua index 69c4f5ba6..c270539cd 100644 --- a/frontend/ui/widget/inputdialog.lua +++ b/frontend/ui/widget/inputdialog.lua @@ -63,6 +63,7 @@ local VerticalGroup = require("ui/widget/verticalgroup") local WidgetContainer = require("ui/widget/container/widgetcontainer") local UIManager = require("ui/uimanager") local Screen = require("device").screen +local _ = require("gettext") local InputDialog = InputContainer:new{ title = "", @@ -72,6 +73,7 @@ local InputDialog = InputContainer:new{ buttons = nil, input_type = nil, enter_callback = nil, + show_password_toggle = true, width = nil, @@ -147,7 +149,26 @@ function InputDialog:init() scroll = false, parent = self, } - + local is_password_type = false + if self._input_widget.text_type == "password" then + is_password_type = true + end + if self.show_password_toggle and is_password_type then + local button_switch = { + { + text = _("Show password"), + callback = function() + if self._input_widget.text_type == "text" then + self._input_widget.text_type = "password" + else + self._input_widget.text_type = "text" + end + self._input_widget:setText(self._input_widget:getText()) + end, + }, + } + table.insert(self.buttons[1], button_switch[1]) + end self.button_table = ButtonTable:new{ width = self.width, button_font_face = "cfont",