diff --git a/CheckoutExample/app/build.gradle b/CheckoutExample/app/build.gradle index bc0bcee..7e4e2ce 100644 --- a/CheckoutExample/app/build.gradle +++ b/CheckoutExample/app/build.gradle @@ -26,9 +26,10 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'com.google.android.instantapps:instantapps:1.1.0' + implementation 'com.google.android.instantapps:instantapps:1.1.0' implementation 'com.google.code.gson:gson:2.8.6' - implementation group: 'com.android.volley', name: 'volley', version: '1.2.0' - implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10' - implementation "com.google.android.material:material:1.4.0-beta01" + implementation group: 'com.android.volley', name: 'volley', version: '1.2.1' + implementation "com.google.android.material:material:1.4.0" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" } diff --git a/CheckoutExample/app/src/main/AndroidManifest.xml b/CheckoutExample/app/src/main/AndroidManifest.xml index 964d5ca..ad2ccc4 100644 --- a/CheckoutExample/app/src/main/AndroidManifest.xml +++ b/CheckoutExample/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ = Build.VERSION_CODES.M) + requestLocationPermissions(this); + else + AnalyticsCollector.collectDeviceDataForSession(this); + + + } + + private void initView() { final TextView merchant = (TextView) findViewById(R.id.merchant); final TextView environment = (TextView) findViewById(R.id.environment); final Button checkoutButton = (Button) findViewById(R.id.checkoutButton); @@ -63,22 +94,18 @@ public void onClick(View v) { }); } - void requestLocationPermissions() { + void requestLocationPermissions(Activity activity) { final TextView location = (TextView) findViewById(R.id.location); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { - if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION)) { - ActivityCompat.requestPermissions(this, new String[]{ - Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_REQUEST_LOCATION); - } else { - ActivityCompat.requestPermissions(this, new String[]{ - Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_REQUEST_LOCATION); - } + + if (ContextCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION)) { + ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, AnalyticsCollector.REQUEST_PERMISSION_LOCATION); } else { - location.setText("Allowed"); + ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, AnalyticsCollector.REQUEST_PERMISSION_LOCATION); } } else { - // The permissions are allowed by default if installed on a device with a OS less than M + //This block executes when permission is already granted. + AnalyticsCollector.collectDeviceDataForSession(activity); location.setText("Allowed"); } } @@ -86,7 +113,9 @@ void requestLocationPermissions() { @Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { final TextView location = (TextView) findViewById(R.id.location); - if (requestCode == PERMISSIONS_REQUEST_LOCATION) { + if (requestCode == AnalyticsCollector.REQUEST_PERMISSION_LOCATION) { + //this block executes when a user grant/deny the permission + AnalyticsCollector.collectDeviceDataForSession(this); if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { location.setText("Allowed"); } else { @@ -95,4 +124,10 @@ public void onRequestPermissionsResult(int requestCode, String permissions[], in } } + @Override + protected void onSaveInstanceState(@NonNull Bundle outState) { + super.onSaveInstanceState(outState); + outState.putString(KEY_UUID, deviceSessionID); + } + } \ No newline at end of file diff --git a/CheckoutExample/kotlinexample/build.gradle b/CheckoutExample/kotlinexample/build.gradle index 3a47bea..d150c0f 100644 --- a/CheckoutExample/kotlinexample/build.gradle +++ b/CheckoutExample/kotlinexample/build.gradle @@ -35,9 +35,9 @@ dependencies { testImplementation 'junit:junit:4.13' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' - implementation 'com.google.android.instantapps:instantapps:1.1.0' + implementation 'com.google.android.instantapps:instantapps:1.1.0' implementation 'com.google.code.gson:gson:2.8.6' - implementation group: 'com.android.volley', name: 'volley', version: '1.2.0' - implementation "com.google.android.material:material:1.4.0-beta01" + implementation group: 'com.android.volley', name: 'volley', version: '1.2.1' + implementation "com.google.android.material:material:1.4.0" } diff --git a/CheckoutExample/kotlinexample/src/main/AndroidManifest.xml b/CheckoutExample/kotlinexample/src/main/AndroidManifest.xml index efbb8af..bec5024 100644 --- a/CheckoutExample/kotlinexample/src/main/AndroidManifest.xml +++ b/CheckoutExample/kotlinexample/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ = Build.VERSION_CODES.M) + requestLocationPermissions(this) + else + AnalyticsCollector.collectDeviceDataForSession(this) + } + + private fun initView() { merchant.text = "$MERCHANT_ID" when (ENVIRONMENT) { AnalyticsCollector.ENVIRONMENT_TEST -> environment.text = "Test" @@ -44,29 +71,28 @@ class MainActivity : AppCompatActivity() { checkoutButton.setOnClickListener { startActivity(Intent(this@MainActivity, CollectionActivity::class.java)) } - } - private fun requestLocationPermissions() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { - if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION)) { - ActivityCompat.requestPermissions(this, arrayOf( - Manifest.permission.ACCESS_FINE_LOCATION), PERMISSIONS_REQUEST_LOCATION) - } else { - ActivityCompat.requestPermissions(this, arrayOf( - Manifest.permission.ACCESS_FINE_LOCATION), PERMISSIONS_REQUEST_LOCATION) - } + fun requestLocationPermissions(activity: Activity?) { + if (ContextCompat.checkSelfPermission(activity!!, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION)) { + ActivityCompat.requestPermissions(activity, arrayOf( + Manifest.permission.ACCESS_FINE_LOCATION), AnalyticsCollector.REQUEST_PERMISSION_LOCATION) } else { - location.text = "Allowed" + ActivityCompat.requestPermissions(activity, arrayOf( + Manifest.permission.ACCESS_FINE_LOCATION), AnalyticsCollector.REQUEST_PERMISSION_LOCATION) } } else { + //This block executes when permission is already granted. + AnalyticsCollector.collectDeviceDataForSession(activity) location.text = "Allowed" } } override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { - if (requestCode == PERMISSIONS_REQUEST_LOCATION) { + if (requestCode == AnalyticsCollector.REQUEST_PERMISSION_LOCATION) { + //this block executes when a user grant/deny the permission + AnalyticsCollector.collectDeviceDataForSession(this) if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { location.text = "Allowed" } else { @@ -74,4 +100,9 @@ class MainActivity : AppCompatActivity() { } } } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + outState.putString(KEY_UUID, deviceSessionID) + } } \ No newline at end of file diff --git a/KountDataCollector/kount-data-collector-4.1.3.jar b/KountDataCollector/kount-data-collector-4.1.3.jar deleted file mode 100644 index 7cebfab..0000000 Binary files a/KountDataCollector/kount-data-collector-4.1.3.jar and /dev/null differ diff --git a/KountDataCollector/kount-data-collector-4.2.1.jar b/KountDataCollector/kount-data-collector-4.2.1.jar new file mode 100644 index 0000000..24ea3e2 Binary files /dev/null and b/KountDataCollector/kount-data-collector-4.2.1.jar differ