use of com.supercilex.robotscouter.ui.PermissionRequestHandler in project Robot-Scouter by SUPERCILEX.
the class SpreadsheetExporter method writeAndShareTeams.
/**
* @return true if an export was attempted, false otherwise
*/
@SuppressWarnings("MissingPermission")
public static boolean writeAndShareTeams(Fragment fragment, PermissionRequestHandler permHandler, @Size(min = 1) List<TeamHelper> teamHelpers) {
if (teamHelpers.isEmpty())
return false;
Context context = fragment.getContext();
if (!EasyPermissions.hasPermissions(context, permHandler.getPermsArray())) {
permHandler.requestPerms(R.string.write_storage_rationale_spreadsheet);
return false;
}
if (shouldShowExportHint(context)) {
Snackbar.make(fragment.getView(), R.string.exporting_spreadsheet_hint, Snackbar.LENGTH_INDEFINITE).setAction(R.string.never_again, v -> setShouldShowExportHint(context, false)).show();
}
fragment.getActivity().startService(new Intent(context, SpreadsheetExporter.class).putExtras(TeamHelper.toIntent(teamHelpers)));
return true;
}
Aggregations