From 1c25d0fd1b4d19d8da7f5144f2ebf75ac4888cb7 Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Tue, 4 Apr 2017 15:31:13 +0200 Subject: [PATCH] Language: improve confirmboxes Generic "OK" buttons should be avoided. Thanks to @lightonflux for pointing this out https://github.com/koreader/koreader/issues/2555#issuecomment-291039945 --- frontend/apps/filemanager/filemanager.lua | 9 +++++---- frontend/ui/network/manager.lua | 4 +++- frontend/ui/otamanager.lua | 1 + frontend/ui/widget/confirmbox.lua | 6 +++++- frontend/ui/widget/inputdialog.lua | 8 ++++++++ 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/frontend/apps/filemanager/filemanager.lua b/frontend/apps/filemanager/filemanager.lua index fbae28726..ed513f20d 100644 --- a/frontend/apps/filemanager/filemanager.lua +++ b/frontend/apps/filemanager/filemanager.lua @@ -196,6 +196,7 @@ function FileManager:init() UIManager:close(self.file_dialog) UIManager:show(ConfirmBox:new{ text = _("Are you sure that you want to delete this file?\n") .. file .. ("\n") .. _("If you delete a file, it is permanently lost."), + ok_text = _("Delete"), ok_callback = function() local autoremove_deleted_items_from_history = G_reader_settings:readSetting("autoremove_deleted_items_from_history") or false local file_abs_path = util.realpath(file) @@ -220,18 +221,18 @@ function FileManager:init() input = util.basename(file), buttons = {{ { - text = _("OK"), + text = _("Cancel"), enabled = true, callback = function() - renameFile(file) - self:refreshPath() UIManager:close(fileManager.rename_dialog) end, }, { - text = _("Cancel"), + text = _("Rename"), enabled = true, callback = function() + renameFile(file) + self:refreshPath() UIManager:close(fileManager.rename_dialog) end, }, diff --git a/frontend/ui/network/manager.lua b/frontend/ui/network/manager.lua index 7509f0981..d5bef5bb0 100644 --- a/frontend/ui/network/manager.lua +++ b/frontend/ui/network/manager.lua @@ -39,6 +39,7 @@ function NetworkMgr:restoreWifiAsync() end function NetworkMgr:promptWifiOn(complete_callback) UIManager:show(ConfirmBox:new{ text = _("Do you want to turn on Wi-Fi?"), + ok_text = _("Turn on"), ok_callback = function() self.wifi_was_on = true G_reader_settings:saveSetting("wifi_was_on", true) @@ -50,6 +51,7 @@ end function NetworkMgr:promptWifiOff(complete_callback) UIManager:show(ConfirmBox:new{ text = _("Do you want to turn off Wi-Fi?"), + ok_text = _("Turn off"), ok_callback = function() self.wifi_was_on = false G_reader_settings:saveSetting("wifi_was_on", false) @@ -160,7 +162,7 @@ function NetworkMgr:getInfoMenuTable() }) else UIManager:show(InfoMessage:new{ - text = _("Cannot retrieve network info"), + text = _("Could not retrieve network info."), timeout = 3, }) end diff --git a/frontend/ui/otamanager.lua b/frontend/ui/otamanager.lua index 92f7a52a3..105feb649 100644 --- a/frontend/ui/otamanager.lua +++ b/frontend/ui/otamanager.lua @@ -145,6 +145,7 @@ function OTAManager:fetchAndProcessUpdate() local_version, ota_version ), + ok_text = _("Update"), ok_callback = function() UIManager:show(InfoMessage:new{ text = _("Downloading may take several minutes…"), diff --git a/frontend/ui/widget/confirmbox.lua b/frontend/ui/widget/confirmbox.lua index 71bc666ff..4cf21a482 100644 --- a/frontend/ui/widget/confirmbox.lua +++ b/frontend/ui/widget/confirmbox.lua @@ -1,5 +1,5 @@ --[[-- -Widget that shows a message and OK/Cancel buttons +Widget that shows a confirmation alert with a message and Cancel/OK buttons Example: @@ -11,6 +11,10 @@ Example: end, }) +It is strongly recommended to set a custom `ok_text` describing the action to be +confirmed, as demonstrated in the example above. No ok_text should be specified +if the resulting phrase would be longer than three words. + ]] local InputContainer = require("ui/widget/container/inputcontainer") diff --git a/frontend/ui/widget/inputdialog.lua b/frontend/ui/widget/inputdialog.lua index b35e53bee..38d141a98 100644 --- a/frontend/ui/widget/inputdialog.lua +++ b/frontend/ui/widget/inputdialog.lua @@ -37,6 +37,14 @@ Example: sample_input:onShowKeyboard() UIManager:show(sample_input) +If it would take the user more than half a minute to recover from a mistake, +a "Cancel" button must be added to the dialog. The cancellation button +should be kept on the left and the button executing the action on the right. + +It is strongly recommended to use a text describing the action to be +executed, as demonstrated in the example above. If the resulting phrase would be +longer than three words it should just read "OK". + ]] local Blitbuffer = require("ffi/blitbuffer")