account-sdk-android

This is the UI part of the Account SDK, which provides customizable UI flows. The responsibility of UI flows is to provide an authenticated user back to the client thanks to a prebuilt UI.

The currently available UI’s are:

Note: You should familiarize yourself with the Core SDK Readme which covers topics like persisting user sessions, logging out and debugging.

Configuration

The minimal configuration of the SDK UIs are: client name, redirect scheme and redirect host. The client name is displayed on the terms and conditions screen as “I accept the terms and conditions for Schibsted account and yourAppName”, while the two other fields are required for deep linking and can be found in SelfService.

You can find the redirect scheme and redirect host on self service with the following format MyschemeMyhost where Myscheme is everything before :. For example with spid-myclientid://login the scheme is spid-myclientid and the host is ://login

strings.xml

<string name="schacc_conf_client_name">My client name</string>
<string name="schacc_conf_redirect_scheme">spid-myclientid</string>
<string name="schacc_conf_redirect_host">://login</string>

Additional configuration parameters

You can further control the behavior of the UIs bu specifying any of the following attributes. These can be specified in your AndroidManifest.xml or by using AccountUi.Params.Builder(). Using only one of these is recommended, but if you were to use both, then the AccountUi parameters will take precedence over the manifest.

Android manifest

<application>
    <meta-data android:name="@string/schacc_conf_locale" android:value="en_EN" />
    <meta-data android:name="@string/schacc_conf_signup_enabled" android:value="false" />
    <meta-data android:name="@string/schacc_conf_signup_disabled_message" android:value="Some reason" />
    <meta-data android:name="@string/schacc_conf_cancellable" android:value="false" />
    <meta-data android:name="@string/schacc_conf_client_logo" android:resource="@drawable/client_logo" />
    <meta-data android:name="@string/schacc_conf_remember_me" android:value="true" />
</application>

AccountUi parameters

 new AccountUi.Params.Builder()
                               .teaserText(getString(R.string.example_teaser_text))
                               ...
                               .build());

Starting the UIs

The UIs can be started through the getCallingIntent function in the AccountUi class. This returns an intent, which you start for the result. The function takes parameters which changes the behavior.

final Intent intent = AccountUi.getCallingIntent(
    getApplicationContext(),
    AccountUi.FlowType.PASSWORD,
    new AccountUi.Params.Builder()
        .teaserText(getString(R.string.example_teaser_text))
        .preFilledIdentifier("user@example.com")
        .smartLockMode(SmartlockMode.DISABLED)
        .build());

startActivityForResult(intent, PASSWORD_REQUEST_CODE);

Get the authenticated user

To get the User back when the flow is successfully finished you have to

  1. Override onActivityResult(final int requestCode, final int resultCode, final Intent data).
  2. Check the result code, it is equal to Activity.RESULT_OK in case of success.
  3. Extract the User from the intent by calling data.getParcelableExtra(EXTRA_USER).

Get the case of failure

To get the case of failure when the flow did not success you have to:

  1. Override onActivityResult(final int requestCode, final int resultCode, final Intent data).
  2. Check the result code, it is equal to AccountUi.RESULT_ERROR in case of error.
  3. Extract the ClientError from the intent by calling data.getParcelableExtra(AccountUi.EXTRA_ERROR).

Tracking

The UIs support tracking for most events and interactions. To use this, you need to implement the UiTracking interface and pass the data off to your tracker of choice.

BaseLoginActivity.setTracker(myTracker);

Pulse tracking (Available internally in Schibsted only)

We provide a default implementation for tracking, using Pulse. This is available in the pulse module and its dependency can be added the following way after adding the internal repository.

implementation "com.schibsted.account:account-sdk-android-pulse:<SCHACC-PULSE-VERSION>"

Please note that the SCHACC-PULSE-VERSION could differ from SCHACC-VERSION because the pulse library doesn’t belong to the same repository and is not tied to the rest of the SDK. Check out the pulse changelog to find which version to use with the different SDK releases.

You can read more about Pulse at pulse.schibsted.io.

Advanced usage

Customize colors

The provided UI come with fully configurable colors. If you want to change these colors to match with your application you need to override the following values in your res/colors.xml file:

    <color name="schacc_primaryEnabled">myColor</color>
    <color name="schacc_primaryDisabled">myColor</color>
    <color name="schacc_primaryHovered">myColor</color>
    <color name="schacc_primaryActive">myColor</color>

    <color name="schacc_secondaryEnabled">myColor</color>
    <color name="schacc_secondaryDisabled">myColor</color>
    <color name="schacc_secondaryHovered">myColor</color>
    <color name="schacc_secondaryActive">myColor</color>

    <color name="schacc_backgroundColor">myColor</color>

Customize the toolbar

If needed the color of the toolbar’s elements can be customized. To apply you own color you need to override the following values in your res/colors.xml file:

Customize the loader color

Next to the CTA button a loader appears when an action is performed, you might need to change this color to match your branding. To apply you own color you need to override the following values in your res/colors.xml file:

    <color name="schacc_progressColor">myColor</color>

Hooking UI events

If you need to perform some additional operations before closing the UIs, you can implement UiHooks in your application class. These functions will be called before certain events and will not continue before the OnProceedListener’s proceed function has been called.

FAQ

How do I provide my own loading screen?
We will only show the loading indicator in the UIs if we need to retrieve client info. This can be pre-loaded if you want your own loading screen. To do so, use the AccountUi.preInitialize(...) function to perform the load. This will notify the callback when ready.