Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
android support
Browse files Browse the repository at this point in the history
  • Loading branch information
geof90 committed Nov 23, 2015
1 parent 380df40 commit 25e3eb6
Show file tree
Hide file tree
Showing 55 changed files with 55,728 additions and 181 deletions.
50 changes: 50 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# OSX
#
.DS_Store

# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
Expand Down Expand Up @@ -97,3 +101,49 @@ xcuserdata
*.xccheckout
*.moved-aside
*.xcuserstate

# Intellij project files
*.iml
*.ipr
*.iws
.idea/

#Gradle
.gradletasknamecache
.gradle/
build/
bin/

# Built application files
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/

# Gradle files
.gradle/
build/
*/build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/
1 change: 1 addition & 0 deletions .watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
17 changes: 0 additions & 17 deletions CodePush.android.js

This file was deleted.

9 changes: 3 additions & 6 deletions CodePush.ios.js → CodePush.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
'use strict';

var NativeCodePush = require("react-native").NativeModules.CodePush;
var requestFetchAdapter = require("./request-fetch-adapter.js");
var Sdk = require("code-push/script/acquisition-sdk").AcquisitionManager;
var packageMixins = require("./package-mixins")(NativeCodePush);

var { AlertIOS } = require("react-native");
var { NativeCodePush, PackageMixins, Alert } = require("./CodePushNativePlatformAdapter");

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

update = Object.assign(update, packageMixins.remote);
update = Object.assign(update, PackageMixins.remote);

NativeCodePush.isFailedUpdate(update.packageHash)
.then((isFailedHash) => {
Expand Down Expand Up @@ -252,7 +249,7 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback)
}

syncStatusChangeCallback(CodePush.SyncStatus.AWAITING_USER_ACTION);
AlertIOS.alert(syncOptions.updateDialog.title, message, dialogButtons);
Alert.alert(syncOptions.updateDialog.title, message, dialogButtons);
} else {
doDownloadAndInstall();
}
Expand Down
66 changes: 66 additions & 0 deletions CodePushNativePlatformAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
'use strict';

var NativeCodePush = require("react-native").NativeModules.CodePush;

var Platform = require("Platform");
var Alert;

if (Platform.OS === "android") {
/*
* Promisify native methods. Assumes that every native method takes
* two callback functions, resolve and reject.
*/
var methodsToPromisify = [
"installUpdate",
"downloadUpdate",
"getConfiguration",
"getCurrentPackage",
"isFailedUpdate",
"isFirstRun",
"notifyApplicationReady"
];

methodsToPromisify.forEach((methodName) => {
var aMethod = NativeCodePush[methodName];
NativeCodePush[methodName] = function() {
var args = [].slice.apply(arguments);
return new Promise((resolve, reject) => {
args.push(resolve);
args.push(reject);
aMethod.apply(this, args);
});
}
});

var CodePushDialog = require("react-native").NativeModules.CodePushDialog;
Alert = {
alert: function(title, message, buttons) {
if (buttons.length > 2) {
throw "Can only show 2 buttons for Android dialog.";
}

var button1Text = buttons[0] ? buttons[0].text : null;
var button2Text = buttons[1] ? buttons[1].text : null;

CodePushDialog.showDialog(
title, message, button1Text, button2Text,
(buttonPressedId) => {
buttons[buttonPressedId].onPress && buttons[buttonPressedId].onPress();
},
(error) => {
throw error;
});
}
};
} else if (Platform.OS === "ios") {
var { AlertIOS } = require("react-native");
Alert = AlertIOS;
}

var PackageMixins = require("./package-mixins")(NativeCodePush);

module.exports = {
NativeCodePush: NativeCodePush,
PackageMixins: PackageMixins,
Alert: Alert
}
46 changes: 46 additions & 0 deletions Examples/CodePushDemoApp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,49 @@ node_modules/
npm-debug.log

main.jsbundle

# Intellij project files
*.iml
*.ipr
*.iws
.idea/

#Gradle
.gradletasknamecache
.gradle/
build/
bin/

# Built application files
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/

# Gradle files
.gradle/
build/
*/build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/
1 change: 1 addition & 0 deletions Examples/CodePushDemoApp/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* @providesModule QueryUpdateTestApp
*/
'use strict';

var React = require('react-native');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* @providesModule QueryUpdateTestApp
*/
'use strict';

var React = require('react-native');
Expand Down
30 changes: 30 additions & 0 deletions Examples/CodePushDemoApp/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.microsoft.codepushdemoapp"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.facebook.react:react-native:0.15.1'
compile project(':react-native-code-push')
}
17 changes: 17 additions & 0 deletions Examples/CodePushDemoApp/android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
22 changes: 22 additions & 0 deletions Examples/CodePushDemoApp/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.microsoft.codepushdemoapp">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme">
<activity
android:name="com.microsoft.codepushdemoapp.MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>

</manifest>
Loading

0 comments on commit 25e3eb6

Please sign in to comment.