public class PrefHelper
extends java.lang.Object
A class that uses the helper pattern to provide regularly referenced static values and logging capabilities used in various other parts of the SDK, and that are related to globally set preference values.
| Modifier and Type | Class and Description |
|---|---|
static class |
PrefHelper.DebugNetworkCallback
Debug connection callback that implements
NetworkCallback to react to server calls
to debug API end-points. |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
NO_STRING_VALUE
A
String value used where no string value is available. |
| Constructor and Description |
|---|
PrefHelper()
Empty, but required constructor for the
PrefHelper SharedPreferences
helper class. |
| Modifier and Type | Method and Description |
|---|---|
void |
clearIsReferrable()
Sets the
KEY_IS_REFERRABLE value in preferences to 0, or false if parsed as a Boolean. |
void |
clearSystemReadStatus()
Resets the time that the system was last read.
|
void |
clearUserValues()
Resets the user-related values that have been stored in preferences.
|
static void |
Debug(java.lang.String tag,
java.lang.String message)
Creates a Debug message in the debugger.
|
void |
disableExternAppListing()
Sets the
Boolean value that is checked prior to the listing of external apps to
false. |
void |
disableSmartSession()
|
int |
getActionTotalCount(java.lang.String action)
Gets the count of total number of times that the specified action has been carried
out during the current session, as defined in preferences.
|
int |
getActionUniqueCount(java.lang.String action)
Gets the count of the unique number of times that the specified action has been carried
out during the current session, as defined in preferences.
|
java.lang.String |
getAPIBaseUrl()
Returns the base URL to use for all calls to the Branch API as a
String. |
java.lang.String |
getAppKey()
Gets the Branch App Key in preferences programmatically.
|
java.lang.String |
getAppLink()
Get the App link which statrted the application.
|
java.lang.String |
getAppVersion()
Returns the current value of
KEY_APP_VERSION as stored in preferences. |
boolean |
getBool(java.lang.String key)
A basic method that returns a
Boolean value from a specified preferences Key. |
java.lang.String |
getBranchKey() |
int |
getBranchViewUsageCount(java.lang.String branchViewId) |
int |
getCreditCount()
Get the current cached credit count for the default bucket, as currently stored in
preferences for the current app.
|
int |
getCreditCount(java.lang.String bucket)
Get the current cached credit count for the default bucket, as currently stored in
preferences for the current app.
|
java.lang.String |
getDeviceFingerPrintID()
Gets the
Build.FINGERPRINT value of the current OS build, on the current device,
as a String from preferences. |
java.lang.String |
getExternalIntentExtra()
Gets the
KEY_EXTERNAL_INTENT_EXTRA String value that has been set via the Branch API. |
java.lang.String |
getExternalIntentUri()
Gets the
KEY_EXTERNAL_INTENT_URI String value that has been set via the Branch API. |
boolean |
getExternAppListing()
Sets the
Boolean value that is checked prior to the listing of external apps. |
boolean |
getExternDebug()
Gets the value of the debug status
Boolean value. |
float |
getFloat(java.lang.String key)
A basic method that returns a
Float value from a specified preferences Key. |
java.lang.String |
getIdentity()
Gets the
KEY_IDENTITY String value that has been set via the Branch API. |
java.lang.String |
getIdentityID()
Gets the
KEY_IDENTITY_ID String value that has been set via the Branch API. |
java.lang.String |
getInstallParams()
Gets the session parameters as originally set at time of app installation, in preferences.
|
static PrefHelper |
getInstance(android.content.Context context)
Singleton method to return the pre-initialised, or newly initialise and return, a singleton
object of the type
PrefHelper. |
int |
getInteger(java.lang.String key)
A basic method that returns an integer value from a specified preferences Key.
|
int |
getInteger(java.lang.String key,
int defaultValue)
A basic method that returns an
Integer value from a specified preferences Key, with a
default value supplied in case the value is null. |
int |
getIsReferrable()
Gets the
Integer value of the preference setting KEY_IS_REFERRABLE, which
indicates whether or not the current session should be considered referrable. |
java.lang.String |
getLinkClickID()
Gets the
KEY_LINK_CLICK_ID String value that has been set via the Branch API. |
java.lang.String |
getLinkClickIdentifier()
Gets the KEY_LINK_CLICK_IDENTIFIER
String value that has been set via the Branch API. |
long |
getLong(java.lang.String key)
A basic method that returns a
Long value from a specified preferences Key. |
java.lang.String |
getPushIdentifier()
Get the branch url in push payload which started the application.
|
int |
getRetryCount()
Gets the current count of the number of times that a Branch API call has been re-attempted.
|
int |
getRetryInterval()
Gets the amount of time in milliseconds to wait before re-attempting a timed-out request
to the Branch API.
|
java.lang.String |
getSessionID()
Gets the ID of the
KEY_SESSION_ID String value from preferences. |
java.lang.String |
getSessionParams()
Gets the session parameters as currently set in preferences.
|
boolean |
getSmartSession()
Gets the state of the
Boolean value indicating whether or not the Smart Session
feature is enabled or not. |
java.lang.String |
getString(java.lang.String key)
A basic method that returns a
String value from a specified preferences Key. |
int |
getTimeout()
Returns the currently set timeout value for calls to the Branch API.
|
java.lang.String |
getUserURL()
Sets the user URL from preferences.
|
boolean |
isDebug()
Gets the
Boolean value of BNC_Dev_Debug, which indicates whether or not
debugging is enabled. |
void |
log(java.lang.String tag,
java.lang.String message)
Creates a Log message in the debugger.
|
java.lang.String |
readBranchKey(boolean isLive) |
void |
setActionTotalCount(java.lang.String action,
int count)
Sets the count of total number of times that the specified action has been carried out
during the current session, as defined in preferences.
|
void |
setActionUniqueCount(java.lang.String action,
int count)
Sets the count of the unique number of times that the specified action has been carried
out during the current session, as defined in preferences.
|
void |
setAppKey(java.lang.String key)
Sets the Branch App Key in preferences programmatically.
|
void |
setAppLink(java.lang.String appLinkUrl)
Set the KEY_APP_LINK
String values that has been started the application. |
void |
setAppVersion(java.lang.String version)
Sets the value of
KEY_APP_VERSION in preferences. |
void |
setBool(java.lang.String key,
java.lang.Boolean value)
Sets the value of the
String key value supplied in preferences. |
boolean |
setBranchKey(java.lang.String key)
Set the given Branch Key to preference.
|
void |
setCreditCount(int count)
Sets the credit count for the default bucket to the specified
Integer, in preferences. |
void |
setCreditCount(java.lang.String bucket,
int count)
Sets the credit count for the default bucket to the specified
Integer, in preferences. |
void |
setDeviceFingerPrintID(java.lang.String device_fingerprint_id)
Sets the
Build.FINGERPRINT value of the current OS build, on the current device,
as a String in preferences. |
void |
setExternalIntentExtra(java.lang.String extras)
Sets the
KEY_EXTERNAL_INTENT_EXTRA with value with given intent extras in string format. |
void |
setExternalIntentUri(java.lang.String uri)
Sets the
KEY_EXTERNAL_INTENT_URI with value with given intent URI String. |
void |
setExternDebug()
Switches external debugging on.
|
void |
setFloat(java.lang.String key,
float value)
Sets the value of the
String key value supplied in preferences. |
void |
setIdentity(java.lang.String identity)
Sets the
KEY_IDENTITY String value that has been set via the Branch API. |
void |
setIdentityID(java.lang.String identity_id)
Sets the
KEY_IDENTITY_ID String value that has been set via the Branch API. |
void |
setInstallParams(java.lang.String params)
Sets the session parameters as originally set at time of app installation, in preferences.
|
void |
setInteger(java.lang.String key,
int value)
Sets the value of the
String key value supplied in preferences. |
void |
setIsReferrable()
Sets the
KEY_IS_REFERRABLE value in preferences to 1, or true if parsed as a Boolean. |
void |
setLinkClickID(java.lang.String link_click_id)
Sets the
KEY_LINK_CLICK_ID String value that has been set via the Branch API. |
void |
setLinkClickIdentifier(java.lang.String identifier)
Sets the KEY_LINK_CLICK_IDENTIFIER
String value that has been set via the Branch API. |
void |
setLong(java.lang.String key,
long value)
Sets the value of the
String key value supplied in preferences. |
void |
setPushIdentifier(java.lang.String pushIdentifier)
Set the KEY_PUSH_IDENTIFIER
String values that has been started the application. |
void |
setRetryCount(int retry)
Sets the value specifying the number of times that a Branch API call has been re-attempted.
|
void |
setRetryInterval(int retryInt)
Sets the amount of time in milliseconds to wait before re-attempting a timed-out request
to the Branch API.
|
void |
setSessionID(java.lang.String session_id)
Sets the ID of the
KEY_SESSION_ID String value in preferences. |
void |
setSessionParams(java.lang.String params)
Sets the session parameters as currently set in preferences.
|
void |
setString(java.lang.String key,
java.lang.String value)
Sets the value of the
String key value supplied in preferences. |
void |
setTimeout(int timeout)
Sets the duration in milliseconds to override the timeout value for calls to the Branch API.
|
void |
setUserURL(java.lang.String user_url)
Sets the user URL from preferences.
|
void |
updateBranchViewUsageCount(java.lang.String branchViewId) |
public static final java.lang.String NO_STRING_VALUE
String value used where no string value is available.public PrefHelper()
Empty, but required constructor for the PrefHelper SharedPreferences
helper class.
public static PrefHelper getInstance(android.content.Context context)
Singleton method to return the pre-initialised, or newly initialise and return, a singleton
object of the type PrefHelper.
context - The Context within which the object should be instantiated; this
parameter is passed to the private PrefHelper(Context)
constructor method.PrefHelper object instance.public java.lang.String getAPIBaseUrl()
Returns the base URL to use for all calls to the Branch API as a String.
String variable containing the hard-coded base URL that the Branch
API uses.public void setTimeout(int timeout)
Sets the duration in milliseconds to override the timeout value for calls to the Branch API.
timeout - The Integer value of the timeout setting in milliseconds.public int getTimeout()
Returns the currently set timeout value for calls to the Branch API. This will be the default SDK setting unless it has been overridden manually between Branch object instantiation and this call.
Integer value containing the currently set timeout value in
milliseconds.public void setRetryCount(int retry)
Sets the value specifying the number of times that a Branch API call has been re-attempted.
This overrides the default retry value.
retry - An Integer value specifying the value to be specified in preferences
that determines the number of times that a Branch API call has been re-
attempted.public int getRetryCount()
Gets the current count of the number of times that a Branch API call has been re-attempted.
Integer value containing the current count of the number of times
that a Branch API call has been attempted.public void setRetryInterval(int retryInt)
Sets the amount of time in milliseconds to wait before re-attempting a timed-out request to the Branch API.
retryInt - An Integer value specifying the number of milliseconds to wait
before re-attempting a timed-out request.public int getRetryInterval()
Gets the amount of time in milliseconds to wait before re-attempting a timed-out request to the Branch API.
Integer value containing the currently set retry interval in
milliseconds.public void setAppVersion(java.lang.String version)
Sets the value of KEY_APP_VERSION in preferences.
version - A String value containing the current app version.public java.lang.String getAppVersion()
Returns the current value of KEY_APP_VERSION as stored in preferences.
String value containing the current app version.public void setAppKey(java.lang.String key)
Sets the Branch App Key in preferences programmatically.
Note: This is a deprecated method, you should configure your App Key as an XML String value instead.
key - A String value containing the App Key for the current App.public java.lang.String getAppKey()
Gets the Branch App Key in preferences programmatically.
String value containing the current App Key as configured.public boolean setBranchKey(java.lang.String key)
key - A String representing Branch Key.Boolean which is true if the key set is a new key. On Setting a new key need to clear all preference items.public java.lang.String getBranchKey()
public java.lang.String readBranchKey(boolean isLive)
public void setDeviceFingerPrintID(java.lang.String device_fingerprint_id)
Sets the Build.FINGERPRINT value of the current OS build, on the current device,
as a String in preferences.
device_fingerprint_id - A String that uniquely identifies this build.public java.lang.String getDeviceFingerPrintID()
Gets the Build.FINGERPRINT value of the current OS build, on the current device,
as a String from preferences.
String that uniquely identifies this build.public void setSessionID(java.lang.String session_id)
Sets the ID of the KEY_SESSION_ID String value in preferences.
session_id - A String value containing the session ID as returned by the
Branch API upon successful initialisation.public java.lang.String getSessionID()
Gets the ID of the KEY_SESSION_ID String value from preferences.
String value containing the session ID as returned by the Branch
API upon successful initialisation.public void setIdentityID(java.lang.String identity_id)
Sets the KEY_IDENTITY_ID String value that has been set via the Branch API.
This is used to identify a specific user ID and link that to a current session. Useful both for analytics and debugging purposes.
Note: Not to be confused with setIdentity(String) - the name of the user
identity_id - A String value containing the currently configured identity
within preferences.public java.lang.String getIdentityID()
Gets the KEY_IDENTITY_ID String value that has been set via the Branch API.
String value containing the currently configured user id within
preferences.public void setIdentity(java.lang.String identity)
Sets the KEY_IDENTITY String value that has been set via the Branch API.
This is used to identify a specific user identity and link that to a current session. Useful both for analytics and debugging purposes.
Note: Not to be confused with setIdentityID(String) - the UID reference of the user
identity - A String value containing the currently configured identity
within preferences.public java.lang.String getIdentity()
Gets the KEY_IDENTITY String value that has been set via the Branch API.
This is used to identify a specific user identity and link that to a current session. Useful both for analytics and debugging purposes.
String value containing the username assigned to the currentuser ID.public void setLinkClickID(java.lang.String link_click_id)
Sets the KEY_LINK_CLICK_ID String value that has been set via the Branch API.
link_click_id - A String value containing the identifier of the
associated link.public java.lang.String getLinkClickID()
Gets the KEY_LINK_CLICK_ID String value that has been set via the Branch API.
String value containing the identifier of the associated link.public void setExternalIntentUri(java.lang.String uri)
Sets the KEY_EXTERNAL_INTENT_URI with value with given intent URI String.
uri - A String value containing intent URI to setpublic java.lang.String getExternalIntentUri()
Gets the KEY_EXTERNAL_INTENT_URI String value that has been set via the Branch API.
String value containing external URI set.public void setExternalIntentExtra(java.lang.String extras)
Sets the KEY_EXTERNAL_INTENT_EXTRA with value with given intent extras in string format.
extras - A String value containing intent URI extra to setpublic java.lang.String getExternalIntentExtra()
Gets the KEY_EXTERNAL_INTENT_EXTRA String value that has been set via the Branch API.
String value containing external intent extra set.public void setLinkClickIdentifier(java.lang.String identifier)
Sets the KEY_LINK_CLICK_IDENTIFIER String value that has been set via the Branch API.
identifier - A String value containing the identifier of the associated
link.public java.lang.String getLinkClickIdentifier()
Gets the KEY_LINK_CLICK_IDENTIFIER String value that has been set via the Branch API.
String value containing the identifier of the associated link.public void setAppLink(java.lang.String appLinkUrl)
Set the KEY_APP_LINK String values that has been started the application.
appLinkUrl - The App link which started this applicationpublic java.lang.String getAppLink()
Get the App link which statrted the application.
String value of App linnk urlpublic void setPushIdentifier(java.lang.String pushIdentifier)
Set the KEY_PUSH_IDENTIFIER String values that has been started the application.
pushIdentifier - The Branch url with the push notification which started the app.public java.lang.String getPushIdentifier()
Get the branch url in push payload which started the application.
String value of push identifierpublic java.lang.String getSessionParams()
Gets the session parameters as currently set in preferences.
Parameters are stored in JSON format, and must be parsed prior to access.
String value containing the JSON-encoded structure of parameters for
the current session.public void setSessionParams(java.lang.String params)
Sets the session parameters as currently set in preferences.
params - A String value containing the JSON-encoded structure of
parameters for the current session.public java.lang.String getInstallParams()
Gets the session parameters as originally set at time of app installation, in preferences.
String value containing the JSON-encoded structure of parameters as
they were at the time of installation.public void setInstallParams(java.lang.String params)
Sets the session parameters as originally set at time of app installation, in preferences.
params - A String value containing the JSON-encoded structure of
parameters as they should be at the time of installation.public void setUserURL(java.lang.String user_url)
Sets the user URL from preferences.
user_url - A String value containing the current user URL.public java.lang.String getUserURL()
Sets the user URL from preferences.
String value containing the current user URL.public int getIsReferrable()
Gets the Integer value of the preference setting KEY_IS_REFERRABLE, which
indicates whether or not the current session should be considered referrable.
Integer value indicating whether or not the session should be
considered referrable.public void setIsReferrable()
Sets the KEY_IS_REFERRABLE value in preferences to 1, or true if parsed as a Boolean.
This value is used by the Branch object.
KEY_IS_REFERRABLE to 1 - true - This session is referrable.public void clearIsReferrable()
Sets the KEY_IS_REFERRABLE value in preferences to 0, or false if parsed as a Boolean.
This value is used by the Branch object.
KEY_IS_REFERRABLE to 0 - false - This session is not referrable.public void clearSystemReadStatus()
Resets the time that the system was last read. This is used to calculate how "stale" the values are that are in use in preferences.
public void clearUserValues()
Resets the user-related values that have been stored in preferences. This will cause a sync to occur whenever a method reads any of the values and finds the value to be 0 or unset.
public void setCreditCount(int count)
Sets the credit count for the default bucket to the specified Integer, in preferences.
Note: This does not set the actual value of the bucket itself on the Branch server,
but only the cached value as stored in preferences for the current app. The age of that value
should be checked before being considered accurate; read KEY_LAST_READ_SYSTEM to see
when the last system sync occurred.
count - A Integer value that the default bucket credit count will be set to.public void setCreditCount(java.lang.String bucket,
int count)
Sets the credit count for the default bucket to the specified Integer, in preferences.
Note: This does not set the actual value of the bucket itself on the Branch server,
but only the cached value as stored in preferences for the current app. The age of that value
should be checked before being considered accurate; read KEY_LAST_READ_SYSTEM to see
when the last system sync occurred.
bucket - A String value containing the value of the bucket being referenced.count - A Integer value that the default bucket credit count will be set to.public int getCreditCount()
Get the current cached credit count for the default bucket, as currently stored in preferences for the current app.
Integer value specifying the current number of credits in the bucket, as
currently stored in preferences.public int getCreditCount(java.lang.String bucket)
Get the current cached credit count for the default bucket, as currently stored in preferences for the current app.
bucket - A String value containing the value of the bucket being referenced.Integer value specifying the current number of credits in the bucket, as
currently stored in preferences.public void setActionTotalCount(java.lang.String action,
int count)
Sets the count of total number of times that the specified action has been carried out during the current session, as defined in preferences.
action - - A String value containing the name of the action to return the
count for.count - - An Integer value containing the total number of times that the
specified action has been carried out during the current session.public void setActionUniqueCount(java.lang.String action,
int count)
Sets the count of the unique number of times that the specified action has been carried out during the current session, as defined in preferences.
action - A String value containing the name of the action to return the
count for.count - An Integer value containing the total number of times that the
specified action has been carried out during the current session.public int getActionTotalCount(java.lang.String action)
Gets the count of total number of times that the specified action has been carried out during the current session, as defined in preferences.
action - A String value containing the name of the action to return the
count for.Integer value containing the total number of times that the
specified action has been carried out during the current session.public int getActionUniqueCount(java.lang.String action)
Gets the count of the unique number of times that the specified action has been carried out during the current session, as defined in preferences.
action - A String value containing the name of the action to return the
count for.Integer value containing the total number of times that the
specified action has been carried out during the current session.public int getInteger(java.lang.String key)
A basic method that returns an integer value from a specified preferences Key.
key - A String value containing the key to reference.Integer value of the specified key as stored in preferences.public int getInteger(java.lang.String key,
int defaultValue)
A basic method that returns an Integer value from a specified preferences Key, with a
default value supplied in case the value is null.
key - A String value containing the key to reference.defaultValue - An Integer specifying the value to use if the preferences value
is null.Integer value containing the value of the specified key, or the supplied
default value if null.public long getLong(java.lang.String key)
A basic method that returns a Long value from a specified preferences Key.
key - A String value containing the key to reference.Long value of the specified key as stored in preferences.public float getFloat(java.lang.String key)
A basic method that returns a Float value from a specified preferences Key.
key - A String value containing the key to reference.Float value of the specified key as stored in preferences.public java.lang.String getString(java.lang.String key)
A basic method that returns a String value from a specified preferences Key.
key - A String value containing the key to reference.String value of the specified key as stored in preferences.public boolean getBool(java.lang.String key)
A basic method that returns a Boolean value from a specified preferences Key.
key - A String value containing the key to reference.Boolean value of the specified key as stored in preferences.public void setInteger(java.lang.String key,
int value)
Sets the value of the String key value supplied in preferences.
key - A String value containing the key to reference.value - An Integer value to set the preference record to.public void setLong(java.lang.String key,
long value)
Sets the value of the String key value supplied in preferences.
key - A String value containing the key to reference.value - A Long value to set the preference record to.public void setFloat(java.lang.String key,
float value)
Sets the value of the String key value supplied in preferences.
key - A String value containing the key to reference.value - A Float value to set the preference record to.public void setString(java.lang.String key,
java.lang.String value)
Sets the value of the String key value supplied in preferences.
key - A String value containing the key to reference.value - A String value to set the preference record to.public void setBool(java.lang.String key,
java.lang.Boolean value)
Sets the value of the String key value supplied in preferences.
key - A String value containing the key to reference.value - A Boolean value to set the preference record to.public void updateBranchViewUsageCount(java.lang.String branchViewId)
public int getBranchViewUsageCount(java.lang.String branchViewId)
public void setExternDebug()
Switches external debugging on.
public boolean getExternDebug()
Gets the value of the debug status Boolean value.
Boolean value indicating the current state of external debugging.public void disableExternAppListing()
Sets the Boolean value that is checked prior to the listing of external apps to
false.
public boolean getExternAppListing()
Sets the Boolean value that is checked prior to the listing of external apps.
Boolean value containing the current value of the
BNC_App_Listing boolean.public void disableSmartSession()
public boolean getSmartSession()
Gets the state of the Boolean value indicating whether or not the Smart Session
feature is enabled or not.
public boolean isDebug()
Gets the Boolean value of BNC_Dev_Debug, which indicates whether or not
debugging is enabled.
Boolean value indicating current debug state:
public void log(java.lang.String tag,
java.lang.String message)
Creates a Log message in the debugger. If debugging is disabled, this will fail silently.
tag - A String value specifying the logging tag to use for the message.message - A String value containing the logging message to record.public static void Debug(java.lang.String tag,
java.lang.String message)
Creates a Debug message in the debugger. If debugging is disabled, this will fail silently.
tag - A String value specifying the logging tag to use for the message.message - A String value containing the debug message to record.