Toggling Kosync auto sync from gestures#14037
Conversation
|
Resolves #14026 (if deemed useful) |
|
Do you think other actions from this chunk are not needed? koreader/plugins/kosync.koplugin/main.lua Lines 223 to 246 in 6a56740 |
|
Maybe we need both actions: toggle and enable/disable? koreader/plugins/statistics.koplugin/main.lua Line 1061 in 6a56740 |
Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
Yeah that seems useful and consistent, thanks for the reference. (Sorry cant seem to get the hang on embedding the PR code somehow) |
Agreed, this would be inconsistent. koreader/plugins/kosync.koplugin/main.lua Lines 240 to 244 in 6a56740 As this would just try and get a network connection again. I get why the menu tries to push one last time when turning the sync off but I don't think I would expect a quick setting to do that. |
|
To avoid code duplication call the method in the menu callback. function KOSync:onToggleAutoSync(toggle, from_menu)
if toggle == self.settings.auto_sync then return true end
-- Actively recommend switching the before wifi action to "turn_on" instead of prompt,
-- as prompt will just not be practical (or even plain usable) here.
if not self.settings.auto_sync
and Device:hasSeamlessWifiToggle()
and G_reader_settings:readSetting("wifi_enable_action") ~= "turn_on" then
UIManager:show(InfoMessage:new{ text = _("You will have to switch the 'Action when Wi-Fi is off' Network setting to 'turn on' to be able to enable this feature!") })
return true
end
self.settings.auto_sync = not self.settings.auto_sync
self:registerEvents()
if self.settings.auto_sync then
-- Since we will update the progress when closing the document,
-- pull the current progress now so as not to silently overwrite it.
self:getProgress(true, true)
elseif from_menu then
-- Since we won't update the progress when closing the document,
-- push the current progress now so as not to lose it.
self:updateProgress(true, true)
end
if not from_menu then
Notification:notify(self.settings.auto_sync and _("Auto progress sync: on") or _("Auto progress sync: off"))
end
return true
endEDIT: |
| if not from_menu then | ||
| Notification:notify(self.settings.auto_sync and _("Auto progress sync: on") or _("Auto progress sync: off")) | ||
| end | ||
| end |
There was a problem hiding this comment.
One more return true at the end.
Adds an action for toggling auto sync to the gesture menu.
This change is