mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
UPDATE readerfrontlight.lua
Code is added to switch between Kobo Aura (Phoenix) and others. `ReaderFrontLight`, `self.ges_events` and the `function ReaderFrontLight:onAdjust` are now different for Kobo Aura. This enables me to do a two-fingered-pan over approx 1/4 Screenheight to change from full on to full off. The difference to the default implementation is that both the `rate` and the `msg` are omitted and the `steps` are different. FURTHER ROOM FOR IMPROVEMENT: It would be an improvement to get a final message after the two-fingered-pan is done stating the achieved setting. Signed-off-by: Markismus <zulde.zuldemans@gmail.com>
This commit is contained in:
@@ -7,31 +7,58 @@ local InputDialog = require("ui/widget/inputdialog")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Notification = require("ui/widget/notification")
|
||||
local _ = require("gettext")
|
||||
local DEBUG = require("dbg")
|
||||
|
||||
local ReaderFrontLight = InputContainer:new{
|
||||
steps = {0,1,2,3,4,5,6,7,8,9,10},
|
||||
}
|
||||
|
||||
function ReaderFrontLight:init()
|
||||
if Device:isTouchDevice() then
|
||||
self.ges_events = {
|
||||
Adjust = {
|
||||
GestureRange:new{
|
||||
ges = "two_finger_pan",
|
||||
range = Geom:new{
|
||||
x = 0, y = 0,
|
||||
w = Screen:getWidth(),
|
||||
h = Screen:getHeight(),
|
||||
},
|
||||
rate = 2.0,
|
||||
}
|
||||
},
|
||||
local ReaderFrontlight = {}
|
||||
if Device:getModel() ~= 'Kobo_phoenix' then
|
||||
ReaderFrontLight = InputContainer:new{
|
||||
steps = {0,1,2,3,4,5,6,7,8,9,10},
|
||||
}
|
||||
self.ui.menu:registerToMainMenu(self)
|
||||
function ReaderFrontLight:onAdjust(arg, ges)
|
||||
return ReaderFrontLight:onAdjustOther(arg, ges)
|
||||
end
|
||||
else ReaderFrontLight = InputContainer:new{
|
||||
steps = {1,1,1,1,1,2,2,2,3,3,4,5},
|
||||
}
|
||||
function ReaderFrontLight:onAdjust(arg, ges)
|
||||
return ReaderFrontLight:onAdjustPhoenix(arg, ges)
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderFrontLight:onAdjust(arg, ges)
|
||||
function ReaderFrontLight:init()
|
||||
if Device:isTouchDevice() then
|
||||
if Device:getModel() ~= 'Kobo_phoenix' then
|
||||
self.ges_events = {
|
||||
Adjust = {
|
||||
GestureRange:new{
|
||||
ges = "two_finger_pan",
|
||||
range = Geom:new{
|
||||
x = 0, y = 0,
|
||||
w = Screen:getWidth(),
|
||||
h = Screen:getHeight(),
|
||||
},
|
||||
rate = 2.0,
|
||||
}
|
||||
},
|
||||
}
|
||||
else self.ges_events = {
|
||||
Adjust = {
|
||||
GestureRange:new{
|
||||
ges = "two_finger_pan",
|
||||
range = Geom:new{
|
||||
x = 0, y = 0,
|
||||
w = Screen:getWidth(),
|
||||
h = Screen:getHeight(),
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
end
|
||||
self.ui.menu:registerToMainMenu(self)
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderFrontLight:onAdjustOther(arg, ges)
|
||||
local powerd = Device:getPowerDevice()
|
||||
if powerd.flIntensity ~= nil then
|
||||
local rel_proportion = ges.distance / Screen:getWidth()
|
||||
@@ -54,6 +81,24 @@ function ReaderFrontLight:onAdjust(arg, ges)
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderFrontLight:onAdjustPhoenix(arg, ges)
|
||||
local powerd = Device:getPowerDevice()
|
||||
if powerd.flIntensity ~= nil then
|
||||
local rel_proportion = ges.distance / Screen:getWidth()
|
||||
DEBUG("rel_proportion = ",rel_proportion)
|
||||
local delta_int = self.steps[math.ceil(#self.steps*rel_proportion)] or self.steps[#self.steps]
|
||||
DEBUG("math.ceil(#self.steps*rel_proportion) = ",math.ceil(#self.steps*rel_proportion))
|
||||
DEBUG("delta_int =", delta_int)
|
||||
if ges.direction == "north" then
|
||||
powerd:setIntensity(powerd.flIntensity + delta_int)
|
||||
elseif ges.direction == "south" then
|
||||
powerd:setIntensity(powerd.flIntensity - delta_int)
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
function ReaderFrontLight:addToMainMenu(tab_item_table)
|
||||
-- insert fldial command to main reader menu
|
||||
table.insert(tab_item_table.main, {
|
||||
|
||||
Reference in New Issue
Block a user