Skip to content

Releases: KinesteX/KinesteX-SDK-Kotlin

KinesteX SDK v1.1.9

25 Nov 15:49
Compare
Choose a tag to compare

Upaded WorkoutSummary for each WeekDetail in Plan with:

    val imgURL: String,
    val calories: Double?,
    val total_minutes: Int?

KinesteX SDK v1.1.8

25 Nov 15:38
Compare
Choose a tag to compare

Added filtering by category and body_parts

KinesteX SDK v1.1.7

07 Nov 20:40
Compare
Choose a tag to compare
  • Added AI Experiences. Learn more here
  • Added API for fetching data about workouts, plans, and exercises. Learn more here

KinesteX SDK v 1.1.6

25 Oct 19:12
Compare
Choose a tag to compare

Moved camera permission logic completely to app lifecycle for easier permission handling across different setups.

Usage:

  1. Update the dependency to 1.1.6:
    implementation "com.github.KinesteX:KinesteX-SDK-Kotlin:1.1.6"

2.1 Make sure your activity or fragment implements the PermissionHandler interface:
class MainActivity : AppCompatActivity(), PermissionHandler

2.2 Create necessary variables and override the requestCameraPermission method in PermissionHandler interface:

private var kinesteXWebView: GenericWebView? = null

 private val requestPermissionLauncher = registerForActivityResult(
     ActivityResultContracts.RequestPermission()
 ) { isGranted: Boolean ->
     kinestexWebView?.handlePermissionResult(isGranted)
 }
 
override fun requestCameraPermission() {
     requestPermissionLauncher.launch(Manifest.permission.CAMERA)
}
  1. Pass permissionHandler to the SDK on function initialization:
kinesteXWebView = KinesteXSDK.createMainView(
                    this,
                    apiKey,
                    company,
                    userId,
                    getPlanCategory(subOption),
                    null,
                    customParams = data, // example of using custom parameters. CAN BE NULL
                    viewModel.isLoading,
                    ::handleWebViewMessage,
                    permissionHandler = this // pass the activity or if fragment: this@YourFragment
                )  as GenericWebView?

KinesteX SDK v 1.1.5

25 Oct 10:15
Compare
Choose a tag to compare

Modified permission request, moving handler to app level and adding exception handlers:

       webChromeClient = object : WebChromeClient() {
            override fun onPermissionRequest(request: PermissionRequest) {
                Log.d("KinesteX SDK", "Permission request received: ${request.resources.contentToString()}")

                try {
                    if (request.resources.contains(PermissionRequest.RESOURCE_VIDEO_CAPTURE)) {
                        // Store the request for later use
                        pendingCameraPermissionRequest = request

                        // Check current permission status
                        when {
                            ContextCompat.checkSelfPermission(
                                context,
                                Manifest.permission.CAMERA
                            ) == PackageManager.PERMISSION_GRANTED -> {
                                // If already granted, grant to WebView immediately
                                Log.d("KinesteX SDK", "Camera permission already granted, granting to WebView")
                                request.grant(request.resources)
                            }
                            (context as? Activity)?.shouldShowRequestPermissionRationale(
                                Manifest.permission.CAMERA
                            ) == true -> {
                                // Optional: Show rationale if needed
                                Log.d("KinesteX SDK", "Should show permission rationale")
                                requestCameraPermission()
                            }
                            else -> {
                                // Request permission
                                Log.d("KinesteX SDK", "Requesting camera permission")
                                requestCameraPermission()
                            }
                        }
                    } else {
                        Log.d("KinesteX SDK", "Denying non-camera permission request")
                        request.deny()
                    }
                } catch (e: Exception) {
                    Log.e("KinesteX SDK", "Error handling permission request", e)
                    request.deny()
                }
            }
        }

NOW you would need to override the onRequestPermissionResult handler to call the handlePermissionResult from within the GenericWebView class in KinesteXSDK:

// Your AppCompatActivity() where KinesteXSDK is used 
    override fun onRequestPermissionsResult(
        requestCode: Int,
        permissions: Array<out String>,
        grantResults: IntArray
    ) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
        webView?.handlePermissionResult(requestCode, grantResults)
    }

KinesteX SDK v 1.1.4

24 Oct 18:20
Compare
Choose a tag to compare

Added app level camera permission for webview on request:

        webChromeClient = object : WebChromeClient() {
            override fun onPermissionRequest(request: PermissionRequest) {
                val requestedResources = request.resources

                if (requestedResources.contains(PermissionRequest.RESOURCE_VIDEO_CAPTURE)
                ) {
                    // Check if app-level permissions are granted before granting to the site
                    if (ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA) ==
                        PackageManager.PERMISSION_GRANTED
                    ) {
                        request.grant(requestedResources)
                    } else {
                        // Request app-level permissions if not granted yet
                        ActivityCompat.requestPermissions(
                            (context as Activity),
                            arrayOf(Manifest.permission.CAMERA),
                            1010101
                        )
                        request.deny()  // Deny until permissions are granted
                    }
                } else {
                    // Deny any other permissions
                    request.deny()
                }
            }
        }