From ffc61fb794fc9fb9196d80bb173d3d4b8a164a4d Mon Sep 17 00:00:00 2001 From: evanwilliams Date: Thu, 11 Mar 2021 14:35:44 -0500 Subject: [PATCH 01/43] SWU: WQI formulas --- .../com/sf/stormwaterutilityandroid/WQI.java | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 app/src/main/java/com/sf/stormwaterutilityandroid/WQI.java diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/WQI.java b/app/src/main/java/com/sf/stormwaterutilityandroid/WQI.java new file mode 100644 index 0000000..813c0dd --- /dev/null +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/WQI.java @@ -0,0 +1,108 @@ +package com.sf.stormwaterutilityandroid; + +public class WQI { + private double QHEI_substrate_size; + private double QHEI_smothering; + private double QHEI_silting; + private double QHEI_rootwads; + private double QHEI_overhanging_veg; + private double QHEI_oxbowsblack_waters; + private double QHEI_downed_treeslogs; + private double QHEI_shallows; + private double QHEI_water_plants; + private double QHEI_deep_pools; + private double QHEI_logswoody_debris; + private double QHEI_boulders; + private double QHEI_undercut_banks; + private double QHEI_sinuosity; + private double QHEI_natural; + private double QHEI_riparian_width; + private double QHEI_land_use; + private double QHEI_bank_erosion; + private double QHEI_stream_shading; + private double QHEI_deepest_pool; + private double QHEI_velocity; + private double QHEI_rifflerun_depth; + private double QHEI_rifflerun_substrate; + + //constructor + WQI(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; + } + + WQI() + { + QHEI_substrate_size = 0; + QHEI_smothering = 0; + QHEI_silting = 0; + QHEI_rootwads = 0; + QHEI_overhanging_veg = 0; + QHEI_oxbowsblack_waters = 0; + QHEI_downed_treeslogs = 0; + QHEI_shallows = 0; + QHEI_water_plants = 0; + QHEI_deep_pools = 0; + QHEI_logswoody_debris = 0; + QHEI_boulders = 0; + QHEI_undercut_banks = 0; + QHEI_sinuosity = 0; + QHEI_natural = 0; + QHEI_riparian_width = 0; + QHEI_land_use = 0; + QHEI_bank_erosion = 0; + QHEI_stream_shading = 0; + QHEI_deepest_pool = 0; + QHEI_velocity = 0; + QHEI_rifflerun_depth = 0; + QHEI_rifflerun_substrate = 0; + } + + public double calculate_WQI() { + 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_WQI(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; + } + +} From cf698ff7e54202c3672cb1c251d448dade7e8e72 Mon Sep 17 00:00:00 2001 From: evanwilliams Date: Thu, 11 Mar 2021 14:45:39 -0500 Subject: [PATCH 02/43] added PTI calculation --- .../WaterWay/PTI.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/PTI.java 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..9a4c346 --- /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; + } +} From 30cf3920a9648546dd7c127c3ff7f244b2253194 Mon Sep 17 00:00:00 2001 From: evanwilliams Date: Thu, 11 Mar 2021 16:29:59 -0500 Subject: [PATCH 03/43] SWU: HEI, not WQI --- .../{WQI.java => HEI.java} | 82 +++++++------------ 1 file changed, 28 insertions(+), 54 deletions(-) rename app/src/main/java/com/sf/stormwaterutilityandroid/{WQI.java => HEI.java} (67%) diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/WQI.java b/app/src/main/java/com/sf/stormwaterutilityandroid/HEI.java similarity index 67% rename from app/src/main/java/com/sf/stormwaterutilityandroid/WQI.java rename to app/src/main/java/com/sf/stormwaterutilityandroid/HEI.java index 813c0dd..1051afa 100644 --- a/app/src/main/java/com/sf/stormwaterutilityandroid/WQI.java +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/HEI.java @@ -1,32 +1,33 @@ package com.sf.stormwaterutilityandroid; -public class WQI { - private double QHEI_substrate_size; - private double QHEI_smothering; - private double QHEI_silting; - private double QHEI_rootwads; - private double QHEI_overhanging_veg; - private double QHEI_oxbowsblack_waters; - private double QHEI_downed_treeslogs; - private double QHEI_shallows; - private double QHEI_water_plants; - private double QHEI_deep_pools; - private double QHEI_logswoody_debris; - private double QHEI_boulders; - private double QHEI_undercut_banks; - private double QHEI_sinuosity; - private double QHEI_natural; - private double QHEI_riparian_width; - private double QHEI_land_use; - private double QHEI_bank_erosion; - private double QHEI_stream_shading; - private double QHEI_deepest_pool; - private double QHEI_velocity; - private double QHEI_rifflerun_depth; - private double QHEI_rifflerun_substrate; +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 - WQI(double QHEI_substrate_size, double QHEI_smothering, double QHEI_silting, double QHEI_rootwads, double QHEI_overhanging_veg, + 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, @@ -57,34 +58,7 @@ public class WQI { this.QHEI_deep_pools = QHEI_deep_pools; } - WQI() - { - QHEI_substrate_size = 0; - QHEI_smothering = 0; - QHEI_silting = 0; - QHEI_rootwads = 0; - QHEI_overhanging_veg = 0; - QHEI_oxbowsblack_waters = 0; - QHEI_downed_treeslogs = 0; - QHEI_shallows = 0; - QHEI_water_plants = 0; - QHEI_deep_pools = 0; - QHEI_logswoody_debris = 0; - QHEI_boulders = 0; - QHEI_undercut_banks = 0; - QHEI_sinuosity = 0; - QHEI_natural = 0; - QHEI_riparian_width = 0; - QHEI_land_use = 0; - QHEI_bank_erosion = 0; - QHEI_stream_shading = 0; - QHEI_deepest_pool = 0; - QHEI_velocity = 0; - QHEI_rifflerun_depth = 0; - QHEI_rifflerun_substrate = 0; - } - - public double calculate_WQI() { + 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) + @@ -92,7 +66,7 @@ public double calculate_WQI() { QHEI_velocity + QHEI_rifflerun_depth + QHEI_rifflerun_substrate; } - public static double get_WQI(double QHEI_substrate_size, double QHEI_smothering, double QHEI_silting, double QHEI_rootwads, double QHEI_overhanging_veg, + 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, From 625faf5cb332b6cb8edcde892b87166bc02b07b2 Mon Sep 17 00:00:00 2001 From: evanwilliams Date: Thu, 11 Mar 2021 16:39:11 -0500 Subject: [PATCH 04/43] added WQI --- .../WaterWay/WQI.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 app/src/main/java/com/sf/stormwaterutilityandroid/WaterWay/WQI.java 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..529fae8 --- /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; + } +} From b4b66bdcc22b0d80476e99254e99907a84f75978 Mon Sep 17 00:00:00 2001 From: Samuelford24 Date: Tue, 16 Mar 2021 19:47:59 -0400 Subject: [PATCH 05/43] 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 @@ + + + + + + + + + + + + + + + + + + +