Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Unraveling the secrets for developing great And...

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
Tweet

More Decks by Juan Andrés Diana

Other Decks in Programming

Transcript

  1. Thus, we need to go beyond the basics… Good UX

    is mandatory nowadays for mobile
  2. 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)
  3. Files • BasicUserControl.control • BasicUserControlProperties.xml Defining a User Control Syntax

    • User Control Definition - Genexus Wiki • User Control Properties - Genexus Wiki
  4. <!-- 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
  5. <!-- 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
  6. <!-- 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
  7. <!-- 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
  8. <!-- 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
  9. <!-- 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
  10. <!-- 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
  11. <!-- 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
  12. <!-- 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
  13. <!-- Platforms supported -->
 <Platforms>
 <Platform>SmartDevices</Platform>
 </Platforms>
 
 <!-- Android

    Specific -->
 <Android_ClassName>com.example.BasicUserControl</ Android_ClassName> Defining a User Control
  14. <!-- Platforms supported -->
 <Platforms>
 <Platform>SmartDevices</Platform>
 </Platforms>
 
 <!-- Android

    Specific -->
 <Android_ClassName>com.example.BasicUserControl</ Android_ClassName> Defining a User Control
  15. <!-- Platforms supported -->
 <Platforms>
 <Platform>SmartDevices</Platform>
 </Platforms>
 
 <!-- Android

    Specific -->
 <Android_ClassName>com.example.BasicUserControl</ Android_ClassName> Defining a User Control
  16. public class Control { // ... } Implementing a User

    Control Mandatory for all User Controls Java class
  17. public class Control extends View { // ... } Implementing

    a User Control Mandatory for all User Controls Java class that: • Extends android.view.View
  18. public class Control extends TextView { // ... } Implementing

    a User Control Mandatory for all User Controls Java class that: • Extends android.view.View
  19. 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
  20. public class Control extends TextView implements IGxUserControl, IGxControlRuntime { //

    ... } Implementing a User Control Interfaces required if the User Control supports • Properties, events and methods.
  21. 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.
  22. 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.
  23. public class Control extends TextView implements IGxUserControl { // ...

    } Implementing a User Control Implement IGxUserControl when no values are represented. E.g. Ads Control
  24. 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
  25. 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
  26. More Information Genexus User Controls Genexus Wiki - Creating User

    Controls for Android Android Knowledge Android Developers - Android Custom Components Android Developers - Android Custom Views
  27. public class BasicExternalObject extends ExternalApi {
 private static final String

    METHOD_HELLO = "Hello";
 
 public BasicExternalObject() {
 addMethodHandler(METHOD_HELLO, 0, ...);
 }
 } Implementing an External Object
  28. 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
  29. 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
  30. 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
  31. 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
  32. 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);
  33. More Information Genexus External Objects Genexus Wiki - Defining an

    External Object Genexus Wiki - Implementing an External Object for Android
  34. Android Library (.AAR) Genexus Android Modules User Controls …. ….

    …. …. …. …. …. …. …. External Objects …. …. …. …. …. …. …. …. ….
  35. Android Library (.AAR) Genexus Android Modules …. …. …. SampleModule.java

    User Controls …. …. …. …. …. …. …. …. …. External Objects …. …. …. …. …. …. …. …. ….
  36. public class SampleModule implements GenexusModule {
 
 @Override
 public void

    initialize(Context context) { // ...
 }
 } Genexus Android Modules
  37. public class SampleModule implements GenexusModule {
 
 @Override
 public void

    initialize(Context context) { UserControlDefinition uc = new UserControlDefinition(
 "BasicUserControl",
 BasicUserControl.class
 );
 UcFactory.addControl(uc);
 }
 } Genexus Android Modules
  38. 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
  39. Android Library (.AAR) Genexus Android Modules …. …. …. SampleModule.java

    User Controls …. …. …. …. …. …. …. …. …. External Objects …. …. …. …. …. …. …. …. ….
  40. Android Library (.AAR) Genexus Android Modules …. …. …. SampleModule.java

    User Controls …. …. …. …. …. …. …. …. …. External Objects …. …. …. …. …. …. …. …. …. …. …. …. AndroidManifest.xml
  41. Requirements for Genexus 15 • Android Studio (includes Gradle) •

    JDK • Android SDK See Android Requirements - Genexus Wiki Development Environment
  42. 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?