mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
the Back key on Android should close the popup window and menu
This commit is contained in:
@@ -61,7 +61,8 @@ function FileManager:init()
|
||||
if DocumentRegistry:getProvider(filename) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end,
|
||||
close_callback = function() return self:onClose() end,
|
||||
}
|
||||
self.file_chooser = file_chooser
|
||||
|
||||
@@ -154,6 +155,7 @@ function FileManager:toggleHiddenFiles()
|
||||
end
|
||||
|
||||
function FileManager:onClose()
|
||||
DEBUG("close filemanager")
|
||||
UIManager:close(self)
|
||||
if self.onExit then
|
||||
self:onExit()
|
||||
|
||||
@@ -31,7 +31,7 @@ function FileManagerMenu:init()
|
||||
}
|
||||
self.registered_widgets = {}
|
||||
|
||||
if Device:hasKeyboard() then
|
||||
if Device:hasKeys() then
|
||||
self.key_events = {
|
||||
ShowMenu = { { "Menu" }, doc = "show menu" },
|
||||
}
|
||||
|
||||
@@ -12,13 +12,6 @@ local _ = require("gettext")
|
||||
local ReaderHighlight = InputContainer:new{}
|
||||
|
||||
function ReaderHighlight:init()
|
||||
if Device:hasKeyboard() then
|
||||
self.key_events = {
|
||||
ShowToc = {
|
||||
{ "." },
|
||||
doc = "highlight text" },
|
||||
}
|
||||
end
|
||||
self.ui.menu:registerToMainMenu(self)
|
||||
end
|
||||
|
||||
@@ -310,6 +303,7 @@ function ReaderHighlight:onHoldRelease(arg, ges)
|
||||
{
|
||||
{
|
||||
text = _("Translate"),
|
||||
enabled = false,
|
||||
callback = function()
|
||||
self:translate(self.selected_text)
|
||||
UIManager:close(self.highlight_dialog)
|
||||
|
||||
@@ -43,9 +43,10 @@ function ReaderMenu:init()
|
||||
}
|
||||
self.registered_widgets = {}
|
||||
|
||||
if Device:hasKeyboard() then
|
||||
if Device:hasKeys() then
|
||||
self.key_events = {
|
||||
ShowReaderMenu = { { "Menu" }, doc = "show menu" },
|
||||
Close = { { "Back" }, doc = "close menu" },
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ local ReaderPaging = InputContainer:new{
|
||||
}
|
||||
|
||||
function ReaderPaging:init()
|
||||
if Device:hasKeyboard() then
|
||||
if Device:hasKeyboard() or Device:hasKeys() then
|
||||
self.key_events = {
|
||||
GotoNextPage = {
|
||||
{Input.group.PgFwd}, doc = "go to next page",
|
||||
|
||||
@@ -23,7 +23,7 @@ local ReaderRolling = InputContainer:new{
|
||||
}
|
||||
|
||||
function ReaderRolling:init()
|
||||
if Device:hasKeyboard() then
|
||||
if Device:hasKeyboard() or Device:hasKeys() then
|
||||
self.key_events = {
|
||||
GotoNextView = {
|
||||
{ Input.group.PgFwd },
|
||||
|
||||
@@ -70,7 +70,7 @@ function ReaderUI:init()
|
||||
self.dialog = self
|
||||
end
|
||||
|
||||
if Device:hasKeyboard() then
|
||||
if Device:hasKeys() then
|
||||
self.key_events.Back = {
|
||||
{ "Back" }, doc = "close document",
|
||||
event = "Close" }
|
||||
|
||||
@@ -16,10 +16,9 @@ local ButtonDialog = InputContainer:new{
|
||||
}
|
||||
|
||||
function ButtonDialog:init()
|
||||
if Device:hasKeyboard() then
|
||||
if Device:hasKeys() then
|
||||
self.key_events = {
|
||||
AnyKeyPressed = { { Input.group.Any },
|
||||
seqtext = "any key", doc = "close dialog" }
|
||||
Close = { {"Back"}, doc = "close button dialog" }
|
||||
}
|
||||
end
|
||||
if Device:isTouchDevice() then
|
||||
@@ -58,4 +57,9 @@ function ButtonDialog:onTapClose()
|
||||
return true
|
||||
end
|
||||
|
||||
function ButtonDialog:onClose()
|
||||
self:onTapClose()
|
||||
return true
|
||||
end
|
||||
|
||||
return ButtonDialog
|
||||
|
||||
@@ -459,7 +459,8 @@ function ConfigDialog:init()
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
end
|
||||
if Device:hasKeys() then
|
||||
-- set up keyboard events
|
||||
self.key_events.Close = { {"Back"}, doc = "close config menu" }
|
||||
-- we won't catch presses to "Right"
|
||||
@@ -551,4 +552,9 @@ function ConfigDialog:onTapCloseMenu(arg, ges_ev)
|
||||
end
|
||||
end
|
||||
|
||||
function ConfigDialog:onClose()
|
||||
self:closeDialog()
|
||||
return true
|
||||
end
|
||||
|
||||
return ConfigDialog
|
||||
|
||||
@@ -46,6 +46,11 @@ local DictQuickLookup = InputContainer:new{
|
||||
|
||||
function DictQuickLookup:init()
|
||||
self:changeToDefaultDict()
|
||||
if Device:hasKeys() then
|
||||
self.key_events = {
|
||||
Close = { {"Back"}, doc = "close quick lookup" }
|
||||
}
|
||||
end
|
||||
if Device:isTouchDevice() then
|
||||
self.ges_events = {
|
||||
TapCloseDict = {
|
||||
|
||||
@@ -26,7 +26,7 @@ local InfoMessage = InputContainer:new{
|
||||
}
|
||||
|
||||
function InfoMessage:init()
|
||||
if Device:hasKeyboard() then
|
||||
if Device:hasKeys() then
|
||||
self.key_events = {
|
||||
AnyKeyPressed = { { Input.group.Any },
|
||||
seqtext = "any key", doc = "close dialog" }
|
||||
|
||||
@@ -152,7 +152,7 @@ function MenuItem:init()
|
||||
},
|
||||
}
|
||||
end
|
||||
if Device:hasKeyboard() then
|
||||
if Device:hasKeys() then
|
||||
self.active_key_events = {
|
||||
Select = { {"Press"}, doc = "chose selected item" },
|
||||
}
|
||||
@@ -447,7 +447,7 @@ function Menu:init()
|
||||
}
|
||||
}
|
||||
end
|
||||
if Device:hasKeyboard() then
|
||||
if Device:hasKeys() then
|
||||
-- set up keyboard events
|
||||
self.key_events.Close = { {"Back"}, doc = "close menu" }
|
||||
self.key_events.NextPage = {
|
||||
|
||||
@@ -22,7 +22,7 @@ local Notification = InputContainer:new{
|
||||
}
|
||||
|
||||
function Notification:init()
|
||||
if Device:hasKeyboard() then
|
||||
if Device:hasKeys() then
|
||||
self.key_events = {
|
||||
AnyKeyPressed = { { Input.group.Any }, seqtext = "any key", doc = "close dialog" }
|
||||
}
|
||||
|
||||
@@ -251,6 +251,8 @@ function TouchMenu:init()
|
||||
}
|
||||
}
|
||||
|
||||
self.key_events.Close = { {"Back"}, doc = "close touch menu" }
|
||||
|
||||
local icons = {}
|
||||
for _,v in ipairs(self.tab_item_table) do
|
||||
table.insert(icons, v.icon)
|
||||
@@ -498,4 +500,8 @@ function TouchMenu:onTapCloseAllMenus(arg, ges_ev)
|
||||
end
|
||||
end
|
||||
|
||||
function TouchMenu:onClose()
|
||||
self:closeMenu()
|
||||
end
|
||||
|
||||
return TouchMenu
|
||||
|
||||
Reference in New Issue
Block a user