From dd91303137a6b0e5d3714e94c6199b2c7c8f7614 Mon Sep 17 00:00:00 2001 From: Mathieu Sanchez Date: Tue, 14 Apr 2020 16:44:17 +0200 Subject: [PATCH] Add Info Page --- app/build.gradle | 10 ++- .../attestationsCovid19/data/db/MyDatabase.kt | 28 ++++++- .../data/db/dao/AttestationDao.kt | 26 +++--- .../data/db/dao/ProfileDao.kt | 52 +++++++++--- .../data/repository/AttestationRepository.kt | 14 ++-- .../data/repository/ProfileRepository.kt | 26 ++++-- .../attestationsCovid19/ui/add/AddFragment.kt | 25 ++++-- .../ui/add/AddViewModel.kt | 39 ++++++++- .../ui/add/AddViewModelFactory.kt | 8 +- .../ui/attestations/AttestationsFragment.kt | 15 ++-- .../ui/attestations/AttestationsViewModel.kt | 10 +-- .../ui/info/InfoFragment.kt | 40 ++++++++++ .../attestationsCovid19/utilities/Event.kt | 17 ++++ .../utilities/InjectorUtils.kt | 20 +++-- app/src/main/res/drawable/ic_info_24dp.xml | 9 +++ app/src/main/res/layout-v26/fragment_info.xml | 79 +++++++++++++++++++ .../res/layout/fragment_add_attestation.xml | 27 ++++--- app/src/main/res/layout/fragment_info.xml | 78 ++++++++++++++++++ app/src/main/res/menu/bottom_nav_menu.xml | 6 ++ .../main/res/navigation/mobile_navigation.xml | 6 ++ app/src/main/res/values-v26/styles.xml | 13 +++ app/src/main/res/values/strings.xml | 14 ++++ app/src/main/res/values/styles.xml | 10 +++ 23 files changed, 496 insertions(+), 76 deletions(-) create mode 100644 app/src/main/java/fr/sanchezm/attestationsCovid19/ui/info/InfoFragment.kt create mode 100644 app/src/main/java/fr/sanchezm/attestationsCovid19/utilities/Event.kt create mode 100644 app/src/main/res/drawable/ic_info_24dp.xml create mode 100644 app/src/main/res/layout-v26/fragment_info.xml create mode 100644 app/src/main/res/layout/fragment_info.xml create mode 100644 app/src/main/res/values-v26/styles.xml diff --git a/app/build.gradle b/app/build.gradle index f6c0cdc..7426c18 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -26,6 +26,10 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } + applicationVariants.all { variant -> + variant.resValue "string", "versionName", variant.versionName + } + buildTypes { release { minifyEnabled false @@ -66,7 +70,11 @@ dependencies { implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0' kapt 'androidx.room:room-compiler:2.2.5' -// kapt 'com.android.databinding:compiler:3.1.4' + // PDF + implementation 'com.tom_roush:pdfbox-android:1.8.10.1' + + // Gson + implementation 'com.google.code.gson:gson:2.8.6' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' diff --git a/app/src/main/java/fr/sanchezm/attestationsCovid19/data/db/MyDatabase.kt b/app/src/main/java/fr/sanchezm/attestationsCovid19/data/db/MyDatabase.kt index cbb9303..7c3785f 100644 --- a/app/src/main/java/fr/sanchezm/attestationsCovid19/data/db/MyDatabase.kt +++ b/app/src/main/java/fr/sanchezm/attestationsCovid19/data/db/MyDatabase.kt @@ -1,5 +1,30 @@ package fr.sanchezm.attestationsCovid19.data.db +import android.content.Context +import fr.sanchezm.attestationsCovid19.data.db.dao.AttestationDao +import fr.sanchezm.attestationsCovid19.data.db.dao.ProfileDao + +class MyDatabase private constructor(private val path: String) { + + private val _profileDao: ProfileDao? = null + private val _attestationDao: AttestationDao? = null + + fun profileDao() : ProfileDao = _profileDao ?: ProfileDao(path) + + fun attestationDao() : AttestationDao = _attestationDao ?: AttestationDao(path) + + companion object { + @Volatile + private var instance: MyDatabase? = null + private val LOCK = Any() + + operator fun invoke(context: Context) = instance ?: synchronized(LOCK) { + instance ?: MyDatabase(context.filesDir.path).also { instance = it } + } + } +} + +/* import android.content.Context import androidx.room.Database import androidx.room.Room @@ -33,4 +58,5 @@ abstract class MyDatabase private constructor() : RoomDatabase() { ) .build() } -} \ No newline at end of file +} +*/ diff --git a/app/src/main/java/fr/sanchezm/attestationsCovid19/data/db/dao/AttestationDao.kt b/app/src/main/java/fr/sanchezm/attestationsCovid19/data/db/dao/AttestationDao.kt index 969b954..b5bafe5 100644 --- a/app/src/main/java/fr/sanchezm/attestationsCovid19/data/db/dao/AttestationDao.kt +++ b/app/src/main/java/fr/sanchezm/attestationsCovid19/data/db/dao/AttestationDao.kt @@ -1,20 +1,14 @@ package fr.sanchezm.attestationsCovid19.data.db.dao -import androidx.lifecycle.LiveData -import androidx.room.Dao -import androidx.room.Insert -import androidx.room.OnConflictStrategy -import androidx.room.Query -import fr.sanchezm.attestationsCovid19.data.db.entity.Attestation -import fr.sanchezm.attestationsCovid19.data.db.entity.CURRENT_ATTESTATION_ID -import fr.sanchezm.attestationsCovid19.data.db.entity.CURRENT_PROFILE_ID -import fr.sanchezm.attestationsCovid19.data.db.entity.Profile +class AttestationDao(private val path: String) { -@Dao -interface AttestationDao { - @Insert - fun insert(attestation: Attestation) +} - @Query(value = "SELECT * FROM attestation WHERE id = $CURRENT_ATTESTATION_ID") - fun getAttestation(): LiveData -} \ No newline at end of file +//@Dao +//interface AttestationDao { +// @Insert +// fun insert(attestation: Attestation) +// +// @Query(value = "SELECT * FROM attestation WHERE id = $CURRENT_ATTESTATION_ID") +// fun getAttestation(): LiveData +//} \ No newline at end of file diff --git a/app/src/main/java/fr/sanchezm/attestationsCovid19/data/db/dao/ProfileDao.kt b/app/src/main/java/fr/sanchezm/attestationsCovid19/data/db/dao/ProfileDao.kt index 0d8d6a0..e4617db 100644 --- a/app/src/main/java/fr/sanchezm/attestationsCovid19/data/db/dao/ProfileDao.kt +++ b/app/src/main/java/fr/sanchezm/attestationsCovid19/data/db/dao/ProfileDao.kt @@ -1,18 +1,46 @@ package fr.sanchezm.attestationsCovid19.data.db.dao import androidx.lifecycle.LiveData -import androidx.room.Dao -import androidx.room.Insert -import androidx.room.OnConflictStrategy -import androidx.room.Query -import fr.sanchezm.attestationsCovid19.data.db.entity.CURRENT_PROFILE_ID +import androidx.lifecycle.MutableLiveData +import com.google.gson.Gson import fr.sanchezm.attestationsCovid19.data.db.entity.Profile +import java.io.File -@Dao -interface ProfileDao { - @Insert(onConflict = OnConflictStrategy.REPLACE) - fun insert(profile: Profile) +class ProfileDao(private val path: String) { - @Query(value = "SELECT * FROM profile WHERE id = $CURRENT_PROFILE_ID") - fun getProfile(): LiveData -} \ No newline at end of file + private var _profile = MutableLiveData() + private var fileName = "profile.db" + + fun getProfile(): LiveData = + _profile + + fun updateProfile(profile: Profile) { + _profile.value = profile + save() + } + + init { + load() + } + + private fun load() { + val file = File("$path/$fileName") + + if (file.exists()) { + _profile.value = Gson().fromJson(file.readText(Charsets.UTF_8), Profile::class.java) + } + } + + private fun save() { + File("$path/$fileName").writeText(Gson().toJson(this)) + } +} + +//@Dao +//interface ProfileDao { +// @Insert(onConflict = OnConflictStrategy.REPLACE) +// fun insert(profile: Profile) +// +// @Query(value = "SELECT * FROM profile WHERE id = $CURRENT_PROFILE_ID") +// fun getProfile(): LiveData +//} diff --git a/app/src/main/java/fr/sanchezm/attestationsCovid19/data/repository/AttestationRepository.kt b/app/src/main/java/fr/sanchezm/attestationsCovid19/data/repository/AttestationRepository.kt index 242debf..724bdb4 100644 --- a/app/src/main/java/fr/sanchezm/attestationsCovid19/data/repository/AttestationRepository.kt +++ b/app/src/main/java/fr/sanchezm/attestationsCovid19/data/repository/AttestationRepository.kt @@ -5,19 +5,23 @@ import fr.sanchezm.attestationsCovid19.data.db.dao.ProfileDao import fr.sanchezm.attestationsCovid19.data.db.entity.Attestation import fr.sanchezm.attestationsCovid19.data.db.entity.Profile -class AttestationRepository private constructor(private val attestationDao: AttestationDao) { +class AttestationRepository private constructor(/*private val attestationDao: AttestationDao*/) { - fun getProfile() = attestationDao.getAttestation() +// fun getAttestation() = attestationDao.getAttestation() - fun insertProfile(attestation: Attestation) = attestationDao.insert(attestation) + fun createAttestation() { + + } +// fun insertAttestation(attestation: Attestation) = attestationDao.insert(attestation) companion object { @Volatile private var instance: AttestationRepository? = null - fun getInstance(attestationDao: AttestationDao) = + fun getInstance(/*attestationDao: AttestationDao*/) = instance ?: synchronized(this) { - instance ?: AttestationRepository(attestationDao).also { instance = it } +// instance ?: AttestationRepository(attestationDao).also { instance = it } + instance ?: AttestationRepository().also { instance = it } } } } \ No newline at end of file diff --git a/app/src/main/java/fr/sanchezm/attestationsCovid19/data/repository/ProfileRepository.kt b/app/src/main/java/fr/sanchezm/attestationsCovid19/data/repository/ProfileRepository.kt index 1d02318..7e5cb14 100644 --- a/app/src/main/java/fr/sanchezm/attestationsCovid19/data/repository/ProfileRepository.kt +++ b/app/src/main/java/fr/sanchezm/attestationsCovid19/data/repository/ProfileRepository.kt @@ -1,21 +1,35 @@ package fr.sanchezm.attestationsCovid19.data.repository -import fr.sanchezm.attestationsCovid19.data.db.dao.ProfileDao +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData import fr.sanchezm.attestationsCovid19.data.db.entity.Profile -class ProfileRepository private constructor(private val profileDao: ProfileDao) { +class ProfileRepository private constructor(/*private val profileDao: ProfileDao*/) { - fun getProfile() = profileDao.getProfile() + private var _profile = MutableLiveData(Profile( + "Mathieu", + "Sanchez", + "19/11/1997", + "Perpignan", + "33 Rue Salvador Dali", + "Canohes", + "66680" + )) - fun insertProfile(profile: Profile) = profileDao.insert(profile) + fun getProfile(): LiveData = _profile + + // fun insertProfile(profile: Profile) = profileDao.insert(profile) + fun insertProfile(profile: Profile) { + _profile.value = profile + } companion object { @Volatile private var instance: ProfileRepository? = null - fun getInstance(profileDao: ProfileDao) = + fun getInstance(/*profileDao: ProfileDao*/) = instance ?: synchronized(this) { - instance ?: ProfileRepository(profileDao).also { instance = it } + instance ?: ProfileRepository(/*profileDao*/).also { instance = it } } } } \ No newline at end of file diff --git a/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/add/AddFragment.kt b/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/add/AddFragment.kt index fb8722e..f65e529 100644 --- a/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/add/AddFragment.kt +++ b/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/add/AddFragment.kt @@ -1,12 +1,15 @@ package fr.sanchezm.attestationsCovid19.ui.add import android.os.Bundle +import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.databinding.DataBindingUtil import androidx.fragment.app.Fragment +import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider +import com.google.android.material.snackbar.Snackbar import fr.sanchezm.attestationsCovid19.R import fr.sanchezm.attestationsCovid19.databinding.FragmentAddAttestationBinding import fr.sanchezm.attestationsCovid19.utilities.InjectorUtils @@ -31,14 +34,26 @@ class AddFragment : Fragment() { this.viewModel = addViewModel } + bindMessage(binding.context) return binding.root } + private fun bindMessage(context: View) { + addViewModel.errorMessage.observe(viewLifecycleOwner, Observer { + it.getContentIfNotHandled()?.let { stringId -> + Snackbar.make(context, stringId, Snackbar.LENGTH_SHORT ).show() + } + }); + } + private fun initializeUi() { - val factory = context?.let { InjectorUtils.provideAddViewModelFactory(it) } - addViewModel = factory?.let { - ViewModelProvider(this, it) - .get(AddViewModel::class.java) - }!! +// val factory = context?.let { InjectorUtils.provideAddViewModelFactory(it) } +// addViewModel = factory?.let { +// ViewModelProvider(this, it) +// .get(AddViewModel::class.java) +// }!! + val factory = InjectorUtils.provideAddViewModelFactory() + addViewModel = ViewModelProvider(this, factory) + .get(AddViewModel::class.java) } } diff --git a/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/add/AddViewModel.kt b/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/add/AddViewModel.kt index 8aa1bd7..57c39bc 100644 --- a/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/add/AddViewModel.kt +++ b/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/add/AddViewModel.kt @@ -2,12 +2,24 @@ package fr.sanchezm.attestationsCovid19.ui.add import android.annotation.SuppressLint import android.util.Log +import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel +import fr.sanchezm.attestationsCovid19.R import fr.sanchezm.attestationsCovid19.data.db.entity.Profile +import fr.sanchezm.attestationsCovid19.data.repository.AttestationRepository import fr.sanchezm.attestationsCovid19.data.repository.ProfileRepository +import fr.sanchezm.attestationsCovid19.utilities.Event -class AddViewModel(private val profileRepository: ProfileRepository) : ViewModel() { +class AddViewModel( + private val profileRepository: ProfileRepository, + private val attestationRepository: AttestationRepository +) : ViewModel() { + + private val _errorMessage = MutableLiveData>() + + val errorMessage: LiveData> + get() = _errorMessage val firstName = MutableLiveData() val lastName = MutableLiveData() @@ -19,12 +31,22 @@ class AddViewModel(private val profileRepository: ProfileRepository) : ViewModel val exitDate = MutableLiveData() val exitHour = MutableLiveData() + val reason1 = MutableLiveData(false) + val reason2 = MutableLiveData(false) + val reason3 = MutableLiveData(false) + val reason4 = MutableLiveData(false) + val reason5 = MutableLiveData(false) + val reason6 = MutableLiveData(false) + val reason7 = MutableLiveData(false) + @SuppressLint("LongLogTag") fun onGenerateAttestationClick() { if (checkAllValue()) { profileRepository.insertProfile(getProfileFromView()) + attestationRepository.createAttestation() } else { - Log.e("onGenerateAttestationClick", "Cannot add profile") + _errorMessage.value = Event(R.string.error_cannot_create_attestation) + Log.e("onGenerateAttestationClick", "Cannot generate Attestation") } } @@ -64,6 +86,19 @@ class AddViewModel(private val profileRepository: ProfileRepository) : ViewModel && !address.value.isNullOrEmpty() && !city.value.isNullOrEmpty() && !postalCode.value.isNullOrEmpty() + && !exitDate.value.isNullOrEmpty() + && !exitHour.value.isNullOrEmpty() + && checkAtLeastOneReasonSelected() + } + + private fun checkAtLeastOneReasonSelected(): Boolean { + return reason1.value!! + || reason2.value!! + || reason3.value!! + || reason4.value!! + || reason5.value!! + || reason6.value!! + || reason7.value!! } } \ No newline at end of file diff --git a/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/add/AddViewModelFactory.kt b/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/add/AddViewModelFactory.kt index f8fcbf9..5570fb7 100644 --- a/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/add/AddViewModelFactory.kt +++ b/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/add/AddViewModelFactory.kt @@ -2,13 +2,17 @@ package fr.sanchezm.attestationsCovid19.ui.add import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider +import fr.sanchezm.attestationsCovid19.data.repository.AttestationRepository import fr.sanchezm.attestationsCovid19.data.repository.ProfileRepository -class AddViewModelFactory(private val profileRepository: ProfileRepository) : +class AddViewModelFactory( + private val profileRepository: ProfileRepository, + private val attestationRepository: AttestationRepository +) : ViewModelProvider.NewInstanceFactory() { @Suppress("UNCHECKED_CAST") override fun create(modelClass: Class): T { - return AddViewModel(profileRepository) as T + return AddViewModel(profileRepository, attestationRepository) as T } } \ No newline at end of file diff --git a/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/attestations/AttestationsFragment.kt b/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/attestations/AttestationsFragment.kt index 35d5915..15e3740 100644 --- a/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/attestations/AttestationsFragment.kt +++ b/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/attestations/AttestationsFragment.kt @@ -23,7 +23,7 @@ class AttestationsFragment : Fragment() { initializeUi() val binding = DataBindingUtil.inflate( inflater, - R.layout.fragment_add_attestation, + R.layout.fragment_attestations, container, false ).apply { @@ -35,10 +35,13 @@ class AttestationsFragment : Fragment() { } private fun initializeUi() { - val factory = context?.let { InjectorUtils.provideAddViewModelFactory(it) } - attestationsViewModel = factory?.let { - ViewModelProvider(this, it) - .get(AttestationsViewModel::class.java) - }!! +// val factory = context?.let { InjectorUtils.provideAttestationViewModel(it) } +// attestationsViewModel = factory?.let { +// ViewModelProvider(this, it) +// .get(AttestationsViewModel::class.java) +// }!! + val factory = InjectorUtils.provideAttestationViewModel() + attestationsViewModel = ViewModelProvider(this, factory) + .get(AttestationsViewModel::class.java) } } \ No newline at end of file diff --git a/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/attestations/AttestationsViewModel.kt b/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/attestations/AttestationsViewModel.kt index df298aa..b6b5093 100644 --- a/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/attestations/AttestationsViewModel.kt +++ b/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/attestations/AttestationsViewModel.kt @@ -1,14 +1,12 @@ package fr.sanchezm.attestationsCovid19.ui.attestations -import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import fr.sanchezm.attestationsCovid19.data.repository.AttestationRepository class AttestationsViewModel(private val attestationRepository: AttestationRepository) : ViewModel() { - private val _text = MutableLiveData().apply { - value = "This is dashboard Fragment" - } - val text: LiveData = _text +// private val _text = MutableLiveData().apply { +// value = "This is dashboard Fragment" +// } +// val text: LiveData = _text } \ No newline at end of file diff --git a/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/info/InfoFragment.kt b/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/info/InfoFragment.kt new file mode 100644 index 0000000..f7fba86 --- /dev/null +++ b/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/info/InfoFragment.kt @@ -0,0 +1,40 @@ +package fr.sanchezm.attestationsCovid19.ui.info + +import android.os.Bundle; +import android.text.method.LinkMovementMethod +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; + +class InfoFragment : Fragment() { + + override fun onCreateView( + inflater:LayoutInflater, + container:ViewGroup?, + savedInstanceState:Bundle? + ): View? { + val root = inflater.inflate(R.layout.fragment_info, container, false) + + root.findViewById(R.id.develop_by).movementMethod = LinkMovementMethod.getInstance() + root.findViewById(R.id.version).text = getVersionText() + return root + } + + private fun getVersionText(): String { + val versionText = getString(R.string.version_number); + val versionName = BuildConfig.VERSION_NAME + + return "$versionText $versionName" + } +} + + + + + + diff --git a/app/src/main/java/fr/sanchezm/attestationsCovid19/utilities/Event.kt b/app/src/main/java/fr/sanchezm/attestationsCovid19/utilities/Event.kt new file mode 100644 index 0000000..5a5fe43 --- /dev/null +++ b/app/src/main/java/fr/sanchezm/attestationsCovid19/utilities/Event.kt @@ -0,0 +1,17 @@ +package fr.sanchezm.attestationsCovid19.utilities + +open class Event(private val content: T) { + var hasBeenHandled = false + private set + + fun getContentIfNotHandled(): T? { + return if (hasBeenHandled) { + null + } else { + hasBeenHandled = true + content + } + } + + fun peekContent(): T = content +} \ No newline at end of file diff --git a/app/src/main/java/fr/sanchezm/attestationsCovid19/utilities/InjectorUtils.kt b/app/src/main/java/fr/sanchezm/attestationsCovid19/utilities/InjectorUtils.kt index 23175b9..1e1e0e4 100644 --- a/app/src/main/java/fr/sanchezm/attestationsCovid19/utilities/InjectorUtils.kt +++ b/app/src/main/java/fr/sanchezm/attestationsCovid19/utilities/InjectorUtils.kt @@ -5,20 +5,30 @@ import fr.sanchezm.attestationsCovid19.data.db.MyDatabase import fr.sanchezm.attestationsCovid19.data.repository.AttestationRepository import fr.sanchezm.attestationsCovid19.data.repository.ProfileRepository import fr.sanchezm.attestationsCovid19.ui.add.AddViewModelFactory -import fr.sanchezm.attestationsCovid19.ui.attestations.AttestationsViewModel +import fr.sanchezm.attestationsCovid19.ui.attestations.AttestationsViewModelFactory object InjectorUtils { fun provideAddViewModelFactory(context: Context): AddViewModelFactory { +// val profileRepository = +// ProfileRepository.getInstance() +// val attestationRepository = +// AttestationRepository.getInstance() val profileRepository = ProfileRepository.getInstance(MyDatabase.invoke(context).profileDao()) + val attestationRepository = + AttestationRepository.getInstance(MyDatabase.invoke(context).attestationDao()) - return AddViewModelFactory(profileRepository = profileRepository) + return AddViewModelFactory(profileRepository, attestationRepository) } - fun provideAttestationViewModel(context: Context): AttestationsViewModel { - val attestationRepository = AttestationRepository.getInstance(MyDatabase.invoke(context).attestationDao()) - return AttestationsViewModel(attestationRepository) + fun provideAttestationViewModel(/*context: Context*/): AttestationsViewModelFactory { + val attestationRepository = + AttestationRepository.getInstance() +// val attestationRepository = +// AttestationRepository.getInstance(MyDatabase.invoke(context).attestationDao()) + + return AttestationsViewModelFactory(attestationRepository) } } \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_info_24dp.xml b/app/src/main/res/drawable/ic_info_24dp.xml new file mode 100644 index 0000000..cc94088 --- /dev/null +++ b/app/src/main/res/drawable/ic_info_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout-v26/fragment_info.xml b/app/src/main/res/layout-v26/fragment_info.xml new file mode 100644 index 0000000..6af002f --- /dev/null +++ b/app/src/main/res/layout-v26/fragment_info.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_add_attestation.xml b/app/src/main/res/layout/fragment_add_attestation.xml index 41e91cb..d97a72f 100644 --- a/app/src/main/res/layout/fragment_add_attestation.xml +++ b/app/src/main/res/layout/fragment_add_attestation.xml @@ -13,6 +13,7 @@ @@ -71,7 +73,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textPersonName|textCapWords" - android:text="@{viewModel.lastName}" /> + android:text="@={viewModel.lastName}" /> @@ -86,7 +88,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="date" - android:text="@{viewModel.birthday}" /> + android:text="@={viewModel.birthday}" /> @@ -101,7 +103,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text|textCapWords" - android:text="@{viewModel.birthPlace}" /> + android:text="@={viewModel.birthPlace}" /> @@ -116,7 +118,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textPostalAddress|textCapWords" - android:text="@{viewModel.address}" /> + android:text="@={viewModel.address}" /> @@ -131,7 +133,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text|textCapWords" - android:text="@{viewModel.city}" /> + android:text="@={viewModel.city}" /> @@ -146,7 +148,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text|textCapWords" - android:text="@{viewModel.postalCode}" /> + android:text="@={viewModel.postalCode}" /> @@ -161,7 +163,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="date" - android:text="@{viewModel.exitDate}" /> + android:text="@={viewModel.exitDate}" /> @@ -176,7 +178,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="time" - android:text="@{viewModel.exitHour}" /> + android:text="@={viewModel.exitHour}" /> @@ -193,6 +195,7 @@ style="@style/MaterialCheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:checked="@={viewModel.reason1}" android:text="@string/reason_1" /> + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml index 5236ab6..14e4c6e 100644 --- a/app/src/main/res/menu/bottom_nav_menu.xml +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -14,4 +14,10 @@ android:title="@string/title_attestations" app:itemBackground="?attr/itemBackground" /> + + diff --git a/app/src/main/res/navigation/mobile_navigation.xml b/app/src/main/res/navigation/mobile_navigation.xml index 2edb615..4d6a9dc 100644 --- a/app/src/main/res/navigation/mobile_navigation.xml +++ b/app/src/main/res/navigation/mobile_navigation.xml @@ -17,4 +17,10 @@ android:label="@string/title_attestations" tools:layout="@layout/fragment_attestations" /> + + diff --git a/app/src/main/res/values-v26/styles.xml b/app/src/main/res/values-v26/styles.xml new file mode 100644 index 0000000..24f6f19 --- /dev/null +++ b/app/src/main/res/values-v26/styles.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1f3fbef..7577999 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2,10 +2,14 @@ Attestation de déplacement dérogatoire Nouvelle Attestation Mes Attestations + À Propos + Attestation de déplacement dérogatoire #RestonsChezNous + Erreur lors de la génération de l\'attestation, tout les champs ne sont pas compléter + Prénom Nom Date de naissance @@ -18,6 +22,7 @@ Heure de sortie Générer l\'attestation + 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. 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 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. @@ -25,4 +30,13 @@ 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. Convocation judiciaire ou administrative. Participation à des missions d’intérêt général sur demande de l’autorité administrative. + + + - Merci de n\'utiliser l\'application quand cas de nécessité. + - Cette application n\'aura jamais de publicité. + - Toutes les données sont stockées uniquement sur votre téléphone, utilisable hors ligne. + - Application non gouvernementale ni officiel, développer par un étudiant. + "Développer avec ❤️ par + Mathieu Sanchez" + Version : diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 3843c51..d14ec18 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -34,7 +34,17 @@ @color/colorAccent + + + 18sp 20dp + 20dp 5dp 0dp