forked from github/cordova-android
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-cordova-android
This commit is contained in:
commit
70473a80af
@ -274,13 +274,15 @@ public class CordovaWebView extends WebView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void exposeJsInterface() {
|
private void exposeJsInterface() {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
|
int SDK_INT = Build.VERSION.SDK_INT;
|
||||||
|
boolean isHoneycomb = (SDK_INT >= Build.VERSION_CODES.HONEYCOMB && SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR2);
|
||||||
|
if (isHoneycomb || (SDK_INT < Build.VERSION_CODES.GINGERBREAD)) {
|
||||||
Log.i(TAG, "Disabled addJavascriptInterface() bridge since Android version is old.");
|
Log.i(TAG, "Disabled addJavascriptInterface() bridge since Android version is old.");
|
||||||
// Bug being that Java Strings do not get converted to JS strings automatically.
|
// Bug being that Java Strings do not get converted to JS strings automatically.
|
||||||
// This isn't hard to work-around on the JS side, but it's easier to just
|
// This isn't hard to work-around on the JS side, but it's easier to just
|
||||||
// use the prompt bridge instead.
|
// use the prompt bridge instead.
|
||||||
return;
|
return;
|
||||||
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB && Build.MANUFACTURER.equals("unknown")) {
|
} else if (SDK_INT < Build.VERSION_CODES.HONEYCOMB && Build.MANUFACTURER.equals("unknown")) {
|
||||||
// addJavascriptInterface crashes on the 2.3 emulator.
|
// addJavascriptInterface crashes on the 2.3 emulator.
|
||||||
Log.i(TAG, "Disabled addJavascriptInterface() bridge callback due to a bug on the 2.3 emulator");
|
Log.i(TAG, "Disabled addJavascriptInterface() bridge callback due to a bug on the 2.3 emulator");
|
||||||
return;
|
return;
|
||||||
|
@ -984,8 +984,16 @@ public class FileUtils extends CordovaPlugin {
|
|||||||
* @return a mime type
|
* @return a mime type
|
||||||
*/
|
*/
|
||||||
public static String getMimeType(String filename) {
|
public static String getMimeType(String filename) {
|
||||||
|
// Stupid bug in getFileExtensionFromUrl when the file name has a space
|
||||||
|
// So we need to replace the space with a url encoded %20
|
||||||
|
String url = filename.replace(" ", "%20");
|
||||||
MimeTypeMap map = MimeTypeMap.getSingleton();
|
MimeTypeMap map = MimeTypeMap.getSingleton();
|
||||||
return map.getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(filename));
|
String extension = MimeTypeMap.getFileExtensionFromUrl(url);
|
||||||
|
if (extension.toLowerCase().equals("3ga")) {
|
||||||
|
return "audio/3gpp";
|
||||||
|
} else {
|
||||||
|
return map.getMimeTypeFromExtension(extension);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1069,16 +1077,18 @@ public class FileUtils extends CordovaPlugin {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
protected static String getRealPathFromURI(Uri contentUri, CordovaInterface cordova) {
|
protected static String getRealPathFromURI(Uri contentUri, CordovaInterface cordova) {
|
||||||
String uri = contentUri.toString();
|
final String scheme = contentUri.getScheme();
|
||||||
if (uri.startsWith("content:")) {
|
|
||||||
|
if (scheme.compareTo("content") == 0) {
|
||||||
String[] proj = { _DATA };
|
String[] proj = { _DATA };
|
||||||
Cursor cursor = cordova.getActivity().managedQuery(contentUri, proj, null, null, null);
|
Cursor cursor = cordova.getActivity().managedQuery(contentUri, proj, null, null, null);
|
||||||
int column_index = cursor.getColumnIndexOrThrow(_DATA);
|
int column_index = cursor.getColumnIndexOrThrow(_DATA);
|
||||||
cursor.moveToFirst();
|
cursor.moveToFirst();
|
||||||
return cursor.getString(column_index);
|
return cursor.getString(column_index);
|
||||||
|
} else if (scheme.compareTo("file") == 0) {
|
||||||
|
return contentUri.getPath();
|
||||||
} else {
|
} else {
|
||||||
return uri;
|
return contentUri.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user