Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 38a3f69

Browse files
author
Felix Salazar
committed
Merge branch 'develop' Release 3.0.0-beta.1
2 parents ef6ba1c + 914fe27 commit 38a3f69

29 files changed

+14344
-6902
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [3.0.0-beta.1] - 2019-05-22
8+
### Added
9+
- AndroidSDK support
10+
11+
### Changed
12+
- React Native and dependencies updated: "react": "16.8.3"; "react-native": "0.59.5"
13+
714
## [2.0.0] - 2018-09-10
815
### Changed
916
- Using iOS SDK v4.0, removing the dependency on Vuforia

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,11 @@
44
## How to use the module
55

66
To install and use this module, please refer to the official [Augment developers documentation](https://developers.augment.com/react-native-sdk)
7+
8+
## iOS
9+
Version compatibility:
10+
11+
| Xcode | SDK |
12+
|-------|-----------|
13+
| 10.1 | <= 4.0.17 |
14+
| 10.2 | soon |

android/build.gradle

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
buildscript {
22
repositories {
33
jcenter()
4+
google()
45
}
56
dependencies {
6-
classpath 'com.android.tools.build:gradle:2.3.+'
7+
classpath 'com.android.tools.build:gradle:3.4.0'
78
}
89
}
910

1011
allprojects {
1112
repositories {
1213
jcenter()
14+
google()
1315
maven {
1416
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
1517
url "$rootDir/../node_modules/react-native/android"
@@ -21,24 +23,30 @@ apply plugin: 'com.android.library'
2123

2224
repositories {
2325
mavenCentral()
26+
mavenLocal()
27+
google()
2428
maven { url "https://dl.bintray.com/augment/augment" }
2529
}
2630

2731
android {
28-
compileSdkVersion 26
29-
buildToolsVersion "26.0.1"
32+
compileSdkVersion 28
33+
34+
compileOptions {
35+
sourceCompatibility 1.8
36+
targetCompatibility 1.8
37+
}
3038

3139
defaultConfig {
32-
minSdkVersion 16
33-
targetSdkVersion 22
40+
minSdkVersion 24
41+
targetSdkVersion 28
3442
versionCode 1
3543
versionName "1.0"
3644
}
3745
}
3846

3947
dependencies {
40-
compile "com.facebook.react:react-native:+"
41-
compile "com.google.zxing:core:3.2.1"
42-
compile "com.drewnoakes:metadata-extractor:2.9.1"
43-
compile "com.ar.augment:augment-player-sdk:1.0.3"
48+
implementation "com.facebook.react:react-native:+"
49+
implementation "com.google.zxing:core:3.2.1"
50+
implementation "com.drewnoakes:metadata-extractor:2.9.1"
51+
implementation "com.ar.augment:augment-player-sdk:2.0.0-alpha2"
4452
}

android/gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
android.useAndroidX=true
2+
android.enableJetifier=true

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

android/src/main/java/com/augment/reactplugin/AugmentReact.java

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

android/src/main/java/com/augment/reactplugin/AugmentReactPackage.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,29 @@
55
import com.facebook.react.bridge.ReactApplicationContext;
66
import com.facebook.react.uimanager.ViewManager;
77

8-
import java.util.Collections;
8+
import java.util.ArrayList;
99
import java.util.List;
1010

11+
import javax.annotation.Nonnull;
12+
1113
public class AugmentReactPackage implements ReactPackage {
1214

15+
private RNAugmentPlayerManager rnAugmentPlayerManager = new RNAugmentPlayerManager();
16+
17+
@Nonnull
1318
@Override
14-
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
15-
return Collections.<NativeModule>singletonList(
16-
new AugmentReact(reactContext)
17-
);
19+
public List<NativeModule> createNativeModules(@Nonnull final ReactApplicationContext reactContext) {
20+
return new ArrayList<NativeModule>() {{
21+
add(new RNAugmentPlayerSDK(reactContext));
22+
add(rnAugmentPlayerManager);
23+
}};
1824
}
1925

26+
@Nonnull
2027
@Override
21-
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
22-
return Collections.EMPTY_LIST;
28+
public List<ViewManager> createViewManagers(@Nonnull ReactApplicationContext reactContext) {
29+
return new ArrayList<ViewManager>() {{
30+
add(rnAugmentPlayerManager);
31+
}};
2332
}
2433
}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
package com.augment.reactplugin;
2+
3+
import android.content.Context;
4+
import android.util.AttributeSet;
5+
import android.view.View;
6+
import android.view.ViewGroup;
7+
import android.widget.FrameLayout;
8+
9+
import androidx.fragment.app.FragmentManager;
10+
11+
import com.ar.augment.arplayer.model.Product;
12+
import com.ar.augment.arplayer.sdk.AugmentPlayer;
13+
import com.ar.augment.arplayer.sdk.AugmentPlayerFragment;
14+
import com.ar.augment.arplayer.sdk.AugmentSDK;
15+
import com.ar.augment.arplayer.sdk.TrackingStatus;
16+
import com.facebook.react.ReactActivity;
17+
import com.facebook.react.bridge.Arguments;
18+
import com.facebook.react.bridge.Promise;
19+
import com.facebook.react.bridge.ReactContext;
20+
import com.facebook.react.bridge.ReadableMap;
21+
import com.facebook.react.bridge.WritableMap;
22+
import com.facebook.react.uimanager.events.RCTEventEmitter;
23+
24+
import kotlin.Unit;
25+
26+
public class RNAugmentPlayer extends FrameLayout {
27+
private static final String AUGMENT_FRAGMENT_TAG = "AUGMENT_FRAGMENT_TAG";
28+
private AugmentPlayer augmentPlayer;
29+
30+
public RNAugmentPlayer(Context context) {
31+
super(context);
32+
}
33+
34+
public RNAugmentPlayer(Context context, AttributeSet attrs) {
35+
super(context, attrs);
36+
}
37+
38+
public RNAugmentPlayer(Context context, AttributeSet attrs, int defStyleAttr) {
39+
super(context, attrs, defStyleAttr);
40+
}
41+
42+
public void onReceiveNativeEvent(RNAugmentPlayerEvent event, WritableMap parametersMap) {
43+
ReactContext reactContext = (ReactContext) getContext();
44+
RCTEventEmitter eventEmitter = reactContext.getJSModule(RCTEventEmitter.class);
45+
eventEmitter.receiveEvent(
46+
getId(),
47+
event.toString(),
48+
parametersMap);
49+
}
50+
51+
void createFragment(ReactContext context) {
52+
AugmentPlayerFragment fragment = new AugmentPlayerFragment();
53+
ReactActivity activity = (ReactActivity) context.getCurrentActivity();
54+
activity.getSupportFragmentManager()
55+
.beginTransaction()
56+
.add(fragment, AUGMENT_FRAGMENT_TAG)
57+
.commitNow();
58+
addView(fragment.getView(), 0);
59+
augmentPlayer = fragment.getAugmentPlayer();
60+
augmentPlayer.setTrackingStatusListener((trackingStatus, reason) -> {
61+
WritableMap paramsMap = Arguments.createMap();
62+
paramsMap.putString("status",
63+
// LIMITED_INSUFFICIENT_LIGHT doesn't exist on ios
64+
trackingStatus == TrackingStatus.LIMITED_INSUFFICIENT_LIGHT ?
65+
TrackingStatus.LIMITED_INSUFFICIENT_FEATURES.toString() :
66+
trackingStatus.name());
67+
paramsMap.putString("message", reason);
68+
onReceiveNativeEvent(RNAugmentPlayerEvent.onTrackingStatusChanged, paramsMap);
69+
});
70+
augmentPlayer.getViews().createLiveViewer(() -> {
71+
onReceiveNativeEvent(RNAugmentPlayerEvent.onPlayerReady, null);
72+
onReceiveNativeEvent(RNAugmentPlayerEvent.onLoadingDidFinish, null);
73+
ViewGroup view = (ViewGroup) fragment.getView();
74+
for (int i = 0; i < view.getChildCount(); i++) {
75+
View child = view.getChildAt(i);
76+
child.measure(
77+
View.MeasureSpec.makeMeasureSpec(getMeasuredWidth(), View.MeasureSpec.EXACTLY),
78+
View.MeasureSpec.makeMeasureSpec(getMeasuredHeight(), View.MeasureSpec.EXACTLY));
79+
child.layout(0, 0, child.getMeasuredWidth(), child.getMeasuredHeight());
80+
}
81+
return Unit.INSTANCE;
82+
});
83+
}
84+
85+
void removeFragment(RNAugmentPlayer view) {
86+
ReactActivity activity = (ReactActivity) ((ReactContext) getContext()).getCurrentActivity();
87+
FragmentManager supportFragmentManager = activity.getSupportFragmentManager();
88+
view.removeAllViews();
89+
AugmentPlayerFragment fragment = (AugmentPlayerFragment) supportFragmentManager.findFragmentByTag(AUGMENT_FRAGMENT_TAG);
90+
augmentPlayer.setTrackingStatusListener(null);
91+
fragment.getAugmentPlayer().getViews().destroyCurrentViewer();
92+
supportFragmentManager
93+
.beginTransaction()
94+
.detach(fragment)
95+
.remove(fragment)
96+
.commit();
97+
}
98+
99+
public void addProduct(ReadableMap productMap, Promise promise) {
100+
Product product = AugmentSDK.getInstance().getProductsDataController().getProduct(productMap.getString(RNAugmentPlayerProductKeys.IDENTIFIER));
101+
if (augmentPlayer != null) {
102+
((ReactContext) getContext()).getCurrentActivity().runOnUiThread(() ->
103+
augmentPlayer.getContent().add(product.getModel3D(), (model3DInstance, error) -> {
104+
if (error != null) {
105+
promise.reject("500", error.getMessage());
106+
}
107+
if (model3DInstance != null) {
108+
promise.resolve(null);
109+
}
110+
return Unit.INSTANCE;
111+
}));
112+
}
113+
}
114+
115+
public void takeScreenshot(Promise promise) {
116+
// augmentPlayer.takeScreenshot((bytes, error) -> {
117+
// if (error != null) {
118+
// promise.reject("500", error.getMessage());
119+
// }
120+
// promise.resolve(image's path);
121+
// return Unit.INSTANCE;
122+
// });
123+
promise.reject("500", "Not Available");
124+
}
125+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.augment.reactplugin;
2+
3+
public enum RNAugmentPlayerEvent {
4+
onPlayerReady,
5+
onInitializationFailed,
6+
onLoadingProgressDidChange,
7+
onLoadingDidFinish,
8+
onTrackingStatusChanged,
9+
onModelGesture
10+
}

0 commit comments

Comments
 (0)