add option to show oldest articles first in offline mode (closes #504)
This commit is contained in:
parent
b706937075
commit
bc7a0a1c0d
@ -143,4 +143,5 @@
|
||||
<string name="ssl_trust_any_host_long">Do not verify server hostname</string>
|
||||
<string name="ssl">SSL</string>
|
||||
<string name="error_ssl_hostname_rejected">Error: SSL hostname not verified</string>
|
||||
<string name="offline_oldest_first">Show oldest articles first</string>
|
||||
</resources>
|
@ -22,20 +22,20 @@
|
||||
android:summary="@string/ttrss_url_summary"
|
||||
android:title="@string/ttrss_url" >
|
||||
</EditTextPreference>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/ssl" android:summary="blah blah blah" >
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:summary="blah blah blah"
|
||||
android:title="@string/ssl" >
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="ssl_trust_any"
|
||||
android:summary="@string/ssl_trust_any_long"
|
||||
android:title="@string/ssl_trust_any" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="ssl_trust_any_host"
|
||||
android:summary="@string/ssl_trust_any_host_long"
|
||||
android:title="@string/ssl_trust_any_host" />
|
||||
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/http_authentication" >
|
||||
<EditTextPreference
|
||||
@ -92,7 +92,7 @@
|
||||
android:defaultValue="false"
|
||||
android:key="combined_mode"
|
||||
android:summary="@string/combined_mode_summary"
|
||||
android:title="@string/combined_mode" />
|
||||
android:title="@string/combined_mode" />
|
||||
-->
|
||||
|
||||
<CheckBoxPreference
|
||||
@ -120,6 +120,10 @@
|
||||
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
|
||||
|
@ -4,8 +4,10 @@ import org.fox.ttrss.R;
|
||||
import org.fox.ttrss.types.Article;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.BaseColumns;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
@ -27,6 +29,7 @@ public class OfflineArticlePager extends Fragment {
|
||||
private int m_articleId;
|
||||
private String m_searchQuery = "";
|
||||
private Cursor m_cursor;
|
||||
private SharedPreferences m_prefs;
|
||||
|
||||
public int getFeedId() {
|
||||
return m_feedId;
|
||||
@ -45,15 +48,17 @@ public class OfflineArticlePager extends Fragment {
|
||||
feedClause = "feed_id = ?";
|
||||
}
|
||||
|
||||
String orderBy = (m_prefs.getBoolean("offline_oldest_first", false)) ? "updated" : "updated DESC";
|
||||
|
||||
if (m_searchQuery == null || m_searchQuery.equals("")) {
|
||||
return m_activity.getReadableDb().query("articles LEFT JOIN feeds ON (feed_id = feeds."+BaseColumns._ID+")",
|
||||
new String[] { "articles."+BaseColumns._ID, "feeds.title AS feed_title" }, feedClause,
|
||||
new String[] { String.valueOf(m_feedId) }, null, null, "updated DESC");
|
||||
new String[] { String.valueOf(m_feedId) }, null, null, orderBy);
|
||||
} else {
|
||||
return m_activity.getReadableDb().query("articles LEFT JOIN feeds ON (feed_id = feeds."+BaseColumns._ID+")",
|
||||
new String[] { "articles."+BaseColumns._ID },
|
||||
feedClause + " AND (articles.title LIKE '%' || ? || '%' OR content LIKE '%' || ? || '%')",
|
||||
new String[] { String.valueOf(m_feedId), m_searchQuery, m_searchQuery }, null, null, "updated DESC");
|
||||
new String[] { String.valueOf(m_feedId), m_searchQuery, m_searchQuery }, null, null, orderBy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,8 +177,11 @@ public class OfflineArticlePager extends Fragment {
|
||||
|
||||
m_activity = (OfflineActivity)activity;
|
||||
m_listener = (OfflineHeadlinesEventListener)activity;
|
||||
m_cursor = createCursor();
|
||||
|
||||
m_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
||||
|
||||
m_cursor = createCursor();
|
||||
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
|
@ -303,15 +303,17 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
||||
feedClause = "feed_id = ?";
|
||||
}
|
||||
|
||||
String orderBy = (m_prefs.getBoolean("offline_oldest_first", false)) ? "updated" : "updated DESC";
|
||||
|
||||
if (m_searchQuery == null || m_searchQuery.equals("")) {
|
||||
return m_activity.getReadableDb().query("articles LEFT JOIN feeds ON (feed_id = feeds."+BaseColumns._ID+")",
|
||||
new String[] { "articles.*", "feeds.title AS feed_title" }, feedClause,
|
||||
new String[] { String.valueOf(m_feedId) }, null, null, "updated DESC");
|
||||
new String[] { String.valueOf(m_feedId) }, null, null, orderBy);
|
||||
} else {
|
||||
return m_activity.getReadableDb().query("articles LEFT JOIN feeds ON (feed_id = feeds."+BaseColumns._ID+")",
|
||||
new String[] { "articles.*", "feeds.title AS feed_title" },
|
||||
feedClause + " AND (articles.title LIKE '%' || ? || '%' OR content LIKE '%' || ? || '%')",
|
||||
new String[] { String.valueOf(m_feedId), m_searchQuery, m_searchQuery }, null, null, "updated DESC");
|
||||
new String[] { String.valueOf(m_feedId), m_searchQuery, m_searchQuery }, null, null, orderBy);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user