Description
Obtaining explicit user consent regarding the gathering analytics data in an app, or with processing user’s personal data is an important part of establishing user trust and seamless user experience.
Although implementing some form to obtain user consents and store them for further reference seems pretty straightforward, digging into it reveals (as usual with “simple tasks”) many programming and design details that must be implemented, which are not the core functionality of your app.
User Consent SDK for Android alternatives and similar packages
Based on the "Kotlin" category.
Alternatively, view User Consent SDK for Android alternatives based on common mentions on social networks and blogs.
-
android-youtube-player
YouTube Player library for Android and Chromecast, stable and customizable. -
CalendarView
A highly customizable calendar library for Android, powered by RecyclerView. -
Kotterknife
Android view injection writen in Kotlin based on ButterKnife -
Shortbread
Android library that generates app shortcuts from Shortcut annotations -
Balloon
🎈 A lightweight popup like tooltips, fully customizable with arrow and animations. -
DrawableToolbox
🛠️ The missing DrawableToolbox for Android. Get rid of the boring and always repeated drawable.xml files. -
kotlin-android-template
Android + Kotlin + Github Actions + ktlint + Detekt + Gradle Kotlin DSL + buildSrc = ❤️ -
Navigation Toolbar for Android
Navigation toolbar is a slide-modeled UI navigation controller made by @Ramotion -
KAndroid
Lightweight library providing useful extensions to eliminate boilerplate code in Android SDK. -
Time
Type-safe time calculations in Kotlin, powered by generics. -
CodeView
Show code content with syntax highlighting in native way. -
NotyKT 🖊️
📝 NotyKT is a complete Kotlin-stack (Backend + Android) application 📱 built to demonstrate the use of Modern development tools with best practices implementation. -
MaterialTimelineView
With MaterialTimelineView you can easily create a material looking timeline. -
MaterialDrawerKt
A Kotlin DSL wrapper around the mikepenz/MaterialDrawer library. -
sliding-panel
Android sliding panel that is part of the view hierarchy, not above it. -
Yasha
A lightweight RecyclerView tool that lets you render items like Javascript. -
CrunchyCalendar — awesome calendar widget for android apps
A beautiful material calendar with endless scroll, range selection and a lot more! -
Transition X
Declarative Kotlin DSL for choreographing Android Transitions -
Only
💐 An easy way to persist and run code block only as many times as necessary on Android. -
Android Kotlin Samples
Some basic Android code samples writen in Kotlin. -
Swagger Gradle Codegen
💫 A Gradle plugin to generate networking code from a Swagger spec file. -
Awesome Jetpack compose
A collaborative list of awesome jetpack compose resources. -
DeviceInfo-Sample
[Android Library] Get easy access to device information super fast, real quick -
CameraViewEx
CameraViewEx makes integration of camera implementation and various camera features into any Android project very easy. -
Events Calendar
A user-friendly library that helps you achieve a cool Calendar UI with events mapping. -
Pdf Viewer For Android
A Lightweight PDF Viewer Android library which only occupies around 125kb while most of the Pdf viewer occupies up to 16MB space. -
ZoomHelper
ZoomHelper will make any view to be zoomable just like Instagram pinch-to-zoom -
Aimybox voice assistant
Embeddable voice assistant for Android apps written in Kotlin -
Vanilla Place Picker
Simple(vanilla) yet 'Do it all' place picker for your place picking needs in Android -
Maildroid
🎉 Maildroid is a small robust android library for sending emails using SMTP server 🎉 -
RecyclerView Presenter
Handle different view types. -
SSCustomEditTextOutLineBorder
Same as an Outlined text fields presented in Material Design page but with some dynamic changes -
EasyCrypt
Android cryptography library with SecureRandom patches. -
SSCustomBottomNavigation
Animated tabbar with native control -
ParallaxScrollingView
Parallax scrolling either by offset or automatically. -
Kotlin-AgendaCalendarView
CalendarView widget (Outlook) -
Kotlin Example
An example for who are all going to start learning Kotlin programming language to develop Android application. -
Google Places AutoComplete EditText
A simple library that can connect your autocomplete edittext to Google places api -
MVVM-To-Do-App
Android To-Do MVVM Architecture App written in Kotlin.(ViewModel, ROOM, Livedata, Coroutines) -
PopKorn
PopKorn is a simple, powerful and lightweight Dependency Injector 100% Kotlin -
EasyPermissions-ktx
🔓 Kotlin version of the popular google/easypermissions wrapper library to simplify basic system permissions logic on Android M or higher. -
Viola
With Viola android face detection library, you can detect faces in a bitmap, crop faces using predefined algorithm and get additional information from the detected faces. -
KDispatcher
Simple and light-weight event dispatcher for Kotlin -
Clean-MVVM-NewsApp
Android News app developed using Clean + MVVM architecture -
Bundlizer
Android Bundle format support for Kotlinx Serialization. -
fusion
An Easy-to-use Kotlin based Customizable Modules Collection with Material Layouts by BlackBeared.
Get performance insights in less than 4 minutes
Do you think we are missing an alternative of User Consent SDK for Android or a related project?
README
Consent SDK for Android
Obtaining explicit user consent regarding the gathering analytics data in an app, or with processing user’s personal data is an important part of establishing user trust and seamless user experience.
Although implementing some form to obtain user consents and store them for further reference seems pretty straightforward, digging into it reveals (as usual with “simple tasks”) many programming and design details that must be implemented, which are not the core functionality of your app.
Consent SDK main functionality
- Provides configurable consent form that can be displayed as:
- Dialog
- FragmentDialog(persists orientation changes)
- Activity
- Fragment
- Stores consent results and provides access methods.
Installation
Add the following dependency in your app's build.gradle:
implementation 'com.smartlook:consent:1.0'
And add the following in your project's build.gradle:
allprojects {
repositories {
maven {
url "https://sdk.smartlook.com/android/release"
}
}
}
How to use
Firstly you need to instantiate ConsentSDK
with applicationContext
.
val consentSDK = ConsentSDK(applicationContext)
This object is going to be used for all interactions with ConsentSDK.
Consent form data
Before you can display consent form you need to prepare consent form data.
companion object {
const val CONSENT_1_KEY = "consent_1_key"
const val CONSENT_2_KEY = "consent_2_key"
}
...
val consentFormItems = arrayOf(
ConsentFormItem(
consentKey = CONSENT_1_KEY,
required = true,
description = getString(R.string.consent_1_description),
link = null
),
ConsentFormItem(
consentKey = CONSENT_2_KEY,
required = false,
description = getString(R.string.consent_2_description),
link = getString(R.string.consent_2_link)
)
)
val consentFormData = ConsentFormData(
titleText = getString(R.string.consent_form_title),
descriptionText = getString(R.string.consent_form_description),
confirmButtonText = getString(R.string.consent_form_confirm_button_text),
consentFormItems = consentFormItems)
Array consentFormItems
represents consents we want the user to grant us. Every item needs to have:
- unique
consentKey
that represents it and can be used to obtain grant result for this consent. required
flag. If this flag is set totrue
user cannot successfully finish the consent form without granting this consent.descriptionText
informing the user about the consent.link
(optional) that lets the user open a web page (URL) with more info.
Object consentFormData
provides all needed data for displaying consent form.
Showing consent form on Dialog
A most simple and straight-forward way of displaying consent form is on Dialog
. It has one drawback, this way we cannot properly persist user data on orientation change. Use this if you have locked screen orientation.
consentSDK.showConsentFormDialog(consentFormData, object : ConsentResultsListener {
override fun onConsentResults(consentResults: HashMap<String, Boolean>) {
// consent form result here
}
})
Showing consent form on DialogFragment
By using DialogFragment
SDK can properly handle orientation changes.
consentSDK.showConsentFormDialogFragment(<activity>/<fragment>, consentFormData)
The first parameter of showConsentFormDialogFragment
accepts Activity
or Fragment
reference so you can call it from both.
Your calling Activity
or Fragment
must implement ConsentResultsListener.
class SampleActivity : AppCompatActivity(), ConsentResultsListener {
...
override fun onConsentResults(consentResults: HashMap<String, Boolean>) {
// consent form result here
}
}
Starting consent form Activity
class SampleActivity : AppCompatActivity() {
companion object {
const val CONSENT_REQUEST_CODE = 10001
}
...
consentSDK.startConsentFormActivity(this, consentFormData, CONSENT_REQUEST_CODE)
...
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == CONSENT_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
val consentResults = consentSDK.parseOutConsentResults(data)
} else {
// user didnt confirm the form (back press)
}
}
}
}
Consent form Activity
is started "for a result" so to get a result you need to implement onActivityResult
method in your Activity
.
Creating conset form Fragment
Method createConsentFormFragment
lets you create Fragment
with consent form. Example usage might look something like this:
const val TAG = "unique_fragment_tag"
...
with(supportFragmentManager) {
beginTransaction()
.replace(R.id.fragment_placeholder, consentSDK.createConsentFormFragment(consentFormData), TAG)
.commit()
executePendingTransactions()
}
ConsentResultsListener
can be registered like this:
val consentFormFragment = supportFragmentManager.findFragmentByTag(TAG) as ConsentFormFragment
consentFormFragment.registerConsentResultsListener(object : ConsentResultsListener {
override fun onConsentResults(consentResults: HashMap<String, Boolean>) {
// Consent form result here
}
})
Consent results
When user sucessfully finishes consent form you gonna get consentResult
. It is a HashMap<String,Boolean>
in which:
key
==consentKey
value
representsconsentResult
:true
consent was granted.false
consent was rejected.
Are consent results stored?
SDK method areConsentResultsStored()
can be used to determine if the user has already successfully filled consent form and results were stored.
Obtaining consent
If you want to obtain a grant result for given conset (identified by unique consentKey
) you can do it like this:
val consentResult = consentSDK.loadConsetResult(consentKey)
If consentResult
is:
true
consent was granted.false
consent was rejected.null
not defined.
Styling
You can define custom style
for the consent form. All configurable attributes are listed in the table below.
Attribute | Description |
---|---|
colorAccent | Confirm button, link icons and Switches color. |
cf_textColor | Description text and form item texts color. |
cf_titleTextColor | Title text color. |
cf_confirmButtonTextColor | Confirm button text color. |
cf_backgroundColor | Form background color. |
cf_dividerColor | Form item list divider color. |
Dialog
/FragmentDialog
In styles.xml
define custom Dialog style:
<style name="DialogStyle" parent="Base.Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#35E6A5</item>
<item name="cf_textColor">#F4F4F4</item>
<item name="cf_titleTextColor">#F4F4F4</item>
<item name="cf_confirmButtonTextColor">#F4F4F4</item>
<item name="cf_backgroundColor">#26262E</item>
<item name="cf_dividerColor">#F4F4F4</item>
</style>
Then add the style reference to showConsentFormDialog
/showConsentFormDialogFragment
method like this:
// Dialog
consentSDK.showConsentFormDialog(this, consentFormData, R.style.DialogStyle, listener)
// DialogFragment
consentSDK.showConsentFormDialogFragment(this, consentFormData, R.style.DialogStyle)
Activity
In styles.xml
define custom Activity style:
<style name="ActivityStyle" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorAccent">#21A76A</item>
<item name="cf_textColor">#F4F4F4</item>
<item name="cf_titleTextColor">#F4F4F4</item>
<item name="cf_confirmButtonTextColor">#F4F4F4</item>
<item name="cf_backgroundColor">#26262E</item>
<item name="cf_dividerColor">#F4F4F4</item>
</style>
Then add the style reference to startConsentFormActivity
method like this:
consentSDK.startConsentFormActivity(this, consentFormData, CONSENT_REQUEST_CODE, R.style.ActivityStyle)
Fragment
In styles.xml
define custom Fragment style:
<style name="FragmentStyle" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorAccent">#21A76A</item>
<item name="cf_textColor">#F4F4F4</item>
<item name="cf_titleTextColor">#F4F4F4</item>
<item name="cf_confirmButtonTextColor">#F4F4F4</item>
<item name="cf_backgroundColor">#26262E</item>
<item name="cf_dividerColor">#F4F4F4</item>
</style>
Then add the style reference to startConsentFormActivity
method like this:
consentSDK.createConsentFormFragment(consentFormData, R.style.FragmentStyle)