Skip to content

Commit 6167a27

Browse files
committed
added personalized plan integration option
1 parent 4ee80ab commit 6167a27

File tree

4 files changed

+68
-4
lines changed

4 files changed

+68
-4
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ android {
3838
}
3939

4040
dependencies {
41-
//implementation(project(":kinestexsdkkotlin"))
41+
implementation(project(":kinestexsdkkotlin"))
4242
implementation("androidx.core:core-ktx:1.9.0")
4343
implementation("com.google.code.gson:gson:2.8.8")
4444
implementation("androidx.appcompat:appcompat:1.6.1")
4545
implementation("com.google.android.material:material:1.11.0")
4646
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
4747
testImplementation("junit:junit:4.13.2")
4848
androidTestImplementation("androidx.test.ext:junit:1.1.5")
49-
implementation("com.github.KinesteX:KinesteX-SDK-Kotlin:1.2.2")
49+
// implementation("com.github.KinesteX:KinesteX-SDK-Kotlin:1.2.2")
5050
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
5151
implementation("androidx.activity:activity-ktx:1.9.0")
5252
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.8.1")

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
<uses-permission android:name="android.permission.INTERNET" />
1414
<uses-permission android:name="android.permission.CAMERA"/>
15-
15+
<!-- Optional: To detect device orientation when prompting to position phone correctly-->
16+
<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="false" />
17+
<uses-feature android:name="android.hardware.sensor.gyroscope" android:required="false" />
1618
<application
1719
android:allowBackup="true"
1820
android:dataExtractionRules="@xml/data_extraction_rules"

kinestexsdkkotlin/src/main/java/com/kinestex/kinestexsdkkotlin/KinesteXSDK.kt

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,68 @@ class KinesteXSDK {
224224
}
225225
}
226226

227+
228+
/**
229+
Creates a view for a personalied workout plan. Keeps track of the progress for the plan, fitness assessment results, recommending the workouts according to the person's progression
230+
231+
- Parameters:
232+
- apiKey: The API key for authentication.
233+
- companyName: The name of the company using the framework provided by KinesteX
234+
- userId: The unique identifier for the user.
235+
- user: Optional user details including age, height, weight, gender, and lifestyle.
236+
- isLoading: A binding to a Boolean value indicating if the view is loading.
237+
- onMessageReceived: A closure that handles messages received from the WebView.
238+
*/
239+
240+
fun createPersonalizedPlanView(
241+
context: Context,
242+
apiKey: String,
243+
companyName: String,
244+
userId: String,
245+
user: UserDetails?,
246+
customParams: MutableMap<String, Any>? = null,
247+
isLoading: MutableStateFlow<Boolean>,
248+
onMessageReceived: (WebViewMessage) -> Unit,
249+
permissionHandler: PermissionHandler
250+
): WebView? {
251+
if (containsDisallowedCharacters(apiKey) || containsDisallowedCharacters(companyName) || containsDisallowedCharacters(
252+
userId
253+
)
254+
) {
255+
Log.e(
256+
"WebViewManager",
257+
"⚠️ Validation Error: apiKey, companyName, or userId contains disallowed characters"
258+
)
259+
return null
260+
} else {
261+
val url =
262+
"https://kinestex.vercel.app/personalized-plan"
263+
val data = mutableMapOf<String, Any>()
264+
265+
user?.let {
266+
data["age"] = it.age
267+
data["height"] = it.height
268+
data["weight"] = it.weight
269+
data["gender"] = genderString(it.gender)
270+
data["lifestyle"] = lifestyleString(it.lifestyle)
271+
}
272+
273+
validateCustomParams(customParams, data)
274+
275+
return GenericWebView(
276+
apiKey = apiKey,
277+
companyName = companyName,
278+
userId = userId,
279+
url = url,
280+
data = data,
281+
isLoading = isLoading,
282+
onMessageReceived = onMessageReceived,
283+
context = context,
284+
permissionHandler = permissionHandler
285+
)
286+
}
287+
}
288+
227289
/**
228290
Creates a view for a specific workout plan. Keeps track of the progress for that particular plan, recommending the workouts according to the person's progression
229291

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ pluginManagement {
1616

1717
rootProject.name = "KinesteXSDKKotlin"
1818
include(":app")
19-
//include(":kinestexsdkkotlin")
19+
include(":kinestexsdkkotlin")

0 commit comments

Comments
 (0)