├── .gitignore ├── .idea ├── caches │ └── build_file_checksums.ser ├── codeStyles │ └── Project.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── gdprdialog │ │ └── lib │ │ └── mk │ │ └── gdprdialog │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── gdprdialog │ │ │ └── lib │ │ │ └── mk │ │ │ └── gdprdialog │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── gdprdialog │ └── lib │ └── mk │ └── gdprdialog │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── mk │ │ │ └── lib │ │ │ └── gdprdialog │ │ │ ├── GDPRDialog.java │ │ │ ├── GDPRFeature.java │ │ │ └── GDPRLearnDialog.java │ └── res │ │ ├── layout │ │ ├── dialog_gdpr.xml │ │ ├── dialog_gdpr_learn.xml │ │ └── gdpr_list_element.xml │ │ └── values │ │ ├── colors.xml │ │ └── strings.xml │ └── test │ └── java │ └── mk │ └── lib │ └── gdprdialog │ └── ExampleUnitTest.java ├── raw └── device-2019-04-18-122320.png └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # IntelliJ 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/gradle.xml 40 | .idea/assetWizardSettings.xml 41 | .idea/dictionaries 42 | .idea/libraries 43 | .idea/caches 44 | 45 | # Keystore files 46 | # Uncomment the following line if you do not want to check your keystore files in. 47 | #*.jks 48 | 49 | # External native build folder generated in Android Studio 2.2 and later 50 | .externalNativeBuild 51 | 52 | # Google Services (e.g. APIs or Firebase) 53 | google-services.json 54 | 55 | # Freeline 56 | freeline.py 57 | freeline/ 58 | freeline_project_description.json 59 | 60 | # fastlane 61 | fastlane/report.xml 62 | fastlane/Preview.html 63 | fastlane/screenshots 64 | fastlane/test_output 65 | fastlane/readme.md 66 | -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkaflowski/GDPRDialog/909abe7f4e7e6481c748494c0a1a70b6cc87cb8c/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 37 | 38 | 39 | 40 | 41 | 42 | 44 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GDPRDialog 2 | Dialog with privacy policy. 3 | 4 | ![Alt Text](https://github.com/mkaflowski/GDPRDialog/blob/master/raw/device-2019-04-18-122320.png) 5 | 6 | 7 | ## Installation 8 | 9 | Add JitPack in your root build.gradle at the end of repositories: 10 | ``` 11 | allprojects { 12 | repositories { 13 | jcenter() 14 | maven { url "https://jitpack.io" } 15 | } 16 | } 17 | ``` 18 | 19 | Add it as a dependency in your app's build.gradle file: 20 | ``` 21 | dependencies { 22 | compile 'com.github.mkaflowski:GDPRDialog:1.x' //CHANGE X TO CURRENT VERSION!!! 23 | } 24 | ``` 25 | 26 | ## How to use 27 | 28 | ### Google Consent SDK 29 | 30 | https://developers.google.com/mobile-ads-sdk/docs/dfp/android/eu-consent 31 | 32 | ```java 33 | final ConsentInformation consentInformation = ConsentInformation.getInstance(this); 34 | consentStatus = consentInformation.getConsentStatus(); 35 | String[] publisherIds = {""}; 36 | consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() { 37 | @Override 38 | public void onConsentInfoUpdated(ConsentStatus consentStatus) { 39 | // User's consent status successfully updated. 40 | SplashActivity.this.consentStatus = consentStatus; 41 | if (consentStatus == ConsentStatus.UNKNOWN && ConsentInformation.getInstance(context).isRequestLocationInEeaOrUnknown()) { 42 | showGDPRDialog(SplashActivity.this); 43 | } 44 | } 45 | 46 | @Override 47 | public void onFailedToUpdateConsentInfo(String errorDescription) { 48 | // User's consent status failed to update. 49 | KLog.w("gdpr " + errorDescription); 50 | } 51 | }); 52 | ``` 53 | 54 | ### GDPRDialog 55 | 56 | ```java 57 | GDPRDialog gdpr = new GDPRDialog(this, false); 58 | 59 | gdpr.setConsentFormListener(new ConsentFormListener() { 60 | @Override 61 | public void onConsentFormOpened() { 62 | super.onConsentFormOpened(); 63 | } 64 | 65 | @Override 66 | public void onConsentFormClosed(ConsentStatus consentStatus, Boolean userPrefersAdFree) { 67 | super.onConsentFormClosed(consentStatus, userPrefersAdFree); 68 | KLog.d("gdpr " + consentStatus); 69 | if (consentStatus == ConsentStatus.NON_PERSONALIZED) { 70 | //disablePersonalizedFeatures(activity); 71 | 72 | } else { 73 | //enablePersonalizedFeatures(activity); 74 | } 75 | } 76 | }); 77 | gdpr.setFeatures(GDPRFeature.GOOGLE, GDPRFeature.FACEBOOK, GDPRFeature.FIREBASE_CRASH_REPORTING, GDPRFeature.FIREBASE_CLOUD_MESSAGING, GDPRFeature.FIREBASE); 78 | gdpr.setPrivacyPolicy("https://play.google.com/store/apps/"); 79 | gdpr.show(); 80 | ``` 81 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 27 5 | defaultConfig { 6 | applicationId "gdprdialog.lib.mk.gdprdialog" 7 | minSdkVersion 15 8 | targetSdkVersion 27 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(dir: 'libs', include: ['*.jar']) 23 | implementation 'com.android.support:appcompat-v7:27.1.1' 24 | implementation 'com.android.support.constraint:constraint-layout:1.1.0' 25 | testImplementation 'junit:junit:4.12' 26 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 28 | implementation 'com.github.zhaokaiqiang.klog:library:1.6.0' 29 | 30 | implementation project(path: ':library') 31 | } 32 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/gdprdialog/lib/mk/gdprdialog/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package gdprdialog.lib.mk.gdprdialog; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("gdprdialog.lib.mk.gdprdialog", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/gdprdialog/lib/mk/gdprdialog/MainActivity.java: -------------------------------------------------------------------------------- 1 | package gdprdialog.lib.mk.gdprdialog; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.view.View; 6 | 7 | import com.google.ads.consent.ConsentFormListener; 8 | import com.google.ads.consent.ConsentInformation; 9 | import com.google.ads.consent.ConsentStatus; 10 | import com.socks.library.KLog; 11 | 12 | import mk.lib.gdprdialog.GDPRDialog; 13 | import mk.lib.gdprdialog.GDPRFeature; 14 | 15 | 16 | public class MainActivity extends AppCompatActivity { 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_main); 22 | } 23 | 24 | 25 | public void showGDPR(View view) { 26 | KLog.i("gdpr status" + ConsentInformation.getInstance(this).getConsentStatus()); 27 | KLog.i("gdpr loaction" + ConsentInformation.getInstance(this).isRequestLocationInEeaOrUnknown()); 28 | 29 | GDPRDialog gdpr = new GDPRDialog(this, false); 30 | 31 | gdpr.setConsentFormListener(new ConsentFormListener() { 32 | @Override 33 | public void onConsentFormOpened() { 34 | super.onConsentFormOpened(); 35 | } 36 | 37 | @Override 38 | public void onConsentFormClosed(ConsentStatus consentStatus, Boolean userPrefersAdFree) { 39 | super.onConsentFormClosed(consentStatus, userPrefersAdFree); 40 | KLog.d("gdpr " + consentStatus); 41 | if (consentStatus == ConsentStatus.NON_PERSONALIZED) { 42 | //disablePersonalizedFeatures(activity); 43 | 44 | } else { 45 | //enablePersonalizedFeatures(activity); 46 | } 47 | } 48 | }); 49 | gdpr.setFeatures(GDPRFeature.GOOGLE, GDPRFeature.FACEBOOK, GDPRFeature.FIREBASE_CRASH_REPORTING, GDPRFeature.FIREBASE_CLOUD_MESSAGING, GDPRFeature.FIREBASE); 50 | gdpr.setPrivacyPolicy("https://play.google.com/store/apps/"); 51 | gdpr.show(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |