Skip to content

Commit

Permalink
Merge pull request #155 from apptentive/branch_5.1.0
Browse files Browse the repository at this point in the history
Release 5.1.0
  • Loading branch information
weeeBox authored May 1, 2018
2 parents 321acac + 60ad9bb commit e0d3d0e
Show file tree
Hide file tree
Showing 153 changed files with 4,233 additions and 1,848 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ android:
- tools
- platform-tools
- tools # not a mistakenly duplicated line: used above api 25.x
- build-tools-26.0.3
- build-tools-27.0.3
- android-19
- android-26
- android-27
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
- addon-google_apis-google-26
- sys-img-armeabi-v7a-android-19
before_install:
- yes | sdkmanager "platforms;android-27"
install: true
before_script:
- echo no | android create avd --force -n test -t android-19 --abi armeabi-v7a
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# 2018-05-01 - v5.1.0

#### Major changes

* Added support for notification-based interactions.

#### Improvements

* Better logging for interaction criteria evaluation.
* Better troubleshooting support.

# 2018-04-19 - v5.0.5

#### Bugs Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use your app, to talk to them at the right time, and in the right way.

##### [Release Notes](https://learn.apptentive.com/knowledge-base/android-sdk-release-notes/)

##### Binary releases are hosted for Maven [here](http://search.maven.org/#artifactdetails|com.apptentive|apptentive-android|5.0.5|aar)
##### Binary releases are hosted for Maven [here](http://search.maven.org/#artifactdetails|com.apptentive|apptentive-android|5.1.0|aar)

#### Reporting Bugs

Expand Down
4 changes: 2 additions & 2 deletions apptentive/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ dependencies {
}

android {
compileSdkVersion 26
buildToolsVersion '26.0.3'
compileSdkVersion 27
buildToolsVersion '27.0.3'

defaultConfig {
minSdkVersion 14
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (c) 2018, Apptentive, Inc. All Rights Reserved.
* Please refer to the LICENSE file for the terms and conditions
* under which redistribution and use of this file is permitted.
*/

package com.apptentive.android.sdk;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.test.RenamingDelegatingContext;

public class InstrumentationTestCaseBase extends TestCaseBase {
protected Context getContext() {
return new RenamingDelegatingContext(InstrumentationRegistry.getTargetContext(), "test_");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class FileMessageStoreTest extends TestCaseBase {
public TemporaryFolder tempFolder = new TemporaryFolder();

@Before
public void setUp() {
public void setUp() throws Exception {
super.setUp();
ApptentiveInternal.setInstance(new ApptentiveInternal(InstrumentationRegistry.getTargetContext()));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright (c) 2016, Apptentive, Inc. All Rights Reserved.
* Please refer to the LICENSE file for the terms and conditions
* under which redistribution and use of this file is permitted.
*/

package com.apptentive.android.sdk.module.engagement;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.test.runner.AndroidJUnit4;

import com.apptentive.android.sdk.InstrumentationTestCaseBase;
import com.apptentive.android.sdk.module.engagement.interaction.model.Interaction;
import com.apptentive.android.sdk.module.engagement.interaction.model.Interaction.DisplayType;
import com.apptentive.android.sdk.module.engagement.interaction.model.TextModalInteraction;
import com.apptentive.android.sdk.util.RuntimeUtils;

import org.json.JSONException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import static junit.framework.Assert.assertEquals;

@RunWith(AndroidJUnit4.class)
public class InteractionLauncherTest extends InstrumentationTestCaseBase {

@Before
@Override
public void setUp() throws Exception {
super.setUp();

RuntimeUtils.overrideStaticFinalField(EngagementModule.class, "LAUNCHER_FACTORY", new DefaultInteractionLauncherFactory() {
@NonNull
@Override
protected InteractionLauncher createActivityInteractionLauncher() {
return new MockInteractionLauncher("Activity");
}

@NonNull
@Override
protected InteractionLauncher createNotificationInteractionLauncher() {
return new MockInteractionLauncher("Notification");
}
});

// Everything should run immediately
overrideMainQueue(true);
}

@Test
public void testInteractionDefaultDisplayType() throws JSONException {
Interaction interaction = new TextModalInteraction("{\"type\":\"TextModal\"}");
assertEquals(interaction.getDisplayType(), DisplayType.unknown);
EngagementModule.launchInteraction(getContext(), interaction);
assertResult("Activity");
}

@Test
public void testInteractionNotificationDisplayType() throws JSONException {
Interaction interaction = new TextModalInteraction("{\"type\":\"TextModal\",\"display_type\":\"notification\"}");
assertEquals(interaction.getDisplayType(), DisplayType.notification);
EngagementModule.launchInteraction(getContext(), interaction);
assertResult("Notification");
}

@Test
public void testInteractionUnknownDisplayType() throws JSONException {
Interaction interaction = new TextModalInteraction("{\"type\":\"TextModal\",\"display_Type\":\"unknown\"}");
assertEquals(interaction.getDisplayType(), DisplayType.unknown);
EngagementModule.launchInteraction(getContext(), interaction);
assertResult("Activity");
}

class MockInteractionLauncher implements InteractionLauncher {
private final String name;

MockInteractionLauncher(String name) {
this.name = name;
}

@Override
public boolean launch(Context context, Interaction interaction) {
addResult(name);
return true;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2016, Apptentive, Inc. All Rights Reserved.
* Please refer to the LICENSE file for the terms and conditions
* under which redistribution and use of this file is permitted.
*/

package com.apptentive.android.sdk.module.engagement;

import android.content.Context;
import android.content.Intent;
import android.support.test.runner.AndroidJUnit4;

import com.apptentive.android.sdk.InstrumentationTestCaseBase;
import com.apptentive.android.sdk.module.engagement.interaction.model.Interaction;
import com.apptentive.android.sdk.module.engagement.interaction.model.TextModalInteraction;
import com.apptentive.android.sdk.module.engagement.notification.ApptentiveNotificationInteractionBroadcastReceiver;
import com.apptentive.android.sdk.module.engagement.notification.DefaultInteractionNotificationBroadcastReceiverHandler;
import com.apptentive.android.sdk.util.Constants;
import com.apptentive.android.sdk.util.RuntimeUtils;

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

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;

@RunWith(AndroidJUnit4.class)
public class InteractionNotificationBroadcastReceiverHandlerTest extends InstrumentationTestCaseBase {

@Test
public void testNoteNotification() throws Exception {
final String interactionDefinition = "{\"type\":\"TextModal\",\"name\":\"TextModal Interaction displayed as Notification\",\"id\":\"textmodal_interaction_notification\",\"displayType\":\"Notification\",\"priority\":1,\"configuration\":{\"title\":\"Note Title\",\"body\":\"Note body\",\"actions\":[{\"id\":\"action_id_1\",\"label\":\"Dismiss\",\"action\":\"dismiss\"},{\"id\":\"action_id_2\",\"label\":\"Dismiss\",\"action\":\"dismiss\"}]}}";
Interaction interaction = new TextModalInteraction(interactionDefinition);

RuntimeUtils.overrideStaticFinalField(ApptentiveNotificationInteractionBroadcastReceiver.class, "DEFAULT_HANDLER", new DefaultInteractionNotificationBroadcastReceiverHandler() {
@Override
public void handleBroadcast(Context context, Intent intent) {
assertNotNull(intent);
assertEquals(Constants.NOTIFICATION_ACTION_DISPLAY, intent.getAction());
assertEquals(interactionDefinition, intent.getStringExtra(Constants.NOTIFICATION_EXTRA_INTERACTION_DEFINITION));
}
});
EngagementModule.launchInteraction(getContext(), interaction);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2016, Apptentive, Inc. All Rights Reserved.
* Please refer to the LICENSE file for the terms and conditions
* under which redistribution and use of this file is permitted.
*/

package com.apptentive.android.sdk.module.engagement;

import android.content.Context;
import android.support.test.runner.AndroidJUnit4;

import com.apptentive.android.sdk.InstrumentationTestCaseBase;
import com.apptentive.android.sdk.module.engagement.interaction.model.Interaction;
import com.apptentive.android.sdk.module.engagement.interaction.model.TextModalInteraction;
import com.apptentive.android.sdk.module.engagement.notification.DefaultInteractionNotificationBroadcastReceiverHandler;
import com.apptentive.android.sdk.module.engagement.notification.NoteInteractionNotificationAdapter;
import com.apptentive.android.sdk.util.RuntimeUtils;

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

import static com.apptentive.android.sdk.util.Constants.NOTIFICATION_CHANNEL_DEFAULT;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

@RunWith(AndroidJUnit4.class)
public class NoteInteractionNotificationAdapterTest extends InstrumentationTestCaseBase {

@Test
public void testNoteNotificationDisplay() throws Exception {
final String interactionDefinition = "{\"type\":\"TextModal\",\"name\":\"TextModal Interaction displayed as Notification\",\"id\":\"textmodal_interaction_notification\",\"display_type\":\"notification\",\"priority\":1,\"configuration\":{\"title\":\"Note Title\",\"body\":\"Note body\",\"actions\":[{\"id\":\"action_id_1\",\"label\":\"Dismiss\",\"action\":\"dismiss\"},{\"id\":\"action_id_2\",\"label\":\"Dismiss\",\"action\":\"dismiss\"}]}}";
Interaction interaction = new TextModalInteraction(interactionDefinition);

RuntimeUtils.overrideStaticFinalField(DefaultInteractionNotificationBroadcastReceiverHandler.class, "DEFAULT_ADAPTER_NOTE", new NoteInteractionNotificationAdapter() {
@Override
protected void actionDisplayNotification(Context context, String channelId, TextModalInteraction interaction) {
assertNotNull(context);
assertEquals(NOTIFICATION_CHANNEL_DEFAULT, channelId);
assertNotNull(interaction);
assertEquals(Interaction.Type.TextModal, interaction.getType());
assertEquals("Note Title", interaction.getTitle());
assertEquals("Note body", interaction.getBody());
}
});
EngagementModule.launchInteraction(getContext(), interaction);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class HttpRequestManagerTest extends TestCaseBase {
private MockDispatchQueue networkQueue;

@Before
public void setUp() {
public void setUp() throws Exception {
super.setUp();

networkQueue = new MockDispatchQueue(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ConcurrentDispatchQueueTest extends TestCaseBase {
private DispatchQueue dispatchQueue;

@Before
public void setUp() {
public void setUp() throws Exception {
super.setUp();
dispatchQueue = DispatchQueue.createBackgroundQueue("Test Queue", DispatchQueueType.Concurrent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class SerialDispatchQueueTest extends TestCaseBase {
private DispatchQueue dispatchQueue;

@Before
public void setUp() {
public void setUp() throws Exception {
super.setUp();
dispatchQueue = DispatchQueue.createBackgroundQueue("Test Queue", DispatchQueueType.Serial);
}
Expand Down
2 changes: 2 additions & 0 deletions apptentive/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@
android:enabled="true"
android:exported="false"/>

<receiver android:name=".module.engagement.notification.ApptentiveNotificationInteractionBroadcastReceiver"
android:exported="false"/>
</application>
</manifest>
Loading

0 comments on commit e0d3d0e

Please sign in to comment.