项目作者: anuragdalia

项目描述 :
CCPA Android SDK to ask for users preferences
高级语言: Kotlin
项目地址: git://github.com/anuragdalia/ccpa-android-sdk.git
创建时间: 2019-12-31T12:40:17Z
项目社区:https://github.com/anuragdalia/ccpa-android-sdk

开源协议:

下载


CCPA ANDROID SDK

CCPA Android Sdk (Unofficial and no guarantee)

Adds a link if the country of the user is unknown or california

  1. if(user clicks links)
  2. if(user from california)
  3. if(okay with data selling)
  4. dismiss()

after link is clicked you can directly jump to second state by setting

  1. <com.anurag.dalia.ccpa.ccpa_sdk.DNSMPI
  2. ...
  3. app:dnsmpi_two_states="false"
  4. ></com.anurag.dalia.ccpa.ccpa_sdk.DNSMPI>

you can also configure the texts shown in each state with the attributes listed below

add this to your root build.gradle

  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url 'https://jitpack.io' }
  5. }
  6. }

and then add this dependency

  1. dependencies {
  2. ...
  3. implementation 'com.github.anuragdalia:ccpa-android-sdk:0.0.8'
  4. }

use this view where ever you wish to show the DNSMPI link (usually on the first screen thats shown to the user)

  1. <com.anurag.dalia.ccpa.ccpa_sdk.DNSMPI
  2. android:layout_width="wrap_content"
  3. android:layout_height="wrap_content" ></com.anurag.dalia.ccpa.ccpa_sdk.DNSMPI>

view configuration attributes and their formats are listed below

  • dnsmpi_custom_layout : reference (layout reference.. only use if you know what you are doing)
  • dnsmpi_link_color : color (color of the DNSPMI link)
  • dnsmpi_two_states : boolean
  • dnsmpi_state_a_text : string
  • dnsmpi_state_b_text : string
  • dnsmpi_ask_geo_permission : boolean
  • dnsmpi_get_location_internet: boolean

if you enable dnsmpi_ask_geo_permission
add this to the activity

  1. override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
  2. super.onRequestPermissionsResult(requestCode, permissions, grantResults)
  3. DNSMPI.onRequestPermissionsResult(requestCode, permissions, grantResults)
  4. }

use only one of these otherwise it will use both the methods and the method that responds last is the decider


dnsmpi_ask_geo_permission and dnsmpi_get_location_internet

At any point to know the preference just call

  1. DNSMPI.canSellData(context) //returns Boolean

//PS ignore the fuck-all readme writing it at 4am and in a hurry :P


//PPS havent even check properly if its working perfectly fine

Feel free to raise a PR