diff --git a/org.fox.ttrss/src/main/AndroidManifest.xml b/org.fox.ttrss/src/main/AndroidManifest.xml index beaef47b..c6a494d6 100755 --- a/org.fox.ttrss/src/main/AndroidManifest.xml +++ b/org.fox.ttrss/src/main/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="413" + android:versionName="1.179" > 0) { - m_activity.toggleArticlesUnread(tmp); - //updateHeadlines(); - } - m_adapter.notifyDataSetChanged(); + } return true; default: @@ -205,6 +222,25 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, } } + private void catchupAbove(Article article) { + ArticleList articles = getAllArticles(); + ArticleList tmp = new ArticleList(); + for (Article a : articles) { + if (article.id == a.id) + break; + + if (a.unread) { + a.unread = false; + tmp.add(a); + } + } + if (tmp.size() > 0) { + m_activity.toggleArticlesUnread(tmp); + //updateHeadlines(); + } + m_adapter.notifyDataSetChanged(); + } + public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item .getMenuInfo(); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java index 355c5a58..b00b829f 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java @@ -32,10 +32,6 @@ import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; -import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiscCache; -import com.nostra13.universalimageloader.core.DefaultConfigurationFactory; -import com.nostra13.universalimageloader.core.ImageLoader; -import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; import org.fox.ttrss.offline.OfflineActivity; import org.fox.ttrss.offline.OfflineDownloadService; @@ -45,12 +41,7 @@ import org.fox.ttrss.types.Article; import org.fox.ttrss.types.ArticleList; import org.fox.ttrss.types.Feed; import org.fox.ttrss.types.Label; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; -import org.jsoup.select.Elements; -import java.io.File; -import java.io.IOException; import java.lang.reflect.Type; import java.util.HashMap; import java.util.List; @@ -897,26 +888,35 @@ public class OnlineActivity extends CommonActivity { return true; case R.id.catchup_above: if (hf != null) { - if (ap != null && ap.getSelectedArticle() != null) { - Article article = ap.getSelectedArticle(); - - ArticleList articles = hf.getAllArticles(); - ArticleList tmp = new ArticleList(); - for (Article a : articles) { - if (article.id == a.id) - break; - if (a.unread) { - a.unread = false; - tmp.add(a); - } - } - if (tmp.size() > 0) { - toggleArticlesUnread(tmp); - hf.notifyUpdated(); - invalidateOptionsMenu(); - } + if (m_prefs.getBoolean("confirm_headlines_catchup", true)) { + + AlertDialog.Builder builder = new AlertDialog.Builder( + OnlineActivity.this) + .setMessage(R.string.confirm_catchup_above) + .setPositiveButton(R.string.dialog_ok, + new Dialog.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + + catchupAbove(hf, ap); + + } + }) + .setNegativeButton(R.string.dialog_cancel, + new Dialog.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + + } + }); + + AlertDialog dlg = builder.create(); + dlg.show(); + } else { + catchupAbove(hf, ap); } + } return true; case R.id.set_labels: @@ -940,7 +940,30 @@ public class OnlineActivity extends CommonActivity { return super.onOptionsItemSelected(item); } } - + + private void catchupAbove(HeadlinesFragment hf, ArticlePager ap) { + if (ap != null && ap.getSelectedArticle() != null) { + Article article = ap.getSelectedArticle(); + + ArticleList articles = hf.getAllArticles(); + ArticleList tmp = new ArticleList(); + for (Article a : articles) { + if (article.id == a.id) + break; + + if (a.unread) { + a.unread = false; + tmp.add(a); + } + } + if (tmp.size() > 0) { + toggleArticlesUnread(tmp); + hf.notifyUpdated(); + invalidateOptionsMenu(); + } + } + } + protected void catchupVisibleArticles() { final HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java index 762d85d2..98b0b32d 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java @@ -22,14 +22,10 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.widget.EditText; -import android.widget.TextView; import org.fox.ttrss.CommonActivity; import org.fox.ttrss.PreferencesActivity; import org.fox.ttrss.R; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; -import org.jsoup.select.Elements; public class OfflineActivity extends CommonActivity { private final String TAG = this.getClass().getSimpleName(); @@ -492,30 +488,33 @@ public class OfflineActivity extends CommonActivity { return true; case R.id.catchup_above: if (oap != null) { - int articleId = oap.getSelectedArticleId(); - int feedId = oap.getFeedId(); - boolean isCat = oap.getFeedIsCat(); + if (m_prefs.getBoolean("confirm_headlines_catchup", true)) { - SQLiteStatement stmt = null; - - if (isCat) { - stmt = getDatabase().compileStatement( - "UPDATE articles SET modified = 1, unread = 0 WHERE " + - "updated >= (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " + - "AND feed_id IN (SELECT "+BaseColumns._ID+" FROM feeds WHERE cat_id = ?)"); + AlertDialog.Builder builder = new AlertDialog.Builder( + OfflineActivity.this) + .setMessage(R.string.confirm_catchup_above) + .setPositiveButton(R.string.dialog_ok, + new Dialog.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + + catchupAbove(oap); + + } + }) + .setNegativeButton(R.string.dialog_cancel, + new Dialog.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + + } + }); + + AlertDialog dlg = builder.create(); + dlg.show(); } else { - stmt = getDatabase().compileStatement( - "UPDATE articles SET modified = 1, unread = 0 WHERE " + - "updated >= (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " + - "AND feed_id = ?"); + catchupAbove(oap); } - - stmt.bindLong(1, articleId); - stmt.bindLong(2, feedId); - stmt.execute(); - stmt.close(); - - refresh(); } return true; default: @@ -524,6 +523,33 @@ public class OfflineActivity extends CommonActivity { } } + private void catchupAbove(OfflineArticlePager oap) { + int articleId = oap.getSelectedArticleId(); + int feedId = oap.getFeedId(); + boolean isCat = oap.getFeedIsCat(); + + SQLiteStatement stmt = null; + + if (isCat) { + stmt = getDatabase().compileStatement( + "UPDATE articles SET modified = 1, unread = 0 WHERE " + + "updated >= (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " + + "AND feed_id IN (SELECT "+BaseColumns._ID+" FROM feeds WHERE cat_id = ?)"); + } else { + stmt = getDatabase().compileStatement( + "UPDATE articles SET modified = 1, unread = 0 WHERE " + + "updated >= (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " + + "AND feed_id = ?"); + } + + stmt.bindLong(1, articleId); + stmt.bindLong(2, feedId); + stmt.execute(); + stmt.close(); + + refresh(); + } + @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java index b2ce09a1..e7e814a4 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java @@ -1,7 +1,10 @@ package org.fox.ttrss.offline; import android.app.Activity; +import android.app.AlertDialog; +import android.app.Dialog; import android.content.Context; +import android.content.DialogInterface; import android.content.SharedPreferences; import android.content.res.Resources.Theme; import android.database.Cursor; @@ -129,7 +132,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis return true; } - private boolean onArticleMenuItemSelected(MenuItem item, int articleId) { + private boolean onArticleMenuItemSelected(MenuItem item, final int articleId) { switch (item.getItemId()) { case R.id.headlines_article_link_copy: if (true) { @@ -159,28 +162,35 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis return true; case R.id.catchup_above: if (true) { - SQLiteStatement stmt = null; + if (m_prefs.getBoolean("confirm_headlines_catchup", true)) { - String updatedOperator = (m_prefs.getBoolean("offline_oldest_first", false)) ? "<" : ">"; + AlertDialog.Builder builder = new AlertDialog.Builder( + m_activity) + .setMessage(R.string.confirm_catchup_above) + .setPositiveButton(R.string.dialog_ok, + new Dialog.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { - if (m_feedIsCat) { - stmt = m_activity.getDatabase().compileStatement( - "UPDATE articles SET modified = 1, unread = 0 WHERE " + - "updated "+updatedOperator+" (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " + - "AND unread = 1 AND feed_id IN (SELECT "+BaseColumns._ID+" FROM feeds WHERE cat_id = ?)"); + catchupAbove(articleId); + + } + }) + .setNegativeButton(R.string.dialog_cancel, + new Dialog.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + + } + }); + + AlertDialog dlg = builder.create(); + dlg.show(); } else { - stmt = m_activity.getDatabase().compileStatement( - "UPDATE articles SET modified = 1, unread = 0 WHERE " + - "updated "+updatedOperator+" (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " + - "AND unread = 1 AND feed_id = ?"); + catchupAbove(articleId); } - stmt.bindLong(1, articleId); - stmt.bindLong(2, m_feedId); - stmt.execute(); - stmt.close(); } - refresh(); return true; default: Log.d(TAG, "onArticleMenuItemSelected, unhandled id=" + item.getItemId()); @@ -189,6 +199,31 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis } + private void catchupAbove(int articleId) { + SQLiteStatement stmt = null; + + String updatedOperator = (m_prefs.getBoolean("offline_oldest_first", false)) ? "<" : ">"; + + if (m_feedIsCat) { + stmt = m_activity.getDatabase().compileStatement( + "UPDATE articles SET modified = 1, unread = 0 WHERE " + + "updated "+updatedOperator+" (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " + + "AND unread = 1 AND feed_id IN (SELECT "+BaseColumns._ID+" FROM feeds WHERE cat_id = ?)"); + } else { + stmt = m_activity.getDatabase().compileStatement( + "UPDATE articles SET modified = 1, unread = 0 WHERE " + + "updated "+updatedOperator+" (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " + + "AND unread = 1 AND feed_id = ?"); + } + + stmt.bindLong(1, articleId); + stmt.bindLong(2, m_feedId); + stmt.execute(); + stmt.close(); + + refresh(); + } + @Override public void onResume() { super.onResume(); diff --git a/org.fox.ttrss/src/main/res/values/strings.xml b/org.fox.ttrss/src/main/res/values/strings.xml index cef96477..a3de6fc6 100755 --- a/org.fox.ttrss/src/main/res/values/strings.xml +++ b/org.fox.ttrss/src/main/res/values/strings.xml @@ -241,4 +241,6 @@ Open with app Opening links Open with… + Mark articles as read? + OK