summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/drawable-hdpi/ic_next_article.pngbin0 -> 473 bytes
-rw-r--r--res/drawable-hdpi/ic_next_article_disabled.pngbin0 -> 482 bytes
-rw-r--r--res/drawable-hdpi/ic_prev_article.pngbin0 -> 466 bytes
-rw-r--r--res/drawable-hdpi/ic_prev_article_disabled.pngbin0 -> 486 bytes
-rw-r--r--res/drawable/s_prev_article.svg70
-rw-r--r--res/layout/article_fragment.xml179
-rw-r--r--src/org/fox/ttrss/ArticleFragment.java83
-rw-r--r--src/org/fox/ttrss/ArticleOps.java5
-rw-r--r--src/org/fox/ttrss/HeadlinesFragment.java23
-rw-r--r--src/org/fox/ttrss/MainActivity.java55
10 files changed, 357 insertions, 58 deletions
diff --git a/res/drawable-hdpi/ic_next_article.png b/res/drawable-hdpi/ic_next_article.png
new file mode 100644
index 00000000..ef7e7be3
--- /dev/null
+++ b/res/drawable-hdpi/ic_next_article.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_next_article_disabled.png b/res/drawable-hdpi/ic_next_article_disabled.png
new file mode 100644
index 00000000..7aeac8a4
--- /dev/null
+++ b/res/drawable-hdpi/ic_next_article_disabled.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_prev_article.png b/res/drawable-hdpi/ic_prev_article.png
new file mode 100644
index 00000000..0d5744de
--- /dev/null
+++ b/res/drawable-hdpi/ic_prev_article.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_prev_article_disabled.png b/res/drawable-hdpi/ic_prev_article_disabled.png
new file mode 100644
index 00000000..848cf464
--- /dev/null
+++ b/res/drawable-hdpi/ic_prev_article_disabled.png
Binary files differ
diff --git a/res/drawable/s_prev_article.svg b/res/drawable/s_prev_article.svg
new file mode 100644
index 00000000..5c83a6b5
--- /dev/null
+++ b/res/drawable/s_prev_article.svg
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="32px"
+ height="32px"
+ id="svg2985"
+ version="1.1"
+ inkscape:version="0.48.0 r9654"
+ sodipodi:docname="s_prev_article.svg"
+ inkscape:export-filename="C:\Users\fox\workspace\org.fox.ttrss\res\drawable-hdpi\s_prev_article.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs2987" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="15.836083"
+ inkscape:cx="13.700373"
+ inkscape:cy="14.630233"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:grid-bbox="true"
+ inkscape:document-units="px"
+ inkscape:window-width="1600"
+ inkscape:window-height="1138"
+ inkscape:window-x="-8"
+ inkscape:window-y="-8"
+ inkscape:window-maximized="1"
+ inkscape:snap-global="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid2997" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata2990">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer">
+ <path
+ style="fill:#898989;fill-opacity:1;stroke:none"
+ d="m 23.5,1 -10,15 10,15 -5,0 -10,-15 10,-15 z"
+ id="path2999"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccc" />
+ </g>
+</svg>
diff --git a/res/layout/article_fragment.xml b/res/layout/article_fragment.xml
index 29334931..2a45daf3 100644
--- a/res/layout/article_fragment.xml
+++ b/res/layout/article_fragment.xml
@@ -1,38 +1,141 @@
-
- <LinearLayout android:id="@+id/article_fragment" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal">
- <ImageView android:layout_weight="0" android:background="?articleDivider" android:layout_width="wrap_content" android:paddingLeft="4dip" android:layout_height="match_parent"></ImageView>
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
- android:id="@+id/linerLayout2"
- android:layout_width="match_parent"
- android:layout_weight="1"
- android:layout_height="match_parent" android:orientation="vertical">
- <LinearLayout android:background="?articleHeader" android:layout_gravity="center_vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/article_header" android:padding="10dip" android:orientation="vertical">
- <TextView android:singleLine="true" android:layout_weight="1" android:text="{Title}" android:layout_height="wrap_content" android:ellipsize="end" android:layout_width="match_parent" android:id="@+id/title" android:textSize="18dip"></TextView>
- <LinearLayout
- android:id="@+id/linearLayout3"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1">
- <TextView android:text="{COMMENTS}" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" android:layout_width="wrap_content" android:id="@+id/comments"></TextView>
- <TextView android:text="{DATE}" android:gravity="right" android:textAppearance="?android:attr/textAppearanceSmall" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/date"></TextView>
- </LinearLayout>
-
- </LinearLayout>
- <ImageView android:background="?feedlistDivider" android:paddingTop="2dip" android:layout_weight="0" android:layout_height="wrap_content" android:layout_width="match_parent"></ImageView>
- <WebView android:layout_weight="1" android:layout_width="match_parent" android:padding="3dip" android:layout_height="match_parent" android:id="@+id/content"></WebView>
-
- <!-- Ad Placeholder -->
- <com.google.ads.AdView
- android:id="@+id/ad"
- android:layout_weight="0"
- android:gravity="center"
- android:background="@android:color/transparent"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- ads:adUnitId="a14ed24fe8c671c"
- ads:adSize="BANNER"
- ads:loadAdOnCreate="false" />
- </LinearLayout>
- </LinearLayout>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/article_fragment"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="horizontal" >
+
+ <ImageView
+ android:id="@+id/splitter_vertical"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_weight="0"
+ android:background="?articleDivider"
+ android:clickable="true"
+ android:paddingLeft="4dip" >
+
+ </ImageView>
+
+ <LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
+ android:id="@+id/linerLayout2"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:orientation="vertical" >
+
+ <ImageView
+ android:id="@+id/splitter_horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0"
+ android:background="?articleDivider"
+ android:clickable="true"
+ android:paddingTop="4dip" />
+
+ <LinearLayout
+ android:id="@+id/linearLayout5"
+ android:padding="5dp"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:layout_weight="0"
+ android:layout_gravity="center_vertical" >
+
+ <ImageView
+ android:id="@+id/prev_article"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="0"
+ android:src="@drawable/ic_prev_article" />
+
+ <LinearLayout
+ android:paddingLeft="5dp"
+ android:paddingRight="5dp"
+ android:id="@+id/article_header"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:background="?articleHeader"
+ android:orientation="vertical"
+ >
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:ellipsize="end"
+ android:singleLine="true"
+ android:text="{Title}"
+ />
+
+ <LinearLayout
+ android:id="@+id/linearLayout3"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1" >
+
+ <TextView
+ android:id="@+id/tags"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:text="{TAGS}"
+ android:textSize="10sp" />
+
+ <TextView
+ android:id="@+id/date"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:gravity="right"
+ android:layout_weight="1"
+ android:text="{DATE}"
+ android:textSize="10sp"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+ </LinearLayout>
+ </LinearLayout>
+
+ <ImageView
+ android:id="@+id/next_article"
+ android:layout_width="wrap_content"
+ android:clickable="true"
+ android:layout_height="wrap_content"
+ android:layout_weight="0"
+ android:src="@drawable/ic_next_article" />
+
+ </LinearLayout>
+
+ <ImageView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0"
+ android:background="?feedlistDivider"
+ android:paddingTop="2dip" >
+ </ImageView>
+
+ <WebView
+ android:id="@+id/content"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:padding="3dip" >
+ </WebView>
+
+ <!-- Ad Placeholder -->
+
+ <com.google.ads.AdView
+ android:id="@+id/ad"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0"
+ ads:adSize="BANNER"
+ ads:adUnitId="a14ed24fe8c671c"
+ android:background="@android:color/transparent"
+ android:gravity="center"
+ ads:loadAdOnCreate="false" />
+ </LinearLayout>
+
+</LinearLayout> \ No newline at end of file
diff --git a/src/org/fox/ttrss/ArticleFragment.java b/src/org/fox/ttrss/ArticleFragment.java
index 4a84aef2..b4075d7e 100644
--- a/src/org/fox/ttrss/ArticleFragment.java
+++ b/src/org/fox/ttrss/ArticleFragment.java
@@ -3,6 +3,9 @@ package org.fox.ttrss;
import java.text.SimpleDateFormat;
import java.util.Date;
+import org.fox.ttrss.ArticleOps.RelativeArticle;
+import org.jsoup.helper.StringUtil;
+
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
@@ -10,22 +13,27 @@ import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.text.Html;
import android.text.method.LinkMovementMethod;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.View.OnClickListener;
import android.webkit.WebView;
+import android.widget.ImageView;
import android.widget.TextView;
import com.google.ads.AdRequest;
import com.google.ads.AdView;
-public class ArticleFragment extends Fragment {
+public class ArticleFragment extends Fragment implements OnClickListener {
@SuppressWarnings("unused")
private final String TAG = this.getClass().getSimpleName();
private SharedPreferences m_prefs;
private Article m_article;
private ArticleOps m_articleOps;
+ private Article m_nextArticle;
+ private Article m_prevArticle;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@@ -35,6 +43,26 @@ public class ArticleFragment extends Fragment {
}
View view = inflater.inflate(R.layout.article_fragment, container, false);
+
+ // TODO change to interface?
+ MainActivity activity = (MainActivity)getActivity();
+
+ if (activity != null) {
+ int orientation = activity.getWindowManager().getDefaultDisplay().getOrientation();
+
+ if (!activity.isSmallScreen()) {
+ if (orientation % 2 == 0) {
+ view.findViewById(R.id.splitter_horizontal).setVisibility(View.GONE);
+ } else {
+ view.findViewById(R.id.splitter_vertical).setVisibility(View.GONE);
+ }
+ } else {
+ view.findViewById(R.id.splitter_vertical).setVisibility(View.GONE);
+ view.findViewById(R.id.splitter_horizontal).setVisibility(View.GONE);
+ }
+ } else {
+ view.findViewById(R.id.splitter_horizontal).setVisibility(View.GONE);
+ }
if (m_article != null) {
@@ -56,6 +84,7 @@ public class ArticleFragment extends Fragment {
String cssOverride = "";
if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) {
+ web.setBackgroundColor(android.R.color.black);
cssOverride = "body { background : black; color : #f0f0f0}\n";
}
@@ -87,11 +116,21 @@ public class ArticleFragment extends Fragment {
dv.setText(df.format(d));
}
- TextView cv = (TextView)view.findViewById(R.id.comments);
-
- // comments are not currently returned by the API
- if (cv != null) {
- cv.setVisibility(View.GONE);
+ TextView tagv = (TextView)view.findViewById(R.id.tags);
+
+ if (tagv != null) {
+ if (m_article.tags != null) {
+ String tagsStr = "";
+
+ for (String tag : m_article.tags)
+ tagsStr += tag + ", ";
+
+ tagsStr = tagsStr.replaceAll(", $", "");
+
+ tagv.setText(tagsStr);
+ } else {
+ tagv.setVisibility(View.GONE);
+ }
}
AdView av = (AdView)view.findViewById(R.id.ad);
@@ -106,6 +145,27 @@ public class ArticleFragment extends Fragment {
av.setVisibility(View.GONE);
}
}
+
+ ImageView next = (ImageView)view.findViewById(R.id.next_article);
+
+ if (next != null) {
+ if (m_nextArticle != null) {
+ next.setOnClickListener(this);
+ } else {
+ next.setImageResource(R.drawable.ic_next_article_disabled);
+ }
+ }
+
+ ImageView prev = (ImageView)view.findViewById(R.id.prev_article);
+
+ if (prev != null) {
+ if (m_prevArticle != null) {
+ prev.setOnClickListener(this);
+ } else {
+ prev.setImageResource(R.drawable.ic_prev_article_disabled);
+ }
+ }
+
}
return view;
@@ -130,6 +190,17 @@ public class ArticleFragment extends Fragment {
m_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
m_articleOps = (ArticleOps)activity;
m_article = m_articleOps.getSelectedArticle();
+
+ m_prevArticle = m_articleOps.getRelativeArticle(m_article, RelativeArticle.BEFORE);
+ m_nextArticle = m_articleOps.getRelativeArticle(m_article, RelativeArticle.AFTER);
+ }
+ @Override
+ public void onClick(View v) {
+ if (v.getId() == R.id.next_article) {
+ m_articleOps.openArticle(m_nextArticle, 0);
+ } else if (v.getId() == R.id.prev_article) {
+ m_articleOps.openArticle(m_prevArticle, R.anim.slide_right);
+ }
}
}
diff --git a/src/org/fox/ttrss/ArticleOps.java b/src/org/fox/ttrss/ArticleOps.java
index 16fa8e7e..070fbd29 100644
--- a/src/org/fox/ttrss/ArticleOps.java
+++ b/src/org/fox/ttrss/ArticleOps.java
@@ -1,11 +1,14 @@
package org.fox.ttrss;
public interface ArticleOps {
+ public enum RelativeArticle { BEFORE, AFTER };
+
public Article getSelectedArticle();
public void saveArticleUnread(final Article article);
public void saveArticleMarked(final Article article);
public void saveArticlePublished(final Article article);
- public void onArticleOpened(Article article);
public void updateHeadlines();
+ public void openArticle(Article article, int compatAnimation);
+ public Article getRelativeArticle(Article article, RelativeArticle ra);
}
diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java
index ba53b3a4..8e0d9756 100644
--- a/src/org/fox/ttrss/HeadlinesFragment.java
+++ b/src/org/fox/ttrss/HeadlinesFragment.java
@@ -93,13 +93,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
if (list != null) {
Article article = (Article)list.getItemAtPosition(position);
- m_articleOps.onArticleOpened(article);
+ m_articleOps.openArticle(article, 0);
- if (article.unread) {
- article.unread = false;
- m_articleOps.saveArticleUnread(article);
- }
-
m_activeArticleId = article.id;
m_adapter.notifyDataSetChanged();
}
@@ -380,4 +375,20 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
m_adapter.notifyDataSetChanged();
}
+ public ArticleList getAllArticles() {
+ return m_articles;
+ }
+
+ public void setActiveArticleId(int id) {
+ m_activeArticleId = id;
+ m_adapter.notifyDataSetChanged();
+
+ ListView list = (ListView)getView().findViewById(R.id.headlines);
+
+ if (list != null) {
+ int position = m_adapter.getPosition(m_articleOps.getSelectedArticle());
+ list.setSelection(position);
+ }
+ }
+
}
diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java
index 08971d59..10beb477 100644
--- a/src/org/fox/ttrss/MainActivity.java
+++ b/src/org/fox/ttrss/MainActivity.java
@@ -148,6 +148,10 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
/** Called when the activity is first created. */
+ public boolean isSmallScreen() {
+ return m_smallScreenMode;
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
m_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
@@ -627,10 +631,21 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
}
}
- public void openArticle(Article article) {
+ public void openArticle(Article article, int compatAnimation) {
m_selectedArticle = article;
+ if (article.unread) {
+ article.unread = false;
+ saveArticleUnread(article);
+ }
+
initMainMenu();
+
+ HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment);
+
+ if (hf != null) {
+ hf.setActiveArticleId(article.id);
+ }
ArticleFragment frag = new ArticleFragment();
@@ -639,7 +654,10 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
ft.commit();
if (m_compatMode) {
- findViewById(R.id.main).setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_left));
+ if (compatAnimation == 0)
+ findViewById(R.id.main).setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_left));
+ else
+ findViewById(R.id.main).setAnimation(AnimationUtils.loadAnimation(this, compatAnimation));
}
if (m_smallScreenMode) {
@@ -652,11 +670,6 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
}
- @Override
- public void onArticleOpened(Article article) {
- openArticle(article);
- }
-
public Feed getActiveFeed() {
return m_activeFeed;
}
@@ -714,4 +727,32 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
setLoadingStatus(R.string.login_in_progress, true);
}
}
+
+ @Override
+ public Article getRelativeArticle(Article article, RelativeArticle ra) {
+ HeadlinesFragment frag = (HeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment);
+ if (frag != null) {
+ ArticleList articles = frag.getAllArticles();
+ for (int i = 0; i < articles.size(); i++) {
+ Article a = articles.get(i);
+
+ if (a.id == article.id) {
+ if (ra == RelativeArticle.AFTER) {
+ try {
+ return articles.get(i+1);
+ } catch (IndexOutOfBoundsException e) {
+ return null;
+ }
+ } else {
+ try {
+ return articles.get(i-1);
+ } catch (IndexOutOfBoundsException e) {
+ return null;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
} \ No newline at end of file