Fix: can not interact with map on Android 4.4.2 if body uses ResetCSS rule
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.3.6" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
+<plugin id="cordova-plugin-googlemaps" version="2.3.7-beta-20180702-1611" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>cordova-plugin-googlemaps</name>
<js-module name="BaseClass" src="www/BaseClass.js">
<runs />

MODIFY
src/android/plugin/google/maps/MyPluginLayout.java
src/android/plugin/google/maps/MyPluginLayout.java
@@ -45,6 +45,7 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
private boolean isScrolling = false;
public boolean isDebug = false;
public final Object _lockHtmlNodes = new Object();
+ public Map<String, String> CACHE_FIND_DOM = new ConcurrentHashMap<String, String>();
public Map<String, Bundle> HTMLNodes = new ConcurrentHashMap<String, Bundle>();
public Map<String, RectF> HTMLNodeRectFs = new ConcurrentHashMap<String, RectF>();
private Activity mActivity = null;
@@ -411,6 +412,14 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
}
private String findClickedDom(String domId, PointF clickPoint, boolean isMapChild, Overflow overflow) {
+ if (CACHE_FIND_DOM.containsKey(domId)) {
+ String cacheResult = CACHE_FIND_DOM.get(domId);
+ if ("(null)".equals(cacheResult)) {
+ cacheResult = null;
+ }
+ return cacheResult;
+ }
+
Overflow overflow1 = null;
if (overflow != null) {
overflow1 = new Overflow();
@@ -418,7 +427,7 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
overflow1.cropY = overflow.cropY;
overflow1.rect = new RectF(overflow.rect.left, overflow.rect.top, overflow.rect.right, overflow.rect.bottom);
}
- Log.d(TAG, "-(findClickedDom)domId = " + domId + ", clickPoint = " + clickPoint.x + ", " + clickPoint.y);
+ //Log.d(TAG, "-(findClickedDom)domId = " + domId + ", clickPoint = " + clickPoint.x + ", " + clickPoint.y);
String maxDomId = null;
RectF rect, rect2, rect3;
@@ -432,7 +441,7 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
}
}
isMapChild = isMapChild || domInfo.getBoolean("isMap", false);
- Log.d(TAG, "--domId = " + domId + ", domInfo = " + domInfo);
+ //Log.d(TAG, "--domId = " + domId + ", domInfo = " + domInfo);
String pointerEvents = domInfo.getString("pointerEvents");
String overflowX = domInfo.getString("overflowX");
@@ -446,9 +455,9 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
overflow1.rect = new RectF(rect3.left, rect3.top, rect3.right, rect3.bottom);
}
- if (overflow1 != null) {
- Log.d(TAG, "--overflow1 cropX= " + overflow1.cropX + ", cropY = " + overflow1.cropY + ", rect = " + overflow1.rect.toShortString());
- }
+ //if (overflow1 != null) {
+ // Log.d(TAG, "--overflow1 cropX= " + overflow1.cropX + ", cropY = " + overflow1.cropY + ", rect = " + overflow1.rect.toShortString());
+ //}
zIndexProp = domInfo.getBundle("zIndex");
ArrayList<String> children = domInfo.getStringArrayList("children");
@@ -471,7 +480,8 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
if (grandChildren == null || grandChildren.size() == 0) {
rect = HTMLNodeRectFs.get(childId);
rect2 = new RectF(rect.left, rect.top, rect.right, rect.bottom);
- if (overflow1 != null ) {
+ if (overflow1 != null && !"root".equals(domId) ) {
+ overflow1.rect = new RectF(HTMLNodeRectFs.get(domId));
if (overflow1.cropX) {
rect2.left = Math.max(rect2.left, overflow1.rect.left);
rect2.right = Math.min(rect2.right, overflow1.rect.right);
@@ -485,15 +495,15 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
continue;
}
- Log.d(TAG, "---childId = " + childId + ", domInfo = " + domInfo);
+ //Log.d(TAG, "---childId = " + childId + ", domInfo = " + domInfo);
if ("none".equals(domInfo.getString("pointerEvents"))) {
continue;
}
- Log.d(TAG, "----childId = " + childId + ", maxZindex = " + maxZindex + ", zIndexValue = " + zIndexValue);
+ //Log.d(TAG, "----childId = " + childId + ", maxZindex = " + maxZindex + ", zIndexValue = " + zIndexValue);
if (maxZindex < zIndexValue) {
maxZindex = zIndexValue;
maxDomId = childId;
- Log.i(TAG, "-----current = " + childId);
+ //Log.i(TAG, "-----current = " + childId);
}
} else {
grandChildId = findClickedDom(childId, clickPoint, isMapChild, overflow1);
@@ -504,8 +514,9 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
}
rect = HTMLNodeRectFs.get(grandChildId);
rect2 = new RectF(rect.left, rect.top, rect.right, rect.bottom);
- Log.d(TAG, "---findClickedDom("+ childId + ") -> " + grandChildId + ",rect = " + rect2.toShortString());
- if (overflow1 != null ) {
+ //Log.d(TAG, "---findClickedDom("+ childId + ") -> " + grandChildId + ",rect = " + rect2.toShortString());
+ if (overflow1 != null && !"root".equals(domId) ) {
+ overflow1.rect = new RectF(HTMLNodeRectFs.get(domId));
if (overflow1.cropX) {
rect2.left = Math.max(rect2.left, overflow1.rect.left);
rect2.right = Math.min(rect2.right, overflow1.rect.right);
@@ -514,36 +525,38 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
rect2.top = Math.max(rect2.top, overflow1.rect.top);
rect2.bottom = Math.min(rect2.bottom, overflow1.rect.bottom);
}
- Log.d(TAG, "---overflow -> " + overflow1.rect.toShortString());
+ //Log.d(TAG, "---overflow(" + domId + ") -> " + overflow1.rect.toShortString() + ", str=" + HTMLNodeRectFs.get(domId));
}
if (!rect2.contains(clickPoint.x, clickPoint.y)) {
- Log.e(TAG, "----the click point is not in this element(" +grandChildId + "), rect = " + rect2.toShortString() + ", click = " + clickPoint.x + "," + clickPoint.y );
+ //Log.e(TAG, "----the click point is not in this element(" +grandChildId + "), rect = " + rect2.toShortString() + ", click = " + clickPoint.x + "," + clickPoint.y );
continue;
}
domInfo = HTMLNodes.get(grandChildId);
- Log.d(TAG, "----grandChildId = " + grandChildId + ", domInfo = " + domInfo);
+ //Log.d(TAG, "----grandChildId = " + grandChildId + ", domInfo = " + domInfo);
if ("none".equals(domInfo.getString("pointerEvents"))) {
- Log.e(TAG, "-----grandChildId(" + grandChildId + ") is " + domInfo.getString("pointerEvents"));
+ //Log.e(TAG, "-----grandChildId(" + grandChildId + ") is " + domInfo.getString("pointerEvents"));
continue;
}
- Log.d(TAG, "----grandChildId = " + grandChildId + ", maxZindex = " + maxZindex + ", zIndexValue = " + zIndexValue);
+ //Log.d(TAG, "----grandChildId = " + grandChildId + ", maxZindex = " + maxZindex + ", zIndexValue = " + zIndexValue);
if (maxZindex < zIndexValue) {
maxZindex = zIndexValue;
maxDomId = grandChildId;
- Log.i(TAG, "-----current = " + grandChildId);
+ //Log.i(TAG, "-----current = " + grandChildId);
}
}
}
}
}
- if (maxDomId == null) {
+ if (maxDomId == null && !"root".equals(domId)) {
if ("none".equals(pointerEvents)) {
+ CACHE_FIND_DOM.put(domId, "(null)");
return null;
}
rect = HTMLNodeRectFs.get(domId);
rect2 = new RectF(rect.left, rect.top, rect.right, rect.bottom);
if (overflow1 != null ) {
+ overflow1.rect = new RectF(HTMLNodeRectFs.get(domId));
if (overflow1.cropX) {
rect2.left = Math.max(rect2.left, overflow1.rect.left);
rect2.right = Math.min(rect2.right, overflow1.rect.right);
@@ -554,10 +567,18 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
}
}
if (!rect2.contains(clickPoint.x, clickPoint.y)) {
+ //Log.e(TAG, "--the click point is not in this element(" +domId + "), rect = " + rect2.toShortString() + ", click = " + clickPoint.x + "," + clickPoint.y );
+ CACHE_FIND_DOM.put(domId, "(null)");
return null;
}
maxDomId = domId;
}
+ if (maxDomId == null) {
+ CACHE_FIND_DOM.put(domId, "(null)");
+ } else {
+ CACHE_FIND_DOM.put(domId, maxDomId);
+ }
+ //Log.i(TAG, "-maxDomId = " + maxDomId + ", domId = " + domId);
return maxDomId;
}
@@ -589,13 +610,10 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
RectF drawRect;
synchronized (_lockHtmlNodes) {
- for (String key: HTMLNodeRectFs.keySet()) {
- Log.d(TAG, "onInterceptTouchEvent: " + key + " = " + HTMLNodeRectFs.get(key).toShortString());
- }
-
+ CACHE_FIND_DOM.clear();
String clickedDomId = findClickedDom("root", clickPoint, false, null);
- Log.d(TAG, "----clickedDomId = " + clickedDomId);
+ //Log.d(TAG, "----clickedDomId = " + clickedDomId);
while (iterator.hasNext()) {
entry = iterator.next();
pluginOverlay = entry.getValue();

Fix: can not interact with map on Android 4.4.2 if body uses ResetCSS rule #2235