Update some scripts

This commit is contained in:
Evgeny
2024-05-16 15:36:24 +04:00
parent 73b85a1a5c
commit 42473099eb
3 changed files with 192 additions and 158 deletions

View File

@@ -1,21 +1,22 @@
-- name = "Amdroid Next Alarm" -- name = "Amdroid Next Alarm"
-- description = "AIO wrapper for the Amdroid next alarm app widget" -- description = "AIO wrapper for the Amdroid Next alarm app widget"
-- type = "widget" -- type = "widget"
-- author = "Theodor Galanis" -- author = "Theodor Galanis (t.me/TheodorGalanis)"
-- version = "1.0.2" -- version = "1.10"
-- foldable = "false" -- foldable = "false"
-- uses_app = "com.amdroidalarmclock.amdroid" -- uses_app = "com.amdroidalarmclock.amdroid"
local prefs = require "prefs" local prefs = require "prefs"
local next_alarm = "" local next_alarm = ""
local accent="#FFFFFF" local accent="#888888"
function on_resume() function on_resume()
if not widgets:bound(prefs.wid) then if not widgets:bound(prefs.wid) then
setup_app_widget() setup_app_widget()
end end
accent = aio:colors().accent accent = aio:colors().accent
primary = aio:colors().primary_text
widgets:request_updates(prefs.wid) widgets:request_updates(prefs.wid)
end end
@@ -28,8 +29,10 @@ function on_app_widget_updated(bridge)
if next_alarm ~= nil if next_alarm ~= nil
then then
my_gui=gui{ my_gui=gui{
{"text", " %%fa:alarm-clock%% <span style=\"color:#FFFFFF\">"..next_alarm.."</span>", {gravity="center_h", color=accent}} {"icon", "fa:alarm-clock", {gravity="center_h|center_v",color = accent}},
} {"spacer", 2},
{"text", next_alarm, {gravity="anchor_prev"}}
}
else else
my_gui=gui{ my_gui=gui{
{"text", "Empty", {gravity="center_h" }} {"text", "Empty", {gravity="center_h" }}
@@ -42,6 +45,10 @@ function on_click(idx)
w_bridge:click(next_alarm) w_bridge:click(next_alarm)
end end
function on_settings()
ui:show_dialog("Amdroid app Next Alarm widget", "This script wrapper uses Amdroid app's Next alarm widget to display the next scheduled alarm. No settings are required.")
end
function setup_app_widget() function setup_app_widget()
local id = widgets:setup("com.amdroidalarmclock.amdroid/com.amdroidalarmclock.amdroid.widgets.NextAlarmWidgetProvider") local id = widgets:setup("com.amdroidalarmclock.amdroid/com.amdroidalarmclock.amdroid.widgets.NextAlarmWidgetProvider")

View File

@@ -1,15 +1,14 @@
-- name = "Google search" -- name = "Google search"
-- description = "AIO wrapper for the Google search app widget" -- description = "AIO wrapper for the Google search app widget - open widget settings for options"
-- type = "widget" -- type = "widget"
-- author = "Theodor Galanis" -- author = "Theodor Galanis (t.me/TheodorGalanis)"
-- version = "2.0" -- version = "2.5"
-- foldable = "false" -- foldable = "false"
-- uses_app: "com.google.android.googlequicksearchbox" -- uses_app: "com.google.android.googlequicksearchbox"
local prefs = require "prefs" local prefs = require "prefs"
local w_bridge = nil local w_bridge = nil
local gravs = {}
local indices = {} local indices = {}
function on_alarm() function on_alarm()
@@ -17,84 +16,113 @@ function on_alarm()
setup_app_widget() setup_app_widget()
end end
if not prefs.mode then if not prefs.mode then
prefs.mode = 1 prefs.mode = 1
end end
mode = prefs.mode mode = prefs.mode
gravs = {"left", "right"} indices = set_indices()
indices = {1, 3, 5, 7} widgets:request_updates(prefs.wid)
if mode == 2 then
gravs= reverse(gravs)
indices = reverse(indices)
end
widgets:request_updates(prefs.wid)
end end
function on_app_widget_updated(bridge) function on_app_widget_updated(bridge)
w_bridge = bridge w_bridge = bridge
local tab = { local tab = {
{"button", "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; %%fa:magnifying-glass%% &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;", {gravity = gravs[1]}}, {"button", "fa:magnifying-glass", {expand = true}},
{"spacer", 2}, {"spacer", 2},
{"button", "&nbsp; &nbsp; %%fa:asterisk%% &nbsp;", {gravity = gravs[2]}}, {"button", "fa:sun-cloud"},
{"spacer", 2}, {"spacer", 2},
{"button", "&nbsp; &nbsp; %%fa:microphone%% &nbsp;"}, {"button", "fa:asterisk"},
{"spacer", 2}, {"spacer", 2},
{"button", "&nbsp; &nbsp; %%fa:camera%% &nbsp;"} {"button", "fa:microphone"},
} {"spacer", 2},
{"button", "fa:camera"}
}
if mode==1 then tab = set_gui(tab)
my_gui = gui(tab) my_gui = gui(tab)
else my_gui.render()
my_gui =gui(reverse(tab))
end
my_gui.render()
end end
function on_click(idx) function on_click(idx)
if idx == indices[1] then if idx == indices[1] then
w_bridge:click("image_4") w_bridge:click("image_4")
elseif idx == indices[2] then elseif idx == indices[2] then
w_bridge:click("image_7") intent:start_activity(open_weather())
elseif idx == indices[3] then elseif idx == indices[3] then
w_bridge:click("image_9") w_bridge:click("image_7")
elseif idx == indices[4] then elseif idx == indices[4] then
w_bridge:click("image_10") w_bridge:click("image_9")
else return elseif idx == indices[5] then
end w_bridge:click("image_10")
else return
end
end end
function on_settings() function on_settings()
local tab = {"Left-handed mode", "Right-handed mode"} local tab = {"Left-handed mode with weather", "Left-handed mode, no weather", "Right-handed mode with weather", "Right-handed mode, no weather" }
ui:show_radio_dialog("Select mode", tab, mode) ui:show_radio_dialog("Select mode", tab, mode)
end end
function on_long_click(idx) function on_long_click(idx)
if idx == indices[1] then if idx == indices[1] then
ui:show_toast("Google search") ui:show_toast("Google search")
elseif idx == indices[2] then elseif idx == indices[2] then
ui:show_toast("Google discover") ui:show_toast("Google weather")
elseif idx == indices[3] then elseif idx == indices[3] then
ui:show_toast("Google voice search") ui:show_toast("Google discover")
elseif idx == indices[4] then elseif idx == indices[4] then
ui:show_toast("Google Lens") ui:show_toast("Google voice search")
end elseif idx == indices[5] then
ui:show_toast("Google Lens")
end
end end
function on_dialog_action(data) function on_dialog_action(data)
if data == -1 then if data == -1 then
return return
end end
prefs.mode = data prefs.mode = data
on_alarm() on_alarm()
end end
function setup_app_widget() function setup_app_widget()
local id = widgets:setup("com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.SearchWidgetProvider") local id = widgets:setup("com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.SearchWidgetProvider")
if (id ~= nil) then if (id ~= nil) then
prefs.wid = id prefs.wid = id
else else
ui:show_text("Can't add widget") ui:show_text("Can't add widget")
return return
end end
end end
function set_indices()
local temp = {1, 3, 5, 7, 9}
if mode == 2 then
temp = {1, 9, 3, 5, 7}
elseif mode == 3 then
temp = reverse (temp)
elseif mode == 4 then
temp = {7, 9, 5, 3, 1}
end
return temp
end
function set_gui(tab)
local temp = tab
if mode == 2 or mode == 4 then
table.remove(tab, 3)
table.remove(tab, 3)
end
if mode > 2 then
temp = reverse(temp)
end
return temp
end
function open_weather()
local tab ={}
tab.category = "MAIN"
tab.package = "com.google.android.googlequicksearchbox"
tab.component = "com.google.android.googlequicksearchbox/com.google.android.apps.search.weather.WeatherExportedActivity"
return tab
end

View File

@@ -1,49 +1,44 @@
-- name = "Quick Actions" -- name = "Quick Actions"
-- type = "widget" -- type = "widget"
-- description = "Launcher selected actions widget - long click button for options, open widget settings for list of buttons" -- description = "Launcher selected actions widget"
-- arguments_help = "Long click button for options, open widget settings for list of buttons"
--foldable = "true" --foldable = "true"
-- author = "Theodor Galanis" -- author = "Theodor Galanis"
-- version = "3.0" -- version = "2.5"
prefs = require "prefs" md_colors = require "md_colors"
prefs._name = "quickactions"
local actions = { "quick_menu", "settings", "apps_menu", "ui_settings", "headers", "quick_apps_menu", "refresh", "restart", "notify", "clear_notifications", "quick_settings", "show_recents", "private_mode", "screen_off", "fold", "unfold", "scroll_down", "scroll_up", "add_note", "add_task", "add_purchase", "shortcuts", "send_mail", "voice", "one_handed", "right_handed", "camera", "flashlight", "dialer", "search"} local icons = { "fa:pen", "fa:edit", "fa:indent", "fa:bars", "fa:sliders-h", "fa:redo", "fa:power-off", "fa:bring-forward", "fa:eraser", "fa:tools", "fa:layer-minus", "fa:layer-group", "fa:user-shield", "fa:lock", "fa:chevron-down", "fa:chevron-up", "fa:notes-medical", "fa:circle-dot", "fa:envelope", "fa:square-full", "fa:microphone", "fa:hand", "fa:search"}
local icons = { "fa:ellipsis-vertical", "fa:sliders-h", "fa:indent", "fa:paintbrush", "fa:bars", "fa:share-from-square", "fa:redo", "fa:power-off", "fa:bring-forward", "fa:eraser", "fa:square-ellipsis", "fa:square-full", "fa:user-shield", "fa:lock", "fa:layer-minus", "fa:layer-group", "fa:chevron-down", "fa:chevron-up", "fa:notes-medical", "fa:list-check", "fa:tag", "fa:share", "fa:envelope", "fa:microphone", "fa:hand", "fa:right-to-bracket", "fa:camera", "fa:brightness", "fa:phone", "fa:search"} local names = {"Quick menu", "Quick apps menu", "Applications menu", "Toggle headers", "Settings", "Screen refresh", "Restart AIO launcher", "Notifications panel", "Clear notifications", "Quick settings", "Fold all widgets", "Unfold all widgets", "Private mode", "Screen off", "Scroll down", "Scroll up", "Add note", "Start audio recording", "Send mail", "Recent apps", "Voice command", "One-handed mode", "Search"}
local cols = { "#6A1B9A", "#4527A0", "#8E24AA", "#FF6F00", "#E65100", "#0D47A1", "#546E7A", "#1B5E20", "#689F38", "#1565C0", "#F06292", "#0073DD", "#00796B", "#424242", "#3F51B5", "#3F51B5", "#AB47BC", "#AB47BC", "#D81B60", "#F57C00", "#9E9D24", "#00838F", "#B71C1C", "#512DA8", "#795548", "#5C6BC0", "#FF5252", "#FF8F00", "#B388FF", "#37474F"} local colors = { md_colors.purple_800, md_colors.purple_600, md_colors.amber_900, md_colors.orange_900, md_colors.blue_900, md_colors.deep_purple_800, md_colors.grey_600, md_colors.green_900, md_colors.green_900, md_colors.blue_800, md_colors.pink_300, md_colors.pink_A200, md_colors.green_600, md_colors.grey_800, md_colors.teal_700, md_colors.teal_800, md_colors.orange_700, md_colors.red_800, md_colors.red_900, md_colors.deep_purple_700, md_colors.blue_700, md_colors.amber_800, md_colors.blue_grey_700}
local actions = { "quick_menu", "quick_apps_menu", "apps_menu", "headers", "settings", "refresh", "restart", "notify", "clear_notifications", "quick_settings", "fold", "unfold", "private_mode", "screen_off", "scroll_down", "scroll_up", "add_note", "start_record", "send_mail", "show_recents", "voice", "one_handed", "search"}
local pos = 0 local pos = 0
local buttons,colors = {},{}
function on_alarm() function on_resume()
args = get_args() if next(settings:get()) == nil then
if not prefs.args then set_default_args()
prefs.args = args.action end
end local buttons,colors = get_buttons()
indexes = get_indexes(prefs.args, args.action) ui:show_buttons(buttons, colors)
ui:show_buttons(get_buttons())
end end
function on_click(idx) function on_click(idx)
if idx > #prefs.args then pos = idx
on_settings() redraw()
return
end
local action = prefs.args[idx]
aio:do_action(action)
on_alarm()
end end
function on_long_click(idx) function on_long_click(idx)
local label = "" pos = idx
pos = idx local tab = settings:get()
if idx > #prefs.args then label = get_label(actions[get_checkbox_idx()[idx]])
return if label == nil then
end label = names[get_checkbox_idx()[idx]]
label = get_label(args.action[indexes[idx]]) end
ui:show_context_menu({{"angle-left",""},{"ban",""},{"angle-right",""},{args.icon[indexes[idx]]:gsub("fa:",""),label}}) ui:show_context_menu({{"angle-left",""},{"ban",""},{"angle-right",""},{icons[get_checkbox_idx()[idx]]:gsub("fa:",""),label}})
end end
function on_context_menu_click(menu_idx) function on_context_menu_click(menu_idx)
@@ -53,92 +48,96 @@ function on_context_menu_click(menu_idx)
remove() remove()
elseif menu_idx == 3 then elseif menu_idx == 3 then
move(1) move(1)
elseif menu_idx == 4 then
redraw()
end end
end end
function on_dialog_action(data) function on_dialog_action(data)
if data == -1 then if data == -1 then
return return
end end
local tab = {} settings:set(data)
for i,v in ipairs(data) do on_resume()
tab[i] = args.action[v]
end
prefs.args = tab
on_alarm()
end end
function on_settings() function on_settings()
local labels = {} axions = aio:actions()
for i = 1, #icons do lab = {}
table.insert(labels, get_label(args.action[i])) for i = 1, #axions do
end lav = get_label(actions[i])
ui:show_checkbox_dialog("Select actions", labels, indexes) if lav == nil then
table.insert(lab,names[i])
else
table.insert(lab, lav)
end
end
ui:show_checkbox_dialog("Select actions", lab, get_checkbox_idx())
end end
--utilities-- --utilities--
function move(x) function redraw()
local tab = prefs.args local buttons,colors = get_buttons()
if (pos*x == -1) or (pos*x == #tab) then local checkbox_idx = get_checkbox_idx()
return local action = actions[checkbox_idx[pos]]
end aio:do_action(action)
local cur = tab[pos] ui:show_buttons(buttons, colors)
tab[pos] = tab[pos+x]
tab[pos+x] = cur
prefs.args = tab
on_alarm()
end end
function remove() function set_default_args()
local tab = prefs.args local args = {}
table.remove(tab,pos) for i = 1, #actions do
prefs.args = tab table.insert(args, i)
on_alarm() end
settings:set(args)
end end
function get_checkbox_idx()
function get_label(name) local tab = settings:get()
local lab="" for i = 1, #tab do
local axions = aio:actions() tab[i] = tonumber(tab[i])
if name == "clear_notifications" then end
lab = aio:res_string("clear_notifications","Clear notifications") return tab
else for _, action in ipairs(axions) do
if action["name"] == name then
lab = action["label"]
end
end
end
return lab
end
function get_args()
local tab = {}
tab.action = actions
tab.icon = icons
tab.color = cols
return tab
end end
function get_buttons() function get_buttons()
buttons,colors = {},{} local buttons,bcolors = {},{}
for i,v in ipairs(indexes) do local checkbox_idx = get_checkbox_idx()
table.insert(buttons, args.icon[v]) for i = 1, #checkbox_idx do
table.insert(colors, args.color[v]) table.insert(buttons, icons[checkbox_idx[i]])
end table.insert(bcolors, colors[checkbox_idx[i]])
return buttons,colors end
return buttons,bcolors
end end
function move(x)
function get_indexes(tab1,tab2) local tab = settings:get()
local tab = {} if (pos == 1 and x < 0) or (pos == #tab and x > 0) then
for i1,v1 in ipairs(tab1) do return
for i2,v2 in ipairs(tab2) do end
if v1 == v2 then local cur = tab[pos]
tab[i1] = i2 local prev = tab[pos+x]
break tab[pos+x] = cur
end tab[pos] = prev
end settings:set(tab)
end local buttons,colors = get_buttons()
return tab ui:show_buttons(buttons, colors)
end
function remove()
local tab = settings:get()
table.remove(tab,pos)
settings:set(tab)
local buttons,colors = get_buttons()
ui:show_buttons(buttons, colors)
end
function get_label(name)
axions = aio:actions()
for _, action in ipairs(axions) do
if action["name"] == name then
return action["label"]
end
end
end end