Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jparrell committed Apr 7, 2021
2 parents b7441be + 544a2f0 commit 2616290
Show file tree
Hide file tree
Showing 11 changed files with 542 additions and 161 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import me.riddhimanadib.formmaster.model.FormElementTextSingleLine;
import me.riddhimanadib.formmaster.model.FormHeader;


public class DryWeatherScreening extends AppCompatActivity{

private FormBuilder formBuilder;
Expand All @@ -37,64 +36,101 @@ public class DryWeatherScreening extends AppCompatActivity{
String maintenanceVal = "";
String screenVal = "";

FormElementTextEmail element11;
//I assume onCreate is important so I will leave it unchanged
boolean flowPres = false;
boolean odorPres = false;
boolean colorPres = false;
boolean polutantsPres = false;
boolean obstructionPres = false;
boolean needMaintenance = false;
boolean screenOK = false;

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_sample_fordm);
recyclerView = findViewById(R.id.recyclerView2);
recyclerView = findViewById(R.id.recyclerView2);
setupForm();
}

private void setupForm() {
formBuilder = new FormBuilder(this, recyclerView);
FormHeader title = (FormHeader) new FormHeader().setTitle("Dry Weather Screening");

//Outfall --> Question: How do you do a subheading?
FormElementTextSingleLine flow = new FormElementTextSingleLine().setTitle("Presence of Flow");
FormElementTextNumber flowData = FormElementTextNumber.createInstance(); //what data type is this?
flowVal = flowData.getValue();

FormElementTextSingleLine odor = new FormElementTextSingleLine().setTitle("Unusual Odor");
FormElementTextNumber odorData = FormElementTextNumber.createInstance();
odorVal = odorData.getValue();

FormElementTextSingleLine color = new FormElementTextSingleLine().setTitle("Unusual Color");
FormElementTextNumber colorData = FormElementTextNumber.createInstance();
colorVal = colorData.getValue();

FormElementTextSingleLine polutants = new FormElementTextSingleLine().setTitle("Polutants Nearby");
FormElementTextNumber polutantsData = FormElementTextNumber.createInstance();
polutantsVal = polutantsData.getValue();

FormElementTextSingleLine obstruction = new FormElementTextSingleLine().setTitle("Obstruction");
FormElementTextNumber obstructionData = FormElementTextNumber.createInstance();
obstructionVal = obstructionData.getValue();

FormElementTextSingleLine maintenance = new FormElementTextSingleLine().setTitle("Needs Maintenance");
FormElementTextNumber maintenanceData = FormElementTextNumber.createInstance();
maintenanceVal = maintenanceData.getValue();

FormElementTextSingleLine screen = new FormElementTextSingleLine().setTitle("Screen OK");
FormElementTextNumber screenData = FormElementTextNumber.createInstance();
screenVal = screenData.getValue();

List<BaseFormElement> formItems = new ArrayList<>();

FormHeader title = (FormHeader) new FormHeader().setTitle("Dry Weather Screening");
formItems.add(title);

FormElementSwitch flow = FormElementSwitch.createInstance().setTitle("Presence of Flow").setSwitchTexts("Yes", "No");
flowPres = convertToBoolean(flow.getValue());
formItems.add(flow);
formItems.add(flowData);

FormElementSwitch odor = FormElementSwitch.createInstance().setTitle("Unusual Odor").setSwitchTexts("Yes", "No");
odorVal = odor.getValue();
odorPres = convertToBoolean(odorVal);
formItems.add(odor);
formItems.add(odorData);

FormElementSwitch color = FormElementSwitch.createInstance().setTitle("Unusual Color").setSwitchTexts("Yes", "No");
colorVal = color.getValue();
colorPres = convertToBoolean(colorVal);
formItems.add(color);
formItems.add(colorData);

FormElementSwitch polutants = FormElementSwitch.createInstance().setTitle("Polutants Nearby").setSwitchTexts("Yes", "No");
polutantsVal = polutants.getValue();
polutantsPres = convertToBoolean(polutantsVal);
formItems.add(polutants);
formItems.add(polutantsData);

FormElementSwitch obstruction = FormElementSwitch.createInstance().setTitle("Obstruction").setSwitchTexts("Yes", "No");
obstructionVal = obstruction.getValue();
obstructionPres = convertToBoolean(obstructionVal);
formItems.add(obstruction);
formItems.add(obstructionData);

FormElementSwitch maintenance = FormElementSwitch.createInstance().setTitle("Needs Maintenance").setSwitchTexts("Yes", "No");
maintenanceVal = maintenance.getValue();
needMaintenance = convertToBoolean(maintenanceVal);
formItems.add(maintenance);
formItems.add(maintenanceData);

FormElementSwitch screen = FormElementSwitch.createInstance().setTitle("Screen OK").setSwitchTexts("Yes", "No");
screenVal = screen.getValue();
screenOK = convertToBoolean(screenVal);
formItems.add(screen);
formItems.add(screenData);


formBuilder.addFormElements(formItems);
}
}

public boolean getFlow() {
return flowPres;
}

public boolean getOdor() {
return odorPres;
}

public boolean getColor() {
return colorPres;
}

public boolean getPolutants() {
return polutantsPres;
}

public boolean getObstruction() {
return obstructionPres;
}

public boolean getMaintenance() {
return needMaintenance;
}

public boolean getScreen() {
return screenOK;
}

public boolean convertToBoolean(String s) {
if (s.compareTo("Yes") == 0) {
return true;
} else {
return false;
}
}
}

11 changes: 8 additions & 3 deletions app/src/main/java/com/sf/stormwaterutilityandroid/Login.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void onClick(View v) {
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

System.out.println("Execute:85");
String email = inputEmail.getText().toString();
final String password = inputPassword.getText().toString();

Expand All @@ -99,10 +99,13 @@ public void onClick(View v) {
progressBar.setVisibility(View.VISIBLE);

//authenticate user
auth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(Login.this, new OnCompleteListener<AuthResult>() {
System.out.println("Execute:102");
auth.signInWithEmailAndPassword(email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {


@Override
public void onComplete(@NonNull Task<AuthResult> task) {
System.out.println("Execute:106");
// If sign in fails, display a message to the user. If sign in succeeds
// the auth state listener will be notified and logic to handle the
// signed in user can be handled in the listener.
Expand All @@ -116,6 +119,7 @@ public void onComplete(@NonNull Task<AuthResult> task) {
}
} else {
if (auth.getCurrentUser().isEmailVerified()) {
System.out.println("Execute:122");
FirebaseFirestore.getInstance().collection("Users").document(auth.getUid()).get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
Expand All @@ -132,6 +136,7 @@ public void onComplete(@NonNull Task<DocumentSnapshot> task) {
progressBar.setVisibility(View.INVISIBLE);
finish();
} else {
System.out.println("Execute:139");
progressBar.setVisibility(View.INVISIBLE);
AlertDialog.Builder builder;
builder = new AlertDialog.Builder(Login.this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ public void onClick(View v) {
cvSettings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

Intent intent = new Intent(MainMenu.this, Settings.class);
startActivity(intent);

}
});
// launchWWF = findViewById(R.id.wwf);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@

import androidx.recyclerview.widget.RecyclerView;

public class ReportAdapter extends RecyclerView.Adapter<ReportAdapter.MyHolder>{
import com.sf.stormwaterutilityandroid.WaterWay.WaterWayReport;

// List<Report> listdata;
import java.util.List;

// public ReportAdapter(List<Report> listdata) {
// this.listdata = listdata;
// }
public class ReportAdapter extends RecyclerView.Adapter<ReportAdapter.MyHolder>{

List<WaterWayReport> listdata;
public ReportAdapter(List<WaterWayReport> listdata) {
this.listdata = listdata;
}

@Override
public ReportAdapter.MyHolder onCreateViewHolder(ViewGroup parent, int viewType) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.sf.stormwaterutilityandroid;
package com.sf.stormwaterutilityandroid.WaterWay;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;

import com.sf.stormwaterutilityandroid.R;

import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -37,82 +39,60 @@ public class ChemicalTesting extends AppCompatActivity{
double other1Val = 0.0;
double other2Val = 0.0;

FormElementTextEmail element11;
@Override
//I assume onCreate is important so I will leave it unchanged


protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_sample_fordm);
recyclerView = findViewById(R.id.recyclerView2);
recyclerView = findViewById(R.id.recyclerView2);
setupForm();
}

private void setupForm() {
formBuilder = new FormBuilder(this, recyclerView);

FormHeader title = (FormHeader) new FormHeader().setTitle("Chemical Testing");

//Outfall --> Question: How do you do a subheading?

FormElementTextSingleLine temperature = new FormElementTextSingleLine().setTitle("Temperature (C) Change");
//FormHeader temp = FormHeader.createInstance("Temperature (C) Change");
FormElementTextNumber tempData = FormElementTextNumber.createInstance(); //what data type is this?
tempVal = Double.parseDouble(tempData.getValue());
FormElementTextSingleLine temperature = new FormElementTextSingleLine().setTitle("Temperature (C) Change").setValue("0");
tempVal = Double.parseDouble(temperature.getValue());

FormElementTextSingleLine tubidity = new FormElementTextSingleLine().setTitle("Tubidity (NTU)");
FormElementTextNumber tubidityData = FormElementTextNumber.createInstance();
turbidityVal = Double.parseDouble(tubidityData.getValue());
FormElementTextSingleLine tubidity = new FormElementTextSingleLine().setTitle("Tubidity (NTU)").setValue("0");
turbidityVal = Double.parseDouble(tubidity.getValue());

FormElementTextSingleLine pH = new FormElementTextSingleLine().setTitle("pH");
FormElementTextNumber pHData = FormElementTextNumber.createInstance();
phVal = Double.parseDouble(pHData.getValue());
FormElementTextSingleLine pH = new FormElementTextSingleLine().setTitle("pH").setValue("0");
phVal = Double.parseDouble(pH.getValue());

FormElementTextSingleLine nitrate = new FormElementTextSingleLine().setTitle("Nitrate (mg/L)");
FormElementTextNumber nitrateData = FormElementTextNumber.createInstance();
nitrateVal = Double.parseDouble(nitrateData.getValue());
FormElementTextSingleLine nitrate = new FormElementTextSingleLine().setTitle("Nitrate (mg/L)").setValue("0");
nitrateVal = Double.parseDouble(nitrate.getValue());

FormElementTextSingleLine phosphate = new FormElementTextSingleLine().setTitle("Total Phosphate (mg/L)");
FormElementTextNumber phosphateData = FormElementTextNumber.createInstance();
phosphateVal = Double.parseDouble(nitrateData.getValue());
FormElementTextSingleLine phosphate = new FormElementTextSingleLine().setTitle("Total Phosphate (mg/L)").setValue("0");
phosphateVal = Double.parseDouble(phosphate.getValue());

FormElementTextSingleLine oxygen = new FormElementTextSingleLine().setTitle("Dissolved Oxygen (mg/L)");
FormElementTextNumber oxygenData = FormElementTextNumber.createInstance();
oxygenVal = Double.parseDouble(oxygenData.getValue());
FormElementTextSingleLine oxygen = new FormElementTextSingleLine().setTitle("Dissolved Oxygen (mg/L)").setValue("0");
oxygenVal = Double.parseDouble(oxygen.getValue());

FormElementTextSingleLine coli = new FormElementTextSingleLine().setTitle("E Coli (col/100mL)");
FormElementTextNumber coliData = FormElementTextNumber.createInstance();
coliVal = Double.parseDouble(coliData.getValue());
FormElementTextSingleLine coli = new FormElementTextSingleLine().setTitle("E Coli (col/100mL)").setValue("0");
coliVal = Double.parseDouble(coli.getValue());

FormElementTextSingleLine other1 = new FormElementTextSingleLine().setTitle("Other 1");
FormElementTextNumber other1Data = FormElementTextNumber.createInstance();
other1Val = Double.parseDouble(other1Data.getValue());
FormElementTextSingleLine other1 = new FormElementTextSingleLine().setTitle("Other 1").setValue("");
other1Val = Double.parseDouble(other1.getValue());

FormElementTextSingleLine other2 = new FormElementTextSingleLine().setTitle("Other 2");
FormElementTextNumber other2Data = FormElementTextNumber.createInstance();
FormElementTextSingleLine other2 = new FormElementTextSingleLine().setTitle("Other 2").setValue("");
other2Val = Double.parseDouble(other2.getValue());

List<BaseFormElement> formItems = new ArrayList<>();

formItems.add(title);
formItems.add(temperature);
formItems.add(tempData);
formItems.add(tubidity);
formItems.add(tubidityData);
formItems.add(pH);
formItems.add(pHData);
formItems.add(nitrate);
formItems.add(nitrateData);
formItems.add(phosphate);
formItems.add(phosphateData);
formItems.add(oxygen);
formItems.add(oxygenData);
formItems.add(coli);
formItems.add(coliData);
formItems.add(other1);
formItems.add(other1Data);
formItems.add(other2);
formItems.add(other2Data);

formBuilder.addFormElements(formItems);
}
Expand Down
Loading

0 comments on commit 2616290

Please sign in to comment.