From b4462da1b6065e091e53139d4a3c143acd82c4a2 Mon Sep 17 00:00:00 2001 From: Robert Date: Sun, 5 Mar 2017 03:54:23 +0100 Subject: [PATCH] Dialog when reopening book at start (#2259) (#2603) --- reader.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/reader.lua b/reader.lua index 18fb8bf26..8a68e2322 100755 --- a/reader.lua +++ b/reader.lua @@ -93,6 +93,24 @@ local lfs = require("libs/libkoreader-lfs") local UIManager = require("ui/uimanager") local Device = require("device") local Font = require("ui/font") +local ConfirmBox = require("ui/widget/confirmbox") + +local function retryLastFile() + return ConfirmBox:new{ + text = _("Cannot open last file.\nThis could be because it was deleted or because external storage is still being mounted.\nDo you want to retry?"), + ok_callback = function() + local last_file = G_reader_settings:readSetting("lastfile") + if lfs.attributes(last_file, "mode") == "file" then + local ReaderUI = require("apps/reader/readerui") + UIManager:nextTick(function() + ReaderUI:showReader(last_file) + end) + else + UIManager:show(retryLastFile()) + end + end, + } +end -- read some global reader setting here: -- font @@ -105,6 +123,7 @@ end -- last file local last_file = G_reader_settings:readSetting("lastfile") if last_file and lfs.attributes(last_file, "mode") ~= "file" then + UIManager:show(retryLastFile()) last_file = nil end -- load last opened file