aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rwxr-xr-xapp/src/main/java/org/rssin/android/FeedItemAdapter.java3
-rw-r--r--app/src/main/java/org/rssin/android/FirstTimeBoot.java120
-rwxr-xr-xapp/src/main/java/org/rssin/android/SharedPreferencesStorageProvider.java22
-rw-r--r--app/src/main/res/layout/activity_article.xml10
-rwxr-xr-xapp/src/main/res/layout/item_feeditem.xml6
-rw-r--r--app/src/main/res/layout/walkthrough_activity.xml23
-rw-r--r--app/src/main/res/layout/walkthrough_single_view.xml5
-rw-r--r--app/src/main/res/values/feeds.xml86
9 files changed, 263 insertions, 13 deletions
diff --git a/README.md b/README.md
index 14bcb11..43511b0 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,6 @@ Copyright © 2015 Randy Wanga, Jos Craaijo, Joep Bernards, Camil Staps. All
* Background sync & notifications
* Add feed from browser
* Add tutorial (e.g.: at first startup, walk user through creating first filter)
-* Default list of feeds?
# Notes
diff --git a/app/src/main/java/org/rssin/android/FeedItemAdapter.java b/app/src/main/java/org/rssin/android/FeedItemAdapter.java
index de1766a..9090439 100755
--- a/app/src/main/java/org/rssin/android/FeedItemAdapter.java
+++ b/app/src/main/java/org/rssin/android/FeedItemAdapter.java
@@ -38,6 +38,7 @@ class FeedItemAdapter extends RecyclerView.Adapter<FeedItemAdapter.FeedItemHolde
SortedFeedItemContainer item = feedItems.get(position);
holder.title.setText(item.getFeeditem().getTitle());
holder.summary.setText(Html.fromHtml(item.getFeeditem().getDescription()));
+ holder.date.setText(item.getFeeditem().getPubDate().toString());
holder.item = item;
}
@@ -53,12 +54,14 @@ class FeedItemAdapter extends RecyclerView.Adapter<FeedItemAdapter.FeedItemHolde
static class FeedItemHolder extends RecyclerView.ViewHolder {
TextView title;
TextView summary;
+ TextView date;
SortedFeedItemContainer item;
public FeedItemHolder(final View itemView) {
super(itemView);
title = (TextView) itemView.findViewById(R.id.feeditem_title);
summary = (TextView) itemView.findViewById(R.id.feeditem_summary);
+ date = (TextView) itemView.findViewById(R.id.feeditem_date);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
diff --git a/app/src/main/java/org/rssin/android/FirstTimeBoot.java b/app/src/main/java/org/rssin/android/FirstTimeBoot.java
new file mode 100644
index 0000000..7374fff
--- /dev/null
+++ b/app/src/main/java/org/rssin/android/FirstTimeBoot.java
@@ -0,0 +1,120 @@
+package org.rssin.android;
+
+/**
+ * Created by Randy on 4-6-2015.
+ */
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.view.PagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import org.rssin.rssin.R;
+
+public class FirstTimeBoot extends Activity {
+
+ private static final int MAX_VIEWS = 5;
+
+ ViewPager mViewPager;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.walkthrough_activity);
+ mViewPager = (ViewPager) findViewById(R.id.view_pager);
+ mViewPager.setAdapter(new WalkthroughPagerAdapter());
+ mViewPager.setOnPageChangeListener(new WalkthroughPageChangeListener());
+ }
+
+
+ class WalkthroughPagerAdapter extends PagerAdapter {
+
+ @Override
+ public int getCount() {
+ return MAX_VIEWS;
+ }
+
+ @Override
+ public boolean isViewFromObject(View view, Object object) {
+ return view == (View) object;
+ }
+
+ @Override
+ public Object instantiateItem(View container, int position) {
+ Log.e("walkthrough", "instantiateItem(" + position + ");");
+ LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ View imageViewContainer = inflater.inflate(R.layout.walkthrough_single_view, null);
+ ImageView imageView = (ImageView) imageViewContainer.findViewById(R.id.image_view);
+
+ switch (position) {
+ case 0:
+ //imageView.setImageResource(R.drawable.image1);
+ break;
+
+ case 1:
+ // imageView.setImageResource(R.drawable.image2);
+ break;
+
+ case 2:
+ // imageView.setImageResource(R.drawable.image3);
+ break;
+
+ case 3:
+ // imageView.setImageResource(R.drawable.image4);
+ break;
+
+ case 4:
+ // imageView.setImageResource(R.drawable.image5);
+ break;
+ }
+
+ ((ViewPager) container).addView(imageViewContainer, 0);
+ return imageViewContainer;
+ }
+
+ @Override
+ public void destroyItem(ViewGroup container, int position, Object object) {
+ ((ViewPager) container).removeView((View) object);
+ }
+ }
+
+
+ class WalkthroughPageChangeListener implements ViewPager.OnPageChangeListener {
+
+ @Override
+ public void onPageScrollStateChanged(int arg0) {
+
+ }
+
+ @Override
+ public void onPageScrolled(int arg0, float arg1, int arg2) {
+
+ }
+
+ @Override
+ public void onPageSelected(int position) {
+ // Here is where you should show change the view of page indicator
+ switch (position) {
+
+ case MAX_VIEWS - 1:
+ break;
+
+ default:
+
+ }
+
+ }
+
+ }
+}
+
diff --git a/app/src/main/java/org/rssin/android/SharedPreferencesStorageProvider.java b/app/src/main/java/org/rssin/android/SharedPreferencesStorageProvider.java
index 4c23fa9..2818a08 100755
--- a/app/src/main/java/org/rssin/android/SharedPreferencesStorageProvider.java
+++ b/app/src/main/java/org/rssin/android/SharedPreferencesStorageProvider.java
@@ -7,6 +7,7 @@ import android.util.Log;
import org.rssin.rssin.Feed;
import org.rssin.rssin.Filter;
+import org.rssin.rssin.R;
import org.rssin.storage.FeedStorageProvider;
import org.rssin.storage.FilterStorageProvider;
import org.rssin.storage.Storable;
@@ -17,6 +18,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -76,8 +78,6 @@ class SharedPreferencesStorageProvider implements StorageProvider, FilterStorage
.edit()
.putString(element.getClass().getName(), base64)
.apply();
-
- Log.v("SPSP", "Store to " + key.toString() + ":\n" + base64);
}
@Override
@@ -88,7 +88,6 @@ class SharedPreferencesStorageProvider implements StorageProvider, FilterStorage
}
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(Base64.decode(serialized.getBytes(), Base64.DEFAULT)));
Object obj = ois.readObject();
- Log.v("SPSP", "Fetch " + className.toString() + " from " + key.toString() + ": " + obj.toString());
return (Storable) className.cast(obj);
}
@@ -116,10 +115,8 @@ class SharedPreferencesStorageProvider implements StorageProvider, FilterStorage
.getStringSet("filters", new HashSet<String>());
List<Filter> filters = new ArrayList<>();
for (String name : names) {
- Log.v("SPSP", "allFilters: " + name);
Filter filter = getFilter(name);
if (filter != null) {
- Log.v("SPSP", "allFilters: not null, returning");
filters.add(filter);
}
}
@@ -137,7 +134,7 @@ class SharedPreferencesStorageProvider implements StorageProvider, FilterStorage
try {
return (Filter) fetch(key.toString(), Filter.class);
} catch (Exception e) {
- Log.w("SPSP", "Fetch filter " + key.toString(), e);
+ Log.w("SPSP", "Fetch filter failed: " + key.toString(), e);
return null;
}
}
@@ -171,6 +168,19 @@ class SharedPreferencesStorageProvider implements StorageProvider, FilterStorage
@Override
public List<Feed> allFeeds() {
Set<String> names = context.getSharedPreferences(ADMIN_PREF_KEY, Context.MODE_PRIVATE).getStringSet("feeds", new HashSet<String>());
+ if (names.isEmpty() && !context.getSharedPreferences(ADMIN_PREF_KEY, Context.MODE_PRIVATE).getBoolean("firstload", false)) {
+ String[] feedsList = context.getResources().getStringArray(R.array.default_feeds);
+ for (String url : feedsList) {
+ try {
+ Feed f = new Feed(url);
+ f.store(this);
+ } catch (Exception e) {
+ Log.w("SPSP", "Couldn't add " + url, e);
+ }
+ }
+ context.getSharedPreferences(ADMIN_PREF_KEY, Context.MODE_PRIVATE).edit().putBoolean("firstload", true).apply();
+ names = context.getSharedPreferences(ADMIN_PREF_KEY, Context.MODE_PRIVATE).getStringSet("feeds", new HashSet<String>());
+ }
List<Feed> feeds = new ArrayList<>();
for (String name : names) {
Feed feed = getFeed(name);
diff --git a/app/src/main/res/layout/activity_article.xml b/app/src/main/res/layout/activity_article.xml
index b08fe38..da66067 100644
--- a/app/src/main/res/layout/activity_article.xml
+++ b/app/src/main/res/layout/activity_article.xml
@@ -2,19 +2,19 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:paddingBottom="@dimen/activity_vertical_margin"
- android:paddingLeft="@dimen/activity_horizontal_margin"
- android:paddingRight="@dimen/activity_horizontal_margin"
- android:paddingTop="@dimen/activity_vertical_margin"
tools:context="org.rssin.android.ArticleActivity">
<ScrollView
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:paddingTop="@dimen/activity_vertical_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
android:orientation="vertical">
<TextView
diff --git a/app/src/main/res/layout/item_feeditem.xml b/app/src/main/res/layout/item_feeditem.xml
index 3927038..1ecd1c5 100755
--- a/app/src/main/res/layout/item_feeditem.xml
+++ b/app/src/main/res/layout/item_feeditem.xml
@@ -11,7 +11,7 @@
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_margin="15dp"
+ android:layout_margin="8dp"
card_view:cardElevation="6dp"
card_view:cardCornerRadius="2dp">
@@ -29,6 +29,10 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/font_size_small"/>
+ <TextView android:id="@+id/feeditem_date"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textSize="12sp"/>
</LinearLayout>
diff --git a/app/src/main/res/layout/walkthrough_activity.xml b/app/src/main/res/layout/walkthrough_activity.xml
new file mode 100644
index 0000000..84a8c10
--- /dev/null
+++ b/app/src/main/res/layout/walkthrough_activity.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent" >
+
+ <android.support.v4.view.ViewPager
+ android:id="@+id/view_pager"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_above="@+id/screen_navigation_button" />
+
+ <!-- This TextView will not swipe when you swipe in the ViewPager -->
+
+ <TextView
+ android:id="@id/screen_navigation_button"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:gravity="center"
+ android:padding="10dip"
+ android:textSize="18sp" />
+
+</RelativeLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/walkthrough_single_view.xml b/app/src/main/res/layout/walkthrough_single_view.xml
new file mode 100644
index 0000000..e8ef067
--- /dev/null
+++ b/app/src/main/res/layout/walkthrough_single_view.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/image_view"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent" /> \ No newline at end of file
diff --git a/app/src/main/res/values/feeds.xml b/app/src/main/res/values/feeds.xml
new file mode 100644
index 0000000..e4ae386
--- /dev/null
+++ b/app/src/main/res/values/feeds.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string-array name="default_feeds">
+ <item>http://feeds.bbci.co.uk/news/business/rss.xml</item>
+ <item>http://feeds.bbci.co.uk/news/entertainment_and_arts/rss.xml</item>
+ <item>http://feeds.bbci.co.uk/news/health/rss.xml</item>
+ <item>http://feeds.bbci.co.uk/news/politics/rss.xml</item>
+ <item>http://feeds.bbci.co.uk/news/science_and_environment/rss.xml</item>
+ <item>http://feeds.bbci.co.uk/news/technology/rss.xml</item>
+ <item>http://feeds.bbci.co.uk/news/uk/rss.xml</item>
+ <item>http://feeds.bbci.co.uk/news/world/rss.xml</item>
+ <item>http://feeds.bbci.co.uk/sport/0/rss.xml</item>
+ <item>http://feeds.foxnews.com/foxnews/internal/travel/mixed</item>
+ <item>http://feeds.foxnews.com/foxnews/opinion</item>
+ <item>http://feeds.foxnews.com/foxnews/politics</item>
+ <item>http://feeds.foxnews.com/foxnews/science</item>
+ <item>http://feeds.foxnews.com/foxnews/section/lifestyle</item>
+ <item>http://feeds.foxnews.com/foxnews/sports</item>
+ <item>http://feeds.foxnews.com/foxnews/tech</item>
+ <item>http://feeds.mashable.com/mashable/business</item>
+ <item>http://feeds.mashable.com/mashable/entertainment</item>
+ <item>http://feeds.mashable.com/mashable/socialmedia</item>
+ <item>http://feeds.mashable.com/mashable/tech</item>
+ <item>http://feeds.reuters.com/news/artsculture</item>
+ <item>http://feeds.reuters.com/news/economy</item>
+ <item>http://feeds.reuters.com/news/reutersmedia</item>
+ <item>http://feeds.reuters.com/news/wealth</item>
+ <item>http://feeds.reuters.com/reuters/businessNews</item>
+ <item>http://feeds.reuters.com/reuters/entertainment</item>
+ <item>http://feeds.reuters.com/reuters/environment</item>
+ <item>http://feeds.reuters.com/reuters/financialsNews</item>
+ <item>http://feeds.reuters.com/reuters/healthNews</item>
+ <item>http://feeds.reuters.com/reuters/hotStocksNews</item>
+ <item>http://feeds.reuters.com/reuters/lifestyle</item>
+ <item>http://feeds.reuters.com/reuters/oddlyEnoughNews</item>
+ <item>http://feeds.reuters.com/Reuters/PoliticsNews</item>
+ <item>http://feeds.reuters.com/reuters/scienceNews</item>
+ <item>http://feeds.reuters.com/reuters/sportsNews</item>
+ <item>http://feeds.reuters.com/reuters/technologyNews</item>
+ <item>http://feeds.reuters.com/reuters/technologysectorNews</item>
+ <item>http://feeds.reuters.com/reuters/UShealthcareNews</item>
+ <item>http://feeds.reuters.com/reuters/worldNews</item>
+ <item>http://rss.cnn.com/rss/edition_entertainment.rss</item>
+ <item>http://rss.cnn.com/rss/edition_space.rss</item>
+ <item>http://rss.cnn.com/rss/edition_sport.rss</item>
+ <item>http://rss.cnn.com/rss/edition_technology.rss</item>
+ <item>http://rss.cnn.com/rss/money_news_international.rss</item>
+ <item>http://rss.cnn.com/rss/si_topstories.rss</item>
+ <item>http://rss.nytimes.com/services/xml/rss/nyt/Books.xml</item>
+ <item>http://rss.nytimes.com/services/xml/rss/nyt/Business.xml</item>
+ <item>http://rss.nytimes.com/services/xml/rss/nyt/Dance.xml</item>
+ <item>http://rss.nytimes.com/services/xml/rss/nyt/Economy.xml</item>
+ <item>http://rss.nytimes.com/services/xml/rss/nyt/Environment.xml</item>
+ <item>http://rss.nytimes.com/services/xml/rss/nyt/FashionandStyle.xml</item>
+ <item>http://rss.nytimes.com/services/xml/rss/nyt/MediaandAdvertising.xml</item>
+ <item>http://rss.nytimes.com/services/xml/rss/nyt/Movies.xml</item>
+ <item>http://rss.nytimes.com/services/xml/rss/nyt/Music.xml</item>
+ <item>http://rss.nytimes.com/services/xml/rss/nyt/Science.xml</item>
+ <item>http://rss.nytimes.com/services/xml/rss/nyt/Sports.xml</item>
+ <item>http://rss.nytimes.com/services/xml/rss/nyt/Technology.xml</item>
+ <item>http://rss.nytimes.com/services/xml/rss/nyt/Travel.xml</item>
+ <item>http://www.cnet.com/rss/news/</item>
+ <item>http://www.dailymail.co.uk/health/index.rss</item>
+ <item>http://www.dailymail.co.uk/money/index.rss</item>
+ <item>http://www.dailymail.co.uk/sciencetech/index.rss</item>
+ <item>http://www.dailymail.co.uk/sport/index.rss</item>
+ <item>http://www.dailymail.co.uk/tvshowbiz/index.rss</item>
+ <item>http://www.thesundaily.my/rss/business</item>
+ <item>http://www.thesundaily.my/rss/lifestyle/food</item>
+ <item>http://www.thesundaily.my/rss/lifestyle/health</item>
+ <item>http://www.thesundaily.my/rss/lifestyle/tech</item>
+ <item>http://www.thesundaily.my/rss/lifestyle/travel</item>
+ <item>http://www.thesundaily.my/rss/media-marketing</item>
+ <item>http://www.thesundaily.my/rss/opinion</item>
+ <item>http://www.thesundaily.my/rss/showbiz</item>
+ <item>http://www.thesundaily.my/rss/sports</item>
+ <item>http://www.thesundaily.my/rss/style</item>
+ <item>http://www.washingtontimes.com/rss/headlines/culture/autos/</item>
+ <item>http://www.washingtontimes.com/rss/headlines/culture/entertainment/</item>
+ <item>http://www.washingtontimes.com/rss/headlines/culture/health/</item>
+ <item>http://www.washingtontimes.com/rss/headlines/culture/travel/</item>
+ <item>http://www.washingtontimes.com/rss/headlines/news/politics/</item>
+ <item>http://www.washingtontimes.com/rss/headlines/opinion/</item>
+ <item>http://www.washingtontimes.com/rss/headlines/sports/</item>
+ </string-array>
+</resources> \ No newline at end of file