You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2015/12/04 09:41:11 UTC
cordova-plugin-contacts git commit: CB-10053 Accept assets URIs for
contact photos
Repository: cordova-plugin-contacts
Updated Branches:
refs/heads/master fe6ce1db5 -> 07f7784ce
CB-10053 Accept assets URIs for contact photos
This fixes #94 and closes #77
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/commit/07f7784c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/tree/07f7784c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/diff/07f7784c
Branch: refs/heads/master
Commit: 07f7784ce4abf4e385b2166f86543cf309c6a8e1
Parents: fe6ce1d
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Fri Dec 4 10:58:30 2015 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Fri Dec 4 11:40:13 2015 +0300
----------------------------------------------------------------------
src/android/ContactAccessorSdk5.java | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/07f7784c/src/android/ContactAccessorSdk5.java
----------------------------------------------------------------------
diff --git a/src/android/ContactAccessorSdk5.java b/src/android/ContactAccessorSdk5.java
index d2d44b5..9a82cfe 100644
--- a/src/android/ContactAccessorSdk5.java
+++ b/src/android/ContactAccessorSdk5.java
@@ -84,6 +84,8 @@ public class ContactAccessorSdk5 extends ContactAccessor {
private static final String EMAIL_REGEXP = ".+@.+\\.+.+"; /* <anything>@<anything>.<anything>*/
+ private static final String ASSET_URL_PREFIX = "file:///android_asset/";
+
/**
* A static map that converts the JavaScript property name to Android database column name.
*/
@@ -1635,24 +1637,29 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
/**
- * Get an input stream based on file path or uri content://, http://, file://
- *
- * @param path
- * @return an input stream
+ * Get an input stream based on file path or uri content://, http://, file://
+ *
+ * @param path path to file
+ * @return an input stream
* @throws IOException
- */
+ */
private InputStream getPathFromUri(String path) throws IOException {
if (path.startsWith("content:")) {
Uri uri = Uri.parse(path);
return mApp.getActivity().getContentResolver().openInputStream(uri);
}
+
+ if (path.startsWith(ASSET_URL_PREFIX)) {
+ String assetRelativePath = path.replace(ASSET_URL_PREFIX, "");
+ return mApp.getActivity().getAssets().open(assetRelativePath);
+ }
+
if (path.startsWith("http:") || path.startsWith("https:") || path.startsWith("file:")) {
URL url = new URL(path);
return url.openStream();
}
- else {
- return new FileInputStream(path);
- }
+
+ return new FileInputStream(path);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org