Share
Embed
Unraveling the secrets for developing great Android extensions for Genexus 15
The Android ecosystem provides an immense and ever-growing number of possibilities for incorporating new APIs or eye-catching design patterns into your app.
In this session you will learn how to develop Android extensions for Genexus 15 ™. Furthermore, you will get a brief overview of the current state of Android extension development for Genexus and a sneak peek of what's coming.
Juan Andrés Diana
September 27, 2016
Transcript
76 slides
-
Unraveling the secrets for developing great Android extensions for Juan
Andrés Diana R&D - Genexus @juandiana7 -
Thus, we need to go beyond the basics… Good UX
is mandatory nowadays for mobile -
User Control Types Bound to an attribute or variable -
Item (e.g. SD Wheel) - List (e.g. SD Horizontal Grid) Not bound to an attribute or variable (e.g. Ads Control) -
Files • BasicUserControl.control • BasicUserControlProperties.xml Defining a User Control Syntax
• User Control Definition - Genexus Wiki • User Control Properties - Genexus Wiki -
<!-- Basic information --> <Id>44bda26b-9309-45fd-8972-0b35b080aff9</Id> <ObjClass>BASICUSERCONTROL</ObjClass> <Name>BasicUserControl</Name> <Description>Basic User Control</Description>
<Version>0.1.0</Version> <IncludeInControlInfo>true</IncludeInControlInfo> <ControlType>Item</ControlType> <ToolboxIcon>basic_user_control.ico</ToolboxIcon> <DesignRender>basic_user_control.png</DesignRender> Defining a User Control -
<!-- Basic information --> <Id>44bda26b-9309-45fd-8972-0b35b080aff9</Id> <ObjClass>BASICUSERCONTROL</ObjClass> <Name>BasicUserControl</Name> <Description>Basic User Control</Description>
<Version>0.1.0</Version> <ToolboxIcon>basic_user_control.ico</ToolboxIcon> <DesignRender>basic_user_control.png</DesignRender> <IncludeInControlInfo>true</IncludeInControlInfo> <ControlType>Item</ControlType> Defining a User Control -
<!-- Basic information --> <Id>44bda26b-9309-45fd-8972-0b35b080aff9</Id> <ObjClass>BASICUSERCONTROL</ObjClass> <Name>BasicUserControl</Name> <Description>Basic User Control</Description>
<Version>0.1.0</Version> <ToolboxIcon>basic_user_control.ico</ToolboxIcon> <DesignRender>basic_user_control.png</DesignRender> <IncludeInControlInfo>true</IncludeInControlInfo> <ControlType>Item</ControlType> Defining a User Control -
<!-- Basic information --> <Id>44bda26b-9309-45fd-8972-0b35b080aff9</Id> <ObjClass>BASICUSERCONTROL</ObjClass> <Name>BasicUserControl</Name> <Description>Basic User Control</Description>
<Version>0.1.0</Version> <ToolboxIcon>basic_user_control.ico</ToolboxIcon> <DesignRender>basic_user_control.png</DesignRender> <IncludeInControlInfo>true</IncludeInControlInfo> <ControlType>Item</ControlType> Defining a User Control -
<!-- Basic information --> <Id>44bda26b-9309-45fd-8972-0b35b080aff9</Id> <ObjClass>BASICUSERCONTROL</ObjClass> <Name>BasicUserControl</Name> <Description>Basic User Control</Description>
<Version>0.1.0</Version> <ToolboxIcon>basic_user_control.ico</ToolboxIcon> <DesignRender>basic_user_control.png</DesignRender> <IncludeInControlInfo>true</IncludeInControlInfo> <ControlType>Item</ControlType> Defining a User Control -
<!-- Properties, methods & events --> <PropertiesDefinition>BasicUserControlProperties.xml</ PropertiesDefinition> <Methods> <Method>
<Name>SetName</Name> <Signature>SetName(name: Character)</Signature> <Parameters> <Parameter>Character</Parameter> </Parameters> </Method> </Methods> <Events> <Event>EventOne</Event> </Events> Defining a User Control -
<!-- Properties, methods & events --> <PropertiesDefinition>BasicUserControlProperties.xml</ PropertiesDefinition> <Methods> <Method>
<Name>SetName</Name> <Signature>SetName(name: Character)</Signature> <Parameters> <Parameter>Character</Parameter> </Parameters> </Method> </Methods> <Events> <Event>EventOne</Event> </Events> Defining a User Control -
<!-- Properties, methods & events --> <PropertiesDefinition>BasicUserControlProperties.xml</ PropertiesDefinition> <Methods> <Method>
<Name>SetName</Name> <Signature>SetName(name: Character)</Signature> <Parameters> <Parameter>Character</Parameter> </Parameters> </Method> </Methods> <Events> <Event>EventOne</Event> </Events> Defining a User Control -
<!-- Properties, methods & events --> <PropertiesDefinition>BasicUserControlProperties.xml</ PropertiesDefinition> <Methods> <Method>
<Name>SetName</Name> <Signature>SetName(name: Character)</Signature> <Parameters> <Parameter>Character</Parameter> </Parameters> </Method> </Methods> <Events> <Event>EventOne</Event> </Events> Defining a User Control -
<!-- Platforms supported --> <Platforms> <Platform>SmartDevices</Platform> </Platforms> <!-- Android
Specific --> <Android_ClassName>com.example.BasicUserControl</ Android_ClassName> Defining a User Control -
<!-- Platforms supported --> <Platforms> <Platform>SmartDevices</Platform> </Platforms> <!-- Android
Specific --> <Android_ClassName>com.example.BasicUserControl</ Android_ClassName> Defining a User Control -
<!-- Platforms supported --> <Platforms> <Platform>SmartDevices</Platform> </Platforms> <!-- Android
Specific --> <Android_ClassName>com.example.BasicUserControl</ Android_ClassName> Defining a User Control -
public class Control { // ... } Implementing a User
Control Mandatory for all User Controls Java class -
public class Control extends View { // ... } Implementing
a User Control Mandatory for all User Controls Java class that: • Extends android.view.View -
public class Control extends TextView { // ... } Implementing
a User Control Mandatory for all User Controls Java class that: • Extends android.view.View -
public class Control extends TextView implements IGxUserControl { // ...
} Implementing a User Control Mandatory for all User Controls Java class that: • Extends android.view.View • Implements com.artech.controls.IGxUserControl -
public class Control extends TextView implements IGxUserControl, IGxControlRuntime { //
... } Implementing a User Control Interfaces required if the User Control supports • Properties, events and methods. -
public class Control extends TextView implements IGxUserControl, IGxControlRuntime, IGxThemeable {
// ... } Implementing a User Control Interfaces required if the User Control supports • Properties, events and methods. • Applying theme styles. -
public class Control extends TextView implements IGxUserControl, IGxControlRuntime, IGxThemeable, IGxLocalizable
{ // ... } Implementing a User Control Interfaces required if the User Control supports • Properties, events and methods. • Applying theme styles. • Language translations. -
public class Control extends TextView implements IGxUserControl { // ...
} Implementing a User Control Implement IGxUserControl when no values are represented. E.g. Ads Control -
public class Control extends TextView implements IGxEdit { public Control(Context
context, Coordinator coordinator, LayoutItemDefinition def) { } } Implementing a User Control Implement IGxEdit when one value is represented. E.g. SD Wheel -
public class Control extends TextView implements IGridView { public Control(Context
context, Coordinator coordinator, GridDefinition def) { } } Implementing a User Control Implement IGridView when a collection of values are represented. E.g. SD Horizontal Grid -
More Information Genexus User Controls Genexus Wiki - Creating User
Controls for Android Android Knowledge Android Developers - Android Custom Components Android Developers - Android Custom Views -
public class BasicExternalObject extends ExternalApi { // ... } Implementing
an External Object -
public class BasicExternalObject extends ExternalApi { private static final String
METHOD_HELLO = "Hello"; public BasicExternalObject() { addMethodHandler(METHOD_HELLO, 0, ...); } } Implementing an External Object -
public class BasicExternalObject extends ExternalApi { private static final String
METHOD_HELLO = "Hello"; public BasicExternalObject() { addMethodHandler(METHOD_HELLO, 0, mMethod); } private final IMethodInvoker mMethod = new IMethodInvoker() { @Override public ExternalApiResult invoke(List<Object> parameters) { // ... } }; } Implementing an External Object -
public class BasicExternalObject extends ExternalApi { private static final String
METHOD_HELLO = "Hello"; public BasicExternalObject() { addMethodHandler(METHOD_HELLO, 0, mMethod); } private final IMethodInvoker mMethod = new IMethodInvoker() { @Override public ExternalApiResult invoke(List<Object> parameters) { String text = (String) parameters.get(0); // ... } }; } Implementing an External Object -
public class BasicExternalObject extends ExternalApi { private static final String
METHOD_HELLO = "Hello"; public BasicExternalObject() { addMethodHandler(METHOD_HELLO, 0, mMethod); } private final IMethodInvoker mMethod = new IMethodInvoker() { @Override public ExternalApiResult invoke(List<Object> parameters) { String text = (String) parameters.get(0); return new ExternalApiResult( ActionResult.SUCCESS_CONTINUE, "Success!" ); } }; } Implementing an External Object -
public class BasicExternalObject extends ExternalApi { private static final String
METHOD_HELLO = "Hello"; public BasicExternalObject() { addMethodHandler(METHOD_HELLO, 0, mMethod); } private final IMethodInvoker mMethod = new IMethodInvoker() { @Override public ExternalApiResult invoke(List<Object> parameters) { String text = (String) parameters.get(0); return new ExternalApiResult( ActionResult.FAILURE, "Failure!" ); } }; } Implementing an External Object -
Properties Mapped to methods • Getter name: PropertyName • Setter
name: “set” + PropertyName Implementing an External Object Events ExternalObjectEvent event = new ExternalObjectEvent( BasicExternalObject.class.getSimpleName(), "EventOne" ); event.fire(args); -
More Information Genexus External Objects Genexus Wiki - Defining an
External Object Genexus Wiki - Implementing an External Object for Android -
Android Library (.AAR) Genexus Android Modules BasicExternalObject.java …. …. ….
BasicUserControl.java …. …. …. -
Android Library (.AAR) Genexus Android Modules User Controls …. ….
…. …. …. …. …. …. …. External Objects …. …. …. …. …. …. …. …. …. -
Android Library (.AAR) Genexus Android Modules …. …. …. SampleModule.java
User Controls …. …. …. …. …. …. …. …. …. External Objects …. …. …. …. …. …. …. …. …. -
public class SampleModule implements GenexusModule { @Override public void
initialize(Context context) { // ... } } Genexus Android Modules -
public class SampleModule implements GenexusModule { @Override public void
initialize(Context context) { UserControlDefinition uc = new UserControlDefinition( "BasicUserControl", BasicUserControl.class ); UcFactory.addControl(uc); } } Genexus Android Modules -
public class SampleModule implements GenexusModule { @Override public void
initialize(Context context) { UserControlDefinition uc = new UserControlDefinition( "BasicUserControl", BasicUserControl.class ); UcFactory.addControl(uc); ExternalApiDefinition eo = new ExternalApiDefinition( "BasicExternalObject", BasicExternalObject.class ); ExternalApiFactory.addApi(eo); } } Genexus Android Modules -
Android Library (.AAR) Genexus Android Modules …. …. …. SampleModule.java
User Controls …. …. …. …. …. …. …. …. …. External Objects …. …. …. …. …. …. …. …. …. -
Android Library (.AAR) Genexus Android Modules …. …. …. SampleModule.java
User Controls …. …. …. …. …. …. …. …. …. External Objects …. …. …. …. …. …. …. …. …. …. …. …. AndroidManifest.xml -
Now in Genexus 15… IDE: Android Studio Building system: Gradle
Development Environment -
Requirements for Genexus 15 • Android Studio (includes Gradle) •
JDK • Android SDK See Android Requirements - Genexus Wiki Development Environment -
Android Extensions Sample github.com/genexuslabs/AndroidExtensionsSample Genexus extensions documentation wiki.genexus.com Genexus extensions
forums genexus.com/developers/forums Genexus tag for StackOverflow stackoverflow.com/questions/tagged/genexus So… How do I start?