Description and category annotation ignored for custom extensions

In the designer description and category annotation are ignored. Category is always "unspecified". Description is the property name.

Example code:

    @SimpleProperty(category = PropertyCategory.BEHAVIOR, description = "This is the description.")
    public String TestProp() {
        return "Hello";
    }

    @DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_ASSET, defaultValue = "")
    @SimpleProperty
    public void TestProp(String path) {
        // Nothing to do
    }
![property|547x244](upload://c6gPMRu0m2fjEUsafwZB8vpxyrK.png)

The image:

property

Which mechanism are you using to build the extension? Are you building it with the code in the source tree or are you using the extension template repository?

Sorry, but I don't know what "source tree" or "extension template repository" mean.

I used this instruction http://kio4.com/appinventor/125B_extensiones_crear_i.htm to get a folder named "appinventor-sources" which contains all I need.

I'll add a very simple extension with nothing more than only one property. I decompiled the build extension. The decompiler shows this (it is identical to the source and the annotations are not lost):

package de.ullisroboterseite.testextension;

import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.DesignerProperty;
import com.google.appinventor.components.annotations.PropertyCategory;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.Component;
import com.google.appinventor.components.runtime.ComponentContainer;

@DesignerComponent(category = ComponentCategory.EXTENSION, nonVisible = true, version = 1)
@SimpleObject(external = true)
/* loaded from: classes.dex */
public class TestExtension extends AndroidNonvisibleComponent implements Component {
    public TestExtension(ComponentContainer container) {
        super(container.$form());
    }

    @SimpleProperty(category = PropertyCategory.BEHAVIOR, description = "This is the description.")
    public String TestProp() {
        return "Hello";
    }

    @SimpleProperty
    @DesignerProperty(defaultValue = "", editorType = "asset")
    public void TestProp(String path) {
    }
}

de.ullisroboterseite.testextension.aix (5.0 KB)

Ok, that's an in source tree build then. I'll poke around and see what's going on there.

category only works with a property setter, not getter, and only with using DesignerProperty annotation, i think.

Is it working?:

    @SimpleProperty(description = "This is the description.")
    public String TestProp() {
        return "Hello";
    }

    @DesignerProperty(category = PropertyCategory.BEHAVIOR, editorType = PropertyTypeConstants.PROPERTY_TYPE_ASSET, defaultValue = "")
    @SimpleProperty
    public void TestProp(String path) {
        // Nothing to do
    }

no, category is used for @SimpeProperty, not @DesignerProperty.

1 Like

Yes it's true. So what Ulrich showed should work.

No, here is an example from a built-in component:

@SimpleProperty(
      category = PropertyCategory.APPEARANCE,
      description = "Left, center, or right.",
      userVisible = false)
  public int TextAlignment() {
    return textAlignment;
  }

  @DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_TEXTALIGNMENT,
                    defaultValue = Component.ALIGNMENT_CENTER + "")
  @SimpleProperty(userVisible = false)
  public void TextAlignment(int alignment) {
    this.textAlignment = alignment;
    TextViewUtil.setAlignment(view, alignment, true);
  }

1 Like