MFlisar / GDPRDialog

GDPR fragment dialog implementation
Apache License 2.0
211 stars 53 forks source link
gdpr

DEPRECATED (REPLACED BY A NEW LIBRARY)

This library is deprecated in favour of my MaterialDialogs library - it's a very modularised library so switching to it won't add a lot of unnecessary overload if you don't want it.

Switching is easy, because I've based the GDPR Dialog module completely on this library, so after switching to new library the new library will reuse the settings from this library automatically (it will reuse any already given consent)

Read the readme(s) over there if you want a full insight, but here's a short example how it works after switching:

Side Note:

Usage:

1) create a setup

// nearly a kotlin based copy of the GDPRSetup from this library
val setup = GDPRSetup(
    networks = listOf(GDPRDefinitions.ADMOB),
    policyLink = "https://www.policy.com",
    //explicitAgeConfirmation = true,
    //hasPaidVersion = true,
    //allowNoConsent = true,
    explicitNonPersonalisedConfirmation = true
    // ...
)

2) ask for consent if necessary

val shouldAskForConsent = GDPR.shouldAskForConsent(activity, setup)
if (shouldAskForConsent) {
    DialogGDPR(
        1100, // some id for identification
        setup = setup
    )
        .showDialogFragment(activity)
}

3) handle the dialog result

The ID parameter is optional, you can listen to ALL events of a specific type as well, but check out the other library for more details.

// handle ALL events
onMaterialDialogEvent<DialogGDPR.Event>(id = 1100) { event ->
    // handle the event including cancels...
}
// handle specific state event only
onMaterialDialogEvent<DialogGDPR.Event.Result>(id = 1100) { event ->
    // handle successful events only...
    val state = event.consent
}

4) query consent if needed

val currentConsent = GDPR.getCurrentConsentState(this, setup)
val canCollectPersonalInformation = GDPR.canCollectPersonalInformation(this, setup)

README

Check out the old readme of this repository here: README