mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[UX] Gesture manager: add action - clear location history (#4716)
Also show notification when previous_location can't go back because the location stack is empty.
This commit is contained in:
@@ -278,7 +278,7 @@ This allows you to specify how much smaller or larger it should be relative to t
|
||||
text = _("Clear location history?"),
|
||||
ok_text = _("Clear"),
|
||||
ok_callback = function()
|
||||
self.location_stack = {}
|
||||
self:onClearLocationStack()
|
||||
touchmenu_instance:closeMenu()
|
||||
end,
|
||||
})
|
||||
@@ -440,6 +440,17 @@ function ReaderLink:addCurrentLocationToStack()
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderLink:onClearLocationStack(show_notification)
|
||||
self.location_stack = {}
|
||||
if show_notification then
|
||||
UIManager:show(Notification:new{
|
||||
text = _("Location history cleared."),
|
||||
timeout = 2,
|
||||
})
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
--- Goes to link.
|
||||
-- (This is called by other modules (highlight, search) to jump to a xpointer,
|
||||
-- they should not provide allow_footnote_popup=true)
|
||||
@@ -613,12 +624,17 @@ function ReaderLink:onGotoLink(link, neglect_current_location, allow_footnote_po
|
||||
end
|
||||
|
||||
--- Goes back to previous location.
|
||||
function ReaderLink:onGoBackLink()
|
||||
function ReaderLink:onGoBackLink(show_notification_if_empty)
|
||||
local saved_location = table.remove(self.location_stack)
|
||||
if saved_location then
|
||||
logger.dbg("GoBack: restoring:", saved_location)
|
||||
self.ui:handleEvent(Event:new('RestoreBookLocation', saved_location))
|
||||
return true
|
||||
elseif show_notification_if_empty then
|
||||
UIManager:show(Notification:new{
|
||||
text = _("Location history is empty."),
|
||||
timeout = 2,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -637,7 +653,7 @@ function ReaderLink:onSwipe(arg, ges)
|
||||
-- Make that gesture don't do anything, and show a Notification
|
||||
-- so the user knows why
|
||||
UIManager:show(Notification:new{
|
||||
text = _("Location history is empty"),
|
||||
text = _("Location history is empty."),
|
||||
timeout = 2,
|
||||
})
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user