Skip to content

Commit 4d06d25

Browse files
Merge remote-tracking branch 'origin/master'
2 parents 22d17d3 + fe2fdf9 commit 4d06d25

File tree

6 files changed

+48
-29
lines changed

6 files changed

+48
-29
lines changed

README.md

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Consent SDK for Android
22

3-
Obtaining explicit user consent with gathering analytics data in an app, or with processing user’s personal data is important part of establishing user trust and seamless user experience.
3+
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.
44

5-
Although implementing some dialog 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.
6-
7-
So why not use or reuse some ready-made SDK?
5+
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.
86

97
<img src="screenshots/consent_form_activity.png" width="300"/> <img src="screenshots/consent_form_dialog.png" width="300"/>
108

@@ -14,9 +12,9 @@ So why not use or reuse some ready-made SDK?
1412
- __Dialog__
1513
- __FragmentDialog__(persists orientation changes)
1614
- __Activity__
17-
- Stores consent grant results and provides access methods.
15+
- Stores consent results and provides access methods.
1816

19-
## Instalation
17+
## Installation
2018

2119
todo
2220

@@ -28,7 +26,7 @@ Firstly you need to instantiate `ConsentSDK` with `applicationContext`.
2826
val consentSDK = ConsentSDK(applicationContext)
2927
```
3028

31-
This object is gonna be used for all interactions with ConsentSDK.
29+
This object is going to be used for all interactions with ConsentSDK.
3230

3331
### Consent form data
3432

@@ -65,16 +63,16 @@ val consentFormData = ConsentFormData(
6563
6664
```
6765

68-
Array `consentFormItems` represents consents we want user to grant us. Every item needs have:
66+
Array `consentFormItems` represents consents we want the user to grant us. Every item needs to have:
6967
- unique `consentKey` that represents it and can be used to obtain grant result for this consent.
70-
- `required` flag. If this flag is set to `true` user cannot successfully finish consent form without granting this consent.
71-
- `descriptionText` informing user about the consent.
72-
- `link` (optional) that lest user open web page (URL) with more info.
68+
- `required` flag. If this flag is set to `true` user cannot successfully finish the consent form without granting this consent.
69+
- `descriptionText` informing the user about the consent.
70+
- `link` (optional) that lets the user open a web page (URL) with more info.
7371

7472
Object `consentFormData` provides all needed data for displaying consent form.
7573

7674
### Showing consent form on `Dialog`
77-
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.
75+
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.
7876

7977
```
8078
consentSDK.showConsentFormDialog(consentFormData, object : ConsentResultsListener {
@@ -91,8 +89,8 @@ By using `DialogFragment` SDK can properly handle orientation changes.
9189
consentSDK.showConsentFormDialogFragment(<activity>/<fragment>, consentFormData)
9290
```
9391

94-
First parameter of `showConsentFormDialogFragment` accepts `Activity` or `Fragment` reference so you can call it from both.
95-
You calling `Activity` or `Fragment` __must__ implement ConsentResultsListener.
92+
The first parameter of `showConsentFormDialogFragment` accepts `Activity` or `Fragment` reference so you can call it from both.
93+
Your calling `Activity` or `Fragment` __must__ implement ConsentResultsListener.
9694

9795
```
9896
class SampleActivity : AppCompatActivity(), ConsentResultsListener {
@@ -120,20 +118,22 @@ class SampleActivity : AppCompatActivity() {
120118
121119
...
122120
123-
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
124-
if (requestCode == CONSENT_REQUEST_CODE) {
125-
if (resultCode == Activity.RESULT_OK) {
126-
val consentResults = consentSDK.parseOutConsentResults(data)
127-
}
128-
}
129-
}
121+
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
122+
if (requestCode == CONSENT_REQUEST_CODE) {
123+
if (resultCode == Activity.RESULT_OK) {
124+
val consentResults = consentSDK.parseOutConsentResults(data)
125+
} else {
126+
// user didnt confirm the form (back press)
127+
}
128+
}
129+
}
130130
}
131131
```
132132

133133
Consent form `Activity` is started "for a result" so to get a result you need to implement `onActivityResult` method in your `Activity`.
134134

135135
### Creating conset form `Fragment`
136-
Method `createConsentFormFragment` lets you create Fragment with consent form. Example usage might look something like this:
136+
Method `createConsentFormFragment` lets you create `Fragment` with consent form. Example usage might look something like this:
137137

138138
```
139139
const val TAG = "unique_fragment_tag"
@@ -167,7 +167,7 @@ When user sucessfully finishes consent form you gonna get `consentResult`. It is
167167
- `false` consent was rejected.
168168

169169
### Are consent results stored?
170-
SDK method `areConsentResultsStored()` can be used to determine if user has already sucessfully granted all required consents.
170+
SDK method `areConsentResultsStored()` can be used to determine if the user has already successfully filled consent form and results were stored.
171171

172172
### Obtaining consent
173173

@@ -186,7 +186,7 @@ If `consentResult` is:
186186

187187
<img src="screenshots/consent_form_activity_styled.png" width="300"/> <img src="screenshots/consent_form_dialog_styled.png" width="300"/>
188188

189-
You can define custom `style` for consent form. All configurable attributes are listed in table below.
189+
You can define custom `style` for the consent form. All configurable attributes are listed in the table below.
190190

191191
| Attribute | Description |
192192
|:-------------------------:|:------------------------------------------------:|
@@ -212,7 +212,7 @@ In `styles.xml` define custom Dialog style:
212212
</style>
213213
```
214214

215-
Then add the style to `showConsentFormDialog`/`showConsentFormDialogFragment` method like this:
215+
Then add the style reference to `showConsentFormDialog`/`showConsentFormDialogFragment` method like this:
216216

217217
```
218218
// Dialog
@@ -227,8 +227,8 @@ consentSDK.showConsentFormDialogFragment(this, consentFormData, R.style.DialogSt
227227
In `styles.xml` define custom Activity style:
228228

229229
```
230-
<style name="ActivityStyle" parent="Base.Theme.AppCompat.Light.Dialog">
231-
<item name="colorAccent">#35E6A5</item>
230+
<style name="ActivityStyle" parent="Theme.AppCompat.Light.NoActionBar">
231+
<item name="colorAccent">#21A76A</item>
232232
<item name="cf_textColor">#F4F4F4</item>
233233
<item name="cf_titleTextColor">#F4F4F4</item>
234234
<item name="cf_confirmButtonTextColor">#F4F4F4</item>
@@ -237,11 +237,29 @@ In `styles.xml` define custom Activity style:
237237
</style>
238238
```
239239

240-
Then add the style to `startConsentFormActivity` method like this:
240+
Then add the style reference to `startConsentFormActivity` method like this:
241241

242242
```
243243
consentSDK.startConsentFormActivity(this, consentFormData, CONSENT_REQUEST_CODE, R.style.ActivityStyle)
244244
```
245245

246246
### Fragment
247-
Not implemented yet.
247+
248+
In `styles.xml` define custom Fragment style:
249+
250+
```
251+
<style name="FragmentStyle" parent="Theme.AppCompat.Light.NoActionBar">
252+
<item name="colorAccent">#21A76A</item>
253+
<item name="cf_textColor">#F4F4F4</item>
254+
<item name="cf_titleTextColor">#F4F4F4</item>
255+
<item name="cf_confirmButtonTextColor">#F4F4F4</item>
256+
<item name="cf_backgroundColor">#26262E</item>
257+
<item name="cf_dividerColor">#F4F4F4</item>
258+
</style>
259+
```
260+
261+
Then add the style reference to `startConsentFormActivity` method like this:
262+
263+
```
264+
consentSDK.createConsentFormFragment(consentFormData, R.style.FragmentStyle)
265+
```

screenshots/consent_form_activity.png

-3.16 KB
Loading
-3.29 KB
Loading

screenshots/consent_form_dialog.png

-1.42 KB
Loading
-1.29 KB
Loading

screenshots/f

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)