From 0020fdf172f65cad4e4c405ebb0bf40a6e5afb4e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 5 Sep 2012 19:00:02 +0400 Subject: [PATCH] add toast notifications for article mark/publish/setnote --- res/values/strings.xml | 5 +++++ src/org/fox/ttrss/CommonActivity.java | 10 ++++++++++ src/org/fox/ttrss/MainActivity.java | 24 ++++++++++++++++++------ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 137af4d9..34085feb 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -123,4 +123,9 @@ Close article Open preferences Please fill in your tt-rss server information such as URL, login, and password. + Article starred + Article unstarred + Article published + Article unpublished + Article note saved \ No newline at end of file diff --git a/src/org/fox/ttrss/CommonActivity.java b/src/org/fox/ttrss/CommonActivity.java index f0b678ae..d88775b3 100644 --- a/src/org/fox/ttrss/CommonActivity.java +++ b/src/org/fox/ttrss/CommonActivity.java @@ -31,6 +31,16 @@ public class CommonActivity extends FragmentActivity { m_smallScreenMode = smallScreen; } + public void toast(int msgId) { + Toast toast = Toast.makeText(CommonActivity.this, msgId, Toast.LENGTH_SHORT); + toast.show(); + } + + public void toast(String msg) { + Toast toast = Toast.makeText(CommonActivity.this, msg, Toast.LENGTH_SHORT); + toast.show(); + } + protected void detectSmallTablet() { DisplayMetrics displayMetrics = new DisplayMetrics(); diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java index bb72543c..e4dcee69 100644 --- a/src/org/fox/ttrss/MainActivity.java +++ b/src/org/fox/ttrss/MainActivity.java @@ -307,8 +307,7 @@ public class MainActivity extends CommonActivity implements OnlineServices { refresh(); - Toast toast = Toast.makeText(MainActivity.this, R.string.offline_sync_success, Toast.LENGTH_SHORT); - toast.show(); + toast(R.string.offline_sync_success); } } @@ -381,7 +380,11 @@ public class MainActivity extends CommonActivity implements OnlineServices { @SuppressWarnings({ "unchecked", "serial" }) public void saveArticleMarked(final Article article) { - ApiRequest req = new ApiRequest(getApplicationContext()); + ApiRequest req = new ApiRequest(getApplicationContext()) { + protected void onPostExecute(JsonElement result) { + toast(article.marked ? R.string.notify_article_marked : R.string.notify_article_unmarked); + } + }; HashMap map = new HashMap() { { @@ -392,13 +395,18 @@ public class MainActivity extends CommonActivity implements OnlineServices { put("field", "0"); } }; - + req.execute(map); } @SuppressWarnings({ "unchecked", "serial" }) public void saveArticlePublished(final Article article) { - ApiRequest req = new ApiRequest(getApplicationContext()); + + ApiRequest req = new ApiRequest(getApplicationContext()) { + protected void onPostExecute(JsonElement result) { + toast(article.published ? R.string.notify_article_published : R.string.notify_article_unpublished); + } + }; HashMap map = new HashMap() { { @@ -415,7 +423,11 @@ public class MainActivity extends CommonActivity implements OnlineServices { @SuppressWarnings({ "unchecked", "serial" }) public void saveArticleNote(final Article article, final String note) { - ApiRequest req = new ApiRequest(getApplicationContext()); + ApiRequest req = new ApiRequest(getApplicationContext()) { + protected void onPostExecute(JsonElement result) { + toast(R.string.notify_article_note_set); + } + }; HashMap map = new HashMap() { {