Skip to content

Commit

Permalink
Release 3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
marinPassio committed Apr 19, 2024
1 parent e791b21 commit a7dcac0
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 84 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Passio SDK

[![release](https://img.shields.io/badge/release-v3.0.2-brightgreen)](https://github.com/Passiolife/Passio-Nutrition-AI-Android-SDK-Distribution/releases/tag/v3.0.2) [![release](https://img.shields.io/badge/platform-Android-lightgray)]() [![release](https://img.shields.io/badge/minimum--suported--version-26-lightgray)](https://developer.android.com/about/versions/oreo) [![release](https://img.shields.io/badge/Kotlin-v1.6.10-informational)](https://github.com/JetBrains/kotlin/releases/tag/v1.6.10) [![release](https://img.shields.io/badge/codelab-Get_started-important)](https://musing-gates-4e7160.netlify.app/#0)
[![release](https://img.shields.io/badge/release-v3.0.3-brightgreen)](https://github.com/Passiolife/Passio-Nutrition-AI-Android-SDK-Distribution/releases/tag/v3.0.3) [![release](https://img.shields.io/badge/platform-Android-lightgray)]() [![release](https://img.shields.io/badge/minimum--suported--version-26-lightgray)](https://developer.android.com/about/versions/oreo) [![release](https://img.shields.io/badge/Kotlin-v1.6.10-informational)](https://github.com/JetBrains/kotlin/releases/tag/v1.6.10) [![release](https://img.shields.io/badge/codelab-Get_started-important)](https://musing-gates-4e7160.netlify.app/#0)

## Overview:

Expand Down
28 changes: 28 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,34 @@

Full project was build with **Kotlin 1.6.10**

## V3.0.3

* Added APIs

* Added two APIs to fetch a list of meal plans and fetch a meal plan for a certain day.

```kotlin
fun fetchMealPlans(callback: (result: List<PassioMealPlan>) -> Unit)

fun fetchMealPlanForDay(
mealPlanLabel: String,
day: Int,
callback: (result: List<PassioMealPlanItem>) -> Unit
)
```

* Added values for carbs protein and fat in the ```PassioSearchNutritionPreview``` data class.

* MealTime was renamed to ```PassioMealTime```.

* Refactored APIs

* PassioSearchResult was renamed to ```PassioFoodDataInfo```, fetchFoodItemForSearchResult was renamed to ```fetchFoodItemForDataInfo```.

* fetchFoodItemForSuggestion was removed. Instead ```fetchFoodItemForDataInfo``` is used.

*

## V3.0.2

## Added APIs
Expand Down
186 changes: 103 additions & 83 deletions SDK_API.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
# Passio SDK API

## Version 2.2.11
## Version 3.0.2

```kotlin


/**
* The identifier of a food item located in the nutritional
* database.
*/
typealias PassioID = String

/**
Expand Down Expand Up @@ -51,6 +45,8 @@ open class DetectedCandidate(
* The id used to query the nutritional database.
*/
val passioID: PassioID,

val foodName: String,
/**
* Percentage of the neural network confidence level. Ranges from 0f - 1f or 0% to 100%.
*/
Expand All @@ -64,7 +60,9 @@ open class DetectedCandidate(
/**
* Represents a part of the original image that the classification process has been ran on.
*/
val croppedImage: Bitmap?
val croppedImage: Bitmap?,

val alternatives: List<DetectedCandidate>
)

/**
Expand Down Expand Up @@ -126,7 +124,7 @@ interface FoodRecognitionListener {
* @param nutritionFacts recognized nutrition facts for the camera frame.
*/
fun onRecognitionResults(
candidates: FoodCandidates,
candidates: FoodCandidates?,
image: Bitmap?,
nutritionFacts: PassioNutritionFacts?
)
Expand Down Expand Up @@ -165,8 +163,46 @@ interface PassioStatusListener {
fun onDownloadError(message: String)
}

data class InflammatoryEffectData(
val nutrient: String,
val amount: Double,
val unit: String,
val inflammatoryEffectScore: Double,
)

data class PassioFoodDataInfo(
val foodName: String,
val brandName: String,
val iconID: PassioID,
val score: Double,
val scoredName: String,

private const val MINIMUM_CONFIDENCE_TF_OD_API = 0.33f
val labelId: String,
val type: String,
val resultId: String,
val useShortName: Boolean,

val nutritionPreview: PassioSearchNutritionPreview
)

data class PassioSearchNutritionPreview(
val calories: Int,
val carbs: Double,
val protein: Double,
val fat: Double,
val servingUnit: String,
val servingQuantity: Double,
val servingWeight: String
)

enum class PassioMealTime(val mealName: String) {
BREAKFAST("breakfast"),
LUNCH("lunch"),
DINNER("dinner"),
SNACK("snack")
}

private const val MINIMUM_CONFIDENCE_TF_OD_API = 0.3f

/**
* Main access point of the SDK. Defines all of the SDK's
Expand Down Expand Up @@ -208,8 +244,6 @@ interface PassioSDK {

@Keep
companion object {
val BARCODE_PREFIX = PassioIDEntityType.barcode.name
val PACKAGED_FOOD_PREFIX = PassioIDEntityType.packagedFoodCode.name
const val BKG_PASSIO_ID = "BKG0001"

private var internalInstance: PassioSDK? = null
Expand All @@ -231,6 +265,8 @@ interface PassioSDK {
* to the user. The default value is 0.5.
*/
fun minimumConfidence() = MINIMUM_CONFIDENCE_TF_OD_API

fun getVersion() = PassioSDKImpl.SDK_VERSION
}

/**
Expand Down Expand Up @@ -378,12 +414,23 @@ interface PassioSDK {
onDetectionCompleted: (candidates: FoodCandidates?) -> Unit
): Boolean

fun lookupIconFor(
// /**
// * @deprecated use [lookupIconsFor] instead.
// */
// @Deprecated("Use lookupIconsFor instead")
// fun lookupIconFor(
// context: Context,
// passioID: PassioID,
// iconSize: IconSize = IconSize.PX90,
// type: PassioIDEntityType = PassioIDEntityType.item,
// ): Pair<Drawable, Boolean>

fun lookupIconsFor(
context: Context,
passioID: PassioID,
iconSize: IconSize = IconSize.PX90,
type: PassioIDEntityType = PassioIDEntityType.item,
): Pair<Drawable, Boolean>
): Pair<Drawable, Drawable?>

/**
* For a given [PassioID] returns the corresponding image from the SDK's asset folder.
Expand All @@ -399,75 +446,6 @@ interface PassioSDK {
callback: (drawable: Drawable?) -> Unit
)

/**
* For a given [PassioID] returns the name of corresponding food item.
*
* @param passioID the ID of the food item
* @return name of the food item if there is a an object in the nutritional database with the
* provided passioID, null otherwise.
*/
fun lookupNameFor(passioID: PassioID): String?

/**
* For a given [PassioID] returns the [PassioIDAttributes] of that food item.
*
* @param passioID the ID of the food item
* @return attributes object that represents all of the nutritional data the SDK has on a food
* item corresponding to the passioID, null otherwise.
*/
fun lookupPassioAttributesFor(passioID: PassioID): PassioIDAttributes?

/**
* For a given food item [name] returns the [PassioIDAttributes]
* of that food item.
*
* @param name of the food item
* @return attributes object that represents all of the nutritional data the SDK
* item corresponding to the food item name, null otherwise.
*/
fun lookupPassioAttributesForName(name: String): PassioIDAttributes?

/**
* For a given [passioID] returns a list that contains the subtree of the food hierarchy that
* has the food item with the given [passioID] as a root.
*
* @param passioID the ID of the food item
* @return list that represents the subtree of the given [passioID], null otherwise.
*/
fun lookupAllDescendantsFor(passioID: PassioID): List<PassioID>?

/**
* Search functions that uses the given [byText] to cross reference
* the names of the food items in the nutritional database.
*
* @param byText the string used to query the database
* @return list of all of the [PassioID]s with the corresponding
* names of the food items.
*/
fun searchForFood(
byText: String,
callback: (result: List<Pair<PassioID, String>>) -> Unit
)

/**
* For a given [Barcode] creates a networking call to Passio's
* backend that tries to fetch the corresponding [PassioIDAttributes].
*
* @param barcode the barcode string of the packaged food.
* @param onAttributesFetched callback function that will return the
* PassioIDAttributes if that packaged food
* is enlisted on Passio's backend.
*/
fun fetchPassioIDAttributesForBarcode(
barcode: Barcode,
onAttributesFetched: (passioIDAttributes: PassioIDAttributes?) -> Unit
)

fun fetchPassioIDAttributesForPackagedFood(
packagedFoodCode: PackagedFoodCode,
onAttributesFetched: (passioIDAttributes: PassioIDAttributes?) -> Unit
)

/**
* If not null, the [PassioStatusListener] will provide callbacks
* when the internal state of the SDK's configuration process changes.
Expand All @@ -493,6 +471,48 @@ interface PassioSDK {
displayAngle: Int = 0,
barcode: Boolean = false
): RectF

fun iconURLFor(passioID: PassioID, size: IconSize = IconSize.PX90): String

fun fetchTagsFor(passioID: PassioID, onTagsFetched: (tags: List<String>?) -> Unit)

fun fetchInflammatoryEffectData(
passioID: PassioID,
onResult: (data: List<InflammatoryEffectData>?) -> Unit
)

fun searchForFood(
term: String,
callback: (result: List<PassioFoodDataInfo>, searchOptions: List<String>) -> Unit
)

fun fetchFoodItemForDataInfo(
searchResult: PassioFoodDataInfo,
callback: (foodItem: PassioFoodItem?) -> Unit
)

fun fetchFoodItemForProductCode(
productCode: String,
onResult: (foodItem: PassioFoodItem?) -> Unit
)

fun fetchFoodItemForPassioID(
passioID: PassioID,
onResult: (foodItem: PassioFoodItem?) -> Unit
)

fun fetchSuggestions(
mealTime: PassioMealTime,
callback: (results: List<PassioFoodDataInfo>) -> Unit
)

fun fetchMealPlans(callback: (result: List<PassioMealPlan>) -> Unit)

fun fetchMealPlanForDay(
mealPlanLabel: String,
day: Int,
callback: (result: List<PassioMealPlanItem>) -> Unit
)
}
```

Expand Down

0 comments on commit a7dcac0

Please sign in to comment.