├── 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 |
7 |
8 |
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 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | generateDebugSources
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
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 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/khirr/Android-Privacy-Policy/ccbb4ce684526925091dbd6090a7781c4612be92/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/khirr/Android-Privacy-Policy/ccbb4ce684526925091dbd6090a7781c4612be92/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/khirr/Android-Privacy-Policy/ccbb4ce684526925091dbd6090a7781c4612be92/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/khirr/Android-Privacy-Policy/ccbb4ce684526925091dbd6090a7781c4612be92/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/khirr/Android-Privacy-Policy/ccbb4ce684526925091dbd6090a7781c4612be92/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/khirr/Android-Privacy-Policy/ccbb4ce684526925091dbd6090a7781c4612be92/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/khirr/Android-Privacy-Policy/ccbb4ce684526925091dbd6090a7781c4612be92/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/khirr/Android-Privacy-Policy/ccbb4ce684526925091dbd6090a7781c4612be92/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/khirr/Android-Privacy-Policy/ccbb4ce684526925091dbd6090a7781c4612be92/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/khirr/Android-Privacy-Policy/ccbb4ce684526925091dbd6090a7781c4612be92/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Android-Privacy-Policy
3 | SecondActivity
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/test/java/net/khirr/android/privacypolicy/example/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package net.khirr.android.privacypolicy.example
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/art/main-view-screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/khirr/Android-Privacy-Policy/ccbb4ce684526925091dbd6090a7781c4612be92/art/main-view-screenshot.png
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.3.71'
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.6.1'
11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/build/kotlin-build/version.txt:
--------------------------------------------------------------------------------
1 | 11001
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | android.enableJetifier=true
10 | android.useAndroidX=true
11 | org.gradle.jvmargs=-Xmx1536m
12 | # When configured, Gradle will run in incubating parallel mode.
13 | # This option should only be used with decoupled projects. More details, visit
14 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
15 | # org.gradle.parallel=true
16 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/khirr/Android-Privacy-Policy/ccbb4ce684526925091dbd6090a7781c4612be92/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Apr 10 13:44:03 CEST 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 26
7 |
8 | defaultConfig {
9 | minSdkVersion 16
10 | targetSdkVersion 26
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | }
26 |
27 | def supportVersion = '26.1.0'
28 |
29 | dependencies {
30 | implementation fileTree(dir: 'libs', include: ['*.jar'])
31 |
32 | implementation 'androidx.appcompat:appcompat:1.1.0'
33 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
34 | implementation 'androidx.recyclerview:recyclerview:1.1.0'
35 | implementation 'androidx.appcompat:appcompat:1.1.0'
36 | }
37 | repositories {
38 | mavenCentral()
39 | }
40 |
--------------------------------------------------------------------------------
/library/library.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | generateDebugSources
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
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 |
--------------------------------------------------------------------------------
/library/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 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/library/src/main/java/net/khirr/android/privacypolicy/EUHelper.kt:
--------------------------------------------------------------------------------
1 | package net.khirr.android.privacypolicy
2 |
3 | import android.content.Context
4 | import android.telephony.TelephonyManager
5 | import java.util.*
6 |
7 | private enum class EUCountry {
8 | AT, BE, BG, HR, CY, CZ, DK, EE, FI, FR, DE, GR, HU, IE, IT, LV, LT, LU, MT, NL, PL, PT, RO, SK, SI, ES, SE, GB, //28 member states
9 | GF, PF, TF, //French territories French Guiana, Polynesia, Southern Territories
10 | EL, UK, // alternative EU names for GR and GB
11 | ME, IS, AL, RS, TR, MK;
12 | }
13 |
14 | object EUHelper {
15 |
16 | fun isEu(context: Context): Boolean {
17 | return isEuByNetwork(context) || isEuBySim(context) || isEuByZoneId(context)
18 | }
19 |
20 | private fun contains(s: String): Boolean {
21 | for (country in EUCountry.values())
22 | if (country.name.equals(s, ignoreCase = true))
23 | return true
24 | return false
25 | }
26 |
27 | private fun isEuBySim(context: Context): Boolean {
28 | try {
29 | val tm = context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
30 | var simCountry: String? = tm.simCountryIso
31 | if (simCountry != null && simCountry.length == 2) {
32 | simCountry = simCountry.toUpperCase()
33 | if (contains(simCountry)) {
34 | return true
35 | }
36 | }
37 | return false
38 | } catch (e: Exception) {
39 | return false
40 | }
41 | }
42 |
43 | private fun isEuByNetwork(context: Context): Boolean {
44 | try {
45 | val tm = context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
46 | if (tm.phoneType != TelephonyManager.PHONE_TYPE_CDMA && tm.phoneType != TelephonyManager.PHONE_TYPE_NONE) {
47 | var networkCountry: String? = tm.networkCountryIso
48 | if (networkCountry != null && networkCountry.length == 2) {
49 | networkCountry = networkCountry.toUpperCase()
50 | if (contains(networkCountry)) {
51 | return true
52 | }
53 | }
54 | }
55 | return false
56 | } catch (e: Exception) {
57 | return true
58 | }
59 | }
60 |
61 | private fun isEuByZoneId(context: Context): Boolean {
62 | try {
63 | val tz = TimeZone.getDefault().id.toLowerCase()
64 | if (tz.length < 10) {
65 | return true
66 | } else if (tz.contains("euro")) {
67 | return true
68 | }
69 | } catch (e: Exception) {
70 | return true
71 | }
72 | return false
73 | }
74 | }
--------------------------------------------------------------------------------
/library/src/main/java/net/khirr/android/privacypolicy/PrivacyPoliciesAdapter.kt:
--------------------------------------------------------------------------------
1 | package net.khirr.android.privacypolicy
2 |
3 | import androidx.recyclerview.widget.RecyclerView
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import kotlinx.android.synthetic.main.net_khirr_dialog_privacy_policy_item.view.*
8 |
9 | class PrivacyPoliciesAdapter(private val textColor: Int) : RecyclerView.Adapter() {
10 |
11 | class PrivacyItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
12 | fun bind(textColor: Int, number: Int, body: String) = with(itemView) {
13 | this.numberTextView.text = ("$number.")
14 | this.bodyTextView.text = body
15 | this.numberTextView.setTextColor(textColor)
16 | this.bodyTextView.setTextColor(textColor)
17 | }
18 | }
19 |
20 | private val items = ArrayList()
21 | override fun getItemCount(): Int = items.size
22 |
23 | fun updateDataSet(items: List) {
24 | this.items.clear()
25 | this.items.addAll(items)
26 | }
27 |
28 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
29 | val view = LayoutInflater.from(parent.context)
30 | .inflate(R.layout.net_khirr_dialog_privacy_policy_item, parent, false)
31 | return PrivacyItemViewHolder(view)
32 | }
33 |
34 | override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
35 | when (holder) {
36 | is PrivacyItemViewHolder -> holder.bind(textColor,position + 1, items[position])
37 | }
38 | }
39 |
40 | }
--------------------------------------------------------------------------------
/library/src/main/java/net/khirr/android/privacypolicy/PrivacyPolicyDialog.kt:
--------------------------------------------------------------------------------
1 | package net.khirr.android.privacypolicy
2 |
3 | import android.app.AlertDialog
4 | import android.content.Context
5 | import android.graphics.Color
6 | import android.graphics.PorterDuff
7 | import android.graphics.drawable.ColorDrawable
8 | import android.graphics.drawable.GradientDrawable
9 | import android.graphics.drawable.RippleDrawable
10 | import android.os.Build
11 | import androidx.appcompat.app.AppCompatActivity
12 | import androidx.recyclerview.widget.LinearLayoutManager
13 | import android.text.Html
14 | import android.text.Spanned
15 | import android.text.method.LinkMovementMethod
16 | import android.util.Log
17 | import android.view.View
18 | import kotlinx.android.synthetic.main.net_khirr_dialog_privacy_policies.view.*
19 | import net.khirr.android.privacypolicy.R
20 | import android.graphics.drawable.ShapeDrawable
21 | import android.graphics.drawable.shapes.RoundRectShape
22 | import android.graphics.drawable.Drawable
23 | import java.util.*
24 | import android.content.res.ColorStateList
25 |
26 | class PrivacyPolicyDialog(private val context: AppCompatActivity,
27 | private val termsOfServiceUrl: String,
28 | private val privacyPolicyUrl: String) {
29 |
30 | var backgroundColor = Color.parseColor("#ffffff")
31 | var titleTextColor = Color.parseColor("#222222")
32 | var subtitleTextColor = Color.parseColor("#757575")
33 | var linkTextColor = Color.parseColor("#000000")
34 | var termsOfServiceTextColor = Color.parseColor("#757575")
35 |
36 |
37 | // Accept Button
38 | var acceptButtonColor = Color.parseColor("#222222")
39 | var acceptTextColor = Color.parseColor("#ffffff")
40 | var acceptText = context.getString(R.string.net_khirr_accept)
41 |
42 | // Cancel
43 | var cancelText = context.getString(R.string.net_khirr_cancel)
44 | var cancelTextColor = Color.parseColor("#757575")
45 |
46 | // Strings
47 | var title = context.getString(R.string.net_khirr_terms_of_service)
48 | var termsOfServiceSubtitle = context.getString(R.string.net_khirr_terms_of_service_subtitle)
49 |
50 | var europeOnly = false
51 |
52 | private var lines = ArrayList()
53 |
54 | companion object {
55 | private const val sharedPreferencesName = "netKhirrPolicies"
56 | private const val fieldPoliciesAccepted = "netKhirrPoliciesAccepted"
57 | }
58 |
59 | interface OnClickListener {
60 | fun onAccept(isFirstTime: Boolean)
61 | fun onCancel()
62 | }
63 |
64 | var onClickListener: OnClickListener? = null
65 | var dialog: AlertDialog? = null
66 |
67 | private var sharedPref = context.getSharedPreferences(sharedPreferencesName, Context.MODE_PRIVATE)
68 | private var adapter: PrivacyPoliciesAdapter? = null
69 |
70 | private var policiesAccepted: Boolean
71 | get() = sharedPref.getBoolean(fieldPoliciesAccepted, false)
72 | set(value) = sharedPref.edit()
73 | .putBoolean(fieldPoliciesAccepted, value)
74 | .apply()
75 |
76 | fun addPoliceLine(line: String) {
77 | lines.add(line)
78 | }
79 |
80 | private fun loadLayout(): View {
81 | val inflater = context.layoutInflater
82 | val layout = inflater.inflate(R.layout.net_khirr_dialog_privacy_policies, null)
83 |
84 | layout.container.setBackgroundColor(backgroundColor)
85 |
86 | layout.termsOfServiceTitle.text = title
87 | layout.termsOfServiceTitle.setTextColor(titleTextColor)
88 |
89 | layout.termsOfServiceSubtitleTextView.text = toHtml(termsOfServiceSubtitle)
90 | layout.termsOfServiceSubtitleTextView.movementMethod = LinkMovementMethod.getInstance()
91 | layout.termsOfServiceSubtitleTextView.setLinkTextColor(linkTextColor)
92 | layout.termsOfServiceSubtitleTextView.setTextColor(subtitleTextColor)
93 |
94 | layout.acceptTextView.setTextColor(acceptTextColor)
95 | setBackgroundColor(layout.acceptButton, acceptButtonColor)
96 | layout.acceptTextView.text = acceptText
97 |
98 | layout.cancelTextView.text = cancelText
99 | layout.cancelTextView.setTextColor(cancelTextColor)
100 |
101 | layout.acceptButton.setOnClickListener {
102 | dismiss()
103 | onClickListener?.onAccept(true)
104 | policiesAccepted = true
105 | }
106 |
107 | layout.cancelButton.setOnClickListener {
108 | dismiss()
109 | onClickListener?.onCancel()
110 | policiesAccepted = false
111 | }
112 |
113 | layout.policiesRecyclerView.layoutManager = LinearLayoutManager(context)
114 |
115 | adapter = PrivacyPoliciesAdapter(termsOfServiceTextColor)
116 | layout.policiesRecyclerView.adapter = adapter
117 |
118 | adapter?.updateDataSet(lines)
119 |
120 |
121 | return layout
122 | }
123 |
124 | private fun dismiss() {
125 | if (!context.isFinishing && dialog != null && dialog!!.isShowing) {
126 | dialog?.dismiss()
127 | }
128 | }
129 |
130 | fun show() {
131 | if (policiesAccepted) {
132 | onClickListener?.onAccept(false)
133 | return
134 | }
135 |
136 | if (europeOnly && !EUHelper.isEu(context)) {
137 | onClickListener?.onAccept(false)
138 | return
139 | }
140 |
141 | val builder = AlertDialog.Builder(context)
142 | builder.setView(loadLayout())
143 | builder.setCancelable(false)
144 | dialog = builder.show()
145 | }
146 |
147 | fun forceReset() {
148 | policiesAccepted = false
149 | }
150 |
151 | private fun toHtml(res: Int): Spanned {
152 | return toHtml(context.getString(res))
153 | }
154 |
155 | private fun toHtml(body: String): Spanned {
156 | val body = body
157 | .replace("{accept}", context.getString(R.string.net_khirr_accept))
158 | .replace("{privacy}", "")
159 | .replace("{/privacy}", "")
160 | .replace("{terms}", "")
161 | .replace("{/terms}", "")
162 | .replace("{", "<")
163 | .replace("}", ">")
164 | return if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
165 | Html.fromHtml(body, Html.FROM_HTML_MODE_LEGACY)
166 | } else {
167 | Html.fromHtml(body)
168 | }
169 | }
170 |
171 | private fun setBackgroundColor(view: View?, resColor: Int) {
172 | if (view == null || view.background == null)
173 | return
174 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && view.background is RippleDrawable) {
175 | val rippleDrawable = view.background as RippleDrawable
176 | rippleDrawable.setColorFilter(resColor, PorterDuff.Mode.MULTIPLY)
177 | } else {
178 | if (view.background is ColorDrawable) {
179 | // Non ripple
180 | val drawable = view.background as ColorDrawable
181 | // Solid
182 | drawable.color = resColor
183 | } else if (view.background is GradientDrawable) {
184 | // Non ripple
185 | val drawable = view.background as GradientDrawable
186 | // Solid
187 | drawable.setColor(resColor)
188 | }
189 | }
190 | }
191 | }
--------------------------------------------------------------------------------
/library/src/main/res/drawable-v21/net_khirr_policies_button_accept.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 | -
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/net_khirr_policies_button_accept.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/net_khirr_dialog_privacy_policies.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
19 |
24 |
28 |
29 |
34 |
35 |
39 |
44 |
56 |
57 |
58 |
59 |
63 |
69 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
90 |
93 |
99 |
100 |
112 |
117 |
118 |
119 |
120 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/net_khirr_dialog_privacy_policy_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
18 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Accept
3 | Cancel
4 | Terms of Service
5 | 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}.
6 |
7 |
--------------------------------------------------------------------------------
/library/src/test/java/net/khirr/android/privacypolicy/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package net.khirr.android.privacypolicy;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file must *NOT* be checked into Version Control Systems,
2 | # as it contains information specific to your local configuration.
3 | #
4 | # Location of the SDK. This is only used by Gradle.
5 | # For customization when using a Version Control System, please read the
6 | # header note.
7 | #Sat Sep 08 16:13:25 CEST 2018
8 | sdk.dir=/Users/khirr/Library/Android/sdk
9 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
2 |
--------------------------------------------------------------------------------