confirm marking headlines as read from the actionbar

This commit is contained in:
Andrew Dolgov 2013-05-15 13:28:47 +04:00
parent a60225626d
commit 9e71ff1b11
3 changed files with 56 additions and 27 deletions

View File

@ -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>

View File

@ -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);

View File

@ -746,6 +746,18 @@ 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) {
int count = hf.getUnreadArticles().size();
if (count > 0) {
AlertDialog.Builder builder = new AlertDialog.Builder(
OnlineActivity.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) {
ArticleList articles = hf.getUnreadArticles(); ArticleList articles = hf.getUnreadArticles();
for (Article a : articles) for (Article a : articles)
@ -772,6 +784,21 @@ public class OnlineActivity extends CommonActivity {
} }
}; };
req.execute(map); 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: