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 = "История вызовов" -- name = "История вызовов"
-- type = "widget" -- type = "widget"
-- root = "yes"
-- author = "Andrey Gavrilov" -- author = "Andrey Gavrilov"
-- version = "1.0" -- version = "1.0"
-- root = "yes"
local types = {"Входящие","Исходящие","Пропущенные","Отменённые","Отклонённые","Заблокированные","Все"} local types = {"Входящие","Исходящие","Пропущенные","Отменённые","Отклонённые","Заблокированные","Все"}
@@ -15,7 +15,7 @@ function on_resume()
end end
function redraw() 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 if typ == 4 then
cmd = cmd.." --where \"type=2 and duration=0\"" cmd = cmd.." --where \"type=2 and duration=0\""
elseif typ ~= 7 then elseif typ ~= 7 then
@@ -35,35 +35,58 @@ function on_shell_result(res)
text = text:gsub(",%s","\",") text = text:gsub(",%s","\",")
text = text.."\"}}" text = text.."\"}}"
tab = load("return "..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 for i,v in ipairs(tab) do
if v.name == "NULL" then local dir = " "
table.insert(tab1,v.number) 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 else
table.insert(tab1,v.name.." ["..v.number.."]") dir = "<b><font color=\""..colors.progress_good.."\">⬀</font></b>"
end end
table.insert(tab2,os.date("%d.%m.%Y %H:%M",math.floor(v.date/1000))) 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 end
table.insert(tab1,types[typ]) table.insert(row,dir)
table.insert(tab2,"Выберите тип") 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(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:set_title(ui:get_default_title().." ("..types[typ]..")")
ui:show_lines(tab1,tab2) ui:show_table(rows,2)
end end
function on_click(idx) function on_click(idx)
if idx > #tab then if math.ceil(idx/3) > #tab then
ui:show_radio_dialog("Выберите тип вызовов",types,typ) ui:show_radio_dialog("Выберите тип вызовов",types,typ)
else 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) system:exec(cmd)
end end
end end
function on_long_click(idx) function on_long_click(idx)
if idx > #tab then if math.ceil(idx/3) > #tab then
return return
end end
phone:make_call(tab[idx].number) phone:make_call(tab[math.ceil(idx/3)].number)
end end
function on_dialog_action(idx) function on_dialog_action(idx)

View File

@@ -1,5 +1,4 @@
-- name = "ТВ-Программа" -- name = "ТВ-Программа"
-- description = "Программа телепередач российского телевидения"
-- type = "widget" -- type = "widget"
-- version = "1.0" -- version = "1.0"
-- author = "Andrey Gavrilov" -- author = "Andrey Gavrilov"
@@ -7,31 +6,25 @@
local url = "https://api.peers.tv/tvguide/2/" local url = "https://api.peers.tv/tvguide/2/"
local channel_id = "10338240" local channel_id = "10338240"
local title = "Матч ТВ" local title = "Матч ТВ"
local tab_name = {} local tab_name,tab_time,tab_desc,tab_link,tab = {},{},{},{},{}
local tab_time = {}
local tab_desc = {}
local tab_link = {}
local link = "" local link = ""
function on_resume() function on_resume()
ui:set_folding_flag(true) ui:set_folding_flag(true)
ui:show_lines(tab_name,tab_time) ui:show_table(tab,2)
end end
function on_alarm() function on_alarm()
tab_name = {} tab_name,tab_time,tab_desc,tab_link = {},{},{},{}
tab_time = {}
tab_desc = {}
tab_link = {}
http:get(url.."schedule.json?channel="..channel_id,"schedule") http:get(url.."schedule.json?channel="..channel_id,"schedule")
end end
function on_click(idx) function on_click(idx)
if idx > #tab_desc then if math.ceil(idx/2) > #tab_desc then
ui:show_edit_dialog("Введите название канала") ui:show_edit_dialog("Введите название канала","",title)
else else
ui:show_dialog("Описание",tab_desc[idx],"Перейти к каналу") ui:show_dialog(tab_name[math.ceil(idx/2)].."\n"..tab_time[math.ceil(idx/2)],tab_desc[math.ceil(idx/2)],"Перейти к каналу")
link = tab_link[idx] link = tab_link[math.ceil(idx/2)]
end end
end end
@@ -43,16 +36,12 @@ function on_network_result_channel(res)
end end
channel_id = tostring(t.channels[1].channelId) channel_id = tostring(t.channels[1].channelId)
title = t.channels[1].title title = t.channels[1].title
tab_name = {} tab_name,tab_time,tab_desc,tab_link = {},{},{},{}
tab_time = {}
tab_desc = {}
tab_link = {}
http:get(url.."schedule.json?channel="..channel_id,"schedule") http:get(url.."schedule.json?channel="..channel_id,"schedule")
end end
function on_dialog_action(data) function on_dialog_action(data)
if type(data) == "string" then if type(data) == "string" then
data = data:gsub(" ","+")
http:get(url.."idbytitle.json?titles="..data,"channel") http:get(url.."idbytitle.json?titles="..data,"channel")
elseif data ~= -1 then elseif data ~= -1 then
system:open_browser(link) system:open_browser(link)
@@ -77,10 +66,21 @@ function on_network_result_schedule(res)
http:get(url.."schedule.json?channel="..channel_id.."&dates="..os.date("%Y-%m-%d",os.time()+24*60*60),"schedule") http:get(url.."schedule.json?channel="..channel_id.."&dates="..os.date("%Y-%m-%d",os.time()+24*60*60),"schedule")
return return
end end
table.insert(tab_name,"Выберите канал") tab = {}
table.insert(tab_time,"") local colors = ui:get_colors()
local row = {}
for i,v in ipairs(tab_name) do
local row = {}
table.insert(row,"<font color=\""..colors.secondary_text.."\">"..tab_time[i].."</font>")
table.insert(row,v)
table.insert(tab,row)
row = {}
end
table.insert(row," ")
table.insert(row,"<font color=\""..colors.secondary_text.."\">Выберите канал</font>")
table.insert(tab,row)
ui:set_title(ui:get_default_title().." ("..title..")") ui:set_title(ui:get_default_title().." ("..title..")")
ui:show_lines(tab_name,tab_time) ui:show_table(tab,2)
end end
function on_settings() function on_settings()