Compare commits
5 Commits
ms/issue-1
...
1.0.4-beta
Author | SHA1 | Date | |
---|---|---|---|
fac797ed32 | |||
731920ca28 | |||
7d8c509e9c | |||
50cd345a53 | |||
8f965e5322 |
@ -15,8 +15,8 @@ android {
|
|||||||
applicationId "fr.sanchezm.attestationsCovid19"
|
applicationId "fr.sanchezm.attestationsCovid19"
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 7
|
versionCode 1001
|
||||||
versionName "1.0.5"
|
versionName "1.0.4-beta2"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package fr.sanchezm.attestationsCovid19.data.db.entity
|
|||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
const val PATTERN = "dd/MM/yyyy 'à' HH:mm"
|
const val PATTERN = "dd/MM/yyyy 'à' HH'h'mm"
|
||||||
|
|
||||||
//@Entity(tableName = "attestation")
|
//@Entity(tableName = "attestation")
|
||||||
data class Attestation(
|
data class Attestation(
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package fr.sanchezm.attestationsCovid19.ui.add
|
package fr.sanchezm.attestationsCovid19.ui.add
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.DatePickerDialog
|
|
||||||
import android.app.TimePickerDialog
|
|
||||||
import android.content.Context
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
@ -16,7 +13,6 @@ import fr.sanchezm.attestationsCovid19.data.repository.AttestationRepository
|
|||||||
import fr.sanchezm.attestationsCovid19.data.repository.ConfigRepository
|
import fr.sanchezm.attestationsCovid19.data.repository.ConfigRepository
|
||||||
import fr.sanchezm.attestationsCovid19.data.repository.ProfileRepository
|
import fr.sanchezm.attestationsCovid19.data.repository.ProfileRepository
|
||||||
import fr.sanchezm.attestationsCovid19.utilities.Event
|
import fr.sanchezm.attestationsCovid19.utilities.Event
|
||||||
import java.text.DateFormat
|
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
@ -25,8 +21,7 @@ import java.util.*
|
|||||||
class AddViewModel(
|
class AddViewModel(
|
||||||
private val configRepository: ConfigRepository,
|
private val configRepository: ConfigRepository,
|
||||||
private val profileRepository: ProfileRepository,
|
private val profileRepository: ProfileRepository,
|
||||||
private val attestationRepository: AttestationRepository,
|
private val attestationRepository: AttestationRepository
|
||||||
private val app: Context
|
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
|
|
||||||
private val _errorMessage = MutableLiveData<Event<Int>>()
|
private val _errorMessage = MutableLiveData<Event<Int>>()
|
||||||
@ -63,7 +58,7 @@ class AddViewModel(
|
|||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
private val datePattern = "dd/MM/yyyy"
|
private val datePattern = "dd/MM/yyyy"
|
||||||
private val timePattern = "HH:mm"
|
private val timePattern = "HH'h'mm"
|
||||||
|
|
||||||
@SuppressLint("LongLogTag")
|
@SuppressLint("LongLogTag")
|
||||||
fun onGenerateAttestationClick() {
|
fun onGenerateAttestationClick() {
|
||||||
@ -80,68 +75,6 @@ class AddViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onBirthdayClick() {
|
|
||||||
val c = Calendar.getInstance().also { it.set(1970, 0, 1) }
|
|
||||||
if (!birthday.value.isNullOrBlank()) {
|
|
||||||
birthday.value?.let { birthday ->
|
|
||||||
DateFormat.getDateInstance(DateFormat.SHORT, Locale.FRANCE).parse(birthday)
|
|
||||||
?.let { c.time = it }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val year = c.get(Calendar.YEAR)
|
|
||||||
val month = c.get(Calendar.MONTH)
|
|
||||||
val day = c.get(Calendar.DAY_OF_MONTH)
|
|
||||||
|
|
||||||
val dpd = DatePickerDialog(
|
|
||||||
app,
|
|
||||||
DatePickerDialog.OnDateSetListener { _, yearPicked, monthOfYear, dayOfMonth ->
|
|
||||||
birthday.value =
|
|
||||||
"${getFormattedDayOrMonth(dayOfMonth)}/${getFormattedDayOrMonth(monthOfYear + 1)}/$yearPicked"
|
|
||||||
},
|
|
||||||
year,
|
|
||||||
month,
|
|
||||||
day
|
|
||||||
)
|
|
||||||
dpd.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun onExitDateClick() {
|
|
||||||
val c = Calendar.getInstance()
|
|
||||||
val year = c.get(Calendar.YEAR)
|
|
||||||
val month = c.get(Calendar.MONTH)
|
|
||||||
val day = c.get(Calendar.DAY_OF_MONTH)
|
|
||||||
|
|
||||||
val dpd = DatePickerDialog(
|
|
||||||
app,
|
|
||||||
DatePickerDialog.OnDateSetListener { _, yearPicked, monthOfYear, dayOfMonth ->
|
|
||||||
exitDate.value =
|
|
||||||
"${getFormattedDayOrMonth(dayOfMonth)}/${getFormattedDayOrMonth(monthOfYear + 1)}/$yearPicked"
|
|
||||||
},
|
|
||||||
year,
|
|
||||||
month,
|
|
||||||
day
|
|
||||||
)
|
|
||||||
dpd.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun onExitHourClick() {
|
|
||||||
val c = Calendar.getInstance()
|
|
||||||
val hour = c.get(Calendar.HOUR_OF_DAY)
|
|
||||||
val minute = c.get(Calendar.MINUTE)
|
|
||||||
|
|
||||||
val tpd = TimePickerDialog(
|
|
||||||
app,
|
|
||||||
TimePickerDialog.OnTimeSetListener { _, hourPicked, minutePicked ->
|
|
||||||
exitHour.value =
|
|
||||||
"${getFormattedDayOrMonth(hourPicked)}:${getFormattedDayOrMonth(minutePicked)}"
|
|
||||||
},
|
|
||||||
hour,
|
|
||||||
minute,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
tpd.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setProfileValue()
|
setProfileValue()
|
||||||
setDateHourToday()
|
setDateHourToday()
|
||||||
@ -231,13 +164,4 @@ class AddViewModel(
|
|||||||
|| reason7.value!!
|
|| reason7.value!!
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getFormattedDayOrMonth(date: Int): String {
|
|
||||||
var formattedDate: String = date.toString()
|
|
||||||
|
|
||||||
if (formattedDate.length <= 1) {
|
|
||||||
formattedDate = "0$formattedDate"
|
|
||||||
}
|
|
||||||
return formattedDate
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package fr.sanchezm.attestationsCovid19.ui.add
|
package fr.sanchezm.attestationsCovid19.ui.add
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import fr.sanchezm.attestationsCovid19.data.repository.AttestationRepository
|
import fr.sanchezm.attestationsCovid19.data.repository.AttestationRepository
|
||||||
@ -10,13 +9,12 @@ import fr.sanchezm.attestationsCovid19.data.repository.ProfileRepository
|
|||||||
class AddViewModelFactory(
|
class AddViewModelFactory(
|
||||||
private val configRepository: ConfigRepository,
|
private val configRepository: ConfigRepository,
|
||||||
private val profileRepository: ProfileRepository,
|
private val profileRepository: ProfileRepository,
|
||||||
private val attestationRepository: AttestationRepository,
|
private val attestationRepository: AttestationRepository
|
||||||
private val app: Context
|
|
||||||
) :
|
) :
|
||||||
ViewModelProvider.NewInstanceFactory() {
|
ViewModelProvider.NewInstanceFactory() {
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
|
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
|
||||||
return AddViewModel(configRepository, profileRepository, attestationRepository, app) as T
|
return AddViewModel(configRepository, profileRepository, attestationRepository) as T
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,8 +16,7 @@ object InjectorUtils {
|
|||||||
AddViewModelFactory(
|
AddViewModelFactory(
|
||||||
getConfigRepo(context),
|
getConfigRepo(context),
|
||||||
getProfileRepo(context),
|
getProfileRepo(context),
|
||||||
getAttestationRepo(context),
|
getAttestationRepo(context)
|
||||||
context
|
|
||||||
)
|
)
|
||||||
|
|
||||||
fun provideAttestationViewModel(context: Context): AttestationsViewModelFactory =
|
fun provideAttestationViewModel(context: Context): AttestationsViewModelFactory =
|
||||||
|
@ -130,8 +130,8 @@ class PdfUtils private constructor(
|
|||||||
addressField.value = "${profile.address} ${profile.postalCode} ${profile.city}"
|
addressField.value = "${profile.address} ${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(":")[0]
|
hourField.value = attestation.exitHour.split("h")[0]
|
||||||
minutesField.value = attestation.exitHour.split(":")[1]
|
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}")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
tools:context=".ui.add.AddFragment">
|
tools:context=".ui.add.AddFragment">
|
||||||
|
|
||||||
<data>
|
<data>
|
||||||
@ -12,9 +12,9 @@
|
|||||||
</data>
|
</data>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/constraintContext"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/constraintContext">
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -34,10 +34,10 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:textStyle="bold"
|
||||||
android:text="@string/attestation_title"
|
android:text="@string/attestation_title"
|
||||||
android:textColor="?attr/colorPrimary"
|
android:textColor="?attr/colorPrimary"
|
||||||
android:textSize="25sp"
|
android:textSize="25sp" />
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -88,11 +88,9 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:inputType="date"
|
android:inputType="date"
|
||||||
android:focusable="false"
|
|
||||||
android:onClick="@{() -> viewModel.onBirthdayClick()}"
|
|
||||||
android:text="@={viewModel.birthday}"
|
android:text="@={viewModel.birthday}"
|
||||||
app:validateDate='@{"dd/MM/yyyy"}'
|
app:validateDate='@{"dd/MM/yyyy"}'
|
||||||
app:validateDateMessage="@{@string/date_error_message}" />
|
app:validateDateMessage="@{@string/date_error_message}"/>
|
||||||
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
@ -166,12 +164,10 @@
|
|||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:focusable="false"
|
|
||||||
android:inputType="date"
|
android:inputType="date"
|
||||||
android:onClick="@{() -> viewModel.onExitDateClick()}"
|
|
||||||
android:text="@={viewModel.exitDate}"
|
android:text="@={viewModel.exitDate}"
|
||||||
app:validateDate='@{"dd/MM/yyyy"}'
|
app:validateDate='@{"dd/MM/yyyy"}'
|
||||||
app:validateDateMessage="@{@string/date_error_message}" />
|
app:validateDateMessage="@{@string/date_error_message}"/>
|
||||||
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
@ -185,9 +181,7 @@
|
|||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:focusable="false"
|
|
||||||
android:inputType="time"
|
android:inputType="time"
|
||||||
android:onClick="@{() -> viewModel.onExitHourClick()}"
|
|
||||||
android:text="@={viewModel.exitHour}" />
|
android:text="@={viewModel.exitHour}" />
|
||||||
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
@ -263,6 +257,7 @@
|
|||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="20dp"
|
||||||
android:onClick="@{() -> viewModel.onGenerateAttestationClick()}"
|
android:onClick="@{() -> viewModel.onGenerateAttestationClick()}"
|
||||||
android:text="@string/generate_attestation_button" />
|
android:text="@string/generate_attestation_button" />
|
||||||
|
<!-- android:enabled="false"-->
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
Reference in New Issue
Block a user