summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/anim/slide_in_left.xml16
-rw-r--r--res/layout/feeds_row_selected.xml26
-rw-r--r--res/layout/headlines_fragment.xml2
-rw-r--r--res/layout/headlines_row.xml20
-rw-r--r--res/layout/headlines_row_selected.xml24
-rw-r--r--res/layout/headlines_row_unread.xml24
-rw-r--r--res/values/attrs.xml2
-rw-r--r--res/values/style.xml26
-rw-r--r--src/org/fox/ttrss/ArticleFragment.java3
-rw-r--r--src/org/fox/ttrss/FeedsFragment.java47
-rw-r--r--src/org/fox/ttrss/HeadlinesFragment.java66
-rw-r--r--src/org/fox/ttrss/MainActivity.java3
12 files changed, 193 insertions, 66 deletions
diff --git a/res/anim/slide_in_left.xml b/res/anim/slide_in_left.xml
index 10a16677..11991019 100644
--- a/res/anim/slide_in_left.xml
+++ b/res/anim/slide_in_left.xml
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
-
<set>
- <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
- android:propertyName="width"
- android:duration="500"
- android:valueFrom="400"
- android:valueTo="0"
- android:valueType="intType"/>
-</set>
-
+ <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
+ android:propertyName="x"
+ android:valueType="floatType"
+ android:valueFrom="-1280"
+ android:valueTo="0"
+ android:duration="500"/>
+</set> \ No newline at end of file
diff --git a/res/layout/feeds_row_selected.xml b/res/layout/feeds_row_selected.xml
new file mode 100644
index 00000000..7ee526f7
--- /dev/null
+++ b/res/layout/feeds_row_selected.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_height="?android:attr/listPreferredItemHeight"
+ android:orientation="horizontal"
+ android:background="?feedsSelectedBackground"
+ android:gravity="center_vertical"
+ android:id="@+id/feeds_row" android:layout_width="match_parent" android:paddingBottom="4dip" android:paddingLeft="8dip" android:paddingRight="8dip" android:paddingTop="4dip">
+ <TextView
+ android:id="@+id/title"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layout_gravity="center_vertical"
+ android:paddingLeft="6dip"
+ android:text="{FEED}" android:layout_width="wrap_content" android:textSize="21dp"/>
+ <TextView
+ android:id="@+id/unread_counter"
+ android:gravity="right"
+ android:textStyle="bold"
+ android:paddingRight="6dip"
+ android:textColor="?unreadCounterColor"
+ android:layout_gravity="center_vertical"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="{123}" android:textSize="16dp"/>
+
+</LinearLayout> \ No newline at end of file
diff --git a/res/layout/headlines_fragment.xml b/res/layout/headlines_fragment.xml
index c5536c5c..83174697 100644
--- a/res/layout/headlines_fragment.xml
+++ b/res/layout/headlines_fragment.xml
@@ -3,7 +3,7 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/headlines_fragment">
- <ListView android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/headlines" android:background="?headlinesBackground"></ListView>
+ <ListView android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/headlines"></ListView>
<LinearLayout android:id="@+id/loading_container" android:gravity="center" android:layout_height="match_parent" android:layout_width="match_parent">
<ProgressBar android:layout_width="wrap_content" style="?android:attr/progressBarStyleLarge" android:id="@+id/loading_progress" android:layout_height="wrap_content"></ProgressBar>
<TextView android:layout_width="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:id="@+id/loading_message" android:layout_height="wrap_content" ></TextView>
diff --git a/res/layout/headlines_row.xml b/res/layout/headlines_row.xml
index 656ff80a..b47528d0 100644
--- a/res/layout/headlines_row.xml
+++ b/res/layout/headlines_row.xml
@@ -2,14 +2,20 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:gravity="center_vertical"
- android:padding="3dip" android:id="@+id/headlines_row" android:orientation="horizontal" android:layout_height="wrap_content">
+ android:id="@+id/headlines_row" android:orientation="horizontal" android:layout_height="wrap_content">
+ <ImageView android:background="?feedsSelectedBackground" android:paddingRight="4dip" android:layout_height="match_parent" android:layout_width="wrap_content"></ImageView>
<CheckBox android:focusable="false"
android:paddingLeft="6dip" android:paddingRight="6dip" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/selected"></CheckBox>
- <ImageView android:layout_width="wrap_content" android:id="@+id/imageView1" android:layout_height="wrap_content" android:src="@android:drawable/star_off" android:paddingRight="5dip" android:clickable="true"></ImageView>
-
- <LinearLayout android:layout_weight="1" android:layout_height="wrap_content" android:id="@+id/linearLayout1" android:orientation="vertical" android:layout_width="match_parent">
- <TextView android:id="@+id/title" android:textSize="16sp" android:text="{Title...}" android:layout_width="match_parent" android:layout_height="match_parent"></TextView>
- <TextView android:id="@+id/excerpt" android:textSize="13sp" android:textColor="#909090" android:text="{Content excerpt...}" android:layout_width="match_parent" android:layout_height="match_parent"></TextView>
- </LinearLayout>
+ <LinearLayout android:orientation="vertical" android:id="@+id/linearLayout1" android:layout_weight="1" android:layout_width="match_parent" android:layout_height="wrap_content">
+ <TextView android:singleLine="true" android:ellipsize="end" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/title" android:text="{Title...}" android:textSize="16sp"></TextView>
+ <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/excerpt" android:text="{Content excerpt...}" android:textSize="13sp" android:textColor="#909090"></TextView>
+ </LinearLayout>
+ <LinearLayout
+ android:id="@+id/linerLayout3"
+ android:layout_width="wrap_content" android:gravity="center"
+ android:layout_height="wrap_content" android:orientation="vertical">
+ <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/date" android:text="Jan 01"></TextView>
+ <ImageView android:clickable="true" android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/star_off"></ImageView>
+ </LinearLayout>
</LinearLayout> \ No newline at end of file
diff --git a/res/layout/headlines_row_selected.xml b/res/layout/headlines_row_selected.xml
new file mode 100644
index 00000000..81760bc4
--- /dev/null
+++ b/res/layout/headlines_row_selected.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:gravity="center_vertical"
+ android:background="?headlinesSelectedBackground"
+ android:padding="3dip" android:id="@+id/headlines_row" android:orientation="horizontal" android:layout_height="wrap_content">
+ <ImageView android:background="?feedsSelectedBackground" android:paddingRight="4dip" android:layout_height="match_parent" android:layout_width="wrap_content"></ImageView>
+ <CheckBox android:focusable="false"
+ android:paddingLeft="6dip" android:paddingRight="6dip" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/selected"></CheckBox>
+
+ <LinearLayout android:layout_weight="1" android:layout_height="wrap_content" android:id="@+id/linearLayout1" android:orientation="vertical" android:layout_width="match_parent">
+ <TextView android:singleLine="true" android:ellipsize="end" android:id="@+id/title" android:textSize="16sp" android:text="{Title...}" android:layout_width="match_parent" android:layout_height="match_parent"></TextView>
+ <TextView android:id="@+id/excerpt" android:textSize="13sp" android:textColor="#909090" android:text="{Content excerpt...}" android:layout_width="match_parent" android:layout_height="match_parent"></TextView>
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/linerLayout3"
+ android:layout_width="wrap_content" android:gravity="center"
+ android:layout_height="wrap_content" android:orientation="vertical">
+ <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/date" android:text="Jan 01"></TextView>
+ <ImageView android:clickable="true" android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/star_off"></ImageView>
+ </LinearLayout>
+
+</LinearLayout> \ No newline at end of file
diff --git a/res/layout/headlines_row_unread.xml b/res/layout/headlines_row_unread.xml
new file mode 100644
index 00000000..e139cfad
--- /dev/null
+++ b/res/layout/headlines_row_unread.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:gravity="center_vertical"
+ android:background="@android:color/white"
+ android:padding="3dip" android:id="@+id/headlines_row" android:orientation="horizontal" android:layout_height="wrap_content">
+ <ImageView android:background="?feedsSelectedBackground" android:paddingRight="4dip" android:layout_height="match_parent" android:layout_width="wrap_content"></ImageView>
+ <CheckBox android:focusable="false"
+ android:paddingLeft="6dip" android:paddingRight="6dip" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/selected"></CheckBox>
+
+ <LinearLayout android:layout_weight="1" android:layout_height="wrap_content" android:id="@+id/linearLayout1" android:orientation="vertical" android:layout_width="match_parent">
+ <TextView android:singleLine="true" android:ellipsize="end" android:id="@+id/title" android:textSize="16sp" android:text="{Title...}" android:layout_width="match_parent" android:layout_height="match_parent"></TextView>
+ <TextView android:id="@+id/excerpt" android:textSize="13sp" android:textColor="#909090" android:text="{Content excerpt...}" android:layout_width="match_parent" android:layout_height="match_parent"></TextView>
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/linerLayout3"
+ android:layout_width="wrap_content" android:gravity="center"
+ android:layout_height="wrap_content" android:orientation="vertical">
+ <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/date" android:text="Jan 01"></TextView>
+ <ImageView android:clickable="true" android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/star_off"></ImageView>
+ </LinearLayout>
+
+</LinearLayout> \ No newline at end of file
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 76647f0e..9a6bbea0 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -6,4 +6,6 @@
<attr name="headlinesBackground" format="reference|color" />
<attr name="articleHeader" format="reference|color" />
<attr name="articleDivider" format="reference|color" />
+ <attr name="headlinesSelectedBackground" format="reference|color" />
+ <attr name="feedsSelectedBackground" format="reference|color" />
</resources> \ No newline at end of file
diff --git a/res/values/style.xml b/res/values/style.xml
index 4bc343e1..69c2e1d6 100644
--- a/res/values/style.xml
+++ b/res/values/style.xml
@@ -4,8 +4,10 @@
<item name="feedlistBackground">#fafafa</item>
<item name="unreadCounterColor">#0000ff</item>
<item name="headlinesBackground">#ffffff</item>
- <item name="articleDivider">#f0f0f0</item>
- <item name="articleHeader">#E8F2FF</item>
+ <item name="articleDivider">#96c5ff</item>
+ <item name="articleHeader">#ffffff</item>
+ <item name="headlinesSelectedBackground">#fff7d5</item>
+ <item name="feedsSelectedBackground">#96C5FF</item>
</style>
<style name="DarkTheme" parent="android:Theme.Holo">
@@ -15,22 +17,8 @@
<item name="headlinesBackground">#000000</item>
<item name="articleDivider">#303030</item>
<item name="articleHeader">#101010</item>
+ <item name="headlinesSelectedBackground">#303060</item>
+ <item name="feedsSelectedBackground">#303060</item>
</style>
-
- <style name="SelectedFeed">
- <item name="android:textStyle">bold</item>
- </style>
-
- <style name="Feed">
- <item name="android:textStyle">normal</item>
- </style>
-
- <style name="UnreadArticle">
- <item name="android:textStyle">bold</item>
- </style>
-
- <style name="Article">
- <item name="android:textStyle">normal</item>
- </style>
-
+
</resources> \ No newline at end of file
diff --git a/src/org/fox/ttrss/ArticleFragment.java b/src/org/fox/ttrss/ArticleFragment.java
index 720c2271..abde36a0 100644
--- a/src/org/fox/ttrss/ArticleFragment.java
+++ b/src/org/fox/ttrss/ArticleFragment.java
@@ -2,13 +2,10 @@ package org.fox.ttrss;
import java.net.URLEncoder;
-import org.jsoup.Jsoup;
-
import android.app.Activity;
import android.app.Fragment;
import android.content.SharedPreferences;
import android.os.Bundle;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
diff --git a/src/org/fox/ttrss/FeedsFragment.java b/src/org/fox/ttrss/FeedsFragment.java
index ad2bd2ef..3b5fefbc 100644
--- a/src/org/fox/ttrss/FeedsFragment.java
+++ b/src/org/fox/ttrss/FeedsFragment.java
@@ -35,6 +35,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener {
private FeedListAdapter m_adapter;
private List<Feed> m_feeds = new ArrayList<Feed>();
private OnFeedSelectedListener m_feedSelectedListener;
+ private int m_selectedFeedId;
public interface OnFeedSelectedListener {
public void onFeedSelected(Feed feed);
@@ -64,7 +65,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener {
ListView list = (ListView)view.findViewById(R.id.feeds);
m_adapter = new FeedListAdapter(getActivity(), R.layout.feeds_row, (ArrayList<Feed>)m_feeds);
list.setAdapter(m_adapter);
- list.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
+ //list.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
list.setOnItemClickListener(this);
//if (m_sessionId != null)
@@ -104,6 +105,8 @@ public class FeedsFragment extends Fragment implements OnItemClickListener {
if (list != null) {
Feed feed = (Feed)list.getItemAtPosition(position);
m_feedSelectedListener.onFeedSelected(feed);
+ m_selectedFeedId = feed.id;
+ m_adapter.notifyDataSetChanged();
}
}
@@ -217,34 +220,55 @@ public class FeedsFragment extends Fragment implements OnItemClickListener {
private class FeedListAdapter extends ArrayAdapter<Feed> {
private ArrayList<Feed> items;
+ public static final int VIEW_NORMAL = 0;
+ public static final int VIEW_SELECTED = 1;
+
+ public static final int VIEW_COUNT = VIEW_SELECTED+1;
+
public FeedListAdapter(Context context, int textViewResourceId, ArrayList<Feed> items) {
super(context, textViewResourceId, items);
this.items = items;
}
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- Feed active_feed = ((MainActivity)getActivity()).getActiveFeed();
+ public int getViewTypeCount() {
+ return VIEW_COUNT;
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ Feed feed = items.get(position);
+ if (feed.id == m_selectedFeedId) {
+ return VIEW_SELECTED;
+ } else {
+ return VIEW_NORMAL;
+ }
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
Feed feed = items.get(position);
if (v == null) {
+ int layoutId = R.layout.feeds_row;
+
+ switch (getItemViewType(position)) {
+ case VIEW_SELECTED:
+ layoutId = R.layout.feeds_row_selected;
+ break;
+ }
+
LayoutInflater vi = (LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- v = vi.inflate(R.layout.feeds_row, null);
+ v = vi.inflate(layoutId, null);
+
}
TextView tt = (TextView) v.findViewById(R.id.title);
if (tt != null) {
tt.setText(feed.title);
-
- if (active_feed != null && feed.id == active_feed.id)
- tt.setTextAppearance(getContext(), R.style.SelectedFeed);
- else
- tt.setTextAppearance(getContext(), R.style.Feed);
}
TextView tu = (TextView) v.findViewById(R.id.unread_counter);
@@ -257,5 +281,4 @@ public class FeedsFragment extends Fragment implements OnItemClickListener {
return v;
}
}
-
}
diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java
index 8aceb830..00e1448e 100644
--- a/src/org/fox/ttrss/HeadlinesFragment.java
+++ b/src/org/fox/ttrss/HeadlinesFragment.java
@@ -1,16 +1,17 @@
package org.fox.ttrss;
import java.lang.reflect.Type;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Date;
import java.util.HashMap;
import java.util.List;
-import org.fox.ttrss.FeedsFragment.OnFeedSelectedListener;
import org.jsoup.Jsoup;
import android.app.Activity;
import android.app.Fragment;
-import android.app.FragmentTransaction;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
@@ -37,6 +38,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
private String m_sessionId;
private Feed m_feed;
//private int m_activeArticleId;
+ private int m_selectedArticleId;
private ArticleListAdapter m_adapter;
private List<Article> m_articles = new ArrayList<Article>();
@@ -98,6 +100,10 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
if (list != null) {
Article article = (Article)list.getItemAtPosition(position);
m_articleSelectedListener.onArticleSelected(article);
+
+ article.unread = false;
+ m_selectedArticleId = article.id;
+ m_adapter.notifyDataSetChanged();
}
}
@@ -115,6 +121,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
put("limit", String.valueOf(30));
put("offset", String.valueOf(0));
put("view_mode", "adaptive");
+ //put("view_mode", "all_articles");
}
};
@@ -197,35 +204,62 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
private class ArticleListAdapter extends ArrayAdapter<Article> {
private ArrayList<Article> items;
+
+ public static final int VIEW_NORMAL = 0;
+ public static final int VIEW_UNREAD = 1;
+ public static final int VIEW_SELECTED = 2;
+
+ public static final int VIEW_COUNT = VIEW_SELECTED+1;
public ArticleListAdapter(Context context, int textViewResourceId, ArrayList<Article> items) {
super(context, textViewResourceId, items);
this.items = items;
}
+ public int getViewTypeCount() {
+ return VIEW_COUNT;
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ Article a = items.get(position);
+
+ if (a.id == m_selectedArticleId) {
+ return VIEW_SELECTED;
+ } else if (a.unread) {
+ return VIEW_UNREAD;
+ } else {
+ return VIEW_NORMAL;
+ }
+ }
+
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
Article article = items.get(position);
-
+
if (v == null) {
+ int layoutId = R.layout.headlines_row;
+
+ switch (getItemViewType(position)) {
+ case VIEW_UNREAD:
+ layoutId = R.layout.headlines_row_unread;
+ break;
+ case VIEW_SELECTED:
+ layoutId = R.layout.headlines_row_selected;
+ break;
+ }
+
LayoutInflater vi = (LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- v = vi.inflate(R.layout.headlines_row, null);
+ v = vi.inflate(layoutId, null);
}
TextView tt = (TextView) v.findViewById(R.id.title);
if (tt != null) {
tt.setText(article.title);
- //tt.setTextAppearance(getContext(), R.style.Connection);
-
- if (article.unread)
- tt.setTextAppearance(getContext(), R.style.UnreadArticle);
- else
- tt.setTextAppearance(getContext(), R.style.Article);
-
}
TextView te = (TextView) v.findViewById(R.id.excerpt);
@@ -234,11 +268,19 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
String excerpt = Jsoup.parse(article.content).text();
if (excerpt.length() > 250)
- excerpt = excerpt.substring(0, 250) + "...";
+ excerpt = excerpt.substring(0, 100) + "...";
te.setText(excerpt);
}
+ TextView dv = (TextView) v.findViewById(R.id.date);
+
+ if (dv != null) {
+ Date d = new Date((long)article.updated * 1000);
+ DateFormat df = new SimpleDateFormat("MMM dd, HH:mm");
+ dv.setText(df.format(d));
+ }
+
return v;
}
}
diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java
index e839c55b..35309338 100644
--- a/src/org/fox/ttrss/MainActivity.java
+++ b/src/org/fox/ttrss/MainActivity.java
@@ -315,9 +315,6 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect
m_selectedArticle = article;
- article.unread = false;
-
-
ArticleFragment frag = new ArticleFragment();
FragmentTransaction ft = getFragmentManager().beginTransaction();