update widgets

This commit is contained in:
Evgeny
2021-09-21 13:13:14 +03:00
parent 3371c438cd
commit 78e5abffe5
2 changed files with 60 additions and 37 deletions

View File

@@ -1,8 +1,8 @@
-- name = "История вызовов"
-- type = "widget"
-- root = "yes"
-- author = "Andrey Gavrilov"
-- version = "1.0"
-- root = "yes"
local types = {"Входящие","Исходящие","Пропущенные","Отменённые","Отклонённые","Заблокированные","Все"}
@@ -15,7 +15,7 @@ function on_resume()
end
function redraw()
local cmd = "content query --uri content://call_log/calls --projection date:number:name --sort \"date desc limit 10\""
local cmd = "content query --uri content://call_log/calls --projection date:number:name:type:duration --sort \"date desc limit 10\""
if typ == 4 then
cmd = cmd.." --where \"type=2 and duration=0\""
elseif typ ~= 7 then
@@ -35,35 +35,58 @@ function on_shell_result(res)
text = text:gsub(",%s","\",")
text = text.."\"}}"
tab = load("return "..text)()
local tab1,tab2 = {},{}
local tab1,tab2,row,rows = {},{},{},{}
local colors = ui:get_colors()
local md_colors = require "md_colors"
for i,v in ipairs(tab) do
if v.name == "NULL" then
table.insert(tab1,v.number)
else
table.insert(tab1,v.name.." ["..v.number.."]")
local dir = " "
if v.type == "1" then
dir = "<b><font color=\""..colors.progress.."\">⬃</font></b>"
elseif v.type == "2" then
if v.duration == "0" then
dir = "<b><font color=\""..md_colors.orange_600.."\">⬀</font></b>"
else
dir = "<b><font color=\""..colors.progress_good.."\">⬀</font></b>"
end
elseif v.type == "3" then
dir = "<b><font color=\""..colors.progress_bad.."\">⬃</font></b>"
elseif v.type == "5" then
dir = "<b><font color=\""..md_colors.orange_600.."\">⬃</font></b>"
elseif v.type == "6" then
dir = "<b><font color=\""..colors.secondary_text.."\">⬃</font></b>"
end
table.insert(tab2,os.date("%d.%m.%Y %H:%M",math.floor(v.date/1000)))
table.insert(row,dir)
if v.name == "NULL" then
table.insert(row,v.number)
else
table.insert(row,v.name)
end
table.insert(row,"<font color=\""..colors.secondary_text.."\">"..os.date("%H:%M - %d.%m",math.floor(v.date/1000)).."</font>")
table.insert(rows,row)
row = {}
end
table.insert(tab1,types[typ])
table.insert(tab2,"Выберите тип")
table.insert(row," ")
table.insert(row,"<font color=\""..colors.secondary_text.."\">Выберите тип</<font>")
table.insert(row," ")
table.insert(rows,row)
ui:set_title(ui:get_default_title().." ("..types[typ]..")")
ui:show_lines(tab1,tab2)
ui:show_table(rows,2)
end
function on_click(idx)
if idx > #tab then
if math.ceil(idx/3) > #tab then
ui:show_radio_dialog("Выберите тип вызовов",types,typ)
else
local cmd = "am start -a android.intent.action.DIAL -d tel:"..tab[idx].number
local cmd = "am start -a android.intent.action.DIAL -d tel:"..tab[math.ceil(idx/3)].number
system:exec(cmd)
end
end
function on_long_click(idx)
if idx > #tab then
if math.ceil(idx/3) > #tab then
return
end
phone:make_call(tab[idx].number)
phone:make_call(tab[math.ceil(idx/3)].number)
end
function on_dialog_action(idx)