From 709b3838bbe00f873ec7e1d18dde52b72517240f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 18 May 2013 13:28:10 +0400 Subject: [PATCH] add preference to confirm marking headlines as read --- res/values/strings.xml | 1 + res/xml/preferences.xml | 6 ++ src/org/fox/ttrss/OnlineActivity.java | 107 +++++++++++++++----------- 3 files changed, 67 insertions(+), 47 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 9212a1e6..05df6e0c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -196,4 +196,5 @@ Mark read on scroll Headlines will be marked read when scrolling past them Mark %1$d article(s) as read? + Confirm marking articles as read diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index e05fc5b6..6bfa0e29 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -129,6 +129,12 @@ android:defaultValue="false" android:key="full_screen_mode" android:title="@string/prefs_fullscreen_mode" /> + + + 0) { - AlertDialog.Builder builder = new AlertDialog.Builder( - OnlineActivity.this) - .setMessage(getString(R.string.mark_num_headlines_as_read, count)) - .setPositiveButton(R.string.catchup, - new Dialog.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { + if (confirm) { + AlertDialog.Builder builder = new AlertDialog.Builder( + OnlineActivity.this) + .setMessage(getString(R.string.mark_num_headlines_as_read, count)) + .setPositiveButton(R.string.catchup, + new Dialog.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { - ArticleList articles = hf.getUnreadArticles(); - - for (Article a : articles) - a.unread = false; - - ApiRequest req = new ApiRequest(getApplicationContext()) { - protected void onPostExecute(JsonElement result) { - if (hf.isAdded()) { - hf.refresh(false); - } - } - }; - - final String articleIds = articlesToIdString(articles); - - @SuppressWarnings("serial") - HashMap map = new HashMap() { - { - put("sid", getSessionId()); - put("op", "updateArticle"); - put("article_ids", articleIds); - put("mode", "0"); - put("field", "2"); - } - }; - req.execute(map); - - - } - }) - .setNegativeButton(R.string.dialog_cancel, - new Dialog.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { - - } - }); - - AlertDialog dlg = builder.create(); - dlg.show(); + catchupVisibleArticles(); + + } + }) + .setNegativeButton(R.string.dialog_cancel, + new Dialog.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + + } + }); + + AlertDialog dlg = builder.create(); + dlg.show(); + } else { + catchupVisibleArticles(); + } } } return true; @@ -1020,6 +1000,39 @@ public class OnlineActivity extends CommonActivity { } } + protected void catchupVisibleArticles() { + final HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); + + if (hf != null) { + ArticleList articles = hf.getUnreadArticles(); + + for (Article a : articles) + a.unread = false; + + ApiRequest req = new ApiRequest(getApplicationContext()) { + protected void onPostExecute(JsonElement result) { + if (hf.isAdded()) { + hf.refresh(false); + } + } + }; + + final String articleIds = articlesToIdString(articles); + + @SuppressWarnings("serial") + HashMap map = new HashMap() { + { + put("sid", getSessionId()); + put("op", "updateArticle"); + put("article_ids", articleIds); + put("mode", "0"); + put("field", "2"); + } + }; + req.execute(map); + } + } + public void editArticleNote(final Article article) { String note = "";