-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from aouaki/master
Add Android support
- Loading branch information
Showing
6 changed files
with
207 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 24 | ||
buildToolsVersion "24.0.0" | ||
|
||
defaultConfig { | ||
minSdkVersion 16 | ||
targetSdkVersion 24 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
repositories { | ||
maven { | ||
url 'http://sdk.uxcam.com/android/' | ||
} | ||
} | ||
|
||
dependencies { | ||
compile 'com.android.support:appcompat-v7:24.+' | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
compile 'com.uxcam:uxcam:2.5.1@aar' | ||
compile 'com.facebook.react:react-native:+' | ||
testCompile 'junit:junit:4.12' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.4.1_1/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 *; | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.rnuxcam.rnuxcam"> | ||
|
||
</manifest> |
102 changes: 102 additions & 0 deletions
102
android/src/main/java/com/rnuxcam/rnuxcam/UXCamModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package com.rnuxcam.rnuxcam; | ||
|
||
import com.uxcam.UXCam; | ||
|
||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.bridge.ReactContextBaseJavaModule; | ||
import com.facebook.react.bridge.ReactMethod; | ||
import com.facebook.react.bridge.ReadableMap; | ||
import com.facebook.react.bridge.ReadableMapKeySetIterator; | ||
import com.facebook.react.bridge.Promise; | ||
|
||
import java.util.HashMap; | ||
|
||
public class UXCamModule extends ReactContextBaseJavaModule { | ||
|
||
public UXCamModule(ReactApplicationContext reactContext) { | ||
super(reactContext); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "RNUXCam"; | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
@ReactMethod | ||
public void startWithKey(String key) { | ||
UXCam.startApplicationWithKeyForCordova(getCurrentActivity(), key); | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
@ReactMethod | ||
public void tagScreenName(String screenName) { | ||
UXCam.tagScreenName(screenName); | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
@ReactMethod | ||
public void tagUserName(String userName) { | ||
UXCam.tagUsersName(userName); | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
@ReactMethod | ||
public void addTag(String tag, ReadableMap properties) { | ||
HashMap<String, String> map = new HashMap<String, String>(); | ||
|
||
ReadableMapKeySetIterator iterator = properties.keySetIterator(); | ||
while (iterator.hasNextKey()) { | ||
String key = iterator.nextKey(); | ||
String value = properties.getString(key); | ||
map.put(key, value); | ||
} | ||
UXCam.addTagWithProperties(tag, map); | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
@ReactMethod | ||
public void markUserAsFavorite() { | ||
UXCam.markSessionAsFavorite(); | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
@ReactMethod | ||
public void urlForCurrentUser(Promise promise) { | ||
String url = UXCam.urlForCurrentUser(); | ||
if (url == null || url.isEmpty()) { | ||
String code = "no_url"; | ||
String message = "Could not retrieve the url for the current user."; | ||
Throwable error = new Throwable(message); | ||
promise.reject(code, message, error); | ||
} else { | ||
promise.resolve(url); | ||
} | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
@ReactMethod | ||
public void urlForCurrentSession(Promise promise) { | ||
String url = UXCam.urlForCurrentSession(); | ||
if (url == null || url.isEmpty()) { | ||
String code = "no_url"; | ||
String message = "Could not retrieve the url for the current session."; | ||
Throwable error = new Throwable(message); | ||
promise.reject(code, message, error); | ||
} else { | ||
promise.resolve(url); | ||
} | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
@ReactMethod | ||
public void occludeSensitiveScreen(boolean occlude) { | ||
UXCam.occludeSensitiveScreen(occlude); | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
@ReactMethod | ||
public void stopApplicationAndUploadData() { | ||
UXCam.stopApplicationAndUploadData(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
android/src/main/java/com/rnuxcam/rnuxcam/UXCamPackage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.rnuxcam.rnuxcam; | ||
|
||
import com.facebook.react.ReactPackage; | ||
import com.facebook.react.bridge.JavaScriptModule; | ||
import com.facebook.react.bridge.NativeModule; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.uimanager.ViewManager; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class UXCamPackage implements ReactPackage { | ||
|
||
@Override | ||
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { | ||
List<NativeModule> modules = new ArrayList<>(); | ||
modules.add(new com.rnuxcam.rnuxcam.UXCamModule(reactContext)); | ||
return modules; | ||
} | ||
|
||
@Override | ||
public List<Class<? extends JavaScriptModule>> createJSModules() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { | ||
return Collections.emptyList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters