properly sort feedlist by unread, misc cleanup

This commit is contained in:
Andrew Dolgov 2011-12-06 15:15:55 +03:00
parent 581f79b3c1
commit 5178ba7287
5 changed files with 103 additions and 86 deletions

View File

@ -4,12 +4,6 @@
<group android:id="@+id/menu_group_feeds" > <group android:id="@+id/menu_group_feeds" >
<item
android:id="@+id/go_offline"
android:icon="@drawable/ic_menu_cloud"
android:showAsAction="ifRoom|withText"
android:title="@string/go_offline"/>
<item <item
android:id="@+id/back_to_categories" android:id="@+id/back_to_categories"
android:icon="@android:drawable/ic_menu_close_clear_cancel" android:icon="@android:drawable/ic_menu_close_clear_cancel"
@ -25,9 +19,15 @@
<item <item
android:id="@+id/update_feeds" android:id="@+id/update_feeds"
android:icon="@android:drawable/ic_menu_rotate" android:icon="@android:drawable/ic_menu_rotate"
android:showAsAction="" android:showAsAction="ifRoom|"
android:title="@string/update_feeds"/> android:title="@string/update_feeds"/>
<item
android:id="@+id/go_offline"
android:icon="@drawable/ic_menu_cloud"
android:showAsAction="ifRoom|withText"
android:title="@string/go_offline"/>
<item <item
android:id="@+id/logout" android:id="@+id/logout"
android:icon="@drawable/ic_menu_exit" android:icon="@drawable/ic_menu_exit"
@ -46,6 +46,7 @@
<item <item
android:id="@+id/headlines_mark_as_read" android:id="@+id/headlines_mark_as_read"
android:icon="@drawable/ic_menu_tick" android:icon="@drawable/ic_menu_tick"
android:showAsAction=""
android:title="@string/headlines_mark_as_read"/> android:title="@string/headlines_mark_as_read"/>
<item <item

View File

@ -20,12 +20,6 @@
android:icon="@android:drawable/ic_menu_agenda" android:icon="@android:drawable/ic_menu_agenda"
android:showAsAction="" android:showAsAction=""
android:title="@string/menu_all_feeds"/> android:title="@string/menu_all_feeds"/>
<item
android:id="@+id/logout"
android:icon="@drawable/ic_menu_exit"
android:showAsAction=""
android:title="@string/logout"/>
</group> </group>
<group android:id="@+id/menu_group_headlines" > <group android:id="@+id/menu_group_headlines" >

View File

@ -101,4 +101,5 @@
<string name="dialog_offline_go">Go offline</string> <string name="dialog_offline_go">Go offline</string>
<string name="dialog_cancel">Cancel</string> <string name="dialog_cancel">Cancel</string>
<string name="syncing_offline_data">Synchronizing offline data...</string> <string name="syncing_offline_data">Synchronizing offline data...</string>
<string name="dialog_offline_switch_prompt">Download unread articles and go offline?</string>
</resources> </resources>

View File

@ -43,6 +43,9 @@ import com.google.gson.reflect.TypeToken;
public class MainActivity extends FragmentActivity implements FeedsFragment.OnFeedSelectedListener, ArticleOps, FeedCategoriesFragment.OnCatSelectedListener { public class MainActivity extends FragmentActivity implements FeedsFragment.OnFeedSelectedListener, ArticleOps, FeedCategoriesFragment.OnCatSelectedListener {
private final String TAG = this.getClass().getSimpleName(); private final String TAG = this.getClass().getSimpleName();
private final int OFFLINE_SYNC_SEQ = 60;
private final int OFFLINE_SYNC_MAX = 500;
private SharedPreferences m_prefs; private SharedPreferences m_prefs;
private String m_themeName = ""; private String m_themeName = "";
private String m_sessionId; private String m_sessionId;
@ -466,7 +469,7 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
put("view_mode", "unread"); put("view_mode", "unread");
put("show_content", "true"); put("show_content", "true");
put("skip", String.valueOf(m_articleOffset)); put("skip", String.valueOf(m_articleOffset));
put("limit", "30"); put("limit", String.valueOf(OFFLINE_SYNC_SEQ));
} }
}; };
@ -475,6 +478,12 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void switchOffline() { public void switchOffline() {
AlertDialog.Builder builder = new AlertDialog.Builder(this).
setMessage(R.string.dialog_offline_switch_prompt).
setPositiveButton(R.string.dialog_offline_go, new Dialog.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Log.d(TAG, "offline: starting"); Log.d(TAG, "offline: starting");
if (m_sessionId != null) { if (m_sessionId != null) {
@ -546,6 +555,17 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
switchOfflineSuccess(); switchOfflineSuccess();
} }
} }
}).
setNegativeButton(R.string.dialog_cancel, new Dialog.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//
}
});
AlertDialog dlg = builder.create();
dlg.show();
}
public void switchOfflineSuccess() { public void switchOfflineSuccess() {
logout(); logout();
@ -746,10 +766,9 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
case R.id.headlines_select: case R.id.headlines_select:
if (hf != null) { if (hf != null) {
Dialog dialog = new Dialog(this); Dialog dialog = new Dialog(this);
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this)
builder.setTitle(R.string.headlines_select_dialog); .setTitle(R.string.headlines_select_dialog)
.setSingleChoiceItems(new String[] { getString(R.string.headlines_select_all),
builder.setSingleChoiceItems(new String[] { getString(R.string.headlines_select_all),
getString(R.string.headlines_select_unread), getString(R.string.headlines_select_none) }, 0, new DialogInterface.OnClickListener() { getString(R.string.headlines_select_unread), getString(R.string.headlines_select_none) }, 0, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
@ -1796,7 +1815,7 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
Log.d(TAG, "offline: received " + articles.size() + " articles"); Log.d(TAG, "offline: received " + articles.size() + " articles");
if (articles.size() == 30 && m_articleOffset < 500) { if (articles.size() == OFFLINE_SYNC_SEQ && m_articleOffset < OFFLINE_SYNC_MAX) {
offlineGetArticles(); offlineGetArticles();
} else { } else {
switchOfflineSuccess(); switchOfflineSuccess();

View File

@ -56,8 +56,10 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
public Cursor createCursor() { public Cursor createCursor() {
String unreadOnly = ((OfflineActivity)getActivity()).getUnreadOnly() ? "unread > 0" : null; String unreadOnly = ((OfflineActivity)getActivity()).getUnreadOnly() ? "unread > 0" : null;
String order = m_prefs.getBoolean("sort_feeds_by_unread", false) ? "unread DESC, title" : "title";
return ((OfflineActivity)getActivity()).getReadableDb().query("feeds_unread", return ((OfflineActivity)getActivity()).getReadableDb().query("feeds_unread",
null, unreadOnly, null, null, null, "title"); null, unreadOnly, null, null, null, order);
} }
public void refresh() { public void refresh() {