confirm if necessary catching up feed from context menu

This commit is contained in:
Andrew Dolgov 2013-09-09 13:52:16 +04:00
parent e01bec4815
commit 9da4f1e5f7
3 changed files with 64 additions and 4 deletions

View File

@ -200,4 +200,5 @@
<string name="author_formatted">by %1$s</string>
<string name="n_unread_articles">%1$d unread articles</string>
<string name="pref_headline_font_size">Headline text size</string>
<string name="context_confirm_catchup">Mark all articles in %1$s as read?</string>
</resources>

View File

@ -13,7 +13,10 @@ import org.fox.ttrss.types.FeedCategoryList;
import android.annotation.SuppressLint;
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.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
@ -125,9 +128,36 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
return true;
case R.id.catchup_category:
if (true) {
FeedCategory cat = getCategoryAtPosition(info.position);
final FeedCategory cat = getCategoryAtPosition(info.position);
if (cat != null) {
m_activity.catchupFeed(new Feed(cat.id, cat.title, true));
if (m_prefs.getBoolean("confirm_headlines_catchup", true)) {
AlertDialog.Builder builder = new AlertDialog.Builder(
m_activity)
.setMessage(getString(R.string.context_confirm_catchup, cat.title))
.setPositiveButton(R.string.catchup,
new Dialog.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
m_activity.catchupFeed(new Feed(cat.id, cat.title, true));
}
})
.setNegativeButton(R.string.dialog_cancel,
new Dialog.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
}
});
AlertDialog dlg = builder.create();
dlg.show();
} else {
m_activity.catchupFeed(new Feed(cat.id, cat.title, true));
}
}
}
return true;

View File

@ -19,7 +19,10 @@ import org.fox.ttrss.types.FeedList;
import android.annotation.SuppressLint;
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.SharedPreferences.OnSharedPreferenceChangeListener;
import android.graphics.Bitmap;
@ -156,9 +159,35 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
return true;
case R.id.catchup_feed:
if (true) {
Feed feed = getFeedAtPosition(info.position);
final Feed feed = getFeedAtPosition(info.position);
if (feed != null) {
m_activity.catchupFeed(feed);
if (m_prefs.getBoolean("confirm_headlines_catchup", true)) {
AlertDialog.Builder builder = new AlertDialog.Builder(
m_activity)
.setMessage(getString(R.string.context_confirm_catchup, feed.title))
.setPositiveButton(R.string.catchup,
new Dialog.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
m_activity.catchupFeed(feed);
}
})
.setNegativeButton(R.string.dialog_cancel,
new Dialog.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
}
});
AlertDialog dlg = builder.create();
dlg.show();
} else {
m_activity.catchupFeed(feed);
}
}
}
return true;