Skip to content

Commit 25e3eb6

Browse files
committed
android support
1 parent 380df40 commit 25e3eb6

Some content is hidden

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

55 files changed

+55728
-181
lines changed

.gitignore

+50
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

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

CodePush.android.js

-17
This file was deleted.

CodePush.ios.js renamed to CodePush.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
'use strict';
22

3-
var NativeCodePush = require("react-native").NativeModules.CodePush;
43
var requestFetchAdapter = require("./request-fetch-adapter.js");
54
var Sdk = require("code-push/script/acquisition-sdk").AcquisitionManager;
6-
var packageMixins = require("./package-mixins")(NativeCodePush);
7-
8-
var { AlertIOS } = require("react-native");
5+
var { NativeCodePush, PackageMixins, Alert } = require("./CodePushNativePlatformAdapter");
96

107
// This function is only used for tests. Replaces the default SDK, configuration and native bridge
118
function setUpTestDependencies(providedTestSdk, providedTestConfig, testNativeBridge){
@@ -102,7 +99,7 @@ function checkForUpdate() {
10299
return resolve(null);
103100
}
104101

105-
update = Object.assign(update, packageMixins.remote);
102+
update = Object.assign(update, PackageMixins.remote);
106103

107104
NativeCodePush.isFailedUpdate(update.packageHash)
108105
.then((isFailedHash) => {
@@ -252,7 +249,7 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback)
252249
}
253250

254251
syncStatusChangeCallback(CodePush.SyncStatus.AWAITING_USER_ACTION);
255-
AlertIOS.alert(syncOptions.updateDialog.title, message, dialogButtons);
252+
Alert.alert(syncOptions.updateDialog.title, message, dialogButtons);
256253
} else {
257254
doDownloadAndInstall();
258255
}

CodePushNativePlatformAdapter.js

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
'use strict';
2+
3+
var NativeCodePush = require("react-native").NativeModules.CodePush;
4+
5+
var Platform = require("Platform");
6+
var Alert;
7+
8+
if (Platform.OS === "android") {
9+
/*
10+
* Promisify native methods. Assumes that every native method takes
11+
* two callback functions, resolve and reject.
12+
*/
13+
var methodsToPromisify = [
14+
"installUpdate",
15+
"downloadUpdate",
16+
"getConfiguration",
17+
"getCurrentPackage",
18+
"isFailedUpdate",
19+
"isFirstRun",
20+
"notifyApplicationReady"
21+
];
22+
23+
methodsToPromisify.forEach((methodName) => {
24+
var aMethod = NativeCodePush[methodName];
25+
NativeCodePush[methodName] = function() {
26+
var args = [].slice.apply(arguments);
27+
return new Promise((resolve, reject) => {
28+
args.push(resolve);
29+
args.push(reject);
30+
aMethod.apply(this, args);
31+
});
32+
}
33+
});
34+
35+
var CodePushDialog = require("react-native").NativeModules.CodePushDialog;
36+
Alert = {
37+
alert: function(title, message, buttons) {
38+
if (buttons.length > 2) {
39+
throw "Can only show 2 buttons for Android dialog.";
40+
}
41+
42+
var button1Text = buttons[0] ? buttons[0].text : null;
43+
var button2Text = buttons[1] ? buttons[1].text : null;
44+
45+
CodePushDialog.showDialog(
46+
title, message, button1Text, button2Text,
47+
(buttonPressedId) => {
48+
buttons[buttonPressedId].onPress && buttons[buttonPressedId].onPress();
49+
},
50+
(error) => {
51+
throw error;
52+
});
53+
}
54+
};
55+
} else if (Platform.OS === "ios") {
56+
var { AlertIOS } = require("react-native");
57+
Alert = AlertIOS;
58+
}
59+
60+
var PackageMixins = require("./package-mixins")(NativeCodePush);
61+
62+
module.exports = {
63+
NativeCodePush: NativeCodePush,
64+
PackageMixins: PackageMixins,
65+
Alert: Alert
66+
}

Examples/CodePushDemoApp/.gitignore

+46
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/
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

Examples/CodePushDemoApp/CodePushDemoAppTests/InstallUpdateTests/InstallUpdateTestApp.ios.js

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/**
2-
* @providesModule QueryUpdateTestApp
3-
*/
41
'use strict';
52

63
var React = require('react-native');

Examples/CodePushDemoApp/CodePushDemoAppTests/QueryUpdateTests/QueryUpdateTestApp.ios.js

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/**
2-
* @providesModule QueryUpdateTestApp
3-
*/
41
'use strict';
52

63
var React = require('react-native');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 23
5+
buildToolsVersion "23.0.1"
6+
7+
defaultConfig {
8+
applicationId "com.microsoft.codepushdemoapp"
9+
minSdkVersion 16
10+
targetSdkVersion 22
11+
versionCode 1
12+
versionName "1.0.0"
13+
ndk {
14+
abiFilters "armeabi-v7a", "x86"
15+
}
16+
}
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21+
}
22+
}
23+
}
24+
25+
dependencies {
26+
compile fileTree(dir: 'libs', include: ['*.jar'])
27+
compile 'com.android.support:appcompat-v7:23.0.0'
28+
compile 'com.facebook.react:react-native:0.15.1'
29+
compile project(':react-native-code-push')
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.microsoft.codepushdemoapp">
3+
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
6+
<application
7+
android:allowBackup="true"
8+
android:label="@string/app_name"
9+
android:icon="@mipmap/ic_launcher"
10+
android:theme="@style/AppTheme">
11+
<activity
12+
android:name="com.microsoft.codepushdemoapp.MainActivity"
13+
android:label="@string/app_name">
14+
<intent-filter>
15+
<action android:name="android.intent.action.MAIN" />
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
</activity>
19+
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
20+
</application>
21+
22+
</manifest>

0 commit comments

Comments
 (0)