diff --git a/.gitignore b/.gitignore index e69de29..d65f388 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures + diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..7564e1b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Android SDK Release Notes + +## 3.0 +* Updated SDK with more intuitive configuration and collection +* Improved collection capabilities + + diff --git a/CheckoutExample/.gitignore b/CheckoutExample/.gitignore new file mode 100644 index 0000000..c6cbe56 --- /dev/null +++ b/CheckoutExample/.gitignore @@ -0,0 +1,8 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures diff --git a/CheckoutExample/.idea/.name b/CheckoutExample/.idea/.name new file mode 100644 index 0000000..e0e9371 --- /dev/null +++ b/CheckoutExample/.idea/.name @@ -0,0 +1 @@ +CheckoutExample \ No newline at end of file diff --git a/CheckoutExample/.idea/compiler.xml b/CheckoutExample/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/CheckoutExample/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CheckoutExample/.idea/copyright/profiles_settings.xml b/CheckoutExample/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/CheckoutExample/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/CheckoutExample/.idea/encodings.xml b/CheckoutExample/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/CheckoutExample/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CheckoutExample/.idea/gradle.xml b/CheckoutExample/.idea/gradle.xml new file mode 100644 index 0000000..58992cc --- /dev/null +++ b/CheckoutExample/.idea/gradle.xml @@ -0,0 +1,24 @@ + + + + + + \ No newline at end of file diff --git a/CheckoutExample/.idea/misc.xml b/CheckoutExample/.idea/misc.xml new file mode 100644 index 0000000..1a3eaff --- /dev/null +++ b/CheckoutExample/.idea/misc.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CheckoutExample/.idea/modules.xml b/CheckoutExample/.idea/modules.xml new file mode 100644 index 0000000..6d96e55 --- /dev/null +++ b/CheckoutExample/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/CheckoutExample/.idea/runConfigurations.xml b/CheckoutExample/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/CheckoutExample/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/CheckoutExample/app/.gitignore b/CheckoutExample/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/CheckoutExample/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/CheckoutExample/app/build.gradle b/CheckoutExample/app/build.gradle new file mode 100644 index 0000000..a40ca09 --- /dev/null +++ b/CheckoutExample/app/build.gradle @@ -0,0 +1,27 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 23 + buildToolsVersion "23.0.2" + + defaultConfig { + applicationId "com.kount.checkoutexample" + minSdkVersion 10 + targetSdkVersion 23 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile fileTree(dir: '../../KountDataCollector', include: ['*.jar']) + testCompile 'junit:junit:4.12' + compile 'com.android.support:appcompat-v7:23.3.0' +} diff --git a/CheckoutExample/app/proguard-rules.pro b/CheckoutExample/app/proguard-rules.pro new file mode 100644 index 0000000..39dfae1 --- /dev/null +++ b/CheckoutExample/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/kdf/Library/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/CheckoutExample/app/src/main/AndroidManifest.xml b/CheckoutExample/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..970d9c4 --- /dev/null +++ b/CheckoutExample/app/src/main/AndroidManifest.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CheckoutExample/app/src/main/java/com/kount/checkoutexample/CollectionActivity.java b/CheckoutExample/app/src/main/java/com/kount/checkoutexample/CollectionActivity.java new file mode 100644 index 0000000..6199940 --- /dev/null +++ b/CheckoutExample/app/src/main/java/com/kount/checkoutexample/CollectionActivity.java @@ -0,0 +1,39 @@ +package com.kount.checkoutexample; + +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.widget.TextView; + +import com.kount.api.DataCollector; + +import java.util.UUID; + +public class CollectionActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_collection); + setTitle("Checkout Page"); + + final TextView textArea = (TextView) findViewById(R.id.textarea); + textArea.append("Collection Starting\n\n"); + + String sessionID = UUID.randomUUID().toString(); + sessionID = sessionID.replace("-", ""); + textArea.append("Session ID:\n" + sessionID + "\n\n"); + + DataCollector.getInstance().collectForSession(sessionID, new DataCollector.CompletionHandler() { + @Override + public void completed(String s) { + textArea.append("Collection Completed"); + } + + @Override + public void failed(String s, final DataCollector.Error error) { + textArea.append("Collection Failed\n\n"); + textArea.append(error.toString()); + } + }); + } +} diff --git a/CheckoutExample/app/src/main/java/com/kount/checkoutexample/MainActivity.java b/CheckoutExample/app/src/main/java/com/kount/checkoutexample/MainActivity.java new file mode 100644 index 0000000..8097ef5 --- /dev/null +++ b/CheckoutExample/app/src/main/java/com/kount/checkoutexample/MainActivity.java @@ -0,0 +1,99 @@ +package com.kount.checkoutexample; + +import android.Manifest; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.os.Build; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + +import com.kount.api.DataCollector; + +import java.util.Locale; + +public class MainActivity extends AppCompatActivity { + + final int PERMISSIONS_REQUEST_LOCATION = 0; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + setTitle("Sample"); + + final int MERCHANT_ID = 0; // Insert your valid merchant ID + final int ENVIRONMENT = DataCollector.ENVIRONMENT_TEST; + + // Check for location permissions so the Data Collector can gather the device location + requestLocationPermissions(); + + // Configure the collector + DataCollector.getInstance().setDebug(true); + DataCollector.getInstance().setContext(this); + DataCollector.getInstance().setMerchantID(MERCHANT_ID); + DataCollector.getInstance().setEnvironment(ENVIRONMENT); + DataCollector.getInstance().setLocationCollectorConfig(DataCollector.LocationConfig.COLLECT); + + final TextView merchant = (TextView) findViewById(R.id.merchant); + final TextView environment = (TextView) findViewById(R.id.environment); + final Button checkoutButton = (Button) findViewById(R.id.checkoutButton); + + merchant.setText(String.format(Locale.US, "%d", MERCHANT_ID)); + switch (ENVIRONMENT) { + case DataCollector.ENVIRONMENT_TEST: + environment.setText("Test"); + break; + case DataCollector.ENVIRONMENT_PRODUCTION: + environment.setText("Production"); + break; + default: + environment.setText("Unknown"); + } + + checkoutButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(MainActivity.this, CollectionActivity.class); + startActivity(intent); + } + }); + } + + void requestLocationPermissions() { + 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); + } + } else { + location.setText("Allowed"); + } + } else { + // The permissions are allowed by default if installed on a device with a OS less than M + location.setText("Allowed"); + } + } + + @Override + public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { + final TextView location = (TextView) findViewById(R.id.location); + if (requestCode == PERMISSIONS_REQUEST_LOCATION) { + if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + location.setText("Allowed"); + } else { + location.setText("Denied"); + } + } + } + +} diff --git a/CheckoutExample/app/src/main/res/layout/activity_collection.xml b/CheckoutExample/app/src/main/res/layout/activity_collection.xml new file mode 100644 index 0000000..428aa29 --- /dev/null +++ b/CheckoutExample/app/src/main/res/layout/activity_collection.xml @@ -0,0 +1,19 @@ + + + + + + diff --git a/CheckoutExample/app/src/main/res/layout/activity_main.xml b/CheckoutExample/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..d4022bf --- /dev/null +++ b/CheckoutExample/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +