/**
 *
 * OverScrollingWebView
 * Cobalt
 *
 * The MIT License (MIT)
 *
 * Copyright (c) 2014 Cobaltians
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 */

package org.cobaltians.cobalt.customviews;

import org.cobaltians.cobalt.fragments.CobaltFragment;

import android.content.Context;
import android.util.AttributeSet;
import android.webkit.WebView;

public class OverScrollingWebView extends WebView {

	/**
	 * Fragment handling scroll events
	 */
	protected CobaltFragment mScrollListener;

	public OverScrollingWebView(Context context) {
		super(context);
	}

	public OverScrollingWebView(Context context, AttributeSet attributes) {
		super(context, attributes);
	}
	
	public OverScrollingWebView(Context context, AttributeSet attributes, int defaultStyle) {
		super(context, attributes, defaultStyle);
	}

	public void setScrollListener(CobaltFragment scrollListener) {
		mScrollListener = scrollListener;
	}

	/**
	 * Notifies listener of scrolling
	 */
	@Override
	protected void onScrollChanged(int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
		super.onScrollChanged(scrollX, scrollY, oldScrollX, oldScrollY);
		
		if (mScrollListener != null
			&& IScrollListener.class.isAssignableFrom(mScrollListener.getClass())) {
			mScrollListener.onOverScrolled(scrollX, scrollY, oldScrollX, oldScrollY);
		}
	}	
}

@@ -1332,24 +1332,82 @@
 oid.
-util.AttributeSe
+os.Build;%0Aimport android.util.AttributeSet;%0Aimport android.view.MotionEven
 t;%0Ai
@@ -2408,12 +2408,1245 @@
 ;%0A%09%09%7D%0A%09%7D
-%09
+%0A%0A%09/*%0A%09 * TODO: do not delete this time!%0A%09 * Overwrite this method and calling onScrollChanged fixes an issue about %22a race condition where%0A%09 * the webkit layout engine gets out of sync with the Android layout and starts mapping touch%0A%09 * events to an incorrect coordinate system%22 leading to %22all touches fall outside of the window,%0A%09 * and get rejected.%22%0A%09 * source: https://stackoverflow.com/questions/12090899/android-webview-jellybean-should-not-happen-no-rect-based-test-nodes-found#comment-22698848%0A%09 * %22I met with John Reck, an engineer on the Android WebView team, a couple of days ago. He%0A%09 * confirmed that this is a bug--basically a race condition where the webkit layout engine gets%0A%09 * out of sync with the Android layout and starts mapping touch events to an incorrect%0A%09 * coordinate system. Until the bug is fixed, calling onScrollChanged() to resync the layouts%0A%09 * seems to be the best workaround%22%0A     */%0A%09@Override%0A%09public boolean onTouchEvent(MotionEvent event) %7B%0A%09%09if (Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.JELLY_BEAN%0A%09%09%09&& Build.VERSION.SDK_INT %3C= Build.VERSION_CODES.JELLY_BEAN_MR2) %7B%0A%09%09%09onScrollChanged(getScrollX(), getScrollY(), getScrollX(), getScrollY());%0A%09%09%7D%0A%0A%09%09return super.onTouchEvent(event);%0A%09%7D
 %0A%7D%0A

Fix touched not received by Web on JellyBean