diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..def5910 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,4 @@ +Dipendra Sharma +Anitha Sangu +Gautham Prabhu +Vijay Makwana diff --git a/README.md b/README.md index d83f94d..f6fdef8 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,72 @@ -# GlamAR SDK Documentation +# GlamAR Android SDK + +[![Maven Central](https://img.shields.io/maven-central/v/io.pixelbin.glamar/glamar.svg)](https://central.sonatype.com/artifact/io.pixelbin.glamar/glamar) +[![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE) ## Overview -The GlamAR SDK provides tools to integrate augmented reality (AR) features into your Android application. The SDK is distributed as a local `.aar` file. This document covers the installation, initialization, and usage of the SDK, including details about `GlamArView` API, and `GlamAr` instance API. +GlamAR is a powerful Augmented Reality SDK for Android that enables virtual try-on experiences for makeup, jewelry, and other beauty products. The SDK provides an easy-to-integrate solution with real-time AR capabilities, face detection, and product visualization features. + +## Features + +- Real-time virtual makeup try-on +- Multiple product category support +- Camera and image-based preview modes +- Real-time face tracking and analysis +- Easy integration with Android applications +- Snapshot functionality +- High-performance WebView-based rendering +- Original/Modified view comparison +- Configurable parameters ## Installation -1. **Add the `.aar` file to your project:** - - Place the `.aar` file in the `libs` directory of your project. - - Open your project's `build.gradle` file and add the following: - - Also add `okhttp` and `gson` dependencies +### Maven Central - ```groovy - dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) - implementation 'com.google.code.gson:gson:2.10.1' - implementation 'com.squareup.okhttp3:okhttp:4.11.0' - // Other dependencies - } - ``` +The GlamAR SDK is available on Maven Central. Add the following dependency to your app's `build.gradle`: -2. **Sync your project with Gradle files.** +```groovy +dependencies { + implementation 'io.pixelbin.glamar:glamar:1.0.2' +} +``` -## Initialization +### Manual Installation + +Alternatively, you can manually include the `.aar` file: + +1. Place the `.aar` file in your project's `libs` directory +2. Add the following to your app's `build.gradle`: + +```groovy +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) + implementation 'com.google.code.gson:gson:2.10.1' + implementation 'com.squareup.okhttp3:okhttp:4.11.0' +} +``` + +Sync your project with Gradle files. + +## Required Permissions + +Add these permissions to your `AndroidManifest.xml`: -### Initialize SDK in Application Class +```xml + + +``` + +## Initialization -Initialize the SDK in your `Application` class to ensure it's set up when your app starts. By default it will be pointing to development make development parameter false for prod. +Initialize the SDK in your Application class to ensure it is set up when your app starts. ```kotlin class MyApplication : Application() { override fun onCreate() { super.onCreate() - GlamAr.initialize(accessKey = "YOUR_ACCESS_KEY", development = false) + GlamAr.init(context = this, accessKey = "YOUR_ACCESS_KEY") } } ``` @@ -43,47 +76,107 @@ Don't forget to register your `Application` class in the `AndroidManifest.xml`: ```xml ``` -## GlamArView +This "init" will prompt our SDK to create a webview and open our SDK in it. + +## AR View ### Setup -To use `GlamArView`, add it to your layout: +To use the webview we have created you will need to add it your layout. Paste the following code inside your layout xml file where you want to show the webview. ```xml - + android:layout_height="match_parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> ``` -### Starting Preview - -Start the preview in various modes using `startPreview`: +Inside the activity class add the following code: ```kotlin -glamARView.startPreview(previewMode = PreviewMode.None) -glamARView.startPreview(previewMode = PreviewMode.Camera) -glamARView.startPreview(previewMode = PreviewMode.Image(imageUrl = "IMAGE_URL")) +class MainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + // This passes the activity context to the webview + GlamArWebViewManager.setUpActivityContext(this) + + // This adds the webview created by SDK in the layout + GlamArWebViewManager.getPreparedWebView()?.let { webView -> + val glamARView = findViewById(R.id.glamARView) + glamARView.apply { + addView(webView) + } + } + } +} ``` -### Applying SKUs +You should be able to see GlamAR SDK page being loaded. -Apply a SKU to the `GlamArView`: +### Initialization options -```kotlin -glamARView.applySku(skuId = "SKU_ID", category = "CATEGORY") +Opens the SDK Home screen with relevant category module setup. + +```kotline +import io.pixelbin.glamar.model.GlamAROverrides + +val overrides = GlamAROverrides( + category = "sunglasses", +) +GlamAr.init(context = this, accessKey = "YOUR_ACCESS_KEY", overrides) ``` -### Clearing View +Open the SDK with Live mode (web camera) straightaway. This bypasses the SDK home screen. + +```kotline +import io.pixelbin.glamar.model.GlamAROverrides +import io.pixelbin.glamar.model.Configuration +import io.pixelbin.glamar.model.GlobalConfig + +val overrides = GlamAROverrides( + category = "sunglasses", + configuration = Configuration( + global = GlobalConfig( + openLiveOnInit = true, + ), + ) +) +GlamAr.init(context = this, accessKey = "YOUR_ACCESS_KEY", overrides) +``` -Clear the `GlamArView`: +Open SDK with disabled previous button and cross button. + +```kotline +import io.pixelbin.glamar.model.GlamAROverrides +import io.pixelbin.glamar.model.Configuration +import io.pixelbin.glamar.model.GlobalConfig + +val overrides = GlamAROverrides( + category = "sunglasses", + configuration = Configuration( + global = GlobalConfig( + disableClose = true, + disableBack = false + ), + ) +) +GlamAr.init(context = this, accessKey = "YOUR_ACCESS_KEY", overrides) +``` + +### Applying SKUs + +Apply a SKU: ```kotlin -glamARView.clear() +GlamAr.applySku(skuId = "SKU_ID") ``` ### Taking Snapshot @@ -91,100 +184,76 @@ glamARView.clear() Take a snapshot of the current view: ```kotlin -glamARView.snapshot() +GlamAr.snapshot() ``` -## GlamAr Instance API - -### Fetch SKU List +## Permissions -Fetch a list of SKUs: +Ensure that you handle permissions appropriately, especially for camera access when using `openLiveOnInit`. ```kotlin -GlamAr.getInstance().api.fetchSkuList(pageNo = 1, pageSize = 100) { result -> - result.onSuccess { skuListResponse -> - // Handle success - }.onFailure { exception -> - // Handle failure - } +override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray +) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + GlamArPermissionHandler.onRequestPermissionsResult(requestCode, grantResults) } ``` -### Fetch Specific SKU +## Event Handling -Fetch details of a specific SKU: +Event listeners are essential soon after initialization is called to start listening to GlamAR SDK callback events. + +### addEventListener ```kotlin -GlamAr.getInstance().api.fetchSku(id = "SKU_ID") { result -> - result.onSuccess { item -> - // Handle success - }.onFailure { exception -> - // Handle failure - } +// Can be any event type sent from SDK +GlamAR.addEventListener("sku-applied"){ + GlamArLogger.d("TAG", "sku-applied callback") } ``` -## Example Usage - -Here's a complete example demonstrating the usage of `GlamAr` and `GlamArView`: +### removeEventListener +Can also unregister from listening to events previously registered to but calling ```kotlin -class MainActivity : AppCompatActivity() { - - private lateinit var glamARView: GlamArView - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - - glamARView = findViewById(R.id.glamARView) - val applyBtn = findViewById