[F/OS] 🍫 LinearProgressbar - Animated Linear Bar!

:computer: Introduction

A non-visible extension that indicates the progress of an operation using an animated linear bar.

:date: Release date: 2022-04-19T04:30:00Z

:clock12: Version: 2

:package: Package name: com.gordonlu.linearprogressbar

:hammer_and_wrench: Built with: Niotron IDE

Some things to note:

  • the Theme of Screen1 must not be Classic.

  • you cannot use a linear progress bar ID that you have previously used in the same screen.

:open_book: Documentation

Event blocks

ProgressChanged

image

This event is fired when the progress of a linear progress bar has changed. The progress parameter returns the current progress value. If you have enabled Inderterminate for this progress bar, 'progress' will be 0.

Parameters: container = component, id = number (int), progress = number (int)

Method blocks

CreateLinearProgressbar

image

Creates a linear progress bar in the given container. If indeterminate is true, an infinite loading animation will be shown on the progress bar.

Parameters: container = component, id = number (int), color = color, indeterminate = boolean

CreateUsableId

image

Creates a usable ID that you can use to create a new progress bar. Each progress bars in every screen should have a unique ID. You should save this in a global variable for later use and to avoid conflicts.

Returns: number (int)

Parameters: container = component

GetMaximum

image

Returns the upper range of the progress bar.

Returns: number (int)

Parameters: container = component, id = number (int)

GetMinimum

image

Returns the lower range of the progress bar. Only works in devices with Android >= 8.

Returns: number (int)

Parameters: container = component, id = number (int)

GetProgress

image

Get the progress bar's current level of progress. Return 0 when the progress bar is in indeterminate mode.

Returns: number (int)

Parameters: container = component, id = number (int)

IncrementProgressBy

image

Increases the progress bar's progress by the specified amount.

Parameters: container = component, id = number (int), value = number (int)

IsIndeterminate

image

Checks whether the progress bar is indeterminate or not.

Returns: boolean

Parameters: container = component, id = number (int)

SetIndeterminate

image

Change the indeterminate mode for this progress bar. In indeterminate mode, the progress is ignored and the progress bar shows an infinite animation instead.

Parameters: container = component, id = number (int), indeterminate = boolean

SetIndeterminateColor

image

Changes the indeterminate color of the progress bar.

Parameters: container = component, id = number (int), color = color

SetMaximum

image

Sets the upper range of the progress bar.

Parameters: container = component, id = number (int), max = number (int)

SetMinimum

image

Sets the lower range of the progress bar. Only works in devices with Android >= 8.

Parameters: container = component, id = number (int), min = number (int)

SetPadding

image

Sets the padding for the progress bar.

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

SetProgress

image

Sets the current progress to the specified value. Does not do anything if the progress bar is in indeterminate mode.

Parameters: container = component, id = number (int), progress = number (int)

SetProgressColor

image

Changes the progress color of the progress bar.

Parameters: container = component, id = number (int), color = color

:books: FAQ

Q1: What is the difference between progress color and indeterminate color?

A1: You set the color of the progress bar with SetIndeterminateColor if your progress bar is indeterminate. Else use SetProgressColor.


Q2: What is a container?

A2: A container is used to contain your progress bar. The height and the width of the progress bar will be adjusted to the dimensions of the container. The container should only contain the progress bar, as if you put other components in the container, the progress bar will overlap them.

The container can be a horizontal or vertical arrangement, but not a scroll arrangement.


Q3: Sample blocks?

A3: Sure, here.

blocks (2)


:inbox_tray: Downloads

AIX: com.gordonlu.linearprogressbar.aix (10.7 KB)

:scroll: History

Version 1, April 19 2022

AIX:
com.gordonlu.linearprogressbar.aix (9.7 KB)


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.

If you find any :lady_beetle: bugs, please reply below.


Gordon Lu

:speech_balloon: Message :earth_africa: Website

13 Likes

Version 2!

  • More blocks:

CreateUsableId

image

Creates a usable ID that you can use to create a new progress bar. Each progress bars in every screen should have a unique ID. You should save this in a global variable for later use and to avoid conflicts.

Returns: number (int)

Parameters: container = component

IsIndeterminate

image

Checks whether the progress bar is indeterminate or not.

Returns: boolean

Parameters: container = component, id = number (int)

SetPadding

image

Sets the padding for the progress bar.

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

1 Like

Good extension 100/100 for you and yor extension @gordonlu310 i have always got inspiration from you

Now open source at GitHub.

I try to use LinearProgress bar without success. Where's my mistake?


Are you using "Classic" theme ?

2 Likes

Did you read this?

1 Like

Hi,
when I add the extension in my app, I receive this error:
Errore dall'app Companion: java.lang.RuntimeException: invalid syntax in eval form: :13:1: caught exception in inliner for # - java.lang.RuntimeException: no such class: com.gordonlu.linearprogressbar.LinearProgressbar gnu.bytecode.ObjectType.getReflectClass(ObjectType.java:179) gnu.bytecode.ClassType.getModifiers(ClassType.java:103) gnu.bytecode.ClassType.isInterface(ClassType.java:471) gnu.expr.InlineCalls.checkType(InlineCalls.java:56) gnu.expr.InlineCalls.visit(InlineCalls.java:49) gnu.expr.InlineCalls.visitSetExpValue(InlineCalls.java:363) gnu.expr.InlineCalls.visitSetExpValue(InlineCalls.java:28) gnu.expr.ExpVisitor.visitSetExp(ExpVisitor.java:114) gnu.expr.InlineCalls.visitSetExp(InlineCalls.java:369) gnu.expr.InlineCalls.visitSetExp(InlineCalls.java:28) gnu.expr.SetExp.visit(SetExp.java:406) gnu.expr.ExpVisitor.visit(ExpVisitor.java:55) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visitBeginExp(InlineCalls.java:272) gnu.expr.InlineCalls.visitBeginExp(InlineCalls.java:28) gnu.expr.BeginExp.visit(BeginExp.java:156) gnu.expr.ExpVisitor.visit(ExpVisitor.java:51) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visitBeginExp(InlineCalls.java:272) gnu.expr.InlineCalls.visitBeginExp(InlineCalls.java:28) gnu.expr.BeginExp.visit(BeginExp.java:156) gnu.expr.ExpVisitor.visit(ExpVisitor.java:51) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visitLetExp(InlineCalls.java:317) gnu.expr.InlineCalls.visitLetExp(InlineCalls.java:28) gnu.expr.LetExp.visit(LetExp.java:207) gnu.expr.ExpVisitor.visit(ExpVisitor.java:51) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visit(InlineCalls.java:28) gnu.expr.LambdaExp.visitChildrenOnly(LambdaExp.java:1664) gnu.expr.LambdaExp.visitChildren(LambdaExp.java:1651) gnu.expr.InlineCalls.visitScopeExp(InlineCalls.java:279) gnu.expr.InlineCalls.visitLambdaExp(InlineCalls.java:349) gnu.expr.InlineCalls.visitLambdaExp(InlineCalls.java:28) gnu.expr.LambdaExp.visit(LambdaExp.java:1640) gnu.expr.ExpVisitor.visit(ExpVisitor.java:55) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visit(InlineCalls.java:28) gnu.expr.ExpVisitor.visitAndUpdate(ExpVisitor.java:161) gnu.expr.ExpVisitor.visitExps(ExpVisitor.java:175) gnu.expr.ApplyExp.visitArgs(ApplyExp.java:415) gnu.kawa.reflect.CompileInvoke.validateApplyInvoke(CompileInvoke.java:23) java.lang.reflect.Method.invoke(Native Method) gnu.expr.InlineCalls.maybeInline(InlineCalls.java:467) gnu.expr.QuoteExp.validateApply(QuoteExp.java:150) gnu.expr.ReferenceExp.validateApply(ReferenceExp.java:191) gnu.kawa.functions.CompilationHelpers.validateApplyToArgs(CompilationHelpers.java:66) java.lang.reflect.Method.invoke(Native Method) gnu.expr.InlineCalls.maybeInline(InlineCalls.java:467) gnu.expr.QuoteExp.validateApply(QuoteExp.java:150) gnu.expr.ReferenceExp.validateApply(ReferenceExp.java:191) gnu.expr.InlineCalls.visitApplyExp(InlineCalls.java:119) gnu.expr.InlineCalls.visitApplyExp(InlineCalls.java:28) gnu.expr.ApplyExp.visit(ApplyExp.java:410) gnu.expr.ExpVisitor.visit(ExpVisitor.java:55) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.QuoteExp.validateApply(QuoteExp.java:162) gnu.expr.ReferenceExp.validateApply(ReferenceExp.java:191) gnu.kawa.functions.CompilationHelpers.validateApplyToArgs(CompilationHelpers.java:66) java.lang.reflect.Method.invoke(Native Method) gnu.expr.InlineCalls.maybeInline(InlineCalls.java:467) gnu.expr.QuoteExp.validateApply(QuoteExp.java:150) gnu.expr.ReferenceExp.validateApply(ReferenceExp.java:191) gnu.expr.InlineCalls.visitApplyExp(InlineCalls.java:119) gnu.expr.InlineCalls.visitApplyExp(InlineCalls.java:28) gnu.expr.ApplyExp.visit(ApplyExp.java:410) gnu.expr.ExpVisitor.visit(ExpVisitor.java:51) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visitBeginExp(InlineCalls.java:272) gnu.expr.InlineCalls.visitBeginExp(InlineCalls.java:28) gnu.expr.BeginExp.visit(BeginExp.java:156) gnu.expr.ExpVisitor.visit(ExpVisitor.java:51) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visit(InlineCalls.java:28) gnu.expr.LambdaExp.visitChildrenOnly(LambdaExp.java:1664) gnu.expr.LambdaExp.visitChildren(LambdaExp.java:1651) gnu.expr.InlineCalls.visitScopeExp(InlineCalls.java:279) gnu.expr.InlineCalls.visitLambdaExp(InlineCalls.java:349) gnu.expr.InlineCalls.visitLambdaExp(InlineCalls.java:28) gnu.expr.ExpVisitor.visitModuleExp(ExpVisitor.java:103) gnu.expr.ModuleExp.visit(ModuleExp.java:482) gnu.expr.ExpVisitor.visit(ExpVisitor.java:51) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.inlineCalls(InlineCalls.java:33) gnu.expr.Compilation.walkModule(Compilation.java:994) gnu.expr.Compilation.process(Compilation.java:1965) gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:330) gnu.expr.ModuleExp.evalModule1(ModuleExp.java:238) gnu.expr.ModuleExp.evalModule(ModuleExp.java:198) gnu.expr.Language.eval(Language.java:943) gnu.expr.Language.eval(Language.java:883) gnu.expr.Language.eval(Language.java:865) com.google.appinventor.components.runtime.util.AppInvHTTPD.serve(AppInvHTTPD.java:197) com.google.appinventor.components.runtime.util.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:489) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) java.lang.Thread.run(Thread.java:923)

are you using USB to connect the companion app?

How to avoid runtime errors with the companion app

  1. After importing an extension, please restart the companion app.
  2. If you like to use an extension on a different screen, in Screen1 additionally drag the extension into the working area.

While starting the companion app, all necessary assets and also the imported extensions of your project will be copied to your device. So in case the no such class error shows up, the extension code to run the extension is not available on your device. Without that code the companion app is not able to execute methods from the extension.

In case restarting the companion app does not work for you after trying several times, then as it looks like the only way for you to test you app will be after building it using the apk file.

Taifun

since one container can only have one component (including this progressbar), why almost every block has container and id as input. normally one of them will be ok. @gordonlu310

Apparently I have to use the "parent" of the progress bar so that I can get the ProgressBar object. I'll take a look into this when I get home.

How to round the edges of the progress bar? A rectangle does not look good.

Thank you.

You can try rounding the arrangement that is containing it.

How do I do that?

Other extensions offer functions to round the corners of components. You can try the SetCornerRadius method of:

1 Like

Also, I am noticing a problem with the extension. I use setProgress and set the value to 50, but nothing happens. The progress bar is created when the screen initializes. Here is my block:

Where am I going wrong? Thanks.

This may be the case if:

  • the Theme of your app is Classic. Do not use the Classic theme along with this extension (as mentioned).

  • you have set indeterminate to true when you initialize the progress bar. The SetProgress block will have no effect on the progress bar.

  1. False.

  2. Where do I change the theme?

In the properties of Screen1, change Theme to something other than Classic.

Thanks. The theme turned out to be the problem. Great extension!

1 Like