Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Commit

Permalink
Merge pull request #122 from AdrienPoupa/curfew-quarantine-march-2021
Browse files Browse the repository at this point in the history
Add March 2021 curfew and quarantine new forms
  • Loading branch information
AdrienPoupa authored Mar 26, 2021
2 parents 58b7578 + e74f224 commit ef89dcd
Show file tree
Hide file tree
Showing 19 changed files with 627 additions and 164 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Non sorti]

## [3.6.0] - 2021-03-26
### Changé
- Ajout des nouveaux formulaires de couvre feu et de confinement

## [3.5.1] - 2021-01-19
### Changé
- Mise à jour des horaires du formulaire de couvre feu
Expand Down
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.poupa.attestationdeplacement"
minSdkVersion 16
targetSdkVersion 29
versionCode 26
versionName "3.5.1"
versionCode 27
versionName "3.6.0"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true

Expand All @@ -35,11 +35,11 @@ android {
}

dependencies {
implementation 'com.google.android.material:material:1.2.1'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation "androidx.room:room-runtime:2.2.6"
annotationProcessor "androidx.room:room-compiler:2.2.6"
implementation 'com.itextpdf:itextg:5.5.10'
implementation 'com.google.zxing:core:3.4.0'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
}
Binary file removed app/src/main/assets/attestation.pdf
Binary file not shown.
Binary file added app/src/main/assets/curfew-certificate.pdf
Binary file not shown.
Binary file added app/src/main/assets/quarantine-certificate.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

import android.app.TimePickerDialog;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
Expand All @@ -20,12 +24,17 @@
import com.poupa.attestationdeplacement.db.ProfileEntity;
import com.poupa.attestationdeplacement.db.ProfileViewModel;
import com.poupa.attestationdeplacement.dto.Attestation;
import com.poupa.attestationdeplacement.dto.CurfewAttestation;
import com.poupa.attestationdeplacement.dto.QuarantineAttestation;
import com.poupa.attestationdeplacement.dto.Reason;
import com.poupa.attestationdeplacement.generator.AttestationGenerator;
import com.poupa.attestationdeplacement.generator.CurfewAttestationGenerator;
import com.poupa.attestationdeplacement.generator.QuarantineAttestationGenerator;
import com.poupa.attestationdeplacement.tasks.GeneratePdfTask;
import com.poupa.attestationdeplacement.tasks.LoadProfilesCreateAttestationTask;
import com.poupa.attestationdeplacement.ui.DateTextWatcher;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -71,9 +80,50 @@ public void onResume() {
* Initialize the input fields
*/
private void initFields(boolean initDate) {
attestation = new Attestation();
attestation = new QuarantineAttestation();
attestationGenerator = new QuarantineAttestationGenerator(this, (QuarantineAttestation) attestation);

LinearLayout curfewLayout = (LinearLayout) findViewById(R.id.reasons_curfew_layout);
LinearLayout quarantineLayout = (LinearLayout) findViewById(R.id.reasons_quarantine_layout);

AutoCompleteTextView autoCompleteAttestation = findViewById(R.id.attestation_type_dropdown);
autoCompleteAttestation.setOnItemClickListener((parent, view, position, id) -> {
attestation = (Attestation) parent.getItemAtPosition(position);

if (attestation instanceof CurfewAttestation) {
CurfewAttestation curfewAttestation = (CurfewAttestation) attestation;
attestationGenerator = new CurfewAttestationGenerator(this, curfewAttestation);
curfewLayout.setVisibility(View.VISIBLE);
quarantineLayout.setVisibility(View.INVISIBLE);
} else {
QuarantineAttestation quarantineAttestation = (QuarantineAttestation) attestation;
attestationGenerator = new QuarantineAttestationGenerator(this, quarantineAttestation);
curfewLayout.setVisibility(View.INVISIBLE);
quarantineLayout.setVisibility(View.VISIBLE);
}
});

attestationGenerator = new AttestationGenerator(this, attestation);
List<Attestation> attestations = new ArrayList<>();
attestations.add(new QuarantineAttestation());
attestations.add(new CurfewAttestation());

ArrayAdapter<Attestation> adapter =
new ArrayAdapter<>(
this,
R.layout.dropdown_menu_popup_item,
attestations);

autoCompleteAttestation.setAdapter(adapter);

// https://stackoverflow.com/a/23568337/11115846
if (Build.VERSION.SDK_INT > 16) {
autoCompleteAttestation.setText(attestation.toString(), false);
} else {
ListAdapter adapter2 = autoCompleteAttestation.getAdapter();
autoCompleteAttestation.setAdapter(null);
autoCompleteAttestation.setText(attestation.toString());
autoCompleteAttestation.setAdapter((ArrayAdapter) adapter2);
}

surnameInput = findViewById(R.id.surname);

Expand Down Expand Up @@ -127,8 +177,8 @@ private void initFields(boolean initDate) {
R.id.travel_hour_layout, ConstraintSet.BOTTOM);
constraintSet.applyTo(constraintLayout);

AutoCompleteTextView autoCompleteTextView = findViewById(R.id.filled_exposed_dropdown);
autoCompleteTextView.setOnItemClickListener((parent, view, position, id) -> {
AutoCompleteTextView autoCompleteProfile = findViewById(R.id.filled_exposed_dropdown);
autoCompleteProfile.setOnItemClickListener((parent, view, position, id) -> {
ProfileEntity profileEntity = (ProfileEntity) parent.getItemAtPosition(position);

CreateAttestationActivity.this.fillFieldsFromProfile(profileEntity);
Expand All @@ -142,7 +192,7 @@ private void setReasonsCheckboxes() {

List<Reason> reasons = attestation.getReasons();
for(int i = 0; i < reasons.size(); i++) {
String reasonKey = "reason" + (i + 1);
String reasonKey = "reason" + (i + 1) + "_" + attestation.getReasonPrefix();

int resId = getResources().getIdentifier(reasonKey, "id", getPackageName());

Expand Down Expand Up @@ -238,7 +288,7 @@ public boolean checkFields() {

List<Reason> reasons = attestation.getReasons();
for(int i = 0; i < reasons.size(); i++) {
String reasonKey = "reason" + (i + 1);
String reasonKey = "reason" + (i + 1) + "_" + attestation.getReasonPrefix();

int resId = getResources().getIdentifier(reasonKey, "id", getPackageName());

Expand Down Expand Up @@ -311,7 +361,7 @@ public void saveFields() {

List<Reason> reasons = attestation.getReasons();
for(int i = 0; i < reasons.size(); i++) {
String reasonKey = "reason" + (i + 1);
String reasonKey = "reason" + (i + 1) + "_" + attestation.getReasonPrefix();

int resId = getResources().getIdentifier(reasonKey, "id", getPackageName());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,50 +1,36 @@
package com.poupa.attestationdeplacement.dto;

import android.content.Context;

import com.poupa.attestationdeplacement.MainActivity;
import com.poupa.attestationdeplacement.R;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
* Attestation Data
*/
public class Attestation {
private int id;
private String surname;
private String lastName;
private String city;
private String postalCode;
private String address;
private String birthPlace;
private String birthDate;
private String travelDate;
private String travelHour;
private String hour;
private String minute;

private List<Reason> reasons;
public abstract class Attestation {
protected int id;
protected String surname;
protected String lastName;
protected String city;
protected String postalCode;
protected String address;
protected String birthPlace;
protected String birthDate;
protected String travelDate;
protected String travelHour;
protected String hour;
protected String minute;

protected List<Reason> reasons;

public Attestation() {
setupReasons();
}

private void setupReasons() {
Context context = MainActivity.getContext();
protected abstract void setupReasons();

this.reasons = new ArrayList<>();
this.reasons.add(new Reason(context.getString(R.string.reason1_smalltext), "travail", 73, 540));
this.reasons.add(new Reason(context.getString(R.string.reason2_smalltext), "sante", 73, 508));
this.reasons.add(new Reason(context.getString(R.string.reason3_smalltext), "famille", 73, 474));
this.reasons.add(new Reason(context.getString(R.string.reason4_smalltext), "handicap", 73, 441));
this.reasons.add(new Reason(context.getString(R.string.reason5_smalltext), "convocation", 73, 418));
this.reasons.add(new Reason(context.getString(R.string.reason6_smalltext), "missions", 73, 397));
this.reasons.add(new Reason(context.getString(R.string.reason7_smalltext), "transits", 73, 363));
this.reasons.add(new Reason(context.getString(R.string.reason8_smalltext), "animaux", 73, 330));
}
public abstract String getPdfFileName();

public abstract String getReasonPrefix();

/**
* Get the full address
Expand Down Expand Up @@ -175,4 +161,6 @@ public int getId() {
public void setId(int id) {
this.id = id;
}

public abstract String toString();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

package com.poupa.attestationdeplacement.dto;

import android.content.Context;

import com.poupa.attestationdeplacement.MainActivity;
import com.poupa.attestationdeplacement.R;

import java.util.ArrayList;

/**
* Curfew Attestation Data
*/
public class CurfewAttestation extends Attestation {

protected void setupReasons() {
Context context = MainActivity.getContext();

this.reasons = new ArrayList<>();
this.reasons.add(new Reason(context.getString(R.string.reason1_curfew_smalltext), "travail", 73, 579));
this.reasons.add(new Reason(context.getString(R.string.reason2_curfew_smalltext), "sante", 73, 546));
this.reasons.add(new Reason(context.getString(R.string.reason3_curfew_smalltext), "famille", 73, 512));
this.reasons.add(new Reason(context.getString(R.string.reason4_curfew_smalltext), "handicap", 73, 478));
this.reasons.add(new Reason(context.getString(R.string.reason5_curfew_smalltext), "convocation", 73, 458));
this.reasons.add(new Reason(context.getString(R.string.reason6_curfew_smalltext), "missions", 73, 412));
this.reasons.add(new Reason(context.getString(R.string.reason7_curfew_smalltext), "transits", 73, 379));
this.reasons.add(new Reason(context.getString(R.string.reason8_curfew_smalltext), "animaux", 73, 345));
}

@Override
public String getPdfFileName() {
return "curfew-certificate.pdf";
}

@Override
public String getReasonPrefix() {
return "curfew";
}

@Override
public String toString() {
Context context = MainActivity.getContext();

return context.getString(R.string.curfew_attestation);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.poupa.attestationdeplacement.dto;

import android.content.Context;

import com.poupa.attestationdeplacement.MainActivity;
import com.poupa.attestationdeplacement.R;

import java.util.ArrayList;

/**
* Curfew Attestation Data
*/
public class QuarantineAttestation extends Attestation {

protected void setupReasons() {
Context context = MainActivity.getContext();

this.reasons = new ArrayList<>();
this.reasons.add(new Reason(context.getString(R.string.reason1_quarantine_smalltext), "sport", 60, 367));
this.reasons.add(new Reason(context.getString(R.string.reason2_quarantine_smalltext), "achats", 60, 244));
this.reasons.add(new Reason(context.getString(R.string.reason3_quarantine_smalltext), "enfants", 60, 161));
this.reasons.add(new Reason(context.getString(R.string.reason4_quarantine_smalltext), "culte_culturel", 60, 781, 2));
this.reasons.add(new Reason(context.getString(R.string.reason5_quarantine_smalltext), "demarche", 60, 726, 2));
this.reasons.add(new Reason(context.getString(R.string.reason6_quarantine_smalltext), "travail", 60, 629, 2));
this.reasons.add(new Reason(context.getString(R.string.reason7_quarantine_smalltext), "sante", 60, 533, 2));
this.reasons.add(new Reason(context.getString(R.string.reason8_quarantine_smalltext), "famille", 60, 477, 2));
this.reasons.add(new Reason(context.getString(R.string.reason9_quarantine_smalltext), "handicap", 60, 422, 2));
this.reasons.add(new Reason(context.getString(R.string.reason10_quarantine_smalltext), "judiciaire", 60, 380, 2));
this.reasons.add(new Reason(context.getString(R.string.reason11_quarantine_smalltext), "demenagement", 60, 311, 2));
this.reasons.add(new Reason(context.getString(R.string.reason12_quarantine_smalltext), "transits", 60, 243, 2));
}

@Override
public String getPdfFileName() {
return "quarantine-certificate.pdf";
}

@Override
public String getReasonPrefix() {
return "quarantine";
}

@Override
public String toString() {
Context context = MainActivity.getContext();

return context.getString(R.string.quarantine_attestation);
}
}
18 changes: 18 additions & 0 deletions app/src/main/java/com/poupa/attestationdeplacement/dto/Reason.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,22 @@ public class Reason {
boolean enabled = false;
int x;
int y;
int page;

public Reason(String databaseName, String qrCodeName, int x, int y) {
this.databaseName = databaseName;
this.qrCodeName = qrCodeName;
this.x = x;
this.y = y;
this.page = 1;
}

public Reason(String databaseName, String qrCodeName, int x, int y, int page) {
this.databaseName = databaseName;
this.qrCodeName = qrCodeName;
this.x = x;
this.y = y;
this.page = page;
}

public String getDatabaseName() {
Expand Down Expand Up @@ -53,4 +63,12 @@ public int getY() {
public void setY(int y) {
this.y = y;
}

public int getPage() {
return page;
}

public void setPage(int page) {
this.page = page;
}
}
Loading

0 comments on commit ef89dcd

Please sign in to comment.