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_trust_any_host_long">Do not verify server hostname</string>
|
||||||
<string name="ssl">SSL</string>
|
<string name="ssl">SSL</string>
|
||||||
<string name="error_ssl_hostname_rejected">Error: SSL hostname not verified</string>
|
<string name="error_ssl_hostname_rejected">Error: SSL hostname not verified</string>
|
||||||
|
<string name="offline_oldest_first">Show oldest articles first</string>
|
||||||
</resources>
|
</resources>
|
@ -23,19 +23,19 @@
|
|||||||
android:title="@string/ttrss_url" >
|
android:title="@string/ttrss_url" >
|
||||||
</EditTextPreference>
|
</EditTextPreference>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:title="@string/ssl" android:summary="blah blah blah" >
|
<PreferenceCategory
|
||||||
|
android:summary="blah blah blah"
|
||||||
|
android:title="@string/ssl" >
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="ssl_trust_any"
|
android:key="ssl_trust_any"
|
||||||
android:summary="@string/ssl_trust_any_long"
|
android:summary="@string/ssl_trust_any_long"
|
||||||
android:title="@string/ssl_trust_any" />
|
android:title="@string/ssl_trust_any" />
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="ssl_trust_any_host"
|
android:key="ssl_trust_any_host"
|
||||||
android:summary="@string/ssl_trust_any_host_long"
|
android:summary="@string/ssl_trust_any_host_long"
|
||||||
android:title="@string/ssl_trust_any_host" />
|
android:title="@string/ssl_trust_any_host" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:title="@string/http_authentication" >
|
<PreferenceCategory android:title="@string/http_authentication" >
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
@ -120,6 +120,10 @@
|
|||||||
android:key="offline_image_cache_enabled"
|
android:key="offline_image_cache_enabled"
|
||||||
android:summary="@string/offline_image_cache_enabled_summary"
|
android:summary="@string/offline_image_cache_enabled_summary"
|
||||||
android:title="@string/offline_image_cache_enabled" />
|
android:title="@string/offline_image_cache_enabled" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="offline_oldest_first"
|
||||||
|
android:title="@string/offline_oldest_first" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:title="@string/debugging" >
|
<PreferenceCategory android:title="@string/debugging" >
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
|
@ -4,8 +4,10 @@ import org.fox.ttrss.R;
|
|||||||
import org.fox.ttrss.types.Article;
|
import org.fox.ttrss.types.Article;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.BaseColumns;
|
import android.provider.BaseColumns;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
@ -27,6 +29,7 @@ public class OfflineArticlePager extends Fragment {
|
|||||||
private int m_articleId;
|
private int m_articleId;
|
||||||
private String m_searchQuery = "";
|
private String m_searchQuery = "";
|
||||||
private Cursor m_cursor;
|
private Cursor m_cursor;
|
||||||
|
private SharedPreferences m_prefs;
|
||||||
|
|
||||||
public int getFeedId() {
|
public int getFeedId() {
|
||||||
return m_feedId;
|
return m_feedId;
|
||||||
@ -45,15 +48,17 @@ public class OfflineArticlePager extends Fragment {
|
|||||||
feedClause = "feed_id = ?";
|
feedClause = "feed_id = ?";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String orderBy = (m_prefs.getBoolean("offline_oldest_first", false)) ? "updated" : "updated DESC";
|
||||||
|
|
||||||
if (m_searchQuery == null || m_searchQuery.equals("")) {
|
if (m_searchQuery == null || m_searchQuery.equals("")) {
|
||||||
return m_activity.getReadableDb().query("articles LEFT JOIN feeds ON (feed_id = feeds."+BaseColumns._ID+")",
|
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[] { "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 {
|
} else {
|
||||||
return m_activity.getReadableDb().query("articles LEFT JOIN feeds ON (feed_id = feeds."+BaseColumns._ID+")",
|
return m_activity.getReadableDb().query("articles LEFT JOIN feeds ON (feed_id = feeds."+BaseColumns._ID+")",
|
||||||
new String[] { "articles."+BaseColumns._ID },
|
new String[] { "articles."+BaseColumns._ID },
|
||||||
feedClause + " AND (articles.title LIKE '%' || ? || '%' OR content LIKE '%' || ? || '%')",
|
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,6 +177,9 @@ public class OfflineArticlePager extends Fragment {
|
|||||||
|
|
||||||
m_activity = (OfflineActivity)activity;
|
m_activity = (OfflineActivity)activity;
|
||||||
m_listener = (OfflineHeadlinesEventListener)activity;
|
m_listener = (OfflineHeadlinesEventListener)activity;
|
||||||
|
|
||||||
|
m_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
||||||
|
|
||||||
m_cursor = createCursor();
|
m_cursor = createCursor();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -303,15 +303,17 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
feedClause = "feed_id = ?";
|
feedClause = "feed_id = ?";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String orderBy = (m_prefs.getBoolean("offline_oldest_first", false)) ? "updated" : "updated DESC";
|
||||||
|
|
||||||
if (m_searchQuery == null || m_searchQuery.equals("")) {
|
if (m_searchQuery == null || m_searchQuery.equals("")) {
|
||||||
return m_activity.getReadableDb().query("articles LEFT JOIN feeds ON (feed_id = feeds."+BaseColumns._ID+")",
|
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[] { "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 {
|
} else {
|
||||||
return m_activity.getReadableDb().query("articles LEFT JOIN feeds ON (feed_id = feeds."+BaseColumns._ID+")",
|
return m_activity.getReadableDb().query("articles LEFT JOIN feeds ON (feed_id = feeds."+BaseColumns._ID+")",
|
||||||
new String[] { "articles.*", "feeds.title AS feed_title" },
|
new String[] { "articles.*", "feeds.title AS feed_title" },
|
||||||
feedClause + " AND (articles.title LIKE '%' || ? || '%' OR content LIKE '%' || ? || '%')",
|
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