You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2012/09/18 04:12:09 UTC
[7/25] android commit: CB-1405: navigator.language
CB-1405: navigator.language
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/eb49e011
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/eb49e011
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/eb49e011
Branch: refs/heads/master
Commit: eb49e011e263104672e7c02197442655534f7cb1
Parents: e0a73f7
Author: Simon MacDonald <si...@gmail.com>
Authored: Mon Sep 10 17:41:52 2012 -0400
Committer: Simon MacDonald <si...@gmail.com>
Committed: Mon Sep 17 22:09:51 2012 -0400
----------------------------------------------------------------------
.../src/org/apache/cordova/CordovaWebView.java | 38 ++++++++++++++-
1 files changed, 37 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/eb49e011/framework/src/org/apache/cordova/CordovaWebView.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java
index 5c43cc9..c9631bd 100755
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@ -36,9 +36,13 @@ import org.xmlpull.v1.XmlPullParserException;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
+import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.content.res.XmlResourceParser;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@@ -63,6 +67,8 @@ public class CordovaWebView extends WebView {
public PluginManager pluginManager;
public CallbackServer callbackServer;
private boolean paused;
+
+ private BroadcastReceiver receiver;
/** Activities and other important classes **/
@@ -229,7 +235,24 @@ public class CordovaWebView extends WebView {
// Enable built-in geolocation
settings.setGeolocationEnabled(true);
-
+
+ // Fix for CB-1405
+ // Google issue 4641
+ this.updateUserAgentString();
+
+ IntentFilter intentFilter = new IntentFilter();
+ intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
+ if (this.receiver == null) {
+ this.receiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ updateUserAgentString();
+ }
+ };
+ this.cordova.getActivity().registerReceiver(this.receiver, intentFilter);
+ }
+ // end CB-1405
+
//Start up the plugin manager
try {
this.pluginManager = new PluginManager(this, this.cordova);
@@ -239,6 +262,10 @@ public class CordovaWebView extends WebView {
}
exposeJsInterface();
}
+
+ private void updateUserAgentString() {
+ this.getSettings().getUserAgentString();
+ }
private void exposeJsInterface() {
// addJavascriptInterface crashes on the 2.3 emulator.
@@ -873,6 +900,15 @@ public class CordovaWebView extends WebView {
if (this.pluginManager != null) {
this.pluginManager.onDestroy();
}
+
+ // unregister the receiver
+ if (this.receiver != null) {
+ try {
+ this.cordova.getActivity().unregisterReceiver(this.receiver);
+ } catch (Exception e) {
+ Log.e(TAG, "Error unregistering configuration receiver: " + e.getMessage(), e);
+ }
+ }
}
public void onNewIntent(Intent intent)