diff --git a/.gitignore b/.gitignore index 520a863..d7f8058 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,13 @@ google-services.json freeline.py freeline/ freeline_project_description.json + +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/Tablet/MatchScouting/.gitignore b/Tablet/MatchScouting/.gitignore new file mode 100644 index 0000000..39fb081 --- /dev/null +++ b/Tablet/MatchScouting/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/Tablet/MatchScouting/.idea/gradle.xml b/Tablet/MatchScouting/.idea/gradle.xml new file mode 100644 index 0000000..7ac24c7 --- /dev/null +++ b/Tablet/MatchScouting/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/Tablet/MatchScouting/.idea/misc.xml b/Tablet/MatchScouting/.idea/misc.xml new file mode 100644 index 0000000..3963879 --- /dev/null +++ b/Tablet/MatchScouting/.idea/misc.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/Tablet/MatchScouting/.idea/modules.xml b/Tablet/MatchScouting/.idea/modules.xml new file mode 100644 index 0000000..ce8e804 --- /dev/null +++ b/Tablet/MatchScouting/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Tablet/MatchScouting/.idea/runConfigurations.xml b/Tablet/MatchScouting/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/Tablet/MatchScouting/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/Tablet/MatchScouting/app/.gitignore b/Tablet/MatchScouting/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/Tablet/MatchScouting/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/Tablet/MatchScouting/app/build.gradle b/Tablet/MatchScouting/app/build.gradle new file mode 100644 index 0000000..6ea867b --- /dev/null +++ b/Tablet/MatchScouting/app/build.gradle @@ -0,0 +1,34 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "org.team100.pitscouting" + minSdkVersion 23 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + repositories { + maven { url 'https://jitpack.io' } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'com.android.support:appcompat-v7:26.1.0' + implementation 'com.android.support.constraint:constraint-layout:1.0.2' + implementation 'com.android.support:design:26.1.0' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.1' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' + compile 'com.google.zxing:core:3.2.0' + compile 'com.github.kenglxn.QRGen:android:2.4.0' +} diff --git a/Tablet/MatchScouting/app/proguard-rules.pro b/Tablet/MatchScouting/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/Tablet/MatchScouting/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/Tablet/MatchScouting/app/src/androidTest/java/org/team100/matchscouting/ExampleInstrumentedTest.java b/Tablet/MatchScouting/app/src/androidTest/java/org/team100/matchscouting/ExampleInstrumentedTest.java new file mode 100644 index 0000000..5d4ce09 --- /dev/null +++ b/Tablet/MatchScouting/app/src/androidTest/java/org/team100/matchscouting/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package org.team100.matchscouting; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("org.team100.pitscouting", appContext.getPackageName()); + } +} diff --git a/Tablet/MatchScouting/app/src/main/AndroidManifest.xml b/Tablet/MatchScouting/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..71bb86f --- /dev/null +++ b/Tablet/MatchScouting/app/src/main/AndroidManifest.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tablet/MatchScouting/app/src/main/java/org/team100/matchscouting/MainActivity.java b/Tablet/MatchScouting/app/src/main/java/org/team100/matchscouting/MainActivity.java new file mode 100644 index 0000000..6a43de7 --- /dev/null +++ b/Tablet/MatchScouting/app/src/main/java/org/team100/matchscouting/MainActivity.java @@ -0,0 +1,170 @@ +package org.team100.matchscouting; + +import android.app.Activity; +import android.content.Intent; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.view.WindowManager; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.RadioButton; +import android.widget.RadioGroup; +import android.widget.Spinner; +import android.widget.TabHost; +import android.widget.Toast; + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); + + //Set Tabs + setTabs(); + } + + public void setTabs(){ + + TabHost tabHost1 = (TabHost)findViewById(R.id.tabhost1); + tabHost1.setup(); + TabHost tabHost2 = (TabHost)findViewById(R.id.tabhost2); + tabHost2.setup(); + + TabHost.TabSpec tab1 = tabHost1.newTabSpec("Auto"); + TabHost.TabSpec tab2 = tabHost1.newTabSpec("Tele-Op"); + TabHost.TabSpec tab3 = tabHost2.newTabSpec("Init"); + TabHost.TabSpec tab4 = tabHost2.newTabSpec("Overall"); + + tab1.setIndicator("Auto"); + tab1.setContent(R.id.Auto); + + tab2.setIndicator("Tele-Op"); + tab2.setContent(R.id.Teleop); + + tab3.setIndicator("Init"); + tab3.setContent(R.id.Init); + + tab4.setIndicator("Overall"); + tab4.setContent(R.id.Overall); + + tabHost1.addTab(tab1); + tabHost1.addTab(tab2); + tabHost2.addTab(tab3); + tabHost2.addTab(tab4); + } + + public void onButton(View v) { + qual(); + } + + public String getData(String qual){ + //Link XML objects to Java objects\ + Spinner spinner4 = findViewById(R.id.spinner4); + EditText editText = findViewById(R.id.editText5); + RadioGroup radioGroup3 = findViewById(R.id.radioGroup3); + RadioGroup radioGroup2 = findViewById(R.id.radioGroup2); + RadioGroup radioGroup = findViewById(R.id.radioGroup); + CheckBox checkBoxALine = findViewById(R.id.checkBoxALine); + CheckBox checkBoxACube = findViewById(R.id.checkBoxACube); + Spinner spinner = findViewById(R.id.spinner); + Spinner spinner2 = findViewById(R.id.spinner2); + CheckBox checkBox2 = findViewById(R.id.checkBox2); + Spinner spinner5 = findViewById(R.id.spinner5); + Spinner spinner6 = findViewById(R.id.spinner6); + Spinner spinner7 = findViewById(R.id.spinner7); + CheckBox checkBox3 = findViewById(R.id.checkBox3); + CheckBox checkBox4 = findViewById(R.id.checkBox4); + CheckBox checkBox5 = findViewById(R.id.checkBox5); + Spinner spinner8 = findViewById(R.id.spinner8); + Spinner spinner9 = findViewById(R.id.spinner9); + CheckBox checkBox6 = findViewById(R.id.checkBox6); + CheckBox checkBox8 = findViewById(R.id.checkBox8); + CheckBox checkBox7 = findViewById(R.id.checkBox7); + CheckBox checkBox9 = findViewById(R.id.checkBox9); + + //Radio Group Init + String rgb2=((RadioButton)this.findViewById(radioGroup2.getCheckedRadioButtonId())).getText().toString(); + String rgb3=((RadioButton)this.findViewById(radioGroup3.getCheckedRadioButtonId())).getText().toString(); + String rgb = ((RadioButton)this.findViewById(radioGroup.getCheckedRadioButtonId())).getText().toString(); + + //Get object values + String sS4 = spinner4.getSelectedItem().toString(); + String sET4 = editText.getText().toString(); + String sRG3 = rgb3; + String sRG2 = rgb2; + String sRG = rgb; + String sCBAL = String.valueOf(checkBoxALine.isChecked()); + String sCBAC = String.valueOf(checkBoxACube.isChecked()); + String sS = spinner.getSelectedItem().toString(); + String sS2 = spinner2.getSelectedItem().toString(); + String sCB2 = String.valueOf(checkBox2.isChecked()); + String sS5 = spinner5.getSelectedItem().toString(); + String sS6 = spinner6.getSelectedItem().toString(); + String sS7 = spinner7.getSelectedItem().toString(); + String sCB3 = String.valueOf(checkBox3.isChecked()); + String sCB4 = String.valueOf(checkBox4.isChecked()); + String sCB5 = String.valueOf(checkBox5.isChecked()); + String sS8 = spinner8.getSelectedItem().toString(); + String sS9 = spinner9.getSelectedItem().toString(); + String sCB6 = String.valueOf(checkBox6.isChecked()); + String sCB8 = String.valueOf(checkBox8.isChecked()); + String sCB7 = String.valueOf(checkBox7.isChecked()); + String sCB9 = String.valueOf(checkBox9.isChecked()); + + String fin = sS4 + "^" + sET4 + "^" + sRG3 + "^" + sRG2 + "^" + sRG + + "^" + sCBAL + "^" + sCBAC + "^" + sS + "^" + sS2 + "^" + sCB2 + + "^" + sS5 + "^" + sS6 + "^" + sS7 + "^" + sCB3 + "^" + sCB4 + + "^" + sCB5 + "^" + sS8 + "^" + sS9 + "^" + sCB6 + "^" + sCB8 + + "^" + sCB7 + "^" + sCB9 + "^" + qual; + + return fin; + } + + public void q(View v){ + Intent intentqq = new Intent(this, QualActivity.class); + startActivity(intentqq); + } + + public void qual(){ + Intent intentQual = new Intent(this, QualActivity.class); + startActivityForResult(intentQual, 1); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data){ + super.onActivityResult(requestCode, resultCode, data); + String returnValue = ""; + switch(requestCode) { + case (1) : { + if (resultCode == Activity.RESULT_OK) { + // TODO Extract the data returned from the child Activity. + returnValue = data.getStringExtra("data1"); + } + break; + } + } + String s = returnValue; + String fin1 = ""; + if(s.isEmpty()){ + fin1 = getData(" "); + }else { + fin1 = getData(s); + } + + //Check if payload is null, otherwise open QR activity and pass payload + if (fin1.isEmpty()) { + Toast.makeText(this, "Invalid Text", Toast.LENGTH_SHORT).show(); + } else { + Spinner spinner4a = findViewById(R.id.spinner4); + Intent intent = new Intent(this, QRActivity.class); + intent.putExtra("payload", fin1); + intent.putExtra("team", spinner4a.getSelectedItem().toString()); + + startActivity(intent); + finish(); + } + } +} \ No newline at end of file diff --git a/Tablet/MatchScouting/app/src/main/java/org/team100/matchscouting/QRActivity.java b/Tablet/MatchScouting/app/src/main/java/org/team100/matchscouting/QRActivity.java new file mode 100644 index 0000000..d929d31 --- /dev/null +++ b/Tablet/MatchScouting/app/src/main/java/org/team100/matchscouting/QRActivity.java @@ -0,0 +1,77 @@ +package org.team100.matchscouting; + +import android.Manifest; +import android.content.pm.PackageManager; +import android.graphics.Bitmap; +import android.os.Bundle; +import android.provider.MediaStore; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.ImageView; +import net.glxn.qrgen.android.QRCode; + +public class QRActivity extends AppCompatActivity { + + public static final int MY_PERMISSIONS_WRITE_EXTERNAL_STORAGE = 1; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_qr); + + //Extract payload from intent + Bundle extras = getIntent().getExtras(); + String payload = ""; + payload = extras.getString("payload", "null"); + + //Link ImageView with Java object and set contents to a QR Code generated from payload + ImageView imageView = findViewById(R.id.imageView); + Bitmap bm = QRCode.from(payload).bitmap(); + imageView.setImageBitmap(bm); + + if (ContextCompat.checkSelfPermission(getApplicationContext(), + Manifest.permission.WRITE_CALENDAR) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(this, + new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, + MY_PERMISSIONS_WRITE_EXTERNAL_STORAGE); + + } + + } + + @Override + public void onRequestPermissionsResult(int requestCode, String permissions[], + int[] grantResults) { + + String team = getIntent().getExtras().getString("team", "null"); + String pdata = getIntent().getExtras().getString("payload", "null"); + Bitmap code = QRCode.from(pdata).bitmap(); + + switch (requestCode) { + case MY_PERMISSIONS_WRITE_EXTERNAL_STORAGE: { + // If request is cancelled, the result arrays are empty. + if (grantResults.length > 0 + && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + + MediaStore.Images.Media.insertImage(getContentResolver(), code, team.toString() , + "Scouting data for team " + team.toString()); + + } else { + } + return; + } + } + } + + public void onBackButton(View v){ + android.os.Process.killProcess(android.os.Process.myPid()); + } + + @Override + public void onBackPressed(){ + android.os.Process.killProcess(android.os.Process.myPid()); + } + +} diff --git a/Tablet/MatchScouting/app/src/main/java/org/team100/matchscouting/QualActivity.java b/Tablet/MatchScouting/app/src/main/java/org/team100/matchscouting/QualActivity.java new file mode 100644 index 0000000..8f93e21 --- /dev/null +++ b/Tablet/MatchScouting/app/src/main/java/org/team100/matchscouting/QualActivity.java @@ -0,0 +1,32 @@ +package org.team100.matchscouting; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.widget.EditText; + +/** + * Created by Team100 on 3/15/2018. + */ + +public class QualActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState){ + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_qual); + } + + public void onBackPressed() { + EditText text = findViewById(R.id.editText2); + String data1 = String.valueOf(text.getText()); + + + Intent resultIntent = new Intent(); + resultIntent.putExtra("data1", data1); + setResult(Activity.RESULT_OK, resultIntent); + finish(); + } + +} diff --git a/Tablet/MatchScouting/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/Tablet/MatchScouting/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..c7bd21d --- /dev/null +++ b/Tablet/MatchScouting/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/Tablet/MatchScouting/app/src/main/res/drawable/ic_launcher_background.xml b/Tablet/MatchScouting/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..d5fccc5 --- /dev/null +++ b/Tablet/MatchScouting/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tablet/MatchScouting/app/src/main/res/layout/activity_main.xml b/Tablet/MatchScouting/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..8254722 --- /dev/null +++ b/Tablet/MatchScouting/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,568 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +