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/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" 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 diff --git a/koreader_kobo.sh b/koreader_kobo.sh index a6ce4f918..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 /mnt/onboard 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 000000000..1e6043247 Binary files /dev/null and b/resources/koreader.png differ