From 365613be700e4edc181c2af70f08dcd5f1021d72 Mon Sep 17 00:00:00 2001 From: IbrahimSaeedPurdue <54752803+IbrahimSaeedPurdue@users.noreply.github.com> Date: Thu, 11 Feb 2021 00:51:01 -0500 Subject: [PATCH 01/15] feature/Basic inspection form UI --- .idea/.name | 1 + .idea/vcs.xml | 6 + app/src/main/AndroidManifest.xml | 1 + .../InspectionForm.java | 128 ++++++++++++++++++ .../home/HomeFragment.java | 10 ++ app/src/main/res/values/strings.xml | 2 + 6 files changed, 148 insertions(+) create mode 100644 .idea/.name create mode 100644 .idea/vcs.xml create mode 100644 app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..c6e7f40 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +StormWaterUtilityAndroid \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5d437cc..1f7f4e7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -20,6 +20,7 @@ + diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java b/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java new file mode 100644 index 0000000..d39429e --- /dev/null +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java @@ -0,0 +1,128 @@ +package com.sf.stormwaterutilityandroid; + +import android.os.Bundle; +import android.widget.Button; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import me.riddhimanadib.formmaster.FormBuilder; +import me.riddhimanadib.formmaster.model.BaseFormElement; +import me.riddhimanadib.formmaster.model.FormElementPickerDate; +import me.riddhimanadib.formmaster.model.FormElementPickerMulti; +import me.riddhimanadib.formmaster.model.FormElementPickerSingle; +import me.riddhimanadib.formmaster.model.FormElementSwitch; +import me.riddhimanadib.formmaster.model.FormElementTextEmail; +import me.riddhimanadib.formmaster.model.FormElementTextMultiLine; +import me.riddhimanadib.formmaster.model.FormElementTextPhone; +import me.riddhimanadib.formmaster.model.FormElementTextSingleLine; +import me.riddhimanadib.formmaster.model.FormHeader; + +public class InspectionForm extends AppCompatActivity { + private FormBuilder formBuilder; + private RecyclerView recyclerView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_sample_fordm); + recyclerView = findViewById(R.id.recyclerView2); + setupForm(); + } + + + private void setupForm() { + formBuilder = new FormBuilder(this, recyclerView); + + + + FormElementTextSingleLine projectTextField = FormElementTextSingleLine.createInstance().setTitle("Project/Contact:").setHint("Enter text here"); + FormElementTextSingleLine addressTextField = FormElementTextSingleLine.createInstance().setTitle("Address/Lot#(s):").setHint("Enter text here"); + FormElementTextSingleLine inspectorTextField = FormElementTextSingleLine.createInstance().setTitle("Inspector:").setHint("Enter name here"); + FormElementPickerDate dataInspectedDatePicker = FormElementPickerDate.createInstance().setTitle("Date Inspected:").setDateFormat("MMM dd, yyyy"); + + + List typeOptions = new ArrayList<>(Arrays.asList( + "Routine Evaluation", + "Re-Inspection", + "Complaint Investigation", + "Entire Development", + "Individual Building Lot(s)" + )); + FormElementPickerSingle inspectionTypePickerSingle = FormElementPickerSingle.createInstance().setTitle("Inspection type:").setOptions(typeOptions).setPickerTitle("Pick inspection type"); + + FormElementSwitch projectRepPresentSwitch = FormElementSwitch.createInstance().setTitle("Project Representative Present?").setSwitchTexts("Yes", "No"); + + FormHeader stakeholdersHeader = FormHeader.createInstance("THE FOLLOWING INDIVIDUALS BECAME AWARE OF ANY ISSUES THOUGH DISCUSSION AND REVIEW OF FINDINGS ON THE DAY OF INSPECTION:"); + FormElementTextSingleLine projectManagerTextField = FormElementTextSingleLine.createInstance().setTitle("Project Manager:").setHint("Enter name here"); + FormElementTextSingleLine siteManagerTextField = FormElementTextSingleLine.createInstance().setTitle("Site Manager:").setHint("Enter name here"); + FormElementTextSingleLine projectOwnerTextField = FormElementTextSingleLine.createInstance().setTitle("Project Owner").setHint("Enter name here"); + + + FormHeader correctiveActionsHeader = FormHeader.createInstance("CORRECTIVE ACTIONS REQUIRED\n***REDER TO APPROVED STORM WATER POLLUTION PREVENTION PLAN (SWP3) FOR SPECIFICATIONS AND DETAILS ON ITEMS BELOW***"); + List correctiveActionsOptions= new ArrayList<>(Arrays.asList( + "Post a laminated copy of completed 327IAC15-5 \"Rule 5\" NOI with permit number at a location visible to the public", + "Remove accumulated sediment from streets sidewalks and gutters (do not flush with water)", + "Install/maintain stable temporary construction entrances(s)", "Entire Development", + "Individual Building Lot(s)", + "Address silt fence issues which includes one or more of the following: Repair, install properly, Replace, Add (areas prone to sheet-flow erosion)", + "Install erosions and sediment control for individual building lot(s) as specified in the approved SWP3", + "Install check dam(s) according to specifications", + "Utilize appropriate construction sequence as specified in the approved SWP3", + "Remove sediment from one or more of the following: sediment traps, behind check dams, around storm drain inlets or/and other", + "Inform Contractors, subcontractors, material vendors, and others or erosion and sediment control requirements", + "Provide copy and self-monitoring inspection records to MS Coordinator within 48 hours", + "Acquire copy of Storm Water Pollution Prevention Plan and retain on project site for reference" + )); + FormElementPickerMulti correctiveActionsPickerMulti = FormElementPickerMulti.createInstance().setTitle("Corrective Actions").setOptions(correctiveActionsOptions).setPickerTitle("Pick corrective action"); + + FormElementTextMultiLine otherCorrectiveAction1TextField = FormElementTextMultiLine.createInstance().setTitle("Other 1:").setHint("Enter text here"); + FormElementTextMultiLine otherCorrectiveAction2TextField = FormElementTextMultiLine.createInstance().setTitle("Other 2:").setHint("Enter text here"); + FormElementTextMultiLine otherCorrectiveAction3TextField = FormElementTextMultiLine.createInstance().setTitle("Other 3:").setHint("Enter text here"); + + + FormHeader enforcementActionHeader = FormHeader.createInstance("ENFORCEMENT ACTIONS"); + List enforcementActionOptions = new ArrayList<>(Arrays.asList( + "Notice of Violation Issued", + "Stop Work Order Issued", + "Fine(s) Issued", + "Other" + )); + FormElementPickerSingle enforcementActionPickerSingle = FormElementPickerSingle.createInstance().setTitle("Inspection type:").setOptions(enforcementActionOptions).setPickerTitle("Pick inspection type"); + + FormElementTextMultiLine evidenceTextField = FormElementTextMultiLine.createInstance().setTitle("Evidence of off-site sediment/pollutants.\nHere is a description of type and location:").setHint("Enter text here"); + + List formItems = new ArrayList<>(); + + formItems.add(projectTextField); + formItems.add(addressTextField); + formItems.add(inspectorTextField); + formItems.add(dataInspectedDatePicker); + + formItems.add(inspectionTypePickerSingle); + formItems.add(projectRepPresentSwitch); + + formItems.add(stakeholdersHeader); + formItems.add(projectManagerTextField); + formItems.add(siteManagerTextField); + formItems.add(projectOwnerTextField); + + formItems.add(correctiveActionsHeader); + formItems.add(correctiveActionsPickerMulti); + formItems.add(otherCorrectiveAction1TextField); + formItems.add(otherCorrectiveAction2TextField); + formItems.add(otherCorrectiveAction3TextField); + + formItems.add(enforcementActionHeader); + formItems.add(enforcementActionPickerSingle); + + formItems.add(evidenceTextField); + + formBuilder.addFormElements(formItems); + + } +} diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/home/HomeFragment.java b/app/src/main/java/com/sf/stormwaterutilityandroid/home/HomeFragment.java index 7809a22..75b11d9 100644 --- a/app/src/main/java/com/sf/stormwaterutilityandroid/home/HomeFragment.java +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/home/HomeFragment.java @@ -10,6 +10,7 @@ import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; +import com.sf.stormwaterutilityandroid.InspectionForm; import com.sf.stormwaterutilityandroid.R; import com.sf.stormwaterutilityandroid.SampleFordm; @@ -31,6 +32,15 @@ public void onClick(View view) { } }); + b1 = root.findViewById(R.id.button2); + b1.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + startActivity(new Intent(getContext(), InspectionForm.class)); + } + }); + + //CHeck To5a.03 project for dealing saved instance state /* if (savedInstanceState != null) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 85a4fdb..381a669 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -46,4 +46,6 @@ Registered Successfully! An email has been sent to verify your email; this must be done before logging in. Sign in + + \ No newline at end of file From 4172104d7214222225be38b84eb11abfcb5feca7 Mon Sep 17 00:00:00 2001 From: IbrahimSaeedPurdue <54752803+IbrahimSaeedPurdue@users.noreply.github.com> Date: Thu, 11 Feb 2021 16:24:02 -0500 Subject: [PATCH 02/15] feature/added submit button listener --- .../stormwaterutilityandroid/InspectionForm.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java b/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java index d39429e..0098a52 100644 --- a/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java @@ -1,6 +1,7 @@ package com.sf.stormwaterutilityandroid; import android.os.Bundle; +import android.view.View; import android.widget.Button; import androidx.appcompat.app.AppCompatActivity; @@ -31,6 +32,7 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sample_fordm); recyclerView = findViewById(R.id.recyclerView2); + setupForm(); } @@ -38,8 +40,6 @@ protected void onCreate(Bundle savedInstanceState) { private void setupForm() { formBuilder = new FormBuilder(this, recyclerView); - - FormElementTextSingleLine projectTextField = FormElementTextSingleLine.createInstance().setTitle("Project/Contact:").setHint("Enter text here"); FormElementTextSingleLine addressTextField = FormElementTextSingleLine.createInstance().setTitle("Address/Lot#(s):").setHint("Enter text here"); FormElementTextSingleLine inspectorTextField = FormElementTextSingleLine.createInstance().setTitle("Inspector:").setHint("Enter name here"); @@ -96,6 +96,15 @@ private void setupForm() { FormElementTextMultiLine evidenceTextField = FormElementTextMultiLine.createInstance().setTitle("Evidence of off-site sediment/pollutants.\nHere is a description of type and location:").setHint("Enter text here"); + Button submitButton = new Button(getApplicationContext()); + submitButton.setText("Submit"); + submitButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + } + }); + List formItems = new ArrayList<>(); formItems.add(projectTextField); @@ -122,7 +131,8 @@ private void setupForm() { formItems.add(evidenceTextField); - formBuilder.addFormElements(formItems); + formBuilder.addFormElements(formItems); + recyclerView.addView(submitButton); } } From 042f8d49b2b873f8a2dad67a0930a996d8f2057c Mon Sep 17 00:00:00 2001 From: IbrahimSaeedPurdue <54752803+IbrahimSaeedPurdue@users.noreply.github.com> Date: Wed, 3 Mar 2021 15:59:14 -0500 Subject: [PATCH 03/15] feature/created constructionFormData class and populated it in actionListener --- .../InspectionForm.java | 160 +++++++++++++----- 1 file changed, 113 insertions(+), 47 deletions(-) diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java b/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java index d4b0d62..975ca71 100644 --- a/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java @@ -9,6 +9,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; import java.util.List; import me.riddhimanadib.formmaster.FormBuilder; @@ -17,9 +18,7 @@ import me.riddhimanadib.formmaster.model.FormElementPickerMulti; import me.riddhimanadib.formmaster.model.FormElementPickerSingle; import me.riddhimanadib.formmaster.model.FormElementSwitch; -import me.riddhimanadib.formmaster.model.FormElementTextEmail; import me.riddhimanadib.formmaster.model.FormElementTextMultiLine; -import me.riddhimanadib.formmaster.model.FormElementTextPhone; import me.riddhimanadib.formmaster.model.FormElementTextSingleLine; import me.riddhimanadib.formmaster.model.FormHeader; @@ -105,49 +104,6 @@ private void setupForm() { FormElementTextMultiLine evidenceTextField = FormElementTextMultiLine.createInstance().setTitle("Evidence of off-site sediment/pollutants.\nHere is a description of type and location:").setHint("Enter text here"); - submitButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - System.out.println("HELLO"); - String projectContact = projectTextField.getValue(); - String address = addressTextField.getValue(); - String inspector = inspectorTextField.getValue(); - String dateInspected = dateInspectedDatePicker.getValue(); - - boolean projectRepPresent = getSwitchBool(projectRepPresentSwitch.getValue()); - - String projectManager = projectManagerTextField.getValue(); - String siteManager = siteManagerTextField.getValue(); - String projectOwner = projectOwnerTextField.getValue(); - - boolean correctiveAction1 = getSwitchBool(correctiveAction1Switch.getValue()); - boolean correctiveAction2 = getSwitchBool(correctiveAction2Switch.getValue()); - boolean correctiveAction3 = getSwitchBool(correctiveAction3Switch.getValue()); - boolean correctiveAction4 = getSwitchBool(correctiveAction4Switch.getValue()); - - List correctiveAction5 = correctiveAction5Multi.getOptionsSelected(); - - boolean correctiveAction6 = getSwitchBool(correctiveAction6Switch.getValue()); - boolean correctiveAction7 = getSwitchBool(correctiveAction6Switch.getValue()); - boolean correctiveAction8 = getSwitchBool(correctiveAction8Switch.getValue()); - boolean correctiveAction9 = getSwitchBool(correctiveAction9Switch.getValue()); - - String correctiveAction10 = correctiveAction10Multi.getValue(); - - String otherCorrectiveAction1 = otherCorrectiveAction1TextField.getValue(); - String otherCorrectiveAction2 = otherCorrectiveAction2TextField.getValue(); - String otherCorrectiveAction3 = otherCorrectiveAction3TextField.getValue(); - - List enforcementAction = enforcementActionPickerSingle.getOptionsSelected(); - - String evidence = evidenceTextField.getValue(); - - - } - }); - - - List formItems = new ArrayList<>(); formItems.add(projectTextField); @@ -192,13 +148,123 @@ public void onClick(View view) { formItems.add(evidenceTextField); - + // populate formBuilder with items formBuilder.addFormElements(formItems); + // onSubmit + submitButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + String contact = projectTextField.getValue(); + String location = addressTextField.getValue(); + String inspector = inspectorTextField.getValue(); + String date = dateInspectedDatePicker.getValue(); + + ArrayList answersList = new ArrayList<>(20); + + boolean projectRepPresent = getSwitchBool(projectRepPresentSwitch.getValue()); + answersList.add(projectRepPresent + ""); + + String projectManager = projectManagerTextField.getValue(); + String siteManager = siteManagerTextField.getValue(); + String projectOwner = projectOwnerTextField.getValue(); + answersList.add(projectManager); + answersList.add(siteManager); + answersList.add(projectOwner); + + boolean correctiveAction1 = getSwitchBool(correctiveAction1Switch.getValue()); + boolean correctiveAction2 = getSwitchBool(correctiveAction2Switch.getValue()); + boolean correctiveAction3 = getSwitchBool(correctiveAction3Switch.getValue()); + boolean correctiveAction4 = getSwitchBool(correctiveAction4Switch.getValue()); + answersList.add(correctiveAction1 + ""); + answersList.add(correctiveAction2 + ""); + answersList.add(correctiveAction3 + ""); + answersList.add(correctiveAction4 + ""); + + List correctiveAction5 = correctiveAction5Multi.getOptionsSelected(); + answersList.addAll(correctiveAction5); + + boolean correctiveAction6 = getSwitchBool(correctiveAction6Switch.getValue()); + boolean correctiveAction7 = getSwitchBool(correctiveAction6Switch.getValue()); + boolean correctiveAction8 = getSwitchBool(correctiveAction8Switch.getValue()); + boolean correctiveAction9 = getSwitchBool(correctiveAction9Switch.getValue()); + answersList.add(correctiveAction6 + ""); + answersList.add(correctiveAction7 + ""); + answersList.add(correctiveAction8 + ""); + answersList.add(correctiveAction9 + ""); + + String correctiveAction10 = correctiveAction10Multi.getValue(); + answersList.add(correctiveAction10); + + String otherCorrectiveAction1 = otherCorrectiveAction1TextField.getValue(); + String otherCorrectiveAction2 = otherCorrectiveAction2TextField.getValue(); + String otherCorrectiveAction3 = otherCorrectiveAction3TextField.getValue(); + answersList.add(otherCorrectiveAction1); + answersList.add(otherCorrectiveAction2); + answersList.add(otherCorrectiveAction3); + + + List enforcementAction = enforcementActionPickerSingle.getOptionsSelected(); + answersList.addAll(enforcementAction); + + String[] imgLink = new String[]{evidenceTextField.getValue()}; + + + String[] answers = answersList.toArray(new String[0]); + // System.out.println(Arrays.toString(answers)); + ConstructionFormData constructionFormData = new ConstructionFormData(contact, date, inspector, location, answers, imgLink); + System.out.println(constructionFormData); + } + }); + + + + } - public boolean getSwitchBool(String value) { + private boolean getSwitchBool(String value) { if (value.equals("yes")) return true; return false; } + + private class ConstructionFormData { + String contact = ""; + String date = ""; + String inspector = ""; + String location = ""; + String[] answers; + + // SortTimeStamp set in constructor + Date SortTimeStamp; + + String[] imgLink; + + public ConstructionFormData(String contact, String date, String inspector, + String location, String[] answers, String[] imgLink) { + this.contact = contact; + this.date = date; + this.inspector = inspector; + this.location = location; + this.answers = answers; + + this.SortTimeStamp = new Date(System.currentTimeMillis()); + + this.answers = answers; + } + + + + @Override + public String toString() { + return "ConstructionFormData{" + + "contact=" + contact + '\n' + + ", date=" + date + '\n' + + ", inspector=" + inspector + '\n' + + ", location=" + location + '\n' + + ", answers=" + Arrays.toString(answers) + "\n" + + ", SortTimeStamp=" + SortTimeStamp + "\n" + + ", imgLink=" + Arrays.toString(imgLink) + "\n" + + '}'; + } + } } From 9c2ca342bfad444cc7e10593ae4d1b96f08be75d Mon Sep 17 00:00:00 2001 From: IbrahimSaeedPurdue <54752803+IbrahimSaeedPurdue@users.noreply.github.com> Date: Thu, 4 Mar 2021 14:44:24 -0500 Subject: [PATCH 04/15] feature/added FireStore functionality feature/update form to take in title/Strings of switches rather booleans (as strings) --- app/build.gradle | 1 + app/google-services.json | 39 +++++ .../InspectionForm.java | 150 +++++++++++------- build.gradle | 1 + 4 files changed, 132 insertions(+), 59 deletions(-) create mode 100644 app/google-services.json diff --git a/app/build.gradle b/app/build.gradle index 19093dd..eea8c58 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,5 +1,6 @@ plugins { id 'com.android.application' + id 'com.google.gms.google-services' } android { diff --git a/app/google-services.json b/app/google-services.json new file mode 100644 index 0000000..50b3497 --- /dev/null +++ b/app/google-services.json @@ -0,0 +1,39 @@ +{ + "project_info": { + "project_number": "715047227500", + "project_id": "auth-test-978bd", + "storage_bucket": "auth-test-978bd.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:715047227500:android:6d404969351cf9a715c849", + "android_client_info": { + "package_name": "com.sf.stormwaterutilityandroid" + } + }, + "oauth_client": [ + { + "client_id": "715047227500-l993hj8oukroedqgtmuecookfmhjp1co.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyDdVIxvfzkh1W0PCJ985hizZLthG6MrjJc" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "715047227500-l993hj8oukroedqgtmuecookfmhjp1co.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java b/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java index 975ca71..a9f8580 100644 --- a/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java @@ -4,13 +4,20 @@ import android.view.View; import android.widget.Button; +import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.RecyclerView; +import com.google.android.gms.tasks.OnFailureListener; +import com.google.android.gms.tasks.OnSuccessListener; +import com.google.firebase.firestore.DocumentReference; +import com.google.firebase.firestore.FirebaseFirestore; + import java.util.ArrayList; import java.util.Arrays; -import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import me.riddhimanadib.formmaster.FormBuilder; import me.riddhimanadib.formmaster.model.BaseFormElement; @@ -162,8 +169,8 @@ public void onClick(View view) { ArrayList answersList = new ArrayList<>(20); - boolean projectRepPresent = getSwitchBool(projectRepPresentSwitch.getValue()); - answersList.add(projectRepPresent + ""); + String projectRepPresent = getSwitchString(projectRepPresentSwitch); + answersList.add(projectRepPresent); String projectManager = projectManagerTextField.getValue(); String siteManager = siteManagerTextField.getValue(); @@ -172,26 +179,26 @@ public void onClick(View view) { answersList.add(siteManager); answersList.add(projectOwner); - boolean correctiveAction1 = getSwitchBool(correctiveAction1Switch.getValue()); - boolean correctiveAction2 = getSwitchBool(correctiveAction2Switch.getValue()); - boolean correctiveAction3 = getSwitchBool(correctiveAction3Switch.getValue()); - boolean correctiveAction4 = getSwitchBool(correctiveAction4Switch.getValue()); - answersList.add(correctiveAction1 + ""); - answersList.add(correctiveAction2 + ""); - answersList.add(correctiveAction3 + ""); - answersList.add(correctiveAction4 + ""); + String correctiveAction1 = getSwitchString(correctiveAction1Switch); + String correctiveAction2 = getSwitchString(correctiveAction2Switch); + String correctiveAction3 = getSwitchString(correctiveAction3Switch); + String correctiveAction4 = getSwitchString(correctiveAction4Switch); + answersList.add(correctiveAction1); + answersList.add(correctiveAction2); + answersList.add(correctiveAction3); + answersList.add(correctiveAction4); List correctiveAction5 = correctiveAction5Multi.getOptionsSelected(); answersList.addAll(correctiveAction5); - boolean correctiveAction6 = getSwitchBool(correctiveAction6Switch.getValue()); - boolean correctiveAction7 = getSwitchBool(correctiveAction6Switch.getValue()); - boolean correctiveAction8 = getSwitchBool(correctiveAction8Switch.getValue()); - boolean correctiveAction9 = getSwitchBool(correctiveAction9Switch.getValue()); - answersList.add(correctiveAction6 + ""); - answersList.add(correctiveAction7 + ""); - answersList.add(correctiveAction8 + ""); - answersList.add(correctiveAction9 + ""); + String correctiveAction6 = getSwitchString(correctiveAction6Switch); + String correctiveAction7 = getSwitchString(correctiveAction6Switch); + String correctiveAction8 = getSwitchString(correctiveAction8Switch); + String correctiveAction9 = getSwitchString(correctiveAction9Switch); + answersList.add(correctiveAction6); + answersList.add(correctiveAction7); + answersList.add(correctiveAction8); + answersList.add(correctiveAction9); String correctiveAction10 = correctiveAction10Multi.getValue(); answersList.add(correctiveAction10); @@ -207,64 +214,89 @@ public void onClick(View view) { List enforcementAction = enforcementActionPickerSingle.getOptionsSelected(); answersList.addAll(enforcementAction); - String[] imgLink = new String[]{evidenceTextField.getValue()}; + String imgLink = new String(evidenceTextField.getValue()); String[] answers = answersList.toArray(new String[0]); - // System.out.println(Arrays.toString(answers)); - ConstructionFormData constructionFormData = new ConstructionFormData(contact, date, inspector, location, answers, imgLink); - System.out.println(constructionFormData); + ConstructionFormData constructionFormData = new ConstructionFormData(contact, date, inspector, location, answersList, imgLink); + + FirebaseFirestore db = FirebaseFirestore.getInstance(); + db.collection("ConstructionSiteForm") + .add(constructionFormData.getMap()) + .addOnSuccessListener(new OnSuccessListener() { + @Override + public void onSuccess(DocumentReference documentReference) { + System.out.println("ibra SUCCESSFUL - FIRESTORE"); + } + }) + .addOnFailureListener(new OnFailureListener() { + @Override + public void onFailure(@NonNull Exception e) { + System.out.println("ibra SUCCESSFUL - ERROR/FAILED: " + e); + } + }); + + // System.out.println(constructionFormData); } }); - - } - private boolean getSwitchBool(String value) { - if (value.equals("yes")) return true; - return false; + private String getSwitchString(FormElementSwitch switchElement) { + System.out.println(switchElement.getValue()); + if (switchElement.getValue().equals("Yes")) return switchElement.getTitle(); + return ""; } private class ConstructionFormData { - String contact = ""; - String date = ""; - String inspector = ""; - String location = ""; - String[] answers; - +// String contact = ""; +// String date = ""; +// String inspector = ""; +// String location = ""; +// String[] answers; // SortTimeStamp set in constructor - Date SortTimeStamp; +// Date SortTimeStamp; +// +// String[] imgLink; - String[] imgLink; + Map data = new HashMap<>(); public ConstructionFormData(String contact, String date, String inspector, - String location, String[] answers, String[] imgLink) { - this.contact = contact; - this.date = date; - this.inspector = inspector; - this.location = location; - this.answers = answers; - - this.SortTimeStamp = new Date(System.currentTimeMillis()); - - this.answers = answers; + String location, List answers, String imgLink) { + data.put("contact", contact); + data.put("date", date); + data.put("inspector", inspector); + data.put("location", location); + data.put("answers", answers); + data.put("imgLink", imgLink); + +// this.contact = contact; +// this.date = date; +// this.inspector = inspector; +// this.location = location; +// this.answers = answers; +// +// this.SortTimeStamp = new Date(System.currentTimeMillis()); +// +// this.answers = answers; } - - - @Override - public String toString() { - return "ConstructionFormData{" + - "contact=" + contact + '\n' + - ", date=" + date + '\n' + - ", inspector=" + inspector + '\n' + - ", location=" + location + '\n' + - ", answers=" + Arrays.toString(answers) + "\n" + - ", SortTimeStamp=" + SortTimeStamp + "\n" + - ", imgLink=" + Arrays.toString(imgLink) + "\n" + - '}'; + public Map getMap() { + return data; } + +// @Override +// public String toString() { +// return "ConstructionFormData{" + +// "contact=" + contact + '\n' + +// ", date=" + date + '\n' + +// ", inspector=" + inspector + '\n' + +// ", location=" + location + '\n' + +// ", answers=" + Arrays.toString(answers) + "\n" + +// ", SortTimeStamp=" + SortTimeStamp + "\n" + +// ", imgLink=" + Arrays.toString(imgLink) + "\n" + +// '}'; +// } } } diff --git a/build.gradle b/build.gradle index 4d24be2..6a4ea19 100644 --- a/build.gradle +++ b/build.gradle @@ -6,6 +6,7 @@ buildscript { } dependencies { classpath "com.android.tools.build:gradle:4.1.1" + classpath 'com.google.gms:google-services:4.3.5' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files From 5af5a1cbb00127166a16ed9a21b07b34b21f7335 Mon Sep 17 00:00:00 2001 From: IbrahimSaeedPurdue <54752803+IbrahimSaeedPurdue@users.noreply.github.com> Date: Thu, 4 Mar 2021 16:43:06 -0500 Subject: [PATCH 05/15] refactor/made ConstructionFormData.java into a public class refactor/answer switches (in List answers) give "true"/"false" in firebase refactor/clean up all comments and unused code --- .../ConstructionFormData.java | 40 ++++++ .../InspectionForm.java | 120 ++++++------------ 2 files changed, 76 insertions(+), 84 deletions(-) create mode 100644 app/src/main/java/com/sf/stormwaterutilityandroid/ConstructionFormData.java diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/ConstructionFormData.java b/app/src/main/java/com/sf/stormwaterutilityandroid/ConstructionFormData.java new file mode 100644 index 0000000..a66ec46 --- /dev/null +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/ConstructionFormData.java @@ -0,0 +1,40 @@ +package com.sf.stormwaterutilityandroid; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ConstructionFormData { + private Map data; + // String contact + // String date + // String inspector + // String location + + // (they are lists because firebase doesn't serialize arrays) + // List answers + // List imgLink + + public ConstructionFormData(String contact, String date, String inspector, + String location, List answers, List imgLink) { + data = new HashMap<>(); + data.put("contact", contact); + data.put("date", date); + data.put("inspector", inspector); + data.put("location", location); + data.put("answers", answers); + data.put("imgLink", imgLink); + } + + public Map getMap() { + return data; + } + + @Override + public String toString() { + return "ConstructionFormData{" + + "data=" + data + + '}'; + } + +} diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java b/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java index a9f8580..f8a16f1 100644 --- a/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java @@ -15,9 +15,7 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.List; -import java.util.Map; import me.riddhimanadib.formmaster.FormBuilder; import me.riddhimanadib.formmaster.model.BaseFormElement; @@ -45,6 +43,23 @@ protected void onCreate(Bundle savedInstanceState) { setupForm(); } + private void uploadToFirestore(ConstructionFormData constructionFormData) { + FirebaseFirestore db = FirebaseFirestore.getInstance(); + db.collection("ConstructionSiteForm") + .add(constructionFormData.getMap()) + .addOnSuccessListener(new OnSuccessListener() { + @Override + public void onSuccess(DocumentReference documentReference) { + System.out.println("SUCCESSFUL - FIRESTORE"); + } + }) + .addOnFailureListener(new OnFailureListener() { + @Override + public void onFailure(@NonNull Exception e) { + System.out.println("FAILED - FIRESTORE: " + e); + } + }); + } private void setupForm() { formBuilder = new FormBuilder(this, recyclerView); @@ -162,6 +177,8 @@ private void setupForm() { submitButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { + + // data retrieval from forms String contact = projectTextField.getValue(); String location = addressTextField.getValue(); String inspector = inspectorTextField.getValue(); @@ -169,7 +186,7 @@ public void onClick(View view) { ArrayList answersList = new ArrayList<>(20); - String projectRepPresent = getSwitchString(projectRepPresentSwitch); + String projectRepPresent = getSwitchBool(projectRepPresentSwitch); answersList.add(projectRepPresent); String projectManager = projectManagerTextField.getValue(); @@ -179,10 +196,10 @@ public void onClick(View view) { answersList.add(siteManager); answersList.add(projectOwner); - String correctiveAction1 = getSwitchString(correctiveAction1Switch); - String correctiveAction2 = getSwitchString(correctiveAction2Switch); - String correctiveAction3 = getSwitchString(correctiveAction3Switch); - String correctiveAction4 = getSwitchString(correctiveAction4Switch); + String correctiveAction1 = getSwitchBool(correctiveAction1Switch); + String correctiveAction2 = getSwitchBool(correctiveAction2Switch); + String correctiveAction3 = getSwitchBool(correctiveAction3Switch); + String correctiveAction4 = getSwitchBool(correctiveAction4Switch); answersList.add(correctiveAction1); answersList.add(correctiveAction2); answersList.add(correctiveAction3); @@ -191,10 +208,10 @@ public void onClick(View view) { List correctiveAction5 = correctiveAction5Multi.getOptionsSelected(); answersList.addAll(correctiveAction5); - String correctiveAction6 = getSwitchString(correctiveAction6Switch); - String correctiveAction7 = getSwitchString(correctiveAction6Switch); - String correctiveAction8 = getSwitchString(correctiveAction8Switch); - String correctiveAction9 = getSwitchString(correctiveAction9Switch); + String correctiveAction6 = getSwitchBool(correctiveAction6Switch); + String correctiveAction7 = getSwitchBool(correctiveAction6Switch); + String correctiveAction8 = getSwitchBool(correctiveAction8Switch); + String correctiveAction9 = getSwitchBool(correctiveAction9Switch); answersList.add(correctiveAction6); answersList.add(correctiveAction7); answersList.add(correctiveAction8); @@ -214,89 +231,24 @@ public void onClick(View view) { List enforcementAction = enforcementActionPickerSingle.getOptionsSelected(); answersList.addAll(enforcementAction); - String imgLink = new String(evidenceTextField.getValue()); - + List imgLink = new ArrayList<>(); + imgLink.add(evidenceTextField.getValue()); String[] answers = answersList.toArray(new String[0]); ConstructionFormData constructionFormData = new ConstructionFormData(contact, date, inspector, location, answersList, imgLink); - FirebaseFirestore db = FirebaseFirestore.getInstance(); - db.collection("ConstructionSiteForm") - .add(constructionFormData.getMap()) - .addOnSuccessListener(new OnSuccessListener() { - @Override - public void onSuccess(DocumentReference documentReference) { - System.out.println("ibra SUCCESSFUL - FIRESTORE"); - } - }) - .addOnFailureListener(new OnFailureListener() { - @Override - public void onFailure(@NonNull Exception e) { - System.out.println("ibra SUCCESSFUL - ERROR/FAILED: " + e); - } - }); - - // System.out.println(constructionFormData); + + // submit data to firestore + uploadToFirestore(constructionFormData); } }); } - private String getSwitchString(FormElementSwitch switchElement) { - System.out.println(switchElement.getValue()); - if (switchElement.getValue().equals("Yes")) return switchElement.getTitle(); - return ""; + private String getSwitchBool(FormElementSwitch switchElement) { + if (switchElement.getValue().equals("Yes")) return "true"; + return "false"; } - private class ConstructionFormData { -// String contact = ""; -// String date = ""; -// String inspector = ""; -// String location = ""; -// String[] answers; - // SortTimeStamp set in constructor -// Date SortTimeStamp; -// -// String[] imgLink; - - Map data = new HashMap<>(); - - public ConstructionFormData(String contact, String date, String inspector, - String location, List answers, String imgLink) { - data.put("contact", contact); - data.put("date", date); - data.put("inspector", inspector); - data.put("location", location); - data.put("answers", answers); - data.put("imgLink", imgLink); - -// this.contact = contact; -// this.date = date; -// this.inspector = inspector; -// this.location = location; -// this.answers = answers; -// -// this.SortTimeStamp = new Date(System.currentTimeMillis()); -// -// this.answers = answers; - } - - public Map getMap() { - return data; - } - -// @Override -// public String toString() { -// return "ConstructionFormData{" + -// "contact=" + contact + '\n' + -// ", date=" + date + '\n' + -// ", inspector=" + inspector + '\n' + -// ", location=" + location + '\n' + -// ", answers=" + Arrays.toString(answers) + "\n" + -// ", SortTimeStamp=" + SortTimeStamp + "\n" + -// ", imgLink=" + Arrays.toString(imgLink) + "\n" + -// '}'; -// } - } } From 31317320c2405cf01ad3d887fb50d3da66d2e706 Mon Sep 17 00:00:00 2001 From: IbrahimSaeedPurdue <54752803+IbrahimSaeedPurdue@users.noreply.github.com> Date: Thu, 4 Mar 2021 16:45:43 -0500 Subject: [PATCH 06/15] refactor/made ConstructionFormData.java into a public class refactor/answer switches (in List answers) give "true"/"false" in firebase refactor/clean up all comments and unused code --- .../InspectionForm.java | 152 ++++++++---------- 1 file changed, 66 insertions(+), 86 deletions(-) diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java b/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java index f8a16f1..9efb51c 100644 --- a/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java @@ -1,16 +1,11 @@ package com.sf.stormwaterutilityandroid; import android.os.Bundle; -import android.view.View; import android.widget.Button; -import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.RecyclerView; -import com.google.android.gms.tasks.OnFailureListener; -import com.google.android.gms.tasks.OnSuccessListener; -import com.google.firebase.firestore.DocumentReference; import com.google.firebase.firestore.FirebaseFirestore; import java.util.ArrayList; @@ -28,7 +23,6 @@ import me.riddhimanadib.formmaster.model.FormHeader; public class InspectionForm extends AppCompatActivity { - private FormBuilder formBuilder; private RecyclerView recyclerView; private Button submitButton; @@ -47,22 +41,12 @@ private void uploadToFirestore(ConstructionFormData constructionFormData) { FirebaseFirestore db = FirebaseFirestore.getInstance(); db.collection("ConstructionSiteForm") .add(constructionFormData.getMap()) - .addOnSuccessListener(new OnSuccessListener() { - @Override - public void onSuccess(DocumentReference documentReference) { - System.out.println("SUCCESSFUL - FIRESTORE"); - } - }) - .addOnFailureListener(new OnFailureListener() { - @Override - public void onFailure(@NonNull Exception e) { - System.out.println("FAILED - FIRESTORE: " + e); - } - }); + .addOnSuccessListener(documentReference -> System.out.println("SUCCESSFUL - FIRESTORE")) + .addOnFailureListener(e -> System.out.println("FAILED - FIRESTORE: " + e)); } private void setupForm() { - formBuilder = new FormBuilder(this, recyclerView); + FormBuilder formBuilder = new FormBuilder(this, recyclerView); FormElementTextSingleLine projectTextField = FormElementTextSingleLine.createInstance().setTitle("Project/Contact:").setHint("Enter text here"); FormElementTextSingleLine addressTextField = FormElementTextSingleLine.createInstance().setTitle("Address/Lot#(s):").setHint("Enter text here"); @@ -174,73 +158,69 @@ private void setupForm() { formBuilder.addFormElements(formItems); // onSubmit - submitButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - - // data retrieval from forms - String contact = projectTextField.getValue(); - String location = addressTextField.getValue(); - String inspector = inspectorTextField.getValue(); - String date = dateInspectedDatePicker.getValue(); - - ArrayList answersList = new ArrayList<>(20); - - String projectRepPresent = getSwitchBool(projectRepPresentSwitch); - answersList.add(projectRepPresent); - - String projectManager = projectManagerTextField.getValue(); - String siteManager = siteManagerTextField.getValue(); - String projectOwner = projectOwnerTextField.getValue(); - answersList.add(projectManager); - answersList.add(siteManager); - answersList.add(projectOwner); - - String correctiveAction1 = getSwitchBool(correctiveAction1Switch); - String correctiveAction2 = getSwitchBool(correctiveAction2Switch); - String correctiveAction3 = getSwitchBool(correctiveAction3Switch); - String correctiveAction4 = getSwitchBool(correctiveAction4Switch); - answersList.add(correctiveAction1); - answersList.add(correctiveAction2); - answersList.add(correctiveAction3); - answersList.add(correctiveAction4); - - List correctiveAction5 = correctiveAction5Multi.getOptionsSelected(); - answersList.addAll(correctiveAction5); - - String correctiveAction6 = getSwitchBool(correctiveAction6Switch); - String correctiveAction7 = getSwitchBool(correctiveAction6Switch); - String correctiveAction8 = getSwitchBool(correctiveAction8Switch); - String correctiveAction9 = getSwitchBool(correctiveAction9Switch); - answersList.add(correctiveAction6); - answersList.add(correctiveAction7); - answersList.add(correctiveAction8); - answersList.add(correctiveAction9); - - String correctiveAction10 = correctiveAction10Multi.getValue(); - answersList.add(correctiveAction10); - - String otherCorrectiveAction1 = otherCorrectiveAction1TextField.getValue(); - String otherCorrectiveAction2 = otherCorrectiveAction2TextField.getValue(); - String otherCorrectiveAction3 = otherCorrectiveAction3TextField.getValue(); - answersList.add(otherCorrectiveAction1); - answersList.add(otherCorrectiveAction2); - answersList.add(otherCorrectiveAction3); - - - List enforcementAction = enforcementActionPickerSingle.getOptionsSelected(); - answersList.addAll(enforcementAction); - - List imgLink = new ArrayList<>(); - imgLink.add(evidenceTextField.getValue()); - - String[] answers = answersList.toArray(new String[0]); - ConstructionFormData constructionFormData = new ConstructionFormData(contact, date, inspector, location, answersList, imgLink); - - - // submit data to firestore - uploadToFirestore(constructionFormData); - } + submitButton.setOnClickListener(view -> { + + // data retrieval from forms + String contact = projectTextField.getValue(); + String location = addressTextField.getValue(); + String inspector = inspectorTextField.getValue(); + String date = dateInspectedDatePicker.getValue(); + + ArrayList answersList = new ArrayList<>(20); + + String projectRepPresent = getSwitchBool(projectRepPresentSwitch); + answersList.add(projectRepPresent); + + String projectManager = projectManagerTextField.getValue(); + String siteManager = siteManagerTextField.getValue(); + String projectOwner = projectOwnerTextField.getValue(); + answersList.add(projectManager); + answersList.add(siteManager); + answersList.add(projectOwner); + + String correctiveAction1 = getSwitchBool(correctiveAction1Switch); + String correctiveAction2 = getSwitchBool(correctiveAction2Switch); + String correctiveAction3 = getSwitchBool(correctiveAction3Switch); + String correctiveAction4 = getSwitchBool(correctiveAction4Switch); + answersList.add(correctiveAction1); + answersList.add(correctiveAction2); + answersList.add(correctiveAction3); + answersList.add(correctiveAction4); + + List correctiveAction5 = correctiveAction5Multi.getOptionsSelected(); + answersList.addAll(correctiveAction5); + + String correctiveAction6 = getSwitchBool(correctiveAction6Switch); + String correctiveAction7 = getSwitchBool(correctiveAction6Switch); + String correctiveAction8 = getSwitchBool(correctiveAction8Switch); + String correctiveAction9 = getSwitchBool(correctiveAction9Switch); + answersList.add(correctiveAction6); + answersList.add(correctiveAction7); + answersList.add(correctiveAction8); + answersList.add(correctiveAction9); + + String correctiveAction10 = correctiveAction10Multi.getValue(); + answersList.add(correctiveAction10); + + String otherCorrectiveAction1 = otherCorrectiveAction1TextField.getValue(); + String otherCorrectiveAction2 = otherCorrectiveAction2TextField.getValue(); + String otherCorrectiveAction3 = otherCorrectiveAction3TextField.getValue(); + answersList.add(otherCorrectiveAction1); + answersList.add(otherCorrectiveAction2); + answersList.add(otherCorrectiveAction3); + + + List enforcementAction = enforcementActionPickerSingle.getOptionsSelected(); + answersList.addAll(enforcementAction); + + List imgLink = new ArrayList<>(); + imgLink.add(evidenceTextField.getValue()); + + ConstructionFormData constructionFormData = new ConstructionFormData(contact, date, inspector, location, answersList, imgLink); + + + // submit data to firestore + uploadToFirestore(constructionFormData); }); From 31a995bd4c9e3b0b6c2a7b5bdaf5ab2668ae3dc8 Mon Sep 17 00:00:00 2001 From: IbrahimSaeedPurdue <54752803+IbrahimSaeedPurdue@users.noreply.github.com> Date: Thu, 4 Mar 2021 16:54:20 -0500 Subject: [PATCH 07/15] refactor/removed google-services.json (my own firebase testing database) --- app/google-services.json | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 app/google-services.json diff --git a/app/google-services.json b/app/google-services.json deleted file mode 100644 index 50b3497..0000000 --- a/app/google-services.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "project_info": { - "project_number": "715047227500", - "project_id": "auth-test-978bd", - "storage_bucket": "auth-test-978bd.appspot.com" - }, - "client": [ - { - "client_info": { - "mobilesdk_app_id": "1:715047227500:android:6d404969351cf9a715c849", - "android_client_info": { - "package_name": "com.sf.stormwaterutilityandroid" - } - }, - "oauth_client": [ - { - "client_id": "715047227500-l993hj8oukroedqgtmuecookfmhjp1co.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyDdVIxvfzkh1W0PCJ985hizZLthG6MrjJc" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "715047227500-l993hj8oukroedqgtmuecookfmhjp1co.apps.googleusercontent.com", - "client_type": 3 - } - ] - } - } - } - ], - "configuration_version": "1" -} \ No newline at end of file From b4b66bdcc22b0d80476e99254e99907a84f75978 Mon Sep 17 00:00:00 2001 From: Samuelford24 Date: Tue, 16 Mar 2021 19:47:59 -0400 Subject: [PATCH 08/15] fixed bugs --- app/build.gradle | 1 + app/google-services.json | 47 ++++ .../ConstructionReportsFragment.java | 97 +++++++- .../ConstructionFormData.java | 40 +++ .../ConstructionReportAdapter.java | 61 +++++ .../DryWeatherScreening.java | 3 +- .../com/sf/stormwaterutilityandroid/HEI.java | 82 ++++++ .../InspectionForm.java | 234 ++++++++++++++++++ .../ReportAdapter.java | 61 +++++ .../WaterWay/PTI.java | 39 +++ .../WaterWay/WQI.java | 31 +++ .../WaterWay/WaterWayNav.java | 115 +-------- .../WaterWay/WaterWayReportFragment.java | 108 +++++++- app/src/main/res/layout/activity_main.xml | 2 +- app/src/main/res/layout/activity_reports.xml | 96 +++++++ app/src/main/res/layout/cardview_reports.xml | 69 ++++++ app/src/main/res/menu/waterway_menu.xml | 4 + build.gradle | 3 +- 18 files changed, 965 insertions(+), 128 deletions(-) create mode 100644 app/google-services.json create mode 100644 app/src/main/java/com/sf/stormwaterutilityandroid/ConstructionFormData.java create mode 100644 app/src/main/java/com/sf/stormwaterutilityandroid/ConstructionReportAdapter.java create mode 100644 app/src/main/java/com/sf/stormwaterutilityandroid/HEI.java create mode 100644 app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java create mode 100644 app/src/main/java/com/sf/stormwaterutilityandroid/ReportAdapter.java create mode 100644 app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/PTI.java create mode 100644 app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/WQI.java create mode 100644 app/src/main/res/layout/activity_reports.xml create mode 100644 app/src/main/res/layout/cardview_reports.xml create mode 100644 app/src/main/res/menu/waterway_menu.xml diff --git a/app/build.gradle b/app/build.gradle index 19093dd..eea8c58 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,5 +1,6 @@ plugins { id 'com.android.application' + id 'com.google.gms.google-services' } android { diff --git a/app/google-services.json b/app/google-services.json new file mode 100644 index 0000000..2545b5d --- /dev/null +++ b/app/google-services.json @@ -0,0 +1,47 @@ +{ + "project_info": { + "project_number": "667793859590", + "firebase_url": "https://aquasource-f5e44.firebaseio.com", + "project_id": "aquasource-f5e44", + "storage_bucket": "aquasource-f5e44.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:667793859590:android:8b4d04aebf855291eb8f87", + "android_client_info": { + "package_name": "com.sf.stormwaterutilityandroid" + } + }, + "oauth_client": [ + { + "client_id": "667793859590-o1vcunhlqe559bvuuetrkj6hels7bisl.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyDbkcA22JD0-r8h4Xu6dcMGMwHpSKyvFc8" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "667793859590-o1vcunhlqe559bvuuetrkj6hels7bisl.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "667793859590-kstclkrr6eial9patuhafmclk7p34re2.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "EPICS.StormWaterUtility" + } + } + ] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/Construction/ConstructionReportsFragment.java b/app/src/main/java/com/sf/stormwaterutilityandroid/Construction/ConstructionReportsFragment.java index c24b425..a41edd4 100644 --- a/app/src/main/java/com/sf/stormwaterutilityandroid/Construction/ConstructionReportsFragment.java +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/Construction/ConstructionReportsFragment.java @@ -1,25 +1,112 @@ package com.sf.stormwaterutilityandroid.Construction; import android.os.Bundle; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProvider; +import androidx.recyclerview.widget.DefaultItemAnimator; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import com.google.firebase.firestore.DocumentSnapshot; +import com.google.firebase.firestore.EventListener; +import com.google.firebase.firestore.FirebaseFirestore; +import com.google.firebase.firestore.FirebaseFirestoreException; +import com.google.firebase.firestore.Query; +import com.google.firebase.firestore.QuerySnapshot; + +import com.sf.stormwaterutilityandroid.ConstructionFormData; +import com.sf.stormwaterutilityandroid.ConstructionReportAdapter; import com.sf.stormwaterutilityandroid.R; + +import java.util.ArrayList; +import java.util.List; + public class ConstructionReportsFragment extends Fragment { + private EditText searchBar; + private RecyclerView recyclerView; + private Button btnSiteName, btnDate, btnInspectorName; + //TODO: Need vars for formdata + + //TODO: Need a var for tvReports: UITableView! + List reportList = new ArrayList<>(); + //TODO: LayoutInflator inflater, ViewGroup container,Might not be needed + //This was a public void + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + + View view = inflater.inflate(R.layout.activity_reports, container, false); + recyclerView = view.findViewById(R.id.recyclerView); + + + + btnSiteName = view.findViewById(R.id.btn_site_name); + btnDate = view.findViewById(R.id.btn_date); + btnInspectorName = view.findViewById(R.id.btn_inspector_name); + searchBar = view.findViewById(R.id.searchView); + recyclerView = view.findViewById(R.id.recyclerView); + + fetchData(); + btnSiteName.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //startActivity(new Intent(Reports.this, Site_name.class)); - public View onCreateView(@NonNull LayoutInflater inflater, - ViewGroup container, Bundle savedInstanceState) { - View root = inflater.inflate(R.layout.fragment_dashboard, container, false); - final TextView textView = root.findViewById(R.id.text_dashboard); - return root; + } + }); + + btnDate.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //startActivity(new Intent(Reports.this, Date.class)); + } + }); + + btnInspectorName.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //startActivity(new Intent(Reports.this, Inspector_name.class)); + } + }); + + return view; + + + + } + public void fetchData() { + final ConstructionReportAdapter reporter = new ConstructionReportAdapter(reportList); + FirebaseFirestore.getInstance().collection("ConstructionForms").orderBy("SortTimeStamp", Query.Direction.DESCENDING).addSnapshotListener(new EventListener() { + @Override + public void onEvent(@javax.annotation.Nullable QuerySnapshot queryDocumentSnapshots, @javax.annotation.Nullable FirebaseFirestoreException e) { + if (e != null) { + Log.i("Error", "No data"); + } + reportList.clear(); + for (DocumentSnapshot d:queryDocumentSnapshots){ + //needs to be changed to waterway data type + reportList.add( d.toObject(ConstructionFormData.class)); + } + + reporter.notifyDataSetChanged(); + } + }); + RecyclerView.LayoutManager layoutmanager = new LinearLayoutManager(getContext()); + recyclerView.setLayoutManager(layoutmanager); + recyclerView.setItemAnimator(new DefaultItemAnimator()); + recyclerView.setAdapter(reporter); } + } \ No newline at end of file diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/ConstructionFormData.java b/app/src/main/java/com/sf/stormwaterutilityandroid/ConstructionFormData.java new file mode 100644 index 0000000..a66ec46 --- /dev/null +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/ConstructionFormData.java @@ -0,0 +1,40 @@ +package com.sf.stormwaterutilityandroid; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ConstructionFormData { + private Map data; + // String contact + // String date + // String inspector + // String location + + // (they are lists because firebase doesn't serialize arrays) + // List answers + // List imgLink + + public ConstructionFormData(String contact, String date, String inspector, + String location, List answers, List imgLink) { + data = new HashMap<>(); + data.put("contact", contact); + data.put("date", date); + data.put("inspector", inspector); + data.put("location", location); + data.put("answers", answers); + data.put("imgLink", imgLink); + } + + public Map getMap() { + return data; + } + + @Override + public String toString() { + return "ConstructionFormData{" + + "data=" + data + + '}'; + } + +} diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/ConstructionReportAdapter.java b/app/src/main/java/com/sf/stormwaterutilityandroid/ConstructionReportAdapter.java new file mode 100644 index 0000000..ceab9b7 --- /dev/null +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/ConstructionReportAdapter.java @@ -0,0 +1,61 @@ +package com.sf.stormwaterutilityandroid; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.recyclerview.widget.RecyclerView; + +import java.util.List; + +public class ConstructionReportAdapter extends RecyclerView.Adapter{ + //needs changed to waterway + List listdata; + + public ConstructionReportAdapter(List listdata) { + this.listdata = listdata; + } + + @Override + public ConstructionReportAdapter.MyHolder onCreateViewHolder(ViewGroup parent, int viewType) { + + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.cardview_reports,parent,false); + + ConstructionReportAdapter.MyHolder myHolder = new ConstructionReportAdapter.MyHolder(view); + return myHolder; + } + + + public void onBindViewHolder(ConstructionReportAdapter.MyHolder holder, final int position) { + + final ConstructionFormData data = listdata.get(position); + //holder.inspectorName.setText(data.getInspectorName()); + // holder.site.setText(data.getSite()); + // holder.date.setText((CharSequence) data.getDate()); + + + } + + @Override + public int getItemCount() { + return listdata.size(); + } + + + class MyHolder extends RecyclerView.ViewHolder{ + TextView inspectorName,site,date; + + public MyHolder(View itemView) { + super(itemView); + inspectorName = (TextView) itemView.findViewById(R.id.inspectorName); + site = (TextView) itemView.findViewById(R.id.siteName); + date = (TextView) itemView.findViewById(R.id.date); + } + } + + +} + + + diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/DryWeatherScreening.java b/app/src/main/java/com/sf/stormwaterutilityandroid/DryWeatherScreening.java index 8220c5a..6bec762 100644 --- a/app/src/main/java/com/sf/stormwaterutilityandroid/DryWeatherScreening.java +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/DryWeatherScreening.java @@ -23,6 +23,7 @@ import me.riddhimanadib.formmaster.model.FormElementTextSingleLine; import me.riddhimanadib.formmaster.model.FormHeader; + public class DryWeatherScreening extends AppCompatActivity{ private FormBuilder formBuilder; @@ -80,4 +81,4 @@ private void setupForm() { formBuilder.addFormElements(formItems); } -} +} \ No newline at end of file diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/HEI.java b/app/src/main/java/com/sf/stormwaterutilityandroid/HEI.java new file mode 100644 index 0000000..a803dee --- /dev/null +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/HEI.java @@ -0,0 +1,82 @@ +package com.sf.stormwaterutilityandroid; + +public class HEI { + //by default, all values are set to be 0 + private double QHEI_substrate_size = 0; + private double QHEI_smothering = 0; + private double QHEI_silting = 0; + private double QHEI_rootwads = 0; + private double QHEI_overhanging_veg = 0; + private double QHEI_oxbowsblack_waters = 0; + private double QHEI_downed_treeslogs = 0; + private double QHEI_shallows = 0; + private double QHEI_water_plants = 0; + private double QHEI_deep_pools = 0; + private double QHEI_logswoody_debris = 0; + private double QHEI_boulders = 0; + private double QHEI_undercut_banks = 0; + private double QHEI_sinuosity = 0; + private double QHEI_natural = 0; + private double QHEI_riparian_width = 0; + private double QHEI_land_use = 0; + private double QHEI_bank_erosion = 0; + private double QHEI_stream_shading = 0; + private double QHEI_deepest_pool = 0; + private double QHEI_velocity = 0; + private double QHEI_rifflerun_depth = 0; + private double QHEI_rifflerun_substrate = 0; + + //constructor + HEI(double QHEI_substrate_size, double QHEI_smothering, double QHEI_silting, double QHEI_rootwads, double QHEI_overhanging_veg, + double QHEI_oxbowsblack_waters, double QHEI_downed_treeslogs, double QHEI_shallows, double QHEI_water_plants, double QHEI_logswoody_debris, + double QHEI_boulders, double QHEI_undercut_banks, double QHEI_sinuosity, double QHEI_natural, double QHEI_riparian_width, + double QHEI_land_use, double QHEI_bank_erosion, double QHEI_stream_shading, double QHEI_deepest_pool, double QHEI_velocity, + double QHEI_rifflerun_depth, double QHEI_rifflerun_substrate, double QHEI_deep_pools) { + + this.QHEI_substrate_size = QHEI_substrate_size; + this.QHEI_smothering = QHEI_smothering; + this.QHEI_silting = QHEI_silting; + this.QHEI_rootwads = QHEI_rootwads; + this.QHEI_overhanging_veg = QHEI_overhanging_veg; + this.QHEI_oxbowsblack_waters = QHEI_oxbowsblack_waters; + this.QHEI_downed_treeslogs = QHEI_downed_treeslogs; + this.QHEI_shallows = QHEI_shallows; + this.QHEI_water_plants = QHEI_water_plants; + this.QHEI_logswoody_debris = QHEI_logswoody_debris; + this.QHEI_boulders = QHEI_boulders; + this.QHEI_undercut_banks = QHEI_undercut_banks; + this.QHEI_sinuosity = QHEI_sinuosity; + this.QHEI_natural = QHEI_natural; + this.QHEI_riparian_width = QHEI_riparian_width; + this.QHEI_land_use = QHEI_land_use; + this.QHEI_bank_erosion = QHEI_bank_erosion; + this.QHEI_stream_shading = QHEI_stream_shading; + this.QHEI_deepest_pool = QHEI_deepest_pool; + this.QHEI_velocity = QHEI_velocity; + this.QHEI_rifflerun_depth = QHEI_rifflerun_depth; + this.QHEI_rifflerun_substrate = QHEI_rifflerun_substrate; + this.QHEI_deep_pools = QHEI_deep_pools; + } + + public double calculate_HEI() { + return QHEI_substrate_size + QHEI_smothering + QHEI_silting + QHEI_rootwads + QHEI_overhanging_veg + + QHEI_oxbowsblack_waters + QHEI_downed_treeslogs + QHEI_shallows + QHEI_water_plants + QHEI_deep_pools + + QHEI_logswoody_debris + QHEI_boulders + QHEI_undercut_banks + 2 * (QHEI_sinuosity + QHEI_natural) + + QHEI_riparian_width + QHEI_land_use + QHEI_bank_erosion + QHEI_stream_shading + QHEI_deepest_pool + + QHEI_velocity + QHEI_rifflerun_depth + QHEI_rifflerun_substrate; + } + + public static double get_HEI(double QHEI_substrate_size, double QHEI_smothering, double QHEI_silting, double QHEI_rootwads, double QHEI_overhanging_veg, + double QHEI_oxbowsblack_waters, double QHEI_downed_treeslogs, double QHEI_shallows, double QHEI_water_plants, double QHEI_logswoody_debris, + double QHEI_boulders, double QHEI_undercut_banks, double QHEI_sinuosity, double QHEI_natural, double QHEI_riparian_width, + double QHEI_land_use, double QHEI_bank_erosion, double QHEI_stream_shading, double QHEI_deepest_pool, double QHEI_velocity, + double QHEI_rifflerun_depth, double QHEI_rifflerun_substrate, double QHEI_deep_pools) + { + return QHEI_substrate_size + QHEI_smothering + QHEI_silting + QHEI_rootwads + QHEI_overhanging_veg + + QHEI_oxbowsblack_waters + QHEI_downed_treeslogs + QHEI_shallows + QHEI_water_plants + QHEI_deep_pools + + QHEI_logswoody_debris + QHEI_boulders + QHEI_undercut_banks + 2 * (QHEI_sinuosity + QHEI_natural) + + QHEI_riparian_width + QHEI_land_use + QHEI_bank_erosion + QHEI_stream_shading + QHEI_deepest_pool + + QHEI_velocity + QHEI_rifflerun_depth + QHEI_rifflerun_substrate; + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java b/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java new file mode 100644 index 0000000..9e8a740 --- /dev/null +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java @@ -0,0 +1,234 @@ +package com.sf.stormwaterutilityandroid; + +import android.os.Bundle; +import android.widget.Button; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.RecyclerView; + +import com.google.firebase.firestore.FirebaseFirestore; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import me.riddhimanadib.formmaster.FormBuilder; +import me.riddhimanadib.formmaster.model.BaseFormElement; +import me.riddhimanadib.formmaster.model.FormElementPickerDate; +import me.riddhimanadib.formmaster.model.FormElementPickerMulti; +import me.riddhimanadib.formmaster.model.FormElementPickerSingle; +import me.riddhimanadib.formmaster.model.FormElementSwitch; +import me.riddhimanadib.formmaster.model.FormElementTextMultiLine; +import me.riddhimanadib.formmaster.model.FormElementTextSingleLine; +import me.riddhimanadib.formmaster.model.FormHeader; + +public class InspectionForm extends AppCompatActivity { + private RecyclerView recyclerView; + private Button submitButton; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_sample_fordm); + recyclerView = findViewById(R.id.recyclerView2); + + // submitButton = findViewById(R.id.submitButton); + + setupForm(); + } + + private void uploadToFirestore(ConstructionFormData constructionFormData) { + FirebaseFirestore db = FirebaseFirestore.getInstance(); + db.collection("ConstructionSiteForm") + .add(constructionFormData.getMap()) + .addOnSuccessListener(documentReference -> System.out.println("SUCCESSFUL - FIRESTORE")) + .addOnFailureListener(e -> System.out.println("FAILED - FIRESTORE: " + e)); + } + + private void setupForm() { + FormBuilder formBuilder = new FormBuilder(this, recyclerView); + + FormElementTextSingleLine projectTextField = FormElementTextSingleLine.createInstance().setTitle("Project/Contact:").setHint("Enter text here"); + FormElementTextSingleLine addressTextField = FormElementTextSingleLine.createInstance().setTitle("Address/Lot#(s):").setHint("Enter text here"); + FormElementTextSingleLine inspectorTextField = FormElementTextSingleLine.createInstance().setTitle("Inspector:").setHint("Enter name here"); + FormElementPickerDate dateInspectedDatePicker = FormElementPickerDate.createInstance().setTitle("Date Inspected:").setDateFormat("MMM dd, yyyy"); + + + List typeOptions = new ArrayList<>(Arrays.asList( + "Routine Evaluation", + "Re-Inspection", + "Complaint Investigation", + "Entire Development", + "Individual Building Lot(s)" + )); + FormElementPickerSingle inspectionTypePickerSingle = FormElementPickerSingle.createInstance().setTitle("Inspection type:").setOptions(typeOptions).setPickerTitle("Pick inspection type"); + + FormElementSwitch projectRepPresentSwitch = FormElementSwitch.createInstance().setTitle("Project Representative Present?").setSwitchTexts("Yes", "No"); + + FormHeader stakeholdersHeader = FormHeader.createInstance("THE FOLLOWING INDIVIDUALS BECAME AWARE OF ANY ISSUES THOUGH DISCUSSION AND REVIEW OF FINDINGS ON THE DAY OF INSPECTION:"); + FormElementTextSingleLine projectManagerTextField = FormElementTextSingleLine.createInstance().setTitle("Project Manager:").setHint("Enter name here"); + FormElementTextSingleLine siteManagerTextField = FormElementTextSingleLine.createInstance().setTitle("Site Manager:").setHint("Enter name here"); + FormElementTextSingleLine projectOwnerTextField = FormElementTextSingleLine.createInstance().setTitle("Project Owner").setHint("Enter name here"); + + + FormHeader correctiveActionsHeader = FormHeader.createInstance("CORRECTIVE ACTIONS REQUIRED\n***REDER TO APPROVED STORM WATER POLLUTION PREVENTION PLAN (SWP3) FOR SPECIFICATIONS AND DETAILS ON ITEMS BELOW***"); + + + FormElementSwitch correctiveAction1Switch = FormElementSwitch.createInstance().setTitle("Post a laminated copy of completed 327IAC15-5 \"Rule 5\" NOI with permit number at a location visible to the public").setSwitchTexts("Yes", "No"); + FormElementSwitch correctiveAction2Switch = FormElementSwitch.createInstance().setTitle("Remove accumulated sediment from streets sidewalks and gutters (do not flush with water)").setSwitchTexts("Yes", "No"); + FormElementSwitch correctiveAction3Switch = FormElementSwitch.createInstance().setTitle("Install/maintain stable temporary construction entrances(s)\", \"Entire Development").setSwitchTexts("Yes", "No"); + FormElementSwitch correctiveAction4Switch = FormElementSwitch.createInstance().setTitle("Individual Building Lot(s)").setSwitchTexts("Yes", "No"); + + FormHeader correctiveAction5Header = FormHeader.createInstance(""); + List correctiveAction5Options= new ArrayList<>(Arrays.asList("Repair", "Install properly"," Replace", "Add (areas prone to sheet-flow erosion)")); + FormElementPickerMulti correctiveAction5Multi = FormElementPickerMulti.createInstance().setTitle("Address silt fence issues which includes one or more of the following: Repair, install properly, Replace, Add (areas prone to sheet-flow erosion)").setOptions(correctiveAction5Options).setPickerTitle("Address silt fence issues which includes one or more of the following:"); + + FormElementSwitch correctiveAction6Switch = FormElementSwitch.createInstance().setTitle("Install erosions and sediment control for individual building lot(s) as specified in the approved SWP3").setSwitchTexts("Yes", "No"); + FormElementSwitch correctiveAction7Switch = FormElementSwitch.createInstance().setTitle("Install check dam(s) according to specifications").setSwitchTexts("Yes", "No"); + FormElementSwitch correctiveAction8Switch = FormElementSwitch.createInstance().setTitle("Utilize appropriate construction sequence as specified in the approved SWP3").setSwitchTexts("Yes", "No"); + FormElementSwitch correctiveAction9Switch = FormElementSwitch.createInstance().setTitle("Individual Building Lot(s)").setSwitchTexts("Yes", "No"); + + FormHeader correctiveAction10Header = FormHeader.createInstance(""); + List correctiveAction10Options= new ArrayList<>(Arrays.asList("sediment traps", "behind check dams", "around storm drain inlets or/and other")); + FormElementPickerMulti correctiveAction10Multi = FormElementPickerMulti.createInstance().setTitle("Remove sediment from one or more of the following: sediment traps, behind check dams, around storm drain inlets or/and other").setOptions(correctiveAction10Options).setPickerTitle("Pick corrective action"); + + + FormElementTextMultiLine otherCorrectiveAction1TextField = FormElementTextMultiLine.createInstance().setTitle("Other 1:").setHint("Enter text here"); + FormElementTextMultiLine otherCorrectiveAction2TextField = FormElementTextMultiLine.createInstance().setTitle("Other 2:").setHint("Enter text here"); + FormElementTextMultiLine otherCorrectiveAction3TextField = FormElementTextMultiLine.createInstance().setTitle("Other 3:").setHint("Enter text here"); + + + FormHeader enforcementActionHeader = FormHeader.createInstance("ENFORCEMENT ACTIONS"); + List enforcementActionOptions = new ArrayList<>(Arrays.asList( + "Notice of Violation Issued", + "Stop Work Order Issued", + "Fine(s) Issued", + "Other" + )); + FormElementPickerSingle enforcementActionPickerSingle = FormElementPickerSingle.createInstance().setTitle("Inspection type:").setOptions(enforcementActionOptions).setPickerTitle("Pick inspection type"); + + FormElementTextMultiLine evidenceTextField = FormElementTextMultiLine.createInstance().setTitle("Evidence of off-site sediment/pollutants.\nHere is a description of type and location:").setHint("Enter text here"); + + + List formItems = new ArrayList<>(); + + formItems.add(projectTextField); + formItems.add(addressTextField); + formItems.add(inspectorTextField); + formItems.add(dateInspectedDatePicker); + + formItems.add(inspectionTypePickerSingle); + formItems.add(projectRepPresentSwitch); + + formItems.add(stakeholdersHeader); + formItems.add(projectManagerTextField); + formItems.add(siteManagerTextField); + formItems.add(projectOwnerTextField); + + formItems.add(correctiveActionsHeader); + + formItems.add(correctiveAction1Switch); + formItems.add(correctiveAction2Switch); + formItems.add(correctiveAction3Switch); + formItems.add(correctiveAction4Switch); + + formItems.add(correctiveAction5Header); + formItems.add(correctiveAction5Multi); + formItems.add(correctiveAction5Header); + + formItems.add(correctiveAction7Switch); + formItems.add(correctiveAction8Switch); + formItems.add(correctiveAction9Switch); + + formItems.add(correctiveAction10Header); + formItems.add(correctiveAction10Multi); + formItems.add(correctiveAction10Header); + + + formItems.add(otherCorrectiveAction1TextField); + formItems.add(otherCorrectiveAction2TextField); + formItems.add(otherCorrectiveAction3TextField); + + formItems.add(enforcementActionHeader); + formItems.add(enforcementActionPickerSingle); + + formItems.add(evidenceTextField); + + // populate formBuilder with items + formBuilder.addFormElements(formItems); + + // onSubmit + submitButton.setOnClickListener(view -> { + + // data retrieval from forms + String contact = projectTextField.getValue(); + String location = addressTextField.getValue(); + String inspector = inspectorTextField.getValue(); + String date = dateInspectedDatePicker.getValue(); + + ArrayList answersList = new ArrayList<>(20); + + String projectRepPresent = getSwitchBool(projectRepPresentSwitch); + answersList.add(projectRepPresent); + + String projectManager = projectManagerTextField.getValue(); + String siteManager = siteManagerTextField.getValue(); + String projectOwner = projectOwnerTextField.getValue(); + answersList.add(projectManager); + answersList.add(siteManager); + answersList.add(projectOwner); + + String correctiveAction1 = getSwitchBool(correctiveAction1Switch); + String correctiveAction2 = getSwitchBool(correctiveAction2Switch); + String correctiveAction3 = getSwitchBool(correctiveAction3Switch); + String correctiveAction4 = getSwitchBool(correctiveAction4Switch); + answersList.add(correctiveAction1); + answersList.add(correctiveAction2); + answersList.add(correctiveAction3); + answersList.add(correctiveAction4); + + List correctiveAction5 = correctiveAction5Multi.getOptionsSelected(); + answersList.addAll(correctiveAction5); + + String correctiveAction6 = getSwitchBool(correctiveAction6Switch); + String correctiveAction7 = getSwitchBool(correctiveAction6Switch); + String correctiveAction8 = getSwitchBool(correctiveAction8Switch); + String correctiveAction9 = getSwitchBool(correctiveAction9Switch); + answersList.add(correctiveAction6); + answersList.add(correctiveAction7); + answersList.add(correctiveAction8); + answersList.add(correctiveAction9); + + String correctiveAction10 = correctiveAction10Multi.getValue(); + answersList.add(correctiveAction10); + + String otherCorrectiveAction1 = otherCorrectiveAction1TextField.getValue(); + String otherCorrectiveAction2 = otherCorrectiveAction2TextField.getValue(); + String otherCorrectiveAction3 = otherCorrectiveAction3TextField.getValue(); + answersList.add(otherCorrectiveAction1); + answersList.add(otherCorrectiveAction2); + answersList.add(otherCorrectiveAction3); + + + List enforcementAction = enforcementActionPickerSingle.getOptionsSelected(); + answersList.addAll(enforcementAction); + + List imgLink = new ArrayList<>(); + imgLink.add(evidenceTextField.getValue()); + + ConstructionFormData constructionFormData = new ConstructionFormData(contact, date, inspector, location, answersList, imgLink); + + + // submit data to firestore + uploadToFirestore(constructionFormData); + }); + + + } + + private String getSwitchBool(FormElementSwitch switchElement) { + if (switchElement.getValue().equals("Yes")) return "true"; + return "false"; + } + +} diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/ReportAdapter.java b/app/src/main/java/com/sf/stormwaterutilityandroid/ReportAdapter.java new file mode 100644 index 0000000..3e765dd --- /dev/null +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/ReportAdapter.java @@ -0,0 +1,61 @@ +package com.sf.stormwaterutilityandroid; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.recyclerview.widget.RecyclerView; + + public class ReportAdapter extends RecyclerView.Adapter{ + + // List listdata; + + // public ReportAdapter(List listdata) { + // this.listdata = listdata; + // } + + @Override + public ReportAdapter.MyHolder onCreateViewHolder(ViewGroup parent, int viewType) { + + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.cardview_reports,parent,false); + + ReportAdapter.MyHolder myHolder = new ReportAdapter.MyHolder(view); + return myHolder; + } + + + public void onBindViewHolder(ReportAdapter.MyHolder holder, final int position) { + + // final Report data = listdata.get(position); + // holder.inspectorName.setText(data.getInspectorName()); + // holder.site.setText(data.getSite()); + // holder.date.setText((CharSequence) data.getDate()); + + + } + + @Override + public int getItemCount() { + return 0; + } + + // @Override + // public int getItemCount() { + // return listdata.size(); + //} + + + class MyHolder extends RecyclerView.ViewHolder{ + TextView inspectorName,site,date; + + public MyHolder(View itemView) { + super(itemView); + inspectorName = (TextView) itemView.findViewById(R.id.inspectorName); + site = (TextView) itemView.findViewById(R.id.siteName); + date = (TextView) itemView.findViewById(R.id.date); + } + } + + +} diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/PTI.java b/app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/PTI.java new file mode 100644 index 0000000..c46ef0b --- /dev/null +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/PTI.java @@ -0,0 +1,39 @@ +package com.sf.stormwaterutilityandroid.WaterWay; + +public class PTI { + private double BM_intolerant = 0; + private double BM_moderately_tolerant = 0; + private double BM_fairly_tolerant = 0; + private double BM_very_tolerant = 0; + + PTI(double BM_intolerant, double BM_moderately_tolerant, double BM_fairly_tolerant, double BM_very_tolerant) { + this.BM_intolerant = BM_intolerant; + this.BM_moderately_tolerant = BM_moderately_tolerant; + this.BM_fairly_tolerant = BM_fairly_tolerant; + this.BM_very_tolerant = BM_very_tolerant; + } + + public void setBM_intolerant(double value) { + BM_intolerant = value; + } + + public void setBM_moderately_tolerant(double value) { + BM_moderately_tolerant = value; + } + + public void setBM_fairly_tolerant(double value) { + BM_fairly_tolerant = value; + } + + public void setBM_very_tolerant(double value) { + BM_very_tolerant = value; + } + + public double calculatePTI() { + return 4.0 * BM_intolerant + 3.0 * BM_moderately_tolerant + 2.0 * BM_fairly_tolerant + 1.0 * BM_very_tolerant; + } + + public static double getPTI(double intolerant, double moderate, double fairly, double very) { + return 4.0 * intolerant + 3.0 * moderate + 2.0 * fairly + 1.0 * very; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/WQI.java b/app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/WQI.java new file mode 100644 index 0000000..0426992 --- /dev/null +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/WQI.java @@ -0,0 +1,31 @@ +package com.sf.stormwaterutilityandroid.WaterWay; + +public class WQI { + private double CT_temperature_change = 0; + private double CT_turbidity = 0; + private double CT_pH = 0; + private double CT_nitrate = 0; + private double CT_total_phosphate = 0; + private double CT_dissolved_oxygen = 0; + + WQI(double CT_temperature_change, double CT_turbidity, double CT_pH, double CT_nitrate, double CT_total_phosphate, + double CT_dissolved_oxygen) { + this.CT_temperature_change = CT_temperature_change; + this.CT_turbidity = CT_turbidity; + this.CT_pH = CT_pH; + this.CT_nitrate = CT_nitrate; + this.CT_total_phosphate = CT_total_phosphate; + this.CT_dissolved_oxygen = CT_dissolved_oxygen; + } + + public double calculateWQI() { + double WQIScore = CT_temperature_change * 0.11 + CT_turbidity * 0.09 + CT_pH * 0.12 + CT_nitrate * 0.1 + + CT_total_phosphate * 0.11 + CT_dissolved_oxygen * 0.18; + + return WQIScore; + } + + public static double getWQI(double tempChange, double turbidity, double pH, double nitrate, double phosphate, double oxygen) { + return tempChange * 0.11 + turbidity * 0.09 + pH * 0.12 + nitrate * 0.1 + phosphate * 0.11 + oxygen * 0.18; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/WaterWayNav.java b/app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/WaterWayNav.java index fbfc264..b851df5 100644 --- a/app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/WaterWayNav.java +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/WaterWayNav.java @@ -13,8 +13,6 @@ import com.google.android.material.bottomnavigation.BottomNavigationView; import com.google.firebase.auth.FirebaseAuth; import com.sf.stormwaterutilityandroid.R; -import com.sf.stormwaterutilityandroid.WaterWay.WaterWayReportFragment; -import com.sf.stormwaterutilityandroid.WaterWay.WaterWayFormFragment; public class WaterWayNav extends AppCompatActivity { @@ -53,115 +51,4 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) { return false; } }; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - // Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - //setSupportActionBar(toolbar); - - - BottomNavigationView navigation = findViewById(R.id.navigation); - navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); - // fm.beginTransaction().add(R.id.main_container, fragment5, "5").hide(fragment5).commit(); - // fm.beginTransaction().add(R.id.main_container, fragment4, "4").hide(fragment4).commit(); - - fm.beginTransaction().add(R.id.main_container, fragment2, "2").hide(fragment2).commit(); - fm.beginTransaction().add(R.id.main_container, fragment1, "1").commit(); - - } - - /* @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - signout2 = (Button) findViewById(R.id.sign_out); - - signout2.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - FirebaseAuth.getInstance().signOut(); - startActivity(new Intent(com.samuelford48gmail.thsconnect.teacher.MainActivity.this, LoginActivity.class)); - finish(); - } - }); - - - mTextMessage = (TextView) findViewById(R.id.message); - BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation); - navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); - - } - - FirebaseAuth.AuthStateListener authListener = new FirebaseAuth.AuthStateListener() { - @SuppressLint("SetTextI18n") - @Override - public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { - FirebaseUser user = firebaseAuth.getCurrentUser(); - if (user == null) { - // user auth state is changed - user is null - // launch login activity - startActivity(new Intent(com.samuelford48gmail.thsconnect.teacher.MainActivity.this, LoginActivity.class)); - finish(); - } - } - - - }; - // public void signout (View v){ - // signOut(); - //} -/* - public void signOut() { - auth.signOut(); - - -// this listener will be called when there is change in firebase user session - FirebaseAuth.AuthStateListener authListener = new FirebaseAuth.AuthStateListener() { - @Override - public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { - FirebaseUser user = firebaseAuth.getCurrentUser(); - if (user == null) { - // user auth state is changed - user is null - // launch login activity - startActivity(new Intent(com.samuelford48gmail.thsconnect.teacher.MainActivity.this, LoginActivity.class)); - finish(); - } - } - }; - - } - - - @Override - public void onStart() { - super.onStart(); - auth.addAuthStateListener(authListener); - } - - @Override - public void onStop() { - super.onStop(); - if (authListener != null) { - auth.removeAuthStateListener(authListener); - } - */ - /*@Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu., menu); - return super.onCreateOptionsMenu(menu); - } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - int id = item.getItemId(); - - if (id == R.id.action_settings) { - startActivity(new Intent(com.samuelford48gmail.thsconnect.teacher.MainActivity.this, SettingsActivity.class)); - return true; - } - - return super.onOptionsItemSelected(item); - } -*/ -} +}; diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/WaterWayReportFragment.java b/app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/WaterWayReportFragment.java index 150a98d..e944fe1 100644 --- a/app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/WaterWayReportFragment.java +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/WaterWayReportFragment.java @@ -1,28 +1,124 @@ package com.sf.stormwaterutilityandroid.WaterWay; import android.os.Bundle; +import android.util.Log; import android.view.LayoutInflater; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.SearchView; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProviders; +import androidx.recyclerview.widget.DefaultItemAnimator; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import com.google.android.material.bottomnavigation.BottomNavigationView; +import com.google.firebase.auth.FirebaseAuth; +import com.google.firebase.firestore.DocumentSnapshot; +import com.google.firebase.firestore.EventListener; +import com.google.firebase.firestore.FirebaseFirestore; +import com.google.firebase.firestore.FirebaseFirestoreException; +import com.google.firebase.firestore.Query; +import com.google.firebase.firestore.QuerySnapshot; +import com.sf.stormwaterutilityandroid.ConstructionReportAdapter; import com.sf.stormwaterutilityandroid.R; +import com.sf.stormwaterutilityandroid.ReportAdapter; + +import java.util.ArrayList; +import java.util.List; + public class WaterWayReportFragment extends Fragment { - public View onCreateView(@NonNull LayoutInflater inflater, - ViewGroup container, Bundle savedInstanceState) { + private SearchView searchBar;//TODO: Make a search bar later? + private RecyclerView recyclerView; + private Button btnSiteName, btnDate, btnInspectorName; + //TODO: Need vars for formdata + + //TODO: Need a var for tvReports: UITableView! + // List reportList = new ArrayList<>(); + //TODO: LayoutInflator inflater, ViewGroup container,Might not be needed + //This was a public void + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + + View view = inflater.inflate(R.layout.activity_reports, container, false); + recyclerView = view.findViewById(R.id.recyclerView); + + + + btnSiteName = view.findViewById(R.id.btn_site_name); + btnDate = view.findViewById(R.id.btn_date); + btnInspectorName = view.findViewById(R.id.btn_inspector_name); + searchBar = view.findViewById(R.id.searchView); + recyclerView = view.findViewById(R.id.recyclerView); + + fetchData(); + + btnSiteName.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //startActivity(new Intent(Reports.this, Site_name.class)); + + } + }); + + btnDate.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //startActivity(new Intent(Reports.this, Date.class)); + } + }); - View root = inflater.inflate(R.layout.fragment_dashboard, container, false); - final TextView textView = root.findViewById(R.id.text_dashboard); + btnInspectorName.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //startActivity(new Intent(Reports.this, Inspector_name.class)); + } + }); - return root; + return view; + + + + } + public void fetchData() { + /* final ReportAdapter reporter = new ReportAdapter(reportList); + FirebaseFirestore.getInstance().collection("AquaSourceForms").orderBy("SortTimeStamp", Query.Direction.DESCENDING).addSnapshotListener(new EventListener() { + @Override + public void onEvent(@javax.annotation.Nullable QuerySnapshot queryDocumentSnapshots, @javax.annotation.Nullable FirebaseFirestoreException e) { + if (e != null) { + Log.i("Error", "No data"); + } + reportList.clear(); + + for (DocumentSnapshot d:queryDocumentSnapshots){ + //needs to be changed to waterway data type + reportList.add( d.toObject(Report.class)); + } + + reporter.notifyDataSetChanged(); + } + }); + RecyclerView.LayoutManager layoutmanager = new LinearLayoutManager(getContext()); + recyclerView.setLayoutManager(layoutmanager); + recyclerView.setItemAnimator(new DefaultItemAnimator()); + recyclerView.setAdapter(reporter);*/ } -} \ No newline at end of file + +} + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 7c509bc..6a8db70 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -43,6 +43,6 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" - app:menu="@menu/bottom_nav_menu" /> + app:menu="@menu/waterway_menu" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_reports.xml b/app/src/main/res/layout/activity_reports.xml new file mode 100644 index 0000000..ea37db6 --- /dev/null +++ b/app/src/main/res/layout/activity_reports.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + +