GithubHelp home page GithubHelp logo

healthybinary / gdprdialog Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mflisar/gdprdialog

8.0 1.0 3.0 6.31 MB

GDPR fragment dialog implementation

License: Apache License 2.0

Java 100.00%

gdprdialog's Introduction

Forked GDPRDialog with more features and improvements Release Localisation

Simple reusable DialogFragment.

GDPR Demo1 GDPR Demo2

What it offers

This library offers following:

  • supports DialogFragment or BottomSheetDialogFragment style
  • supports multiple services, already defined ones are AdMob and Firebase
  • supports intermediator services as well, also supports to load your ad providers from AdMob
  • supports custom service definitions
  • is set up via a setup class that allows you to select which possibilities you give the user - any combination of personalised ads, non personalised ads and paid version, depending on what you want. Examples:
    • allow personalised ads or paid version only
    • allow personalised ads, non personalised ads or paid or free version
    • combine whatever you want here...
  • optionally enable location checks (supports google's check from the SDK via the internet, TelephoneManager, TimeZone, Locale) and also allows to define to use fallback methods, by providing your own list of checks sorted by their priority
  • optionally adds a Checkbox for age confirmation
  • uses soft opt in by default if you offer e.g. a personalised ads vs non personalised ads version
  • it closes the app if the user did not give any consent (i.e if the user clicks the back button in the dialog)
  • it manages the user's selected consent decision and remembers it (including location, date and app version)
  • it automatically reshows the dialog if the user did not give any consent or if the setup defines that the app is not allowed to be used without ads and the user has not accepted ads at all yet
  • fully customizable dialog to fit your needs.

GDPR and law safety

Such dialogs must always be adjusted to the use case in general, although this one should be fine in most cases.

Checkout following to find out more: EU GDPR

Just to make this clear, I'm no lawyer and I can't guarantee that you are save if you use this library.

Gradle (via JitPack.io)

  1. add jitpack to your project's build.gradle:
repositories {
    maven { url "https://jitpack.io" }
}
  1. add the compile statement to your module's build.gradle:
dependencies {
     implementation 'com.github.MFlisar:GDPRDialog:LATEST-VERSION'
}

LATEST-VERSION: Release

Usage

  1. Init the singleton in your application
GDPR.getInstance().init(this);
  1. call following in your activities onCreate
GDPRSetup setup = new GDPRSetup(GDPRDefinitions.ADMOB) // add all networks you use to the constructor, signature is `GDPRSetup(GDPRNetwork... adNetworks)`
    // everything is optional, but you should at least provide your policy
    .withPrivacyPolicy("www.my-privacy-policy.com")
    .withAllowNoConsent(true)
    .withPaidVersion(allowNonPersonalisedOptionAsWell)
    .withExplicitAgeConfirmation(true)
    .withCheckRequestLocation(GDPRLocationCheck.DEFAULT) // pass in an array of location check methods, predefined arrays like `DEFAULT` and `DEFAULT_WITH_FALLBACKS` do exists
    .withCheckRequestLocationTimeouts(readTimeout, connectTimeout)
    .withBottomSheet(true)
    .withForceSelection(true)
    .withCustomDialogTheme(theme)
    .withShortQuestion(true)
    .withLoadAdMobNetworks(publisherId(s)) // e.g. "pub-0123456789012345"
    .withNoToolbarTheme(noToolbarTheme)
    .withShowPaidOrFreeInfoText(true) // show the info that this app is cheap/free based on the networks or hide it
    // Customize the dialog for your needs
    .withShowAgeMessage(true) // To show the age confirmation message, (disabled by default)
    .withCustomAgeMessage("By agreeing, you are comfirming ...") // To show a custom age confirmation message
    .withCustomQuestionMessage("Can we continue to use your data ...") // To show a custom question message
    .withCustomMainMessage(">We use ads in this app. These services ... <a href=\"\">Learn more</a>") // To show a custom main message
    .withCustomSecondaryMessage("We care about your privacy and data security.") // To show a custom secondary message
    .withDarkThemeDialog() // Use dark theme dialog
    .withCustomTitle("Data Protection Consent") // To show a custom dialog title
;
// The implementation of this method in 3.a
GDPR.getInstance().checkIfNeedsToBeShown(this /* extends AppCompatActivity & GDPR.IGDPRCallback */, setup);

3.a implement the GDPR.IGDPRCallback in your activity

public class ExampleActivity extends AppCompatActivity implements GDPR.IGDPRCallback {
    @Override
    public void onConsentInfoUpdate(GDPRConsentState consentState, boolean isNewState) {
        // handle consent here
		
    }
	
    @Override
    public void onConsentNeedsToBeRequested() {
        // we need to get consent, so we show the dialog here
        GDPR.getInstance().showDialog(this, mSetup);
    }
}

3.b Second method without implementing GDPR.IGDPRCallback into the activity

GDPR.getInstance().checkIfNeedsToBeShown(this, mSetup, new GDPR.IGDPRCallback() {
    @Override
    public void onConsentNeedsToBeRequested(GDPRPreperationData data) {
        // handle consent here

    }

    @Override
    public void onConsentInfoUpdate(GDPRConsentState consentState, boolean isNewState) {
        // we need to get consent, so we show the dialog here
        GDPR.getInstance().showDialog(activity, mSetup, false);
    }
});

3.c Manualy requesting the dialog whithout checkIfNeedsToBeShown method

// Set callback
GDPR.getInstance().setCallback(new IGDPRCallback() {
    @Override
    public void onConsentInfoUpdate(GDPRConsentState consentState, boolean isNewState) {
	// handler conset here
    }
    
    @Override
    public void onConsentNeedsToBeRequested(GDPRPreperationData data) {
	GDPR.getInstance().showDialog(activity, setup, GDPR.getInstance().consentState.location, false); 
    }
});
// To request the dialog
GDPR.getInstance().showDialog(activity, setup, GDPR.getInstance().consentState.location, false);
  1. Other usages
// get current consent anywhere in the app after user has given consent
GDPRConsentState consentState = GDPR.getInstance().getConsentState();
// get location, time, app version of given consent
GDPRConsent consent = consentState.getConsent(); // the given constent
GDPRLocation location = consentState.getLocation(); // where has the given consent been given
long date = consentState.getDate(); // when has the given consent been given
int appVersion = consentState.getVersion(); // in which app version has the consent been given
// check if you can use personal informations or not
boolean canCollectPersonalInformation = GDPR.getInstance().canCollectPersonalInformation();
// Check if the user is within EEA or Unknwon
boolean isUserWithinEEAOrUnknwon = GDPR.getInstance().isUserWithinEEAOrUnknwon();
// Check if the consent is personalized or non-personalized
boolean isConsentPersonalized = GDPR.getInstance().isConsentPersonalized();

Check out the MinimalDemo to get something to start with or check out the DemoActivity with the example setups for a more complex example

Where can I add additional networks?

You can simply do this in the GDPRDefinitions. Of course you can always define new networks in project only as well, but if you think you use a service many others do use as well, fell free to add it to the definitions.

Migration

Migrations will be explained in the release notes

TODO

  • Localisation Localisation

    At least translations for all official languages within the european union should be added

    • Bulgarian
    • Croatian
    • Czech
    • Danish
    • Dutch
    • English
    • Estonian
    • Finnish
    • French
    • German
    • Greek
    • Hungarian
    • Irish
    • Italian
    • Latvian
    • Lithuanian
    • Maltese
    • Polish
    • Portuguese
    • Romanian
    • Slovak
    • Slovenian
    • Spanish
    • Swedish

License

Apache2

gdprdialog's People

Contributors

mflisar avatar healthybinary avatar luklek avatar mmarco94 avatar digipom avatar foreza avatar ferreirajoao avatar thubalek avatar ocos avatar ivfit avatar kubastick avatar marcin-sielski avatar sphrak avatar

Stargazers

Rohit Verma avatar  avatar Yassine Baghdadi avatar  avatar  avatar  avatar  avatar SALIH EliASSE avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.