Skip to content

Commit

Permalink
Merge pull request #27 from EPICSGroup/Samuel2
Browse files Browse the repository at this point in the history
connected several pages, added evan's and Cazandras code, added construction form
  • Loading branch information
seford authored Apr 26, 2021
2 parents 144d058 + 1bfb711 commit 61f952d
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 44 deletions.
13 changes: 3 additions & 10 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET" />


<application

android:allowBackup="true"
Expand All @@ -22,14 +21,13 @@
android:theme="@style/Theme.StormWaterUtilityAndroid">
<activity android:name=".ImageAttachForm"></activity>
<activity android:name=".Settings" />
<activity android:name=".MainMenu">
<activity android:name=".MainMenu"/>

android:theme="@style/Theme.StormWaterUtilityAndroid"
android:requestLegacyExternalStorage="true">

<activity android:name=".WaterwayReportDetail"></activity>
<activity android:name=".Settings" />
<activity android:name=".MainMenu"></activity>

<activity android:name=".WaterWay.WaterWayNav"></activity>
<activity android:name=".Construction.ConstructionNav"></activity>
<activity android:name=".Reset_password" />
Expand All @@ -48,12 +46,7 @@
</intent-filter>
</activity>

<activity android:name=".WaterWay.WaterWayNav"></activity>
<activity android:name=".Construction.ConstructionNav"></activity>
<activity android:name=".Reset_password" />
<activity android:name=".SampleFordm" />
<activity android:name=".InspectionForm" />
<activity android:name=".Login" />


<activity android:name=".SignUp" />
</application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public ConstructionFormData(String contact, String date, String inspector,
data.put("location", location);
data.put("answers", answers);
data.put("imgLinks", imgLinks);
}

public ConstructionFormData(String contact, String date, String inspector, Date timestamp, String location,
GeoPoint geoPoint, List<String> answers, List<String> imgLinks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import me.riddhimanadib.formmaster.model.FormElementTextSingleLine;
import me.riddhimanadib.formmaster.model.FormHeader;

import static android.app.Activity.RESULT_OK;


public class InspectionForm extends Fragment {

Expand Down Expand Up @@ -67,26 +69,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
View view = inflater.inflate(R.layout.activity_sample_fordm, container, false);
recyclerView = view.findViewById(R.id.recyclerView2);
submitButton = view.findViewById(R.id.submitButton);
uploadImageBtn = view.findViewById(R.id.uploadImageBtn);

setupForm();
return view;
}



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));


this.storage = FirebaseStorage.getInstance();
this.storageReference = storage.getReference();

setupForm();

}

private void setupForm() {
FormBuilder formBuilder = new FormBuilder(getContext(), recyclerView);
Expand Down Expand Up @@ -201,7 +192,7 @@ private void setupForm() {
formBuilder.addFormElements(formItems);

uploadImageBtn.setOnClickListener(view -> {
Intent intent = new Intent(getApplicationContext(), ImageAttachForm.class);
Intent intent = new Intent(getContext(), ImageAttachForm.class);
startActivityForResult(intent, UPLOAD_IMAGE_REQUEST);
});

Expand Down Expand Up @@ -281,7 +272,7 @@ private void setupForm() {

// result of getting added images
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if (requestCode == UPLOAD_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getExtras() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public void onClick(View v) {
public void onClick(View v) {
//startActivity(new Intent(Reports.this, Inspector_name.class));
FirebaseAuth.getInstance().signOut();
Intent intent = new Intent(getApplicationContext(),Login.class);
startActivity(intent);
}
});

Expand All @@ -73,7 +75,7 @@ public void onClick(View v) {
// Get auth credentials from the user for re-authentication. The example below shows
// email and password credentials but there are multiple possible providers,
// such as GoogleAuthProvider or FacebookAuthProvider.
AuthCredential credential = EmailAuthProvider.getCredential("user@example.com", "password1234");
AuthCredential credential = EmailAuthProvider.getCredential(user.getEmail(), "123456");

// Prompt the user to re-provide their sign-in credentials
user.reauthenticate(credential).addOnCompleteListener(new OnCompleteListener<Void>() {
Expand All @@ -83,6 +85,8 @@ public void onComplete(@NonNull Task<Void> task) {
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d("UserDelete", "User account deleted.");
Intent intent = new Intent(getApplicationContext(),Login.class);
startActivity(intent);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ public void createPDF(String[] labels, WaterWayReport wp) {
//File naming convention: inspector _ site name _ date
String fileName = String.valueOf(wp.getH_inspector_name()) + "_" + String.valueOf(wp.getH_site_name()) + "_" + String.valueOf(wp.getH_date()) + ".pdf";

File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), fileName);// + "/Test", fileName);//"Test.pdf");
// File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), fileName);// + "/Test", fileName);//"Test.pdf");
File file = new File(getExternalFilesDir(null), fileName);
if (!file.exists()) {
Log.d("pdf", "DOESN'T EXIST");
file.getParentFile().mkdirs();
Expand All @@ -245,14 +246,16 @@ public void createPDF(String[] labels, WaterWayReport wp) {


try {
//write pdf ot file location
file.createNewFile();//NEW
document.writeTo(new FileOutputStream(file));
Toast.makeText(WaterwayReportDetail.this, "PDF file generated succesfully.", Toast.LENGTH_SHORT).show();
document.close();//MOVED THIS HERE
Log.d("pdf", "file name is " + String.valueOf(fileName));
} catch (IOException e) {
e.printStackTrace();
}

document.close();

}

private boolean checkPermission() {
Expand Down
Binary file added app/src/main/res/drawable-v24/folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 13 additions & 12 deletions app/src/main/res/layout/activity_reports.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Date,name,or site"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:hint="Date,name,or site" />
app:layout_constraintTop_toTopOf="parent" />


<androidx.recyclerview.widget.RecyclerView
Expand All @@ -25,37 +25,35 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btn_inspector_name" />
app:layout_constraintTop_toBottomOf="@+id/btn_site_name" />

<Button
android:id="@+id/btn_site_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginStart="8dp"
android:text="SN"
app:layout_constraintBottom_toTopOf="@+id/guideline"
app:layout_constraintEnd_toStartOf="@+id/btn_inspector_name"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toStartOf="parent" />

<Button
android:id="@+id/btn_inspector_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="9dp"
android:layout_marginStart="8dp"
android:text="IN"
app:layout_constraintBottom_toTopOf="@+id/guideline"
app:layout_constraintEnd_toStartOf="@+id/btn_date"
app:layout_constraintStart_toEndOf="@+id/btn_site_name" />

<Button
android:id="@+id/btn_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="6dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:text="D"
app:layout_constraintBottom_toTopOf="@+id/guideline"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btn_grapher"
app:layout_constraintStart_toEndOf="@+id/btn_inspector_name" />

<androidx.constraintlayout.widget.Guideline
Expand All @@ -69,9 +67,12 @@
android:id="@+id/btn_grapher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="25dp"
android:text="Graph"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
android:textSize="10sp"
app:iconPadding="2dp"
app:layout_constraintBottom_toTopOf="@+id/guideline"
app:layout_constraintEnd_toEndOf="@+id/recyclerView" />


</androidx.constraintlayout.widget.ConstraintLayout>
8 changes: 6 additions & 2 deletions app/src/main/res/layout/activity_waterway_report_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
android:id="@+id/listView"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="17dp"
app:layout_constraintBottom_toTopOf="@+id/export_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand All @@ -19,7 +20,10 @@
android:id="@+id/export_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="Export"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/listView" />
</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/cardview_reports.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
android:layout_height="95dp"
android:scaleType="centerCrop"
android:layout_margin="4dp"
android:src="@drawable/ic_home_black_24dp"
android:src="@drawable/folder"
tools:layout_editor_absoluteX="24dp"
tools:layout_editor_absoluteY="3dp" />

Expand Down

0 comments on commit 61f952d

Please sign in to comment.