Skip to content

Commit bbf1874

Browse files
committed
updating Android docs
1 parent 98f15de commit bbf1874

File tree

1 file changed

+89
-1
lines changed

1 file changed

+89
-1
lines changed

docs/Spren-Vision/Spren-Vision-Android-SDK.md

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ The open source code is available in the [Spren Vision Android SDK GitHub Reposi
4747

4848
## Spren UI
4949

50-
### Implementation Example
50+
### Finger Camera Example
5151

5252
```kotlin
5353
// MainActivity.kt
@@ -57,6 +57,7 @@ import com.spren.sprenui.SprenUI
5757
class MainActivity : AppCompatActivity() {
5858

5959
private lateinit var binding: ActivityMainBinding
60+
private lateinit var hardwareAlert: HardwareAlert
6061

6162
override fun onCreate(savedInstanceState: Bundle?) {
6263
super.onCreate(savedInstanceState)
@@ -69,6 +70,12 @@ class MainActivity : AppCompatActivity() {
6970
binding = ActivityMainBinding.inflate(layoutInflater)
7071
setContentView(binding.root)
7172

73+
// optionally check if hardware is compatible
74+
hardwareAlert = HardwareAlert(this)
75+
if (!HardwareCheck.isHighPerformingDevice(this)) {
76+
hardwareAlert.show()
77+
}
78+
7279
// set user ID
7380
SprenUI.Config.userId = ...
7481

@@ -97,10 +104,90 @@ class MainActivity : AppCompatActivity() {
97104
SprenUI.Config.onCancel = {
98105
// handle user exit of UI flow without completing a reading
99106
}
107+
108+
// optionally override default intro screen graphics
109+
// provide drawable ids for image sets in project
110+
// *all are required for each project if overriding
111+
SprenUI.Config.graphics = mapOf(
112+
SprenUI.Graphic.GREETING_1 to <image set drawable id>, // greeting screen 1
113+
SprenUI.Graphic.GREETING_2 to <image set drawable id>, // greeting screen 2
114+
SprenUI.Graphic.FINGER_ON_CAMERA to <image set drawable id>, // finger on camera instruction screen
115+
SprenUI.Graphic.NO_CAMERA to <image set drawable id>, // camera access authorization denied screen
116+
SprenUI.Graphic.SERVER_ERROR to <image set drawable id> // server or calculation error
117+
)
100118
}
101119
}
102120
```
103121

122+
### Body Composition Example
123+
124+
```kotlin
125+
// MainActivity.kt
126+
127+
import com.spren.sprenui.SprenUI
128+
129+
class MainActivity : AppCompatActivity() {
130+
131+
private lateinit var binding: ActivityMainBinding
132+
private lateinit var hardwareAlert: HardwareAlert
133+
134+
override fun onCreate(savedInstanceState: Bundle?) {
135+
super.onCreate(savedInstanceState)
136+
137+
// optionally set custom theme
138+
// theme inherits from "Theme.MaterialComponents.DayNight.NoActionBar"
139+
// see themes.xml example below
140+
setTheme(R.style.Theme_SprenUI)
141+
142+
binding = ActivityMainBinding.inflate(layoutInflater)
143+
setContentView(binding.root)
144+
145+
// optionally check if hardware is compatible
146+
hardwareAlert = HardwareAlert(this)
147+
if (!HardwareCheck.isHighPerformingDevice(this)) {
148+
hardwareAlert.show()
149+
}
150+
151+
// set user ID
152+
SprenUI.Config.userId = ...
153+
154+
// optionally set user biological sex
155+
SprenUI.Config.userGender = ...
156+
157+
// optionally set user birthdate
158+
SprenUI.Config.userBirthdate = ...
159+
160+
// after dismissing results screen
161+
SprenUI.Config.onFinish =
162+
{ results ->
163+
// user completed a scan!
164+
print(results)
165+
// dismiss SprenUI
166+
}
167+
168+
169+
SprenUI.Config.onCancel = {
170+
// handle user exit of UI flow without completing a scan
171+
}
172+
173+
// optionally override default intro screen graphics
174+
// provide drawable ids for image sets in project
175+
// *all are required for each project if overriding
176+
SprenUI.Config.graphics = mapOf(
177+
SprenUI.Graphic.GREETINGS to <image set drawable id>,
178+
SprenUI.Graphic.PRIVACY to <image set drawable id>,
179+
SprenUI.Graphic.CAMERA_ACCESS_DENIED <image set drawable id>,
180+
SprenUI.Graphic.PHOTOS_ACCESS_DENIED to <image set drawable id>,
181+
SprenUI.Graphic.SETUP_GUIDE to <image set drawable id>,
182+
SprenUI.Graphic.SERVER_ERROR to <image set drawable id>,
183+
SprenUI.Graphic.INCORRECT_BODY_POSITION to <image set drawable id>
184+
)
185+
}
186+
}
187+
```
188+
189+
### Layout and Theme
190+
104191
```xml
105192
<!-- activity_main.xml corresponding to MainActivity.kt -->
106193

@@ -112,6 +199,7 @@ class MainActivity : AppCompatActivity() {
112199
android:layout_height="match_parent"
113200
app:api_key="@string/api_key"
114201
app:base_url="@string/base_url"
202+
app:project="FINGER_CAMERA" or "BODY_COMPOSITION"
115203
tools:context=".MainActivity" />
116204
```
117205

0 commit comments

Comments
 (0)