mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-31 17:32:51 +08:00
CB-13800: (android) Drop pre-KitKat specific code
This commit is contained in:
parent
6cc4896690
commit
075d38117a
@ -123,7 +123,7 @@ public class CordovaActivity extends Activity {
|
|||||||
if (preferences.getBoolean("Fullscreen", false)) {
|
if (preferences.getBoolean("Fullscreen", false)) {
|
||||||
// NOTE: use the FullscreenNotImmersive configuration key to set the activity in a REAL full screen
|
// NOTE: use the FullscreenNotImmersive configuration key to set the activity in a REAL full screen
|
||||||
// (as was the case in previous cordova versions)
|
// (as was the case in previous cordova versions)
|
||||||
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) && !preferences.getBoolean("FullscreenNotImmersive", false)) {
|
if (!preferences.getBoolean("FullscreenNotImmersive", false)) {
|
||||||
immersiveMode = true;
|
immersiveMode = true;
|
||||||
} else {
|
} else {
|
||||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||||
|
@ -149,21 +149,6 @@ public class SystemWebChromeClient extends WebChromeClient {
|
|||||||
quotaUpdater.updateQuota(MAX_QUOTA);
|
quotaUpdater.updateQuota(MAX_QUOTA);
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log in api level 7: http://developer.android.com/guide/developing/debug-tasks.html
|
|
||||||
// Expect this to not compile in a future Android release!
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
|
||||||
public void onConsoleMessage(String message, int lineNumber, String sourceID)
|
|
||||||
{
|
|
||||||
//This is only for Android 2.1
|
|
||||||
if(android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.ECLAIR_MR1)
|
|
||||||
{
|
|
||||||
LOG.d(LOG_TAG, "%s: Line %d : %s", sourceID, lineNumber, message);
|
|
||||||
super.onConsoleMessage(message, lineNumber, sourceID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TargetApi(8)
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onConsoleMessage(ConsoleMessage consoleMessage)
|
public boolean onConsoleMessage(ConsoleMessage consoleMessage)
|
||||||
{
|
{
|
||||||
|
@ -112,7 +112,7 @@ public class SystemWebViewClient extends WebViewClient {
|
|||||||
* @param request
|
* @param request
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@TargetApi(21)
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
public void onReceivedClientCertRequest (WebView view, ClientCertRequest request)
|
public void onReceivedClientCertRequest (WebView view, ClientCertRequest request)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -219,7 +219,6 @@ public class SystemWebViewClient extends WebViewClient {
|
|||||||
* @param handler An SslErrorHandler object that will handle the user's response.
|
* @param handler An SslErrorHandler object that will handle the user's response.
|
||||||
* @param error The SSL error object.
|
* @param error The SSL error object.
|
||||||
*/
|
*/
|
||||||
@TargetApi(8)
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
|
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
|
||||||
|
|
||||||
@ -316,7 +315,6 @@ public class SystemWebViewClient extends WebViewClient {
|
|||||||
this.authenticationTokens.clear();
|
this.authenticationTokens.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
|
||||||
@Override
|
@Override
|
||||||
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
|
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
|
||||||
try {
|
try {
|
||||||
@ -349,7 +347,7 @@ public class SystemWebViewClient extends WebViewClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean needsKitKatContentUrlFix(Uri uri) {
|
private static boolean needsKitKatContentUrlFix(Uri uri) {
|
||||||
return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT && "content".equals(uri.getScheme());
|
return "content".equals(uri.getScheme());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean needsSpecialsInAssetUrlFix(Uri uri) {
|
private static boolean needsSpecialsInAssetUrlFix(Uri uri) {
|
||||||
@ -364,11 +362,6 @@ public class SystemWebViewClient extends WebViewClient {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(android.os.Build.VERSION.SDK_INT){
|
|
||||||
case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH:
|
|
||||||
case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,6 @@ public class SystemWebViewEngine implements CordovaWebViewEngine {
|
|||||||
SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r);
|
SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2)
|
|
||||||
nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.EvalBridgeMode(this, cordova));
|
nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.EvalBridgeMode(this, cordova));
|
||||||
bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue);
|
bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue);
|
||||||
exposeJsInterface(webView, bridge);
|
exposeJsInterface(webView, bridge);
|
||||||
@ -153,26 +152,8 @@ public class SystemWebViewEngine implements CordovaWebViewEngine {
|
|||||||
settings.setJavaScriptCanOpenWindowsAutomatically(true);
|
settings.setJavaScriptCanOpenWindowsAutomatically(true);
|
||||||
settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
|
settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
|
||||||
|
|
||||||
// Set the nav dump for HTC 2.x devices (disabling for ICS, deprecated entirely for Jellybean 4.2)
|
|
||||||
try {
|
|
||||||
Method gingerbread_getMethod = WebSettings.class.getMethod("setNavDump", new Class[] { boolean.class });
|
|
||||||
|
|
||||||
String manufacturer = android.os.Build.MANUFACTURER;
|
String manufacturer = android.os.Build.MANUFACTURER;
|
||||||
LOG.d(TAG, "CordovaWebView is running on device made by: " + manufacturer);
|
LOG.d(TAG, "CordovaWebView is running on device made by: " + manufacturer);
|
||||||
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB &&
|
|
||||||
android.os.Build.MANUFACTURER.contains("HTC"))
|
|
||||||
{
|
|
||||||
gingerbread_getMethod.invoke(settings, true);
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
LOG.d(TAG, "We are on a modern version of Android, we will deprecate HTC 2.3 devices in 2.8");
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
LOG.d(TAG, "Doing the NavDump failed with bad arguments");
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
LOG.d(TAG, "This should never happen: IllegalAccessException means this isn't Android anymore");
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
LOG.d(TAG, "This should never happen: InvocationTargetException means this isn't Android anymore.");
|
|
||||||
}
|
|
||||||
|
|
||||||
//We don't save any form data in the application
|
//We don't save any form data in the application
|
||||||
settings.setSaveFormData(false);
|
settings.setSaveFormData(false);
|
||||||
@ -180,12 +161,9 @@ public class SystemWebViewEngine implements CordovaWebViewEngine {
|
|||||||
|
|
||||||
// Jellybean rightfully tried to lock this down. Too bad they didn't give us a whitelist
|
// Jellybean rightfully tried to lock this down. Too bad they didn't give us a whitelist
|
||||||
// while we do this
|
// while we do this
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
|
|
||||||
settings.setAllowUniversalAccessFromFileURLs(true);
|
settings.setAllowUniversalAccessFromFileURLs(true);
|
||||||
}
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
|
||||||
settings.setMediaPlaybackRequiresUserGesture(false);
|
settings.setMediaPlaybackRequiresUserGesture(false);
|
||||||
}
|
|
||||||
// Enable database
|
// Enable database
|
||||||
// We keep this disabled because we use or shim to get around DOM_EXCEPTION_ERROR_16
|
// We keep this disabled because we use or shim to get around DOM_EXCEPTION_ERROR_16
|
||||||
String databasePath = webView.getContext().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
|
String databasePath = webView.getContext().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
|
||||||
@ -195,8 +173,7 @@ public class SystemWebViewEngine implements CordovaWebViewEngine {
|
|||||||
|
|
||||||
//Determine whether we're in debug or release mode, and turn on Debugging!
|
//Determine whether we're in debug or release mode, and turn on Debugging!
|
||||||
ApplicationInfo appInfo = webView.getContext().getApplicationContext().getApplicationInfo();
|
ApplicationInfo appInfo = webView.getContext().getApplicationContext().getApplicationInfo();
|
||||||
if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0 &&
|
if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
|
||||||
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
|
|
||||||
enableRemoteDebugging();
|
enableRemoteDebugging();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +221,6 @@ public class SystemWebViewEngine implements CordovaWebViewEngine {
|
|||||||
// end CB-1405
|
// end CB-1405
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
|
||||||
private void enableRemoteDebugging() {
|
private void enableRemoteDebugging() {
|
||||||
try {
|
try {
|
||||||
WebView.setWebContentsDebuggingEnabled(true);
|
WebView.setWebContentsDebuggingEnabled(true);
|
||||||
@ -254,17 +230,9 @@ public class SystemWebViewEngine implements CordovaWebViewEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Yeah, we know, which is why we makes ure that we don't do this if the bridge is
|
// Yeah, we know. It'd be great if lint was just a little smarter.
|
||||||
// below JELLYBEAN_MR1. It'd be great if lint was just a little smarter.
|
|
||||||
@SuppressLint("AddJavascriptInterface")
|
@SuppressLint("AddJavascriptInterface")
|
||||||
private static void exposeJsInterface(WebView webView, CordovaBridge bridge) {
|
private static void exposeJsInterface(WebView webView, CordovaBridge bridge) {
|
||||||
if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)) {
|
|
||||||
LOG.i(TAG, "Disabled addJavascriptInterface() bridge since Android version is old.");
|
|
||||||
// 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
|
|
||||||
// use the prompt bridge instead.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SystemExposedJsApi exposedJsApi = new SystemExposedJsApi(bridge);
|
SystemExposedJsApi exposedJsApi = new SystemExposedJsApi(bridge);
|
||||||
webView.addJavascriptInterface(exposedJsApi, "_cordovaNative");
|
webView.addJavascriptInterface(exposedJsApi, "_cordovaNative");
|
||||||
}
|
}
|
||||||
@ -346,12 +314,6 @@ public class SystemWebViewEngine implements CordovaWebViewEngine {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluateJavascript(String js, ValueCallback<String> callback) {
|
public void evaluateJavascript(String js, ValueCallback<String> callback) {
|
||||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
|
||||||
webView.evaluateJavascript(js, callback);
|
webView.evaluateJavascript(js, callback);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG.d(TAG, "This webview is using the old bridge");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user