CookiesConsent


Source link: https://github.com/Carlosph/CookiesConsent

CookiesConsent for Android

Android library to inform EU users of the use of cookies. The alert can be shown via dialog or an overlay view.

Gradle

Add the next dependency to your gradle.build

compile 'com.github.carlosph:cookiesconsent:0.9.5'

Usage

On the onCreate method of your MainActivity, create a new CookiesConsetDialog or CookiesConsetOverlay and call the method showIfApplies().

To add a link to your privacy policy use the method setPolicyUrl(String policyUrl).

If you need to run some code only when the user has given the consent (i.e. ads or analytics code), you can set a CookiesConsentListener, and the code on its onCookiesAllowed method will be executed only when the user is not from the EU or he has already being notified about the use of cookies.

Additionally you can use the method CookiesConsentAlert.isConsentNeeded(Context context) anywhere in your code to know if the user has yet to give consent about the use of cookies.

#Example

To show the dialog or the overlay to EU users when they open the app for the first time just add the following code:

Dialog

new CookiesConsentDialog(this)  .setPolicyUrl("https://github.com/Carlosph/CookiesConsent")  .showIfApplies();

Overlay

new CookiesConsentOverlay(this)  .setPolicyUrl("https://github.com/Carlosph/CookiesConsent")  .showIfApplies();

With listener

If you want to run some code only when users are not from EU or when they have already given consent to the use of cookies, you can use a listener. The code would be something like this:

new CookiesConsentOverlay(this)
  .setPolicyUrl("https://github.com/Carlosph/CookiesConsent")
  .setListener(new CookiesConsentAlert.CookiesConsentListener() {

@Override

public void onCookiesAllowed() {

 // Code for non EU users or users
 // which have already given consent

}

  
}
)
  .showIfApplies();

Languages

Supported languages:

  • English
  • Spanish
  • French
  • Russian

There are just a few strings to be translated, so if your language is not supported, please help us by sending the translation.

You can send a pull request or just send me the strings, as you like. I will try to keep the library updated with the translations that I receive.

Strings to translate

<resources>
  <string name="dialog_title">This app uses cookies</string>
  <string name="dialog_text">Using it, you consent to the use of cookies in accordance with the terms of our %1$s.</string>
  <string name="privacy_policy">privacy policy</string>
  <string name="exit_button_text">Exit App</string>
  <string name="continue_button_text">Continue</string> </resources>

Thanks

The code to detect if the user is from the European Union is from this Stack Overflow question, asked by Mr.Betatester and answered by Ruyo.

License


 Copyright 2015 Carlos PiƱar Hafner

Licensed under the Apache License, Version 2.0 (the "License");

  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

Resources

DaVinci is an image downloading and caching library for Android Wear.

jimu Mirror provides live, on-device previews of Android layouts. It also allows you to create realistic prototypes of Android native UI without Java code.

This library provides a BaseBluetoothActivity that you inherit from to easily take care of:

  • Enabling bluetooth
  • Scanning for new devices.
  • Connecting to a device.
  • Receiving data from the device.
  • Sending data to the device.

Just a simple a linked ViewPager.

A modern JSON library for Android and Java.

A custom ViewPager which gives continuous feedback to the user when scrolling.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes