Skip to content

Commit

Permalink
Merge pull request #47 from apptentive/develop
Browse files Browse the repository at this point in the history
Release 5.0.0
  • Loading branch information
frankus authored Jan 19, 2018
2 parents 9804da6 + 95ac176 commit 0c166ff
Show file tree
Hide file tree
Showing 41 changed files with 552 additions and 427 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ This document lets you know what has changed in the Cordova plugin. For changes
- [Android Changelog](https://github.com/apptentive/apptentive-android/blob/master/CHANGELOG.md)
- [iOS Changelog](https://github.com/apptentive/apptentive-ios/blob/master/CHANGELOG.md)

# 2018-01-18 - v5.0.0

- Apptentive Android SDK: 5.0.2
- Apptentive iOS SDK: 5.0.0

# 2018-01-17 - v4.1.1

- Apptentive Android SDK: 4.1.4
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apptentive-cordova",
"version": "4.1.1",
"version": "5.0.0",
"description": "Apptentive Plugin For Cordova",
"cordova": {
"id": "com.apptentive.cordova",
Expand Down
8 changes: 4 additions & 4 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="com.apptentive.cordova" version="4.1.1">
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="com.apptentive.cordova" version="5.0.0">

<name>ApptentiveBridge</name>
<description>Apptentive Plugin For Cordova</description>
Expand Down Expand Up @@ -41,9 +41,9 @@
</config-file>
<config-file target="./res/values/strings.xml" parent="/resources">
<string name="apptentive_distribution">Cordova</string>
<string name="apptentive_distribution_version">4.1.1</string>
<string name="apptentive_distribution_version">5.0.0</string>
</config-file>
<framework src="com.apptentive:apptentive-android:4.1.4"/>
<framework src="com.apptentive:apptentive-android:5.0.2"/>
<source-file src="src/android/ApptentiveBridge.java" target-dir="src/com/apptentive/cordova"/>
<source-file src="src/android/JsonHelper.java" target-dir="src/com/apptentive/cordova"/>
</platform>
Expand Down Expand Up @@ -74,7 +74,7 @@
</config-file>

<config-file target="*-Info.plist" parent="ApptentivePluginVersion">
<string>4.1.1</string>
<string>5.0.0</string>
</config-file>

<!-- ApptentiveBridge -->
Expand Down
93 changes: 48 additions & 45 deletions src/android/ApptentiveBridge.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
package com.apptentive.cordova;

import android.provider.Settings;
import android.widget.Toast;
import android.content.Intent;
import android.os.Bundle;

import android.app.Activity;

import com.apptentive.android.sdk.Apptentive;
import com.apptentive.android.sdk.ApptentiveLog;
import com.apptentive.android.sdk.Apptentive.BooleanCallback;
import com.apptentive.android.sdk.ApptentiveInternal;
import com.apptentive.android.sdk.lifecycle.ApptentiveActivityLifecycleCallbacks;
import com.apptentive.android.sdk.ApptentiveLog;
import com.apptentive.android.sdk.module.messagecenter.UnreadMessagesListener;
import com.apptentive.android.sdk.module.rating.impl.AmazonAppstoreRatingProvider;
import com.apptentive.android.sdk.module.survey.OnSurveyFinishedListener;
import com.apptentive.cordova.JsonHelper;

import java.io.IOException;
import java.lang.Boolean;
import java.util.Map;
import java.util.Iterator;

import org.apache.cordova.CordovaWebView;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.Map;

public class ApptentiveBridge extends CordovaPlugin {

Expand Down Expand Up @@ -61,36 +50,41 @@ public class ApptentiveBridge extends CordovaPlugin {
public ApptentiveBridge() {
}

UnreadMessagesListener listener = null;
UnreadMessagesListener listener = null;

public boolean execute(final String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
ApptentiveLog.v("Executing action: %s", action);

if (action.equals(ACTION_DEVICE_READY)) {
final Activity currentActivity = cordova.getActivity();
if (currentActivity != null && !ApptentiveInternal.isApptentiveRegistered()) {
currentActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
Apptentive.register(currentActivity.getApplication());
ApptentiveInternal.getInstance().getRegisteredLifecycleCallbacks().onActivityCreated(currentActivity, null);
ApptentiveInternal.getInstance().getRegisteredLifecycleCallbacks().onActivityStarted(currentActivity);
ApptentiveInternal.getInstance().getRegisteredLifecycleCallbacks().onActivityResumed(currentActivity);
}
});
}
final Activity currentActivity = cordova.getActivity();
if (currentActivity != null && !ApptentiveInternal.isApptentiveRegistered()) {
currentActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
Apptentive.register(currentActivity.getApplication());
ApptentiveInternal.getInstance().getRegisteredLifecycleCallbacks().onActivityCreated(currentActivity, null);
ApptentiveInternal.getInstance().getRegisteredLifecycleCallbacks().onActivityStarted(currentActivity);
ApptentiveInternal.getInstance().getRegisteredLifecycleCallbacks().onActivityResumed(currentActivity);
}
});
}
callbackContext.success();
return true;

} else if (action.equals(ACTION_CAN_SHOW_MESSAGE_CENTER)) {
boolean canShowMessageCenter = Apptentive.canShowMessageCenter();
PluginResult result = new PluginResult(PluginResult.Status.OK, canShowMessageCenter);
callbackContext.sendPluginResult(result);
Apptentive.canShowMessageCenter(new BooleanCallback() {
@Override
public void onFinish(boolean canShowMessageCenter) {
PluginResult result = new PluginResult(PluginResult.Status.OK, canShowMessageCenter);
callbackContext.sendPluginResult(result);
}
});
return true;

} else if (action.equals(ACTION_SHOW_MESSAGE_CENTER)) {
// TODO: pass boolean callback and use returned value
if (args.length() > 0) {
Map config = JsonHelper.toMap(args.getJSONObject(0));
Map<String, Object> config = JsonHelper.toMap(args.getJSONObject(0));
Apptentive.showMessageCenter(cordova.getActivity(), config);
} else {
Apptentive.showMessageCenter(cordova.getActivity());
Expand Down Expand Up @@ -139,23 +133,32 @@ else if (value instanceof Boolean) {
return true;

} else if (action.equals(ACTION_CAN_SHOW_INTERACTION)) {
String eventId = args.getString(0);
boolean canShowInteraction = Apptentive.canShowInteraction(eventId);
PluginResult result = new PluginResult(PluginResult.Status.OK, canShowInteraction);
callbackContext.sendPluginResult(result);
final String eventId = args.getString(0);
Apptentive.queryCanShowInteraction(eventId, new BooleanCallback() {
@Override
public void onFinish(boolean canShowInteraction) {
PluginResult result = new PluginResult(PluginResult.Status.OK, canShowInteraction);
callbackContext.sendPluginResult(result);
}
});
return true;

} else if (action.equals(ACTION_ENGAGE)) {
String eventId = args.getString(0);
boolean shown = false;
final String eventId = args.getString(0);
BooleanCallback callback = new BooleanCallback() {
@Override
public void onFinish(boolean shown) {
PluginResult result = new PluginResult(PluginResult.Status.OK, shown);
callbackContext.sendPluginResult(result);
}
};

if (args.length() > 1) {
Map customData = JsonHelper.toMap(args.getJSONObject(1));
shown = Apptentive.engage(cordova.getActivity(), eventId, customData);
Map<String, Object> customData = JsonHelper.toMap(args.getJSONObject(1));
Apptentive.engage(cordova.getActivity(), eventId, callback, customData);
} else {
shown = Apptentive.engage(cordova.getActivity(), eventId);
Apptentive.engage(cordova.getActivity(), eventId, callback);
}
PluginResult result = new PluginResult(PluginResult.Status.OK, shown);
callbackContext.sendPluginResult(result);
return true;

} else if (action.equals(ACTION_GET_UNREAD_MESSAGE_COUNT)) {
Expand Down
71 changes: 71 additions & 0 deletions src/ios/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
ConstructorInitializerIndentWidth: 4

AlignAfterOpenBracket: false
AlignEscapedNewlinesLeft: true
AlignOperands: false
AlignTrailingComments: true

AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortLoopsOnASingleLine: true

AlwaysBreakAfterDefinitionReturnType: false
AlwaysBreakTemplateDeclarations: false
AlwaysBreakBeforeMultilineStrings: false

BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false

BinPackArguments: true
BinPackParameters: true
ColumnLimit: 0
ConstructorInitializerAllOnOneLineOrOnePerLine: true
DerivePointerAlignment: false
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: true
IndentWrappedFunctionNames: false
IndentFunctionDeclarationAfterType: false
MaxEmptyLinesToKeep: 2
KeepEmptyLinesAtTheStartOfBlocks: false
NamespaceIndentation: Inner
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 10000
PenaltyBreakComment: 300
PenaltyBreakString: 10000
PenaltyBreakFirstLessLess: 120
PenaltyExcessCharacter: 1
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Right
SpacesBeforeTrailingComments: 1
Cpp11BracedListStyle: true
Standard: Auto
IndentWidth: 4
TabWidth: 4
UseTab: Always
BreakBeforeBraces: Attach

SpacesInParentheses: false
SpacesInSquareBrackets: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpaceAfterCStyleCast: false
SpacesInContainerLiterals: false
SpaceBeforeAssignmentOperators: true

ContinuationIndentWidth: 4
CommentPragmas: '^ IWYU pragma:'
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
SpaceBeforeParens: ControlStatements
DisableFormat: false
...
5 changes: 3 additions & 2 deletions src/ios/ApptentiveBridge.h
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#import <Cordova/CDV.h>


@interface ApptentiveBridge : CDVPlugin

- (void)execute:(CDVInvokedUrlCommand*)command;
- (void)execute:(CDVInvokedUrlCommand *)command;

@end
@end
Loading

0 comments on commit 0c166ff

Please sign in to comment.