Skip to main content

Android SDK

Getting Started

Follow the instructions below to get you a copy of the project up and running on your local machine to integrate the Android SDK.

Installation

The procedures mentioned below lets you to install and use A8-Flow SDK.

Step 1: Add the maven repository to your build file. Now, add it in your root build.gradle at the beginning.

allprojects {
repositories {
...
maven {
url "https://maven.autonom8.com/artifactory/gradle-release-local"
credentials {
username = "USER_NAME"
password = "PASSWORD"
}
}
maven { url 'https://jitpack.io' }
}
}

Step 2: Add the dependency to app build.gradle.

dependencies {
// a8-sdk
implementation 'com.autonom8.public:a8flow:1.0.19'
}

Step 3: Now, sync the project.

✅ That's it! The first time you request a project; Maven checks out the code, builds it and serves the build artifacts.

Using the A8Flow SDK with Builder Options

A8FlowOptions.Builder builder = new A8FlowOptions.Builder();
builder.setBaseUrl("YOUR_BASE_URL"); // It is mandatory
builder.setFlavour("YOUR_APP_FLAVOUR"); // Option to show the App flavour dev/stag etc.
builder.setShowScannerGallery(true);// Option to show/hide gallery pick option for a8scanner sdk
builder.setScannerClassifyValidation(false);// Option for enable/disable image classifier validation
builder.setNotificationEnabled(false);// Option to enable/disable notification screen if FCM Implemented
builder.setCompletedTaskShow(false); // Option to enable/disable Completed Task screen
builder.setIsExternalAuth(true);// Option to set external login
builder.setIsGroupedApplication(false);// Option to enable Group Application Task Feature
builder.setClaimTaskShow(true);// Option to enable/disable Claim Task screen
builder.setAutoUpdate(false);// Option to enable/disable App Auto Update when new version is available
builder.setFormCacheExpirationNoOfMinutes(10);// Set minutes to clear the Form cache from the time it has been opened , default value is 87600 min (ie 2 months)
builder.setEnableProcessDelete(true); //Option to enable/disable process deletion functionality
A8FlowApps.initializeA8Flow(context, builder.create()); // Initializing the A8Flow SDK with Builder Options

Here BASE_URL is the form url that has to be loaded. You should initialize the above code into your application class.

UI Customization & Themes

Use the style names mentioned in the code below to change the header logo.

<style name="loginBannerImage">
<item name="android:src">@drawable/login_banner_img</item>
</style>

<style name="headerLogo">
<item name="android:scaleType">centerCrop</item>
<item name="android:src">@drawable/header_logo</item>
<item name="android:maxWidth">@dimen/header_logo_max_width</item>
</style>

<style name="bottomNavColorStyle">
<item name="android:scaleType">centerCrop</item>
<item name="android:src">@drawable/header_logo</item>
</style>

<style name="DialogAnimation">
<item name="android:windowEnterAnimation">@anim/slide_up</item>
<item name="android:windowExitAnimation">@anim/slide_down</item>
</style>

<dimen name="header_logo_max_width">200dp</dimen>

<style name="loginInputContainer">
<item name="android:layout_marginTop">@dimen/dimen_30</item>
</style>

Use the same color names mentioned below to change the colors with same color.

<resources>
<color name="primary">*your color code*</color>
<color name="primaryDark">*your color code*</color>
<color name="accent">*your color code*</color>

<color name="bottomNavBgColor">*your color code*</color>
<color name="bottomNavItemBgColor">*your color code*</color>
<color name="completeBtnBgColor">*your color code*</color>
<color name="saveBtnBgColor">*your color code*</color>
<color name="fabBgColor">*your color code*</color>
<color name="loadingIndicatorColor">*your color code*</color>
<color name="taskCardTagTextColor">*your color code*</color>
<color name="taskCardTagTextBg">*your color code*</color>

<color name="a8_scanner_theme">@color/primary</color>// Set A8Scanner theme color

</resources>

Use the bool names mentioned below to show/hide the various views.

<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="a8_scanner_rotate_visibility">true</bool>// Option to show/hide a8 scanner rotate button
<bool name="a8_scanner_enhancement_visibility">true</bool>// Option to show/hide s8 scanner image enhancement features
<bool name="a8flow_linear_view_visibility">true</bool>// Option to show/hide linear view button
<bool name="a8flow_bottom_nav_visibility">true</bool>// Option to show/hide bottom navigation view
<bool name="a8flow_forget_password_visibility">true</bool>// Option to show/hide forget password view
<bool name="a8flow_filter_enabled">true</bool>// Option to show/hide filter button
<bool name="a8flow_change_password_visibility">false</bool>// Option to show/hide change password view
</resources>

Splash Screen

Use the below code to implement the default login screen from SDK.

A8Auth a8Auth = A8Auth.getInstance(this);// your splash screen context

a8Auth.validateAuth(new AuthValidator() {
@Override
public boolean onAuthenticated(GlobalData globalData) {
Log.i(TAG, "onAuthenticated: globalData[" + globalData + "]");
return true;
}

@Override
public boolean onNotAuthenticated() {

}
});

Type the below mentioned code to implement the customized login screen.

a8Auth.validateAuth(new AuthValidator() {
@Override
public boolean onAuthenticated(GlobalData globalData) {
Log.i(TAG, "onAuthenticated: globalData[" + globalData + "]");
return true;
}

@Override
public boolean onNotAuthenticated() {
Intent intent = new Intent(SplashActivity.this, YourCustomizedLoginActivity.class);
startActivity(intent);
return false;
}
});

Login Functionality

While using your own login screen you can use the below call back method to perform login.

A8Auth a8Auth = A8Auth.getInstance(this); // Your following context

LoginRequest loginRequest = new LoginRequest();

loginRequest.setUsername("Your User Name");
loginRequest.setPassword("Your Password");

a8Auth.getInstance(this).login(isExternalAuth, loginRequest, new LoginListener() {
@Override
public boolean onSuccess(com.autonom8.a8flow.datasource.realmObject.LoginResponse response) {
return true;
}

@Override
public void onComplete(com.autonom8.a8flow.datasource.realmObject.LoginResponse response) {
finish();
}

@Override
public void onFailure(Exception error) {
}
});

//Note: isExternalAuth is a boolean true/false

By implementing the above callback method, you can use this in your own customized login screen.

FCM Implementation

Follow the steps mentioned below for integrating Firebase Cloud Messaging (FCM) to implement cloud messaging into your application.

Add the below code snippet to your root gradle.

buildscript {
repositories {
google()
jcenter()

}
dependencies {
classpath 'com.google.gms:google-services:4.3.3'
}
}

Now, add the below code snippet to your app gradle dependency.

implementation 'com.google.firebase:firebase-messaging:20.2.1'

After integrating, use the following snippets to implement the FCM Integration inside Firebase messaging service class.

public class MyFirebaseService extends A8FirebaseMessagingService {

@Override
public void onNewToken(@NotNull String token) {
super.onNewToken(token);
Log.d("MyFirebaseService", "New Token " + token);

}

@Override
public void onMessageReceived(@NotNull RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);

}
}

Use the above mentioned code to handle the receieved notification in On Message received function.

Firebase Crashlytics Implementation

Follow the below steps in integrating Firebase Crashlytics to implement crashlytics into your application.

Add the below code snippet to your root gradle.

buildscript {
repositories {
google()
jcenter()

}
dependencies {
// Add the Crashlytics Gradle plugin.
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'
}
}

Add the below code snippet to your app gradle dependency.

// Apply the Crashlytics Gradle plugin
apply plugin: 'com.google.firebase.crashlytics' // add this to your top of gradle

dependencies {
// Add the Firebase Crashlytics SDK.
implementation 'com.google.firebase:firebase-crashlytics:17.1.0'
}

Firebase Analytics Implementation

Follow the below steps for integrating Firebase Analytics to implement crashlytics into your application.

Add the below code snippet to your app gradle dependency.

dependencies {
// Firebase Analytics
implementation 'com.google.firebase:firebase-analytics:17.4.3'
}

Contact

If you have any technical questions or queries about this project, feel free to reach out to Autonom8.