[F/OS] πŸ› οΈ ComponentUtil - Additional Tools For Visible Components (90+ blocks)

:computer: Introduction

A non-visible extension that provides additional tools to visible components, such as Label.

Hope it saved some of your time! It took me :date: 3 days to complete this.

:clock3: Version: 5

:date: Release date: 2022-04-03T09:00:00Z

:hammer_and_wrench: Built with: Niotron IDE

:package: Package name: com.gordonlu.componenutil

:eye: Blocks overview

There are 96 blocks, 9 events and 88 methods.

V2 additions:

V3 additions:

V4 additions:

blocks (6)

:open_book: Documentation

Event blocks

AfterFocus

image

This event is fired after the extension has attempted to give focus to a component.

Parameters: component = component, successful = boolean

GotFocus

image

This event is fired when a registered component is focused.

Parameters: component = component

LostFocus

image

This event is fired when a registered component has focus removed.

Parameters: component = component

OnClick

image

This event is fired when a registered component is clicked.

Parameters: component = component

OnContextMenuFinish

image

This event is fired when the action is completed. The isAdvanced parameter identifies whether the action is showing an advanced context menu, and the successful parameter is whether the action is successfully completed.

Parameters: isAdvanced = boolean, successful = boolean

OnKey

image

This event is fired when the user has pressed a hardware key while playing around with this component. To check out what keyCode means, please read the keys in KeyEvent  |  Android Developers, starting with KEYCODE_.

Parameters: component = component, keyCode = number (int)

OnLongClick

image

This event is fired when a registered component is long clicked.

Parameters: component = component

OnScrollChange

image

This event is fired when the user has scrolled the component. This probably only works with scrollable arrangements.

Parameters: component = component, prevX = number (int), prevY = number (int), currentX = number (int), currentY = number (int)

OnTouch

image

This event is fired when the user has touched a registered component.

Parameters: component = component

Method blocks

ApplyBlink

image

Applies blink animation to a component, given a specific duration and a component.

Parameters: component = component, duration = number (int), startOffset = number (int)

Bounce

image

Bounces the given component with the given duration and repeat counts.

Parameters: component = component, duration = number (int), repeatCount = number (int)

CanScrollDown

image

Checks whether the component can be scrolled vertically in a down direction.

Returns: boolean

Parameters: component = component

CanScrollLeft

image

Checks whether the component can be scrolled horizontally in a left direction.

Returns: boolean

Parameters: component = component

CanScrollRight

image

Checks whether the component can be scrolled horizontally in a right direction.

Returns: boolean

Parameters: component = component

CanScrollUp

image

Checks whether the component can be scrolled vertically in a up direction.

Returns: boolean

Parameters: component = component

FadeIn

image

Applies fade-in animation for the given component.

Parameters: component = component

FadeOut

image

Applies fade-out animation for the given component.

Parameters: component = component, duration = number (int), startOffset = number (int)

GetBaseline

image

Return the offset of the component's text baseline from the widget's top boundary. If this component does not support baseline alignment, this method returns -1.

Returns: number (int)

Parameters: component = component

GetBottom

image

Returns the bottom of this component, in pixels.

Returns: number (int)

Parameters: component = component

GetContentDescription

image

Returns the component's content description.

Returns: text

Parameters: component = component

GetElevation

image

Returns the base depth position, or elevation, of the component, in pixels.

Returns: number (float)

Parameters: component = component

GetLeft

image

Returns the left edge of this component, in pixels.

Returns: number (int)

Parameters: component = component

GetOpacity

image

Returns the opacity of the component. 0 is less opaque and 1 is most opaque.

Returns: number (float)

Parameters: component = component

GetPaddingBottom

image

Returns the bottom padding of this component in pixels. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.

Returns: number (int)

Parameters: component = component

GetPaddingEnd

image

Returns the end padding of this component in pixels. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.

Returns: number (int)

Parameters: component = component

GetPaddingLeft

image

Returns the left padding of this component in pixels. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.

Returns: number (int)

Parameters: component = component

GetPaddingRight

image

Returns the left padding of this component in pixels. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.

Returns: number (int)

Parameters: component = component

GetPaddingStart

image

Returns the start padding of this component in pixels. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.

Returns: number (int)

Parameters: component = component

GetPaddingTop

image

Returns the top padding of this component in pixels. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.

Returns: number (int)

Parameters: component = component

GetPivotX

image

Returns the x location of the point around which the component is rotated and scaled.

Returns: number (float)

Parameters: component = component

GetPivotY

image

Returns the y location of the point around which the component is rotated and scaled.

Returns: number (float)

Parameters: component = component

GetRight

image

Returns the right edge of this component, in pixels.

Returns: number (int)

Parameters: component = component

GetRotation

image

Returns the degrees that the component is rotated around the pivot point.

Returns: number (float)

Parameters: component = component

GetRotationX

image

Returns the degrees that the component is rotated around the horizontal axis through the pivot point.

Returns: number (float)

Parameters: component = component

GetRotationY

image

Returns the degrees that the component is rotated around the vertical axis through the pivot point.

Returns: number (float)

Parameters: component = component

GetScaleX

image

Returns the amount that the component is scaled in x around the pivot point, as a proportion of the view's unscaled width.

Returns: number (float)

Parameters: component = component

GetScaleY

image

Returns the amount that the component is scaled in y around the pivot point, as a proportion of the view's unscaled width.

Returns: number (float)

Parameters: component = component

GetScrollBarSize

image

Returns the scrollbar size for this component.

Returns: number (int)

Parameters: component = component

GetScrollX

image

Return the scrolled left position of this component. This is the left edge of the displayed part of your component. You do not need to draw any pixels farther left, since those are outside of the frame of your component on screen.

Returns: number (int)

Parameters: component = component

GetScrollY

image

Return the scrolled top position of this component. This is the top edge of the displayed part of your component. You do not need to draw any pixels farther top, since those are outside of the frame of your component on screen.

Returns: number (int)

Parameters: component = component

GetTop

image

Returns the top edge of this component, in pixels.

Returns: number (int)

Parameters: component = component

GetTranslationX

image

Returns the horizontal location of this component relative to its left position. This position is post-layout, in addition to wherever the object's layout placed it.

Returns: number (float)

Parameters: component = component

GetTranslationY

image

Returns the vertical location of this component relative to its top position. This position is post-layout, in addition to wherever the object's layout placed it.

Returns: number (float)

Parameters: component = component

GetTranslationZ

image

Returns the depth location of this component relative to its elevation.

Returns: number (float)

Parameters: component = component

GetX

image

Returns the visual x position of this component, in pixels. This is equivalent to the TranslationX property plus the current left property.

Returns: number (float)

Parameters: component = component

GetY

image

Returns the visual y position of this component, in pixels. This is equivalent to the TranslationX property plus the current top property.

Returns: number (float)

Parameters: component = component

GetZ

image

Returns the visual z position of this component, in pixels. This is equivalent to the TranslationZ property plus the current elevation property.

Returns: number (float)

Parameters: component = component

IsActivated

image

Indicates the activation state of this component. Activation state is not equivalent to enabling state.

Returns: boolean

Parameters: component = component

IsClickable

image

Checks whether this component is clickable or not.

Returns: boolean

IsFocusable

image

Checks whether this component is currently able to take focus.

Returns: boolean

Parameters: component = component

IsLongClickable

image

Checks whether this component is long clickable or not.

Returns: boolean

IsPressed

image

Checks whether this component is currently pressed by the user.

Returns: boolean

PerformClick

image

Performs a click for the given component.

Parameters: component = component

PerformLongClick

image

Performs a long click for the given component.

Parameters: component = component

RegisterClick

image

Registers the component so that when the user clicks the component, it will fire the OnClick event.

Parameters: component = component

RegisterFocus

image

Registers the component so that when the user focuses or removes focus for the component, it will fire the respective event.

Parameters: component = component

RegisterLongClick

image

Registers the component so that when the user clicks the component, it will fire the OnLongClick event.

Parameters: component = component

RegisterOnKey

image

Registers the component so that when the user presses hardware keys while playing around with this component, the extension will fire the OnKey event.

Parameters: component = component

RegisterScroll

image

Registers the component so that when the user scrolls the component, it will fire the OnScroll event.

Parameters: component = component

RegisterTouch

image

Registers the component so that when the user touches the component, it will fire the OnTouch event.

Parameters: component = component

RemoveContentDescription

image

Removes the component's content description.

Parameters: component = component

RequestFocus

image

Call this to try to give focus to a specific component or to one of its descendants.

Parameters: component = component

Rotate

image

Rotates the given component.

Parameters: component = component, degree = number (float)

ScrollTo

image

Scrolls the scrollable arrangement to the given position.

Parameters: scrollableArrangement = component, x = number (int), y = number (int)

SetActivated

image

Changes the activated state of this component.

Parameters: component = component, activate = boolean

SetBottom

image

Sets the bottom position of this component relative to its parent, in pixels.

Parameters: component = component, bottom = number (int)

SetContentDescription

image

Sets the component's content description. A content description briefly describes the component and is primarily used for accessibility support to determine how a component should be presented to the user.

Parameters: component = component, description = text

SetElevation

image

Sets the elevation for the given component.

Parameters: component = component, elevation = number (float)

SetFocusable

image

Set whether this component can receive the focus.

Parameters: component = component, focusable = boolean

SetLeft

image

Sets the left position of this component relative to its parent, in pixels.

Parameters: component = component, left = number (int)

SetLongClickable

image

Sets whether this component can be long clickable.

Parameters: component = component, longClickable = boolean

SetOpacity

image

Sets the opacity of this component. 0 is less opaque and 1 is most opaque.

Parameters: component = component, opacity = number (float)

SetPadding

image

Sets the padding of the given component.

Parameters: component = component, left = number (int), top = number (int), right = number (int), bottom = number (int)

SetPivotX

image

Sets the x location of the point around which the component is rotated and scaled. By default, the pivot point is centered on the object.

Parameters: component = component, pivotX = number (float)

SetPivotY

image

Sets the y location of the point around which the component is rotated and scaled. By default, the pivot point is centered on the object.

Parameters: component = component, pivotX = number (float)

SetRight

image

Sets the right position of this component relative to its parent, in pixels.

Parameters: component = component, right = number (int)

SetRipple

image

Applies ripple effect for the given component.

Parameters: component = component, color = color

SetRotationX

image

Sets the degrees that the component is rotated around the horizontal axis through the pivot point.

Parameters: component = component, rotationX = number (float)

SetRotationY

image

Sets the degrees that the component is rotated around the vertical axis through the pivot point.

Parameters: component = component, rotationY = number (float)

SetScaleX

image

Sets the amount that the component is scaled in x around the pivot point, as a proportion of the component's unscaled width. A value of 1 means that no scaling is applied.

Parameters: component = component, scaleX = number (float)

SetScaleY

image

Sets the amount that the component is scaled in y around the pivot point, as a proportion of the component's unscaled height. A value of 1 means that no scaling is applied.

Parameters: component = component, scaleY = number (float)

SetScrollbarFadingEnabled

image

Define whether scrollbars will fade when the component is not scrolling.

Parameters: component = component, fade = boolean

SetScrollBarSize

image

Sets the size of the scrollbar.

Parameters: component = component, size = number (int)

SetTop

image

Sets the top position of this component relative to its parent, in pixels.

Parameters: component = component, top = number (int)

SetTranslationX

image

Sets the horizontal location of this component relative to its left position.

Parameters: component = component, translationX = number (float)

SetTranslationY

image

Sets the vertical location of this component relative to its top position.

Parameters: component = component, translationY = number (float)

SetTranslationZ

image

Sets the depth location of this component relative to its elevation.

Parameters: component = component, translationZ = number (float)

SetX

image

Sets the visual x position of this component, in pixels. This is equivalent to setting the TranslationX property to be the difference between the x value passed in and the current left property.

Parameters: component = component, x = number (float)

SetY

image

Sets the visual y position of this component, in pixels. This is equivalent to setting the TranslationY property to be the difference between the y value passed in and the current top property.

Parameters: component = component, y = number (float)

SetZ

image

Sets the visual z position of this component, in pixels. This is equivalent to setting the TranslationZ property to be the difference between the z value passed in and the current elevation property.

Parameters: component = component, y = number (float)

ShowAdvancedContextMenu

image

Shows the advanced context menu for this component and fires the OnContextMenuFinish event for whether it is successful. What's different from ShowContextMenu is that you can specify the x and y position of the context menu. This function will require devices with Android versions larger or 7.0.

:warning: NOTE: I cannot guarantee that this block works properly. That's why there is a successfull parameter in the corresponding event.

Parameters: component = component, x = number (float), y = number (float)

ShowContextMenu

image

Shows the context menu for this component and fires the OnContextMenuFinish event for whether it is successful.

:warning: NOTE: I cannot guarantee that this block works properly. That's why there is a successfull parameter in the corresponding event.

Parameters: component = component

StopAnimation

image

Stops all animations that you applied for the given component.

Parameters: component = component

UnregisterClick

image

Unregisters the component so that when it is clicked, the extension will not fire the OnClick event.

Parameters: component = component

UnregisterFocus

image

Unregisters the component so that when the user has focused or removed focus this component, it will not fire the respective event.

Parameters: component = component

UnregisterLongClick

image

Unregisters the component so that when it is clicked, the extension will not fire the OnLongClick event.

Parameters: component = component

UnregisterOnKey

image

Unegisters the component so that when a hardware key is pressed in this component, the extension will not fire the OnKey event.

Parameters: component = component

UnregisterScroll

image

Unregisters the component so that when the user has scrolled this component, it will not fire the OnScrollChange event.

Parameters: component = component

UnregisterTouch

image

Unregisters the component so that when the user has touched this component, it will not fire the OnTouch event.

Parameters: component = component

WillNotDraw

image

Checks whether the component can draw on its own.

Returns: boolean

Parameters: component = component

:inbox_tray: Downloads

AIX:
com.gordonlu.componentutil.aix (31.1 KB)

:scroll: History

Version 5, April 16 2022

AIX: com.gordonlu.componentutil.aix (28.6 KB)

Version 4, April 6 2022

AIX: com.gordonlu.componentutil.aix (27.3 KB)

Version 3, April 5 2022

AIX:
com.gordonlu.componentutil.aix (26.6 KB)

JAVA:
ComponentUtilV3.txt (32.5 KB)

Version 2, April 4 2022

AIX: com.gordonlu.componentutil.aix (24.1 KB)

JAVA:
ComponentUtilV2.txt (28.9 KB)

Version 1, April 3 2022

AIX: com.gordonlu.componentutil.aix (20.5 KB)

JAVA:
ComponentUtil.txt (25.1 KB)

:+1: Credits

Thank you @Kumaraswamy and @Salman_Dev for your help (I read your posts in the OS Development category, helps me a lot) and @MohamedTamer for his ComponentTools extension. Go check it out!

Also, for extensions that were mine and migrated into here, I would like to thank @Aquib_Khan for ClickZ.

Special thanks for YOU for reading this.

Other contributors:


Made with Niotron IDE.

Kindly :email: PM me if you have any questions! Also, if you like my extension, please :heart: like it! It takes some effort for me to make it...

Likes tell me the general user feedback of my extension. If you read this extension, please take 20 seconds to drop by and give a like!

If you have any features that you want to add and you know the code, PM me or directly reply below using the image button.

By downloading my extension, you agree the terms and conditions in my website.


Gordon Lu

:speech_balloon: Message :earth_africa: Website :e-mail: E-mail

35 Likes

I am very happy that many people can be helped from my post :partying_face:


@gordonlu310 I believe this is an extension that many people really need.
Good Job :+1:

1 Like

You two joined one year before me in this community. When I was a beginner, I learnt a lot from you two. Appreciate your help. You two are my favorite extension developers, BTW. :grinning:

2 Likes

Nice extension, but there are some issues with some methods.

Here is only one:
grafik

grafik

You should check before publishing.

1 Like

There is a method called GetRotationX. Did you check that?

I think it confuses people, since there is GetRotation and GetRotationX/Y. I tested:

image

Thank you for reporting though.

1 Like

Ok, but as you can see, nothing is rotated.

1 Like

I'll keep that in mind when I update it TMR. Thank you for reporting.

1 Like

And these don't work as expected either:

grafik

1 Like

Thank you very much, If you could add Reduis Method also

I figured it out. No, it's not a bug, it is just it should be. Compared to RotationX = 0, RotationX = 45 looks like the component is more laid down.

image

image

If you want to rotate a component, for example, flip it upside down, you have to use the Rotate block.

image

For Fade-In and Fade-Out, yes, there are bugs. I will fix it today.

1 Like

:candy: Version 2!

  • Updated the fade in and fade out blocks. Hope they work now. :sweat_smile:

  • New blocks added.

OnContextMenuFinish

image

This event is fired when the action is completed. The isAdvanced parameter identifies whether the action is showing an advanced context menu, and the successful parameter is whether the action is successfully completed.

Parameters: isAdvanced = boolean, successful = boolean

OnScrollChange

image

This event is fired when the user has scrolled the component. This probably only works with scrollable arrangements.

Parameters: component = component, prevX = number (int), prevY = number (int), currentX = number (int), currentY = number (int)

OnTouch

image

This event is fired when the user has touched a registered component.

Parameters: component = component

RegisterScroll

image

Registers the component so that when the user scrolls the component, it will fire the OnScroll event.

Parameters: component = component

RegisterTouch

image

Registers the component so that when the user touches the component, it will fire the OnTouch event.

Parameters: component = component

ShowAdvancedContextMenu

image

Shows the advanced context menu for this component and fires the OnContextMenuFinish event for whether it is successful. What's different from ShowContextMenu is that you can specify the x and y position of the context menu. This function will require devices with Android versions larger or 7.0.

:warning: NOTE: I cannot guarantee that this block works properly. That's why there is a successfull parameter in the corresponding event.

Parameters: component = component, x = number (float), y = number (float)

ShowContextMenu

image

Shows the context menu for this component and fires the OnContextMenuFinish event for whether it is successful.

:warning: NOTE: I cannot guarantee that this block works properly. That's why there is a successfull parameter in the corresponding event.

Parameters: component = component

UnregisterScroll

image

Unregisters the component so that when the user has scrolled this component, it will not fire the OnScrollChange event.

Parameters: component = component

UnregisterTouch

image

Unregisters the component so that when the user has touched this component, it will not fire the OnTouch event.

Parameters: component = component

1 Like

No, same as before.

It should work this way:

:pensive: Ok. That is exactly what the Stack Overflow answer is. I'll check it.

1 Like

I really loved your hard work :slightly_smiling_face::slightly_smiling_face:,
It's really awesome

2 Likes

Thank you! :hugs:

2 Likes

I have liked your all the posts just because of your hard work

1 Like

I still can't figure out where the problem is. The source code is open source, I'll find some extension developers to figure it out. :grinning:

You could also get inspired form designs in Dribbble

1 Like

The extension is now open source in GitHub. Don't forget to :star: the repo!

3 Likes

Thank you @gordonlu310 for this great contribution

1 Like