Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,26 @@ public static void sendEmail(Context context, String email, String location,
UIUtils.sendEmail(context, email, location, obaRegionName, regionSelectionMethod,
tripPlanUrl, tripPlanFail);
}
/**
* Safely formats a string resource using the provided format arguments.
*
* This method replaces any null elements in the varargs array with an empty string
* before calling {@link Context#getString(int, Object...)} to avoid formatting errors
* or unexpected "null" text in the resulting string.
*
* @param context the Context used to retrieve the string resource
* @param resId the resource id of the string to format
* @param formatArgs optional format arguments to be interpolated into the resource;
* any null elements will be converted to empty strings
* @return the formatted string from resources with null format arguments replaced by empty strings
*/
private static String safeGetString(Context context, int resId, Object... formatArgs) {
Object[] safeArgs = new Object[formatArgs.length];
for (int i = 0; i < formatArgs.length; i++) {
safeArgs[i] = (formatArgs[i] != null) ? formatArgs[i] : "";
}
return context.getString(resId, safeArgs);
}

/**
* Opens email apps based on the given email address
Expand Down Expand Up @@ -725,7 +745,7 @@ private static void sendEmail(Context context, String email, String location, St
// Have location
if (tripPlanUrl == null) {
// No trip plan
body = context.getString(R.string.bug_report_body,
body = safeGetString(context,R.string.bug_report_body,
obaVersion,
Build.MODEL,
Build.VERSION.RELEASE,
Expand Down