update widgets
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
-- name = "ТВ-Программа"
|
||||
-- description = "Программа телепередач российского телевидения"
|
||||
-- type = "widget"
|
||||
-- version = "1.0"
|
||||
-- author = "Andrey Gavrilov"
|
||||
@@ -7,31 +6,25 @@
|
||||
local url = "https://api.peers.tv/tvguide/2/"
|
||||
local channel_id = "10338240"
|
||||
local title = "Матч ТВ"
|
||||
local tab_name = {}
|
||||
local tab_time = {}
|
||||
local tab_desc = {}
|
||||
local tab_link = {}
|
||||
local tab_name,tab_time,tab_desc,tab_link,tab = {},{},{},{},{}
|
||||
local link = ""
|
||||
|
||||
function on_resume()
|
||||
ui:set_folding_flag(true)
|
||||
ui:show_lines(tab_name,tab_time)
|
||||
ui:show_table(tab,2)
|
||||
end
|
||||
|
||||
function on_alarm()
|
||||
tab_name = {}
|
||||
tab_time = {}
|
||||
tab_desc = {}
|
||||
tab_link = {}
|
||||
tab_name,tab_time,tab_desc,tab_link = {},{},{},{}
|
||||
http:get(url.."schedule.json?channel="..channel_id,"schedule")
|
||||
end
|
||||
|
||||
function on_click(idx)
|
||||
if idx > #tab_desc then
|
||||
ui:show_edit_dialog("Введите название канала")
|
||||
if math.ceil(idx/2) > #tab_desc then
|
||||
ui:show_edit_dialog("Введите название канала","",title)
|
||||
else
|
||||
ui:show_dialog("Описание",tab_desc[idx],"Перейти к каналу")
|
||||
link = tab_link[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[math.ceil(idx/2)]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -43,16 +36,12 @@ function on_network_result_channel(res)
|
||||
end
|
||||
channel_id = tostring(t.channels[1].channelId)
|
||||
title = t.channels[1].title
|
||||
tab_name = {}
|
||||
tab_time = {}
|
||||
tab_desc = {}
|
||||
tab_link = {}
|
||||
tab_name,tab_time,tab_desc,tab_link = {},{},{},{}
|
||||
http:get(url.."schedule.json?channel="..channel_id,"schedule")
|
||||
end
|
||||
|
||||
function on_dialog_action(data)
|
||||
if type(data) == "string" then
|
||||
data = data:gsub(" ","+")
|
||||
http:get(url.."idbytitle.json?titles="..data,"channel")
|
||||
elseif data ~= -1 then
|
||||
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")
|
||||
return
|
||||
end
|
||||
table.insert(tab_name,"Выберите канал")
|
||||
table.insert(tab_time,"")
|
||||
tab = {}
|
||||
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:show_lines(tab_name,tab_time)
|
||||
ui:show_table(tab,2)
|
||||
end
|
||||
|
||||
function on_settings()
|
||||
|
||||
Reference in New Issue
Block a user