Merge pull request #1407 from chrox/fix_evernote_login

fix PocketBook screen configuration and Evernote login
This commit is contained in:
Qingping Hou
2015-02-01 01:18:07 -08:00
6 changed files with 30 additions and 15 deletions

2
base

Submodule base updated: ccf469ff25...1444062f3e

View File

@@ -70,6 +70,7 @@ function Device:getPowerDevice()
return self.powerd
end
-- ONLY used for Kindle devices
function Device:intoScreenSaver()
local UIManager = require("ui/uimanager")
if self.charging_mode == false and self.screen_saver_mode == false then
@@ -79,18 +80,19 @@ function Device:intoScreenSaver()
UIManager:sendEvent(Event:new("FlushSettings"))
end
-- ONLY used for Kindle devices
function Device:outofScreenSaver()
if self.screen_saver_mode == true and self.charging_mode == false then
-- wait for native system update screen before we recover saved
-- Blitbuffer.
util.usleep(1500000)
self.screen:restoreFromSavedBB()
self.screen:refreshFull()
self.survive_screen_saver = true
self:resume()
end
self.screen_saver_mode = false
end
-- ONLY used for Kobo and PocketBook devices
function Device:onPowerEvent(ev)
local Screensaver = require("ui/screensaver")
if (ev == "Power" or ev == "Suspend") and not self.screen_saver_mode then
@@ -102,12 +104,12 @@ function Device:onPowerEvent(ev)
Screensaver:show()
self:prepareSuspend()
UIManager:sendEvent(Event:new("FlushSettings"))
UIManager:scheduleIn(10, self.Suspend)
UIManager:scheduleIn(10, self.suspend)
elseif (ev == "Power" or ev == "Resume") and self.screen_saver_mode then
DEBUG("Resuming...")
-- restore to previous rotation mode
self.screen:setRotationMode(self.orig_rotation_mode)
self:Resume()
self:resume()
Screensaver:close()
end
end
@@ -121,14 +123,15 @@ function Device:prepareSuspend()
self.screen_saver_mode = true
end
function Device:Suspend()
function Device:suspend()
end
function Device:Resume()
function Device:resume()
local UIManager = require("ui/uimanager")
UIManager:unschedule(self.Suspend)
UIManager:unschedule(self.suspend)
self.screen:refreshFull()
self.screen_saver_mode = false
self.powerd:refreshCapacity()
end
function Device:usbPlugIn()

View File

@@ -73,6 +73,10 @@ function BasePowerD:getCapacity()
end
end
function BasePowerD:refreshCapacity()
self:getCapacityHW()
end
function BasePowerD:isCharging()
return self:isChargingHW()
end

View File

@@ -120,11 +120,11 @@ function Kobo:getFirmwareVersion()
version_file:close()
end
function Kobo:Suspend()
function Kobo:suspend()
os.execute("./suspend.sh")
end
function Kobo:Resume()
function Kobo:resume()
os.execute("echo 0 > /sys/power/state-extended")
if self.powerd then
if KOBO_LIGHT_ON_START and tonumber(KOBO_LIGHT_ON_START) > -1 then
@@ -134,7 +134,7 @@ function Kobo:Resume()
end
end
Generic.Resume(self)
Generic.resume(self)
end
-------------- device probe ------------

View File

@@ -38,11 +38,17 @@ local function koboEnableWifi(toggle)
end
end
local function pocketbookEnableWifi(toggle)
os.execute("/ebrmain/bin/netagent " .. (toggle == 1 and "connect" or "disconnect"))
end
function NetworkMgr:turnOnWifi()
if Device:isKindle() then
kindleEnableWifi(1)
elseif Device:isKobo() then
koboEnableWifi(1)
elseif Device:isPocketBook() then
pocketbookEnableWifi(1)
end
end
@@ -51,6 +57,8 @@ function NetworkMgr:turnOffWifi()
kindleEnableWifi(0)
elseif Device:isKobo() then
koboEnableWifi(0)
elseif Device:isPocketBook() then
pocketbookEnableWifi(0)
end
end

View File

@@ -126,6 +126,9 @@ function EvernoteExporter:addToMainMenu(tab_item_table)
end
function EvernoteExporter:login()
if NetworkMgr:getWifiStatus() == false then
NetworkMgr:promptWifiOn()
end
self.login_dialog = LoginDialog:new{
title = self.login_title,
username = self.evernote_username or "",
@@ -185,10 +188,7 @@ function EvernoteExporter:doLogin(username, password)
self.evernote_username = username
local ok, token = pcall(oauth.getToken, oauth)
-- prompt users to turn on Wifi if network is unreachable
if not ok and token and token:find("Network is unreachable") then
NetworkMgr:promptWifiOn()
return
elseif not ok and token then
if not ok and token then
UIManager:show(InfoMessage:new{
text = _("An error occurred while logging in:") .. "\n" .. token,
})