Good...
Hope Rapid repo. comes back with a updated and simple-to-use instance...
Good Luck @MohamedTamer
Hello again,
I have got back to working on Rapid in the last months and it's already almost done. Here's an example of usage of how Rapid works:
This is a simple code to add two numbers:
It would generate the following java code:
Click to view code
/*
* Copyright (c) 2022, <<Your Name>>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package io.mohamed.myextension;
import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
@SimpleObject(external=true)
@DesignerComponent(version = 1, nonVisible = true, category = ComponentCategory.EXTENSION, iconName = "images/extension.png", description = "Some description here.", versionName = "1.0")
public class MyExtension extends AndroidNonvisibleComponent {
public MyExtension(ComponentContainer container) {
super(container.$form());
}
/**
* Description goes here
*
* @param a
* @param b
* @return double
*/
@SimpleFunction
public double Add(double a, double b) {
return a + b;
}
}
And when imported in AI2 it displays as follow:
Of course, the generated code is pretty much similar to the code you would write normally to develop an extension, and all the extension properties such as description, version name and number, icon, help url, min sdk, etc.. can be modified using a built-in interface. Support for adding android manifest tags ( activities, services, etc..) and proguard is available. The buildserver of Rapid doesn't use any existing building tools for extensions but rather a custom optimized build mechanism which currently takes 3-10 secs to compile according to the project.
Also, here's an example of using a Java API through blocks by simply accessing the java.lang.String class:
Constructors are translated into a 'Create' block and static methods have the same behavior as the instance methods except for the fact that the instance parameter is removed.
These are just a simple examples, you could create much more advanced extensions with Rapid and make use of Android, AppInventor, Java, and even external libraries APIs.
Currently I'm fixing a few bugs related to variable typing system. Once completed, the first Alpha version of Rapid would be released as an online website.
I tried to make Rapid as simple as possible even for people who didn't code with Java or Kotlin before through using blocks, providing a brief explanation of errors thrown by the Java Compiler and what's exactly required to fix these errors, and showing warnings for blocks combination that could result errors ( Ex: Returning a value with a different type than the return type defined for the method, Putting blocks outside a top-level block, invoking a method on null instance, etc..) in a simple way. I would like to hear your opinions ( weather you are an extension developer or not ) about Rapid, would coding extension with blocks be easier for you than learning another high level language, what would you like to have it added and what you wouldn't like to see there. Let me also know if you have any questions about Rapid.
Cheers,
Mohamed Tamer
P.S: Sorry for bumping an old topic. I just didn't want to create a new topic when we already have an existing one.
P.S 2: The above github link is no longer valid as the main repository of Rapid was made private.
Fine work Mohamed, a very exciting idea and clearly complex for one person to define - is all the hair on your head grey now?