View on GitHub

sensibill-android-documentation

Sample Sensibill Integration

Last updated for v1.15.1
CompileSdkVersion => 27
BuildToolsVersion => 27.0.3
TargetSdkVersion => 26
MinSdkVersion => 18
supportLibraryVersion => 27.1.1
GooglePlayServices => 11.8.0

This project is an application demonstrating how to integrate with the Sensibill Android SDK. Sample initialization of SDK is done in the SensibillManager class. Launching of Sensibill Functionality is done in the SensibillActionsActivity.

Environment Setup

Install Gradle

Installing Demo Repo via GitHub Desktop

Installing Demo Repo via Git command line


Integration Steps

Import SDK into the project ###- Add sensibill SDK maven repository to top level build.gradle

allprojects{
    repositories {
        maven {
            // Sensibill SDK repository
            url 'https://maven.getsensibill.com'
                credentials {
                    username 'to be provided by sensibill'
                    password 'to be provided by sensibill'
                }
        }
    }
}
dependencies {
    compile "com.getsensibill:sensibill-auth:X.X.X"
    compile "com.getsensibill:sensibill-sdk-all:X.X.X"
    // Optional - For Transaction matching
    compile "com.getsensibill:sensibill-transaction-matcher:X.X.X"
    //Please ask for latest value of X.X.X from Sensibill
}

Pre SDK Initialization

IMPORTANT: Make sure that client credentials provided are for the chosen DefaultEnvironment

SDK Initialization

Initialization Extension: SDK Lifecycle Listener
Initialization Extension: Token Provider
Initialization Extension: Event Listener
InitializationBuilder builder = new InitializationBuilder(getApplicationContext(), DefaultEnvironment.BETA_SANDBOX)
    .builder.onTrackEventListener(new OnTrackEventListener {
        @Override
        public void trackEvent(AnalyticsEvent eventName, Map<String, Object> attributes, Map<String, Object> superAttributes) {
            // Track Event
        }

        @Override
        public void onDestroy() {
            // Handle Tracker Destruction
        }
    });

Initialization Extension: SDK Customization

Build and Initialize

SensibillSDK.getInstance().initialize(builder.build());
Adding Transaction Observer

Example: Initialization example can be found in [SensibillManager.java]

Signing in User

Access Token Sign in
SensibillSDK.getInstance().login(getApplicationContext(), access_token, username, new SDKStartup() {
    @Override
    public void onSDKStarted() {
        // SDK Logged in
    }

    @Override
    public void onSDKFailed(LoginError sdkLoginError, String message) {
        // SDK failed to login
    }
});
Username - Password
auth.signIn(username, password, new SensibillAuth.SessionListener() {
@Override
      public void onFailure(@NotNull SensibillAuth.AuthError error) {
        // Authorization Error
      }

      @Override
      public void onSuccess(@NotNull final OauthUser user) {
        // Sign in Successful
      }
}

Example: Login example can be found in [SensibillManager.java]


Using Sensibill SDK Activities

Launching Capture Activity

Launching Receipt Detail Activity

Using SDK Fragment

There are couple of fragments that you can embed in your app’s activities for seamless integration between SDK and your app.

All these fragments can also be embedded directly in the layout file (except SBMainTabsFragment).


> **IMPORTANT** Make sure that Theme.Sensibill or a style extending Theme.Sensibill is applied to any activity hosting a Sensibill Fragment in the Android Manifest

***

### Customize Sensibill Colours
To style SDK with brand colors, extend the Sensibill external theme **Theme.Sensibill**:
<style name="Theme.Sensibill" parent="Base.Theme.Sensibill">
    ...
</style> ```

The SDK has 16 colours which can be overridden in the Theme.Sensibill style. All elements in the SDK map to one of the 16 colours. For further details on the sensibill branding strategy, please refer to the provided style guide. The following is an example of a full re-branding of the Sensibill SDK:

    <style name="Theme.Sensibill" parent="Base.Theme.Sensibill">
        <item name="sb__brandBackground">@color/myBank_brandBackground</item>
        <item name="sb__brandForeground">@color/white</item>
        <item name="sb__brandForegroundDisabled">@color/myBank_brandBackground</item>
        <item name="sb__actionBackground">@color/myBank_actionBackground</item>
        <item name="sb__actionForeground">@color/white</item>
        <item name="sb__accentBackground">@color/myBank_accentBackground</item>
        <item name="sb__accentForeground">@color/black</item>
        <item name="sb__alternateBackground">@color/myBank_alternateBackground</item>
        <item name="sb__alternateForeground">@color/white</item>
        <item name="sb__errorBackground">@color/myBank_errorBackground</item>
        <item name="sb__errorForeground">@color/white</item>
        <item name="sb__disabledBackground">@color/myBank_disabledBackground</item>
        <item name="sb__disabledForeground">@color/white</item>
        <item name="sb__primaryBackground">@color/myBank_primaryBackground</item>
        <item name="sb__offPrimaryBackground">@color/white</item>
        <item name="sb__primaryForeground">@color/black</item>
        <item name="sb__primaryForegroundTwo">@color/myBank_primaryForegroundTwo</item>
        <item name="sb__primaryForegroundThree">@color/myBank_primaryForegroundThree</item>
        <item name="sb__primaryForegroundFour">@color/myBank_primaryForegroundFour</item>
    </style>

To brand the SDK for android versions less than 23, override the following colors to get the same effect:

    <color name="sb__brand_background">@color/myBank_brandBackground</color>
    <color name="sb__action_background">@color/myBank_actionBackground</color>
    <color name="sb__accent_background">@color/myBank_accentBackground</color>
    <color name="sb__accent_foreground">@color/black</color>
    <color name="sb__alternate_foreground">@color/myBank_alternateBackground</color>
    <color name="sb__error_background">@color/myBank_errorBackground</color>
    <color name="sb__disabled_background">@color/myBank_disabledBackground</color>
    <color name="sb__primary_background">@color/myBank_primaryBackground</color>
    <color name="sb__primary_off_background">@color/white</color>
    <color name="sb__primary_foreground">@color/black</color>
    <color name="sb__primary_foreground_two">@color/myBank_primaryForegroundTwo</color>
    <color name="sb__primary_foreground_three">@color/myBank_primaryForegroundThree</color>
    <color name="sb__primary_foreground_four">@color/myBank_primaryForegroundFour</color>
    ...

Customize Sensibill Font

To customize font of the SDK, create a resource folder called assets with subfolder fonts.

Asset Folder

Add a bold, italic and regular version of desired font to the fonts folder. Create three string resources of the path to each font, starting from the assets folder, for example:

    <string name="brand_font_regular">fonts/RNHouseSans-Regular.ttf</string>
    <string name="brand_font_bold">fonts/RNHouseSans-Bold.ttf</string>
    <string name="brand_font_italic">fonts/RNHouseSans-Italic.ttf</string>

Override the sb__font_regular, sb__font_italic, sb__font_bold properties of Theme.Sensibill with your string resources pointing to your desired fonts. For example:

    <style name="Theme.Sensibill" parent="Base.Theme.Sensibill">
        ...
        <item name="sb__font_regular">@string/brand_font_regular</item>
        <item name="sb__font_italic">@string/brand_font_italic</item>
        <item name="sb__font_bold">@string/brand_font_bold</item>
        ...
    </style>