Add new APIs
This commit is contained in:
45
README.md
45
README.md
@@ -33,7 +33,8 @@ The type of script is determined by the line (meta tag) at the beginning of the
|
|||||||
* 4.5.5 - added `on_action` callback and `calendar:add_event` function;
|
* 4.5.5 - added `on_action` callback and `calendar:add_event` function;
|
||||||
* 4.5.6 - `aio:active_widgets()` now returns also widget `label`, added `checks` module;
|
* 4.5.6 - `aio:active_widgets()` now returns also widget `label`, added `checks` module;
|
||||||
* 4.5.7 - added "fold" and "unfold" actions to the `on_action` callback;
|
* 4.5.7 - added "fold" and "unfold" actions to the `on_action` callback;
|
||||||
* 4.6.0 - added `system:request_location()` and `tasker:send_command()` functions.
|
* 4.6.0 - added `system:request_location()` and `tasker:send_command()` functions;
|
||||||
|
* 4.7.0 - added `ui:build()` and functions to display search results in different formats.
|
||||||
|
|
||||||
# Widget scripts
|
# Widget scripts
|
||||||
|
|
||||||
@@ -55,10 +56,10 @@ Unlike widget scripts, search scripts are launched only when you open the search
|
|||||||
|
|
||||||
The search script can use two functions to display search results:
|
The search script can use two functions to display search results:
|
||||||
|
|
||||||
* `search:show(strings, [colors])` - shows results BELOW all other results;
|
* `search:show_buttons(names, [colors], [top])` - show buttons in the search results, the first parameter is table of button names, second - table of button colors in format `#XXXXXX`, `top` - whether the results need to be shown at the top (false by default);
|
||||||
* `search:show_top(strings, [colors])` - shows results BEFORE all other results.
|
* `search:show_lines(lines, [colors], [top])` - show text lines in the search results;
|
||||||
|
* `search:show_progress(names, progresses, [colors], [top])` - show progress bars in the search results, the first parameter is a table of names, the second is a table of progress bars (from 1 to 100);
|
||||||
Both functions take a table with search results strings as the first argument. Second optional parameter: table with colors of results in format `#XXXXXX`.
|
* `search:show_chart(points, format, [title], [show_grid], [top])` - show chart in the search results, parameters are analogous to `ui:show_chart()`.
|
||||||
|
|
||||||
When user click on a result, one of the following functions will be executed:
|
When user click on a result, one of the following functions will be executed:
|
||||||
|
|
||||||
@@ -114,7 +115,7 @@ First line<br/> Second line
|
|||||||
|
|
||||||
You can also use Markdown markup. To do this, add the prefix `%%mkd%%` to the beginning of the line. Or you can disable the formatting completely with the prefix `%%txt%%`.
|
You can also use Markdown markup. To do this, add the prefix `%%mkd%%` to the beginning of the line. Or you can disable the formatting completely with the prefix `%%txt%%`.
|
||||||
|
|
||||||
The `ui:show_buttons()` function supports Fontawesome icons. Simply specify `fa:icon_name` as the button name, for example: `fa:play`.
|
The `ui:show_buttons()` function supports Fontawesome icons. Simply specify `fa:icon_name` as the button name, for example: `fa:play`. (Note: AIO only supports icons up to Fontawesome 5.12.)
|
||||||
|
|
||||||
## Dialogs
|
## Dialogs
|
||||||
|
|
||||||
@@ -189,6 +190,38 @@ Here `share`, `copy` and `trash` are the names of the icons, which can be found
|
|||||||
|
|
||||||
When you click on any menu item, the collback `on_context_menu_click(idx)` will be called, where `idx` is the index of the menu item.
|
When you click on any menu item, the collback `on_context_menu_click(idx)` will be called, where `idx` is the index of the menu item.
|
||||||
|
|
||||||
|
## Build meta-widget
|
||||||
|
|
||||||
|
_Avaialble from: 4.7.0_
|
||||||
|
|
||||||
|
* `ui:build(table)` - constructs a widget from pieces of other AIO widgets.
|
||||||
|
|
||||||
|
The function takes a command table of this format as a parameter:
|
||||||
|
|
||||||
|
```
|
||||||
|
`battery` - battery progress bar;
|
||||||
|
`ram` - ram progress bar;
|
||||||
|
`nand` - nand progress bar;
|
||||||
|
`traffic` - traffic progress bar;
|
||||||
|
`screen` - screen time progress bar;
|
||||||
|
`alarm` - next alarm info;
|
||||||
|
`notes [NUM]` - last NUM notes;
|
||||||
|
`tasks [NUM]` - last NUM tasks;
|
||||||
|
`calendar [NUM]` - last NUM calendar events;
|
||||||
|
`exchage [NUM] [FROM] [TO]` - exchange rate FROM currency TO currency;
|
||||||
|
`player` - player controls;
|
||||||
|
`health` - health data;
|
||||||
|
`weather [NUM]` - weather forecast for NUM days;
|
||||||
|
`bitcoin` - bitcoin rate chart;
|
||||||
|
`worldclock [TIME_ZONE]` - time in the given TIME_ZONE;
|
||||||
|
`notify [NUM]` - last NUM notifications;
|
||||||
|
`dialogs [NUM]` - last NUM dialogs;
|
||||||
|
`text [TEXT]` - just shows TEXT;
|
||||||
|
`space [NUM]` - NUM of spaces.
|
||||||
|
```
|
||||||
|
|
||||||
|
[Sample](samples/build_ui_sample.lua).
|
||||||
|
|
||||||
## System
|
## System
|
||||||
|
|
||||||
* `system:open_browser(url)` - opens the specified URL in a browser or application that can handle this type of URL;
|
* `system:open_browser(url)` - opens the specified URL in a browser or application that can handle this type of URL;
|
||||||
|
|||||||
19
samples/build_ui_sample.lua
Normal file
19
samples/build_ui_sample.lua
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
function on_resume()
|
||||||
|
ui:build{
|
||||||
|
"text <b>This is a sample</b>",
|
||||||
|
"space 2",
|
||||||
|
"text Battery level",
|
||||||
|
"space",
|
||||||
|
"battery",
|
||||||
|
"space 2",
|
||||||
|
"text Notes",
|
||||||
|
"space",
|
||||||
|
"notes 2",
|
||||||
|
"space 2",
|
||||||
|
"text Exchange rates",
|
||||||
|
"exchange 10 usd amd",
|
||||||
|
"space 2",
|
||||||
|
"text Timezones",
|
||||||
|
"worldclock new_york kiev bangkok",
|
||||||
|
}
|
||||||
|
end
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
local table = {}
|
local table = {}
|
||||||
|
|
||||||
function on_search(input)
|
function on_search(input)
|
||||||
search:show({ input.." 1", input.." 2" })
|
search:show_buttons({ input.." 1", input.." 2" })
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_click(idx)
|
function on_click(idx)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ function on_search()
|
|||||||
local texts = { "text1", "text2", "text3" }
|
local texts = { "text1", "text2", "text3" }
|
||||||
local colors = { md_colors.purple_400, md_colors.purple_600, md_colors.purple_800 }
|
local colors = { md_colors.purple_400, md_colors.purple_600, md_colors.purple_800 }
|
||||||
|
|
||||||
search:show(texts, colors)
|
search:show_buttons(texts, colors)
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_click(idx)
|
function on_click(idx)
|
||||||
|
|||||||
19
samples/search-test3.lua
Normal file
19
samples/search-test3.lua
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
-- name = "Script #3"
|
||||||
|
-- type = "search"
|
||||||
|
|
||||||
|
md_colors = require("md_colors")
|
||||||
|
|
||||||
|
function on_search()
|
||||||
|
local texts = { "Line one", "Line two", "Line three" }
|
||||||
|
local colors = { md_colors.purple_400, md_colors.purple_600, md_colors.purple_800 }
|
||||||
|
|
||||||
|
search:show_lines(texts, colors)
|
||||||
|
end
|
||||||
|
|
||||||
|
function on_click(idx)
|
||||||
|
if idx == 1 then
|
||||||
|
system:vibrate(100)
|
||||||
|
else
|
||||||
|
system:vibrate(300)
|
||||||
|
end
|
||||||
|
end
|
||||||
20
samples/search-test4.lua
Normal file
20
samples/search-test4.lua
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
-- name = "Script #4"
|
||||||
|
-- type = "search"
|
||||||
|
|
||||||
|
md_colors = require("md_colors")
|
||||||
|
|
||||||
|
function on_search()
|
||||||
|
local texts = { "progress 1", "progress 2", "progress 3" }
|
||||||
|
local progresses = { 10, 50, 90 }
|
||||||
|
local colors = { md_colors.purple_400, md_colors.purple_600, md_colors.purple_800 }
|
||||||
|
|
||||||
|
search:show_progress(texts, progresses, colors)
|
||||||
|
end
|
||||||
|
|
||||||
|
function on_click(idx)
|
||||||
|
if idx == 1 then
|
||||||
|
system:vibrate(100)
|
||||||
|
else
|
||||||
|
system:vibrate(300)
|
||||||
|
end
|
||||||
|
end
|
||||||
20
samples/search-test5.lua
Normal file
20
samples/search-test5.lua
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
-- name = "Script #5"
|
||||||
|
-- type = "search"
|
||||||
|
|
||||||
|
function on_search()
|
||||||
|
local points = {
|
||||||
|
{ 1628501740654, 123456789 },
|
||||||
|
{ 1628503740654, 300000000 },
|
||||||
|
{ 1628505740654, 987654321 },
|
||||||
|
}
|
||||||
|
|
||||||
|
search:show_chart(points, "x:date y:number")
|
||||||
|
end
|
||||||
|
|
||||||
|
function on_click(idx)
|
||||||
|
if idx == 1 then
|
||||||
|
system:vibrate(100)
|
||||||
|
else
|
||||||
|
system:vibrate(300)
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user