Merge pull request #381 from chrox/master

sort history file with modification time
This commit is contained in:
Qingping Hou
2013-12-01 07:22:12 -08:00
3 changed files with 20 additions and 14 deletions

View File

@@ -4,6 +4,7 @@ local Menu = require("ui/widget/menu")
local Screen = require("ui/screen")
local UIManager = require("ui/uimanager")
local DocSettings = require("docsettings")
local DEBUG = require("dbg")
local _ = require("gettext")
local FileManagerHistory = InputContainer:extend{
@@ -55,22 +56,27 @@ function FileManagerHistory:addToMainMenu(tab_item_table)
end
function FileManagerHistory:updateItemTable()
function readHistDir(order_arg, re)
for f in lfs.dir("./history") do
local filemode = lfs.attributes(f, "mode")
if filemode ~= "directory" then -- we can't use filemode == "file" here, when it should be "file" it is actually nil, weird
table.insert(re, {
dir = DocSettings:getPathFromHistory(f),
name = DocSettings:getNameFromHistory(f),
})
end
function readHistDir(re)
local sorted_files = {}
local history_dir = "./history/"
for f in lfs.dir(history_dir) do
local path = history_dir..f
if lfs.attributes(path, "mode") == "file" then
table.insert(sorted_files, {file = f, date = lfs.attributes(path, "modification")})
end
end
table.sort(sorted_files, function(v1,v2) return v1.date > v2.date end)
for _, v in pairs(sorted_files) do
table.insert(re, {
dir = DocSettings:getPathFromHistory(v.file),
name = DocSettings:getNameFromHistory(v.file),
})
end
end
self.hist = {}
local last_files = {}
readHistDir("-c", last_files)
readHistDir(last_files)
for _,v in pairs(last_files) do
table.insert(self.hist, {
text = v.name,
@@ -81,4 +87,4 @@ function FileManagerHistory:updateItemTable()
end
end
return FileManagerHistory
return FileManagerHistory

View File

@@ -46,7 +46,7 @@ function Device:getModel()
local k4_set = Set { "0E", "23" }
local touch_set = Set { "0F", "11", "10", "12" }
local pw_set = Set { "24", "1B", "1D", "1F", "1C", "20" }
local pw2_set = Set { "D4", "5A", "D5" }
local pw2_set = Set { "D4", "5A", "D5", "D7", "D8", "F2" }
if k2_set[kindle_devcode] then
self.model = "Kindle2"