Search in sources :

Example 1 with PermissionRequestHandler

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;
}
Also used : Context(android.content.Context) PreferencesUtilsKt.setShouldShowExportHint(com.supercilex.robotscouter.util.PreferencesUtilsKt.setShouldShowExportHint) SpreadsheetUtils.getMetricForScouts(com.supercilex.robotscouter.data.client.spreadsheet.SpreadsheetUtils.getMetricForScouts) ClientAnchor(org.apache.poi.ss.usermodel.ClientAnchor) Drawing(org.apache.poi.ss.usermodel.Drawing) Arrays(java.util.Arrays) Uri(android.net.Uri) DataSources(org.apache.poi.ss.usermodel.charts.DataSources) PreferencesUtilsKt.shouldShowExportHint(com.supercilex.robotscouter.util.PreferencesUtilsKt.shouldShowExportHint) IntentService(android.app.IntentService) NotificationForwarder(com.supercilex.robotscouter.data.client.NotificationForwarder) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Manifest(android.Manifest) ScatterChartData(org.apache.poi.ss.usermodel.charts.ScatterChartData) SpreadsheetUtils.createChartAnchor(com.supercilex.robotscouter.data.client.spreadsheet.SpreadsheetUtils.createChartAnchor) Map(java.util.Map) SpreadsheetUtils.showToast(com.supercilex.robotscouter.data.client.spreadsheet.SpreadsheetUtils.showToast) ChartAxis(org.apache.poi.ss.usermodel.charts.ChartAxis) NUMBER(com.supercilex.robotscouter.data.model.MetricTypeKt.NUMBER) XSSFChart(org.apache.poi.xssf.usermodel.XSSFChart) Sheet(org.apache.poi.ss.usermodel.Sheet) Fragment(android.support.v4.app.Fragment) ContextCompat(android.support.v4.content.ContextCompat) IoUtilsKt.unhideFile(com.supercilex.robotscouter.util.IoUtilsKt.unhideFile) ChartDataSource(org.apache.poi.ss.usermodel.charts.ChartDataSource) SpreadsheetUtils.getSafeSheetName(com.supercilex.robotscouter.data.client.spreadsheet.SpreadsheetUtils.getSafeSheetName) Snackbar(android.support.design.widget.Snackbar) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) Scout(com.supercilex.robotscouter.data.model.Scout) IoUtilsKt.getRootFolder(com.supercilex.robotscouter.util.IoUtilsKt.getRootFolder) R(com.supercilex.robotscouter.R) Metric(com.supercilex.robotscouter.data.model.Metric) LineChartData(org.apache.poi.ss.usermodel.charts.LineChartData) SpreadsheetUtils.autoFitColumnWidths(com.supercilex.robotscouter.data.client.spreadsheet.SpreadsheetUtils.autoFitColumnWidths) ArrayList(java.util.ArrayList) SpreadsheetUtils.getChartRowIndex(com.supercilex.robotscouter.data.client.spreadsheet.SpreadsheetUtils.getChartRowIndex) AddTrace(com.google.firebase.perf.metrics.AddTrace) STOPWATCH(com.supercilex.robotscouter.data.model.MetricTypeKt.STOPWATCH) SpreadsheetUtils.setChartAxisTitle(com.supercilex.robotscouter.data.client.spreadsheet.SpreadsheetUtils.setChartAxisTitle) LIST(com.supercilex.robotscouter.data.model.MetricTypeKt.LIST) PluralsRes(android.support.annotation.PluralsRes) FileOutputStream(java.io.FileOutputStream) TextUtils(android.text.TextUtils) IOException(java.io.IOException) File(java.io.File) ExecutionException(java.util.concurrent.ExecutionException) Workbook(org.apache.poi.ss.usermodel.Workbook) ValueAxis(org.apache.poi.ss.usermodel.charts.ValueAxis) AxisCrosses(org.apache.poi.ss.usermodel.charts.AxisCrosses) IoUtilsKt.hideFile(com.supercilex.robotscouter.util.IoUtilsKt.hideFile) Scouts(com.supercilex.robotscouter.data.util.Scouts) AnalyticsUtilsKt.logExportTeamsEvent(com.supercilex.robotscouter.util.AnalyticsUtilsKt.logExportTeamsEvent) Chart(org.apache.poi.ss.usermodel.Chart) ConstantsKt.providerAuthorityJava(com.supercilex.robotscouter.util.ConstantsKt.providerAuthorityJava) TimeoutException(java.util.concurrent.TimeoutException) PendingIntent(android.app.PendingIntent) FileProvider(android.support.v4.content.FileProvider) TEXT(com.supercilex.robotscouter.data.model.MetricTypeKt.TEXT) SpreadsheetUtils.getAdjustedList(com.supercilex.robotscouter.data.client.spreadsheet.SpreadsheetUtils.getAdjustedList) Cell(org.apache.poi.ss.usermodel.Cell) CTChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTChart) ConnectivityUtilsKt.isOffline(com.supercilex.robotscouter.util.ConnectivityUtilsKt.isOffline) AxisPosition(org.apache.poi.ss.usermodel.charts.AxisPosition) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) LegendPosition(org.apache.poi.ss.usermodel.charts.LegendPosition) SINGLE_ITEM(com.supercilex.robotscouter.util.ConstantsKt.SINGLE_ITEM) RichTextString(org.apache.poi.ss.usermodel.RichTextString) FirebaseCrash(com.google.firebase.crash.FirebaseCrash) SpreadsheetUtils.getStringForCell(com.supercilex.robotscouter.data.client.spreadsheet.SpreadsheetUtils.getStringForCell) RequiresPermission(android.support.annotation.RequiresPermission) WorkbookEvaluator(org.apache.poi.ss.formula.WorkbookEvaluator) SpreadsheetUtils.showError(com.supercilex.robotscouter.data.client.spreadsheet.SpreadsheetUtils.showError) PermissionRequestHandler(com.supercilex.robotscouter.ui.PermissionRequestHandler) List(java.util.List) Tasks(com.google.android.gms.tasks.Tasks) Notification(android.app.Notification) Nullable(android.support.annotation.Nullable) EasyPermissions(pub.devrel.easypermissions.EasyPermissions) Context(android.content.Context) CellType(org.apache.poi.ss.usermodel.CellType) SpreadsheetUtils.getCellRangeAddress(com.supercilex.robotscouter.data.client.spreadsheet.SpreadsheetUtils.getCellRangeAddress) Pair(android.util.Pair) SpreadsheetUtils.isUnsupportedDevice(com.supercilex.robotscouter.data.client.spreadsheet.SpreadsheetUtils.isUnsupportedDevice) Intent(android.content.Intent) HashMap(java.util.HashMap) CTPlotArea(org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea) TeamHelper(com.supercilex.robotscouter.data.util.TeamHelper) MissingCellPolicy(org.apache.poi.ss.usermodel.Row.MissingCellPolicy) ChartLegend(org.apache.poi.ss.usermodel.charts.ChartLegend) Build(android.os.Build) Iterator(java.util.Iterator) BOOLEAN(com.supercilex.robotscouter.data.model.MetricTypeKt.BOOLEAN) Size(android.support.annotation.Size) TimeUnit(java.util.concurrent.TimeUnit) HEADER(com.supercilex.robotscouter.data.model.MetricTypeKt.HEADER) OnSuccessListener(com.google.android.gms.tasks.OnSuccessListener) SpreadsheetUtils.getMetricForChart(com.supercilex.robotscouter.data.client.spreadsheet.SpreadsheetUtils.getMetricForChart) NotificationCompat(android.support.v4.app.NotificationCompat) Row(org.apache.poi.ss.usermodel.Row) Collections(java.util.Collections) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent)

Aggregations

Manifest (android.Manifest)1 IntentService (android.app.IntentService)1 Notification (android.app.Notification)1 PendingIntent (android.app.PendingIntent)1 Context (android.content.Context)1 Intent (android.content.Intent)1 Uri (android.net.Uri)1 Build (android.os.Build)1 Nullable (android.support.annotation.Nullable)1 PluralsRes (android.support.annotation.PluralsRes)1 RequiresPermission (android.support.annotation.RequiresPermission)1 Size (android.support.annotation.Size)1 Snackbar (android.support.design.widget.Snackbar)1 Fragment (android.support.v4.app.Fragment)1 NotificationCompat (android.support.v4.app.NotificationCompat)1 ContextCompat (android.support.v4.content.ContextCompat)1 FileProvider (android.support.v4.content.FileProvider)1 TextUtils (android.text.TextUtils)1 Pair (android.util.Pair)1 OnSuccessListener (com.google.android.gms.tasks.OnSuccessListener)1