13 Commits

Author SHA1 Message Date
1530028f4b Version 2.0.1-beta1 version code 1004 2020-10-30 08:50:16 +01:00
20d41dec23 Merge branch 'ms/issue-16/update_new_attestation' into beta 2020-10-30 08:49:09 +01:00
b712c391ce Version 2.0.0-beta1 code 1003 2020-10-24 17:34:02 +02:00
b04cd541b4 Merge master in beta 2020-10-24 17:33:03 +02:00
055be5f968 Merge branch 'master' into beta
# Conflicts:
#	app/build.gradle
#	app/src/main/java/fr/sanchezm/attestationsCovid19/utilities/PdfUtils.kt
2020-10-24 17:23:06 +02:00
af6cef0cd4 Version 1.0.5-beta1 version code 1002 2020-05-02 15:47:23 +02:00
3b2bf5f0ae Merge branch 'ms/issue-14/adding-pickers' into beta
# Conflicts:
#	app/build.gradle
2020-05-02 15:46:43 +02:00
5cb3478bb6 Adding pickers for date and time 2020-05-02 15:46:08 +02:00
fac797ed32 Version 1.0.4-beta2 version code 1001 2020-05-02 14:47:57 +02:00
731920ca28 Merge branch 'ms/issue-4/add-credits-libraries-used' into beta 2020-05-02 14:46:45 +02:00
7d8c509e9c 1.0.4-beta1 version code 1000 2020-04-29 23:56:48 +02:00
50cd345a53 Merge pull request 'Adding config for alpha and beta build' (#12) from adding-config-alpha-beta into beta 2020-04-29 21:48:52 +00:00
8f965e5322 Merge pull request 'Adding credits and correct spelling mistake' (#10) from ms/issue-4/add-credits-libraries-used into beta 2020-04-29 21:46:11 +00:00
6 changed files with 100 additions and 18 deletions

View File

@ -15,8 +15,8 @@ android {
applicationId "fr.sanchezm.attestationsCovid19"
minSdkVersion 23
targetSdkVersion 30
versionCode 9
versionName "2.0.0"
versionCode 1004
versionName "2.0.1-beta1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@ -82,9 +82,7 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.1'
implementation 'androidx.navigation:navigation-fragment:2.3.1'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.1'
implementation 'androidx.navigation:navigation-ui:2.3.1'
// Design
implementation 'com.google.android.material:material:1.2.1'

View File

@ -3,7 +3,7 @@ package fr.sanchezm.attestationsCovid19.data.db.entity
import java.text.SimpleDateFormat
import java.util.*
const val PATTERN = "dd/MM/yyyy 'à' HH'h'mm"
const val PATTERN = "dd/MM/yyyy 'à' HH:mm"
//@Entity(tableName = "attestation")
data class Attestation(

View File

@ -1,6 +1,9 @@
package fr.sanchezm.attestationsCovid19.ui.add
import android.annotation.SuppressLint
import android.app.DatePickerDialog
import android.app.TimePickerDialog
import android.content.Context
import android.os.Build
import android.util.Log
import androidx.lifecycle.LiveData
@ -13,6 +16,7 @@ import fr.sanchezm.attestationsCovid19.data.repository.AttestationRepository
import fr.sanchezm.attestationsCovid19.data.repository.ConfigRepository
import fr.sanchezm.attestationsCovid19.data.repository.ProfileRepository
import fr.sanchezm.attestationsCovid19.utilities.Event
import java.text.DateFormat
import java.text.SimpleDateFormat
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
@ -21,7 +25,8 @@ import java.util.*
class AddViewModel(
private val configRepository: ConfigRepository,
private val profileRepository: ProfileRepository,
private val attestationRepository: AttestationRepository
private val attestationRepository: AttestationRepository,
private val app: Context
) : ViewModel() {
private val _errorMessage = MutableLiveData<Event<Int>>()
@ -60,7 +65,7 @@ class AddViewModel(
// endregion
private val datePattern = "dd/MM/yyyy"
private val timePattern = "HH'h'mm"
private val timePattern = "HH:mm"
@SuppressLint("LongLogTag")
fun onGenerateAttestationClick() {
@ -77,6 +82,68 @@ 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,
{ _, 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 {
setProfileValue()
setDateHourToday()
@ -170,4 +237,13 @@ class AddViewModel(
|| reason9.value!!
}
private fun getFormattedDayOrMonth(date: Int): String {
var formattedDate: String = date.toString()
if (formattedDate.length <= 1) {
formattedDate = "0$formattedDate"
}
return formattedDate
}
}

View File

@ -1,5 +1,6 @@
package fr.sanchezm.attestationsCovid19.ui.add
import android.content.Context
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import fr.sanchezm.attestationsCovid19.data.repository.AttestationRepository
@ -9,12 +10,13 @@ import fr.sanchezm.attestationsCovid19.data.repository.ProfileRepository
class AddViewModelFactory(
private val configRepository: ConfigRepository,
private val profileRepository: ProfileRepository,
private val attestationRepository: AttestationRepository
private val attestationRepository: AttestationRepository,
private val app: Context
) :
ViewModelProvider.NewInstanceFactory() {
@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
return AddViewModel(configRepository, profileRepository, attestationRepository) as T
return AddViewModel(configRepository, profileRepository, attestationRepository, app) as T
}
}

View File

@ -16,7 +16,8 @@ object InjectorUtils {
AddViewModelFactory(
getConfigRepo(context),
getProfileRepo(context),
getAttestationRepo(context)
getAttestationRepo(context),
context
)
fun provideAttestationViewModel(context: Context): AttestationsViewModelFactory =

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".ui.add.AddFragment">
<data>
@ -12,9 +12,9 @@
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintContext"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/constraintContext">
android:layout_height="match_parent">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
@ -34,10 +34,10 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="@string/attestation_title"
android:textColor="?attr/colorPrimary"
android:textSize="25sp" />
android:textSize="25sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
@ -88,9 +88,11 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="date"
android:focusable="false"
android:onClick="@{() -> viewModel.onBirthdayClick()}"
android:text="@={viewModel.birthday}"
app:validateDate='@{"dd/MM/yyyy"}'
app:validateDateMessage="@{@string/date_error_message}"/>
app:validateDateMessage="@{@string/date_error_message}" />
</com.google.android.material.textfield.TextInputLayout>
@ -164,10 +166,12 @@
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:inputType="date"
android:onClick="@{() -> viewModel.onExitDateClick()}"
android:text="@={viewModel.exitDate}"
app:validateDate='@{"dd/MM/yyyy"}'
app:validateDateMessage="@{@string/date_error_message}"/>
app:validateDateMessage="@{@string/date_error_message}" />
</com.google.android.material.textfield.TextInputLayout>
@ -181,7 +185,9 @@
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:inputType="time"
android:onClick="@{() -> viewModel.onExitHourClick()}"
android:text="@={viewModel.exitHour}" />
</com.google.android.material.textfield.TextInputLayout>
@ -273,7 +279,6 @@
android:layout_marginTop="20dp"
android:onClick="@{() -> viewModel.onGenerateAttestationClick()}"
android:text="@string/generate_attestation_button" />
<!-- android:enabled="false"-->
</LinearLayout>