A Simple Extension


#1

Could someone provide here a source code for a simple extension for ide.makeroid.io ?

Something very simple, send 2 numbers and return the result.

Thank you in advance.


#2

Another Greek:’)


(Pavitra Golchha) #3

#4

thanks @pavi2410 but I couldn’t manage to finish it. The following is a copy of yours with some modifications in order to pass the compilation.

Differences are on the

  • import packages (not important, the same packages you import in a higher level)
  • the return value of methods (I got a syntax error when return a+b; so I used return a; just to pass compiler error)

The .aix file is compiled successfully. My problem is when I import the .aix into a project, I can’t find the methods Add, Sub

package io.makeroid.xxxxxxxxxx.SimpleMaths;

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.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.annotations.UsesPermissions;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.common.PropertyTypeConstants;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;

@DesignerComponent(
version = 1,
description = “Extension made with Makeroid IDE”,
category = ComponentCategory.EXTENSION,
nonVisible = true,
iconName = “https://ide.makeroid.io/assets/logo.png”)

@SimpleObject(external = true)
public final class SimpleMaths extends AndroidNonvisibleComponent {

/**

  • Creates a new component
    */
    public SimpleMaths(ComponentContainer container) {
    super(container.$form());
    }
@SimpleFunction(description = "Simple addition of two numbers")
public double Add(double a, double b) {
    return a;
}

@SimpleFunction(description = "Simple sub of two numbers")
public double Sub(double a, double b) {
    return b;
}

}

edit:
Everything is ok except the syntax error I get when the line is return a+b; or return a-b;
Thanks again.


(Diego Barreiro Pérez) #5

Someone else already reported that the + sign crashes the extension, I’ll take a look :+1:


(Diego Barreiro Pérez) #6

I’ve just pushed an update which should fix the “+” sign (@Vasques1995)

Please test it again (remember to wait a few hours as cache will be there for a while, not only client side, also server side)


#7

Yes, the +,- signs work fine now.
Thanks a lot :slight_smile: