public static class

SosConfiguration.Builder

extends Object
java.lang.Object
   ↳ com.salesforce.android.sos.api.SosConfiguration.Builder

Class Overview

Builder for SosConfiguration instances. Exposes a fluent API for instantiating SosConfiguration instances.

Summary

Public Constructors
Builder()
Public Methods
SosConfiguration.Builder agentJoinSound(int agentJoinSoundResId)
Play a custom sound when the an SOS Session is fully connected.
SosConfiguration.Builder agentJoinSound(Uri agentJoinSoundUri)
Play a custom sound when the an SOS Session is fully connected.
SosConfiguration.Builder agentPublish(boolean publish)
Enables or disables publishing the agent in the Widget.
SosConfiguration.Builder agentViewDpScaled(boolean isScaled)
Enables or disables DP scaling for the agent view based on the following resource dimensions:
  • sos_agent_square_container_width
  • sos_agent_square_container_height
SosConfiguration.Builder audio(boolean allowed)
Allows or disallows audio during the SOS session.
SosConfiguration.Builder backFacingCamera(boolean enabled)
Enables or disables the back-facing camera.
SosConfiguration build()
Instantiates an SosConfiguration with the current state of the builder.
SosConfiguration.Builder cameraFps(int cameraFps)
Sets the number of frames captured from the camera per second when sharing the front or back facing camera.
SosConfiguration.Builder connectingUi(boolean enabled)
Sets whether or not the default SOS UI should appear during the connecting phase of the session.
SosConfiguration.Builder defaultAgentPosition(int position)
Set the default position of the agent container.
SosConfiguration.Builder defaultShareType(SosShareType source)
Sets the default share type to be used for SOS sessions.
SosConfiguration.Builder disableToasts(EnumSet<SosToast> toasts)
Disables all of the toasts in the given EnumSet.
SosConfiguration.Builder endSessionTimeout(int durationMs)
Set the length of time a disconnected session will wait for a reconnect before giving up.
SosConfiguration.Builder fieldServices(boolean enabled)
Enables or disables Field Services mode, which is a beta feature.
SosConfiguration.Builder frontFacingCamera(boolean enabled)
Enables or disables the front-facing camera.
SosConfiguration.Builder insertOnboardingCardLayout(Integer layoutId, Integer index)
Append a new card to display on the onboarding carousel by providing a Layout ID and the desired order for it to appear (index).
SosConfiguration.Builder keepScreenOn(boolean keepScreenOn)
Tells SOS whether or not the session should keep the screen on while it runs (while not backgrounded), This will set a FLAG_KEEP_SCREEN_ON on whichever activity SOS is running within.
SosConfiguration.Builder loggingEnabled(boolean enabled)
Enables or disables logging functionality.
SosConfiguration.Builder networkTestEnabled(boolean enabled)
Enables or disables the network test preceding the SOS session.
SosConfiguration.Builder onboardingCardLayouts(Integer... layoutIds)
Provide a list of Layout ID's that will be displayed as cards within the onboarding carousel.
SosConfiguration.Builder onboardingUi(boolean enabled)
Enable or disable the onboarding UI.
SosConfiguration.Builder permissionUi(boolean enabled)
Enable or disable the permissions UI.
SosConfiguration.Builder playSounds(boolean enabled)
Enable or disable the playback of sound effects during the SOS session.
SosConfiguration.Builder screenCaptureFps(int screenCaptureFps)
Sets the number of frames to capture per second when sharing the screen with the agent.
SosConfiguration.Builder sessionRetryTime(long sessionRetryTime)
The length of time before SOS will prompt the user to retry or cancel.
SosConfiguration.Builder twoWayVideo(boolean enabled)
Enables or disables the Two-way Video feature.
SosConfiguration.Builder typefaceFromAsset(String assetTtf)
Sets a custom typefaceFromAsset that will be used wherever SOS writes text.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Builder ()

Public Methods

public SosConfiguration.Builder agentJoinSound (int agentJoinSoundResId)

Play a custom sound when the an SOS Session is fully connected. If the agent sound has been declared using both a Resource ID and a URI, the Resource ID will be used.

Parameters
agentJoinSoundResId Resource ID of the sound file.
Returns
  • The builder instance for fluent API calls.

public SosConfiguration.Builder agentJoinSound (Uri agentJoinSoundUri)

Play a custom sound when the an SOS Session is fully connected.

Parameters
agentJoinSoundUri The URI of the sound file.
Returns
  • The builder instance for fluent API calls.

public SosConfiguration.Builder agentPublish (boolean publish)

Enables or disables publishing the agent in the Widget. If disabled, there is no creation, configuration, or use of the OpenTok agent. This is done primarily for testing as the automated suites we use have no audio or video capabilities.

Parameters
publish Set to false to disable the OpenTok agent. Defaults to true.
Returns
  • The Builder instance for fluent API calls.

public SosConfiguration.Builder agentViewDpScaled (boolean isScaled)

Enables or disables DP scaling for the agent view based on the following resource dimensions:

  • sos_agent_square_container_width
  • sos_agent_square_container_height

Parameters
isScaled Set to false to disable DP scaling and use a hard-coded size
Returns
  • The Builder instance for fluent API calls.

public SosConfiguration.Builder audio (boolean allowed)

Allows or disallows audio during the SOS session. If disabled, no audio will be played during the session, and the Mute/Unmute buttons will have no effect. Audio connections require the video provider to be enabled, so this flag will be ignored if the video provider is disabled.

One use for this setting is to disable audio during local demonstrations in order to avoid audio feedback.

Parameters
allowed Set to false to disable all audio. Defaults to true.
Returns
  • The Builder instance for fluent API calls.

public SosConfiguration.Builder backFacingCamera (boolean enabled)

Enables or disables the back-facing camera. Only applicable when Two-way Video mode is enabled.

NOTE
You must declare <uses-permission android:name="android.permission.CAMERA"/> in your AndroidManifest.xml in order to use this feature. The SDK will fail silently if not included.

Parameters
enabled True if the back-facing camera should be enabled. Default is true;
Returns
  • The builder instance for fluent API calls.

public SosConfiguration build ()

Instantiates an SosConfiguration with the current state of the builder.

Returns
  • A new SosConfiguration instance matching the state of the builder.

public SosConfiguration.Builder cameraFps (int cameraFps)

Sets the number of frames captured from the camera per second when sharing the front or back facing camera. A higher value results in a smoother video feed to the agent, at a cost of increased bandwidth usage for the user. The value must be [1, 60].

Parameters
cameraFps The number of frames to capture per second.
Returns
  • The builder instance for fluent API calls.
Throws
IllegalArgumentException if the supplied value is not in the range of [1, 60].

public SosConfiguration.Builder connectingUi (boolean enabled)

Sets whether or not the default SOS UI should appear during the connecting phase of the session. If set to false, the UI will not appear when a session has been started until the agent has accepted the session and the AV streams are fully connected, e.g. when the SosState changes to Connected.

If this value is set to false, it is the consuming application's responsibility to show an appropriate UI to the user during the connecting phase. You may choose to leverage the SosListener and optionally the SosNetworkTestListener APIs to have your application present contextual information to the user regarding the state of their session.

Note that this value does not affect the onboarding or permissions pre-session flows, which can be disabled separately with the onboardingUi(boolean) and permissionUi(boolean) methods, respectively.

Parameters
enabled True if the UI should appear at the start of the session, false if it should only appear once connected. Default is true.
Returns
  • The builder instance for fluent API calls.

public SosConfiguration.Builder defaultAgentPosition (int position)

Set the default position of the agent container. This will be used to place the agent container when the session first starts, as well as when the device orientation changes.

Parameters
position An IntDef representing where the container should be placed.
Returns
  • The builder instance for fluent API calls.

public SosConfiguration.Builder defaultShareType (SosShareType source)

Sets the default share type to be used for SOS sessions. The default is Screen Sharing.

NOTE
For compatibility with devices running API 22 and earlier you must declare <uses-permission android:name="android.permission.CAMERA"/> in your AndroidManifest.xml in order to use Front or Back-facing Camera. The SDK will fail silently if not included.

Parameters
source Default share type for the session
Returns
  • The builder instance for fluent API calls.
See Also

public SosConfiguration.Builder disableToasts (EnumSet<SosToast> toasts)

Disables all of the toasts in the given EnumSet. Disabled toasts are not shown by the SOS SDK. Note that this method is not additive; multiple invocations will overwrite prior values.

Parameters
toasts The toasts to disable.
Returns
  • The builder instance for fluent API calls.

public SosConfiguration.Builder endSessionTimeout (int durationMs)

Set the length of time a disconnected session will wait for a reconnect before giving up.

Parameters
durationMs The length of time to wait in ms.
Returns
  • The builder instance for fluent API calls.

public SosConfiguration.Builder fieldServices (boolean enabled)

Enables or disables Field Services mode, which is a beta feature. Every SOS session will operate as a Camera-only session. The device's screen will not be captured and shared with the Agent. Enabling this feature implies twoWayVideo(boolean) is enabled.

Parameters
enabled True if Field Services mode should be enabled. Default is false.
Returns
  • The builder instance for fluent API calls.

public SosConfiguration.Builder frontFacingCamera (boolean enabled)

Enables or disables the front-facing camera. Only applicable when Two-way Video mode is enabled.

NOTE
You must declare <uses-permission android:name="android.permission.CAMERA"/> in your AndroidManifest.xml in order to use this feature. The SDK will fail silently if not included.

Parameters
enabled True if the front-facing camera should be enabled. Default is true;
Returns
  • The builder instance for fluent API calls.

public SosConfiguration.Builder insertOnboardingCardLayout (Integer layoutId, Integer index)

Append a new card to display on the onboarding carousel by providing a Layout ID and the desired order for it to appear (index). Please see MAX_ONBOARDING_CARDS for the maximum number of cards permitted.

Parameters
layoutId Layout ID for a new card to display on the onboarding carousel.
index The order by which the new card will be displayed on the onboarding carousel.
Returns
  • The builder instance for fluent API calls.

public SosConfiguration.Builder keepScreenOn (boolean keepScreenOn)

Tells SOS whether or not the session should keep the screen on while it runs (while not backgrounded), This will set a FLAG_KEEP_SCREEN_ON on whichever activity SOS is running within.

Once SOS stops or it leaves the activity, that flag will be cleared.

Notes

The flag will only be added once the session is actually running. This means the screen can still go inactive and turn off during the initial user confirmation portion of the session.

Also, the flag will only affect the app when it is in the foreground. This means that if the user clicks the home button or switches to another app, the phone may fall asleep once again.

If this is insufficient for your use case, you may wish to look at using a android.os.PowerManager.WakeLock.

Parameters
keepScreenOn whether or not to keep the screen on while the session runs
Returns
  • The builder instance for fluent API calls.

public SosConfiguration.Builder loggingEnabled (boolean enabled)

Enables or disables logging functionality.

Parameters
enabled True if logging should be enabled. Default is true.
Returns
  • The builder instance for fluent API calls.

public SosConfiguration.Builder networkTestEnabled (boolean enabled)

Enables or disables the network test preceding the SOS session.

Parameters
enabled True if the network test should be enabled. Default is true.
Returns
  • The builder instance for fluent API calls.

public SosConfiguration.Builder onboardingCardLayouts (Integer... layoutIds)

Provide a list of Layout ID's that will be displayed as cards within the onboarding carousel. This will replace all of the existing default cards. They will be displayed on the carousel in the order that they are provided. Please see MAX_ONBOARDING_CARDS for the maximum number of cards permitted.

Parameters
layoutIds A list of Layout ID's to use as onboarding cards that will replace the default cards.
Returns
  • The builder instance for fluent API calls.

public SosConfiguration.Builder onboardingUi (boolean enabled)

Enable or disable the onboarding UI. If disabled, the onboarding UI will be skipped entirely.

Parameters
enabled False to disable the UI. Default is true.
Returns
  • The builder instance for fluent API calls.

public SosConfiguration.Builder permissionUi (boolean enabled)

Enable or disable the permissions UI. If disabled, the application is responsible for ensuring it has been granted all permissions needed for the SOS session to run.

Parameters
enabled False to disable the UI. Default is true.
Returns
  • The builder instance for fluent API calls.

public SosConfiguration.Builder playSounds (boolean enabled)

Enable or disable the playback of sound effects during the SOS session.

Parameters
enabled True if sounds should be played. Default is true.
Returns
  • The builder instance for fluent API calls.

public SosConfiguration.Builder screenCaptureFps (int screenCaptureFps)

Sets the number of frames to capture per second when sharing the screen with the agent. A higher value results in a smoother video feed to the agent, but will consume more of the user's bandwidth. There is also a CPU cost to capturing the screen, so a higher value may impact the display framerate of the app. The value must be [1, 60].

Parameters
screenCaptureFps The number of frames to capture per second.
Returns
  • The builder instance for fluent API calls.
Throws
IllegalArgumentException if the supplied value is not in the range of [1, 60].

public SosConfiguration.Builder sessionRetryTime (long sessionRetryTime)

The length of time before SOS will prompt the user to retry or cancel. This value is used whenever no agents pick up the customers call from their queue's.

Default: 30000 (30 seconds)


Note: This value is triggered after the call is received and acknowledged on the back-end. As a result, the time taken will measure slightly longer than the give value from the point after the user confirms they want to start a session.

Parameters
sessionRetryTime The length of time to wait before prompting (in ms)
Returns
  • The builder instance for fluent API calls.

public SosConfiguration.Builder twoWayVideo (boolean enabled)

Enables or disables the Two-way Video feature.

NOTE
You must declare <uses-permission android:name="android.permission.CAMERA"/> in your AndroidManifest.xml in order to use this feature. The SDK will fail silently if not included.

Parameters
enabled True if Two-way Video should be turned on. Default is false.
Returns
  • The builder instance for fluent API calls.

public SosConfiguration.Builder typefaceFromAsset (String assetTtf)

Sets a custom typefaceFromAsset that will be used wherever SOS writes text.

Parameters
assetTtf The string path to typeface asset.
Returns
  • The builder instance for fluent API calls.