From 51f0eac6eecbb2f986b8859c7e6a9f204854b57a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 15 Jul 2025 21:03:39 +0800 Subject: [PATCH] Update google search app widget --- community/google-search-app-widget.lua | 146 ++++++++++++------------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/community/google-search-app-widget.lua b/community/google-search-app-widget.lua index 11f9a07..8f85ab2 100644 --- a/community/google-search-app-widget.lua +++ b/community/google-search-app-widget.lua @@ -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" @@ -16,78 +16,78 @@ function on_alarm() setup_app_widget() end if not prefs.mode then - prefs.mode = 1 + prefs.mode = 1 end - mode = prefs.mode - indices = set_indices() - widgets:request_updates(prefs.wid) + mode = prefs.mode + indices = set_indices() + 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 - 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") - else return -end + 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_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 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 - ui:show_toast("Google discover") -elseif idx == indices[4] then - ui:show_toast("Google voice search") -elseif idx == indices[5] then - ui:show_toast("Google Lens") -end + 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 + ui:show_toast("Google voice search") + elseif idx == indices[5] then + ui:show_toast("Google Lens") + 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() local id = widgets:setup("com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.SearchWidgetProvider") - if (id ~= nil) then + if (id ~= nil) then prefs.wid = id else ui:show_text("Can't add widget") @@ -96,33 +96,33 @@ function setup_app_widget() 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 + 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 + 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 + 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