cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject android commit: CB-7085 Add onConfigurationChanged hook for plugins (close #165)
Date Tue, 24 Mar 2015 17:36:44 GMT
Repository: cordova-android
Updated Branches:
  refs/heads/master 151b86cb7 -> 32e84d231


CB-7085 Add onConfigurationChanged hook for plugins (close #165)


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/32e84d23
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/32e84d23
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/32e84d23

Branch: refs/heads/master
Commit: 32e84d231607a2b35bc77da3471494e255222ee7
Parents: 151b86c
Author: Tim Lancina <tim@drifty.com>
Authored: Tue Mar 24 10:29:22 2015 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Tue Mar 24 13:36:25 2015 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaActivity.java   | 18 ++++++++++++++++++
 .../src/org/apache/cordova/CordovaPlugin.java     |  9 +++++++++
 .../src/org/apache/cordova/PluginManager.java     | 14 ++++++++++++++
 3 files changed, 41 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/32e84d23/framework/src/org/apache/cordova/CordovaActivity.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java
index 5d0a586..ab1ef88 100755
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@ -28,6 +28,7 @@ import android.app.Activity;
 import android.app.AlertDialog;
 import android.content.DialogInterface;
 import android.content.Intent;
+import android.content.res.Configuration;
 import android.graphics.Color;
 import android.media.AudioManager;
 import android.os.Bundle;
@@ -441,4 +442,21 @@ public class CordovaActivity extends Activity {
         super.onSaveInstanceState(outState);
         cordovaInterface.onSaveInstanceState(outState);
     }
+
+    /**
+     * Called by the system when the device configuration changes while your activity is
running.
+     *
+     * @param newConfig		The new device configuration
+     */
+    @Override
+    public void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+        if (this.appView == null) {
+            return;
+        }
+        PluginManager pm = this.appView.getPluginManager();
+        if (pm != null) {
+            pm.onConfigurationChanged(newConfig);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/32e84d23/framework/src/org/apache/cordova/CordovaPlugin.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaPlugin.java b/framework/src/org/apache/cordova/CordovaPlugin.java
index 95a39c7..0d08117 100644
--- a/framework/src/org/apache/cordova/CordovaPlugin.java
+++ b/framework/src/org/apache/cordova/CordovaPlugin.java
@@ -26,6 +26,7 @@ import org.json.JSONArray;
 import org.json.JSONException;
 
 import android.content.Intent;
+import android.content.res.Configuration;
 import android.net.Uri;
 
 import java.io.FileNotFoundException;
@@ -338,4 +339,12 @@ public class CordovaPlugin {
     public boolean onReceivedClientCertRequest(CordovaWebView view, ICordovaClientCertRequest
request) {
         return false;
     }
+
+    /**
+     * Called by the system when the device configuration changes while your activity is
running.
+     *
+     * @param newConfig		The new device configuration
+     */
+    public void onConfigurationChanged(Configuration newConfig) {
+    }
 }

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/32e84d23/framework/src/org/apache/cordova/PluginManager.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/PluginManager.java b/framework/src/org/apache/cordova/PluginManager.java
index 9306009..7115bb1 100755
--- a/framework/src/org/apache/cordova/PluginManager.java
+++ b/framework/src/org/apache/cordova/PluginManager.java
@@ -24,6 +24,7 @@ import java.util.LinkedHashMap;
 import org.json.JSONException;
 
 import android.content.Intent;
+import android.content.res.Configuration;
 import android.net.Uri;
 import android.os.Debug;
 import android.util.Log;
@@ -488,4 +489,17 @@ public class PluginManager {
         }
         return ret;
     }
+
+    /**
+     * Called by the system when the device configuration changes while your activity is
running.
+     *
+     * @param newConfig		The new device configuration
+     */
+    public void onConfigurationChanged(Configuration newConfig) {
+        for (CordovaPlugin plugin : this.pluginMap.values()) {
+            if (plugin != null) {
+                plugin.onConfigurationChanged(newConfig);
+            }
+        }
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message