diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 5a8ee1e9..bf1b2d8c 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="212" + android:versionName="1.16b9" > + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 7b475ddc..229a21e1 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -209,4 +209,6 @@ Download articles and go offline Save and close Synchronize read articles and go online + Compatible article layout + Enable if you see glitches in article content diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 7f247d92..ec74841a 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -161,6 +161,11 @@ android:title="@string/offline_oldest_first" /> + = 11) { + web.setLayerType(View.LAYER_TYPE_SOFTWARE, null); + } } web.setWebChromeClient(new WebChromeClient() { @@ -259,6 +263,10 @@ public class ArticleFragment extends Fragment implements GestureDetector.OnDoubl "" + "" + articleContent; + if (useTitleWebView) { + content += "

 

 

 

 

"; + } + if (m_article.attachments != null && m_article.attachments.size() != 0) { String flatContent = articleContent.replaceAll("[\r\n]", ""); boolean hasImages = flatContent.matches(".*?+].*?"); diff --git a/src/org/fox/ttrss/offline/OfflineArticleFragment.java b/src/org/fox/ttrss/offline/OfflineArticleFragment.java index dd7dde5e..b9d9f0de 100644 --- a/src/org/fox/ttrss/offline/OfflineArticleFragment.java +++ b/src/org/fox/ttrss/offline/OfflineArticleFragment.java @@ -123,7 +123,9 @@ public class OfflineArticleFragment extends Fragment implements GestureDetector. m_articleId = savedInstanceState.getInt("articleId"); } - View view = inflater.inflate(R.layout.article_fragment, container, false); + boolean useTitleWebView = m_prefs.getBoolean("article_compat_view", false); + + View view = inflater.inflate(useTitleWebView ? R.layout.article_fragment_compat : R.layout.article_fragment, container, false); m_cursor = m_activity.getReadableDb().query("articles LEFT JOIN feeds ON (feed_id = feeds."+BaseColumns._ID+")", new String[] { "articles.*", "feeds.title AS feed_title" }, "articles." + BaseColumns._ID + "=?", @@ -212,8 +214,10 @@ public class OfflineArticleFragment extends Fragment implements GestureDetector. getActivity().getTheme().resolveAttribute(R.attr.linkColor, tv, true); // prevent flicker in ics - if (!m_prefs.getBoolean("webview_hardware_accel", true)) { - web.setLayerType(View.LAYER_TYPE_SOFTWARE, null); + if (!m_prefs.getBoolean("webview_hardware_accel", true) || useTitleWebView) { + if (android.os.Build.VERSION.SDK_INT >= 11) { + web.setLayerType(View.LAYER_TYPE_SOFTWARE, null); + } } String theme = m_prefs.getString("theme", "THEME_DARK"); @@ -282,8 +286,14 @@ public class OfflineArticleFragment extends Fragment implements GestureDetector. cssOverride + "" + "" + - "" + articleContent + ""; - + "" + articleContent; + + if (useTitleWebView) { + content += "

 

 

 

 

"; + } + + content += ""; + try { String baseUrl = null; diff --git a/src/org/fox/ttrss/util/TitleWebView.java b/src/org/fox/ttrss/util/TitleWebView.java new file mode 100644 index 00000000..4d97918e --- /dev/null +++ b/src/org/fox/ttrss/util/TitleWebView.java @@ -0,0 +1,91 @@ +package org.fox.ttrss.util; + +// http://www.techques.com/question/1-9718245/Webview-in-Scrollview + +import android.content.Context; +import android.graphics.Canvas; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.view.View; +import android.webkit.WebView; + +public class TitleWebView extends WebView{ + + public TitleWebView(Context context, AttributeSet attrs){ + super(context, attrs); + } + + private int titleHeight; + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){ + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + // determine height of title bar + View title = getChildAt(0); + titleHeight = title==null ? 0 : title.getMeasuredHeight(); + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev){ + return true; // don't pass our touch events to children (title bar), we send these in dispatchTouchEvent + } + + private boolean touchInTitleBar; + @Override + public boolean dispatchTouchEvent(MotionEvent me){ + + boolean wasInTitle = false; + switch(me.getActionMasked()){ + case MotionEvent.ACTION_DOWN: + touchInTitleBar = (me.getY() <= visibleTitleHeight()); + break; + + case MotionEvent.ACTION_UP: + case MotionEvent.ACTION_CANCEL: + wasInTitle = touchInTitleBar; + touchInTitleBar = false; + break; + } + if(touchInTitleBar || wasInTitle) { + View title = getChildAt(0); + if(title!=null) { + // this touch belongs to title bar, dispatch it here + me.offsetLocation(0, getScrollY()); + return title.dispatchTouchEvent(me); + } + } + // this is our touch, offset and process + me.offsetLocation(0, -titleHeight); + return super.dispatchTouchEvent(me); + } + + /** + * @return visible height of title (may return negative values) + */ + private int visibleTitleHeight(){ + return titleHeight-getScrollY(); + } + + @Override + protected void onScrollChanged(int l, int t, int oldl, int oldt){ + super.onScrollChanged(l, t, oldl, oldt); + View title = getChildAt(0); + if(title!=null) // undo horizontal scroll, so that title scrolls only vertically + title.offsetLeftAndRight(l - title.getLeft()); + } + + @Override + protected void onDraw(Canvas c){ + + c.save(); + int tH = visibleTitleHeight(); + if(tH>0) { + // clip so that it doesn't clear background under title bar + int sx = getScrollX(), sy = getScrollY(); + c.clipRect(sx, sy+tH, sx+getWidth(), sy+getHeight()); + } + c.translate(0, titleHeight); + super.onDraw(c); + c.restore(); + } + }