Skip to content

Commit

Permalink
Merge pull request #24 from EPICSGroup/Zan2
Browse files Browse the repository at this point in the history
3/25/2021 changes with grapher and gradle and settings and androidman…
  • Loading branch information
seford authored Apr 21, 2021
2 parents 0e9f329 + b70ab9d commit 5376663
Show file tree
Hide file tree
Showing 19 changed files with 1,652 additions and 5 deletions.
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

117 changes: 117 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ android {
}

dependencies {

//Added this:
implementation 'com.github.AnyChart:AnyChart-Android:0.0.3'
//Done adding
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sf.stormwaterutilityandroid">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.StormWaterUtilityAndroid">
android:theme="@style/Theme.StormWaterUtilityAndroid"
android:requestLegacyExternalStorage="true">

<activity android:name=".WaterwayReportDetail"></activity>
<activity android:name=".Settings" />
<activity android:name=".MainMenu"></activity>
Expand All @@ -17,6 +23,9 @@
<activity android:name=".Reset_password" />
<activity android:name=".SampleFordm" />
<activity android:name=".InspectionForm" />
<activity android:name=".GraphPicker" />
<activity android:name=".PDFCreator" />
<activity android:name=".Grapher" />
<activity android:name=".Login">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
196 changes: 196 additions & 0 deletions app/src/main/java/com/sf/stormwaterutilityandroid/GraphPicker.java
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() {

}
}
Loading

0 comments on commit 5376663

Please sign in to comment.