Skip to content

Commit c95ddd9

Browse files
committed
Merge pull request #14 from testfairy/android-sdk
Android sdk Updated to ios sdk 1.7.4
2 parents f448ea8 + 32e70f4 commit c95ddd9

File tree

9 files changed

+165
-8
lines changed

9 files changed

+165
-8
lines changed

.travis.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
language: objective-c
22

3+
before_install:
4+
- wget http://dl.google.com/android/android-sdk_r24.4.1-macosx.zip
5+
- unzip android-sdk_r24.4.1-macosx.zip
6+
- export ANDROID_HOME=$PWD/android-sdk-macosx
7+
- export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
8+
9+
- echo yes | android update sdk --filter platform-tools --no-ui --force > /dev/null
10+
- echo yes | android update sdk --filter android-23 --no-ui --force > /dev/null
11+
- echo yes | android update sdk --filter build-tools-23.0.3 --all --no-ui --force > /dev/null
12+
- echo yes | android update sdk --filter sysimg-23 --no-ui --force > /dev/null
13+
- echo yes | android update sdk --filter extra-android-support --no-ui --force > /dev/null
14+
- echo yes | android update sdk --filter extra-android-m2repository --no-ui --force > /dev/null
15+
316
install:
417
- npm install -g cordova
518

@@ -8,6 +21,8 @@ script:
821
- cordova create hello com.example.hello HelloWorld
922
- cd hello
1023
- cordova platform add ios
24+
- cordova platform add android
1125
- cordova plugin add https://github.com/testfairy/testfairy-cordova-plugin
1226
- cordova build ios
27+
- cordova build android
1328

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### Supported Platforms
66

7-
TestFairy SDK for PhoneGap/Cordova is currently available only for *iOS*. For Android apps, just upload the APK files directly to https://app.testfairy.com.
7+
TestFairy SDK for PhoneGap/Cordova is currently only available for iOS and Android apps.
88

99
### Installation
1010

@@ -16,12 +16,14 @@ cordova plugin add https://github.com/testfairy/testfairy-cordova-plugin
1616

1717
### Usage
1818

19-
Initialize TestFairy with your [App Token](https://app.testfairy.com/settings/#apptoken) by calling `TestFairy.begin` from *onDeviceReady*. For example, here's *onDeviceReady* from *index.js*:
19+
Initialize TestFairy with your [App Token](https://app.testfairy.com/settings/#apptoken) by calling `TestFairy.begin`. Your APP_TOKEN is available at https://app.testfairy.com/settings/#apptoken.
20+
21+
It's recommended to invoke `TestFairy.begin` from `onDeviceReady`. For example, here's *onDeviceReady* from *index.js*:
2022

2123
```
2224
onDeviceReady: function() {
2325
app.receivedEvent('deviceready');
24-
TestFairy.begin("MY_APP_TOKEN");
26+
TestFairy.begin("APP_TOKEN");
2527
},
2628
```
2729

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "com.testfairy.cordova-plugin",
3-
"version": "1.7.0",
3+
"version": "2.0.0",
44
"description": "TestFairy SDK plugin for Cordova",
55
"cordova": {
66
"id": "com.testfairy.cordova-plugin",
77
"platforms": [
8-
"ios"
8+
"ios",
9+
"android"
910
]
1011
},
1112
"repository": {
@@ -20,6 +21,7 @@
2021
"distribution",
2122
"testflight",
2223
"cordova-ios",
24+
"cordova-android",
2325
"ecosystem:cordova"
2426
],
2527
"author": "Apache Software Foundation",
@@ -29,3 +31,4 @@
2931
},
3032
"homepage": "https://github.com/testfairy/testfairy-cordova-plugin"
3133
}
34+

plugin.xml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="com.testfairy.cordova-plugin" version="1.7.0">
2+
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="com.testfairy.cordova-plugin" version="2.0.0">
33
<name>TestFairy Plugin</name>
44
<description>TestFairy SDK plugin for Cordova</description>
55
<license>Apache 2.0 License</license>
66
<engines>
77
<engine name="cordova" version=">=2.9.0" />
8-
<!--
8+
<!--
99
<engine name="cordova-android" version=">=3.1.0" />
10-
-->
10+
-->
1111
</engines>
1212

1313
<js-module src="www/testfairy.js" name="TestFairy">
@@ -34,4 +34,13 @@
3434
<framework src="OpenGLES.framework" />
3535
<framework src="CoreLocation.framework" />
3636
</platform>
37+
<platform name="android">
38+
<source-file src="src/android/CDVTestFairy.java" target-dir="src/com/testfairy" />
39+
<source-file src="src/android/testfairy-sdk.jar" target-dir="libs" />
40+
<config-file target="config.xml" parent="/widget">
41+
<feature name="TestFairy">
42+
<param name="android-package" value="com.testfairy.CDVTestFairy" />
43+
</feature>
44+
</config-file>
45+
</platform>
3746
</plugin>

src/android/CDVTestFairy.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.testfairy;
2+
3+
import org.apache.cordova.CallbackContext;
4+
import org.apache.cordova.CordovaPlugin;
5+
import org.apache.cordova.CordovaInterface;
6+
import org.json.JSONArray;
7+
import org.json.JSONObject;
8+
import org.json.JSONException;
9+
import android.content.Intent;
10+
11+
import android.content.Context;
12+
13+
public class CDVTestFairy extends CordovaPlugin {
14+
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
15+
if ("begin".equals(action)) {
16+
String apiKey = args.optString(0);
17+
TestFairy.begin(cordova.getActivity(), apiKey);
18+
} else if ("pushFeedbackController".equals(action)) {
19+
20+
} else if ("updateLocation".equals(action)) {
21+
22+
} else if ("checkpoint".equals(action)) {
23+
String name = args.optString(0);
24+
TestFairy.addCheckpoint(name);
25+
} else if ("setCorrelationId".equals(action)) {
26+
String id = args.optString(0);
27+
TestFairy.setCorrelationId(id);
28+
} else if ("pause".equals(action)) {
29+
TestFairy.pause();
30+
} else if ("resume".equals(action)) {
31+
TestFairy.resume();
32+
} else {
33+
return false;
34+
}
35+
36+
callbackContext.success();
37+
return true;
38+
}
39+
}

src/android/testfairy-sdk.jar

288 KB
Binary file not shown.

src/ios/TestFairy.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,8 @@ extern NSString *const TFSDKIdentityTraitWebsiteAddressKey;
172172
extern NSString *const TFSDKIdentityTraitAgeKey;
173173
extern NSString *const TFSDKIdentityTraitSignupDateKey;
174174
extern NSString *const TFSDKEnableCrashReporterKey;
175+
extern NSString *const TestFairyDidShakeDevice;
176+
extern NSString *const TestFairyWillProvideFeedback;
177+
extern NSString *const TestFairyDidCancelFeedback;
178+
extern NSString *const TestFairyDidSendFeedback;
175179

src/ios/libTestFairy.a

42.3 KB
Binary file not shown.

src/ios/upload-dsym.sh

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/sh
2+
3+
TESTFAIRY_ENDPOINT="http://app.testfairy.com/upload/dsym/"
4+
5+
ZIP=zip
6+
CURL=curl
7+
STAT=stat
8+
DATE=date
9+
10+
log() {
11+
NOW=$($DATE +"%Y-%m-%d %H:%M:%S")
12+
echo "${NOW} ${1}"
13+
}
14+
15+
help() {
16+
echo "Usage: ${0} [-f] TESTFAIRY_API_KEY [-p DSYM_PATH]"
17+
exit 1
18+
}
19+
20+
DAEMON=1
21+
if [ "${1}" == "-f" ]; then
22+
DAEMON=0
23+
shift
24+
elif [ "${1}" == "-d" ]; then
25+
# backward compatible when -f was the default
26+
shift
27+
fi
28+
29+
30+
API_KEY="${1}"
31+
if [ ! "${API_KEY}" ]; then
32+
help
33+
fi
34+
35+
DSYM_PATH=${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}
36+
37+
if [ "${#}" -gt 1 ]; then
38+
shift
39+
if [ "${1}" != "-p" ]; then
40+
help
41+
fi
42+
43+
shift
44+
DSYM_PATH="${1}"
45+
fi
46+
47+
if [ "${DSYM_PATH}" == "" ] || [ "${DSYM_PATH}" == "/" ] || [ ! -d "${DSYM_PATH}" ]; then
48+
echo "Fatal: Can't find .dSYM folder!"
49+
help
50+
fi
51+
52+
NOW=$($DATE +%s)
53+
TMP_FILENAME="/tmp/${NOW}-${DWARF_DSYM_FILE_NAME}.zip"
54+
55+
# Compress the .dSYM folder into a zip file
56+
log "Compressing .dSYM folder ${DSYM_PATH}"
57+
$ZIP -qrp9 "${TMP_FILENAME}" "${DSYM_PATH}"
58+
FILE_SIZE=$($STAT -f "%z" "${TMP_FILENAME}")
59+
60+
foreground_upload() {
61+
# Upload zipped .dSYM file to TestFairy's servers
62+
STARTED=$($DATE +"%s")
63+
$CURL -s -F api_key="${API_KEY}" -F dsym=@"${1}" -o /dev/null "${TESTFAIRY_ENDPOINT}"
64+
ENDED=$($DATE +"%s")
65+
DIFF=$(expr ${ENDED} - ${STARTED})
66+
log "Symbols uploaded in ${DIFF} seconds"
67+
68+
# Clean up behind
69+
rm -f ${TMP_FILENAME}
70+
}
71+
72+
background_upload() {
73+
sh -c "$CURL -F api_key=\"${API_KEY}\" -F dsym=@\"${1}\" -s -o /dev/null \"${TESTFAIRY_ENDPOINT}\"; rm -f ${TMP_FILENAME};" /dev/null 2>&1 &
74+
}
75+
76+
if [ "$DAEMON" == "0" ]; then
77+
log "Uploading ${FILE_SIZE} bytes to dsym server in foreground"
78+
foreground_upload "${TMP_FILENAME}"
79+
else
80+
log "Uploading ${FILE_SIZE} bytes to dsym server in background"
81+
background_upload "${TMP_FILENAME}"
82+
fi
83+
84+
log "TestFairy .dSYM upload script ends"
85+

0 commit comments

Comments
 (0)