Skip to content

Commit

Permalink
Merge pull request #26 from Passiolife/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
marinPassio authored Oct 4, 2024
2 parents 206cd03 + 06fe780 commit f5de247
Show file tree
Hide file tree
Showing 189 changed files with 9,960 additions and 3,657 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/ai/passio/uimodule/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class MainActivity : ComponentActivity() {
).apply {
sdkDownloadsModels = true
debugMode = -333
remoteOnly = true
}

PassioSDK.instance.configure(passioConfiguration) { passioStatus ->
Expand Down
Binary file modified passio-sdk/passiolib-release.aar
Binary file not shown.
3 changes: 3 additions & 0 deletions passio-ui-module/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,8 @@ dependencies {
implementation 'io.noties.markwon:html:4.6.2'
// implementation 'io.noties.markwon:syntax-highlight:4.6.2'

implementation 'com.intuit.sdp:sdp-android:1.1.1'
implementation 'com.intuit.ssp:ssp-android:1.1.1'


}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ interface PassioConnector {
fun initialize()

suspend fun updateRecord(foodRecord: FoodRecord): Boolean

suspend fun updateRecords(foodRecords: List<FoodRecord>): Boolean

suspend fun deleteRecord(foodRecord: FoodRecord): Boolean
suspend fun deleteRecord(uuid: String): Boolean

suspend fun fetchDayRecords(day: Date): List<FoodRecord>

Expand All @@ -36,6 +37,7 @@ interface PassioConnector {
suspend fun removeWeightRecord(weightRecord: WeightRecord): Boolean

suspend fun fetchWeightRecords(startDate: Date, endDate: Date): List<WeightRecord>

suspend fun fetchLatestWeightRecord(): WeightRecord?

suspend fun updateWaterRecord(waterRecord: WaterRecord): Boolean
Expand All @@ -44,4 +46,24 @@ interface PassioConnector {

suspend fun fetchWaterRecords(startDate: Date, endDate: Date): List<WaterRecord>

suspend fun saveCustomFood(foodRecord: FoodRecord): Boolean

suspend fun fetchCustomFoods(): List<FoodRecord>
suspend fun fetchCustomFoods(searchQuery: String): List<FoodRecord>

suspend fun fetchCustomFood(uuid: String): FoodRecord?

suspend fun deleteCustomFood(uuid: String): Boolean

suspend fun getCustomFoodUsingBarcode(barcode: String): FoodRecord?

suspend fun saveRecipe(foodRecord: FoodRecord): Boolean

suspend fun fetchRecipe(uuid: String): FoodRecord?

suspend fun fetchRecipes(): List<FoodRecord>

suspend fun fetchRecipes(searchQuery: String): List<FoodRecord>

suspend fun deleteRecipe(uuid: String): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import android.content.SharedPreferences
class PassioDemoSharedPreferences(private val sharedPreferences: SharedPreferences) {

companion object Key {
const val PREF_NAME = "PassioDemoPrefs"
const val PREF_NAME = "PassioUIPrefs"
private const val PREF_FOOD_RECORDS = "foodRecords"
private const val PREF_CUSTOM_FOODS = "customFoods"
private const val PREF_RECIPES = "recipes"
private const val PREF_WEIGHT_RECORDS = "weightRecords"
private const val PREF_WATER_RECORDS = "waterRecords"
private const val PREF_FOOD_FAVORITES = "foodFavorites"
Expand All @@ -20,6 +22,21 @@ class PassioDemoSharedPreferences(private val sharedPreferences: SharedPreferenc
fun getRecords(): Set<String> {
return sharedPreferences.getStringSet(PREF_FOOD_RECORDS, hashSetOf())!!
}

fun saveCustomFoods(customFoods: List<String>) {
sharedPreferences.edit().putStringSet(PREF_CUSTOM_FOODS, customFoods.toSet()).apply()
}

fun getCustomFoods(): Set<String> {
return sharedPreferences.getStringSet(PREF_CUSTOM_FOODS, hashSetOf())!!
}
fun saveRecipes(recipes: List<String>) {
sharedPreferences.edit().putStringSet(PREF_RECIPES, recipes.toSet()).apply()
}

fun getRecipes(): Set<String> {
return sharedPreferences.getStringSet(PREF_RECIPES, hashSetOf())!!
}
fun getWeightRecords(): Set<String> {
return sharedPreferences.getStringSet(PREF_WEIGHT_RECORDS, hashSetOf())!!
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ai.passio.nutrition.uimodule.ui.model.UserProfile
import ai.passio.nutrition.uimodule.ui.model.WaterRecord
import ai.passio.nutrition.uimodule.ui.model.WeightRecord
import ai.passio.nutrition.uimodule.ui.progress.TimePeriod
import ai.passio.nutrition.uimodule.ui.util.StringKT.isValid
import ai.passio.nutrition.uimodule.ui.util.getBefore30Days
import ai.passio.nutrition.uimodule.ui.util.getEndOfMonth
import ai.passio.nutrition.uimodule.ui.util.getEndOfWeek
Expand Down Expand Up @@ -124,8 +125,8 @@ class Repository private constructor() {
return connector.updateRecords(records)
}

suspend fun deleteFoodRecord(record: FoodRecord): Boolean {
return connector.deleteRecord(record)
suspend fun deleteFoodRecord(uuid: String): Boolean {
return connector.deleteRecord(uuid)
}

suspend fun getLogsForDay(day: Date): List<FoodRecord> {
Expand Down Expand Up @@ -233,4 +234,57 @@ class Repository private constructor() {
return connector.fetchWaterRecords(startDate.toDate(), endDate.toDate())
}

suspend fun saveCustomFood(record: FoodRecord): Boolean {
return connector.saveCustomFood(record)
}

suspend fun fetchCustomFoods(): List<FoodRecord> {
return connector.fetchCustomFoods()
}

suspend fun fetchCustomFoods(searchQuery: String): List<FoodRecord> {
return if (!searchQuery.isValid()) {
emptyList()
} else {
connector.fetchCustomFoods(searchQuery)
}
}

suspend fun fetchCustomFood(uuid: String): FoodRecord? {
return connector.fetchCustomFood(uuid)
}

suspend fun deleteCustomFood(uuid: String): Boolean {
return connector.deleteCustomFood(uuid)
}

suspend fun getCustomFoodUsingBarcode(barcode: String): FoodRecord? {
return connector.getCustomFoodUsingBarcode(barcode)
}


suspend fun saveRecipe(record: FoodRecord): Boolean {
return connector.saveRecipe(record)
}

suspend fun fetchRecipes(): List<FoodRecord> {
return connector.fetchRecipes()
}

suspend fun fetchRecipes(searchQuery: String): List<FoodRecord> {
return if (!searchQuery.isValid()) {
emptyList()
} else {
connector.fetchRecipes(searchQuery)
}
}

suspend fun fetchRecipe(id: String): FoodRecord? {
return connector.fetchRecipe(id)
}

suspend fun deleteRecipe(uuid: String): Boolean {
return connector.deleteRecipe(uuid)
}

}
Loading

0 comments on commit f5de247

Please sign in to comment.