diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 5870003..0df62b6 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,6 +1,6 @@ diff --git a/res/values/strings.xml b/res/values/strings.xml index 701cf20..2b7188a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -23,5 +23,5 @@ API global token : Your username ID (user_id in Feed URL): Your token (token in Feed URL): - 1.5.3.1 + 1.5.3.2 diff --git a/src/fr/gaulupeau/apps/Poche/ArticlesSQLiteOpenHelper.java b/src/fr/gaulupeau/apps/Poche/ArticlesSQLiteOpenHelper.java index 7c9204a..9703dff 100644 --- a/src/fr/gaulupeau/apps/Poche/ArticlesSQLiteOpenHelper.java +++ b/src/fr/gaulupeau/apps/Poche/ArticlesSQLiteOpenHelper.java @@ -15,6 +15,7 @@ public class ArticlesSQLiteOpenHelper extends SQLiteOpenHelper { public static final String DB_NAME = "article_db.sqlite"; public static String MY_ID = "my_id"; public static String ARTICLE_TABLE = "article"; + public static String ARTICLE_DATE = "update_date"; public static String ARTICLE_ID = "article_id"; public static String ARTICLE_AUTHOR = "author"; public static String ARTICLE_CONTENT = "content"; @@ -57,6 +58,7 @@ public class ArticlesSQLiteOpenHelper extends SQLiteOpenHelper { "create table " + ARTICLE_TABLE + " (" + MY_ID + " integer primary key autoincrement not null, " + ARTICLE_AUTHOR + " text, " + + ARTICLE_DATE + " datetime, " + ARTICLE_CONTENT + " text, " + ARTICLE_TITLE + " text, " + ARTICLE_URL + " text, " + diff --git a/src/fr/gaulupeau/apps/Poche/ListArticles.java b/src/fr/gaulupeau/apps/Poche/ListArticles.java index 199235d..bc0b359 100644 --- a/src/fr/gaulupeau/apps/Poche/ListArticles.java +++ b/src/fr/gaulupeau/apps/Poche/ListArticles.java @@ -94,7 +94,7 @@ public class ListArticles extends Activity { Cursor ac = database.query( ARTICLE_TABLE, getStrColumns, - filter, null, null, null, null); + filter, null, null, null, ARTICLE_DATE + " DESC"); ac.moveToFirst(); if(!ac.isAfterLast()) { do { diff --git a/src/fr/gaulupeau/apps/Poche/Poche.java b/src/fr/gaulupeau/apps/Poche/Poche.java index 7487f8c..cb0c2c9 100644 --- a/src/fr/gaulupeau/apps/Poche/Poche.java +++ b/src/fr/gaulupeau/apps/Poche/Poche.java @@ -19,6 +19,8 @@ import java.net.URL; import java.security.SecureRandom; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; +import java.text.DateFormat; +import java.util.Date; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; @@ -45,6 +47,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.database.sqlite.SQLiteConstraintException; import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteException; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.Uri; @@ -68,6 +71,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_TITLE; import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_CONTENT; import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARCHIVE; import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_SYNC; +import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE; @@ -392,6 +396,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_SYNC; arrays.PodcastURL = new String[itemLst.getLength()]; arrays.PodcastContent = new String[itemLst.getLength()]; arrays.PodcastMedia = new String[itemLst.getLength()]; + arrays.PodcastDate = new String[itemLst.getLength()]; // Loop through the XML passing the data to the arrays for (int i = 0; i < itemLst.getLength(); i++) @@ -407,6 +412,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_SYNC; // and remove elements that you want / don't want NodeList title = ielem.getElementsByTagName("title"); NodeList link = ielem.getElementsByTagName("link"); + NodeList date = ielem.getElementsByTagName("pubDate"); NodeList content = ielem .getElementsByTagName("description"); //NodeList media = ielem @@ -429,7 +435,12 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_SYNC; e.printStackTrace(); arrays.PodcastTitle[i] = "Echec"; } - + try { + arrays.PodcastDate[i] = date.item(0).getChildNodes().item(0).getNodeValue(); + } catch (NullPointerException e) { + e.printStackTrace(); + arrays.PodcastDate[i] = null; + } try { arrays.PodcastURL[i] = link.item(0).getChildNodes() @@ -454,13 +465,17 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_SYNC; values.put(ARTICLE_CONTENT, Html.fromHtml(arrays.PodcastContent[i]).toString()); //values.put(ARTICLE_ID, Html.fromHtml(article.getString("id")).toString()); values.put(ARTICLE_URL, Html.fromHtml(arrays.PodcastURL[i]).toString()); + values.put(ARTICLE_DATE, arrays.PodcastDate[i]); values.put(ARCHIVE, 0); values.put(ARTICLE_SYNC, 0); try { database.insertOrThrow(ARTICLE_TABLE, null, values); } catch (SQLiteConstraintException e) { continue; - } + } catch (SQLiteException e) { + database.execSQL("ALTER TABLE " + ARTICLE_TABLE + " ADD COLUMN " + ARTICLE_DATE + " datetime;"); + database.insertOrThrow(ARTICLE_TABLE, null, values); + } } } diff --git a/src/fr/gaulupeau/apps/Poche/ReadArticle.java b/src/fr/gaulupeau/apps/Poche/ReadArticle.java index 1537d89..aa724e1 100644 --- a/src/fr/gaulupeau/apps/Poche/ReadArticle.java +++ b/src/fr/gaulupeau/apps/Poche/ReadArticle.java @@ -62,6 +62,7 @@ public class ReadArticle extends Activity { ContentValues values = new ContentValues(); values.put(ARCHIVE, 1); database.update(ARTICLE_TABLE, values, MY_ID + "=" + id, null); + finish(); } }); diff --git a/src/fr/gaulupeau/apps/Poche/arrays.java b/src/fr/gaulupeau/apps/Poche/arrays.java index e9cf37d..288c7f4 100644 --- a/src/fr/gaulupeau/apps/Poche/arrays.java +++ b/src/fr/gaulupeau/apps/Poche/arrays.java @@ -5,4 +5,5 @@ public class arrays { public static String[] PodcastURL; public static String[] PodcastContent; public static String[] PodcastMedia; + public static String[] PodcastDate; }