fix ANRs in Kosync plugin login/register

reviewable/pr6302/r1
Martín Fdez 4 years ago committed by Martín Fernández
parent 1f994f8ede
commit 835f9f62c6

@ -257,6 +257,10 @@ function Device:performHapticFeedback(type)
android.hapticFeedback(C["AHAPTIC_"..type])
end
function Device:setIgnoreInput(enable)
android.setIgnoreInput(enable)
end
function Device:retrieveNetworkInfo()
local ok, type = android.getNetworkInfo()
ok, type = tonumber(ok), tonumber(type)

@ -315,6 +315,9 @@ Device specific method for performing haptic feedback.
--]]
function Device:performHapticFeedback(type) end
-- Device specific method for toggling input events
function Device:setIgnoreInput(enable) return true end
-- Device specific method for toggling the GSensor
function Device:toggleGSensor(toggle) end

@ -1 +1 @@
Subproject commit 8cb68727e2b723759c468f25472191e3415676ec
Subproject commit fc4982b4afd50d2b86ae56e97b3bf09d191c81bb

@ -384,6 +384,7 @@ function KOSync:doRegister(username, password)
custom_url = self.kosync_custom_server,
service_spec = self.path .. "/api.json"
}
Device:setIgnoreInput(true)
local userkey = md5.sum(password)
local ok, status, body = pcall(client.register, client, username, userkey)
if not ok then
@ -409,7 +410,7 @@ function KOSync:doRegister(username, password)
text = body and body.message or _("Unknown server error"),
})
end
Device:setIgnoreInput(false)
self:saveSettings()
end
@ -419,6 +420,7 @@ function KOSync:doLogin(username, password)
custom_url = self.kosync_custom_server,
service_spec = self.path .. "/api.json"
}
Device:setIgnoreInput(true)
local userkey = md5.sum(password)
local ok, status, body = pcall(client.authorize, client, username, userkey)
if not ok then
@ -432,6 +434,7 @@ function KOSync:doLogin(username, password)
text = _("An unknown error occurred while logging in."),
})
end
Device:setIgnoreInput(false)
return
elseif status then
self.kosync_username = username
@ -445,7 +448,7 @@ function KOSync:doLogin(username, password)
text = body and body.message or _("Unknown server error"),
})
end
Device:setIgnoreInput(false)
self:saveSettings()
end

Loading…
Cancel
Save