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/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/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 0947cea..6b5108f 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -20,13 +20,14 @@
+ >
+
diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/Construction/ConstructionFormFragment.java b/app/src/main/java/com/sf/stormwaterutilityandroid/Construction/ConstructionFormFragment.java
index bb325fa..95b3678 100644
--- a/app/src/main/java/com/sf/stormwaterutilityandroid/Construction/ConstructionFormFragment.java
+++ b/app/src/main/java/com/sf/stormwaterutilityandroid/Construction/ConstructionFormFragment.java
@@ -4,22 +4,49 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.Button;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
+import androidx.recyclerview.widget.RecyclerView;
+import com.google.firebase.Timestamp;
+import com.google.type.DateTime;
import com.sf.stormwaterutilityandroid.R;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+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 ConstructionFormFragment extends Fragment {
+ private FormBuilder formBuilder;
+ private RecyclerView recyclerView;
+ private Button submitButton;
+ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- public View onCreateView(@NonNull LayoutInflater inflater,
- ViewGroup container, Bundle savedInstanceState) {
+ View root = inflater.inflate(R.layout.activity_sample_fordm, container, false);
- View root = inflater.inflate(R.layout.fragment_home, container, false);
+ recyclerView = root.findViewById(R.id.recyclerView2);
- return root;
+ recyclerView.addView(submitButton);
+ return root;
}
+
+
}
\ 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/InspectionForm.java b/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java
new file mode 100644
index 0000000..9efb51c
--- /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/WaterWay/WaterWayFormFragment.java b/app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/WaterWayFormFragment.java
index 6663fd4..806377b 100644
--- a/app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/WaterWayFormFragment.java
+++ b/app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/WaterWayFormFragment.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/layout/activity_sample_fordm.xml b/app/src/main/res/layout/activity_sample_fordm.xml
index bab35dc..7b0f1ef 100644
--- a/app/src/main/res/layout/activity_sample_fordm.xml
+++ b/app/src/main/res/layout/activity_sample_fordm.xml
@@ -5,9 +5,27 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SampleFordm">
+
+ android:id="@+id/recyclerView2"
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:layout_marginBottom="10dp"
+ app:layout_constraintBottom_toTopOf="@+id/submitButton"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintHorizontal_bias="1.0"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5a2d2b9..f113322 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -48,4 +48,6 @@
WaterWay
+
+
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 46397e1..1de4043 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,8 +5,13 @@ buildscript {
jcenter()
}
dependencies {
+
+
+ classpath 'com.google.gms:google-services:4.3.5'
+
classpath 'com.android.tools.build:gradle:4.1.2'
+
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}