fix headlines catchup button not respecting confirm option
This commit is contained in:
parent
68ea91c567
commit
491d8f082f
@ -1,6 +1,7 @@
|
|||||||
package org.fox.ttrss.offline;
|
package org.fox.ttrss.offline;
|
||||||
|
|
||||||
import org.fox.ttrss.CommonActivity;
|
import org.fox.ttrss.CommonActivity;
|
||||||
|
import org.fox.ttrss.OnlineActivity;
|
||||||
import org.fox.ttrss.PreferencesActivity;
|
import org.fox.ttrss.PreferencesActivity;
|
||||||
import org.fox.ttrss.R;
|
import org.fox.ttrss.R;
|
||||||
|
|
||||||
@ -246,23 +247,42 @@ public class OfflineActivity extends CommonActivity {
|
|||||||
return true;
|
return true;
|
||||||
case R.id.headlines_mark_as_read:
|
case R.id.headlines_mark_as_read:
|
||||||
if (ohf != null) {
|
if (ohf != null) {
|
||||||
int feedId = ohf.getFeedId();
|
final int feedId = ohf.getFeedId();
|
||||||
boolean isCat = ohf.getFeedIsCat();
|
final boolean isCat = ohf.getFeedIsCat();
|
||||||
|
|
||||||
SQLiteStatement stmt = null;
|
int count = getUnreadArticleCount(feedId, isCat);
|
||||||
|
boolean confirm = m_prefs.getBoolean("confirm_headlines_catchup", true);
|
||||||
|
|
||||||
|
if (count > 0) {
|
||||||
|
if (confirm) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||||
|
OfflineActivity.this)
|
||||||
|
.setMessage(getString(R.string.mark_num_headlines_as_read, count))
|
||||||
|
.setPositiveButton(R.string.catchup,
|
||||||
|
new Dialog.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog,
|
||||||
|
int which) {
|
||||||
|
|
||||||
|
catchupFeed(feedId, isCat);
|
||||||
|
|
||||||
if (isCat) {
|
|
||||||
stmt = getWritableDb().compileStatement(
|
|
||||||
"UPDATE articles SET modified = 1, unread = 0 WHERE feed_id IN (SELECT "+BaseColumns._ID+" FROM feeds WHERE cat_id = ?)");
|
|
||||||
} else {
|
|
||||||
stmt = getWritableDb().compileStatement(
|
|
||||||
"UPDATE articles SET modified = 1, unread = 0 WHERE feed_id = ?");
|
|
||||||
}
|
}
|
||||||
stmt.bindLong(1, feedId);
|
})
|
||||||
stmt.execute();
|
.setNegativeButton(R.string.dialog_cancel,
|
||||||
stmt.close();
|
new Dialog.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog,
|
||||||
|
int which) {
|
||||||
|
|
||||||
refresh();
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AlertDialog dlg = builder.create();
|
||||||
|
dlg.show();
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
catchupFeed(feedId, isCat);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.share_article:
|
case R.id.share_article:
|
||||||
@ -384,7 +404,6 @@ public class OfflineActivity extends CommonActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
MenuInflater inflater = getSupportMenuInflater();
|
MenuInflater inflater = getSupportMenuInflater();
|
||||||
@ -601,6 +620,29 @@ public class OfflineActivity extends CommonActivity {
|
|||||||
return selected;
|
return selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected int getUnreadArticleCount(int feedId, boolean isCat) {
|
||||||
|
|
||||||
|
Cursor c;
|
||||||
|
|
||||||
|
if (isCat) {
|
||||||
|
c = getReadableDb().query("articles",
|
||||||
|
new String[] { "COUNT(*)" }, "unread = 1 AND feed_id IN (SELECT "+BaseColumns._ID+" FROM feeds WHERE cat_id = ?)",
|
||||||
|
new String[] { String.valueOf(feedId) },
|
||||||
|
null, null, null);
|
||||||
|
} else {
|
||||||
|
c = getReadableDb().query("articles",
|
||||||
|
new String[] { "COUNT(*)" }, "unread = 1 AND feed_id = ?",
|
||||||
|
new String[] { String.valueOf(feedId) },
|
||||||
|
null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
c.moveToFirst();
|
||||||
|
int selected = c.getInt(0);
|
||||||
|
c.close();
|
||||||
|
|
||||||
|
return selected;
|
||||||
|
}
|
||||||
|
|
||||||
protected void deselectAllArticles() {
|
protected void deselectAllArticles() {
|
||||||
getWritableDb().execSQL("UPDATE articles SET selected = 0 ");
|
getWritableDb().execSQL("UPDATE articles SET selected = 0 ");
|
||||||
refresh();
|
refresh();
|
||||||
@ -631,4 +673,24 @@ public class OfflineActivity extends CommonActivity {
|
|||||||
initMenu();
|
initMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void catchupFeed(int feedId, boolean isCat) {
|
||||||
|
if (isCat) {
|
||||||
|
SQLiteStatement stmt = getWritableDb().compileStatement(
|
||||||
|
"UPDATE articles SET modified = 1, unread = 0 WHERE feed_id IN (SELECT "+
|
||||||
|
BaseColumns._ID+" FROM feeds WHERE cat_id = ?)");
|
||||||
|
stmt.bindLong(1, feedId);
|
||||||
|
stmt.execute();
|
||||||
|
stmt.close();
|
||||||
|
} else {
|
||||||
|
SQLiteStatement stmt = getWritableDb().compileStatement(
|
||||||
|
"UPDATE articles SET modified = 1, unread = 0 WHERE feed_id = ?");
|
||||||
|
stmt.bindLong(1, feedId);
|
||||||
|
stmt.execute();
|
||||||
|
stmt.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -272,31 +272,11 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
|||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
m_actionbarUpEnabled = true;
|
m_actionbarUpEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}, 10);
|
}, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void catchupFeed(int feedId, boolean isCat) {
|
|
||||||
if (isCat) {
|
|
||||||
SQLiteStatement stmt = getWritableDb().compileStatement(
|
|
||||||
"UPDATE articles SET modified = 1, unread = 0 WHERE feed_id IN (SELECT "+
|
|
||||||
BaseColumns._ID+" FROM feeds WHERE cat_id = ?)");
|
|
||||||
stmt.bindLong(1, feedId);
|
|
||||||
stmt.execute();
|
|
||||||
stmt.close();
|
|
||||||
} else {
|
|
||||||
SQLiteStatement stmt = getWritableDb().compileStatement(
|
|
||||||
"UPDATE articles SET modified = 1, unread = 0 WHERE feed_id = ?");
|
|
||||||
stmt.bindLong(1, feedId);
|
|
||||||
stmt.execute();
|
|
||||||
stmt.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onArticleSelected(int articleId, boolean open) {
|
public void onArticleSelected(int articleId, boolean open) {
|
||||||
SQLiteStatement stmt = getWritableDb().compileStatement(
|
SQLiteStatement stmt = getWritableDb().compileStatement(
|
||||||
|
@ -251,6 +251,8 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
|
m_activity.initMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
|
Loading…
Reference in New Issue
Block a user