use of com.supercilex.robotscouter.data.util.TeamHelper 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;
}
use of com.supercilex.robotscouter.data.util.TeamHelper in project Robot-Scouter by SUPERCILEX.
the class TeamMenuHelper method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
TeamHelper teamHelper = mSelectedTeams.get(0);
switch(item.getItemId()) {
case R.id.action_export_spreadsheet:
exportTeams();
break;
case R.id.action_share:
if (TeamSharer.launchInvitationIntent(mFragment.getActivity(), mSelectedTeams)) {
resetMenu();
}
logShareTeamEvent(teamHelper.getTeam().getNumber());
break;
case R.id.action_visit_tba_website:
teamHelper.visitTbaWebsite(mFragment.getContext());
resetMenu();
break;
case R.id.action_visit_team_website:
teamHelper.visitTeamWebsite(mFragment.getContext());
resetMenu();
break;
case R.id.action_edit_team_details:
TeamDetailsDialog.show(mFragment.getChildFragmentManager(), teamHelper);
logEditTeamDetailsEvent(teamHelper.getTeam().getNumber());
break;
case R.id.action_delete:
DeleteTeamDialog.Companion.show(mFragment.getChildFragmentManager(), mSelectedTeams);
break;
case android.R.id.home:
resetMenu();
break;
default:
return false;
}
return true;
}
use of com.supercilex.robotscouter.data.util.TeamHelper in project Robot-Scouter by SUPERCILEX.
the class SpreadsheetExporter method getWorkbook.
@AddTrace(name = "getWorkbook")
private Workbook getWorkbook() {
Workbook workbook;
if (isUnsupportedDevice()) {
workbook = new HSSFWorkbook();
showToast(this, getString(R.string.unsupported_device));
} else {
workbook = new XSSFWorkbook();
}
mCache.setWorkbook(workbook);
Sheet averageSheet = null;
if (mCache.getTeamHelpers().size() > SINGLE_ITEM) {
averageSheet = workbook.createSheet("Team Averages");
averageSheet.createFreezePane(1, 1);
}
List<TeamHelper> teamHelpers = mCache.getTeamHelpers();
for (TeamHelper teamHelper : teamHelpers) {
mCache.updateNotification(getString(R.string.exporting_spreadsheet_team, teamHelper));
Sheet teamSheet = workbook.createSheet(getSafeSheetName(workbook, teamHelper));
teamSheet.createFreezePane(1, 1);
buildTeamSheet(teamHelper, teamSheet);
}
mCache.updateNotification(getString(R.string.exporting_spreadsheet_average));
if (averageSheet != null)
buildTeamAveragesSheet(averageSheet);
mCache.updateNotification(getString(R.string.exporting_spreadsheet_cleanup));
autoFitColumnWidths(workbook);
return workbook;
}
use of com.supercilex.robotscouter.data.util.TeamHelper in project Robot-Scouter by SUPERCILEX.
the class ScoutTemplateSheet method getTemplateKey.
private void getTemplateKey() {
TeamHelper teamHelper = TeamHelper.parse(getArguments());
mTemplateKey = teamHelper.getTeam().getTemplateKey();
if (TextUtils.isEmpty(mTemplateKey)) {
if (!Constants.sFirebaseScoutTemplates.isEmpty()) {
mTemplateKey = Constants.sFirebaseScoutTemplates.get(0).getKey();
teamHelper.updateTemplateKey(mTemplateKey);
return;
}
DatabaseReference newTemplateRef = FIREBASE_SCOUT_TEMPLATES.push();
mTemplateKey = newTemplateRef.getKey();
FirebaseCopier.copyTo(Constants.sDefaultTemplate, newTemplateRef);
teamHelper.updateTemplateKey(mTemplateKey);
UserHelper.getScoutTemplateIndicesRef().child(mTemplateKey).setValue(true);
for (int i = 0; i < Constants.sFirebaseTeams.size(); i++) {
Team team = Constants.sFirebaseTeams.getObject(i);
String templateKey = team.getTemplateKey();
if (TextUtils.isEmpty(templateKey)) {
team.getHelper().updateTemplateKey(mTemplateKey);
}
}
}
}
Aggregations