confirm marking headlines as read from the actionbar
This commit is contained in:
parent
a60225626d
commit
9e71ff1b11
@ -195,4 +195,5 @@
|
|||||||
<string name="light_theme_is_not_supported_on_honeycomb">Light theme is not supported on Honeycomb</string>
|
<string name="light_theme_is_not_supported_on_honeycomb">Light theme is not supported on Honeycomb</string>
|
||||||
<string name="pref_headlines_mark_read_scroll">Mark read on scroll</string>
|
<string name="pref_headlines_mark_read_scroll">Mark read on scroll</string>
|
||||||
<string name="pref_headlines_mark_read_scroll_long">Headlines will be marked read when scrolling past them</string>
|
<string name="pref_headlines_mark_read_scroll_long">Headlines will be marked read when scrolling past them</string>
|
||||||
|
<string name="mark_num_headlines_as_read">Mark %1$d article(s) as read?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -7,6 +7,7 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
|
|||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
@ -118,7 +119,7 @@ public class CommonActivity extends SherlockFragmentActivity {
|
|||||||
|
|
||||||
initDatabase();
|
initDatabase();
|
||||||
|
|
||||||
m_compatMode = android.os.Build.VERSION.SDK_INT <= 10;
|
m_compatMode = android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB;
|
||||||
|
|
||||||
Log.d(TAG, "m_compatMode=" + m_compatMode);
|
Log.d(TAG, "m_compatMode=" + m_compatMode);
|
||||||
|
|
||||||
|
@ -746,32 +746,59 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
return true;
|
return true;
|
||||||
case R.id.headlines_mark_as_read:
|
case R.id.headlines_mark_as_read:
|
||||||
if (hf != null) {
|
if (hf != null) {
|
||||||
ArticleList articles = hf.getUnreadArticles();
|
|
||||||
|
|
||||||
for (Article a : articles)
|
int count = hf.getUnreadArticles().size();
|
||||||
a.unread = false;
|
|
||||||
|
|
||||||
ApiRequest req = new ApiRequest(getApplicationContext()) {
|
if (count > 0) {
|
||||||
protected void onPostExecute(JsonElement result) {
|
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||||
if (hf.isAdded()) {
|
OnlineActivity.this)
|
||||||
hf.refresh(false);
|
.setMessage(getString(R.string.mark_num_headlines_as_read, count))
|
||||||
}
|
.setPositiveButton(R.string.catchup,
|
||||||
}
|
new Dialog.OnClickListener() {
|
||||||
};
|
public void onClick(DialogInterface dialog,
|
||||||
|
int which) {
|
||||||
|
|
||||||
final String articleIds = articlesToIdString(articles);
|
ArticleList articles = hf.getUnreadArticles();
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
for (Article a : articles)
|
||||||
HashMap<String, String> map = new HashMap<String, String>() {
|
a.unread = false;
|
||||||
{
|
|
||||||
put("sid", getSessionId());
|
ApiRequest req = new ApiRequest(getApplicationContext()) {
|
||||||
put("op", "updateArticle");
|
protected void onPostExecute(JsonElement result) {
|
||||||
put("article_ids", articleIds);
|
if (hf.isAdded()) {
|
||||||
put("mode", "0");
|
hf.refresh(false);
|
||||||
put("field", "2");
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
req.execute(map);
|
|
||||||
|
final String articleIds = articlesToIdString(articles);
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
HashMap<String, String> map = new HashMap<String, String>() {
|
||||||
|
{
|
||||||
|
put("sid", getSessionId());
|
||||||
|
put("op", "updateArticle");
|
||||||
|
put("article_ids", articleIds);
|
||||||
|
put("mode", "0");
|
||||||
|
put("field", "2");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
req.execute(map);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.dialog_cancel,
|
||||||
|
new Dialog.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog,
|
||||||
|
int which) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AlertDialog dlg = builder.create();
|
||||||
|
dlg.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.headlines_view_mode:
|
case R.id.headlines_view_mode:
|
||||||
|
Loading…
Reference in New Issue
Block a user