catchup above uses general catchup confirmation setting
This commit is contained in:
parent
d95d9f75bb
commit
6e336ec8ac
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.fox.ttrss"
|
||||
android:versionCode="412"
|
||||
android:versionName="1.178" >
|
||||
android:versionCode="413"
|
||||
android:versionName="1.179" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="16"
|
||||
|
@ -1,7 +1,10 @@
|
||||
package org.fox.ttrss;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
@ -181,6 +184,45 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
return true;
|
||||
case R.id.catchup_above:
|
||||
if (true) {
|
||||
|
||||
if (m_prefs.getBoolean("confirm_headlines_catchup", true)) {
|
||||
final Article fa = article;
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||
m_activity)
|
||||
.setMessage(R.string.confirm_catchup_above)
|
||||
.setPositiveButton(R.string.dialog_ok,
|
||||
new Dialog.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int which) {
|
||||
|
||||
catchupAbove(fa);
|
||||
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.dialog_cancel,
|
||||
new Dialog.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int which) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog dlg = builder.create();
|
||||
dlg.show();
|
||||
} else {
|
||||
catchupAbove(article);
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
Log.d(TAG, "onArticleMenuItemSelected, unhandled id=" + item.getItemId());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void catchupAbove(Article article) {
|
||||
ArticleList articles = getAllArticles();
|
||||
ArticleList tmp = new ArticleList();
|
||||
for (Article a : articles) {
|
||||
@ -198,12 +240,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
}
|
||||
m_adapter.notifyDataSetChanged();
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
Log.d(TAG, "onArticleMenuItemSelected, unhandled id=" + item.getItemId());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
|
||||
|
@ -32,10 +32,6 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiscCache;
|
||||
import com.nostra13.universalimageloader.core.DefaultConfigurationFactory;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
||||
|
||||
import org.fox.ttrss.offline.OfflineActivity;
|
||||
import org.fox.ttrss.offline.OfflineDownloadService;
|
||||
@ -45,12 +41,7 @@ import org.fox.ttrss.types.Article;
|
||||
import org.fox.ttrss.types.ArticleList;
|
||||
import org.fox.ttrss.types.Feed;
|
||||
import org.fox.ttrss.types.Label;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -897,26 +888,35 @@ public class OnlineActivity extends CommonActivity {
|
||||
return true;
|
||||
case R.id.catchup_above:
|
||||
if (hf != null) {
|
||||
if (ap != null && ap.getSelectedArticle() != null) {
|
||||
Article article = ap.getSelectedArticle();
|
||||
|
||||
ArticleList articles = hf.getAllArticles();
|
||||
ArticleList tmp = new ArticleList();
|
||||
for (Article a : articles) {
|
||||
if (article.id == a.id)
|
||||
break;
|
||||
if (m_prefs.getBoolean("confirm_headlines_catchup", true)) {
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||
OnlineActivity.this)
|
||||
.setMessage(R.string.confirm_catchup_above)
|
||||
.setPositiveButton(R.string.dialog_ok,
|
||||
new Dialog.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int which) {
|
||||
|
||||
catchupAbove(hf, ap);
|
||||
|
||||
if (a.unread) {
|
||||
a.unread = false;
|
||||
tmp.add(a);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.dialog_cancel,
|
||||
new Dialog.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int which) {
|
||||
|
||||
}
|
||||
if (tmp.size() > 0) {
|
||||
toggleArticlesUnread(tmp);
|
||||
hf.notifyUpdated();
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog dlg = builder.create();
|
||||
dlg.show();
|
||||
} else {
|
||||
catchupAbove(hf, ap);
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
case R.id.set_labels:
|
||||
@ -941,6 +941,29 @@ public class OnlineActivity extends CommonActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private void catchupAbove(HeadlinesFragment hf, ArticlePager ap) {
|
||||
if (ap != null && ap.getSelectedArticle() != null) {
|
||||
Article article = ap.getSelectedArticle();
|
||||
|
||||
ArticleList articles = hf.getAllArticles();
|
||||
ArticleList tmp = new ArticleList();
|
||||
for (Article a : articles) {
|
||||
if (article.id == a.id)
|
||||
break;
|
||||
|
||||
if (a.unread) {
|
||||
a.unread = false;
|
||||
tmp.add(a);
|
||||
}
|
||||
}
|
||||
if (tmp.size() > 0) {
|
||||
toggleArticlesUnread(tmp);
|
||||
hf.notifyUpdated();
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void catchupVisibleArticles() {
|
||||
final HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||
|
||||
|
@ -22,14 +22,10 @@ import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.fox.ttrss.CommonActivity;
|
||||
import org.fox.ttrss.PreferencesActivity;
|
||||
import org.fox.ttrss.R;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
public class OfflineActivity extends CommonActivity {
|
||||
private final String TAG = this.getClass().getSimpleName();
|
||||
@ -492,6 +488,42 @@ public class OfflineActivity extends CommonActivity {
|
||||
return true;
|
||||
case R.id.catchup_above:
|
||||
if (oap != null) {
|
||||
if (m_prefs.getBoolean("confirm_headlines_catchup", true)) {
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||
OfflineActivity.this)
|
||||
.setMessage(R.string.confirm_catchup_above)
|
||||
.setPositiveButton(R.string.dialog_ok,
|
||||
new Dialog.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int which) {
|
||||
|
||||
catchupAbove(oap);
|
||||
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.dialog_cancel,
|
||||
new Dialog.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int which) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog dlg = builder.create();
|
||||
dlg.show();
|
||||
} else {
|
||||
catchupAbove(oap);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
Log.d(TAG, "onOptionsItemSelected, unhandled id=" + item.getItemId());
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void catchupAbove(OfflineArticlePager oap) {
|
||||
int articleId = oap.getSelectedArticleId();
|
||||
int feedId = oap.getFeedId();
|
||||
boolean isCat = oap.getFeedIsCat();
|
||||
@ -517,12 +549,6 @@ public class OfflineActivity extends CommonActivity {
|
||||
|
||||
refresh();
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
Log.d(TAG, "onOptionsItemSelected, unhandled id=" + item.getItemId());
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
@ -1,7 +1,10 @@
|
||||
package org.fox.ttrss.offline;
|
||||
|
||||
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.res.Resources.Theme;
|
||||
import android.database.Cursor;
|
||||
@ -129,7 +132,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean onArticleMenuItemSelected(MenuItem item, int articleId) {
|
||||
private boolean onArticleMenuItemSelected(MenuItem item, final int articleId) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.headlines_article_link_copy:
|
||||
if (true) {
|
||||
@ -159,6 +162,44 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
||||
return true;
|
||||
case R.id.catchup_above:
|
||||
if (true) {
|
||||
if (m_prefs.getBoolean("confirm_headlines_catchup", true)) {
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||
m_activity)
|
||||
.setMessage(R.string.confirm_catchup_above)
|
||||
.setPositiveButton(R.string.dialog_ok,
|
||||
new Dialog.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int which) {
|
||||
|
||||
catchupAbove(articleId);
|
||||
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.dialog_cancel,
|
||||
new Dialog.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int which) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog dlg = builder.create();
|
||||
dlg.show();
|
||||
} else {
|
||||
catchupAbove(articleId);
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
Log.d(TAG, "onArticleMenuItemSelected, unhandled id=" + item.getItemId());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void catchupAbove(int articleId) {
|
||||
SQLiteStatement stmt = null;
|
||||
|
||||
String updatedOperator = (m_prefs.getBoolean("offline_oldest_first", false)) ? "<" : ">";
|
||||
@ -179,14 +220,8 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
||||
stmt.bindLong(2, m_feedId);
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
}
|
||||
refresh();
|
||||
return true;
|
||||
default:
|
||||
Log.d(TAG, "onArticleMenuItemSelected, unhandled id=" + item.getItemId());
|
||||
return false;
|
||||
}
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -241,4 +241,6 @@
|
||||
<string name="open_with_app">Open with app</string>
|
||||
<string name="prefs_opening_links">Opening links</string>
|
||||
<string name="open_with">Open with…</string>
|
||||
<string name="confirm_catchup_above">Mark articles as read?</string>
|
||||
<string name="dialog_ok">OK</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user