From 93990298e8235dd578d05d6e6ab4940306e344e1 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 27 Aug 2022 08:49:29 +0300 Subject: [PATCH 1/5] community scripts refactoring and cleanup --- community/apps-widget.lua | 1 + community/calllog-ru-root-widget.lua | 4 +- ...ile-explorer.lua => cloud-file-widget.lua} | 1 + community/conversations-widget.lua | 3 + community/currency-widget-ru.lua | 2 +- community/fifteen-widget.lua | 6 +- community/horoscope-widget.lua | 1 + .../{net-file.lua => net-file-widget.lua} | 3 + ...rogress.lua => period-progress-widget.lua} | 67 +++++++++---------- community/public-ip-search.lua | 4 +- community/{qr-code.lua => qr-code-search.lua} | 0 ...ion-search-ru.lua => region-ru-search.lua} | 14 +++- community/rss-widget.lua | 2 +- .../{share-menu.lua => share-menu-search.lua} | 0 community/sudoku-widget.lua | 6 +- 15 files changed, 72 insertions(+), 42 deletions(-) rename community/{cloud-file-explorer.lua => cloud-file-widget.lua} (95%) rename community/{net-file.lua => net-file-widget.lua} (71%) rename community/{period_progress.lua => period-progress-widget.lua} (96%) rename community/{qr-code.lua => qr-code-search.lua} (100%) rename community/{region-search-ru.lua => region-ru-search.lua} (91%) rename community/{share-menu.lua => share-menu-search.lua} (100%) diff --git a/community/apps-widget.lua b/community/apps-widget.lua index 72989f8..91f6de0 100644 --- a/community/apps-widget.lua +++ b/community/apps-widget.lua @@ -1,4 +1,5 @@ -- name = "My apps" +-- description = "Simple apps widget" -- type = "widget" -- version = "1.0" -- author = "Andrey Gavrilov" diff --git a/community/calllog-ru-root-widget.lua b/community/calllog-ru-root-widget.lua index 368c6bf..c6dfc41 100644 --- a/community/calllog-ru-root-widget.lua +++ b/community/calllog-ru-root-widget.lua @@ -1,8 +1,10 @@ -- name = "История вызовов" +-- description = "Скрипт показывает историю вызов через прямое чтение базы звонков" -- type = "widget" -- author = "Andrey Gavrilov" -- version = "1.0" --- root = "yes" +-- lang = "ru" +-- root = "true" local types = {"Входящие","Исходящие","Пропущенные","Отменённые","Отклонённые","Заблокированные","Все"} diff --git a/community/cloud-file-explorer.lua b/community/cloud-file-widget.lua similarity index 95% rename from community/cloud-file-explorer.lua rename to community/cloud-file-widget.lua index 2431a95..737dcf4 100644 --- a/community/cloud-file-explorer.lua +++ b/community/cloud-file-widget.lua @@ -1,4 +1,5 @@ -- name = "File Explorer" +-- description = "Dropbox file explorer. Shows only AIO Launcher subdirectory" -- type = "widget" -- version = "1.0" -- author = "Andrey Gavrilov" diff --git a/community/conversations-widget.lua b/community/conversations-widget.lua index 75d6069..13b2420 100644 --- a/community/conversations-widget.lua +++ b/community/conversations-widget.lua @@ -1,4 +1,7 @@ -- name = "Conversations" +-- description = "Dialogs widget anologue" +-- author = "Evgeny Zobnin (zobnin@gmail.com)" +-- version = "1.0" local first_launch = true diff --git a/community/currency-widget-ru.lua b/community/currency-widget-ru.lua index 3414967..78466a0 100644 --- a/community/currency-widget-ru.lua +++ b/community/currency-widget-ru.lua @@ -4,7 +4,7 @@ -- type = "widget" -- author = "Andrey Gavrilov" -- version = "2.0" --- language = "ru" +-- lang = "ru" local json = require "json" local color = require "md_colors" diff --git a/community/fifteen-widget.lua b/community/fifteen-widget.lua index 7b17775..a7aca2a 100644 --- a/community/fifteen-widget.lua +++ b/community/fifteen-widget.lua @@ -1,4 +1,8 @@ -ui:set_title("15 puzzle") +-- name = "15 Puzzle" +-- description = "Game" +-- type = "widget" +-- author = "Andrey Gavrilov" +-- version = "1.0" local json = require "json" local folded = "15 puzzle" diff --git a/community/horoscope-widget.lua b/community/horoscope-widget.lua index e44452d..eadecde 100644 --- a/community/horoscope-widget.lua +++ b/community/horoscope-widget.lua @@ -1,4 +1,5 @@ -- name = "Horoscope" +-- description = "Horoscope for a given day" -- arguments_default = "scorpio today en" -- type = "widget" -- version = "1.0" diff --git a/community/net-file.lua b/community/net-file-widget.lua similarity index 71% rename from community/net-file.lua rename to community/net-file-widget.lua index ef13005..f292415 100644 --- a/community/net-file.lua +++ b/community/net-file-widget.lua @@ -1,4 +1,7 @@ -- name = "Network file" +-- description = "Shows the contents of any file on the Internet" +-- author = "Evgeny Zobnin (zobnin@gmail.com)" +-- version = "1.0" function on_resume() local args = settings:get() diff --git a/community/period_progress.lua b/community/period-progress-widget.lua similarity index 96% rename from community/period_progress.lua rename to community/period-progress-widget.lua index eac3ef8..8be2091 100644 --- a/community/period_progress.lua +++ b/community/period-progress-widget.lua @@ -1,34 +1,33 @@ --- name = "Period progress" --- description = "Shows period progress" --- type = "widget" --- author = "Nikolai Galashev" --- version = "1.0" --- arguments_help = "Enter the title and the start and end date in this format: Title 2021 01 31 2021 09 25" - - -function on_resume() - if (next(settings:get()) == nil) then - ui:show_text("Tap to enter date") - return - end - - local params = settings:get() - start_period = get_time(params[2], params[3], params[4]); - end_period = get_time(params[5], params[6], params[7]); - name_period = params[1] - current_time = os.time() - init_progressbar() -end - -function on_click() - settings:show_dialog() -end - -function get_time(y,m,d) - return os.time{day=d,month=m,year=y} -end - -function init_progressbar() - percent = math.floor((current_time - start_period) / ((end_period - start_period) / 100)) - ui:show_progress_bar(name_period..": "..percent.."%", current_time - start_period, end_period - start_period, "#7069f0ae") -end +-- name = "Period progress" +-- description = "Shows period progress" +-- type = "widget" +-- author = "Nikolai Galashev" +-- version = "1.0" +-- arguments_help = "Enter the title and the start and end date in this format: Title 2021 01 31 2021 09 25" + +function on_resume() + if (next(settings:get()) == nil) then + ui:show_text("Tap to enter date") + return + end + + local params = settings:get() + start_period = get_time(params[2], params[3], params[4]); + end_period = get_time(params[5], params[6], params[7]); + name_period = params[1] + current_time = os.time() + init_progressbar() +end + +function on_click() + settings:show_dialog() +end + +function get_time(y,m,d) + return os.time{day=d,month=m,year=y} +end + +function init_progressbar() + percent = math.floor((current_time - start_period) / ((end_period - start_period) / 100)) + ui:show_progress_bar(name_period..": "..percent.."%", current_time - start_period, end_period - start_period, "#7069f0ae") +end diff --git a/community/public-ip-search.lua b/community/public-ip-search.lua index 5c57821..febd5b2 100644 --- a/community/public-ip-search.lua +++ b/community/public-ip-search.lua @@ -11,14 +11,14 @@ local red = md_colors.red_500 local ip = "" function on_search(input) - if input:lower():find(string.lower("^ip$")) then + if input:lower():find("^ip$") then get_ip() end end function on_click() system:copy_to_clipboard(ip) -end +end function get_ip() http:get("https://api.ipify.org") diff --git a/community/qr-code.lua b/community/qr-code-search.lua similarity index 100% rename from community/qr-code.lua rename to community/qr-code-search.lua diff --git a/community/region-search-ru.lua b/community/region-ru-search.lua similarity index 91% rename from community/region-search-ru.lua rename to community/region-ru-search.lua index 8b2b174..491118e 100644 --- a/community/region-search-ru.lua +++ b/community/region-ru-search.lua @@ -2,7 +2,7 @@ -- description = "Поиск по кодам автомобильных номеров России" -- lang = "ru" -- type = "search" --- author = "Evgeny Zobnin (zobnin@gmail.com) +-- author = "Evgeny Zobnin (zobnin@gmail.com)" -- version = "1.0" function on_search(str) @@ -19,6 +19,7 @@ codes = { ["02"] = "Республика Башкортостан", ["102"] = "Республика Башкортостан", ["03"] = "Республика Бурятия", + ["103"] = "Республика Бурятия", ["04"] = "Республика Алтай (Горный Алтай)", ["05"] = "Республика Дагестан", ["06"] = "Республика Ингушетия", @@ -43,6 +44,7 @@ codes = { ["23"] = "Краснодарский край", ["93"] = "Краснодарский край", ["123"] = "Краснодарский край", + ["193"] = "Краснодарский край", ["24"] = "Красноярский край", ["84"] = "Красноярский край", ["88"] = "Красноярский край", @@ -50,6 +52,7 @@ codes = { ["25"] = "Приморский край", ["125"] = "Приморский край", ["26"] = "Ставропольский край", + ["126"] = "Ставропольский край", ["27"] = "Хабаровский край", ["28"] = "Амурская область", ["29"] = "Архангельская область", @@ -61,14 +64,17 @@ codes = { ["134"] = "Волгоградская область", ["35"] = "Вологодская область", ["36"] = "Воронежская область", + ["136"] = "Воронежская область", ["37"] = "Ивановская область", ["38"] = "Иркутская область", + ["138"] = "Иркутская область", ["85"] = "Иркутская область", ["39"] = "Калининградская область", ["91"] = "Калининградская область", ["40"] = "Калужская область", ["41"] = "Камчатский край", ["42"] = "Кемеровская область", + ["142"] = "Кемеровская область", ["43"] = "Кировская область", ["44"] = "Костромская область", ["45"] = "Курганская область", @@ -79,12 +85,15 @@ codes = { ["50"] = "Московская область", ["90"] = "Московская область", ["150"] = "Московская область", + ["750"] = "Московская область", ["190"] = "Московская область", + ["790"] = "Московская область", ["51"] = "Мурманская область", ["52"] = "Нижегородская область", ["152"] = "Нижегородская область", ["53"] = "Новгородская область", ["54"] = "Новосибирская область", + ["154"] = "Новосибирская область", ["55"] = "Омская область", ["56"] = "Оренбургская область", ["57"] = "Орловская область", @@ -98,11 +107,13 @@ codes = { ["62"] = "Рязанская область", ["63"] = "Самарская область", ["163"] = "Самарская область", + ["763"] = "Самарская область", ["64"] = "Саратовская область", ["164"] = "Саратовская область", ["65"] = "Сахалинская область", ["66"] = "Свердловская область", ["96"] = "Свердловская область", + ["196"] = "Свердловская область", ["67"] = "Смоленская область", ["68"] = "Тамбовская область", ["69"] = "Тверская область", @@ -123,6 +134,7 @@ codes = { ["197"] = "Москва", ["199"] = "Москва", ["777"] = "Москва", + ["797"] = "Москва", ["799"] = "Москва", ["78"] = "Санкт-Петербург", ["98"] = "Санкт-Петербург", diff --git a/community/rss-widget.lua b/community/rss-widget.lua index c01a7b0..6124711 100644 --- a/community/rss-widget.lua +++ b/community/rss-widget.lua @@ -6,7 +6,7 @@ -- version = "1.0" -- settings -local feed = "https://news.yandex.ru/index.rss" +local feed = "https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml" local lines_num = 5 local auto_folding = false diff --git a/community/share-menu.lua b/community/share-menu-search.lua similarity index 100% rename from community/share-menu.lua rename to community/share-menu-search.lua diff --git a/community/sudoku-widget.lua b/community/sudoku-widget.lua index edc3e42..96bb643 100644 --- a/community/sudoku-widget.lua +++ b/community/sudoku-widget.lua @@ -1,4 +1,8 @@ -ui:set_title("Sudoku") +-- name = "Sudoku" +-- description = "Sudoku games" +-- type = "Game" +-- author = "Andrey Gavrilov" +-- version = "1.0" local json = require "json" local folded = "Sudoku" -- 2.43.0 From e7a2acfe00f49aafb0849fda39dd832d6880e116 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 27 Aug 2022 11:48:03 +0300 Subject: [PATCH 2/5] add anim and morph modules in the README --- README.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0b8def0..1bf5307 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,8 @@ The type of script is determined by the line (meta tag) at the beginning of the * 4.4.4 - added `tasker` module; * 4.4.6 - added `csv` module; * 4.4.7 - added `intent` module; -* 4.5.0 - the `aio` module has been significantly expanded, also added `system:get_currency()` and `ui:show_list_dialog()`. +* 4.5.0 - the `aio` module has been significantly expanded, also added `system:get_currency()` and `ui:show_list_dialog()`; +* 4.5.2 - added `anim` and `morph` packages, added `calendar:open_event()` function. # Widget scripts @@ -283,7 +284,8 @@ If there is a problem with the network, the `on_network_error_$id` callback will * `calendar:get_events([start_date], [end_date], [cal_table])` - returns table of event tables of all calendars, start\_date - event start date, end\_date - event end date, cal\_table - calendar ID table; * `calendar:get_calendars()` - returns table of calendars tables; -* `calendar:show_event_dialog(id)` - opens an event in the system calendar. +* `calendar:show_event_dialog(id)` - shows the event dialog; +* `calendar:open_ovent(id)` - opens an event in the system calendar. Event table format: @@ -398,6 +400,27 @@ User can change settings through the dialog, which is available by clicking on t The standard edit dialog can be replaced by your own if you implement the `on_settings()` function. +## Animation and real time updates + +_Available only in widget scripts._ +_Avaialble from: 4.5.2_ + +The scripts API is designed in a way that every function that changes a widget's UI updates the entire interface. This approach makes the API as simple and convenient as possible for quick scripting, but it also prevents the creation of more complex scripts that change the UI state very often. + +There are two modules to solve this problem: `morph` and `anim`. The first is used to change individual UI elements, the second is used to animate those elements. + +* `morph:change_text(idx, text, [duration])` - changes element text with number `idx`, `duration` - animation duration in milliseconds; +* `morph:change_text_seq(idx, table, delay)` - sequentially changes text of element with number `idx`, `table` - table of lines which will be sequentially assigned to element with delay `delay`; +* `morph:change_outer_color(idx, color)` - changes "external" color (for example, button color) of element with index `idx`, `color` - color in format #XXXXXX; +* `morph:run_with_delay(delay, function) - populates specified Lua function with delay `delay`; +* `morph:cancel(idx)` - cancels a previously run change if it is not yet complete (e.g., delay or animation is not over). + +* `anim:blink(idx)` - blinks UI element with index `idx`; +* `anim:move(x, y, [delay])` - moves element sideways by specified number of DP and returns back after delay; +* `anim:heartbeat(idx)` - animation of heartbeat; +* `anim:shake(idx)` - shake animation; +* `anim:cancel(idx)` - cancel the running animation. + ## Functions _Avaialble from: 4.1.3_ -- 2.43.0 From a03b68adc0695e26f6b4446dda72aa3b68c61d2c Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 27 Aug 2022 11:49:41 +0300 Subject: [PATCH 3/5] small readme fix --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 1bf5307..3d8f977 100644 --- a/README.md +++ b/README.md @@ -414,7 +414,6 @@ There are two modules to solve this problem: `morph` and `anim`. The first is us * `morph:change_outer_color(idx, color)` - changes "external" color (for example, button color) of element with index `idx`, `color` - color in format #XXXXXX; * `morph:run_with_delay(delay, function) - populates specified Lua function with delay `delay`; * `morph:cancel(idx)` - cancels a previously run change if it is not yet complete (e.g., delay or animation is not over). - * `anim:blink(idx)` - blinks UI element with index `idx`; * `anim:move(x, y, [delay])` - moves element sideways by specified number of DP and returns back after delay; * `anim:heartbeat(idx)` - animation of heartbeat; -- 2.43.0 From 10240c8be0c8dad03febf7d1d7a1bae189100399 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 27 Aug 2022 21:44:35 +0300 Subject: [PATCH 4/5] small readme fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3d8f977..fb242a6 100644 --- a/README.md +++ b/README.md @@ -412,7 +412,7 @@ There are two modules to solve this problem: `morph` and `anim`. The first is us * `morph:change_text(idx, text, [duration])` - changes element text with number `idx`, `duration` - animation duration in milliseconds; * `morph:change_text_seq(idx, table, delay)` - sequentially changes text of element with number `idx`, `table` - table of lines which will be sequentially assigned to element with delay `delay`; * `morph:change_outer_color(idx, color)` - changes "external" color (for example, button color) of element with index `idx`, `color` - color in format #XXXXXX; -* `morph:run_with_delay(delay, function) - populates specified Lua function with delay `delay`; +* `morph:run_with_delay(delay, function)` - populates specified Lua function with delay `delay`; * `morph:cancel(idx)` - cancels a previously run change if it is not yet complete (e.g., delay or animation is not over). * `anim:blink(idx)` - blinks UI element with index `idx`; * `anim:move(x, y, [delay])` - moves element sideways by specified number of DP and returns back after delay; -- 2.43.0 From 074aed7b80993eff9ac9d7a8572392a61773ba73 Mon Sep 17 00:00:00 2001 From: sriramsv Date: Sat, 27 Aug 2022 12:08:36 -0700 Subject: [PATCH 5/5] Add Tasker Widget control script --- community/tasker-widget-control.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 community/tasker-widget-control.lua diff --git a/community/tasker-widget-control.lua b/community/tasker-widget-control.lua new file mode 100644 index 0000000..91de2dd --- /dev/null +++ b/community/tasker-widget-control.lua @@ -0,0 +1,26 @@ +-- name = "Tasker Widget Control" +-- description = "Add or Remove widgets from Tasker" +-- data_source = "internal" +-- type = "widget" +-- author = "Sriram SV" +-- version = "1.0" + +-- command structure +-- cmd:script:*:add=:= +-- cmd:script:*:remove=:= +-- adb shell am broadcast -a ru.execbit.aiolauncher.COMMAND --es cmd "script:tasker widget control:add=:=" --es password +-- adb shell am broadcast -a ru.execbit.aiolauncher.COMMAND --es cmd "script:tasker widget control:remove=:=" --es password +function on_command(cmd) + data = cmd:split("=:=") + command = data[1] + widget_name = data[2] + if command == "add" then + aio:add_widget(widget_name) + elseif command == "remove" then + aio:remove_widget(widget_name) + end +end + +function on_alarm() + ui:show_text("Use tasker tasks to add/remove widgets") +end \ No newline at end of file -- 2.43.0