Luscii Android SDK
Getting started
Hilt is required (for now). If your app already uses Hilt, no setup is necessary, except adding the correct @AndroidEntryPoint
annotation to the Activity
the SDK is used in.
If your app does not use Hilt yet, from the Dependency injection with Hilt page, follow the Adding dependencies, Hilt application class and Hilt application class steps.
The Luscii Android SDK is published to a public Maven repo hosted on Github Packages.
In the
settings.gradle.kts
file, add the Luscii Maven repo: Because Github does not support anonymous access for their Maven package repositories, you have to provide your Github username, and as a password a classic Github access token with theread:packages
permission.You don't need any invite or approval from Luscii before you can retrieve the package.
Also add the Jitpack repository, because the SDK depends on a library from there.
dependencyResolutionManagement {
repositories {
// Other repositories..
maven {
url = uri("https://maven.pkg.github.com/Luscii/actions-sdk-android")
// These should be loaded from a .properties file
credentials {
username = "githubusername"
password = "gh_someToken123"
}
}
maven(url = "https://jitpack.io")
}
}Content copied to clipboardIn the project's
build.gradke.kts
, add the following dependency:dependencies {
implementation("com.luscii:sdk:0.4.1")
// Other dependencies..
}Content copied to clipboardAlso in the project's
build.gradke.kts
, specifydataBinding = true
:android {
// Other stuff..
buildFeatures {
dataBinding = true
}
}Content copied to clipboard
Usage
Initialize a
Luscii
instance somewhere::val luscii = Luscii {
applicationContext = ...
useDynamicTheming = true // Optional, use if you want to use Material You, defaults to false
}Content copied to clipboardBefore using any other
Luscii
method, make sure to authenticate.luscii.authenticate(patientApiKey = "some-api-key")
Content copied to clipboard
Default Actions screen
If you want to use the default, pre-made Actions screen, you can launch it like so:
luscii.startActionsActivity()
Custom Action screen
You can also create your own Actions screen UI, using:
val actionsToday = luscii.getActions()
This method returns all Action
s for today.
An Action
can be launched by starting an activity using:
import com.luscii.sdk.actions.ActionFlowResult.*
val actionFlowLauncher = registerForActivityResult(
luscii.createActionFlowActivityResultContract()
) { result: ActionFlowResult ->
// Handle result
when (result) {
is Completed -> TODO()
is Cancelled -> TODO()
is Error -> TODO()
}
}
Launchable status
However, it's recommend to first check if the Action
is launchable. An Action
might have to be completed today, but in a specific timeframe. There are a few ways to check for this:
val launchable = someAction.isLaunchable()
import com.luscii.sdk.actions.Action.LaunchableStatus.*
// Somewhere down..
when (someAction.getLaunchableStatus()) {
is CompletedAt -> TODO()
is Launchable -> TODO()
is LaunchableAfter -> TODO()
is LaunchableBefore -> TODO()
}
import com.luscii.sdk.actions.Action.LaunchableStatus.*
// Somewhere down..
when (someAction.getLaunchableStatus()) {
is Launchable -> TODO()
is NotLaunchable -> TODO()
}
Acceptance environment
If you want to use the SDK on Luscii's acceptance environment, use the following dependency in your build.gradle.kts instead of the one mentioned before:
dependencies {
implementation("com.luscii:sdk-acceptance:0.4.1")
// Other dependencies..
}
Notes
Some actions require third-party SDKs from Happitech, iHealth, etc. If these are not present, the SDK will not show devices using those SDKs as an option when performing an action. Some actions force the use of a third-party device. When launching such an action, an error message will be displayed to the user.
Changelog
*0.4.1
Add sources jar for Kotlin docs in IDE
Fix a small Kotlin code-gen issue
0.4.0
Add methods to launch
Activity
s instead ofFragment
sAdd support for enabling dynamic theming (Material You)
Fix an issue where a completed action would have a blank screen after pressing back
Deprecate passing a
patientApiKey
throughLusciiConfiguration
, pass it toauthenticate
instead0.3.19
Fix multiple issues regarding minifying and Proguard
0.3.18
Fix background not being dark in dark-mode in the default actions screen
Action
is not a data class anymore, it's now equal to otherAction
s only by itsid
0.3.17
Fix
InflateException
when launching an action flowFix the need for having to supply a theme in
<application>
in the manifest