add workaround for webview not working correctly inside viewpager or w/e

(the no rect test based nodes found issue)

thanks, google engineers, amazing work
This commit is contained in:
Andrew Dolgov 2013-11-19 20:07:17 +04:00
parent 12b784d06b
commit ac96ae00d3
4 changed files with 41 additions and 136 deletions

View File

@ -94,7 +94,7 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<WebView <org.fox.ttrss.util.LessBrokenWebView
android:id="@+id/content" android:id="@+id/content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />

View File

@ -41,13 +41,12 @@ import android.webkit.WebView;
import android.webkit.WebView.HitTestResult; import android.webkit.WebView.HitTestResult;
import android.widget.TextView; import android.widget.TextView;
public class ArticleFragment extends Fragment implements GestureDetector.OnDoubleTapListener { public class ArticleFragment extends Fragment {
private final String TAG = this.getClass().getSimpleName(); private final String TAG = this.getClass().getSimpleName();
private SharedPreferences m_prefs; private SharedPreferences m_prefs;
private Article m_article; private Article m_article;
private OnlineActivity m_activity; private OnlineActivity m_activity;
private GestureDetector m_detector;
public void initialize(Article article) { public void initialize(Article article) {
m_article = article; m_article = article;
@ -183,13 +182,6 @@ public class ArticleFragment extends Fragment implements GestureDetector.OnDoubl
} }
}); });
web.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return m_detector.onTouchEvent(event);
}
});
String content; String content;
String cssOverride = ""; String cssOverride = "";
@ -385,63 +377,5 @@ public class ArticleFragment extends Fragment implements GestureDetector.OnDoubl
m_activity = (OnlineActivity)activity; m_activity = (OnlineActivity)activity;
//m_article = m_onlineServices.getSelectedArticle(); //m_article = m_onlineServices.getSelectedArticle();
m_detector = new GestureDetector(m_activity, new GestureDetector.OnGestureListener() {
@Override
public boolean onSingleTapUp(MotionEvent e) {
// TODO Auto-generated method stub
return false;
}
@Override
public void onShowPress(MotionEvent e) {
// TODO Auto-generated method stub
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
float distanceY) {
// TODO Auto-generated method stub
return false;
}
@Override
public void onLongPress(MotionEvent e) {
m_activity.openContextMenu(getView());
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean onDown(MotionEvent e) {
// TODO Auto-generated method stub
return false;
}
});
m_detector.setOnDoubleTapListener(this);
}
@Override
public boolean onDoubleTap(MotionEvent arg0) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean onDoubleTapEvent(MotionEvent arg0) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean onSingleTapConfirmed(MotionEvent arg0) {
// TODO Auto-generated method stub
return false;
} }
} }

View File

@ -43,7 +43,7 @@ import android.webkit.WebView;
import android.webkit.WebView.HitTestResult; import android.webkit.WebView.HitTestResult;
import android.widget.TextView; import android.widget.TextView;
public class OfflineArticleFragment extends Fragment implements GestureDetector.OnDoubleTapListener { public class OfflineArticleFragment extends Fragment {
private final String TAG = this.getClass().getSimpleName(); private final String TAG = this.getClass().getSimpleName();
private SharedPreferences m_prefs; private SharedPreferences m_prefs;
@ -51,7 +51,6 @@ public class OfflineArticleFragment extends Fragment implements GestureDetector.
private boolean m_isCat = false; // FIXME use private boolean m_isCat = false; // FIXME use
private Cursor m_cursor; private Cursor m_cursor;
private OfflineActivity m_activity; private OfflineActivity m_activity;
private GestureDetector m_detector;
public void initialize(int articleId) { public void initialize(int articleId) {
m_articleId = articleId; m_articleId = articleId;
@ -191,13 +190,6 @@ public class OfflineArticleFragment extends Fragment implements GestureDetector.
} }
}); });
web.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return m_detector.onTouchEvent(event);
}
});
String content; String content;
String cssOverride = ""; String cssOverride = "";
@ -379,63 +371,5 @@ public class OfflineArticleFragment extends Fragment implements GestureDetector.
m_activity = (OfflineActivity) activity; m_activity = (OfflineActivity) activity;
m_detector = new GestureDetector(m_activity, new GestureDetector.OnGestureListener() {
@Override
public boolean onSingleTapUp(MotionEvent e) {
// TODO Auto-generated method stub
return false;
}
@Override
public void onShowPress(MotionEvent e) {
// TODO Auto-generated method stub
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
float distanceY) {
// TODO Auto-generated method stub
return false;
}
@Override
public void onLongPress(MotionEvent e) {
m_activity.openContextMenu(getView());
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean onDown(MotionEvent e) {
// TODO Auto-generated method stub
return false;
}
});
m_detector.setOnDoubleTapListener(this);
}
@Override
public boolean onDoubleTap(MotionEvent arg0) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean onDoubleTapEvent(MotionEvent arg0) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
// TODO Auto-generated method stub
return false;
} }
} }

View File

@ -0,0 +1,37 @@
package org.fox.ttrss.util;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.webkit.WebView;
public class LessBrokenWebView extends WebView {
public LessBrokenWebView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public LessBrokenWebView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public LessBrokenWebView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
int temp_ScrollY = getScrollY();
scrollTo(getScrollX(), getScrollY() + 1);
scrollTo(getScrollX(), temp_ScrollY);
}
return super.onTouchEvent(event);
}
}