-
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 #24 from EPICSGroup/Zan2
3/25/2021 changes with grapher and gradle and settings and androidman…
- Loading branch information
Showing
19 changed files
with
1,652 additions
and
5 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.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
196 changes: 196 additions & 0 deletions
196
app/src/main/java/com/sf/stormwaterutilityandroid/GraphPicker.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,196 @@ | ||
package com.sf.stormwaterutilityandroid; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.NumberPicker; | ||
import android.widget.Toast; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import com.anychart.anychart.AnyChart; | ||
import com.anychart.anychart.AnyChartView; | ||
import com.anychart.anychart.Cartesian; | ||
import com.anychart.anychart.DataEntry; | ||
import com.anychart.anychart.StrokeLineCap; | ||
import com.anychart.anychart.StrokeLineJoin; | ||
import com.anychart.anychart.ValueDataEntry; | ||
import com.google.android.gms.tasks.OnCompleteListener; | ||
import com.google.android.gms.tasks.Task; | ||
import com.google.firebase.auth.AuthResult; | ||
import com.google.firebase.auth.FirebaseAuth; | ||
import com.google.firebase.auth.FirebaseUser; | ||
import com.google.firebase.firestore.FirebaseFirestore; | ||
import com.google.firebase.firestore.Query; | ||
import com.google.firebase.firestore.QueryDocumentSnapshot; | ||
import com.google.firebase.firestore.QuerySnapshot; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class GraphPicker extends AppCompatActivity { | ||
private NumberPicker np1, np2, np3, np4, np5, np6, np7, np8; | ||
private Button btnGen; | ||
int docCount = 0; | ||
String sitePicked = new String(); | ||
String formPicked = new String(); | ||
String startMonthPicked = new String(); | ||
int startDayPicked = 0; | ||
int startYearPicked = 2000; | ||
String endMonthPicked = new String(); | ||
int endDayPicked = 0; | ||
int endYearPicked = 2000; | ||
|
||
//Added for firebase stuff | ||
private FirebaseAuth mAuth; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_pick_graph); | ||
btnGen = findViewById(R.id.generate_button); | ||
setupPickers(); | ||
btnGen.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
String[] forms1 = np1.getDisplayedValues(); | ||
String[] sites1 = np2.getDisplayedValues(); | ||
String[] startM = np3.getDisplayedValues(); | ||
String[] endM = np6.getDisplayedValues(); | ||
formPicked = String.valueOf(forms1[np1.getValue()]); | ||
sitePicked = String.valueOf(sites1[np2.getValue()]); | ||
startMonthPicked = String.valueOf(startM[np3.getValue()]); | ||
startDayPicked = np4.getValue(); | ||
startYearPicked = np5.getValue(); | ||
|
||
endMonthPicked = String.valueOf(endM[np6.getValue()]); | ||
endDayPicked = np7.getValue(); | ||
endYearPicked = np8.getValue(); | ||
Log.d("TEST", "Form Picked = " + formPicked); | ||
Log.d("TEST", "Site Picked = " + sitePicked); | ||
Log.d("TEST", "start month = " + startMonthPicked); | ||
Log.d("TEST", "start day = " + startDayPicked); | ||
Log.d("TEST", "start year = " + startYearPicked); | ||
Log.d("TEST", "end month = " + endMonthPicked); | ||
Log.d("TEST", "end day = " + endDayPicked); | ||
Log.d("TEST", "end year = " + endYearPicked); | ||
|
||
Intent intent = new Intent(GraphPicker.this, Grapher.class); | ||
Bundle extras = new Bundle(); | ||
extras.putString("FORM_CHOICE", formPicked); | ||
extras.putString("SITE_CHOICE", sitePicked); | ||
extras.putString("START_MONTH", startMonthPicked); | ||
extras.putString("END_MONTH", endMonthPicked); | ||
extras.putInt("START_DAY", startDayPicked); | ||
extras.putInt("END_DAY", endDayPicked); | ||
extras.putInt("START_YEAR", startYearPicked); | ||
extras.putInt("END_YEAR", endYearPicked); | ||
Log.d("graph", "ORIGINAL Collection string is " + formPicked); | ||
Log.d("graph", "ORIGINAL Site string is " + sitePicked); | ||
intent.putExtras(extras); | ||
startActivity(intent); | ||
} | ||
}); | ||
} | ||
|
||
public void setupPickers() { | ||
//TODO: QUERY FIREBASE FOR THIS INFO | ||
np1 = findViewById(R.id.pickForm); | ||
np2 = findViewById(R.id.pickSite); | ||
np3 = findViewById(R.id.pickStartMonth); | ||
np4 = findViewById(R.id.pickStartDay); | ||
np5 = findViewById(R.id.pickStartYear); | ||
np6 = findViewById(R.id.pickEndMonth); | ||
np7 = findViewById(R.id.pickEndDay); | ||
np8 = findViewById(R.id.pickEndYear); | ||
|
||
//TODO: Accomodate Construction form at some point | ||
String[] forms = {"Waterway"};//, "Construction"}; | ||
np1.setMaxValue(forms.length - 1); | ||
np1.setDisplayedValues(forms); | ||
np1.setWrapSelectorWheel(false); | ||
|
||
//TODO: limit choices to forms? | ||
Query WaterwaySites = FirebaseFirestore.getInstance().collection("Forms").document("purdue.edu").collection("Waterway").orderBy("SortTimeStamp", Query.Direction.ASCENDING); | ||
WaterwaySites.get().addOnCompleteListener(this, new OnCompleteListener<QuerySnapshot>() { | ||
@Override | ||
public void onComplete(@NonNull Task<QuerySnapshot> task) { | ||
Log.d("Grapher", "Got into This thing"); | ||
if (task.isSuccessful()) { | ||
docCount = task.getResult().size(); | ||
String[] WaterSites = new String[docCount]; | ||
int i = 0; | ||
for (QueryDocumentSnapshot document : task.getResult()) { | ||
//Check if the string already exists in the WaterSites | ||
if (Arrays.stream(WaterSites).anyMatch(document.getString("H_site_name")::equals)) { | ||
//Then don't add it in | ||
//Log.d("Graph", "This arrays things was true"); | ||
} | ||
else { | ||
//Log.d("Graph", "This arrays thing was false"); | ||
WaterSites[i] = document.getString("H_site_name"); | ||
i++; | ||
} | ||
} | ||
String[] actualSites = new String[i]; | ||
for (int j = 0; j < i; j++) { | ||
actualSites[j] = WaterSites[j]; | ||
Log.d("Graph", "actualSites["+String.valueOf(j)+"] ="+String.valueOf(actualSites[j])); | ||
} | ||
np2.setMaxValue(actualSites.length - 1);//WaterSites.length - 1); | ||
np2.setDisplayedValues(actualSites);//WaterSites); | ||
np2.setWrapSelectorWheel(false); | ||
} else { | ||
Log.d("Graph", "Error getting documents: ", task.getException()); | ||
} | ||
Log.d("Graph", "docCount" + docCount); | ||
} | ||
}); | ||
|
||
String[] months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; | ||
String[] days = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", | ||
"11", "12", "13", "14", "15", "16", "17", "18", "19", "20", | ||
"21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"}; | ||
String[] years = {"1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", | ||
"2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", | ||
"2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", | ||
"2020", "2021", "2022", "2023", "2024", "2025", "2026", "2027", "2028", "2029"}; | ||
|
||
np3.setMaxValue(months.length - 1); | ||
np3.setDisplayedValues(months); | ||
np3.setWrapSelectorWheel(false); | ||
np6.setMaxValue(months.length - 1); | ||
np6.setDisplayedValues(months); | ||
np6.setWrapSelectorWheel(false); | ||
|
||
/*np4.setMaxValue(days.length - 1); | ||
np4.setDisplayedValues(days); | ||
np7.setMaxValue(days.length - 1); | ||
np7.setDisplayedValues(days);*/ | ||
np4.setMinValue(1); | ||
np4.setMaxValue(31); | ||
np7.setMinValue(1); | ||
np7.setMaxValue(31); | ||
|
||
/*np5.setMaxValue(years.length - 1); | ||
np5.setDisplayedValues(years); | ||
np8.setMaxValue(years.length - 1); | ||
np8.setDisplayedValues(years);*/ | ||
np5.setMinValue(1980); | ||
np5.setMaxValue(2030); | ||
np5.setWrapSelectorWheel(false); | ||
np8.setMinValue(1980); | ||
np8.setMaxValue(2030); | ||
np8.setWrapSelectorWheel(false); | ||
} | ||
|
||
public void pickerValues() { | ||
|
||
} | ||
} |
Oops, something went wrong.