From d473c5abbda4e5f8fbb0aef9c21014470e2dbec1 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 14 Dec 2012 19:37:05 +0400 Subject: [PATCH] move between articles by tapping left/right sides --- AndroidManifest.xml | 4 +- src/org/fox/ttrss/ArticleFragment.java | 109 +++++++++++++++++- .../ttrss/offline/OfflineArticleFragment.java | 109 +++++++++++++++++- 3 files changed, 217 insertions(+), 5 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 90117d6e..3f656b1a 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="119" + android:versionName="0.9.3" > = width-(width/15)) { + onRightSideTapped(); + return true; + } /* else if (!m_activity.isCompatMode()) { + ActionBar bar = m_activity.getActionBar(); + + if (bar.isShowing()) { + bar.hide(); + } else { + bar.show(); + } + } */ + return false; } } diff --git a/src/org/fox/ttrss/offline/OfflineArticleFragment.java b/src/org/fox/ttrss/offline/OfflineArticleFragment.java index d5d004cf..a16ab002 100644 --- a/src/org/fox/ttrss/offline/OfflineArticleFragment.java +++ b/src/org/fox/ttrss/offline/OfflineArticleFragment.java @@ -3,6 +3,8 @@ package org.fox.ttrss.offline; import java.text.SimpleDateFormat; import java.util.Date; +import org.fox.ttrss.ArticlePager; +import org.fox.ttrss.CommonActivity; import org.fox.ttrss.R; import org.fox.ttrss.util.ImageCacheService; import org.jsoup.Jsoup; @@ -27,6 +29,7 @@ import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; import android.view.LayoutInflater; import android.view.MenuItem; +import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; @@ -35,8 +38,9 @@ import android.webkit.WebSettings; import android.webkit.WebSettings.LayoutAlgorithm; import android.webkit.WebView; import android.widget.TextView; +import android.view.GestureDetector; -public class OfflineArticleFragment extends Fragment { +public class OfflineArticleFragment extends Fragment implements GestureDetector.OnDoubleTapListener { private final String TAG = this.getClass().getSimpleName(); private SharedPreferences m_prefs; @@ -44,6 +48,7 @@ public class OfflineArticleFragment extends Fragment { private boolean m_isCat = false; // FIXME use private Cursor m_cursor; private OfflineActivity m_activity; + private GestureDetector m_detector; public OfflineArticleFragment() { super(); @@ -161,6 +166,13 @@ public class OfflineArticleFragment extends Fragment { } }); + web.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + return m_detector.onTouchEvent(event); + } + }); + String content; String cssOverride = ""; @@ -297,6 +309,101 @@ public class OfflineArticleFragment extends Fragment { m_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext()); 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) { + // TODO Auto-generated method stub + + } + + @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; + } + + private void onLeftSideTapped() { + OfflineArticlePager ap = (OfflineArticlePager) m_activity.getSupportFragmentManager().findFragmentByTag(CommonActivity.FRAG_ARTICLE); + + if (ap != null && ap.isAdded()) { + ap.selectArticle(false); + } + } + + private void onRightSideTapped() { + OfflineArticlePager ap = (OfflineArticlePager) m_activity.getSupportFragmentManager().findFragmentByTag(CommonActivity.FRAG_ARTICLE); + + if (ap != null && ap.isAdded()) { + ap.selectArticle(true); + } + } + + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + + int width = getView().getWidth(); + int x = Math.round(e.getX()); + + if (x <= width/15) { + onLeftSideTapped(); + return true; + } else if (x >= width-(width/15)) { + onRightSideTapped(); + return true; + } /* else if (!m_activity.isCompatMode()) { + ActionBar bar = m_activity.getActionBar(); + + if (bar.isShowing()) { + bar.hide(); + } else { + bar.show(); + } + } */ + + return false; }