tweak timeouts, add haptic feedback support

Co-Authored-By: Frans de Jonge <fransdejonge@gmail.com>
This commit is contained in:
Martín Fernández
2019-10-08 18:15:43 +02:00
parent e131443834
commit b75fec4971
2 changed files with 75 additions and 39 deletions

View File

@@ -70,6 +70,7 @@ local Device = Generic:new{
canRestart = no,
firmware_rev = android.app.activity.sdkVersion,
display_dpi = android.lib.AConfiguration_getDensity(android.app.config),
isHapticFeedbackEnabled = yes,
hasClipboard = yes,
hasOTAUpdates = canUpdateApk,
canOpenLink = yes,
@@ -169,19 +170,17 @@ function Device:init()
self.isTouchDevice = yes
end
-- check if we enabled support for custom timeouts (including wakelocks)
-- check if we use custom timeouts
if android.needsWakelocks() then
android.setScreenOffTimeout(-1)
android.timeout.set(C.AKEEP_SCREEN_ON_ENABLED)
else
local timeout = G_reader_settings:readSetting("android_screen_timeout")
if timeout and timeout > 0 then
-- set a custom timeout if we already have write settings permission.
-- do not attempt to request permissions here.
if android.canWriteSettings() then
android.setScreenOffTimeout(timeout)
if timeout then
if timeout == C.AKEEP_SCREEN_ON_ENABLED
or (timeout > C.AKEEP_SCREEN_ON_DISABLED
and android.settings.canWrite()) then
android.timeout.set(timeout)
end
elseif timeout and timeout == -1 then
android.setScreenOffTimeout(timeout)
end
end
@@ -225,6 +224,10 @@ function Device:initNetworkManager(NetworkMgr)
end
end
function Device:performHapticFeedback(type)
android.hapticFeedback(C["AHAPTIC_"..type])
end
function Device:retrieveNetworkInfo()
local ssid, ip, gw = android.getNetworkInfo()
if ip == "0" or gw == "0" then