-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from EPICSGroup/ibrahim
Ibrahim - Construction Site Form (without google-services.json)
- Loading branch information
Showing
10 changed files
with
347 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'com.google.gms.google-services' | ||
} | ||
|
||
android { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
app/src/main/java/com/sf/stormwaterutilityandroid/ConstructionFormData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String, Object> data; | ||
// String contact | ||
// String date | ||
// String inspector | ||
// String location | ||
|
||
// (they are lists because firebase doesn't serialize arrays) | ||
// List<String> answers | ||
// List<String> imgLink | ||
|
||
public ConstructionFormData(String contact, String date, String inspector, | ||
String location, List<String> answers, List<String> 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<String, Object> getMap() { | ||
return data; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ConstructionFormData{" + | ||
"data=" + data + | ||
'}'; | ||
} | ||
|
||
} |
234 changes: 234 additions & 0 deletions
234
app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> 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<String> 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<String> 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<String> 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<BaseFormElement> 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<String> 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<String> 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<String> enforcementAction = enforcementActionPickerSingle.getOptionsSelected(); | ||
answersList.addAll(enforcementAction); | ||
|
||
List<String> 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"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.