diff options
author | Andrew Dolgov <[email protected]> | 2014-11-04 17:27:11 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2014-11-04 17:27:11 +0300 |
commit | 36c24e5846cffb9ed5928b59bcca2b184343f7dc (patch) | |
tree | 9ea558cecf26bbfdc4c4738602d7f340d4cb28d3 | |
parent | 7feb9203ab97edf4bb6ff95a4aa8c3fb06554045 (diff) |
implement support for article sorting modes instead of previous preference options
7 files changed, 88 insertions, 19 deletions
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticlePager.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticlePager.java index 6f45432b..87ca61dd 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticlePager.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticlePager.java @@ -233,7 +233,7 @@ public class ArticlePager extends Fragment { put("view_mode", m_activity.getViewMode()); put("skip", String.valueOf(fskip)); put("include_nested", "true"); - put("order_by", m_prefs.getBoolean("oldest_first", false) ? "date_reverse" : ""); + put("order_by", m_activity.getSortMode()); if (feed.is_cat) put("is_cat", "true"); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsActivity.java index a6a3069a..39e4ae6f 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsActivity.java @@ -2,6 +2,9 @@ package org.fox.ttrss; import android.annotation.SuppressLint; +import android.app.AlertDialog; +import android.app.Dialog; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; @@ -297,10 +300,58 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe //getSupportFragmentManager().popBackStack(); return true; case R.id.headlines_toggle_sort_order: - SharedPreferences.Editor editor = m_prefs.edit(); - editor.putBoolean("oldest_first", !m_prefs.getBoolean("oldest_first", false)); - editor.commit(); - refresh(); + Dialog dialog = new Dialog(this); + + String sortMode = getSortMode(); + + int selectedIndex = 0; + + if (sortMode.equals("feed_dates")) { + selectedIndex = 1; + } else if (sortMode.equals("date_reverse")) { + selectedIndex = 2; + } else if (sortMode.equals("title")) { + selectedIndex = 3; + } + + AlertDialog.Builder builder = new AlertDialog.Builder(this) + .setTitle(getString(R.string.headlines_sort_articles_title)) + .setSingleChoiceItems( + new String[] { + getString(R.string.headlines_sort_default), + getString(R.string.headlines_sort_newest_first), + getString(R.string.headlines_sort_oldest_first), + getString(R.string.headlines_sort_title) + }, + selectedIndex, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int which) { + Log.d(TAG, "which:" + which); + + switch (which) { + case 0: + setSortMode("default"); + break; + case 1: + setSortMode("feed_dates"); + break; + case 2: + setSortMode("date_reverse"); + break; + case 3: + setSortMode("title"); + break; + } + dialog.cancel(); + + refresh(); + } + }); + + dialog = builder.create(); + dialog.show(); + return true; case R.id.show_feeds: setUnreadOnly(!getUnreadOnly()); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java index 69d6033a..93e6a8e7 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java @@ -541,7 +541,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, put("offset", String.valueOf(0)); put("skip", String.valueOf(fskip)); put("include_nested", "true"); - put("order_by", m_prefs.getBoolean("oldest_first", false) ? "date_reverse" : ""); + put("order_by", m_activity.getSortMode()); if (isCat) put("is_cat", "true"); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java index 244f40a4..894920cb 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java @@ -1723,13 +1723,25 @@ public class OnlineActivity extends CommonActivity { } - public void setViewMode(String viewMode) { + public String getSortMode() { + return m_prefs.getString("headlines_sort_mode", "default"); + } + + public void setSortMode(String sortMode) { + Log.d(TAG, "setSortMode:" + sortMode); + + SharedPreferences.Editor editor = m_prefs.edit(); + editor.putString("headlines_sort_mode", sortMode); + editor.commit(); + } + + public void setViewMode(String viewMode) { SharedPreferences.Editor editor = m_prefs.edit(); editor.putString("view_mode", viewMode); editor.commit(); } - - public String getViewMode() { + + public String getViewMode() { return m_prefs.getString("view_mode", "adaptive"); } diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java index 6059bf2f..184937a7 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java @@ -823,7 +823,17 @@ public class OfflineActivity extends CommonActivity { editor.putString("offline_view_mode", viewMode); editor.commit(); } - + + /* public String getSortMode() { + return m_prefs.getString("headlines_sort_mode", "default"); + } + + public void setSortMode(String sortMode) { + SharedPreferences.Editor editor = m_prefs.edit(); + editor.putString("headlines_sort_mode", sortMode); + editor.commit(); + } */ + public String getViewMode() { return m_prefs.getString("offline_view_mode", "adaptive"); } diff --git a/org.fox.ttrss/src/main/res/values/strings.xml b/org.fox.ttrss/src/main/res/values/strings.xml index b4f81543..0752ff54 100644 --- a/org.fox.ttrss/src/main/res/values/strings.xml +++ b/org.fox.ttrss/src/main/res/values/strings.xml @@ -244,5 +244,10 @@ <string name="error_loading_image">Error loading image.</string> <string name="open_parent">Open parent</string> <string name="toggle_sort_order">Toggle oldest first</string> + <string name="headlines_sort_default">Default</string> + <string name="headlines_sort_newest_first">Newest first</string> + <string name="headlines_sort_oldest_first">Oldest first</string> + <string name="headlines_sort_title">Title</string> + <string name="headlines_sort_articles_title">Sort articles</string> </resources> diff --git a/org.fox.ttrss/src/main/res/xml/preferences.xml b/org.fox.ttrss/src/main/res/xml/preferences.xml index 7ee21f84..ec1c6418 100644 --- a/org.fox.ttrss/src/main/res/xml/preferences.xml +++ b/org.fox.ttrss/src/main/res/xml/preferences.xml @@ -106,11 +106,6 @@ <CheckBoxPreference android:defaultValue="false" - android:key="oldest_first" - android:summary="@string/requires_api5" - android:title="@string/offline_oldest_first" /> - <CheckBoxPreference - android:defaultValue="false" android:key="headlines_mark_read_scroll" android:summary="@string/pref_headlines_mark_read_scroll_long" android:title="@string/pref_headlines_mark_read_scroll" /> @@ -171,10 +166,6 @@ android:key="offline_image_cache_enabled" android:summary="@string/offline_image_cache_enabled_summary" android:title="@string/offline_image_cache_enabled" /> - <CheckBoxPreference - android:defaultValue="false" - android:key="offline_oldest_first" - android:title="@string/offline_oldest_first" /> </PreferenceCategory> <PreferenceCategory android:title="@string/debugging" > <CheckBoxPreference |