Package-level declarations
Types
Wraps Log so that Braze log messages can be set to a configurable level.
Useful validation methods for checking user input.
Functions
If both null, returns true.
Gets the sample factor given a bitmap's dimensions and destination view's bounds.
Creates a new JSONArray containing the contents of the input array.
Converts a JSONObject to a Map
Recursively deletes all the files under a directory. If the input file is not a directory, then this only deletes the file. This is recursive since directories must be empty before deletion.
Deletes the android.content.SharedPreferences file. Expects the filename to end in ".xml".
If input is empty or only contains whitespace, returns null. No null checking is performed.
Formats the date using the specified DateFormat pattern.
Formats the current time with the specified format in the current timezone.
Retrieve the string contents of a file from Android assets.
Gets the image metadata from an input stream without having to allocate memory for the image's pixels, see android.graphics.BitmapFactory.Options.inJustDecodeBounds. Note that the stream's position is changed as a result. The input stream is not closed by this method and must be closed the caller.
Gets the number of bytes in UTF-8 encoding.
Gets a MD5 hash of the userId. If userId is null, a MD5 hash of the String "null" is returned.
There is the potential for having a too-long filename, but Android doesn't actually have anything about that in the docs. Stack overflow suggests < 127 characters, so with the API key 36 characters and 31 characters of prefix, that leaves 60 characters for userId. We'll use the MD5 hash to make sure it fits.
Gets the size in bytes to give the image loader's cache.
Calculates the MD5 hash for some text.
Returns the string value for key, or null if the key is not mapped in the object.
Helper method to determine how many times a permission has been requested through this util. Does not cover situations where the permission was requested by the integrator!!!
Returns the JSONArray.toString result if possible. Returns an empty string if the input JSONArray is null or on any thrown Throwable.
Returns the JSONObject.toString result if possible. Returns an empty string if the input JSONObject is null or on any thrown Throwable.
Helper method for checking if a permission is allowed. In case of error the permission is reported as denied.
Invokes the input block iff the string is non-null and non-empty.
Checks if the string is empty or only contains whitespace characters. This will call String.trim to ascertain whether the string contains only whitespace.
Checks if the string is null or only contains whitespace characters. This will call String.trim to ascertain whether the string contains only whitespace.
Checks if the string is null or has a length of 0.
Helper method to determine if a timeZoneId is valid.
Merges key-values from oldJson and newJson into a new JSONObject. Keys which exist in both oldJson and newJson will be overridden by the values in newJson. Key-values present in oldJson but not newJson will be preserved.
Returns the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC (Unix time).
Returns the difference, measured in seconds, between the current time and midnight, January 1, 1970 UTC (Unix time).
Returns the difference, measured in seconds, between the current time and midnight, January 1, 1970 UTC (Unix time) with millisecond precision to 3 places.
Returns a Date object parsed from a BrazeDateFormat formatted date string.
Parses the JSON into a bundle. The JSONObject parsed from the input string must be a flat dictionary with all string values.
Requests the push permission prompt to be shown if on Android API 13+ and the push permission hasn't already been granted.
Truncates and returns the input text to the desired number of UTF-8 bytes.