From 1bfb711504359e56d4866d1a18f029e1d179f690 Mon Sep 17 00:00:00 2001 From: Samuelford24 Date: Mon, 26 Apr 2021 10:06:10 -0400 Subject: [PATCH] connected several pages, added evans code, added construction form --- app/src/main/AndroidManifest.xml | 13 +++------ .../ConstructionFormData.java | 1 + .../InspectionForm.java | 21 +++++---------- .../sf/stormwaterutilityandroid/Settings.java | 6 ++++- .../WaterwayReportDetail.java | 9 ++++--- app/src/main/res/drawable-v24/folder.png | Bin 0 -> 2830 bytes app/src/main/res/layout/activity_reports.xml | 25 +++++++++--------- .../activity_waterway_report_detail.xml | 8 ++++-- app/src/main/res/layout/cardview_reports.xml | 2 +- 9 files changed, 41 insertions(+), 44 deletions(-) create mode 100644 app/src/main/res/drawable-v24/folder.png diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4ce92a1..e1213d0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,7 +10,6 @@ - - + android:theme="@style/Theme.StormWaterUtilityAndroid" android:requestLegacyExternalStorage="true"> - - + @@ -48,12 +46,7 @@ - - - - - - + diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/ConstructionFormData.java b/app/src/main/java/com/sf/stormwaterutilityandroid/ConstructionFormData.java index 8c1b45f..f11d855 100644 --- a/app/src/main/java/com/sf/stormwaterutilityandroid/ConstructionFormData.java +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/ConstructionFormData.java @@ -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 answers, List imgLinks) { diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java b/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java index 51fc665..1932022 100644 --- a/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java @@ -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 { @@ -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); @@ -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); }); @@ -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) { diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/Settings.java b/app/src/main/java/com/sf/stormwaterutilityandroid/Settings.java index e9cac67..3d2a773 100644 --- a/app/src/main/java/com/sf/stormwaterutilityandroid/Settings.java +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/Settings.java @@ -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); } }); @@ -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() { @@ -83,6 +85,8 @@ public void onComplete(@NonNull Task task) { public void onComplete(@NonNull Task task) { if (task.isSuccessful()) { Log.d("UserDelete", "User account deleted."); + Intent intent = new Intent(getApplicationContext(),Login.class); + startActivity(intent); } } }); diff --git a/app/src/main/java/com/sf/stormwaterutilityandroid/WaterwayReportDetail.java b/app/src/main/java/com/sf/stormwaterutilityandroid/WaterwayReportDetail.java index 4436094..a89f13b 100644 --- a/app/src/main/java/com/sf/stormwaterutilityandroid/WaterwayReportDetail.java +++ b/app/src/main/java/com/sf/stormwaterutilityandroid/WaterwayReportDetail.java @@ -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(); @@ -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() { diff --git a/app/src/main/res/drawable-v24/folder.png b/app/src/main/res/drawable-v24/folder.png new file mode 100644 index 0000000000000000000000000000000000000000..40eb01b3d2b26b87c11f5263b323718b5a304694 GIT binary patch literal 2830 zcmV+p3-R=cP)002t}1^@s6I8J)%00006VoOIv0RI60 z0RN!9r;`8x3d2c6K~#90?VNvbRMi#7zvsQ(%_f8-YzXG}hG4>m{Nm?`GfIQnPXD2! zLIABKmD;MPsAH{8{n0uW>vX1$S{$%dgn(E>MeEr5Bb0Emz#kP zQ*Ds>0S1x*u8QmJ+Dt2bIlEqD1k|0GTxD2j1QZR*O3>w|W0jSPC%2|6Z814Q& zDTkQ&8ObdjVVP?I#EixTUQM{+^c^BPlaefM+LEN03?*PJ1u!2#E`Vu%TpR#S08|T7 zt7W6HhEi|s7LC{U@8nWNl0P*n>f;RDIsUxC?Mj{UEn|8#hCcc}Qe+|GA zh7beHyvbm2{gE>6==EpVzbAPeKrda=KHyY*uO*vS9v#*S6t-kBR~yvU_IsJ|6o9yJ z#Ti3C5uTJX%`XwH^g3X3CFFif@?QwF7VsoWQfXD(k2?P=5+E$e8g6-Qu1xY)28zR> z?+*eUcB^W6RCam2FPp&+rl$-`QCB2bP93F%aEWV&7`J_U8JIU=%pGSE7$TxaW$T(3 zLMa-uWHDFDiv7Z7fP`+tmj%LRIn#WvuWktdj*=B6P*A82M{P^|?DYYEa>3k@M&Xv% z%!=K)>pPVw0ASpu*oWTarWd2UopzM0&SDi+On6Z;JO8957j&|iD`kZY+X22QSgkOz zTrtE~GFKb?8LylxlZYu#ZH!-3l5T zPod9oUU!3HrkG%}r6DH9>zEuYW*Kq?bM<_prEa~>LZw6RlF~v+HFhNI-{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1@OwJ5=J}uyrk$t+|81uv( zckY}HMM-d}O8n?|9VEFQq&g_QyeAax43-cjOMVPcK#T(yUxd=j$aflqzts>SLWBqr gB1DJ~;s1yK0gxNdsZXqfbTuK)l5 literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/activity_reports.xml b/app/src/main/res/layout/activity_reports.xml index 0a39c25..14786ab 100644 --- a/app/src/main/res/layout/activity_reports.xml +++ b/app/src/main/res/layout/activity_reports.xml @@ -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" /> + app:layout_constraintTop_toBottomOf="@+id/btn_site_name" />