SDK - Android
Lune's Data API function is to simplify financial data for businesses, offering a transformative approach to managing and interpreting transaction data, a key aspect of transaction data enrichment. The way it works is that the API serves as a bridge, connecting raw transactional information that's hard to understand for regular teams and end-consumers to a world of enriched, meaningful insights.
Version 3
This version includes several changes to improve authentication, streamline and simplify the API, and improve international support.
Requirements
- Android Studio Arctic Fox (2020.3.1) or later
- Kotlin 1.5.10 or later
- Minimum Android API level 21 (Android 5)
- Lune SDK (AAR) file
Integration
- 1. Download the Lune SDK (AAR) file and place it in the
libs
older of your Android project. If thelibs
folder does not exist, create it at the root level of your project. - 2. Open your app-level
build.gradle
file and add the following to the `dependencies block:
//LuneSdk
implementation(files("libs/lunesdk-release.aar"))
implementation("androidx.compose.material:material:1.5.4")
// Retrofit
implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.8.0")
// OkHttp
implementation("com.squareup.okhttp3:okhttp:4.9.3")
implementation("com.squareup.okhttp3:logging-interceptor:4.9.3")
// flow stuff
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.6.2")
// For Navigation
implementation("androidx.navigation:navigation-compose:2.6.0")
implementation("androidx.compose.material3:material3:1.2.0-alpha02")
//Coil
implementation("io.coil-kt:coil-compose:2.3.0")
//Flow
implementation("com.google.accompanist:accompanist-flowlayout:0.20.0")
// For Bottomsheet
implementation("androidx.activity:activity-ktx:1.7.2")
implementation("com.google.android.material:material:1.9.0")
- 3. Sync your project with the Gradle files to add the Line SDK to your project.
Initialization
Activities and Fragments:
To initialize the SDK within a project using Activities and Fragments, Place the fully qualified class name for Lune views, io.lunedata.lunesdk.library.classes.LuneCompatManager
, as seen in the example below, in your layout file.
You are free to setup the layout constraints as you deem appropriate.
<!-- YourLayoutFile.xml -->
<io.lunedata.lunesdk.library.classes.LuneCompatManager
android:id="@+id/luneLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
// other attributes...
/>
In your Activity or Fragment code, you need to create an instance of LuneSDKManager
and initialise it with the required credentials.
// YourActivity.kt
private lateinit var luneSDK: LuneSDKManager;
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// initialise the SDK manager
luneSDK = LuneSDKManager(
baseUrl = "<your.base.url>",
email = "<your.email.address>",
password = "<your.password>",
customerId = customer.id
)
// proceed to next step
}
Then, you need to specify which of the components you intend to render (ActivityComponent
, in this case), and pass arguments if required.
To do this, find and interact with the views using their IDs (R.id.luneLayout
, in this case) or by using findViewById()
and set the component field, as seen in the example below.
// YourActivity.kt
private lateinit var luneSDK: LuneSDKManager;
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// initialise the SDK manager
luneSDK = LuneSDKManager(
baseUrl = "<your.base.url>",
email = "<your.email.address>",
password = "<your.password>",
customerId = customer.id
)
// Grab our luneView and set the manager and component properties.
val luneView = findViewById<LuneCompatManager>(R.id.luneLayout)
luneView.manager = luneSDK
luneView.component = LuneView.ActivityComponent
}
Jetpack Compose:
To initialize the SDK within a Jetpack Compose project, you simply have to create an instance of LuneSDKManager
in the onCreate()
method of your main activity. This instance would be used across your app.
💡 Jetpack Compose Tip:
While you could create multiple instances of LuneSDKManager
, we recommend that you create just one instance per app. You could share that single instance with other views by passing it around.
The SDK takes in necessary credentials as arguments to the LuneSDKManager
constructor, as shown below.
import io.lunedata.lunesdk.library.classes.LuneSDKManager
class MainActivity : ComponentActivity() {
private lateinit var luneSDK: LuneSDKManager;
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
luneSDK = LuneSDKManager(
baseUrl = "<your.base.url>",
email = "<your.email.address>",
password = "<your.password>",
customerId = customer.id
)
setContent {
LuneBankTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
) {
RootComposable(luneSDK)
}
}
}
}
}
You can use the LuneSDKManager
instance within any composable in your app as shown below.
// TransactionView.kt
import io.lunedata.lunesdk.library.classes.LuneSDKManager
@Composable
fun TransactionView(
luneSDK: LuneSDKManager
) {
luneSDK.TransactionListComponent()
}
The views automatically use any customizations that have been set up within the Resource files
.
Lune Views
Customization
The SDK has lots of configurable parameters which can be overridden by setting up a JSON
file with a schema similar to the one below.
You could just copy the example below and modify the values you wish to change.
{
"meta": {
"name": "config",
"version": "0.01"
},
"global": {
"palette": {
"light": {
"primary": "#002E2A",
"secondary": "#469B93",
"error": "#E86161",
"success": "#4BB543",
"warning": "#FFAA59",
"accent": "#EDF5F4",
"active": "#469B93",
"hint": "#66827F",
"foreground": "#002E2A",
"background": "#FFFFFF",
"card-background": "#FFFFFF",
"success-background": "#EDF5F4",
"error-background": "#FCEFEF"
},
"dark": {
"primary": "#002E2A",
"secondary": "#469B93",
"error": "#E86161",
"success": "#4BB543",
"warning": "#FFAA59",
"active": "#B3C0BF",
"accent": "#FFFFFF",
"hint": "#B3C0BF",
"foreground": "#FFFFFF",
"background": "#151515",
"card-background": "#2A292E",
"success-background": "#EDF5F4",
"error-background": "#FCEFEF"
}
},
"typography": {
"h0": {
"font": "Poppins",
"weight": 600,
"size": 20,
"line-height": 30
},
"h1": {
"font": "Poppins",
"weight": 600,
"size": 16,
"line-height": 24
},
"h2": {
"font": "Poppins",
"weight": 500,
"size": 16,
"line-height": 24
},
"body": {
"font": "Poppins",
"weight": 400,
"size": 14,
"line-height": 14
},
"hint": {
"font": "Poppins",
"weight": 400,
"size": 12,
"line-height": 12
}
},
"textfields": {
"radius": 10,
"border": 1,
"show-label": true,
"type": "outlined"
},
"buttons": {
"radius": 70,
"border": 1,
"type": ""
},
"cards": {
"radius-small": 10,
"radius-medium": 15,
"radius-large": 15,
"shadow": {
"radius": 40,
"offset-x": 0,
"offset-y": 4
}
}
},
"component-specific": {
"cashflow": {
"theme": {
"light": {
"expense": "#7EB8B3",
"income": "#1A433F"
},
"dark": {
"expense": "#7EB8B3",
"income": "#ffffff"
}
}
},
"expense": {
},
"budget-summary": {
},
"budget-form": {
},
"brand-trend": {
},
"category-trend": {
},
"activity": {
},
"category-activity": {
},
"transaction-detail": {
},
"category-spend-chart": {
"theme": {
"light": [
"#102D2A",
"#3B5755",
"#5D9993",
"#9AC0BE",
"#CCE0DF"
],
"dark": [
"#102D2A",
"#3B5755",
"#5D9993",
"#9AC0BE",
"#CCE0DF"
]
}
},
"brand-list": {
},
"transaction-list": {
},
"category-spend-list": {
"category-budget-increment": 50
}
}
}
The JSON
file should be saved as lune_config.json
and added to the /res/raw
directory of your Android project. In the end the file should be in located at /res/raw/lune_config.json
.
![](https://cdn.prod.website-files.com/645cc47082c0e871f3f1618c/65c953d2fdbb3072f55003fb_Screenshot%202024-02-12%20at%201.09.51%E2%80%AFAM.png)
Localization
If your app is already localized, the SDK would be localized as well - no configurations needed. If your app is not localized, however, the SDK respects that and stays in English to preserve consistency and uniformity across your app.
Optional
To allow buttons to float above the keyboard, add the following attribute in your AndroidManifest.xml
file:
<activity android:windowSoftInputMode="adjustResize">
<!--this allows buttons to float above the keyboard-->
</activity>