Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 75fa7dc

Browse files
committed
Merge pull request #62 from Microsoft/android-support
Android support
2 parents 854bb93 + a8b90d9 commit 75fa7dc

File tree

70 files changed

+2314
-317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2314
-317
lines changed

.gitignore

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
15
# Xcode
26
#
37
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
@@ -97,3 +101,49 @@ xcuserdata
97101
*.xccheckout
98102
*.moved-aside
99103
*.xcuserstate
104+
105+
# Intellij project files
106+
*.iml
107+
*.ipr
108+
*.iws
109+
.idea/
110+
111+
#Gradle
112+
.gradletasknamecache
113+
.gradle/
114+
build/
115+
bin/
116+
117+
# Built application files
118+
*.apk
119+
*.ap_
120+
121+
# Files for the Dalvik VM
122+
*.dex
123+
124+
# Java class files
125+
*.class
126+
127+
# Generated files
128+
bin/
129+
gen/
130+
131+
# Gradle files
132+
.gradle/
133+
build/
134+
*/build/
135+
136+
# Local configuration file (sdk path, etc)
137+
local.properties
138+
139+
# Proguard folder generated by Eclipse
140+
proguard/
141+
142+
# Log Files
143+
*.log
144+
145+
# Android Studio Navigation editor temp files
146+
.navigation/
147+
148+
# Android Studio captures folder
149+
captures/

.watchmanconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

AlertAdapter.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use strict';
2+
3+
var Platform = require("Platform");
4+
var Alert;
5+
6+
if (Platform.OS === "android") {
7+
var CodePushDialog = require("react-native").NativeModules.CodePushDialog;
8+
Alert = {
9+
alert: function(title, message, buttons) {
10+
if (buttons.length > 2) {
11+
throw "Can only show 2 buttons for Android dialog.";
12+
}
13+
14+
var button1Text = buttons[0] ? buttons[0].text : null;
15+
var button2Text = buttons[1] ? buttons[1].text : null;
16+
17+
CodePushDialog.showDialog(
18+
title, message, button1Text, button2Text,
19+
(buttonPressedId) => {
20+
buttons[buttonPressedId].onPress && buttons[buttonPressedId].onPress();
21+
},
22+
(error) => {
23+
throw error;
24+
});
25+
}
26+
};
27+
} else if (Platform.OS === "ios") {
28+
var { AlertIOS } = require("react-native");
29+
Alert = AlertIOS;
30+
}
31+
32+
module.exports = {
33+
Alert: Alert
34+
}

CodePush.android.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

CodePush.ios.js renamed to CodePush.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict';
22

3-
var { AlertIOS } = require("react-native");
4-
var NativeCodePush = require("react-native").NativeModules.CodePush;
5-
var packageMixins = require("./package-mixins")(NativeCodePush);
63
var requestFetchAdapter = require("./request-fetch-adapter.js");
74
var Sdk = require("code-push/script/acquisition-sdk").AcquisitionManager;
5+
var NativeCodePush = require("react-native").NativeModules.CodePush;
6+
var PackageMixins = require("./package-mixins")(NativeCodePush);
7+
var { Alert } = require("./AlertAdapter");
88

99
function checkForUpdate(deploymentKey = null) {
1010
var config, sdk;
@@ -21,14 +21,14 @@ function checkForUpdate(deploymentKey = null) {
2121
}
2222

2323
sdk = getSDK(config);
24-
return getCurrentPackage();
24+
// Allow dynamic overwrite of function. This is only to be used for tests.
25+
return module.exports.getCurrentPackage();
2526
})
2627
.then((localPackage) => {
2728
var queryPackage = { appVersion: config.appVersion };
2829
if (localPackage && localPackage.appVersion === config.appVersion) {
2930
queryPackage = localPackage;
3031
}
31-
3232
return new Promise((resolve, reject) => {
3333
sdk.queryUpdateWithCurrentPackage(queryPackage, (err, update) => {
3434
if (err) {
@@ -41,7 +41,7 @@ function checkForUpdate(deploymentKey = null) {
4141
return resolve(null);
4242
}
4343

44-
update = Object.assign(update, packageMixins.remote);
44+
update = Object.assign(update, PackageMixins.remote);
4545

4646
NativeCodePush.isFailedUpdate(update.packageHash)
4747
.then((isFailedHash) => {
@@ -248,7 +248,7 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback)
248248
}
249249

250250
syncStatusChangeCallback(CodePush.SyncStatus.AWAITING_USER_ACTION);
251-
AlertIOS.alert(syncOptions.updateDialog.title, message, dialogButtons);
251+
Alert.alert(syncOptions.updateDialog.title, message, dialogButtons);
252252
} else {
253253
doDownloadAndInstall();
254254
}

CodePush.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ - (void)startRollbackTimer:(int)rollbackTimeout
321321
progressCallback:^(long expectedContentLength, long receivedContentLength) {
322322
// Notify the script-side about the progress
323323
[self.bridge.eventDispatcher
324-
sendAppEventWithName:@"CodePushDownloadProgress"
324+
sendDeviceEventWithName:@"CodePushDownloadProgress"
325325
body:@{
326326
@"totalBytes":[NSNumber numberWithLong:expectedContentLength],
327327
@"receivedBytes":[NSNumber numberWithLong:receivedContentLength]

CodePush.xcodeproj/project.pbxproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,8 @@
215215
HEADER_SEARCH_PATHS = (
216216
"$(inherited)",
217217
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
218-
"$(SRCROOT)/../../React/**",
219-
"$(SRCROOT)/../../node_modules/react-native/React/**",
220218
"$(SRCROOT)/node_modules/react-native/React/**",
219+
"$(SRCROOT)/Examples/CodePushDemoApp/node_modules/react-native/React/**",
221220
);
222221
LIBRARY_SEARCH_PATHS = "$(inherited)";
223222
OTHER_LDFLAGS = "-ObjC";
@@ -232,9 +231,8 @@
232231
HEADER_SEARCH_PATHS = (
233232
"$(inherited)",
234233
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
235-
"$(SRCROOT)/../../React/**",
236-
"$(SRCROOT)/../../node_modules/react-native/React/**",
237234
"$(SRCROOT)/node_modules/react-native/React/**",
235+
"$(SRCROOT)/Examples/CodePushDemoApp/node_modules/react-native/React/**",
238236
);
239237
LIBRARY_SEARCH_PATHS = "$(inherited)";
240238
OTHER_LDFLAGS = "-ObjC";

Examples/CodePushDemoApp/.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,49 @@ node_modules/
2727
npm-debug.log
2828

2929
main.jsbundle
30+
31+
# Intellij project files
32+
*.iml
33+
*.ipr
34+
*.iws
35+
.idea/
36+
37+
#Gradle
38+
.gradletasknamecache
39+
.gradle/
40+
build/
41+
bin/
42+
43+
# Built application files
44+
*.apk
45+
*.ap_
46+
47+
# Files for the Dalvik VM
48+
*.dex
49+
50+
# Java class files
51+
*.class
52+
53+
# Generated files
54+
bin/
55+
gen/
56+
57+
# Gradle files
58+
.gradle/
59+
build/
60+
*/build/
61+
62+
# Local configuration file (sdk path, etc)
63+
local.properties
64+
65+
# Proguard folder generated by Eclipse
66+
proguard/
67+
68+
# Log Files
69+
*.log
70+
71+
# Android Studio Navigation editor temp files
72+
.navigation/
73+
74+
# Android Studio captures folder
75+
captures/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

Examples/CodePushDemoApp/CodePushDemoAppTests/DownloadProgressTests.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ - (void)setUp
2323

2424
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
2525
RCTAssert(version.majorVersion == 8 || version.minorVersion == 3, @"Tests should be run on iOS 8.3, found %zd.%zd.%zd", version.majorVersion, version.minorVersion, version.patchVersion);
26-
_runner = RCTInitRunnerForApp(@"CodePushDemoAppTests/DownloadProgressTests/DownloadProgressTestApp.ios", nil);
26+
_runner = RCTInitRunnerForApp(@"CodePushDemoAppTests/DownloadProgressTests/DownloadProgressTestApp", nil);
2727
}
2828

2929
#pragma mark Logic Tests

0 commit comments

Comments
 (0)