Resize widget area?

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
mbirth
Posts: 80
Joined: 17 Mar 2016 00:02
Location: Berlin, Germany
Contact:

Resize widget area?

Post by mbirth » 15 Jan 2020 19:52

I have a script that uses the "Motion Detector" app to turn on the screen when somebody is moving in front of my tablet and then it counts down 180 seconds until it turns the screen off again. During that countdown it shows a widget with a green bar at the top of the screen that gets shorter with the time running out.

The widget was 1280x4 px in size. The green bar is resized to the screen width * percent of time done.

Now I've recently moved my setup from a 7" tablet to a 10" tablet with higher resolution (2560px width). And while I'm using the actual screen width for the Show Custom Widget Overlay action, the green bar appeared centred instead of starting at the top left (gravity). And it didn't get shorter.

After some looking around I finally found the reason: The widget itself (in "Custom Widgets") had a fixed size of 1280 pixels. So "Show Custom Widget Overlay" for some reason ignored the specified width and just used that for displaying it (centred in the area I've specified in the "Show Custom Widget Overlay" action). It then resized the green bar to 2560 pixels and displayed that in the 1280px widget.

Is this a bug or a feature? And is there a way to programmatically resize a widget itself? Sadly, I can't set it to e.g. 4000px (to make it ready for other devices) as it only allows a number up to the resolution of my current device.

EDIT: There's a "Stretch widget" option in the "Show Custom Widget Overlay" action, but that one scales the widget, reducing resolution when upscaling and making things blurry.
Last edited by mbirth on 19 Jan 2020 19:10, edited 1 time in total.
BlackBerry KEY2, Android 8.1.0

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Resize widget area?

Post by Desmanto » 16 Jan 2020 17:05

I am confused. Can you show a partial screenshot of what you got and what you expected to be? The widget should be able to scale up properly to the size you have chosen.

Currently, the widget maximum size is limited to the maximum longer resolution part of the screen. Mine is 1080x2160, and I can only design widget with maximum 2160x2160.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
mbirth
Posts: 80
Joined: 17 Mar 2016 00:02
Location: Berlin, Germany
Contact:

Re: Resize widget area?

Post by mbirth » 16 Jan 2020 17:17

My problem was that the widget in the menu "Custom widgets" had a smaller size than my screen (because I've imported it from another device).

And in a script, I've tried to resize the widget to full screen (with the "Stretch" option DISABLED to get the full resolution). But instead, it showed up in the size from the previous device.

So, without manually adjusting the widget size in that menu, there is no way to make the widget work on different devices. And my question was if that is intended or not.
BlackBerry KEY2, Android 8.1.0

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Resize widget area?

Post by Desmanto » 17 Jan 2020 05:18

This seems to be intended feature. So the widget can scale down from bigger size to smaller resolution. But will only show original widget resolution if the display is higher. I thought of getting the display resolution might help, such as here : viewtopic.php?p=19193#p19193

But it seems it is better we just design a widget bigger than most current devices resolution and let it scaled down automatically on all devices. You can actually cheat the limitation, but a bit hassle. Export the widget and edit the width and height to the one you need. So maybe thrice the size

Code: Select all

    <width>3840</width>
    <height>12</height>
Edit the widget name and add something, so it won't be duplicate. Tap and import back the widget, and there you got a bigger widget. The widget then can work in all devices with the maximum 3840x1920 resolution (4K).

Don't make it too big, or you might crash automagic. I try 10000x10000, and it takes more than 10 seconds just to open the widget. I immediately delete it afterward to prevent any future problem.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
mbirth
Posts: 80
Joined: 17 Mar 2016 00:02
Location: Berlin, Germany
Contact:

Re: Resize widget area?

Post by mbirth » 17 Jan 2020 10:31

Desmanto wrote:
17 Jan 2020 05:18
I try 10000x10000, and it takes more than 10 seconds just to open the widget.
See, that's why I would like to have a method of changing this value programmatically. I fetch the screen size already and use it to calculate the length of the green bar.

I was hoping something like

Code: Select all

setWidgetElementProperty("MyWidget", "MyWidget", "width", global_ScreenWidth)
would work.
BlackBerry KEY2, Android 8.1.0

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Resize widget area?

Post by Desmanto » 19 Jan 2020 18:02

A native function will better, but I don't know if it will be destructive. If you resize up the widget size, the inner elements will looks smaller. You have to resize everything too to make sure it scaled up/down proportional to the widget size. Maybe a better option is additional tick box to allow us upscale a widget when showing.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
mbirth
Posts: 80
Joined: 17 Mar 2016 00:02
Location: Berlin, Germany
Contact:

Re: Resize widget area?

Post by mbirth » 19 Jan 2020 18:45

Desmanto wrote:
19 Jan 2020 18:02
Maybe a better option is additional tick box to allow us upscale a widget when showing.
I believe that checkbox already is there (Show Custom Widget Overlay --> Stretch widget), but I'm afraid this will downgrade the resolution, e.g. 1px might get stretched to 2 or more pixels when drawing the widget. That's what I'm trying to avoid.

And all widget elements CAN be programmatically modified (setWidgetElementProperty) to match the desired widget size.
BlackBerry KEY2, Android 8.1.0

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Resize widget area?

Post by Desmanto » 19 Jan 2020 18:57

mbirth wrote:
19 Jan 2020 18:45
I believe that checkbox already is there (Show Custom Widget Overlay --> Stretch widget), but I'm afraid this will downgrade the resolution, e.g. 1px might get stretched to 2 or more pixels when drawing the widget. That's what I'm trying to avoid.

And all widget elements CAN be programmatically modified (setWidgetElementProperty) to match the desired widget size.
Oh, you are right. I thought Stretch is to make it non proportionally small only, turns out can be used to scale up too. I wonder why I remember the wrong thing and haven't bother to test it before testing, my bad.

Stretching from 1 to 2 seems still fine, if don't have any picture inside. Since your widget is a bar, so maybe it won't be pixelated. I try scaled up 1 to 4, and text will now become fuzzy/blurry, unacceptable.

Maybe you can add this into feature request. In mean time, you maybe need to cheat the widget resolution using text editing above.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply