diff --git a/README.md b/README.md index f40ec99..a3703d7 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ The type of script is determined by the line (meta tag) at the beginning of the ### 5.6.0 * Added `ui:set_edit_mode_buttons()` method +* Added size argument to `widgets:request_updates()` method ### 5.5.4 diff --git a/README_APP_WIDGETS.md b/README_APP_WIDGETS.md index f270968..ee113cb 100644 --- a/README_APP_WIDGETS.md +++ b/README_APP_WIDGETS.md @@ -2,7 +2,9 @@ Starting from version 5.2.0, AIO Launcher supports interaction with app widgets ### Introduction -Before you start working with app widgets, you need to find out the app widget provider's name and the widget interface structure. Both can be done using the [android-widget-dumper.lua](samples/android-widget-dumper.lua) script. Enter the package name of the desired application in its global variable `app_pkg` and run the script. It will display all the widgets available for that application. Click on the widget name, and you will see its provider name (first line) and a tree-like structure of its UI. Click on the text to copy it. +Before you start working with app widgets, you need to find out the app widget provider's name and the widget interface structure. Both can be done using the [android-widget-dumper.lua](dev/android-widget-dumper.lua) script. Enter the package name of the desired application in its global variable `app_pkg` and run the script. It will display all the widgets available for that application. Click on the widget name, and you will see its provider name (first line) and a tree-like structure of its UI. Click on the text to copy it. + +_Note: Some widgets can dynamically change their UI depending on their size. If you encounter such a widget, update the value of the `widget_size` variable by specifying a string from `1x1` to `4x4`. In other cases, leave the value as `nil`._ Take, for example, The Weather Channel app (package name: `com.weather.Weather`). Install this app and add its package name to the dumper script. After running the dumper, it will show you a list of widgets. Click on "Widget 2x2". A widget configuration screen will open. Click Done at the top of the configurator screen, and you will see the data of this widget. The first line will be the provider's name: @@ -43,7 +45,7 @@ end Using the `widgets:setup()` method, we ask the launcher to prepare a widget for us. The method returns an identifier needed to work with the widget, or `nil` if an error occurred. Note that this function may trigger the widget's configuration window if it has one. -Having obtained the identifier, we can use it to communicate with the widget. For this purpose, we call the `widgets:request_updates()` method: +Having obtained the identifier, we can use it to communicate with the widget. For this purpose, we call the `widgets:request_updates()` method (you can specify the widget size as a string from 1x1 to 4x4 as the second argument): ``` widgets:request_updates(prefs.wid) diff --git a/dev/android-widget-dumper.lua b/dev/android-widget-dumper.lua index b0b89e1..25c030c 100644 --- a/dev/android-widget-dumper.lua +++ b/dev/android-widget-dumper.lua @@ -6,6 +6,10 @@ app_pkg = "com.weather.Weather" --app_pkg = "com.android.chrome" --app_pkg = "com.whatsapp" +-- Widget size (string from "1x1" to "4x4") +-- In most cases you can use nil +widget_size = nil + -- Globals labels = {} providers = {} @@ -35,7 +39,7 @@ end function on_click(idx) if w_content == "" then wid = widgets:setup(providers[idx]) - widgets:request_updates(wid) + widgets:request_updates(wid, widget_size) else system:copy_to_clipboard(w_content) end