summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-05-18 13:28:10 +0400
committerAndrew Dolgov <[email protected]>2013-05-18 13:28:10 +0400
commit709b3838bbe00f873ec7e1d18dde52b72517240f (patch)
tree930fcff1367ff99e3ad560a823b3752b45ccaf82
parentc1b41d9de8559240fa6c0b8f6cae8b4266830270 (diff)
add preference to confirm marking headlines as read
-rw-r--r--res/values/strings.xml1
-rw-r--r--res/xml/preferences.xml6
-rw-r--r--src/org/fox/ttrss/OnlineActivity.java109
3 files changed, 68 insertions, 48 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 @@
<string name="pref_headlines_mark_read_scroll">Mark read on scroll</string>
<string name="pref_headlines_mark_read_scroll_long">Headlines will be marked read when scrolling past them</string>
<string name="mark_num_headlines_as_read">Mark %1$d article(s) as read?</string>
+ <string name="prefs_confirm_headlines_catchup">Confirm marking articles as read</string>
</resources>
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" />
+
+ <CheckBoxPreference
+ android:defaultValue="true"
+ android:key="confirm_headlines_catchup"
+ android:title="@string/prefs_confirm_headlines_catchup" />
+
</PreferenceCategory>
<PreferenceCategory android:title="@string/offline_mode" >
<ListPreference
diff --git a/src/org/fox/ttrss/OnlineActivity.java b/src/org/fox/ttrss/OnlineActivity.java
index 50f1c71c..1606c728 100644
--- a/src/org/fox/ttrss/OnlineActivity.java
+++ b/src/org/fox/ttrss/OnlineActivity.java
@@ -749,55 +749,35 @@ public class OnlineActivity extends CommonActivity {
int count = hf.getUnreadArticles().size();
+ boolean confirm = m_prefs.getBoolean("confirm_headlines_catchup", true);
+
if (count > 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) {
-
- 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<String, String> map = new HashMap<String, String>() {
- {
- 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();
+ 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) {
+
+ 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<String, String> map = new HashMap<String, String>() {
+ {
+ 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 = "";