Compare commits
3 Commits
1.0.5-beta
...
ms/issue-5
Author | SHA1 | Date | |
---|---|---|---|
a914e5e0fd | |||
54a57b65ab | |||
5f373a19d7 |
@ -15,8 +15,8 @@ android {
|
||||
applicationId "fr.sanchezm.attestationsCovid19"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 29
|
||||
versionCode 1002
|
||||
versionName "1.0.5-beta1"
|
||||
versionCode 6
|
||||
versionName "1.0.4"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import android.content.Context
|
||||
import fr.sanchezm.attestationsCovid19.data.db.dao.AttestationDao
|
||||
import fr.sanchezm.attestationsCovid19.data.db.dao.ConfigDao
|
||||
import fr.sanchezm.attestationsCovid19.data.db.dao.ProfileDao
|
||||
import fr.sanchezm.attestationsCovid19.data.repository.ConfigRepository
|
||||
|
||||
class MyDatabase private constructor(private val savePath: String, private val filesPath: String) {
|
||||
|
||||
@ -11,10 +12,15 @@ class MyDatabase private constructor(private val savePath: String, private val f
|
||||
private var _attestationDao: AttestationDao? = null
|
||||
private var _configDao: ConfigDao? = null
|
||||
|
||||
fun profileDao(): ProfileDao = _profileDao ?: ProfileDao(savePath).also { _profileDao = it }
|
||||
fun profileDao(configRepository: ConfigRepository): ProfileDao =
|
||||
_profileDao ?: ProfileDao(savePath, configRepository).also { _profileDao = it }
|
||||
|
||||
fun attestationDao(): AttestationDao =
|
||||
_attestationDao ?: AttestationDao(savePath, filesPath).also { _attestationDao = it }
|
||||
fun attestationDao(configRepository: ConfigRepository): AttestationDao =
|
||||
_attestationDao ?: AttestationDao(
|
||||
savePath,
|
||||
filesPath,
|
||||
configRepository
|
||||
).also { _attestationDao = it }
|
||||
|
||||
fun configDao(): ConfigDao = _configDao ?: ConfigDao(savePath).also { _configDao = it }
|
||||
|
||||
@ -28,40 +34,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()
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -6,10 +6,15 @@ import androidx.lifecycle.MutableLiveData
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import fr.sanchezm.attestationsCovid19.data.db.entity.Attestation
|
||||
import fr.sanchezm.attestationsCovid19.data.repository.ConfigRepository
|
||||
import fr.sanchezm.attestationsCovid19.utilities.PdfUtils
|
||||
import java.io.File
|
||||
|
||||
class AttestationDao(private val savePath: String, private val filesPath: String) {
|
||||
class AttestationDao(
|
||||
private val savePath: String,
|
||||
private val filesPath: String,
|
||||
private val configRepository: ConfigRepository
|
||||
) {
|
||||
|
||||
private val _attestations = MutableLiveData<ArrayList<Attestation>>()
|
||||
private val fileName = "attestation.db"
|
||||
@ -23,9 +28,8 @@ class AttestationDao(private val savePath: String, private val filesPath: String
|
||||
_attestations.value?.elementAt(id)
|
||||
|
||||
fun addAttestation(attestation: Attestation) {
|
||||
_attestations.value = _attestations.value ?: ArrayList()
|
||||
|
||||
_attestations.value?.add(attestation)
|
||||
_attestations.value = _attestations.value
|
||||
Log.d(TAG, "Add Attestation : $attestation")
|
||||
save()
|
||||
}
|
||||
@ -66,6 +70,8 @@ class AttestationDao(private val savePath: String, private val filesPath: String
|
||||
|
||||
if (file.exists()) {
|
||||
_attestations.value = Gson().fromJson(file.readText(Charsets.UTF_8), type)
|
||||
} else {
|
||||
_attestations.value = ArrayList()
|
||||
}
|
||||
_attestations.value?.forEach {
|
||||
val filePath = PdfUtils.getPath(filesPath, it.createAt)
|
||||
|
@ -33,7 +33,12 @@ class ConfigDao(private val savePath: String) {
|
||||
_config.value?.versionName = BuildConfig.VERSION_NAME
|
||||
} else {
|
||||
_config.value =
|
||||
Config(BuildConfig.DB_VERSION, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)
|
||||
Config(
|
||||
BuildConfig.DB_VERSION,
|
||||
BuildConfig.VERSION_NAME,
|
||||
BuildConfig.VERSION_CODE,
|
||||
-1
|
||||
)
|
||||
save()
|
||||
}
|
||||
}
|
||||
|
@ -1,48 +1,77 @@
|
||||
package fr.sanchezm.attestationsCovid19.data.db.dao
|
||||
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import fr.sanchezm.attestationsCovid19.BuildConfig
|
||||
import fr.sanchezm.attestationsCovid19.data.db.entity.Profile
|
||||
import fr.sanchezm.attestationsCovid19.data.repository.ConfigRepository
|
||||
import fr.sanchezm.attestationsCovid19.utilities.DbMigration
|
||||
import java.io.File
|
||||
|
||||
class ProfileDao(private val path: String) {
|
||||
class ProfileDao(private val path: String, private val configRepository: ConfigRepository) {
|
||||
|
||||
private val _profile = MutableLiveData<Profile>()
|
||||
private val _profile = MutableLiveData<ArrayList<Profile>>()
|
||||
private val fileName = "profile.db"
|
||||
private val type = object : TypeToken<ArrayList<Profile>>() {}.type
|
||||
|
||||
fun getProfile(): LiveData<Profile> =
|
||||
_profile
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getProfiles(): LiveData<List<Profile>> =
|
||||
_profile as LiveData<List<Profile>>
|
||||
|
||||
fun updateProfile(profile: Profile) {
|
||||
_profile.value = profile
|
||||
fun getProfile(id: Int): Profile? =
|
||||
_profile.value?.get(id)
|
||||
|
||||
fun getProfileId(profile: Profile): Int? =
|
||||
_profile.value?.indexOf(profile)
|
||||
|
||||
fun addProfile(profile: Profile): Int {
|
||||
_profile.value?.add(profile)
|
||||
_profile.value = _profile.value
|
||||
save()
|
||||
|
||||
return _profile.value?.indexOf(profile)!!
|
||||
}
|
||||
|
||||
init {
|
||||
val currentDbVersion = configRepository.getConfig().value!!.dbVersion
|
||||
val appDbVersion = BuildConfig.DB_VERSION
|
||||
|
||||
if (currentDbVersion != appDbVersion) {
|
||||
if (currentDbVersion == 1 && appDbVersion == 2) {
|
||||
_profile.value = DbMigration.migrateProfileFrom1To2("$path/$fileName")
|
||||
save()
|
||||
configRepository.getConfig().value!!.let {
|
||||
it.dbVersion = appDbVersion
|
||||
configRepository.updateConfig(it)
|
||||
}
|
||||
Log.d(TAG, "Db version update from $currentDbVersion to $appDbVersion")
|
||||
} else {
|
||||
File("$path/$fileName").delete()
|
||||
load()
|
||||
}
|
||||
} else {
|
||||
load()
|
||||
}
|
||||
}
|
||||
|
||||
private fun load() {
|
||||
val file = File("$path/$fileName")
|
||||
|
||||
if (file.exists()) {
|
||||
_profile.value = Gson().fromJson(file.readText(Charsets.UTF_8), Profile::class.java)
|
||||
_profile.value = Gson().fromJson(file.readText(Charsets.UTF_8), type)
|
||||
} else {
|
||||
_profile.value = Profile("", "", "", "", "", "", "")
|
||||
_profile.value = ArrayList()
|
||||
}
|
||||
}
|
||||
|
||||
private fun save() {
|
||||
File("$path/$fileName").writeText(Gson().toJson(_profile.value))
|
||||
}
|
||||
}
|
||||
|
||||
//@Dao
|
||||
//interface ProfileDao {
|
||||
// @Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
// fun insert(profile: Profile)
|
||||
//
|
||||
// @Query(value = "SELECT * FROM profile WHERE id = $CURRENT_PROFILE_ID")
|
||||
// fun getProfile(): LiveData<Profile>
|
||||
//}
|
||||
companion object {
|
||||
private val TAG = ProfileDao::class.simpleName
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,8 @@ package fr.sanchezm.attestationsCovid19.data.db.entity
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
const val PATTERN = "dd/MM/yyyy 'à' HH:mm"
|
||||
const val PATTERN = "dd/MM/yyyy 'a' HH'h'mm"
|
||||
|
||||
//@Entity(tableName = "attestation")
|
||||
data class Attestation(
|
||||
val profile: Profile,
|
||||
val exitDate: String,
|
||||
|
@ -1,7 +1,8 @@
|
||||
package fr.sanchezm.attestationsCovid19.data.db.entity
|
||||
|
||||
data class Config(
|
||||
val dbVersion: Int,
|
||||
var dbVersion: Int,
|
||||
var versionName: String,
|
||||
var versionCode: Int
|
||||
var versionCode: Int,
|
||||
var selectProfileId: Int
|
||||
)
|
@ -1,6 +1,5 @@
|
||||
package fr.sanchezm.attestationsCovid19.data.db.entity
|
||||
|
||||
//@Entity(tableName = "profile")
|
||||
data class Profile(
|
||||
val firstName: String,
|
||||
val lastName: String,
|
||||
@ -10,8 +9,6 @@ data class Profile(
|
||||
val city: String,
|
||||
val postalCode: String
|
||||
) {
|
||||
// @PrimaryKey
|
||||
// var id: Int = CURRENT_PROFILE_ID
|
||||
|
||||
override fun toString(): String {
|
||||
return "Nom: $lastName; Prenom: $firstName; Naissance: $birthday a $birthPlace; Adresse: $address $postalCode $city"
|
||||
|
@ -6,11 +6,14 @@ import fr.sanchezm.attestationsCovid19.data.db.entity.Profile
|
||||
|
||||
class ProfileRepository private constructor(private val profileDao: ProfileDao) {
|
||||
|
||||
fun getProfile(): LiveData<Profile> =
|
||||
profileDao.getProfile()
|
||||
fun getProfiles(): LiveData<List<Profile>> =
|
||||
profileDao.getProfiles()
|
||||
|
||||
fun insertProfile(profile: Profile) =
|
||||
profileDao.updateProfile(profile)
|
||||
fun getProfile(id: Int): Profile? =
|
||||
profileDao.getProfile(id)
|
||||
|
||||
fun insertProfile(profile: Profile): Int =
|
||||
profileDao.addProfile(profile)
|
||||
|
||||
companion object {
|
||||
@Volatile
|
||||
|
@ -1,9 +1,6 @@
|
||||
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
|
||||
@ -16,7 +13,6 @@ 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
|
||||
@ -25,8 +21,7 @@ import java.util.*
|
||||
class AddViewModel(
|
||||
private val configRepository: ConfigRepository,
|
||||
private val profileRepository: ProfileRepository,
|
||||
private val attestationRepository: AttestationRepository,
|
||||
private val app: Context
|
||||
private val attestationRepository: AttestationRepository
|
||||
) : ViewModel() {
|
||||
|
||||
private val _errorMessage = MutableLiveData<Event<Int>>()
|
||||
@ -63,7 +58,7 @@ class AddViewModel(
|
||||
// endregion
|
||||
|
||||
private val datePattern = "dd/MM/yyyy"
|
||||
private val timePattern = "HH:mm"
|
||||
private val timePattern = "HH'h'mm"
|
||||
|
||||
@SuppressLint("LongLogTag")
|
||||
fun onGenerateAttestationClick() {
|
||||
@ -80,83 +75,21 @@ 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 {
|
||||
setProfileValue()
|
||||
setDateHourToday()
|
||||
}
|
||||
|
||||
private fun setProfileValue() {
|
||||
val profile = profileRepository.getProfile()
|
||||
val profile = profileRepository.getProfiles().value?.first()
|
||||
|
||||
firstName.value = profile.value?.firstName
|
||||
lastName.value = profile.value?.lastName
|
||||
birthday.value = profile.value?.birthday
|
||||
birthPlace.value = profile.value?.birthPlace
|
||||
address.value = profile.value?.address
|
||||
city.value = profile.value?.city
|
||||
postalCode.value = profile.value?.postalCode
|
||||
firstName.value = profile?.firstName
|
||||
lastName.value = profile?.lastName
|
||||
birthday.value = profile?.birthday
|
||||
birthPlace.value = profile?.birthPlace
|
||||
address.value = profile?.address
|
||||
city.value = profile?.city
|
||||
postalCode.value = profile?.postalCode
|
||||
}
|
||||
|
||||
private fun setDateHourToday() {
|
||||
@ -231,13 +164,4 @@ class AddViewModel(
|
||||
|| 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
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import fr.sanchezm.attestationsCovid19.data.repository.AttestationRepository
|
||||
@ -10,13 +9,12 @@ import fr.sanchezm.attestationsCovid19.data.repository.ProfileRepository
|
||||
class AddViewModelFactory(
|
||||
private val configRepository: ConfigRepository,
|
||||
private val profileRepository: ProfileRepository,
|
||||
private val attestationRepository: AttestationRepository,
|
||||
private val app: Context
|
||||
private val attestationRepository: AttestationRepository
|
||||
) :
|
||||
ViewModelProvider.NewInstanceFactory() {
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
|
||||
return AddViewModel(configRepository, profileRepository, attestationRepository, app) as T
|
||||
return AddViewModel(configRepository, profileRepository, attestationRepository) as T
|
||||
}
|
||||
}
|
@ -1,15 +1,15 @@
|
||||
package fr.sanchezm.attestationsCovid19.ui.info
|
||||
|
||||
import android.os.Bundle
|
||||
import android.os.Bundle;
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.Fragment
|
||||
import fr.sanchezm.attestationsCovid19.BuildConfig
|
||||
|
||||
import fr.sanchezm.attestationsCovid19.R
|
||||
import kotlinx.android.synthetic.main.fragment_info.view.*
|
||||
import fr.sanchezm.attestationsCovid19.R;
|
||||
|
||||
class InfoFragment : Fragment() {
|
||||
|
||||
@ -20,19 +20,13 @@ class InfoFragment : Fragment() {
|
||||
): View? {
|
||||
val root = inflater.inflate(R.layout.fragment_info, container, false)
|
||||
|
||||
root.credits_1.movementMethod = LinkMovementMethod.getInstance()
|
||||
root.credits_2.movementMethod = LinkMovementMethod.getInstance()
|
||||
root.credits_3.movementMethod = LinkMovementMethod.getInstance()
|
||||
root.credits_4.movementMethod = LinkMovementMethod.getInstance()
|
||||
root.credits_5.movementMethod = LinkMovementMethod.getInstance()
|
||||
|
||||
root.develop_by.movementMethod = LinkMovementMethod.getInstance()
|
||||
root.version.text = getVersionText()
|
||||
root.findViewById<TextView>(R.id.develop_by).movementMethod = LinkMovementMethod.getInstance()
|
||||
root.findViewById<TextView>(R.id.version).text = getVersionText()
|
||||
return root
|
||||
}
|
||||
|
||||
private fun getVersionText(): String {
|
||||
val versionText = getString(R.string.version_number)
|
||||
val versionText = getString(R.string.version_number);
|
||||
val versionName = BuildConfig.VERSION_NAME
|
||||
|
||||
return "$versionText $versionName"
|
||||
|
@ -0,0 +1,22 @@
|
||||
package fr.sanchezm.attestationsCovid19.utilities
|
||||
|
||||
import com.google.gson.Gson
|
||||
import fr.sanchezm.attestationsCovid19.data.db.entity.Profile
|
||||
import java.io.File
|
||||
|
||||
object DbMigration {
|
||||
|
||||
fun migrateProfileFrom1To2(filename: String): ArrayList<Profile> {
|
||||
val file = File(filename)
|
||||
val list = ArrayList<Profile>()
|
||||
|
||||
val profile: Profile = if (file.exists()) {
|
||||
Gson().fromJson(file.readText(Charsets.UTF_8), Profile::class.java)
|
||||
} else {
|
||||
Profile("", "", "", "", "", "", "")
|
||||
}
|
||||
list.add(profile)
|
||||
|
||||
return list
|
||||
}
|
||||
}
|
@ -16,8 +16,7 @@ object InjectorUtils {
|
||||
AddViewModelFactory(
|
||||
getConfigRepo(context),
|
||||
getProfileRepo(context),
|
||||
getAttestationRepo(context),
|
||||
context
|
||||
getAttestationRepo(context)
|
||||
)
|
||||
|
||||
fun provideAttestationViewModel(context: Context): AttestationsViewModelFactory =
|
||||
@ -40,11 +39,12 @@ object InjectorUtils {
|
||||
|
||||
private fun getAttestationRepo(context: Context): AttestationRepository =
|
||||
AttestationRepository.getInstance(
|
||||
MyDatabase.invoke(context, getMyFilesDir(context)).attestationDao()
|
||||
MyDatabase.invoke(context, getMyFilesDir(context))
|
||||
.attestationDao(getConfigRepo(context))
|
||||
)
|
||||
|
||||
private fun getProfileRepo(context: Context): ProfileRepository = ProfileRepository.getInstance(
|
||||
MyDatabase.invoke(context, getMyFilesDir(context)).profileDao()
|
||||
MyDatabase.invoke(context, getMyFilesDir(context)).profileDao(getConfigRepo(context))
|
||||
)
|
||||
|
||||
private fun getConfigRepo(context: Context): ConfigRepository = ConfigRepository.getInstance(
|
||||
|
@ -130,8 +130,8 @@ class PdfUtils private constructor(
|
||||
addressField.value = "${profile.address} ${profile.postalCode} ${profile.city}"
|
||||
cityField.value = profile.city
|
||||
dateField.value = attestation.exitDate
|
||||
hourField.value = attestation.exitHour.split(":")[0]
|
||||
minutesField.value = attestation.exitHour.split(":")[1]
|
||||
hourField.value = attestation.exitHour.split("h")[0]
|
||||
minutesField.value = attestation.exitHour.split("h")[1]
|
||||
return true
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "${e.message}")
|
||||
|
79
app/src/main/res/layout-v26/fragment_info.xml
Normal file
79
app/src/main/res/layout-v26/fragment_info.xml
Normal file
@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingHorizontal="30dp"
|
||||
android:paddingVertical="20dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="30sp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="?attr/colorPrimaryDark"
|
||||
android:text="@string/title_info"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/explication_1"
|
||||
android:text="@string/explication_1"
|
||||
android:layout_marginTop="40dp"
|
||||
style="@style/TextView"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/explication_2"
|
||||
android:text="@string/explication_2"
|
||||
style="@style/TextView"
|
||||
android:justificationMode="inter_word"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/explication_1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/explication_3"
|
||||
android:text="@string/explication_3"
|
||||
style="@style/TextView"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/explication_2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/explication_4"
|
||||
android:text="@string/explication_4"
|
||||
style="@style/TextView"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/explication_3" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/develop_by"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp"
|
||||
android:textColor="?attr/colorPrimaryDark"
|
||||
android:text="@string/develop_by"
|
||||
android:layout_marginBottom="5dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/version" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/version"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/version_number"
|
||||
android:textSize="12sp"
|
||||
android:textColor="?attr/colorAccent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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:app="http://schemas.android.com/apk/res-auto"
|
||||
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:layout_height="match_parent"
|
||||
android:id="@+id/constraintContext">
|
||||
|
||||
<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:textStyle="bold" />
|
||||
android:textSize="25sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
@ -88,11 +88,9 @@
|
||||
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>
|
||||
|
||||
@ -121,7 +119,7 @@
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textPostalAddress|textCapWords"
|
||||
android:inputType="number|textCapWords"
|
||||
android:text="@={viewModel.address}" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
@ -166,12 +164,10 @@
|
||||
<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>
|
||||
|
||||
@ -185,9 +181,7 @@
|
||||
<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>
|
||||
@ -263,6 +257,7 @@
|
||||
android:layout_marginTop="20dp"
|
||||
android:onClick="@{() -> viewModel.onGenerateAttestationClick()}"
|
||||
android:text="@string/generate_attestation_button" />
|
||||
<!-- android:enabled="false"-->
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -52,58 +52,6 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/explication_3" />
|
||||
|
||||
<TextView
|
||||
android:layout_marginTop="20dp"
|
||||
android:id="@+id/credits_title"
|
||||
android:text="@string/credits_title"
|
||||
android:textSize="17sp"
|
||||
android:textStyle="bold"
|
||||
style="@style/TextViewCredits"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/explication_4" />
|
||||
|
||||
<TextView
|
||||
android:layout_marginTop="10dp"
|
||||
android:id="@+id/credits_1"
|
||||
android:text="@string/credits_1"
|
||||
style="@style/TextViewCredits"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/credits_title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/credits_2"
|
||||
android:text="@string/credits_2"
|
||||
style="@style/TextViewCredits"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/credits_1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/credits_3"
|
||||
android:text="@string/credits_3"
|
||||
style="@style/TextViewCredits"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/credits_2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/credits_4"
|
||||
android:text="@string/credits_4"
|
||||
style="@style/TextViewCredits"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/credits_3" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/credits_5"
|
||||
android:text="@string/credits_5"
|
||||
style="@style/TextViewCredits"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/credits_4" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/develop_by"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -4,7 +4,7 @@
|
||||
<style name="TextView">
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:layout_marginTop">@dimen/margin15dp</item>
|
||||
<item name="android:layout_marginTop">@dimen/margin20dp</item>
|
||||
<item name="android:textColor">@color/colorPrimary</item>
|
||||
<item name="android:textSize">@dimen/textSize18sp</item>
|
||||
<item name="android:justificationMode">inter_word</item>
|
||||
|
@ -5,9 +5,9 @@
|
||||
<string name="title_info">À Propos</string>
|
||||
|
||||
<!-- Attestation Fragment -->
|
||||
<string name="attestation_title">@string/app_name</string>
|
||||
<string name="attestation_title">Attestation de déplacement dérogatoire</string>
|
||||
<string name="attestation_subtitle">#RestonsChezNous</string>
|
||||
<string name="attestation_generated">Attestation générée</string>
|
||||
<string name="attestation_generated">Attestation générer</string>
|
||||
<string name="no_attestation">Aucune attestation, veuillez en générer une.</string>
|
||||
|
||||
<!-- Field for attestation -->
|
||||
@ -33,17 +33,11 @@
|
||||
<string name="reason_7">Participation à des missions d’intérêt général sur demande de l’autorité administrative.</string>
|
||||
|
||||
<!-- 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 quand cas de nécessité.</string>
|
||||
<string name="explication_2">- Cette application n\'aura jamais de publicité.</string>
|
||||
<string name="explication_3">- Toutes les données sont stockées uniquement sur votre téléphone, utilisable hors ligne.</string>
|
||||
<string name="explication_4">- Application non gouvernementale ni officielle, développée par un étudiant.</string>
|
||||
<string name="credits_title">Petit remerciement pour l\'aide apportée au développement de l\'application :</string>
|
||||
<string name="credits_1">TomRoush: <a href="https://github.com/TomRoush/PdfBox-Android">PdfBox-Android</a></string>
|
||||
<string name="credits_2">Barteksc: <a href="https://github.com/barteksc/AndroidPdfViewer">AndroidPdfViewer</a></string>
|
||||
<string name="credits_3">Journeyapps: <a href="https://github.com/journeyapps/zxing-android-embedded">zxing-android-embedded</a></string>
|
||||
<string name="credits_4">Ainsi que toutes les libraries fourni par google</string>
|
||||
<string name="credits_5">Merci à <a href="https://www.linkedin.com/in/julienfabbro/">Fabbro J.</a> pour l\'aide sur l\'orthographe</string>
|
||||
<string name="develop_by">"Développée avec ❤ par
|
||||
<string name="explication_4">- Application non gouvernementale ni officiel, développer par un étudiant.</string>
|
||||
<string name="develop_by">"Développer avec ❤️ par
|
||||
<a href="https://www.sanchezm.fr/">Mathieu Sanchez</a>"</string>
|
||||
<string name="version_number">Version :</string>
|
||||
|
||||
|
@ -37,20 +37,14 @@
|
||||
<style name="TextView" parent="Widget.MaterialComponents.TextView">
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:layout_marginTop">@dimen/margin15dp</item>
|
||||
<item name="android:layout_marginTop">@dimen/margin20dp</item>
|
||||
<item name="android:textColor">@color/colorPrimary</item>
|
||||
<item name="android:textSize">@dimen/textSize18sp</item>
|
||||
</style>
|
||||
|
||||
<style name="TextViewCredits" parent="TextView">
|
||||
<item name="android:textSize">@dimen/textSize14sp</item>
|
||||
<item name="android:layout_marginTop">@dimen/margin5dp</item>
|
||||
</style>
|
||||
|
||||
<dimen name="textSize18sp">18sp</dimen>
|
||||
<dimen name="textSize14sp">14sp</dimen>
|
||||
<dimen name="textInputCornerRadius">20dp</dimen>
|
||||
<dimen name="margin15dp">15dp</dimen>
|
||||
<dimen name="margin20dp">20dp</dimen>
|
||||
<dimen name="margin5dp">5dp</dimen>
|
||||
<dimen name="emptySize">0dp</dimen>
|
||||
</resources>
|
||||
|
@ -3,8 +3,7 @@
|
||||
buildscript {
|
||||
ext {
|
||||
kotlin_version = '1.3.72'
|
||||
db_version = '1'
|
||||
|
||||
db_version = '2'
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
Reference in New Issue
Block a user