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"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.fox.ttrss"
|
package="org.fox.ttrss"
|
||||||
android:versionCode="412"
|
android:versionCode="413"
|
||||||
android:versionName="1.178" >
|
android:versionName="1.179" >
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="16"
|
android:minSdkVersion="16"
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package org.fox.ttrss;
|
package org.fox.ttrss;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
@ -181,22 +184,36 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
return true;
|
return true;
|
||||||
case R.id.catchup_above:
|
case R.id.catchup_above:
|
||||||
if (true) {
|
if (true) {
|
||||||
ArticleList articles = getAllArticles();
|
|
||||||
ArticleList tmp = new ArticleList();
|
|
||||||
for (Article a : articles) {
|
|
||||||
if (article.id == a.id)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (a.unread) {
|
if (m_prefs.getBoolean("confirm_headlines_catchup", true)) {
|
||||||
a.unread = false;
|
final Article fa = article;
|
||||||
tmp.add(a);
|
|
||||||
}
|
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);
|
||||||
}
|
}
|
||||||
if (tmp.size() > 0) {
|
|
||||||
m_activity.toggleArticlesUnread(tmp);
|
|
||||||
//updateHeadlines();
|
|
||||||
}
|
|
||||||
m_adapter.notifyDataSetChanged();
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
@ -205,6 +222,25 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void catchupAbove(Article article) {
|
||||||
|
ArticleList articles = 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) {
|
||||||
|
m_activity.toggleArticlesUnread(tmp);
|
||||||
|
//updateHeadlines();
|
||||||
|
}
|
||||||
|
m_adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean onContextItemSelected(MenuItem item) {
|
public boolean onContextItemSelected(MenuItem item) {
|
||||||
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
|
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
|
||||||
.getMenuInfo();
|
.getMenuInfo();
|
||||||
|
@ -32,10 +32,6 @@ import com.google.gson.Gson;
|
|||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.reflect.TypeToken;
|
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.OfflineActivity;
|
||||||
import org.fox.ttrss.offline.OfflineDownloadService;
|
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.ArticleList;
|
||||||
import org.fox.ttrss.types.Feed;
|
import org.fox.ttrss.types.Feed;
|
||||||
import org.fox.ttrss.types.Label;
|
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.lang.reflect.Type;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -897,26 +888,35 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
return true;
|
return true;
|
||||||
case R.id.catchup_above:
|
case R.id.catchup_above:
|
||||||
if (hf != null) {
|
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 (a.unread) {
|
if (m_prefs.getBoolean("confirm_headlines_catchup", true)) {
|
||||||
a.unread = false;
|
|
||||||
tmp.add(a);
|
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||||
}
|
OnlineActivity.this)
|
||||||
}
|
.setMessage(R.string.confirm_catchup_above)
|
||||||
if (tmp.size() > 0) {
|
.setPositiveButton(R.string.dialog_ok,
|
||||||
toggleArticlesUnread(tmp);
|
new Dialog.OnClickListener() {
|
||||||
hf.notifyUpdated();
|
public void onClick(DialogInterface dialog,
|
||||||
invalidateOptionsMenu();
|
int which) {
|
||||||
}
|
|
||||||
|
catchupAbove(hf, ap);
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.dialog_cancel,
|
||||||
|
new Dialog.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog,
|
||||||
|
int which) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AlertDialog dlg = builder.create();
|
||||||
|
dlg.show();
|
||||||
|
} else {
|
||||||
|
catchupAbove(hf, ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.set_labels:
|
case R.id.set_labels:
|
||||||
@ -940,7 +940,30 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
protected void catchupVisibleArticles() {
|
||||||
final HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
final HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||||
|
|
||||||
|
@ -22,14 +22,10 @@ import android.view.Menu;
|
|||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import org.fox.ttrss.CommonActivity;
|
import org.fox.ttrss.CommonActivity;
|
||||||
import org.fox.ttrss.PreferencesActivity;
|
import org.fox.ttrss.PreferencesActivity;
|
||||||
import org.fox.ttrss.R;
|
import org.fox.ttrss.R;
|
||||||
import org.jsoup.Jsoup;
|
|
||||||
import org.jsoup.nodes.Document;
|
|
||||||
import org.jsoup.select.Elements;
|
|
||||||
|
|
||||||
public class OfflineActivity extends CommonActivity {
|
public class OfflineActivity extends CommonActivity {
|
||||||
private final String TAG = this.getClass().getSimpleName();
|
private final String TAG = this.getClass().getSimpleName();
|
||||||
@ -492,30 +488,33 @@ public class OfflineActivity extends CommonActivity {
|
|||||||
return true;
|
return true;
|
||||||
case R.id.catchup_above:
|
case R.id.catchup_above:
|
||||||
if (oap != null) {
|
if (oap != null) {
|
||||||
int articleId = oap.getSelectedArticleId();
|
if (m_prefs.getBoolean("confirm_headlines_catchup", true)) {
|
||||||
int feedId = oap.getFeedId();
|
|
||||||
boolean isCat = oap.getFeedIsCat();
|
|
||||||
|
|
||||||
SQLiteStatement stmt = null;
|
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||||
|
OfflineActivity.this)
|
||||||
if (isCat) {
|
.setMessage(R.string.confirm_catchup_above)
|
||||||
stmt = getDatabase().compileStatement(
|
.setPositiveButton(R.string.dialog_ok,
|
||||||
"UPDATE articles SET modified = 1, unread = 0 WHERE " +
|
new Dialog.OnClickListener() {
|
||||||
"updated >= (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " +
|
public void onClick(DialogInterface dialog,
|
||||||
"AND feed_id IN (SELECT "+BaseColumns._ID+" FROM feeds WHERE cat_id = ?)");
|
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 {
|
} else {
|
||||||
stmt = getDatabase().compileStatement(
|
catchupAbove(oap);
|
||||||
"UPDATE articles SET modified = 1, unread = 0 WHERE " +
|
|
||||||
"updated >= (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " +
|
|
||||||
"AND feed_id = ?");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt.bindLong(1, articleId);
|
|
||||||
stmt.bindLong(2, feedId);
|
|
||||||
stmt.execute();
|
|
||||||
stmt.close();
|
|
||||||
|
|
||||||
refresh();
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
@ -524,6 +523,33 @@ public class OfflineActivity extends CommonActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void catchupAbove(OfflineArticlePager oap) {
|
||||||
|
int articleId = oap.getSelectedArticleId();
|
||||||
|
int feedId = oap.getFeedId();
|
||||||
|
boolean isCat = oap.getFeedIsCat();
|
||||||
|
|
||||||
|
SQLiteStatement stmt = null;
|
||||||
|
|
||||||
|
if (isCat) {
|
||||||
|
stmt = getDatabase().compileStatement(
|
||||||
|
"UPDATE articles SET modified = 1, unread = 0 WHERE " +
|
||||||
|
"updated >= (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " +
|
||||||
|
"AND feed_id IN (SELECT "+BaseColumns._ID+" FROM feeds WHERE cat_id = ?)");
|
||||||
|
} else {
|
||||||
|
stmt = getDatabase().compileStatement(
|
||||||
|
"UPDATE articles SET modified = 1, unread = 0 WHERE " +
|
||||||
|
"updated >= (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " +
|
||||||
|
"AND feed_id = ?");
|
||||||
|
}
|
||||||
|
|
||||||
|
stmt.bindLong(1, articleId);
|
||||||
|
stmt.bindLong(2, feedId);
|
||||||
|
stmt.execute();
|
||||||
|
stmt.close();
|
||||||
|
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
MenuInflater inflater = getMenuInflater();
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package org.fox.ttrss.offline;
|
package org.fox.ttrss.offline;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Resources.Theme;
|
import android.content.res.Resources.Theme;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
@ -129,7 +132,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onArticleMenuItemSelected(MenuItem item, int articleId) {
|
private boolean onArticleMenuItemSelected(MenuItem item, final int articleId) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.headlines_article_link_copy:
|
case R.id.headlines_article_link_copy:
|
||||||
if (true) {
|
if (true) {
|
||||||
@ -159,28 +162,35 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
return true;
|
return true;
|
||||||
case R.id.catchup_above:
|
case R.id.catchup_above:
|
||||||
if (true) {
|
if (true) {
|
||||||
SQLiteStatement stmt = null;
|
if (m_prefs.getBoolean("confirm_headlines_catchup", true)) {
|
||||||
|
|
||||||
String updatedOperator = (m_prefs.getBoolean("offline_oldest_first", false)) ? "<" : ">";
|
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) {
|
||||||
|
|
||||||
if (m_feedIsCat) {
|
catchupAbove(articleId);
|
||||||
stmt = m_activity.getDatabase().compileStatement(
|
|
||||||
"UPDATE articles SET modified = 1, unread = 0 WHERE " +
|
}
|
||||||
"updated "+updatedOperator+" (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " +
|
})
|
||||||
"AND unread = 1 AND feed_id IN (SELECT "+BaseColumns._ID+" FROM feeds WHERE cat_id = ?)");
|
.setNegativeButton(R.string.dialog_cancel,
|
||||||
|
new Dialog.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog,
|
||||||
|
int which) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AlertDialog dlg = builder.create();
|
||||||
|
dlg.show();
|
||||||
} else {
|
} else {
|
||||||
stmt = m_activity.getDatabase().compileStatement(
|
catchupAbove(articleId);
|
||||||
"UPDATE articles SET modified = 1, unread = 0 WHERE " +
|
|
||||||
"updated "+updatedOperator+" (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " +
|
|
||||||
"AND unread = 1 AND feed_id = ?");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt.bindLong(1, articleId);
|
|
||||||
stmt.bindLong(2, m_feedId);
|
|
||||||
stmt.execute();
|
|
||||||
stmt.close();
|
|
||||||
}
|
}
|
||||||
refresh();
|
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
Log.d(TAG, "onArticleMenuItemSelected, unhandled id=" + item.getItemId());
|
Log.d(TAG, "onArticleMenuItemSelected, unhandled id=" + item.getItemId());
|
||||||
@ -189,6 +199,31 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void catchupAbove(int articleId) {
|
||||||
|
SQLiteStatement stmt = null;
|
||||||
|
|
||||||
|
String updatedOperator = (m_prefs.getBoolean("offline_oldest_first", false)) ? "<" : ">";
|
||||||
|
|
||||||
|
if (m_feedIsCat) {
|
||||||
|
stmt = m_activity.getDatabase().compileStatement(
|
||||||
|
"UPDATE articles SET modified = 1, unread = 0 WHERE " +
|
||||||
|
"updated "+updatedOperator+" (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " +
|
||||||
|
"AND unread = 1 AND feed_id IN (SELECT "+BaseColumns._ID+" FROM feeds WHERE cat_id = ?)");
|
||||||
|
} else {
|
||||||
|
stmt = m_activity.getDatabase().compileStatement(
|
||||||
|
"UPDATE articles SET modified = 1, unread = 0 WHERE " +
|
||||||
|
"updated "+updatedOperator+" (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " +
|
||||||
|
"AND unread = 1 AND feed_id = ?");
|
||||||
|
}
|
||||||
|
|
||||||
|
stmt.bindLong(1, articleId);
|
||||||
|
stmt.bindLong(2, m_feedId);
|
||||||
|
stmt.execute();
|
||||||
|
stmt.close();
|
||||||
|
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
@ -241,4 +241,6 @@
|
|||||||
<string name="open_with_app">Open with app</string>
|
<string name="open_with_app">Open with app</string>
|
||||||
<string name="prefs_opening_links">Opening links</string>
|
<string name="prefs_opening_links">Opening links</string>
|
||||||
<string name="open_with">Open with…</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>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user