Skip to content

Commit

Permalink
Merge pull request #108 from Wikitude/release/5_1_3
Browse files Browse the repository at this point in the history
updated to SDK version 5.1.3
  • Loading branch information
danielguttenberg committed Mar 7, 2016
2 parents 13e635d + 467f14a commit 9058214
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 169 deletions.
16 changes: 11 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# PhoneGap Plugin Release Notes
## Plugin 3.2.1 (SDK 5.1.1)
### PhoneGap Plugin 5.1.1-3.2.1
Release Date: 12.01.16
## Plugin 3.2.1 (SDK 5.1.3)
### PhoneGap Plugin 5.1.3-3.2.1
Release Date: 25.02.2016
#### New
- Integrates Wikitude SDK 5.1.1 for Android and iOS (see detailed release notes for <a href="http://www.wikitude.com/developer/documentation/android" target="_top">Android</a> and <a href="http://www.wikitude.com/developer/documentation/ios" target="_top">iOS</a>)

- Integrates Wikitude SDK 5.1.3 for Android and iOS (see detailed release notes for <a href="http://www.wikitude.com/developer/documentation/android" target="_top">Android</a> and <a href="http://www.wikitude.com/developer/documentation/ios" target="_top">iOS</a>)

## Plugin 3.2.1 (SDK 5.1.2)
### PhoneGap Plugin 5.1.2-3.2.1
Release Date: 09.03.15
#### New
- Integrates Wikitude SDK 5.1.2 for Android and iOS (see detailed release notes for <a href="http://www.wikitude.com/developer/documentation/android" target="_top">Android</a> and <a href="http://www.wikitude.com/developer/documentation/ios" target="_top">iOS</a>)
-
## Plugin 3.0.0 (SDK 4.1.0)
### PhoneGap Plugin 4.1.0-3.0.0
Release Date: 09.03.15
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The Wikitude Plugin is under Apache 2.0 license (see below), where the Wikitude


```
Copyright 2012-2015 Wikitude GmbH, http://www.wikitude.com
Copyright 2012-2016 Wikitude GmbH, http://www.wikitude.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
7 changes: 3 additions & 4 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="com.wikitude.phonegap.WikitudePlugin"
version="5.1.1">
version="5.1.3">

<name>Augmented Reality - Wikitude SDK Plugin</name>

Expand All @@ -15,7 +15,7 @@

<repo>https://github.com/Wikitude/wikitude-phonegap.git</repo>

<license>(c) 2015 Wikitude GmbH - see License.md for details of the license</license>
<license>(c) 2016 Wikitude GmbH - see License.md for details of the license</license>


<engines>
Expand Down Expand Up @@ -106,11 +106,10 @@
<header-file src="src/ios/WTNavigation.h" />
<header-file src="src/ios/WTStartupConfiguration.h" />
<header-file src="src/ios/WTArchitectViewDebugDelegate.h" />
<header-file src="src/ios/WTArchitectView+Plugins.h" />
<header-file src="src/ios/WTWikitudeTypes.h" />

<source-file src="src/ios/libWikitudeSDK.a" framework="true" />
<source-file src="src/ios/libWikitudeSDK_simulator.a" framework="true" />
<source-file src="src/ios/libWikitudeSDK-simulator.a" framework="true" />


<!-- Additional WikitudePlugin libraries and frameworks -->
Expand Down
140 changes: 56 additions & 84 deletions src/android/WikitudePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ public class WikitudePlugin extends CordovaPlugin implements ArchitectUrlListene

private static final int LOCATION_PERMISSION_REQUEST_CODE = 2;

private static final int WRITE_TO_EXTERNAL_STORAGE_REQUEST_CODE = 3;

/**
* the Wikitude ARchitectview
*/
Expand All @@ -149,11 +147,6 @@ public class WikitudePlugin extends CordovaPlugin implements ArchitectUrlListene
*/
private CallbackContext openCallback = null;

/**
* callback-id for capture screen
*/
private CallbackContext captureScreenCallbackContext = null;

/**
* last known location of the user, used internally for content-loading after user location was fetched
*/
Expand All @@ -179,9 +172,6 @@ public class WikitudePlugin extends CordovaPlugin implements ArchitectUrlListene
private JSONArray openArgs;
private String action;

private String screenCaptureName;
private Bitmap screenCapture;


@Override
public boolean execute( final String action, final JSONArray args, final CallbackContext callContext ) {
Expand Down Expand Up @@ -234,9 +224,7 @@ public void run() {
if (WikitudePlugin.ACTION_CAPTURE_SCREEN.equals(action) ) {
if (architectView!=null) {

WikitudePlugin.this.captureScreenCallbackContext = callContext;

int captureMode = ArchitectView.CaptureScreenCallback.CAPTURE_MODE_CAM_AND_WEBVIEW;
int captureMode = ArchitectView.CaptureScreenCallback.CAPTURE_MODE_CAM_AND_WEBVIEW;

try {
captureMode = ( args.getBoolean( 0 )) ? ArchitectView.CaptureScreenCallback.CAPTURE_MODE_CAM_AND_WEBVIEW : ArchitectView.CaptureScreenCallback.CAPTURE_MODE_CAM;
Expand All @@ -253,19 +241,64 @@ public void run() {
}
}

WikitudePlugin.this.screenCaptureName = name;
final String fileName = name;

architectView.captureScreen(captureMode, new CaptureScreenCallback() {

@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");
}
screenCaptureFile = new File (imageDirectory, name);
} else {
File screenCapturePath = new File (fileName);
if (screenCapturePath.isDirectory()) {
screenCaptureFile = new File (screenCapturePath, name);
} else {
screenCaptureFile = screenCapturePath;
}
}
if (screenCaptureFile.exists()) {
screenCaptureFile.delete();
}
final FileOutputStream out = new FileOutputStream(screenCaptureFile);
screenCapture.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();

ContentValues values = new ContentValues();
values.put(Images.Media.DATE_TAKEN, System.currentTimeMillis());
values.put(Images.Media.MIME_TYPE, "image/jpeg");
values.put(MediaStore.MediaColumns.DATA, screenCaptureFile.getAbsolutePath());

Context context= cordova.getActivity().getApplicationContext();
context.getContentResolver().insert(Images.Media.EXTERNAL_CONTENT_URI, values);

cordova.getActivity().runOnUiThread(new Runnable() {

@Override
public void run() {
final String absoluteCaptureImagePath = screenCaptureFile.getAbsolutePath();
callContext.success(absoluteCaptureImagePath);

// in case you want to sent the pic to other applications, uncomment these lines (for future use)
// final Intent share = new Intent(Intent.ACTION_SEND);
// share.setType("image/jpg");
// share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(screenCaptureFile));
// final String chooserTitle = "Share Snaphot";
// cordova.getActivity().startActivity(Intent.createChooser(share, chooserTitle));
}
});
} catch (Exception e) {
callContext.error(e.getMessage());
}

if ( !cordova.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) ) {
WikitudePlugin.this.screenCapture = screenCapture;
WikitudePlugin.this.cordova.requestPermission(WikitudePlugin.this, WRITE_TO_EXTERNAL_STORAGE_REQUEST_CODE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
} else {
WikitudePlugin.this.saveScreenCapture(screenCapture);
}
}
});
return true;
Expand Down Expand Up @@ -758,7 +791,7 @@ public void onLocationChanged( final Location location ) {
InputMethodManager inputManager = (InputMethodManager)
(this.cordova.getActivity()).getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow((this.cordova.getActivity()).getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
InputMethodManager.HIDE_NOT_ALWAYS);
}


Expand All @@ -784,66 +817,11 @@ private static void handleResumeInCordovaWebView(final View rootView) {
else if (rootView instanceof ViewGroup) {
final int childCount = ((ViewGroup)rootView).getChildCount();
for (int i=0; i< childCount; i++) {
WikitudePlugin.handleResumeInCordovaWebView(((ViewGroup) rootView).getChildAt(i));
WikitudePlugin.handleResumeInCordovaWebView(((ViewGroup)rootView).getChildAt(i));
}
}
}

private void saveScreenCapture(Bitmap screenCapture) {

final File screenCaptureFile;
final String name = System.currentTimeMillis() + ".jpg";
try {
if (WikitudePlugin.this.screenCaptureName .equals("")) {
final File imageDirectory = Environment.getExternalStorageDirectory();
if (imageDirectory == null) {
WikitudePlugin.this.captureScreenCallbackContext.error("External storage not available");
}
screenCaptureFile = new File (imageDirectory, name);
} else {
File screenCapturePath = new File (WikitudePlugin.this.screenCaptureName);
if (screenCapturePath.isDirectory()) {
screenCaptureFile = new File (screenCapturePath, name);
} else {
screenCaptureFile = screenCapturePath;
}
}
if (screenCaptureFile.exists()) {
screenCaptureFile.delete();
}
final FileOutputStream out = new FileOutputStream(screenCaptureFile);
screenCapture.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();

ContentValues values = new ContentValues();
values.put(Images.Media.DATE_TAKEN, System.currentTimeMillis());
values.put(Images.Media.MIME_TYPE, "image/jpeg");
values.put(MediaStore.MediaColumns.DATA, screenCaptureFile.getAbsolutePath());

Context context= cordova.getActivity().getApplicationContext();
context.getContentResolver().insert(Images.Media.EXTERNAL_CONTENT_URI, values);

cordova.getActivity().runOnUiThread(new Runnable() {

@Override
public void run() {
final String absoluteCaptureImagePath = screenCaptureFile.getAbsolutePath();
WikitudePlugin.this.captureScreenCallbackContext.success(absoluteCaptureImagePath);

// in case you want to sent the pic to other applications, uncomment these lines (for future use)
// final Intent share = new Intent(Intent.ACTION_SEND);
// share.setType("image/jpg");
// share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(screenCaptureFile));
// final String chooserTitle = "Share Snaphot";
// cordova.getActivity().startActivity(Intent.createChooser(share, chooserTitle));
}
});
} catch (Exception e) {
WikitudePlugin.this.captureScreenCallbackContext.error(e.getMessage());
}
}


protected static class ArchitectViewPhoneGap extends ArchitectView {
public static interface OnKeyUpDownListener {
Expand Down Expand Up @@ -1017,13 +995,7 @@ public void onRequestPermissionResult(int requestCode, String[] permissions, int
} else {
this.openCallback.error("Location permission wasn't granted");
}
} else if ( permission.equals(Manifest.permission.WRITE_EXTERNAL_STORAGE) ) {
if (grantResults.length > 0 && grantResults[i] == PackageManager.PERMISSION_GRANTED) {
WikitudePlugin.this.saveScreenCapture(WikitudePlugin.this.screenCapture);
} else {
WikitudePlugin.this.captureScreenCallbackContext.error("External storage permission wasn't granted");
}
}
}
}
}
}

0 comments on commit 9058214

Please sign in to comment.