Update google search app widget

This commit is contained in:
Evgeny
2025-07-15 21:03:39 +08:00
parent 4d3ee33c01
commit 51f0eac6ee

View File

@@ -2,9 +2,9 @@
-- description = "AIO wrapper for the Google search app widget - open widget settings for options"
-- type = "widget"
-- author = "Theodor Galanis (t.me/TheodorGalanis)"
-- version = "2.7"
-- version = "2.8"
-- foldable = "false"
-- uses_app: "com.google.android.googlequicksearchbox"
-- uses_app = "com.google.android.googlequicksearchbox"
local prefs = require "prefs"
@@ -20,68 +20,68 @@ function on_alarm()
end
mode = prefs.mode
indices = set_indices()
widgets:request_updates(prefs.wid)
widgets:request_updates(prefs.wid, "4x1")
end
function on_app_widget_updated(bridge)
w_bridge = bridge
local tab = {
{"button", "fa:magnifying-glass", {expand = true}},
{"spacer", 2},
{"button", "fa:sun-cloud"},
{"spacer", 2},
{"button", "fa:asterisk"},
{"spacer", 2},
{"button", "fa:microphone"},
{"spacer", 2},
{"button", "fa:camera"}
}
{"button", "fa:magnifying-glass", {expand = true}},
{"spacer", 2},
{"button", "fa:sun-cloud"},
{"spacer", 2},
{"button", "fa:asterisk"},
{"spacer", 2},
{"button", "fa:microphone"},
{"spacer", 2},
{"button", "fa:camera"}
}
tab = set_gui(tab)
my_gui = gui(tab)
my_gui.render()
tab = set_gui(tab)
my_gui = gui(tab)
my_gui.render()
end
function on_click(idx)
if idx == indices[1] then
w_bridge:click("image_4")
elseif idx == indices[2] then
if idx == indices[1] then
w_bridge:click("image_2")
elseif idx == indices[2] then
intent:start_activity(open_weather())
elseif idx == indices[3] then
w_bridge:click("image_7")
elseif idx == indices[4] then
w_bridge:click("image_11")
elseif idx == indices[5] then
w_bridge:click("image_12")
elseif idx == indices[3] then
w_bridge:click("image_3")
elseif idx == indices[4] then
w_bridge:click("image_5")
elseif idx == indices[5] then
w_bridge:click("image_6")
else return
end
end
end
function on_settings()
local tab = {"Left-handed mode with weather", "Left-handed mode, no weather", "Right-handed mode with weather", "Right-handed mode, no weather" }
dialogs:show_radio_dialog("Select mode", tab, mode)
local tab = {"Left-handed mode with weather", "Left-handed mode, no weather", "Right-handed mode with weather", "Right-handed mode, no weather" }
dialogs:show_radio_dialog("Select mode", tab, mode)
end
function on_long_click(idx)
if idx == indices[1] then
ui:show_toast("Google search")
elseif idx == indices[2] then
ui:show_toast("Google weather")
elseif idx == indices[3] then
if idx == indices[1] then
ui:show_toast("Google search")
elseif idx == indices[2] then
ui:show_toast("Google weather")
elseif idx == indices[3] then
ui:show_toast("Google discover")
elseif idx == indices[4] then
elseif idx == indices[4] then
ui:show_toast("Google voice search")
elseif idx == indices[5] then
elseif idx == indices[5] then
ui:show_toast("Google Lens")
end
end
end
function on_dialog_action(data)
if data == -1 then
return
end
prefs.mode = data
on_alarm()
if data == -1 then
return
end
prefs.mode = data
on_alarm()
end
function setup_app_widget()
@@ -96,33 +96,33 @@ function setup_app_widget()
end
function set_indices()
local temp = {1, 3, 5, 7, 9}
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
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
local temp = tab
if mode == 2 or mode == 4 then
table.remove(tab, 3)
table.remove(tab, 3)
end
if mode > 2 then
table.remove(tab, 3)
table.remove(tab, 3)
end
if mode > 2 then
temp = reverse(temp)
end
return 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
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