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.2.2'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
#	docs/installation.md
#	sample/build.gradle
  • Loading branch information
catt-stefano committed Sep 25, 2017
2 parents 5e29f8a + 39730b6 commit 4132849
Show file tree
Hide file tree
Showing 28 changed files with 330 additions and 162 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ env:
android:
components:
- tools # see https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943)
- build-tools-25.0.2
- platform-tools
- android-25
- build-tools-26.0.1
- tools
- android-26
- extra-google-m2repository
- extra-android-m2repository
- sys-img-armeabi-v7a-android-21
Expand Down
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ Once the settings are configured, **everyone** - even people without technical s

**NearIT SDK** synchronize with servers and behave accordingly to the settings and the recipes. Any content will be delivered at the right time, you just need to handle its presentation.

## Features
* User Segmentation
* Beacon monitoring and ranging
* Geofence monitoring
* Notifications and in-app content
* Analytics

## Installation

Minimum Requirements:
Expand All @@ -37,7 +30,7 @@ To start using the SDK, include this in your app *build.gradle*

```java
dependencies {
compile 'it.near.sdk:nearit:2.2.1'
compile 'it.near.sdk:nearit:2.2.2'
}
```

Expand All @@ -55,7 +48,6 @@ In your app, you can access the NearItManager instance with
NearItManager.getInstance()
```


## Integration guide

For information on how to integrate all NearIT features in your app, follow the [integration guide](http://nearit-android.readthedocs.io/en/latest/?badge=latest)
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath "com.github.dcendents:android-maven-gradle-plugin:1.4.1"
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.google.gms:google-services:3.1.0'


// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -19,6 +19,7 @@ allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
}
}

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:nearit:2.2.1'
compile 'it.near.sdk:nearit:2.2.2'
}
```
In AndroidManifest.xml, add the following element as a child of the `<application>` element, by inserting it just before the closing `</application>` tag:
Expand Down
4 changes: 2 additions & 2 deletions docs/location-based-notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ To learn how to deal with in-app content once the user taps on the notification,
If you want to customize your notifications, see this [section](custom-bkg-notification.md).

___
**WARNING**: If you experience build or runtime problems with google play services components, make sure to include the 10.2.0 version of any gms dependency in your app. Example:
**WARNING**: If you experience build or runtime problems with google play services components, make sure to include the 11.4.0 version of any gms dependency in your app. Example:
```xml
compile 'com.google.android.gms:play-services-analytics:10.2.0'
compile 'com.google.android.gms:play-services-analytics:11.4.0'
```
Conflicting play services version may result in compile-time and run-time errors.
4 changes: 2 additions & 2 deletions docs/push-notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ If you want to customize your notifications, see this [section](custom-bkg-notif


___
**WARNING**: If you experience build or runtime problems with google play services components, make sure to include the 10.2.0 version of any gms dependency in your app. Example:
**WARNING**: If you experience build or runtime problems with google play services components, make sure to include the 11.4.0 version of any gms dependency in your app. Example:
```xml
compile 'com.google.android.gms:play-services-analytics:10.2.0'
compile 'com.google.android.gms:play-services-analytics:11.4.0'
```
Conflicting play services version may result in compile-time and run-time errors.
24 changes: 12 additions & 12 deletions nearit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
jcenter()
flatDir{
flatDir {
dirs 'libs'
}
}
Expand Down Expand Up @@ -64,9 +64,9 @@ def getLatestVersionName = {
}
}

def playServicesVersion = '10.2.0'
def playServicesVersion = '11.4.0'

allprojects{
allprojects {
version = "${getVersionName()}"
}

Expand All @@ -77,8 +77,8 @@ buildProperties {
}

android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
compileSdkVersion 26
buildToolsVersion '26.0.1'

defaultConfig {
minSdkVersion 15
Expand Down Expand Up @@ -122,26 +122,26 @@ bintray {

// Upload docs on ftp

repositories{
repositories {
mavenCentral()
}
configurations {
ftpAntTask
}
dependencies{
ftpAntTask ("org.apache.ant:ant-commons-net:1.8.4") {
dependencies {
ftpAntTask("org.apache.ant:ant-commons-net:1.8.4") {
module("commons-net:commons-net:1.4.1") {
dependencies "oro:oro:2.0.8:jar"
}
}
}

task injectVersionsInMarkdowns(type: Copy){
task injectVersionsInMarkdowns(type: Copy) {
duplicatesStrategy 'exclude'
from('docs/src') {
include '*'
filter{ it.replaceAll('@@versionNumber@@', "${getLatestVersionName()}")}
filter{ it.replaceAll('@@playServicesNumber@@', playServicesVersion)}
filter { it.replaceAll('@@versionNumber@@', "${getLatestVersionName()}") }
filter { it.replaceAll('@@playServicesNumber@@', playServicesVersion) }
}
into 'docs'
}
Expand All @@ -154,7 +154,7 @@ dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.google.code.gson:gson:2.8.0'
compile 'org.altbeacon:android-beacon-library:2.12.1'
compile 'org.altbeacon:android-beacon-library:2.12.2'
compile "com.google.firebase:firebase-messaging:${playServicesVersion}"
compile "com.google.firebase:firebase-core:${playServicesVersion}"
compile "com.google.android.gms:play-services-location:${playServicesVersion}"
Expand Down
11 changes: 3 additions & 8 deletions nearit/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,14 @@
<!-- Android system receivers -->
<receiver android:name=".geopolis.geofences.GeoFenceSystemEventsReceiver">
<intent-filter>
<action android:name="android.location.PROVIDERS_CHANGED" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>

<receiver
android:name=".trackings.BluetoothStatusReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
</intent-filter>
</receiver>

<receiver
android:name=".geopolis.geofences.LocationUpdatesReceiver"
android:exported="false" />
<!-- receiver for auto-tracking the ENGAGED status -->
<receiver
android:name=".recipes.background.AutoTrackingReceiver"
Expand Down
13 changes: 13 additions & 0 deletions nearit/src/main/java/it/near/sdk/NearItManager.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package it.near.sdk;

import android.app.Application;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.location.LocationManager;
import android.os.Handler;
import android.os.Looper;
import android.os.Parcelable;
Expand All @@ -24,6 +27,7 @@
import it.near.sdk.communication.NearInstallation;
import it.near.sdk.geopolis.GeopolisManager;
import it.near.sdk.geopolis.beacons.ranging.ProximityListener;
import it.near.sdk.geopolis.geofences.GeoFenceSystemEventsReceiver;
import it.near.sdk.logging.NearLog;
import it.near.sdk.operation.NearItUserProfile;
import it.near.sdk.operation.ProfileCreationListener;
Expand Down Expand Up @@ -55,6 +59,7 @@
import it.near.sdk.recipes.validation.CooldownValidator;
import it.near.sdk.recipes.validation.RecipeValidationFilter;
import it.near.sdk.recipes.validation.Validator;
import it.near.sdk.trackings.BluetoothStatusReceiver;
import it.near.sdk.trackings.TrackManager;
import it.near.sdk.trackings.TrackingInfo;
import it.near.sdk.utils.ApiKeyConfig;
Expand Down Expand Up @@ -119,6 +124,9 @@ public static NearItManager init(@NonNull Application application, @NonNull Stri
// first run: this is executed only after the setup.
// usually to inject the nearit manager instance in object that needs it, it couldn't been done inside the nearItManager constructor.
nearItManager.firstRun();

registerReceivers();

return nearItManager;
}

Expand Down Expand Up @@ -180,6 +188,11 @@ public void onProfileCreationError(String error) {
});
}

private static void registerReceivers() {
context.registerReceiver(new BluetoothStatusReceiver(), new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED));
context.registerReceiver(new GeoFenceSystemEventsReceiver(), new IntentFilter(LocationManager.PROVIDERS_CHANGED_ACTION));
}

private void plugInSetup(Context context, GlobalConfig globalConfig) {
RecipesHistory recipesHistory = new RecipesHistory(
RecipesHistory.getSharedPreferences(context),
Expand Down
2 changes: 2 additions & 0 deletions nearit/src/main/java/it/near/sdk/communication/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ interface Headers {
String version_header_key = "X-API-Version";

String near_version_header_key = "X-Near-Version";

String acceptLanguage = "Accept-Language";
}

// -------------------- PATHS --------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.json.JSONObject;

import java.io.UnsupportedEncodingException;
import java.util.Locale;

import cz.msebera.android.httpclient.Header;
import cz.msebera.android.httpclient.HttpEntity;
Expand All @@ -20,6 +21,7 @@
import cz.msebera.android.httpclient.message.BasicHeader;
import it.near.sdk.R;
import it.near.sdk.utils.ApiKeyConfig;
import it.near.sdk.utils.NearUtils;

/**
* @author cattaneostefano.
Expand Down Expand Up @@ -105,7 +107,8 @@ private static Header[] getHeaders(Context context) throws AuthenticationExcepti
new BasicHeader(Constants.Headers.contentType, Constants.Headers.jsonApiHeader),
new BasicHeader(Constants.Headers.accept, Constants.Headers.jsonApiHeader),
new BasicHeader(Constants.Headers.version_header_key, String.valueOf(it.near.sdk.BuildConfig.API_VERSION)),
new BasicHeader(Constants.Headers.near_version_header_key, String.valueOf(it.near.sdk.BuildConfig.NEAR_API_VERSION))
new BasicHeader(Constants.Headers.near_version_header_key, String.valueOf(it.near.sdk.BuildConfig.NEAR_API_VERSION)),
new BasicHeader(Constants.Headers.acceptLanguage, NearUtils.toBcp47Language(Locale.getDefault()))
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import org.json.JSONException;

import java.util.HashMap;
import java.util.Locale;

import it.near.sdk.GlobalConfig;
import it.near.sdk.logging.NearLog;
import it.near.sdk.utils.NearJsonAPIUtils;
import it.near.sdk.utils.NearUtils;

/**
* Class with static method to register an app installation to our Near APIs.
Expand All @@ -35,6 +37,7 @@ public class NearInstallation {
private static final String LOCATION = "location";
private static final String TAG = "NearInstallation";
private static final String PROFILE_ID = "profile_id";
private static final String LANG = "lang";

private NearInstallationRequestQueue requestQueue;
private Context context;
Expand Down Expand Up @@ -84,9 +87,15 @@ private String getInstallationBody(Context context, GlobalConfig globalConfig, S
attributeMap.put(BLUETOOTH, getBluetoothStatus());
// Set location permission
attributeMap.put(LOCATION, getLocationPermissionStatus(context));
// Set language
attributeMap.put(LANG, getDeviceLanguage());
return NearJsonAPIUtils.toJsonAPI(INSTALLATION_RES_TYPE, id, attributeMap);
}

private String getDeviceLanguage() {
return NearUtils.toBcp47Language(Locale.getDefault());
}

private static boolean getLocationPermissionStatus(Context context) {
return ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION)
== PackageManager.PERMISSION_GRANTED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

Expand Down Expand Up @@ -298,5 +296,6 @@ private void setRadarState(boolean b) {

public void initLifecycle(Application application) {
altBeaconMonitor.initAppLifecycleMonitor(application);
geofenceMonitor.initAppLifecycleMonitor(application);
}
}
Loading

0 comments on commit 4132849

Please sign in to comment.