From cea353323eae7f3fd04f9eef8844203fc3670f37 Mon Sep 17 00:00:00 2001 From: Giorgio Micotti Date: Mon, 5 Aug 2013 23:06:26 +0200 Subject: [PATCH 1/3] Initial light control widget; final fixes for kobo light --- frontend/ui/device.lua | 7 +++ frontend/ui/reader/readerfrontlight.lua | 70 ++++++++++++++++++++++++- frontend/ui/reader/readermenu.lua | 9 +++- frontend/ui/readerui.lua | 4 +- frontend/ui/widget/menu.lua | 1 + 5 files changed, 86 insertions(+), 5 deletions(-) diff --git a/frontend/ui/device.lua b/frontend/ui/device.lua index 34d859365..997954401 100644 --- a/frontend/ui/device.lua +++ b/frontend/ui/device.lua @@ -105,6 +105,13 @@ function Device:isTouchDevice() return (self.model == "KindlePaperWhite") or (self.model == "KindleTouch") or self:isKobo() or util.isEmulated() end +function Device:hasFrontlight() + if not self.model then + self.model = self:getModel() + end + return (self.model == "KindlePaperWhite") or (self.model == "Kobo_dragon") or (self.model == "Kobo_kraken") or (self.model == "Kobo_phoenix") or util.isEmulated() +end + function Device:setTouchInputDev(dev) self.touch_dev = dev end diff --git a/frontend/ui/reader/readerfrontlight.lua b/frontend/ui/reader/readerfrontlight.lua index 93f1f75b5..3ab2d2555 100644 --- a/frontend/ui/reader/readerfrontlight.lua +++ b/frontend/ui/reader/readerfrontlight.lua @@ -1,7 +1,10 @@ require "ui/widget/container" +require "ui/widget/inputdialog" require "ui/device" ReaderFrontLight = InputContainer:new{ + fldial_menu_title = ("Frontlight Settings"), + fl_dialog_title = ("Frontlight Level"), steps = {0,1,2,3,4,5,6,7,8,9,10}, intensity = nil, fl = nil, @@ -31,7 +34,11 @@ function ReaderFrontLight:init() end if Device:isKobo() then self.fl = kobolight.open() - self.intensity = 20 + self.intensity = G_reader_settings:readSetting("frontlight_intensity") + if not self.intensity then + self.intensity = 20 + end + self:setIntensity(self.intensity, "Set intensity") end end @@ -54,7 +61,7 @@ function ReaderFrontLight:onAdjust(arg, ges) end function ReaderFrontLight:setIntensity(intensity, msg) - if self.lipc_handle then + if self.lipc_handle then intensity = intensity < 0 and 0 or intensity intensity = intensity > 24 and 24 or intensity self.intensity = intensity @@ -65,6 +72,8 @@ function ReaderFrontLight:setIntensity(intensity, msg) }) end if Device:isKobo() then + intensity = intensity < 1 and 1 or intensity + intensity = intensity > 100 and 100 or intensity if self.fl == nil then ReaderFrontLight:init() end @@ -87,3 +96,60 @@ function ReaderFrontLight:toggle() end return true end + +function ReaderFrontLight:addToMainMenu(tab_item_table) + -- insert fldial command to main reader menu + table.insert(tab_item_table.main, { + text = self.fldial_menu_title, + callback = function() + self:onShowFlDialog() + end, + }) +end + +function ReaderFrontLight:onShowFlDialog() + DEBUG("show fldial dialog") + self.fl_dialog = InputDialog:new{ + title = self.fl_dialog_title, + input_hint = "(1 - 100)", + buttons = { + { + { + text = _("Apply"), + enabled = true, + callback = function() + self:fldialIntensity() + end, + }, + { + text = _("OK"), + enabled = true, + callback = function() + self:fldialIntensity() + self:close() + end, + }, + + }, + }, + input_type = "number", + width = Screen:getWidth() * 0.8, + height = Screen:getHeight() * 0.2, + } + self.fl_dialog:onShowKeyboard() + UIManager:show(self.fl_dialog) +end + +function ReaderFrontLight:close() + self.fl_dialog:onClose() + G_reader_settings:saveSetting("frontlight_intensity", self.intensity) + UIManager:close(self.fl_dialog) +end + +function ReaderFrontLight:fldialIntensity() + local number = tonumber(self.fl_dialog:getInputText()) + if number then + self:setIntensity(number, "Set intensity") + end + return true +end diff --git a/frontend/ui/reader/readermenu.lua b/frontend/ui/reader/readermenu.lua index e0d297a56..35055b663 100644 --- a/frontend/ui/reader/readermenu.lua +++ b/frontend/ui/reader/readermenu.lua @@ -56,7 +56,14 @@ function ReaderMenu:setUpdateItemTable() for _, widget in pairs(self.registered_widgets) do widget:addToMainMenu(self.tab_item_table) end - + if Device:hasFrontlight() then + table.insert(self.tab_item_table.main, { + text = _("Frontlight settings"), + callback = function() + ReaderFrontLight:onShowFlDialog() + end + }) + end table.insert(self.tab_item_table.main, { text = _("Help"), callback = function() diff --git a/frontend/ui/readerui.lua b/frontend/ui/readerui.lua index 96b8fd079..877ccb200 100644 --- a/frontend/ui/readerui.lua +++ b/frontend/ui/readerui.lua @@ -129,14 +129,14 @@ function ReaderUI:init() view = self[1], ui = self } + table.insert(self.active_widgets, reader_ss) -- frontlight controller local reader_fl = ReaderFrontLight:new{ dialog = self.dialog, view = self[1], ui = self } - table.insert(self.active_widgets, reader_ss) - table.insert(self.active_widgets, reader_fl) + table.insert(self, reader_fl) if self.document.info.has_pages then -- for page specific controller diff --git a/frontend/ui/widget/menu.lua b/frontend/ui/widget/menu.lua index fc157a2df..4b3cbdd86 100644 --- a/frontend/ui/widget/menu.lua +++ b/frontend/ui/widget/menu.lua @@ -1,6 +1,7 @@ require "ui/widget/container" require "ui/widget/focusmanager" require "ui/widget/infomessage" +require "ui/widget/frontlight" require "ui/widget/button" require "ui/widget/text" require "ui/widget/group" From 1be83abede5f12834015bca641bb7272412f92c9 Mon Sep 17 00:00:00 2001 From: Giorgio Micotti Date: Tue, 6 Aug 2013 09:01:44 +0200 Subject: [PATCH 2/3] update koreader-base. --- koreader-base | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koreader-base b/koreader-base index 698fb1764..b5625d48e 160000 --- a/koreader-base +++ b/koreader-base @@ -1 +1 @@ -Subproject commit 698fb1764ffc0eafbd5cdb2dcc6d8165cca8d8f0 +Subproject commit b5625d48e91016b9ac33bf15c9d662d7bcb17bcd From 1201b64d180bd2eeb2d824982bea8613e960bc7b Mon Sep 17 00:00:00 2001 From: Giorgio Micotti Date: Tue, 6 Aug 2013 12:03:10 +0200 Subject: [PATCH 3/3] Add an option "make koboupdate" --- Makefile | 35 +++++++++++++++++++++++++++++++++++ fmon/koreader.sh | 1 + koreader_kobo.sh | 2 +- resources/koreader.png | Bin 0 -> 2250 bytes 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 fmon/koreader.sh create mode 100644 resources/koreader.png diff --git a/Makefile b/Makefile index 845b40bb5..5728bf89c 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ VERSION=$(shell git describe HEAD) # subdirectory we use to build the installation bundle INSTALL_DIR=koreader +INSTALL_DIR_KOBO=mnt/onboard/.kobo/koreader # subdirectory we use to setup emulation environment EMU_DIR=emu @@ -90,6 +91,40 @@ customupdate: all rm -rf $(INSTALL_DIR) # @TODO write an installation script for KUAL (houqp) +koboupdate: all + # ensure that the binaries were built for ARM + file $(KOR_BASE)/koreader-base | grep ARM || exit 1 + file $(KOR_BASE)/extr | grep ARM || exit 1 + # remove old package and dir if any + rm -f koreader-kobo-$(VERSION).zip + rm -rf $(INSTALL_DIR_KOBO) + # create new dir for package + mkdir -p $(INSTALL_DIR_KOBO)/{history,screenshots,clipboard,libs} + cp -p README.md COPYING $(KOR_BASE)/{koreader-base,extr,sdcv} koreader.sh koreader_kobo.sh $(LUA_FILES) $(INSTALL_DIR_KOBO) + $(STRIP) --strip-unneeded $(INSTALL_DIR_KOBO)/koreader-base $(INSTALL_DIR_KOBO)/extr $(INSTALL_DIR_KOBO)/sdcv + mkdir $(INSTALL_DIR_KOBO)/data $(INSTALL_DIR_KOBO)/data/dict $(INSTALL_DIR_KOBO)/data/tessdata + cp -L koreader-base/$(DJVULIB) $(KOR_BASE)/$(CRELIB) \ + $(KOR_BASE)/$(LUALIB) $(KOR_BASE)/$(K2PDFOPTLIB) \ + $(KOR_BASE)/$(LEPTONICALIB) $(KOR_BASE)/$(TESSERACTLIB) \ + $(INSTALL_DIR_KOBO)/libs + $(STRIP) --strip-unneeded $(INSTALL_DIR_KOBO)/libs/* + cp -rpL $(KOR_BASE)/data/*.css $(INSTALL_DIR_KOBO)/data + cp -rpL $(KOR_BASE)/data/hyph $(INSTALL_DIR_KOBO)/data/hyph + cp -rpL $(KOR_BASE)/fonts $(INSTALL_DIR_KOBO) + cp -rp $(MO_DIR) $(INSTALL_DIR_KOBO) + rm $(INSTALL_DIR_KOBO)/fonts/droid/DroidSansFallbackFull.ttf + echo $(VERSION) > git-rev + cp -r git-rev resources $(INSTALL_DIR_KOBO) + rm -r $(INSTALL_DIR_KOBO)/resources/fonts + cp -rpL frontend $(INSTALL_DIR_KOBO) + cp defaults.lua $(INSTALL_DIR_KOBO) + mkdir $(INSTALL_DIR_KOBO)/fonts/host + cp -rpL fmon $(INSTALL_DIR_KOBO)/.. + cp -p resources/koreader.png $(INSTALL_DIR_KOBO)/../.. + tar -zcvf KoboRoot.tgz mnt/ + zip -9 -r koreader-kobo-$(VERSION).zip KoboRoot.tgz + rm KoboRoot.tgz + rm -rf mnt/ pot: $(XGETTEXT_BIN) reader.lua `find frontend -iname "*.lua"` \ diff --git a/fmon/koreader.sh b/fmon/koreader.sh new file mode 100644 index 000000000..03ba8f433 --- /dev/null +++ b/fmon/koreader.sh @@ -0,0 +1 @@ +$root/.kobo/fmon/fmon $root/koreader.png $root/.kobo/koreader/koreader_kobo.sh & diff --git a/koreader_kobo.sh b/koreader_kobo.sh index 16e7b1dfb..2cd418578 100644 --- a/koreader_kobo.sh +++ b/koreader_kobo.sh @@ -14,7 +14,7 @@ export STARDICT_DATA_DIR="data/dict" killall nickel # finally call reader -./reader.lua "$1" 2> crash.log +./reader.lua /mnt/onboard 2> crash.log # continue with nickel diff --git a/resources/koreader.png b/resources/koreader.png new file mode 100644 index 0000000000000000000000000000000000000000..1e60432478065bb5c5cb4d2300d89dbf7c324a40 GIT binary patch literal 2250 zcmV;*2sQVKP)Px#22e~?MgRZ*00010!qa{L000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2i*t; z2r3JK#r0GG000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}000OjNklk58&0HuB*wh!VExEPQ9rn>&IEZv8Yf_`Vw=5#crx6LnVP=#acR=QuPeL ztP4!joN8wN6Z&E)15J+AegJ$7eJy>pIL02Pp_M*1&%c>owqil^{9(Fm#VU4=u-S~4 z%|Zb3t+YYIXveE&A*BqK9_{>9BS9&HsEq7)N9s6VQw0Hu$8E9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