diff --git a/.gradle/2.14.1/taskArtifacts/fileSnapshotsToTreeSnapshotsIndex.bin b/.gradle/2.14.1/taskArtifacts/fileSnapshotsToTreeSnapshotsIndex.bin new file mode 100644 index 0000000..9383181 Binary files /dev/null and b/.gradle/2.14.1/taskArtifacts/fileSnapshotsToTreeSnapshotsIndex.bin differ diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..9a8b7e5 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..b410f03 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/animated_vector_drawable_24_2_0.xml b/.idea/libraries/animated_vector_drawable_24_2_0.xml new file mode 100644 index 0000000..e4d9c25 --- /dev/null +++ b/.idea/libraries/animated_vector_drawable_24_2_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/appcompat_v7_24_2_0.xml b/.idea/libraries/appcompat_v7_24_2_0.xml new file mode 100644 index 0000000..0e2385e --- /dev/null +++ b/.idea/libraries/appcompat_v7_24_2_0.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/brein_api_library_android.xml b/.idea/libraries/brein_api_library_android.xml new file mode 100644 index 0000000..2637e0c --- /dev/null +++ b/.idea/libraries/brein_api_library_android.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/gson_2_6_2.xml b/.idea/libraries/gson_2_6_2.xml new file mode 100644 index 0000000..5cae373 --- /dev/null +++ b/.idea/libraries/gson_2_6_2.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/hamcrest_core_1_3.xml b/.idea/libraries/hamcrest_core_1_3.xml new file mode 100644 index 0000000..157e3f3 --- /dev/null +++ b/.idea/libraries/hamcrest_core_1_3.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/json_20140107.xml b/.idea/libraries/json_20140107.xml new file mode 100644 index 0000000..395ab89 --- /dev/null +++ b/.idea/libraries/json_20140107.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/junit_4_12.xml b/.idea/libraries/junit_4_12.xml new file mode 100644 index 0000000..305df30 --- /dev/null +++ b/.idea/libraries/junit_4_12.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_annotations_24_2_0.xml b/.idea/libraries/support_annotations_24_2_0.xml new file mode 100644 index 0000000..b01b9db --- /dev/null +++ b/.idea/libraries/support_annotations_24_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_compat_24_2_0.xml b/.idea/libraries/support_compat_24_2_0.xml new file mode 100644 index 0000000..58040ae --- /dev/null +++ b/.idea/libraries/support_compat_24_2_0.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_core_ui_24_2_0.xml b/.idea/libraries/support_core_ui_24_2_0.xml new file mode 100644 index 0000000..e090114 --- /dev/null +++ b/.idea/libraries/support_core_ui_24_2_0.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_core_utils_24_2_0.xml b/.idea/libraries/support_core_utils_24_2_0.xml new file mode 100644 index 0000000..463ee38 --- /dev/null +++ b/.idea/libraries/support_core_utils_24_2_0.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_fragment_24_2_0.xml b/.idea/libraries/support_fragment_24_2_0.xml new file mode 100644 index 0000000..9cdfc36 --- /dev/null +++ b/.idea/libraries/support_fragment_24_2_0.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_media_compat_24_2_0.xml b/.idea/libraries/support_media_compat_24_2_0.xml new file mode 100644 index 0000000..19ecbfc --- /dev/null +++ b/.idea/libraries/support_media_compat_24_2_0.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_v4_24_2_0.xml b/.idea/libraries/support_v4_24_2_0.xml new file mode 100644 index 0000000..9a609dc --- /dev/null +++ b/.idea/libraries/support_v4_24_2_0.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_vector_drawable_24_2_0.xml b/.idea/libraries/support_vector_drawable_24_2_0.xml new file mode 100644 index 0000000..71c3b16 --- /dev/null +++ b/.idea/libraries/support_vector_drawable_24_2_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..95f0f03 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..d202a8c --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..279f0d7 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,3772 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1475702849367 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + file://$PROJECT_DIR$/app/src/main/java/com/breinapp/FullscreenActivity.java + 142 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/BreinAndroidApi.iml b/BreinAndroidApi.iml new file mode 100644 index 0000000..bdaab9a --- /dev/null +++ b/BreinAndroidApi.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..39ba415 --- /dev/null +++ b/README.md @@ -0,0 +1,85 @@ +

+ Breinify API Java Library +

+ +

+Breinify's DigitalDNA API puts dynamic behavior-based, people-driven data right at your fingertips. +

+ +### Step By Step Introduction + +#### What is Breinify's DigitialDNA + +Breinify's DigitalDNA API puts dynamic behavior-based, people-driven data right at your fingertips. We believe that in many situations, a critical component of a great user experience is personalization. With all the data available on the web it should be easy to provide a unique experience to every visitor, and yet, sometimes you may find yourself wondering why it is so difficult. + +Thanks to **Breinify's DigitalDNA** you are now able to adapt your online presence to your visitors needs and **provide a unique experience**. Let's walk step-by-step through a simple example. + +### Quick start + +#### Step 1: Download the Library + +Download the Library from JCenter Repository <> + + +#### Step 2: Integrate the library + +Integrate the Library into your Android project. + + +#### Step 3: Configure the library + +In order to use the library you need a valid API-key, which you can get for free at [https://www.breinify.com](https://www.breinify.com). In this example, we assume you have the following api-key: + +**772A-47D7-93A3-4EA9-9D73-85B9-479B-16C6** + +```Java +// this is the valid api-key +final String apiKey = "772A-47D7-93A3-4EA9-9D73-85B9-479B-16C6"; + +// this is the URL of the Breinify service +final String serviceEndpoint = "https://api.breinify.com"; + +// create the configuration object +final BreinConfig breinConfig = new BreinConfig(VALID_API_KEY, + BASE_URL, + BreinEngineType.HTTP_URL_CONNECTION_ENGINE); + +// set the configuration for later usage +Breinify.setConfig(breinConfig); + +``` + +The Breinify class is now configured with a valid configuration object. + + +#### Step 4: Start using the library + +##### Placing activity triggers + +The engine powering the DigitalDNA API provides two endpoints. The first endpoint is used to inform the engine about the activities performed by visitors of your site. The activities are used to understand the user's current interest and infer the intent. It becomes more and more accurate across different users and verticals as more activities are collected. It should be noted, that any personal information is not stored within the engine, thus each individual's privacy is well protected. The engine understands several different activities performed by a user, e.g., landing, login, search, item selection, or logout. + +The engine is informed of an activity by executing *Breinify.activity(...)*. + +```Java +// create a user you are interested in +final BreinUser breinUser = new BreinUser("user.anywhere@email.com") + .setFirstName("User") + .setLastName("Anyhere"); + +// invoke an activity noting that the user has logged in +Breinify.activity(breinUser, + BreinActivityType.LOGIN, + BreinCategoryType.HOME, + "Login-Description", + false); + +``` + +That's it! + +### Further links +To understand all the capabilities of Breinify's DigitalDNA API, take a look at: + +* [Additional code snippets](documentation/more-snippets.md), +* [Change Log](documentation/changelog.md), or +* [Breinify's Website](https://www.breinify.com). diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/app.iml b/app/app.iml new file mode 100644 index 0000000..4e612ed --- /dev/null +++ b/app/app.iml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..061dbdd --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,41 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 24 + buildToolsVersion "24.0.2" + + defaultConfig { + applicationId "com.breinapp" + minSdkVersion 14 + targetSdkVersion 24 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + + packagingOptions { + exclude 'META-INF/DEPENDENCIES.txt' + exclude 'META-INF/LICENSE.txt' + exclude 'META-INF/NOTICE.txt' + exclude 'META-INF/NOTICE' + exclude 'META-INF/LICENSE' + exclude 'META-INF/DEPENDENCIES' + exclude 'META-INF/notice.txt' + exclude 'META-INF/license.txt' + exclude 'META-INF/dependencies.txt' + exclude 'META-INF/LGPL2.1' + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + testCompile 'junit:junit:4.12' + compile 'com.android.support:appcompat-v7:24.2.0' + compile 'com.android.support:support-v4:24.2.0' + compile project(path: ':brein-api-library-android') +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..bdc84a6 --- /dev/null +++ b/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/marcorecchioni/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/app/src/androidTest/java/com/breinapp/ApplicationTest.java b/app/src/androidTest/java/com/breinapp/ApplicationTest.java new file mode 100644 index 0000000..c28aad4 --- /dev/null +++ b/app/src/androidTest/java/com/breinapp/ApplicationTest.java @@ -0,0 +1,13 @@ +package com.breinapp; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..8a28860 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/breinapp/FullscreenActivity.java b/app/src/main/java/com/breinapp/FullscreenActivity.java new file mode 100644 index 0000000..920c06c --- /dev/null +++ b/app/src/main/java/com/breinapp/FullscreenActivity.java @@ -0,0 +1,226 @@ +package com.breinapp; + +import android.annotation.SuppressLint; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.os.Handler; +import android.view.MotionEvent; +import android.view.View; + +import com.brein.api.Breinify; +import com.brein.domain.BreinActivityType; +import com.brein.domain.BreinCategoryType; +import com.brein.domain.BreinConfig; +import com.brein.domain.BreinUser; +import com.brein.engine.BreinEngineType; + +/** + * An example full-screen activity that shows and hides the system UI (i.e. + * status bar and navigation/system bar) with user interaction. + */ +public class FullscreenActivity extends AppCompatActivity { + + /** + * BASE URL + */ + private static final String BASE_URL = "https://api.breinify.com"; + + /** + * This has to be a valid api key + */ + private static final String VALID_API_KEY = "772A-47D7-93A3-4EA9-9D73-85B9-479B-16C6"; + private static final String VALID_SIGNATURE_API_KEY = "CA8A-8D28-3408-45A8-8E20-8474-06C0-8548"; + + /** + * Whether or not the system UI should be auto-hidden after + * {@link #AUTO_HIDE_DELAY_MILLIS} milliseconds. + */ + private static final boolean AUTO_HIDE = true; + + /** + * If {@link #AUTO_HIDE} is set, the number of milliseconds to wait after + * user interaction before hiding the system UI. + */ + private static final int AUTO_HIDE_DELAY_MILLIS = 3000; + + /** + * Some older devices needs a small delay between UI widget updates + * and a change of the status and navigation bar. + */ + private static final int UI_ANIMATION_DELAY = 300; + private final Handler mHideHandler = new Handler(); + private View mContentView; + private final Runnable mHidePart2Runnable = new Runnable() { + @SuppressLint("InlinedApi") + @Override + public void run() { + // Delayed removal of status and navigation bar + + // Note that some of these constants are new as of API 16 (Jelly Bean) + // and API 19 (KitKat). It is safe to use them, as they are inlined + // at compile-time and do nothing on earlier devices. + mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); + } + }; + private View mControlsView; + private final Runnable mShowPart2Runnable = new Runnable() { + @Override + public void run() { + // Delayed display of UI elements + ActionBar actionBar = getSupportActionBar(); + if (actionBar != null) { + actionBar.show(); + } + mControlsView.setVisibility(View.VISIBLE); + } + }; + private boolean mVisible; + private final Runnable mHideRunnable = new Runnable() { + @Override + public void run() { + hide(); + } + }; + /** + * Touch listener to use for in-layout UI controls to delay hiding the + * system UI. This is to prevent the jarring behavior of controls going away + * while interacting with activity UI. + */ + private final View.OnTouchListener mDelayHideTouchListener = new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + if (AUTO_HIDE) { + delayedHide(AUTO_HIDE_DELAY_MILLIS); + } + return false; + } + }; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.activity_fullscreen); + + mVisible = true; + mControlsView = findViewById(R.id.fullscreen_content_controls); + mContentView = findViewById(R.id.fullscreen_content); + + + // Set up the user interaction to manually show or hide the system UI. + mContentView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + toggle(); + } + }); + + // Upon interacting with UI controls, delay any scheduled hide() + // operations to prevent the jarring behavior of controls going away + // while interacting with the UI. + findViewById(R.id.dummy_button).setOnTouchListener(mDelayHideTouchListener); + + // configure the Breinify API + configure(); + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); + + // Trigger the initial hide() shortly after the activity has been + // created, to briefly hint to the user that UI controls + // are available. + delayedHide(100); + + // test call + testLogin(); + } + + private void toggle() { + if (mVisible) { + hide(); + } else { + show(); + } + } + + private void hide() { + // Hide UI first + ActionBar actionBar = getSupportActionBar(); + if (actionBar != null) { + actionBar.hide(); + } + mControlsView.setVisibility(View.GONE); + mVisible = false; + + // Schedule a runnable to remove the status and navigation bar after a delay + mHideHandler.removeCallbacks(mShowPart2Runnable); + mHideHandler.postDelayed(mHidePart2Runnable, UI_ANIMATION_DELAY); + } + + @SuppressLint("InlinedApi") + private void show() { + // Show the system bar + mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); + mVisible = true; + + // Schedule a runnable to display UI elements after a delay + mHideHandler.removeCallbacks(mHidePart2Runnable); + mHideHandler.postDelayed(mShowPart2Runnable, UI_ANIMATION_DELAY); + } + + /** + * Schedules a call to hide() in [delay] milliseconds, canceling any + * previously scheduled calls. + */ + private void delayedHide(int delayMillis) { + mHideHandler.removeCallbacks(mHideRunnable); + mHideHandler.postDelayed(mHideRunnable, delayMillis); + } + + /** + * configuration for Breinify REST call + */ + private void configure() { + + final BreinConfig breinConfig = new BreinConfig(VALID_API_KEY, + BASE_URL, + BreinEngineType.HTTP_URL_CONNECTION_ENGINE); + + Breinify.setConfig(breinConfig); + } + + private void testLogin() { + + final BreinUser breinUser = new BreinUser("User.Name@email.com") + .setFirstName("User") + .setLastName("Name") + .setReferrer("chacka"); + + /** + * Contains the Category + */ + final String breinCategoryType = BreinCategoryType.HOME; + + /** + * Contains the BreinActivityType + */ + final String breinActivityType = BreinActivityType.LOGIN; + + Breinify.activity(breinUser, + breinActivityType, + breinCategoryType, + "Login-Description", + false); + + + } +} diff --git a/app/src/main/res/layout/activity_fullscreen.xml b/app/src/main/res/layout/activity_fullscreen.xml new file mode 100644 index 0000000..a4a3dfc --- /dev/null +++ b/app/src/main/res/layout/activity_fullscreen.xml @@ -0,0 +1,50 @@ + + + + + + + + + + +