Skip to content

Commit

Permalink
Merge pull request #135 from apptentive/branch_4.1.0
Browse files Browse the repository at this point in the history
Release 4.1.0
  • Loading branch information
weeeBox authored Nov 7, 2017
2 parents bbd011b + 0ebc76d commit b20a316
Show file tree
Hide file tree
Showing 237 changed files with 3,136 additions and 1,942 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ gen/
out/
bin/
build/
captures/

# IntelliJ
*.iws
Expand All @@ -29,4 +30,4 @@ projectFilesBackup/

# Eclipse
.settings
.metadata
.metadata
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

20 changes: 15 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: android
dist: precise
env:
global:
- SNAPSHOT_REPOSITORY_USERNAME=travis
Expand All @@ -16,29 +17,38 @@ cache:
- $HOME/.android/build-cache
android:
components:
- tools
- tools
- platform-tools
- build-tools-25.0.3
- tools # not a mistakenly duplicated line: used above api 25.x
- build-tools-26.0.2
- android-19
- android-24
- android-25
- android-26
- extra-google-google_play_services
- extra-google-m2repository
- addon-google_apis-google-25
- extra-android-m2repository
- addon-google_apis-google-26
- sys-img-armeabi-v7a-android-19
install: true
before_script:
- echo no | android create avd --force -n test -t android-19 --abi armeabi-v7a
- emulator -avd test -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
#- adb -e logcat *:W | tee logcat.log > /dev/null 2>&1 &
script:
- ./gradlew :apptentive:test -i
- ./gradlew :test-app:connectedAndroidTest
# - if [ -d "apptentive-internal-app" ]; then ./gradlew :apptentive-internal-app:installAutomatedDebug; fi
# - if [ -d "apptentive-internal-app" ]; then ./gradlew :apptentive-internal-app:installAutomatedDebugAndroidTest; fi
# - if [ -d "apptentive-internal-app" ]; then ./gradlew :apptentive-internal-app:connectedAutomatedDebugAndroidTest -i; fi
- if [ -d "apptentive-internal-app" ]; then ./gradlew :apptentive-internal-app:assembleQaDebug; fi
after_script:
- if [ "$TRAVIS_BRANCH" = "develop" ]; then
./gradlew :apptentive:uploadArchives;
if [ -d "apptentive-internal-app" ]; then ./gradlew :apptentive-internal-app:uploadQaDebugToHockeyApp; fi;
fi
after_failure:
#- echo " LOGCAT "; echo "========"; cat logcat.log; pkill -KILL -f adb
notifications:
slack:
secure: HejMl0EUociwGu+5djx95snbS+m/Yw8DseQKCSqeyWvMQLrAy8bi9oa89mZvXnvjqSVY3kKRZgJncEkQdIe9c7xwgNA9QYLkc7UVbXqga291HMoNnWaIMewD2ervbzM4aBQAHnkDr+GsXgb7+1YdOktIn8dA7jdIuB90ar4So9U=
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# 2017-11-06 - v4.1.0

#### Improvements

* Improved accessibility of Surveys and Message center for the visually impaired
* Made use of vector drawables to cut down on AAR and APK size
* Added the ability to enable troubleshooting mode in the SDK, and easily email logs to Apptentive support

#### Bugs Fixed

* Fix global configuration fetching
* Fix Love Dialog to stack buttons if their labels are too long

# 2017-08-15 - v4.0.2

#### 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|4.0.2|aar)
##### Binary releases are hosted for Maven [here](http://search.maven.org/#artifactdetails|com.apptentive|apptentive-android|4.1.0|aar)

#### Reporting Bugs

Expand Down
16 changes: 9 additions & 7 deletions apptentive/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ init()
apply plugin: 'com.android.library'

dependencies {
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
testCompile 'junit:junit:4.12'
testCompile "org.powermock:powermock-module-junit4:1.6.2"
testCompile "org.powermock:powermock-module-junit4-rule:1.6.2"
testCompile "org.powermock:powermock-api-mockito:1.6.2"
testCompile "org.powermock:powermock-classloading-xstream:1.6.2"

// Required for instrumented tests
androidTestCompile 'com.android.support:support-annotations:24.2.1'
androidTestCompile 'com.android.support:support-annotations:26.1.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
}

android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
compileSdkVersion 26
buildToolsVersion '26.0.2'

defaultConfig {
minSdkVersion 14
Expand All @@ -31,6 +31,8 @@ android {
versionName project.version
consumerProguardFiles 'consumer-proguard-rules.pro'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
resValue "string", "apptentive_distribution_version", versionName
vectorDrawables.useSupportLibrary = true
}

lintOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

package com.apptentive.android.sdk.conversation;

import android.support.test.InstrumentationRegistry;

import com.apptentive.android.sdk.ApptentiveInternal;
import com.apptentive.android.sdk.ApptentiveInternalMock;
import com.apptentive.android.sdk.TestCaseBase;
import com.apptentive.android.sdk.model.ApptentiveMessage;
import com.apptentive.android.sdk.model.CompoundMessage;
Expand Down Expand Up @@ -40,7 +41,7 @@ public class FileMessageStoreTest extends TestCaseBase {
@Before
public void setUp() {
super.setUp();
ApptentiveInternal.setInstance(new ApptentiveInternalMock());
ApptentiveInternal.setInstance(new ApptentiveInternal(InstrumentationRegistry.getTargetContext()));
}

@After
Expand Down
9 changes: 9 additions & 0 deletions apptentive/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application>
<provider android:name=".debug.AttachmentFileProvider"
android:authorities="com.apptentive.android.sdk.debug.AttachmentFileProvider"
android:enabled="true"
android:exported="true"
android:grantUriPermissions="true"/>
<activity android:name="com.apptentive.android.sdk.ApptentiveViewActivity"
android:theme="@style/ApptentiveTheme.Base.Versioned"/>
<receiver android:name=".debug.LogBroadcastReceiver"
android:enabled="true"
android:exported="false"/>

</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.apptentive.android.sdk.comm.ApptentiveHttpClient;
import com.apptentive.android.sdk.conversation.Conversation;
import com.apptentive.android.sdk.conversation.ConversationManager;
import com.apptentive.android.sdk.debug.LogMonitor;
import com.apptentive.android.sdk.lifecycle.ApptentiveActivityLifecycleCallbacks;
import com.apptentive.android.sdk.model.Configuration;
import com.apptentive.android.sdk.model.EventPayload;
Expand Down Expand Up @@ -56,13 +57,12 @@
import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;

import static com.apptentive.android.sdk.ApptentiveLogTag.CONVERSATION;
Expand All @@ -74,10 +74,12 @@
import static com.apptentive.android.sdk.ApptentiveNotifications.NOTIFICATION_CONVERSATION_WILL_LOGOUT;
import static com.apptentive.android.sdk.ApptentiveNotifications.NOTIFICATION_INTERACTIONS_FETCHED;
import static com.apptentive.android.sdk.ApptentiveNotifications.NOTIFICATION_INTERACTIONS_SHOULD_DISMISS;
import static com.apptentive.android.sdk.ApptentiveNotifications.NOTIFICATION_INTERACTION_MANIFEST_FETCHED;
import static com.apptentive.android.sdk.ApptentiveNotifications.NOTIFICATION_KEY_ACTIVITY;
import static com.apptentive.android.sdk.ApptentiveNotifications.NOTIFICATION_KEY_AUTHENTICATION_FAILED_REASON;
import static com.apptentive.android.sdk.ApptentiveNotifications.NOTIFICATION_KEY_CONVERSATION;
import static com.apptentive.android.sdk.ApptentiveNotifications.NOTIFICATION_KEY_CONVERSATION_ID;
import static com.apptentive.android.sdk.ApptentiveNotifications.NOTIFICATION_KEY_MANIFEST;
import static com.apptentive.android.sdk.debug.Assert.assertNotNull;
import static com.apptentive.android.sdk.debug.Assert.assertTrue;
import static com.apptentive.android.sdk.util.Constants.CONVERSATIONS_DIR;
Expand All @@ -99,7 +101,6 @@ public class ApptentiveInternal implements ApptentiveNotificationObserver {
// We keep a readonly reference to AppRelease object since it won't change at runtime
private final AppRelease appRelease;

private boolean appIsInForeground;
private final SharedPreferences globalSharedPrefs;
private final String apptentiveKey;
private final String apptentiveSignature;
Expand Down Expand Up @@ -151,14 +152,14 @@ public static PushAction parse(String name) {
private static volatile ApptentiveInternal sApptentiveInternal;

// for unit testing
protected ApptentiveInternal() {
public ApptentiveInternal(Context appContext) {
taskManager = null;
globalSharedPrefs = null;
apptentiveKey = null;
apptentiveSignature = null;
apptentiveHttpClient = null;
conversationManager = null;
appContext = null;
this.appContext = appContext;
appRelease = null;
lifecycleCallbacks = null;
}
Expand Down Expand Up @@ -188,7 +189,8 @@ private ApptentiveInternal(Application application, String apptentiveKey, String
lifecycleCallbacks = new ApptentiveActivityLifecycleCallbacks();
ApptentiveNotificationCenter.defaultCenter()
.addObserver(NOTIFICATION_CONVERSATION_WILL_LOGOUT, this)
.addObserver(NOTIFICATION_AUTHENTICATION_FAILED, this);
.addObserver(NOTIFICATION_AUTHENTICATION_FAILED, this)
.addObserver(NOTIFICATION_INTERACTION_MANIFEST_FETCHED, this);
}

public static boolean isApptentiveRegistered() {
Expand Down Expand Up @@ -216,6 +218,9 @@ static void createInstance(Application application, String apptentiveKey, String
throw new IllegalArgumentException("Application is null");
}

// try initializing log monitor
LogMonitor.tryInitialize(application.getApplicationContext(), apptentiveKey, apptentiveSignature);

synchronized (ApptentiveInternal.class) {
if (sApptentiveInternal == null) {

Expand Down Expand Up @@ -440,14 +445,15 @@ public void onActivityResumed(Activity activity) {
}

public void onAppEnterForeground() {
appIsInForeground = true;

// Try to initialize log monitor
LogMonitor.tryInitialize(appContext, apptentiveKey, apptentiveSignature);

// Post a notification
ApptentiveNotificationCenter.defaultCenter().postNotification(NOTIFICATION_APP_ENTERED_FOREGROUND);
}

public void onAppEnterBackground() {
appIsInForeground = false;
currentTaskStackTopActivity = null;

// Post a notification
Expand Down Expand Up @@ -666,7 +672,7 @@ private void checkSendVersionChanges(Conversation conversation) {
conversation.getVersionHistory().updateVersionHistory(Util.currentTimeSeconds(), currentVersionCode, currentVersionName);
}

Sdk sdk = SdkManager.generateCurrentSdk();
Sdk sdk = SdkManager.generateCurrentSdk(appContext);
if (sdkChanged) {
ApptentiveLog.i("SDK version changed: %s => %s", lastSeenSdkVersion, currentSdkVersion);
conversation.setLastSeenSdkVersion(currentSdkVersion);
Expand Down Expand Up @@ -757,17 +763,6 @@ private void setMinimumLogLevel(ApptentiveLog.Level level) {
ApptentiveLog.overrideLogLevel(level);
}

private String pushCallbackActivityName;

public void setPushCallbackActivity(Class<? extends Activity> activity) {
pushCallbackActivityName = activity.getName();
ApptentiveLog.d("Setting push callback activity name to %s", pushCallbackActivityName);
}

public String getPushCallbackActivityName() {
return pushCallbackActivityName;
}

/**
* The key that is used to store extra data on an Apptentive push notification.
*/
Expand Down Expand Up @@ -851,6 +846,9 @@ public void showAboutInternal(Context context, boolean showBrandingBand) {
context.startActivity(intent);
}

/**
* TODO: Decouple this from Conversation and Message Manager so it can be unit tested.
*/
static PendingIntent generatePendingIntentFromApptentivePushData(String apptentivePushData) {
ApptentiveLog.d("Generating Apptentive push PendingIntent.");
if (!TextUtils.isEmpty(apptentivePushData)) {
Expand Down Expand Up @@ -1092,6 +1090,9 @@ public void onReceiveNotification(ApptentiveNotification notification) {
String conversationIdOfFailedRequest = notification.getUserInfo(NOTIFICATION_KEY_CONVERSATION_ID, String.class);
Apptentive.AuthenticationFailedReason authenticationFailedReason = notification.getUserInfo(NOTIFICATION_KEY_AUTHENTICATION_FAILED_REASON, Apptentive.AuthenticationFailedReason.class);
notifyAuthenticationFailedListener(authenticationFailedReason, conversationIdOfFailedRequest);
} else if (notification.hasName(NOTIFICATION_INTERACTION_MANIFEST_FETCHED)) {
String manifest = notification.getRequiredUserInfo(NOTIFICATION_KEY_MANIFEST, String.class);
storeManifestResponse(appContext, manifest);
}
}

Expand All @@ -1104,4 +1105,17 @@ private boolean engageInternal(Context context, String eventName) {
}

//endregion

//region Engagement Manifest Data

private void storeManifestResponse(Context context, String manifest) {
try {
File file = new File(context.getCacheDir(), Constants.FILE_APPTENTIVE_ENGAGEMENT_MANIFEST);
Util.writeText(file, manifest);
} catch (Exception e) {
ApptentiveLog.e(e, "Exception while trying to save engagement manifest data");
}
}

//endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public class ApptentiveLog {

private static Level logLevel = Level.DEFAULT;

public static Level getLogLevel() {
return logLevel;
}

public static void overrideLogLevel(Level level) {
ApptentiveLog.logLevel = level;
}
Expand Down Expand Up @@ -51,12 +55,16 @@ private static void doLog(Level level, ApptentiveLogTag tag, Throwable throwable
message = extra + " " + message;
}


//noinspection WrongConstant
android.util.Log.println(level.getAndroidLevel(), TAG, message);
if(throwable != null){
if(throwable.getMessage() != null){
//noinspection WrongConstant
android.util.Log.println(level.getAndroidLevel(), TAG, throwable.getMessage());
}
while(throwable != null) {
//noinspection WrongConstant
android.util.Log.println(level.getAndroidLevel(), TAG, android.util.Log.getStackTraceString(throwable));
throwable = throwable.getCause();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

public enum ApptentiveLogTag {
NETWORK(true),
APP_CONFIGURATION(true),
CONVERSATION(true),
NOTIFICATIONS(true),
MESSAGES(true),
Expand Down
Loading

0 comments on commit b20a316

Please sign in to comment.