diff options
author | Andrew Dolgov <[email protected]> | 2013-11-27 18:58:25 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2013-11-27 18:58:25 +0400 |
commit | 5e8a618fd822f1a64888737bbb3a12831fe872a6 (patch) | |
tree | 2d660b569e5f84a99615e68541a74cbbe0d27d3d /src/org | |
parent | 033dec883ac016270b4df749c091b64f0e9b3518 (diff) |
add unsubscribe to feed context menu
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/fox/ttrss/FeedsActivity.java | 22 | ||||
-rw-r--r-- | src/org/fox/ttrss/FeedsFragment.java | 29 | ||||
-rw-r--r-- | src/org/fox/ttrss/OnlineActivity.java | 2 |
3 files changed, 52 insertions, 1 deletions
diff --git a/src/org/fox/ttrss/FeedsActivity.java b/src/org/fox/ttrss/FeedsActivity.java index 39b5f487..9c8a54bc 100644 --- a/src/org/fox/ttrss/FeedsActivity.java +++ b/src/org/fox/ttrss/FeedsActivity.java @@ -2,6 +2,7 @@ package org.fox.ttrss; import java.util.Date; +import java.util.HashMap; import org.fox.ttrss.types.Article; import org.fox.ttrss.types.ArticleList; @@ -25,6 +26,7 @@ import android.util.Log; import android.widget.LinearLayout; import com.actionbarsherlock.view.MenuItem; +import com.google.gson.JsonElement; import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu; public class FeedsActivity extends OnlineActivity implements HeadlinesEventListener { @@ -459,4 +461,24 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe public void createCategoryShortcut(FeedCategory cat) { createFeedShortcut(new Feed(cat.id, cat.title, true)); } + + public void unsubscribeFeed(final Feed feed) { + ApiRequest req = new ApiRequest(getApplicationContext()) { + protected void onPostExecute(JsonElement result) { + refresh(); + } + }; + + @SuppressWarnings("serial") + HashMap<String, String> map = new HashMap<String, String>() { + { + put("sid", getSessionId()); + put("op", "unsubscribeFeed"); + put("feed_id", String.valueOf(feed.id)); + } + }; + + req.execute(map); + + } } diff --git a/src/org/fox/ttrss/FeedsFragment.java b/src/org/fox/ttrss/FeedsFragment.java index 430294ed..cd08b35f 100644 --- a/src/org/fox/ttrss/FeedsFragment.java +++ b/src/org/fox/ttrss/FeedsFragment.java @@ -159,6 +159,35 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh } } return true; + case R.id.unsubscribe_feed: + if (true) { + final Feed feed = getFeedAtPosition(info.position); + + AlertDialog.Builder builder = new AlertDialog.Builder( + m_activity) + .setMessage(getString(R.string.unsubscribe_from_prompt, feed.title)) + .setPositiveButton(R.string.unsubscribe, + new Dialog.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + + m_activity.unsubscribeFeed(feed); + + } + }) + .setNegativeButton(R.string.dialog_cancel, + new Dialog.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + + } + }); + + AlertDialog dlg = builder.create(); + dlg.show(); + } + + return true; case R.id.create_shortcut: if (true) { Feed feed = getFeedAtPosition(info.position); diff --git a/src/org/fox/ttrss/OnlineActivity.java b/src/org/fox/ttrss/OnlineActivity.java index d68c3642..8d856cd9 100644 --- a/src/org/fox/ttrss/OnlineActivity.java +++ b/src/org/fox/ttrss/OnlineActivity.java @@ -1004,7 +1004,7 @@ public class OnlineActivity extends CommonActivity { if (getApiLevel() != 7) { editArticleLabels(ap.getSelectedArticle()); } else { - toast("Sorry, this function is not available on your tt-rss version."); + toast(R.string.server_function_not_available); } } |