[Free] Color Extension

I've updated it.
As for the name it seems that when I change the name the exstension breaks.

See here:

Sorry Anke.
I don't understand it.

you have to change the directory of your extension, the package name and all occurences of Color_Exstension and replace it by Color

Taifun

1 Like

Hello Sketch

Congratulations on making your first App Inventor Extension. Remember that it is your responsibility to maintain it and keep it up-to-date with the changes brought in by new App Inventor versions.... even if that means announcing that it is incompatible.

The situation where that might be required is to carry across a colour specified in the Designer to the Blocks. However, how would this work in practice?

  1. Designer uses 32bit Hex, (RGBA) your example is 24bit Hex (RGB) -if a developer inputs 32bit Hex the result will be wrong. A hex value from the Designer is probably the most common conversion needed.

  2. The icon for your extension is way too large?

Snap1

Snap2

the correct size would be 16px x 16px
Taifun

2 Likes

Thank you :blush:

I didn't know there where more sorts of Hex codes.
I've checked the 32bit Hex code and IT doesn't work.
So I will change that.

Can easily be done with existing blocks:

image

1 Like

component_method (4)

Change this block to take hex values from the text field e.g. # 00FF00FF or # 00FF00 and automatically verify whether the color is 24 bit or 32 bit, then it will make little sense.

I know that.

Can you explains a bit more.
I don't really understand what you are trying to say.

I edited the post. It should be understandable now. Just rewrite this block to recognize hex 24 and 32bit correctly.

I was already Working on that.

we already talked about the naming conventions...
unfortunately you still do not follow them...
the correct name for RGBAColor would be rgbaColor

also you still have that spelling mistake in the extension name... this does not look very professional, does it?

Taifun

I think you can also rename argbToHex, which would correctly indicate that the first byte is an alpha channel.

It looks like you have used appybuilder code editor. You can't rename java file there so create a new project with file name color.java and copy-paste your code there and recompile it.

I've already tried that multiple Times but IT doesn't work.

Make sure that your java file name and class name is same.

i did that but then i get this error:
Buildfile: /projects/goldv2/appinventor-sources/appinventor/build.xml

extensions:

clean:
[delete] Deleting directory /projects/goldv2/appinventor-sources/appinventor/components/build

BUILD FAILED
/projects/goldv2/appinventor-sources/appinventor/build.xml:34: The following error [delete] Deleting directory /projects/goldv2/appinventor-sources/appinventor/components/reports

init:

common_CommonUtils:

init:

CommonUtils:

common_CommonVersion:

init:

CommonVersion:
[exec] Result: 128
[exec] Result: 128

CopyToRunLibDir:

components_AndroidRuntime:

init:
[mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/build/components
[mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/components/build
[mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/components/build/classes
[mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/components/reports
[mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/components/reports/raw
[mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/components/reports/html

CommonConstants:
[mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/components/build/classes/CommonConstants
[javac] Compiling 6 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/CommonConstants
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] 1 warning
[javac] Creating empty /projects/goldv2/appinventor-sources/appinventor/components/build/classes/CommonConstants/com/google/appinventor/components/common/package-info.class
[jar] Building jar: /projects/goldv2/appinventor-sources/appinventor/build/components/CommonConstants.jar
[jar] Building jar: /projects/goldv2/appinventor-sources/appinventor/build/components/CommonConstants-gwt.jar

HtmlEntities:
[mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/components/build/classes/HtmlEntities
[javac] Compiling 1 source file to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/HtmlEntities
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] 1 warning
[jar] Building jar: /projects/goldv2/appinventor-sources/appinventor/components/build/HtmlEntities.jar

common_CommonVersion:

init:

CommonVersion:
[exec] Result: 128
[exec] Result: 128

AndroidRuntime:
[mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/components/build/classes/AndroidRuntime
[javac] Compiling 332 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/AndroidRuntime
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/lukehoogenboom/Color/Color.java:18: error: Color is already defined in this compilation unit
[javac] import android.graphics.Color;
[javac] ^
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/lukehoogenboom/Color/Color.java:40: error: cannot find symbol
[javac] return Color.parseColor(hexColorCode);
[javac] ^
[javac] symbol: method parseColor(String)
[javac] location: class Color
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/lukehoogenboom/Color/Color.java:46: error: cannot find symbol
[javac] return Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
[javac] ^
[javac] symbol: method argb(int,int,int,int)
[javac] location: class Color
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/lukehoogenboom/Color/Color.java:52: error: cannot find symbol
[javac] float r = (Color.red(firstColor) * ratio) + (Color.red(secondColor) * inverseRation);
[javac] ^
[javac] symbol: method red(int)
[javac] location: class Color
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/lukehoogenboom/Color/Color.java:52: error: cannot find symbol
[javac] float r = (Color.red(firstColor) * ratio) + (Color.red(secondColor) * inverseRation);
[javac] ^
[javac] symbol: method red(int)
[javac] location: class Color
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/lukehoogenboom/Color/Color.java:53: error: cannot find symbol
[javac] float g = (Color.green(firstColor) * ratio) + (Color.green(secondColor) * inverseRation);
[javac] ^
[javac] symbol: method green(int)
[javac] location: class Color
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/lukehoogenboom/Color/Color.java:53: error: cannot find symbol
[javac] float g = (Color.green(firstColor) * ratio) + (Color.green(secondColor) * inverseRation);
[javac] ^
[javac] symbol: method green(int)
[javac] location: class Color
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/lukehoogenboom/Color/Color.java:54: error: cannot find symbol
[javac] float b = (Color.blue(firstColor) * ratio) + (Color.blue(secondColor) * inverseRation);
[javac] ^
[javac] symbol: method blue(int)
[javac] location: class Color
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/lukehoogenboom/Color/Color.java:54: error: cannot find symbol
[javac] float b = (Color.blue(firstColor) * ratio) + (Color.blue(secondColor) * inverseRation);
[javac] ^
[javac] symbol: method blue(int)
[javac] location: class Color
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/lukehoogenboom/Color/Color.java:55: error: cannot find symbol
[javac] return Color.rgb((int) r, (int) g, (int) b);
[javac] ^
[javac] symbol: method rgb(int,int,int)
[javac] location: class Color
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/lukehoogenboom/Color/Color.java:60: error: cannot find symbol
[javac] return Color.argb((int) alpha, (int) red, (int) green, (int) blue);
[javac] ^
[javac] symbol: method argb(int,int,int,int)
[javac] location: class Color
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/lukehoogenboom/Color/Color.java:65: error: cannot find symbol
[javac] int alpha = Color.alpha(RGBAColor);
[javac] ^
[javac] symbol: method alpha(int)
[javac] location: class Color
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/lukehoogenboom/Color/Color.java:66: error: cannot find symbol
[javac] int red = Color.red(RGBAColor);
[javac] ^
[javac] symbol: method red(int)
[javac] location: class Color
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/lukehoogenboom/Color/Color.java:67: error: cannot find symbol
[javac] int green = Color.green(RGBAColor);
[javac] ^
[javac] symbol: method green(int)
[javac] location: class Color
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/lukehoogenboom/Color/Color.java:68: error: cannot find symbol
[javac] int blue = Color.blue(RGBAColor);
[javac] ^
[javac] symbol: method blue(int)
[javac] location: class Color
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 15 errors
[javac] 1 warning

BUILD FAILED
/projects/goldv2/appinventor-sources/appinventor/build.xml:35: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:372: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/components/build.xml:141: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:118: Compile failed; see the compiler error output for details.

Total time: 4 seconds

The file name should not be the same as imports or object names.

3 Likes

Update
Update log:
The name has been changed to Colour instead of Color_Exstension and now follows the naming conventions as reqeusted by @Taifun
Also I really wan't to thank @Kumaraswamy, @Techno_Vedang and @Taifun for helping me change the name.
NOTE: the new exstension won't upgrade to the old one but wil insert a new one.
download:
com.appybuilder.lukehoogenboom.Colour.aix (7.6 KB)

4 Likes