Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/anrouxel/MedicApp into Do…
Browse files Browse the repository at this point in the history
…wnloadFromApi

# Conflicts:
#	app/src/main/java/fr/medicapp/medicapp/ui/navigation/UserNavGraph.kt
  • Loading branch information
marine committed Feb 29, 2024
2 parents 1e0b455 + 17c722e commit 2ef59cd
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Android CI
name: Android Nightly

on:
schedule:
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/android_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Android Test

on:
pull_request:
push:
workflow_dispatch:

permissions:
contents: write

jobs:
Nightly:
name: '📦 Test'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew test
1 change: 0 additions & 1 deletion app/src/main/java/fr/medicapp/medicapp/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.annotation.RequiresApi
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.navigation.compose.rememberNavController
import fr.medicapp.medicapp.ai.PrescriptionAI
import fr.medicapp.medicapp.api.address.apiInteractions.MedicationDownload
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fr.medicapp.medicapp.ui.navigation

import android.content.Context
import android.content.SharedPreferences
import android.os.Build
import android.util.Log
import androidx.annotation.RequiresApi
Expand All @@ -14,6 +15,8 @@ import fr.medicapp.medicapp.ui.components.screen.Loading
import fr.medicapp.medicapp.ui.screen.user.UserEditAllergy
import fr.medicapp.medicapp.ui.screen.user.UserEditGeneralInformation
import fr.medicapp.medicapp.viewModel.SharedUserEditViewModel
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.callbackFlow

/**
* Cette fonction construit le graphe de navigation pour l'écran utilisateur.
Expand Down Expand Up @@ -68,10 +71,20 @@ fun NavGraphBuilder.userNavGraph(
LaunchedEffect(Unit) {
val sharedPreferences =
context.getSharedPreferences("medicapp", Context.MODE_PRIVATE)
snapshotFlow {
sharedPreferences.getBoolean("isDataDownloaded", false)
}.collect {
if(it) {
callbackFlow {
val listener = SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
if (key == "isDataDownloaded") {
this.trySend(sharedPreferences.getBoolean(key, false)).isSuccess
}
}
sharedPreferences.registerOnSharedPreferenceChangeListener(listener)
awaitClose {
sharedPreferences.unregisterOnSharedPreferenceChangeListener(
listener
)
}
}.collect { isDataDownloaded ->
if (isDataDownloaded) {
Log.d("Guegueintervention", "ça change !!!!!!!")
navController.navigate(Graph.HOME) {
popUpTo(Graph.HOME) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fun DoctorItem(
onDoctorClick: (Long) -> Unit
) {
ReusableElevatedCardButton(
onClick = {onDoctorClick(doctor.nationalId) }
onClick = { onDoctorClick(doctor.nationalId) }
) {
CardContent(
title = "${doctor.civilCodeEx} ${doctor.firstName} ${doctor.lastName}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import com.google.accompanist.permissions.rememberPermissionState
import fr.medicapp.medicapp.ui.components.button.ReusableButton
import fr.medicapp.medicapp.ui.components.button.ReusableOutlinedDateRangePickerButton
import fr.medicapp.medicapp.ui.components.button.ReusableOutlinedSearchButton
import fr.medicapp.medicapp.ui.components.button.ReusableOutlinedTextFieldButton
import fr.medicapp.medicapp.ui.components.card.ReusableElevatedCard
import fr.medicapp.medicapp.ui.components.screen.Edit
import fr.medicapp.medicapp.ui.components.textfield.ReusableOutlinedTextField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DoctorViewModel : ViewModel() {
private val _doctors = MutableLiveData<List<Doctor>>()
val doctors: LiveData<List<Doctor>> get() = _doctors

fun searchDoctor(query: Long, callback: (List<Doctor>) -> Unit){
fun searchDoctor(query: Long, callback: (List<Doctor>) -> Unit) {
viewModelScope.launch {
val searchResults = DoctorsSearch().searchDoctor(query) { doctors ->
_doctors.postValue(doctors)
Expand All @@ -21,7 +21,7 @@ class DoctorViewModel : ViewModel() {
}
}

fun searchLittleDoctor(query: String, callback: (List<Doctor>) -> Unit){
fun searchLittleDoctor(query: String, callback: (List<Doctor>) -> Unit) {
viewModelScope.launch {
val searchResults = DoctorsSearch().searchLittleDoctor(query) { doctors ->
_doctors.postValue(doctors)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SharedDoctorDetailViewModel(
)
val sharedState: StateFlow<Doctor> = _sharedState

fun loadDoctor(id : Long) {
fun loadDoctor(id: Long) {
DoctorsSearch().searchDoctor(id) {
_sharedState.value = it.first()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.toMutableStateList
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import fr.medicapp.medicapp.ai.PrescriptionAI
import fr.medicapp.medicapp.api.address.apiInteractions.DoctorsSearch
import fr.medicapp.medicapp.database.repositories.medication.MedicationRepository
import fr.medicapp.medicapp.database.repositories.prescription.DoctorRepository
import fr.medicapp.medicapp.database.repositories.prescription.PrescriptionRepository
import fr.medicapp.medicapp.model.OptionDialog
import fr.medicapp.medicapp.model.prescription.Alarm
import fr.medicapp.medicapp.model.prescription.Doctor
import fr.medicapp.medicapp.model.prescription.Duration
import fr.medicapp.medicapp.model.prescription.relationship.Notification
import fr.medicapp.medicapp.model.prescription.relationship.Prescription
Expand All @@ -26,7 +24,6 @@ import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.time.DayOfWeek

Expand Down Expand Up @@ -178,7 +175,7 @@ class SharedPrescriptionEditViewModel(
NotificationPrescriptionManager.add(context, _sharedState.value[0].getNextAlarms())
}

suspend fun searchDoctor(query: String) : List<OptionDialog> {
suspend fun searchDoctor(query: String): List<OptionDialog> {
return withContext(dispatcher) {
val doctors = mutableListOf<OptionDialog>()
DoctorsSearch().searchLittleDoctor(query) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.medicapp.medicapp.ai.tokenization

import fr.medicapp.medicapp.tokenization.BasicTokenizer
import org.junit.Assert.assertEquals
import org.junit.Test

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.medicapp.medicapp.ai.tokenization

import fr.medicapp.medicapp.tokenization.BasicTokenizer
import org.junit.Assert.assertEquals
import org.junit.Test

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.medicapp.medicapp.ai.tokenization

import fr.medicapp.medicapp.tokenization.BasicTokenizer
import org.junit.Assert.assertEquals
import org.junit.Test

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.medicapp.medicapp.ai.tokenization

import fr.medicapp.medicapp.tokenization.CharChecker
import org.junit.Test
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ValueSource
Expand Down

0 comments on commit 2ef59cd

Please sign in to comment.