├── Android-Privacy-Policy.iml ├── README.md ├── app ├── .gitignore ├── app.iml ├── build.gradle ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── net │ │ │ └── khirr │ │ │ └── android │ │ │ └── privacypolicy │ │ │ └── example │ │ │ ├── MainActivity.java │ │ │ └── SecondActivity.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── activity_second.xml │ │ └── content_second.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 │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── net │ └── khirr │ └── android │ └── privacypolicy │ └── example │ └── ExampleUnitTest.kt ├── art └── main-view-screenshot.png ├── build.gradle ├── build └── kotlin-build │ └── version.txt ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── library.iml ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── net │ │ │ └── khirr │ │ │ └── android │ │ │ └── privacypolicy │ │ │ ├── EUHelper.kt │ │ │ ├── PrivacyPoliciesAdapter.kt │ │ │ └── PrivacyPolicyDialog.kt │ └── res │ │ ├── drawable-v21 │ │ └── net_khirr_policies_button_accept.xml │ │ ├── drawable │ │ └── net_khirr_policies_button_accept.xml │ │ ├── layout │ │ ├── net_khirr_dialog_privacy_policies.xml │ │ └── net_khirr_dialog_privacy_policy_item.xml │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── net │ └── khirr │ └── android │ └── privacypolicy │ └── ExampleUnitTest.java ├── local.properties └── settings.gradle /Android-Privacy-Policy.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android-Privacy-Policy 2 | A simple Android library to show Privacy Policy, Terms of Service and General Data Protection Regulation (GDPR). 3 | 4 | Api-level 16+ 5 | 6 | Preview: 7 | 8 | 9 | 10 | Usage: 11 | 12 | Add the repository to your gradle app 13 | 14 | **You can use 1.0.1 for AppCompat project, use 1.0.3 or higher for AndroidX projects.** 15 | ``` 16 | allprojects { 17 | repositories { 18 | maven { url 'https://jitpack.io' } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation 'com.github.khirr:Android-Privacy-Policy:1.0.1' 24 | } 25 | ``` 26 | 27 | Add this view to your code 28 | ``` 29 | // Initialice your dialog, first param is your terms of service url, and second param is your privacy policy url 30 | 31 | PrivacyPolicyDialog dialog = new PrivacyPolicyDialog(this, 32 | "https://localhost/terms", 33 | "https://localhost/privacy"); 34 | ``` 35 | 36 | Add your policy lines, the most import for users, your full policy and terms of service are on your urls. 37 | ``` 38 | dialog.addPoliceLine("This application uses a unique user identifier for advertising purposes, it is shared with third-party companies."); 39 | dialog.addPoliceLine("This application sends error reports, installation and send it to a server of the Fabric.io company to analyze and process it."); 40 | dialog.addPoliceLine("This application requires internet access and must collect the following information: Installed applications and history of installed applications, ip address, unique installation id, token to send notifications, version of the application, time zone and information about the language of the device."); 41 | dialog.addPoliceLine("All details about the use of data are available in our Privacy Policies, as well as all Terms of Service links below."); 42 | ``` 43 | 44 | Add your listener 45 | ``` 46 | final Intent intent = new Intent(this, SecondActivity.class); 47 | 48 | dialog.setOnClickListener(new PrivacyPolicyDialog.OnClickListener() { 49 | @Override 50 | public void onAccept(boolean isFirstTime) { 51 | Log.e("MainActivity", "Policies accepted"); 52 | startActivity(intent); 53 | finish(); 54 | } 55 | 56 | @Override 57 | public void onCancel() { 58 | Log.e("MainActivity", "Policies not accepted"); 59 | finish(); 60 | } 61 | }); 62 | ``` 63 | Enable for Europe only 64 | ``` 65 | dialog.setEuropeOnly(true); 66 | ``` 67 | 68 | Force reset if you need to update your policies and request accept it again (do not use it in your load-app lifecycle, if you do it, policies will need to be accepted everytime you launch app). 69 | ``` 70 | dialog.forceReset(); 71 | ``` 72 | 73 | Full dialog customizing 74 | ``` 75 | // Example 76 | dialog.setTitleTextColor(Color.parseColor("#222222")); 77 | dialog.setAcceptButtonColor(ContextCompat.getColor(this, R.color.colorAccent)); 78 | ``` 79 | 80 | ## License 81 | MIT 82 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 11 | 12 | 13 | 26 | 27 | 28 | 29 | 30 | 32 | 33 | 47 | 60 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | apply plugin: 'kotlin-android' 4 | 5 | apply plugin: 'kotlin-android-extensions' 6 | 7 | android { 8 | compileSdkVersion 29 9 | defaultConfig { 10 | applicationId "net.khirr.android.privacypolicy.example" 11 | minSdkVersion 16 12 | targetSdkVersion 29 13 | versionCode 1 14 | versionName "1.0" 15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation project(':library') 27 | implementation fileTree(dir: 'libs', include: ['*.jar']) 28 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 29 | implementation 'androidx.appcompat:appcompat:1.1.0' 30 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 31 | implementation 'com.google.android.material:material:1.1.0' 32 | } 33 | -------------------------------------------------------------------------------- /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/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/java/net/khirr/android/privacypolicy/example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package net.khirr.android.privacypolicy.example; 2 | 3 | import android.content.Intent; 4 | import android.graphics.Color; 5 | import android.os.Bundle; 6 | import androidx.annotation.Nullable; 7 | import androidx.core.content.ContextCompat; 8 | import androidx.appcompat.app.AppCompatActivity; 9 | import android.util.Log; 10 | 11 | import net.khirr.android.privacypolicy.PrivacyPolicyDialog; 12 | 13 | public class MainActivity extends AppCompatActivity { 14 | 15 | @Override 16 | protected void onCreate(@Nullable Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_main); 19 | 20 | // Params: context, termsOfService url, privacyPolicyUrl 21 | PrivacyPolicyDialog dialog = new PrivacyPolicyDialog(this, 22 | "https://localhost", 23 | "https://localhost"); 24 | 25 | final Intent intent = new Intent(this, SecondActivity.class); 26 | 27 | dialog.setOnClickListener(new PrivacyPolicyDialog.OnClickListener() { 28 | @Override 29 | public void onAccept(boolean isFirstTime) { 30 | Log.e("MainActivity", "Policies accepted"); 31 | startActivity(intent); 32 | finish(); 33 | } 34 | 35 | @Override 36 | public void onCancel() { 37 | Log.e("MainActivity", "Policies not accepted"); 38 | finish(); 39 | } 40 | }); 41 | 42 | dialog.addPoliceLine("This application uses a unique user identifier for advertising purposes, it is shared with third-party companies."); 43 | dialog.addPoliceLine("This application sends error reports, installation and send it to a server of the Fabric.io company to analyze and process it."); 44 | dialog.addPoliceLine("This application requires internet access and must collect the following information: Installed applications and history of installed applications, ip address, unique installation id, token to send notifications, version of the application, time zone and information about the language of the device."); 45 | dialog.addPoliceLine("All details about the use of data are available in our Privacy Policies, as well as all Terms of Service links below."); 46 | 47 | // Customizing (Optional) 48 | dialog.setTitleTextColor(Color.parseColor("#222222")); 49 | dialog.setAcceptButtonColor(ContextCompat.getColor(this, R.color.colorAccent)); 50 | 51 | // Title 52 | dialog.setTitle("Terms of Service"); 53 | 54 | // {terms}Terms of Service{/terms} is replaced by a link to your terms 55 | // {privacy}Privacy Policy{/privacy} is replaced by a link to your privacy policy 56 | dialog.setTermsOfServiceSubtitle("If you click on {accept}, you acknowledge that it makes the content present and all the content of our {terms}Terms of Service{/terms} and implies that you have read our {privacy}Privacy Policy{privacy}."); 57 | 58 | // Set Europe only 59 | dialog.setEuropeOnly(true); 60 | 61 | dialog.show(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/src/main/java/net/khirr/android/privacypolicy/example/SecondActivity.java: -------------------------------------------------------------------------------- 1 | package net.khirr.android.privacypolicy.example; 2 | 3 | import android.os.Bundle; 4 | import com.google.android.material.floatingactionbutton.FloatingActionButton; 5 | import com.google.android.material.snackbar.Snackbar; 6 | import androidx.appcompat.app.AppCompatActivity; 7 | import androidx.appcompat.widget.Toolbar; 8 | import android.view.View; 9 | import android.widget.Button; 10 | import android.widget.Toast; 11 | 12 | import net.khirr.android.privacypolicy.PrivacyPolicyDialog; 13 | 14 | public class SecondActivity extends AppCompatActivity { 15 | 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_second); 20 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 21 | setSupportActionBar(toolbar); 22 | 23 | Button forceResetButton = (Button) findViewById(R.id.forceResetButton); 24 | 25 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 26 | fab.setOnClickListener(new View.OnClickListener() { 27 | @Override 28 | public void onClick(View view) { 29 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) 30 | .setAction("Action", null).show(); 31 | } 32 | }); 33 | 34 | final PrivacyPolicyDialog dialog = new PrivacyPolicyDialog(this, 35 | "https://localhost", 36 | "https://localhost"); 37 | 38 | forceResetButton.setOnClickListener(new View.OnClickListener() { 39 | @Override 40 | public void onClick(View view) { 41 | dialog.forceReset(); 42 | Toast.makeText(SecondActivity.this, "Next time you show policies, it will ask you again", Toast.LENGTH_LONG).show(); 43 | } 44 | }); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /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 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_second.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_second.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 |