Issue-15: From attestation to get outside to attestation to move after curfew
This commit is contained in:
parent
52892c13d4
commit
a2e8a5e333
@ -7,8 +7,8 @@ android {
|
|||||||
compileSdkVersion 29
|
compileSdkVersion 29
|
||||||
buildToolsVersion "29.0.3"
|
buildToolsVersion "29.0.3"
|
||||||
|
|
||||||
dataBinding {
|
buildFeatures {
|
||||||
enabled = true
|
dataBinding = true
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
@ -74,24 +74,20 @@ dependencies {
|
|||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
// Android X
|
// Android X
|
||||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||||
implementation 'androidx.core:core-ktx:1.2.0'
|
implementation 'androidx.core:core-ktx:1.3.2'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
|
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
|
||||||
|
|
||||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2'
|
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.1'
|
||||||
implementation 'androidx.navigation:navigation-fragment:2.2.2'
|
implementation 'androidx.navigation:navigation-fragment:2.3.1'
|
||||||
implementation 'androidx.navigation:navigation-ui-ktx:2.2.2'
|
implementation 'androidx.navigation:navigation-ui-ktx:2.3.1'
|
||||||
implementation 'androidx.navigation:navigation-ui:2.2.2'
|
implementation 'androidx.navigation:navigation-ui:2.3.1'
|
||||||
|
|
||||||
// Design
|
// Design
|
||||||
implementation 'com.google.android.material:material:1.1.0'
|
implementation 'com.google.android.material:material:1.2.1'
|
||||||
|
|
||||||
// Room
|
|
||||||
// implementation 'androidx.room:room-runtime:2.2.5'
|
|
||||||
// kapt 'androidx.room:room-compiler:2.2.5'
|
|
||||||
|
|
||||||
// PDF
|
// PDF
|
||||||
implementation 'com.tom_roush:pdfbox-android:1.8.10.1'
|
implementation 'com.tom_roush:pdfbox-android:1.8.10.1'
|
||||||
@ -110,6 +106,6 @@ dependencies {
|
|||||||
|
|
||||||
// Test
|
// Test
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -28,40 +28,3 @@ class MyDatabase private constructor(private val savePath: String, private val f
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
import android.content.Context
|
|
||||||
import androidx.room.Database
|
|
||||||
import androidx.room.Room
|
|
||||||
import androidx.room.RoomDatabase
|
|
||||||
import fr.sanchezm.attestationsCovid19.data.db.dao.AttestationDao
|
|
||||||
import fr.sanchezm.attestationsCovid19.data.db.dao.ProfileDao
|
|
||||||
import fr.sanchezm.attestationsCovid19.data.db.entity.Profile
|
|
||||||
|
|
||||||
@Database(
|
|
||||||
entities = [Profile::class],
|
|
||||||
version = 1
|
|
||||||
)
|
|
||||||
abstract class MyDatabase private constructor() : RoomDatabase() {
|
|
||||||
|
|
||||||
abstract fun profileDao(): ProfileDao
|
|
||||||
abstract fun attestationDao(): AttestationDao
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
@Volatile
|
|
||||||
private var instance: MyDatabase? = null
|
|
||||||
private val LOCK = Any()
|
|
||||||
|
|
||||||
operator fun invoke(context: Context) = instance ?: synchronized(LOCK) {
|
|
||||||
instance ?: buildDatabase(context).also { instance = it }
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun buildDatabase(context: Context) =
|
|
||||||
Room.databaseBuilder(
|
|
||||||
context.applicationContext,
|
|
||||||
MyDatabase::class.java, "data.db"
|
|
||||||
)
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
@ -34,15 +34,16 @@ data class Attestation(
|
|||||||
|
|
||||||
private fun getDate(dateTime: Long): String = SimpleDateFormat(PATTERN, Locale.FRANCE).format(Date(dateTime))
|
private fun getDate(dateTime: Long): String = SimpleDateFormat(PATTERN, Locale.FRANCE).format(Date(dateTime))
|
||||||
|
|
||||||
private fun getMotifText(i: Int): String {
|
fun getMotifText(i: Int): String {
|
||||||
return when (i) {
|
return when (i) {
|
||||||
1 -> "travail"
|
1 -> "travail"
|
||||||
2 -> "courses"
|
2 -> "sante"
|
||||||
3 -> "sante"
|
3 -> "famille"
|
||||||
4 -> "famille"
|
4 -> "handicap"
|
||||||
5 -> "sport"
|
5 -> "convocation"
|
||||||
6 -> "judiciare"
|
6 -> "missions"
|
||||||
7 -> "missions"
|
7 -> "transits"
|
||||||
|
8 -> "animaux"
|
||||||
else -> "Error $i not found"
|
else -> "Error $i not found"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ class AddViewModel(
|
|||||||
val reason5 = MutableLiveData(false)
|
val reason5 = MutableLiveData(false)
|
||||||
val reason6 = MutableLiveData(false)
|
val reason6 = MutableLiveData(false)
|
||||||
val reason7 = MutableLiveData(false)
|
val reason7 = MutableLiveData(false)
|
||||||
|
val reason8 = MutableLiveData(false)
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
private val datePattern = "dd/MM/yyyy"
|
private val datePattern = "dd/MM/yyyy"
|
||||||
@ -137,6 +138,7 @@ class AddViewModel(
|
|||||||
if (reason5.value!!) reasons.add(5)
|
if (reason5.value!!) reasons.add(5)
|
||||||
if (reason6.value!!) reasons.add(6)
|
if (reason6.value!!) reasons.add(6)
|
||||||
if (reason7.value!!) reasons.add(7)
|
if (reason7.value!!) reasons.add(7)
|
||||||
|
if (reason8.value!!) reasons.add(8)
|
||||||
|
|
||||||
return reasons
|
return reasons
|
||||||
}
|
}
|
||||||
|
@ -65,8 +65,7 @@ class PdfUtils private constructor(
|
|||||||
attestation,
|
attestation,
|
||||||
size / 3,
|
size / 3,
|
||||||
page1.mediaBox.upperRightX - margin - size / 3 - 30,
|
page1.mediaBox.upperRightX - margin - size / 3 - 30,
|
||||||
141f,
|
101f
|
||||||
true
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Add QRCode on a new page
|
// Add QRCode on a new page
|
||||||
@ -83,8 +82,7 @@ class PdfUtils private constructor(
|
|||||||
attestation: Attestation,
|
attestation: Attestation,
|
||||||
size: Int,
|
size: Int,
|
||||||
x: Float,
|
x: Float,
|
||||||
y: Float,
|
y: Float
|
||||||
addText: Boolean = false
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
val contentStream = PDPageContentStream(document, page, true, false)
|
val contentStream = PDPageContentStream(document, page, true, false)
|
||||||
@ -92,21 +90,7 @@ class PdfUtils private constructor(
|
|||||||
LosslessFactory.createFromImage(document, QRCodeUtils.getQrCode(attestation, size))
|
LosslessFactory.createFromImage(document, QRCodeUtils.getQrCode(attestation, size))
|
||||||
|
|
||||||
contentStream.drawImage(alphaXimage, x, y)
|
contentStream.drawImage(alphaXimage, x, y)
|
||||||
if (addText) {
|
|
||||||
contentStream.beginText()
|
|
||||||
contentStream.setFont(font, 7f)
|
|
||||||
contentStream.newLineAtOffset(page.mediaBox.upperRightX - size - 20, 145f)
|
|
||||||
contentStream.showText("Date de création:")
|
|
||||||
contentStream.endText()
|
|
||||||
|
|
||||||
contentStream.beginText()
|
|
||||||
contentStream.setFont(font, 7f)
|
|
||||||
contentStream.newLineAtOffset(page.mediaBox.upperRightX - size - 27, 138f)
|
|
||||||
contentStream.showText(attestation.getCreatedAtFormattedDate())
|
|
||||||
contentStream.endText()
|
|
||||||
}
|
|
||||||
contentStream.close()
|
contentStream.close()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setFieldsData(acroForm: PDAcroForm, attestation: Attestation): Boolean {
|
private fun setFieldsData(acroForm: PDAcroForm, attestation: Attestation): Boolean {
|
||||||
@ -117,21 +101,21 @@ class PdfUtils private constructor(
|
|||||||
val namesField = acroForm.getField("Nom et prénom") as PDTextField
|
val namesField = acroForm.getField("Nom et prénom") as PDTextField
|
||||||
val birthdayField = acroForm.getField("Date de naissance") as PDTextField
|
val birthdayField = acroForm.getField("Date de naissance") as PDTextField
|
||||||
val birthPlaceField = acroForm.getField("Lieu de naissance") as PDTextField
|
val birthPlaceField = acroForm.getField("Lieu de naissance") as PDTextField
|
||||||
val addressField = acroForm.getField("Adresse actuelle") as PDTextField
|
val addressField = acroForm.getField("Adresse") as PDTextField
|
||||||
|
val postalAndCityField = acroForm.getField("Ville et code postal") as PDTextField
|
||||||
val cityField = acroForm.getField("Ville") as PDTextField
|
val cityField = acroForm.getField("Ville") as PDTextField
|
||||||
val dateField = acroForm.getField("Date") as PDTextField
|
val dateField = acroForm.getField("Date") as PDTextField
|
||||||
val hourField = acroForm.getField("Heure") as PDTextField
|
val exitField = acroForm.getField("Heure") as PDTextField
|
||||||
val minutesField = acroForm.getField("Minute") as PDTextField
|
|
||||||
// val signatureField = acroForm.getField("Signature") as PDTextField
|
// val signatureField = acroForm.getField("Signature") as PDTextField
|
||||||
|
|
||||||
namesField.value = "${profile.firstName} ${profile.lastName}"
|
namesField.value = "${profile.firstName} ${profile.lastName}"
|
||||||
birthdayField.value = profile.birthday
|
birthdayField.value = profile.birthday
|
||||||
birthPlaceField.value = profile.birthPlace
|
birthPlaceField.value = profile.birthPlace
|
||||||
addressField.value = "${profile.address} ${profile.postalCode} ${profile.city}"
|
addressField.value = profile.address
|
||||||
|
postalAndCityField.value = "${profile.postalCode} ${profile.city}"
|
||||||
cityField.value = profile.city
|
cityField.value = profile.city
|
||||||
dateField.value = attestation.exitDate
|
dateField.value = attestation.exitDate
|
||||||
hourField.value = attestation.exitHour.split("h")[0]
|
exitField.value = attestation.exitHour
|
||||||
minutesField.value = attestation.exitHour.split("h")[1]
|
|
||||||
return true
|
return true
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(TAG, "${e.message}")
|
Log.e(TAG, "${e.message}")
|
||||||
@ -141,7 +125,7 @@ class PdfUtils private constructor(
|
|||||||
|
|
||||||
private fun setCheckboxFields(acroForm: PDAcroForm, attestation: Attestation) {
|
private fun setCheckboxFields(acroForm: PDAcroForm, attestation: Attestation) {
|
||||||
attestation.reasons.forEach {
|
attestation.reasons.forEach {
|
||||||
(acroForm.getField(checkboxListNames[it - 1]) as PDCheckbox).check()
|
(acroForm.getField(attestation.getMotifText(it)) as PDCheckbox).check()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,6 +250,14 @@
|
|||||||
android:checked="@={viewModel.reason7}"
|
android:checked="@={viewModel.reason7}"
|
||||||
android:text="@string/reason_7" />
|
android:text="@string/reason_7" />
|
||||||
|
|
||||||
|
<com.google.android.material.checkbox.MaterialCheckBox
|
||||||
|
android:id="@+id/reason_8"
|
||||||
|
style="@style/MaterialCheckBox"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:checked="@={viewModel.reason8}"
|
||||||
|
android:text="@string/reason_8" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/generate_attestation"
|
android:id="@+id/generate_attestation"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<!-- Attestation Fragment -->
|
<!-- Attestation Fragment -->
|
||||||
<string name="attestation_title">@string/app_name</string>
|
<string name="attestation_title">@string/app_name</string>
|
||||||
<string name="attestation_subtitle">#RestonsChezNous</string>
|
<string name="attestation_subtitle">Respectons les gestes barrières et les distanciations sociales et faisons barrière à la Covid-19</string>
|
||||||
<string name="attestation_generated">Attestation générée</string>
|
<string name="attestation_generated">Attestation générée</string>
|
||||||
<string name="no_attestation">Aucune attestation, veuillez en générer une.</string>
|
<string name="no_attestation">Aucune attestation, veuillez en générer une.</string>
|
||||||
|
|
||||||
@ -18,19 +18,20 @@
|
|||||||
<string name="address">Adresse</string>
|
<string name="address">Adresse</string>
|
||||||
<string name="city">Ville</string>
|
<string name="city">Ville</string>
|
||||||
<string name="postal_code">Code Postal</string>
|
<string name="postal_code">Code Postal</string>
|
||||||
<string name="reason">Choisissez le ou les motif(s) de sortie</string>
|
<string name="reason">Je certifie que mon déplacement est lié au motif suivant (cocher la case) autorisé en application des mesures générales nécessaires pour faire face à l\'épidémie de Covid19 dans le cadre de l\'état d\'urgence sanitaire :</string>
|
||||||
<string name="exit_date">Date de sortie</string>
|
<string name="exit_date">Date de sortie</string>
|
||||||
<string name="exit_hour">Heure de sortie</string>
|
<string name="exit_hour">Heure de sortie</string>
|
||||||
<string name="generate_attestation_button">Générer l\'attestation</string>
|
<string name="generate_attestation_button">Générer l\'attestation</string>
|
||||||
|
|
||||||
<!-- Reasons for leaving house -->
|
<!-- Reasons for leaving house -->
|
||||||
<string name="reason_1">Déplacements entre le domicile et le lieu d’exercice de l’activité professionnelle, lorsqu\'ils sont indispensables à l\'exercice d’activités ne pouvant être organisées sous forme de télétravail ou déplacements professionnels ne pouvant être différés.</string>
|
<string name="reason_1">Déplacements entre le domicile et le lieu d\'exercice de l\'activité professionnelle ou le lieu d\'enseignement et de formation.</string>
|
||||||
<string name="reason_2">Déplacements pour effectuer des achats de fournitures nécessaires à l’activité professionnelle et des achats de première nécessité dans des établissements dont les activités demeurent autorisées</string>
|
<string name="reason_2">Déplacements pour des consultations et soins ne pouvant être assurés à distance et ne pouvant être différés ou pour l\'achat de produits de santé.</string>
|
||||||
<string name="reason_3">Consultations et soins ne pouvant être assurés à distance et ne pouvant être différés ; consultations et soins des patients atteints d\'une affection de longue durée.</string>
|
<string name="reason_3">Déplacements pour motif familial impérieux, pour l\'assistance aux personnes vulnérables ou précaires ou pour la garde d\'enfants.</string>
|
||||||
<string name="reason_4">Déplacements pour motif familial impérieux, pour l’assistance aux personnes vulnérables ou la garde d’enfants.</string>
|
<string name="reason_4">Déplacements des personnes en situation de handicap et de leur accompagnant.</string>
|
||||||
<string name="reason_5">Déplacements brefs, dans la limite d\'une heure quotidienne et dans un rayon maximal d\'un kilomètre autour du domicile, liés soit à l\'activité physique individuelle des personnes, à l\'exclusion de toute pratique sportive collective et de toute proximité avec d\'autres personnes, soit à la promenade avec les seules personnes regroupées dans un même domicile, soit aux besoins des animaux de compagnie.</string>
|
<string name="reason_5">Déplacements pour répondre à une convocation judiciaire ou administrative.</string>
|
||||||
<string name="reason_6">Convocation judiciaire ou administrative.</string>
|
<string name="reason_6">Déplacements pour participer à des missions d\'intérêt général sur demande de l\'autorité administrative.</string>
|
||||||
<string name="reason_7">Participation à des missions d’intérêt général sur demande de l’autorité administrative.</string>
|
<string name="reason_7">Déplacements liés à des transits pour des déplacements de longues distances.</string>
|
||||||
|
<string name="reason_8">Déplacements brefs, dans un rayon maximal d\'un kilomètre autour du domicile pour les besoins des animaux de compagnie.</string>
|
||||||
|
|
||||||
<!-- Info Fragment -->
|
<!-- Info Fragment -->
|
||||||
<string name="explication_1">- Merci de n\'utiliser l\'application qu\'en cas de nécessité.</string>
|
<string name="explication_1">- Merci de n\'utiliser l\'application qu\'en cas de nécessité.</string>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext {
|
ext {
|
||||||
kotlin_version = '1.3.72'
|
kotlin_version = '1.4.10'
|
||||||
db_version = '1'
|
db_version = '1'
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -13,7 +13,7 @@ buildscript {
|
|||||||
|
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.6.3'
|
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
#Sun Apr 12 01:14:42 CEST 2020
|
#Sat Oct 24 15:33:39 CEST 2020
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
|
||||||
|
Loading…
Reference in New Issue
Block a user