Starting On a Specific Page

Starting the Spend Manager UI on a specific page

By default, Spend Manager launches on “Dashboard” home page. The SDK has the ability to launch directly to a desired page instead.

Launch specific page:

The desired page of type NavigationIntent can be provided in a navigationIntent argument of the start function:

let options = SensibillUICoordinator.StartOptions.Builder()
              .add(navigationIntent: .achievements)
              .build()

sensibillUICoordinator.start(options: options)

Launch specific page requiring additional parameters:

Some views do not require any additional information. For other views, like receipt details, you must provide an ID of the item you would like to navigate to:

let options = SensibillUICoordinator.StartOptions.Builder()
              .add(navigationIntent: .receiptDetails(id: "receiptID"))
              .build()

sensibillUICoordinator.start(options: options)

Applicable in Objective-C only

The desired page of type SBLNavigationIntent can be provided in a navigationIntent argument of start function:

SensibillUICoordinatorStartOptionsBuilder *builder = [[SensibillUICoordinatorStartOptionsBuilder alloc] init];

SensibillUICoordinatorStartOptions *options = [builder addWithNavigationIntent:(enum SBLNavigationIntent)
                                                                     parameter:<#(id _Nullable)#>] build];

[sensibillUICoordinator startWithOptions: options];

Note: Provide value for parameter argument if page requires any specific item id or array of ids, otherwise specify nil.


Here’s the list of available views:

The general views

  • dashboard - the Spend Manager home page (default)
  • tips - the Spend Manager tips page
  • achievements - the Spend Manager achievements page

The views that display all the items in corresponding category:

  • receiptList
  • folderList
  • exportList

The following views that display an individual item, matching a provided id:

  • receiptDetails(id: String)
  • folderDetails(id: String)

The following views that display metadata edit page for provided list of localIds. The list of local IDs should be retrieved from the Transaction objects submitted for processing.

  • metadataEdit(localIds: [String])

In order to customize the initial page, an extra NavigationIntent argument must be provided to the WebUiFragment.

Depending on your integration method, the way that this argument is provided may change. Continue reading to determine the correct method for you.

Providing the NavigationIntent Argument

When Directly Using the WebUiFragment

When directly using the WebUiFragment, to change the inital screen a NavigationIntent must be passed as an argument with the key WebUiFragment.ARG_NAVIGATION_OVERRIDE when creating the fragment.

Kotlin

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    if (savedInstanceState == null) {
        val spendManagerFragment = WebUiFragment()
        spendManagerFragment.arguments = Bundle().apply {
            // Using the navigation intent for the Dashboard being the inital screen
            putParcelable(WebUiFragment.ARG_NAVIGATION_OVERRIDE, NavigationIntent.DASHBOARD)
        }

        supportFragmentManager.commit(true) {
            add(R.id.container, spendManagerFragment, TAG_WEB_FRAGMENT)
        }
    }
}

Java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState == null) {
        final WebUiFragment spendManagerFragment = new WebUiFragment();

        final Bundle args = new Bundle();
        // Using the navigation intent for the Dashboard being the inital screen
        final NavigationIntent navigationIntent = NavigationIntent.DASHBOARD.INSTANCE;
        args.putParcelable(WebUiFragment.ARG_NAVIGATION_OVERRIDE, navigationIntent);

        spendManagerFragment.setArguments(args);

        getSupportFragmentManager().beginTransaction()
                .add(R.id.container, spendManagerFragment, TAG_WEB_FRAGMENT)
                .commitAllowingStateLoss();
    }
}

When Launching the WebUiActivity

When launching the WebUiActivity, to change the inital screen a NavigationIntent must be passed as an intent extra with the key WebUiActivity.ARG_NAVIGATION_OVERRIDE when creating the intent to launch the activity.

Kotlin

val intent = Intent(this, WebUiActivity::class.java).apply {
    // Using the navigation intent for the Dashboard being the inital screen
    putExtra(WebUiActivity.ARG_NAVIGATION_OVERRIDE, NavigationIntent.DASHBOARD)
}
startActivity(intent)

Java

final Intent intent = new Intent(this, WebUiActivity.class);
// Using the navigation intent for the Dashboard being the inital screen
final NavigationIntent navigationIntent = NavigationIntent.DASHBOARD.INSTANCE;
intent.putExtra(WebUiActivity.ARG_NAVIGATION_OVERRIDE, navigationIntent);
startActivity(intent);

When Subclassing the WebUiActivity

When subclassing the WebUiActivity, to change the inital screen a NavigationIntent must be provided to the WebUiFragment managed by WebUiActivity via the WebUiActivity.createWebUiFragment method. This can be achieved by overriding the createWebUiFragment method.

The NavigationIntent could either be determined by your subclass of WebUiActiviy, or passed to your subclass of WebUiActiviy at your discretion.

Note: createWebUiFragment() is called within WebUiActivity.onCreate(). To ensure the value is available when required, please ensure that you can determine your intended NavigationIntent before calling super.onCreate()

Kotlin

override fun createWebUiFragment(): WebUiFragment = super.createWebUiFragment().apply {
    // Can add fragment arguments here, eg.
    arguments = (arguments ?: Bundle()).apply {
        // Using the navigation intent for the Dashboard being the inital screen
        putParcelable(WebUiFragment.ARG_NAVIGATION_OVERRIDE, NavigationIntent.DASHBOARD)
    }
}

Java

@NotNull
@Override
protected WebUiFragment createWebUiFragment() {
    final WebUiFragment spendManagerFragment = super.createWebUiFragment();
    Bundle args = spendManagerFragment.getArguments();
    if (args == null) {
        args = new Bundle();
    }

    // Using the navigation intent for the Dashboard being the inital screen
    final NavigationIntent navigationIntent = NavigationIntent.DASHBOARD.INSTANCE;
    args.putParcelable(WebUiFragment.ARG_NAVIGATION_OVERRIDE, navigationIntent);
    spendManagerFragment.setArguments(args);

    return spendManagerFragment;
}

Available Starting Pages

The available starting pages are listed below, along with any configuration options available for their usage.

General Views

  • NavigationIntent.DASHBOARD - The Spend Manager home page (default)
  • NavigationIntent.TIPS - The Spend Manager tips page
  • NavigationIntent.ACHIEVEMENTS - The Spend Manager achievements page

Views That Display Lists of User Data

  • NavigationIntent.RECEIPT_LIST
  • NavigationIntent.FOLDER_LIST
  • NavigationIntent.EXPORT_LIST

Views That Display A Single Item (Given an id)

  • NavigationIntent.ReceiptDetail(receiptId: String)
  • NavigationIntent.FolderDetail(folderId: String)

Documentation References

NavigationIntent
WebUiActivity
WebUiFragment