Skip to content

Commit

Permalink
Bug fixes and prep for 4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
widavies committed Feb 25, 2018
1 parent d99aa9a commit 28bf305
Show file tree
Hide file tree
Showing 37 changed files with 1,664 additions and 351 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

<!-- Supports Chrome-OS -->
<uses-feature android:name="android.hardware.touchscreen"
Expand Down Expand Up @@ -127,6 +126,7 @@
<activity android:name=".ui.images.FullScreenImageGalleryActivity"/>
<activity android:name=".ui.images.ImageGalleryActivity"/>
<activity android:name=".ui.images.Drawing"/>
<activity android:name=".csv.CSVActivity"/>
</application>

</manifest>
40 changes: 25 additions & 15 deletions app/src/main/assets/predefinedForms/2018-5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,32 @@ Title:FRC 2018
Description:Courtesy Team 2826, Wave Robotics
PIT
DEFAULTS
textfield,What kind of wheels do they have?,
textfield,Wheel diameter?,
textfield,Ground clearance?,
textfield,How much does the robot weigh?,
textfield,Center of gravity where?,
gallery,Robot pictures.
textfield,Wheel Type?,
textfield,Wheel Diameter?,
textfield,Ground Clearance?,
textfield,Robot Weight?,
textfield,Center of Gravity Position?,
checkbox,Auto Functions,Cross Auto-line:Place Cube on Switch:Place Cube on Scale:Place Cube on Switch
divider,Preferred Auto Start Positions
chooser,First,Left:Center:Right,0
chooser,Second,Left:Center:Right,0
chooser,Third,Left:Center:Right,0
MATCH
checkbox,Auto,No Auto:Auto But Didn't Work:Base-Line Cross
counter,# of blocks placed on switch during auto?,1,0
counter,# of blocks placed on scale during auto?,1,0
counter,# of blocks in exchange during tele-op?,1,0
counter,# of blocks on switch during tele-op?,1,0
counter,# of blocks on scale during tele-op?,1,0
counter,# of blocks on opposing switch during tele-op?,1,0
checkbox,Where is the robot acquiring the cubes?,Field:Portal
divider,Auto
boolean,Did it Cross the Auto-Line?,false
counter,# of Cubes placed on switch?,1,0
counter,# of Cubes placed on scale?,1,0
divider,Tele-Op
counter,# of cubes in exchange?,1,0
counter,# of cubes on switch?,1,0
counter,# of cubes on scale?,1,0
counter,# of cubes on Opponent's Switch during tele-op?,1,0
checkbox,Where is it acquiring cubes from?,Field:Portal
divider,Last 30 Sec
checkbox,Last 30 Sec,Did Nothing:Lifted itself:Lifted 1 other robot:Lifted 2 other robots:Drove onto another:Climbed another:Parked:Continued to work on platforms:Captured scale:Captured switch
boolean,Did the robot break/lose comms?,false
textfield,If Lifted by Another Please State That Team's #,
divider,Additional Information,
checkbox,Did anything abnormal happen?,Lose Communications:Break:Disabled by Other Robot
textfield,Anything you want to add?,


133 changes: 133 additions & 0 deletions app/src/main/java/com/cpjd/roblu/csv/CSVActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package com.cpjd.roblu.csv;

import android.app.ProgressDialog;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.AppCompatEditText;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.CheckBox;
import android.widget.Spinner;
import android.widget.Toast;

import com.cpjd.roblu.BuildConfig;
import com.cpjd.roblu.R;
import com.cpjd.roblu.models.REvent;
import com.cpjd.roblu.ui.UIHandler;

import java.io.File;
import java.util.ArrayList;

/**
* Allows the user to select several .CSV options for export
*
* @since 4.1.0
* @version 1
* @author Will Davies
*/
public class CSVActivity extends AppCompatActivity implements ExportCSVTask.ExportCSVListener {

private REvent event;

private ProgressDialog pd;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_csv);

event = (REvent) getIntent().getSerializableExtra("event");

Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("CSV Exporter");

new UIHandler(this, toolbar).update();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.csv_menu, menu);
new UIHandler(this, menu).updateMenu();
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(item.getItemId() == R.id.export) {
// Get verboseness ID
Spinner spinner = findViewById(R.id.verboseness);

Spinner fileTypes = findViewById(R.id.file_type);

// Check the check lists
CheckBox matchData = findViewById(R.id.match_data);
CheckBox pitData = findViewById(R.id.pit_data);
CheckBox matchList = findViewById(R.id.match_list);
CheckBox matchLookup = findViewById(R.id.match_lookup);
CheckBox ourMatches = findViewById(R.id.our_matches);
ArrayList<Integer> enabledSheets = new ArrayList<>();

if(matchData.isChecked()) enabledSheets.add(ExportCSVTask.SHEETS.MATCH_DATA);
if(pitData.isChecked()) enabledSheets.add(ExportCSVTask.SHEETS.PIT_DATA);
if(matchList.isChecked()) enabledSheets.add(ExportCSVTask.SHEETS.MATCH_LIST);
if(matchLookup.isChecked()) enabledSheets.add(ExportCSVTask.SHEETS.MATCH_LOOKUP);
if(ourMatches.isChecked()) enabledSheets.add(ExportCSVTask.SHEETS.OUR_MATCHES);

String fileName = ((AppCompatEditText)findViewById(R.id.file_name)).getText().toString();

if(enabledSheets.size() == 0) {
Toast.makeText(getApplicationContext(), "You must select at least 1 sheet before exporting.", Toast.LENGTH_LONG).show();
return true;
}

pd = ProgressDialog.show(CSVActivity.this, "Generating spreadsheet file...", "This may take several moments...", false);
pd.setCancelable(false);
pd.show();
new ExportCSVTask(getApplicationContext(), this, event, fileName, fileTypes.getSelectedItemPosition() == 0, enabledSheets, spinner.getSelectedItemPosition()).start();
}
else if(item.getItemId() == android.R.id.home) {
finish();
}
return true;
}

@Override
public void errorOccurred(final String message) {

runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(), "An error occurred while exporting CSV: "+message, Toast.LENGTH_LONG).show();
}
});
}

@Override
public void csvFileGenerated(final File file) {
runOnUiThread(new Runnable() {
@Override
public void run() {
pd.dismiss();
Log.d("RBS", "CSV file successfully generated.");
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
Uri uri = FileProvider.getUriForFile(getApplicationContext(), BuildConfig.APPLICATION_ID, file);
intent.setType("application/vnd.ms-excel");
intent.putExtra(Intent.EXTRA_STREAM, uri);
PackageManager pm = getPackageManager();
if(intent.resolveActivity(pm) != null) {
startActivity(Intent.createChooser(intent, "Export spreadsheet to..."));
}
// Utils.showSnackbar(getActivity().findViewById(R.id.event_settings), getActivity(), "Error occurred while generating .CSV file: "+message, true, 0);
}
});
}
}
Loading

0 comments on commit 28bf305

Please sign in to comment.