mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[RTL UI] update widgets and apps for UI mirroring
Small tweaks all around to handle UI mirroring: - swap existing symbols like arrows, or use alternative ones - rotate some images, like chevrons and dogear icons - flip some left and right swipe handling - flip some geometry arithmetic like tap on left or right side of page or dict window - use new ProgressWidget:getPercentageFromPosition() instead of geometry arithmetic - BD.wrap() some concatenated string bits, like in reader and menu footers - flip inverse_reading_order when UI is mirrored More specific tweaks: - ReaderGesture: reset some specific gestures when UI direction has changed (tap on top/bottom left/right corners, for bookmarks and FileManager "Plus menu"). - ReaderRolling: show markers on the correct side of page, in single or dual page mode. - KoptOptions: swap left and right icons in Alignment toggle - CheckMark: proper rendering in all 4 mirroring/rtl combinations. - VirtualKeyboard: forbid any mirroring - Move util.getMenuText into Menu.lua
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
local BD = require("ui/bidi")
|
||||
local ConfirmBox = require("ui/widget/confirmbox")
|
||||
local DataStorage = require("datastorage")
|
||||
local Device = require("device")
|
||||
@@ -225,6 +226,44 @@ function ReaderGesture:init()
|
||||
}
|
||||
local gm = G_reader_settings:readSetting(self.ges_mode)
|
||||
if gm == nil then G_reader_settings:saveSetting(self.ges_mode, {}) end
|
||||
|
||||
-- Some of these defaults need to be reversed in RTL mirrored UI,
|
||||
-- and as we set them in the saved gestures, we need to reset them
|
||||
-- to the defaults in case of UI language's direction change.
|
||||
local mirrored_if_rtl = {
|
||||
tap_top_left_corner = "tap_top_right_corner",
|
||||
tap_right_bottom_corner = "tap_left_bottom_corner",
|
||||
}
|
||||
local is_rtl = BD.mirroredUILayout()
|
||||
if is_rtl then
|
||||
for k, v in pairs(mirrored_if_rtl) do
|
||||
self.default_gesture[k], self.default_gesture[v] = self.default_gesture[v], self.default_gesture[k]
|
||||
end
|
||||
end
|
||||
-- We remember the last UI direction gestures were made on. If it changes,
|
||||
-- reset the mirrored_if_rtl ones to the default for the new direction.
|
||||
local ges_dir_setting = self.ges_mode.."ui_lang_direction_rtl"
|
||||
local prev_lang_dir_rtl = G_reader_settings:isTrue(ges_dir_setting)
|
||||
if (is_rtl and not prev_lang_dir_rtl) or (not is_rtl and prev_lang_dir_rtl) then
|
||||
local reset = false
|
||||
for k, v in pairs(mirrored_if_rtl) do
|
||||
-- We only replace them if they are still the other direction's default.
|
||||
-- If not, the user has changed them: let him deal with setting new ones if needed.
|
||||
if gm[k] == self.default_gesture[v] then
|
||||
gm[k] = self.default_gesture[k]
|
||||
reset = true
|
||||
end
|
||||
if gm[v] == self.default_gesture[k] then
|
||||
gm[v] = self.default_gesture[v]
|
||||
reset = true
|
||||
end
|
||||
end
|
||||
if reset then
|
||||
logger.info("UI language direction changed: resetting some gestures to direction default")
|
||||
end
|
||||
G_reader_settings:flipNilOrFalse(ges_dir_setting)
|
||||
end
|
||||
|
||||
self.ui.menu:registerToMainMenu(self)
|
||||
self:initGesture()
|
||||
end
|
||||
@@ -1577,8 +1616,12 @@ function ReaderGesture:onToggleReadingOrder()
|
||||
local document_module = self.ui.document.info.has_pages and self.ui.paging or self.ui.rolling
|
||||
document_module.inverse_reading_order = not document_module.inverse_reading_order
|
||||
document_module:setupTouchZones()
|
||||
local is_rtl = BD.mirroredUILayout()
|
||||
if document_module.inverse_reading_order then
|
||||
is_rtl = not is_rtl
|
||||
end
|
||||
UIManager:show(Notification:new{
|
||||
text = document_module.inverse_reading_order and _("RTL page turning.") or _("LTR page turning."),
|
||||
text = is_rtl and _("RTL page turning.") or _("LTR page turning."),
|
||||
timeout = 2.5,
|
||||
})
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user