Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release/2.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
catt-stefano committed Mar 7, 2017
2 parents 5faa64b + 0f3769d commit 01ab6e6
Show file tree
Hide file tree
Showing 66 changed files with 1,890 additions and 733 deletions.
27 changes: 22 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,16 @@ def getLatestVersionName = {
commandLine 'git', 'describe', '--tags', '--abbrev=0'
standardOutput = stdout
}
return stdout.toString().trim()
def versionFromTag = stdout.toString().trim()
stdout.reset()
exec {
commandLine 'git', 'describe', '--contains', '--all', 'HEAD'
standardOutput = stdout
}
def branchName = stdout.toString()
def versionFromReleaseBranch = branchName.substring(branchName.indexOf('/') + 1).trim()
return versionFromTag == versionFromReleaseBranch ? versionFromTag : versionFromReleaseBranch
// return branchName
}
catch (e) {
printl("Can't get version from git: " + e);
Expand All @@ -53,11 +62,12 @@ android {
versionName version
buildConfigField("int", "API_VERSION", "2")
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
release {
minifyEnabled false
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
consumerProguardFiles 'proguard-rules.pro'
}
}
}
Expand Down Expand Up @@ -155,6 +165,7 @@ task uploadDocs {
}

task injectVersionsInMarkdowns(type: Copy){
duplicatesStrategy 'exclude'
from('docs/src') {
include '*'
filter{ it.replaceAll('@@versionNumber@@', "${getLatestVersionName()}")}
Expand All @@ -177,10 +188,16 @@ dependencies {
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:2.7.6"
testCompile "com.google.guava:guava:21.0"
testCompile 'org.hamcrest:hamcrest-core:1.3'
testCompile 'org.hamcrest:hamcrest-library:1.3'
testCompile 'org.json:json:20160212'
testCompile 'joda-time:joda-time:2.9.3'

androidTestCompile 'junit:junit:4.12'
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
androidTestCompile 'com.android.support.test:runner:0.5'
// using the latest java7-compatible guava version
androidTestCompile "com.google.guava:guava:20.0"

javadocDeps 'com.android.support:support-annotations:24.0.0'
javadocDeps 'org.altbeacon:android-beacon-library:2.9.2'

Expand All @@ -195,4 +212,4 @@ buildscript {
dirs 'libs'
}
}
}
}
4 changes: 2 additions & 2 deletions docs/custom-bkg-notification.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ protected void onHandleIntent(Intent intent) {
Since you are overriding the default notification mechanism, remember to track the recipe as notified with:
String recipeId = intent.getStringExtra(NearItIntentConstants.RECIPE_ID);
try {
Recipe.sendTracking(getApplicationContext(), recipeId, Recipe.NOTIFIED_STATUS);
RecipesManager.sendTracking(getApplicationContext(), recipeId, Recipe.NOTIFIED_STATUS);
} catch (JSONException e) {
e.printStackTrace();
}
There is an utility method to automatically process known content types to calls the CoreContentsListener callback methods.
Expand Down
1 change: 0 additions & 1 deletion docs/custom-receiver-sample.md

This file was deleted.

12 changes: 8 additions & 4 deletions docs/handle-content.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ NearIT analytics on recipes are built from trackings describing the status of us

Background recipes track themselves as notified. To track the tap event, use this method:
```java
Recipe.sendTracking(getApplicationContext(), recipeId, Recipe.ENGAGED_STATUS);
RecipesManager.sendTracking(getApplicationContext(), recipeId, Recipe.ENGAGED_STATUS);
```
You should be able to catch the event inside the activity that is started after interacting with the notification.

Foreground recipes don't have automatic tracking. You need to track both the "Notified" and the "Engaged" statuses when it's the best appropriate for you scenario.
```java
Recipe.sendTracking(getApplicationContext(), recipe.getId(), Recipe.NOTIFIED_STATUS);
RecipesManager.sendTracking(getApplicationContext(), recipe.getId(), Recipe.NOTIFIED_STATUS);
// and
Recipe.sendTracking(getApplicationContext(), recipe.getId(), Recipe.ENGAGED_STATUS);
RecipesManager.sendTracking(getApplicationContext(), recipe.getId(), Recipe.ENGAGED_STATUS);
```

## Content Objects
Expand All @@ -72,16 +72,20 @@ For each callback method of the *coreContentListener* you will receive a differe
- `getContent()` returns the text content
- `getVideo_link()` returns the video link string
- `getImages_links()` returns a list of *ImageSet* object containing the source links for the images
- `getUpload()` returns an Upload object containing a link to a file uploaded on NearIT if any
- `getAudio()` returns an Audio object containing a link to an audio file uploaded on NearIT if any

- `Feedback` with the following getters:
- `getQuestion()` returns the feedback request string
- `getRecipeId()` returns the recipeId associated with the feedback (you'll need it for answer it)
To give a feedback call this method:
```java
// rating must be an integer between 0 and 5, and you can set a comment string.
// rating must be an integer between 1 and 5, and you can set a comment string.
nearItManager.sendEvent(new FeedbackEvent(feedback, rating, "Awesome"));
// if you don't hold the feedback object use this constructor
nearItManager.sendEvent(new FeedbackEvent(feedbackId, rating, "Nice", recipeId));
// the sendEvent method is available in 2 variants: with or without explicit callback handler. Example:
nearItManager.sendEvent(new FeedbackEvent(...), responseHandler);
```

- `Coupon` with the following getters:
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ To start using the SDK, include this in your app *build.gradle*

```java
dependencies {
compile 'it.near.sdk.core:nearitsdk:2.0.9'
compile 'it.near.sdk.core:nearitsdk:2.1.0'
}
```

Expand Down
12 changes: 0 additions & 12 deletions docs/proguard-log.md → docs/logging.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
## Pro-Guard

If you are using pro-guard to minify your app, add this configuration in the *proguard-rules.pro* file for your app.
This will stop proguard from excluding NearIT SDK classes from your final artifact.
This is mandatory to minify the app and still be able to use the SDK.

```
-dontwarn it.near.sdk.**
-keep class it.near.sdk.** { *; }
-keep interface it.near.sdk.** { *; }
```

## Logging

If you are scanning beacons you have probably noticed the flood of logging messages, with either the `ScanRecord` or the `BluetoothLeScanner` tag. Those logs are created by the operating system and are due to always appear when doing BLE scans. To stop them from appearing in the logcat stream, create a custom filter and filter the two tags with a regex. Here is a screenshot of our filter.
Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ pages:
- 'Integration Samples' : 'integration-samples.md'
- 'Best Practice on Permissions Request' : 'permission-request-sample.md'
- 'Other resources' :
- 'Pro-Guard & Logging' : 'proguard-log.md'
- 'Logging' : 'logging.md'
- 'Firebase Help' : 'firebase.md'
20 changes: 3 additions & 17 deletions proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/cattaneostefano/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 *;
#}
-dontwarn it.near.sdk.**
-keep class it.near.sdk.** { *; }
-keep interface it.near.sdk.** { *; }
41 changes: 41 additions & 0 deletions src/androidTest/java/it/near/sdk/Reaction/Content/AudioTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package it.near.sdk.Reaction.Content;

import android.os.Parcel;
import android.support.test.runner.AndroidJUnit4;

import com.google.common.collect.Maps;

import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.HashMap;

import it.near.sdk.Reactions.Content.Audio;

import static junit.framework.Assert.*;

/**
* Created by cattaneostefano on 02/03/2017.
*/

@RunWith(AndroidJUnit4.class)
public class AudioTest {

@Test
public void audioIsParcelable() {
Audio audio = new Audio();
HashMap<String, Object> map = Maps.newHashMap();
String audioUrl = "http://jsnfijegfuien.mp3";
map.put("url", audioUrl);
audio.setAudio(map);
audio.setId("audio_id");
Parcel parcel = Parcel.obtain();
audio.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
Audio actual = Audio.CREATOR.createFromParcel(parcel);
assertEquals(audio.getAudio(), actual.getAudio());
assertEquals(audioUrl, actual.getUrl());
assertEquals(audio.getId(), actual.getId());
}

}
63 changes: 63 additions & 0 deletions src/androidTest/java/it/near/sdk/Reaction/Content/ContentTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package it.near.sdk.Reaction.Content;

import android.os.Parcel;
import android.support.test.runner.AndroidJUnit4;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.HashMap;
import java.util.Map;

import it.near.sdk.Reactions.Content.Audio;
import it.near.sdk.Reactions.Content.Content;
import it.near.sdk.Reactions.Content.Image;
import it.near.sdk.Reactions.Content.ImageSet;
import it.near.sdk.Reactions.Content.Upload;

import static junit.framework.Assert.*;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.assertThat;

/**
* Created by cattaneostefano on 28/02/2017.
*/

@RunWith(AndroidJUnit4.class)
public class ContentTest {

@Test
public void contentIsParcelable() {
Content content = new Content();
content.setContent("content");
content.setImages_links(Lists.newArrayList(new ImageSet(), new ImageSet()));
content.setVideo_link("video_link");
content.setId("content_id");
content.setUpdated_at("updated@whatever");
Audio audio = new Audio();
HashMap<String, Object> audioMap = Maps.newHashMap();
audioMap.put("url", "a.mp3");
audio.setAudio(audioMap);
content.setAudio(audio);
Upload upload = new Upload();
HashMap<String, Object> uploadMap = Maps.newHashMap();
uploadMap.put("url", "a.pdf");
upload.setUpload(uploadMap);
content.setUpload(upload);
Parcel parcel = Parcel.obtain();
content.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
Content actual = Content.CREATOR.createFromParcel(parcel);
assertEquals(content.getContent(), actual.getContent());
assertThat(content.getImages_links(), containsInAnyOrder(actual.getImages_links().toArray()));
assertEquals(content.getVideo_link(), actual.getVideo_link());
assertEquals(content.getId(), actual.getId());
assertEquals(content.getUpdated_at(), actual.getUpdated_at());
assertEquals(content.getAudio().getAudio(), actual.getAudio().getAudio());
assertEquals(content.getUpload().getUpload(), actual.getUpload().getUpload());
}

}
40 changes: 40 additions & 0 deletions src/androidTest/java/it/near/sdk/Reaction/Content/UploadTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package it.near.sdk.Reaction.Content;

import android.os.Parcel;
import android.support.test.runner.AndroidJUnit4;

import com.google.common.collect.Maps;

import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.HashMap;

import it.near.sdk.Reactions.Content.Upload;

import static junit.framework.Assert.*;

/**
* Created by cattaneostefano on 02/03/2017.
*/

@RunWith(AndroidJUnit4.class)
public class UploadTest {

@Test
public void uploadIsParcelable() {
Upload upload = new Upload();
upload.setId("upload_id");
HashMap<String, Object> map = Maps.newHashMap();
String pdfUrl = "http://jsnfijegfuien.pdf";
map.put("url", pdfUrl);
upload.setUpload(map);
Parcel parcel = Parcel.obtain();
upload.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
Upload actual = Upload.CREATOR.createFromParcel(parcel);
assertEquals(upload.getId(), actual.getId());
assertEquals(upload.getUpload(), actual.getUpload());
assertEquals(pdfUrl, actual.getUrl());
}
}
55 changes: 55 additions & 0 deletions src/androidTest/java/it/near/sdk/Reaction/Coupon/CouponTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package it.near.sdk.Reaction.Coupon;

import android.os.Parcel;
import android.support.test.runner.AndroidJUnit4;

import com.google.common.collect.Lists;

import org.junit.Test;
import org.junit.runner.RunWith;

import it.near.sdk.Reactions.Content.Content;
import it.near.sdk.Reactions.Content.ImageSet;
import it.near.sdk.Reactions.Coupon.Claim;
import it.near.sdk.Reactions.Coupon.Coupon;

import static junit.framework.Assert.*;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.assertThat;

/**
* Created by cattaneostefano on 28/02/2017.
*/

@RunWith(AndroidJUnit4.class)
public class CouponTest {

@Test
public void couponIsParcelable() {
Coupon coupon = new Coupon();
coupon.setId("coupon_id");
coupon.setName("coupon_name");
coupon.setDescription("coupon_description");
coupon.setValue("coupon_value");
coupon.setExpires_at("expiring_soon");
coupon.setIcon_id("coupon_icon_id");
coupon.setClaims(Lists.newArrayList(new Claim(), new Claim()));
coupon.setIconSet(new ImageSet());

Parcel parcel = Parcel.obtain();
coupon.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
Coupon actual = Coupon.CREATOR.createFromParcel(parcel);

assertEquals(coupon.getId(), actual.getId());
assertEquals(coupon.getName(), actual.getName());
assertEquals(coupon.getDescription(), actual.getDescription());
assertEquals(coupon.getValue(), actual.getValue());
assertEquals(coupon.getExpires_at(), actual.getExpires_at());
assertEquals(coupon.getIcon_id(), actual.getIcon_id());
assertThat(coupon.getClaims(), containsInAnyOrder(actual.getClaims().toArray()));
assertEquals(coupon.getIconSet(), actual.getIconSet());

}

}
Loading

0 comments on commit 01ab6e6

Please sign in to comment.