Skip to content

Commit

Permalink
Merge pull request #58 from Wikitude/Integration_4_0_2
Browse files Browse the repository at this point in the history
Integrates the Wikitude SDK 4.0.2 into the Wikitude PhoneGap Plugin.
  • Loading branch information
AndreasSchacherbauerWikitude committed Oct 14, 2014
2 parents 362cb6f + 879f109 commit 32ead73
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 91 deletions.
3 changes: 2 additions & 1 deletion plugin.xml
Expand Up @@ -100,6 +100,7 @@
<source-file src="src/ios/WTARViewController.m" />

<header-file src="src/ios/WTArchitectView.h" />
<header-file src="src/ios/WTNavigation.h" />
<source-file src="src/ios/libWikitudeSDK.a" framework="true" />


Expand Down Expand Up @@ -138,7 +139,7 @@
<info>
Have fun using world's first AR plugin for PhoneGap. Visit http://developer.wikitude.com/documentation/phonegap for technical support.

Make sure that you enter your Wikitude SDK license key in `WikitudePlugin.js` line 12. If you havent bought a license please visit http://www.wikitude.com/store.
Make sure that you enter your Wikitude SDK license key in `WikitudePlugin.js` line 53. If you havent bought a license please visit http://www.wikitude.com/store.

If you want to contribute to the open source project, please visit us at github, http://github.com/Wikitude
</info>
Expand Down
27 changes: 19 additions & 8 deletions src/android/WikitudePlugin.java
Expand Up @@ -35,6 +35,7 @@
import android.widget.Toast;

import com.wikitude.architect.ArchitectView;
import com.wikitude.architect.ArchitectView.ARMode;
import com.wikitude.architect.ArchitectView.ArchitectConfig;
import com.wikitude.architect.ArchitectView.ArchitectUrlListener;
import com.wikitude.architect.ArchitectView.CaptureScreenCallback;
Expand Down Expand Up @@ -224,16 +225,21 @@ public void run() {
@Override
public void onScreenCaptured(Bitmap screenCapture) {
final File screenCaptureFile;
final String name = System.currentTimeMillis() + ".jpg";
try {
if (fileName.equals("")) {
final File imageDirectory = Environment.getExternalStorageDirectory();
if (imageDirectory == null) {
callContext.error("External storage not available");
}
String name = System.currentTimeMillis() + ".jpg";
screenCaptureFile = new File (imageDirectory, name);
} else {
screenCaptureFile = new File (fileName);
File screenCapturePath = new File (fileName);
if (screenCapturePath.isDirectory()) {
screenCaptureFile = new File (screenCapturePath, name);
} else {
screenCaptureFile = screenCapturePath;
}
}
if (screenCaptureFile.exists()) {
screenCaptureFile.delete();
Expand Down Expand Up @@ -452,7 +458,7 @@ public void run() {
@Override
public void run() {
try {
WikitudePlugin.this.addArchitectView( apiKey, filePath );
WikitudePlugin.this.addArchitectView( apiKey, filePath, arMode );

/* call success method once architectView was added successfully */
if ( openCallback != null ) {
Expand Down Expand Up @@ -570,11 +576,16 @@ private static int clearCacheFolder( final File dir, final int numDays ) {
/**
* Architect-Configuration required for proper set-up
* @param apiKey
* @param arMode
* @return
*/
protected ArchitectConfig getArchitectConfig( final String apiKey ) {
protected ArchitectConfig getArchitectConfig( final String apiKey, String arMode ) {
/* no special set-up required in default Wikitude-Plugin, further things required in advanced usage (e.g. Vuforia Image Recognition) */
ArchitectConfig config = new ArchitectConfig( apiKey );
ArchitectConfig config = new ArchitectConfig( apiKey,
arMode.equals("IR") ? ARMode.IR :
arMode.equals("Geo") ? ARMode.GEO :
ARMode.GEO | ARMode.IR
);
config.setOrigin( ArchitectConfig.ORIGIN_PHONEGAP );
return config;
}
Expand All @@ -583,14 +594,14 @@ protected ArchitectConfig getArchitectConfig( final String apiKey ) {
* add architectView to current screen
* @param apiKey developers's api key to use (hides watermarking/intro-animation if it matches your package-name)
* @param filePath the url (starting with http:// for online use; starting with LOCAL_ASSETS_PATH_ROOT if oyu want to load assets within your app-assets folder)
* @param arMode Augmented Reality mode ()
* @throws IOException might be thrown from ARchitect-SDK
*/
private void addArchitectView( final String apiKey, String filePath ) throws IOException {
private void addArchitectView( final String apiKey, String filePath, String arMode ) throws IOException {
if ( this.architectView == null ) {

WikitudePlugin.releaseFocusInCordovaWebView(cordova.getActivity().getWindow().getDecorView().findViewById(android.R.id.content));


this.architectView = new ArchitectViewPhoneGap( this.cordova.getActivity() , new OnKeyUpDownListener() {

@Override
Expand Down Expand Up @@ -647,7 +658,7 @@ public void onLocationChanged( final Location location ) {


/* fake life-cycle calls, because activity is already up and running */
this.architectView.onCreate( getArchitectConfig( apiKey ) );
this.architectView.onCreate( getArchitectConfig( apiKey, arMode ) );
this.architectView.onPostCreate();

/* register self as url listener to fwd these native calls to PhoneGap */
Expand Down
2 changes: 1 addition & 1 deletion src/ios/WTARViewController.h
Expand Up @@ -41,6 +41,6 @@ extern NSString * const WTArchitectNotificationErrorKey;
+ (BOOL)isDeviceSupportedForAugmentedRealityMode:(WTAugmentedRealityMode)augmentedRealityMode;


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil motionManager:(CMMotionManager *)motionManagerOrNil augmentedRealityMode:(WTAugmentedRealityMode)augmentedRealityMode;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil motionManager:(CMMotionManager *)motionManagerOrNil;

@end
4 changes: 2 additions & 2 deletions src/ios/WTARViewController.m
Expand Up @@ -36,13 +36,13 @@ + (BOOL)isDeviceSupportedForAugmentedRealityMode:(WTAugmentedRealityMode)augment
}


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil motionManager:(CMMotionManager *)motionManagerOrNil augmentedRealityMode:(WTAugmentedRealityMode)augmentedRealityMode;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil motionManager:(CMMotionManager *)motionManagerOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization

self.architectView = [[WTArchitectView alloc] initWithFrame:[[UIScreen mainScreen] bounds] motionManager:motionManagerOrNil augmentedRealityMode:augmentedRealityMode];
self.architectView = [[WTArchitectView alloc] initWithFrame:[[UIScreen mainScreen] bounds] motionManager:motionManagerOrNil];
self.architectView.delegate = self;

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceivedDeviceWillResignActiveNotification:) name:UIApplicationWillResignActiveNotification object:nil];
Expand Down

0 comments on commit 32ead73

Please sign in to comment.