mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
#1226 Preference for feed order
This commit is contained in:
parent
62c94b0181
commit
8ef74ce745
7 changed files with 56 additions and 0 deletions
|
@ -355,6 +355,7 @@
|
|||
|
||||
<string name="settings_cat_feed_list">Feed List</string>
|
||||
|
||||
<string name="setting_feed_list_order">Feed list order</string>
|
||||
<string name="settings_enable_row_global_shared">Show Global Shared Stories</string>
|
||||
<string name="settings_enable_row_global_shared_sum">Show the Global Shared Stories folder</string>
|
||||
<string name="settings_enable_row_infrequent_stories">Show Infrequent Stories</string>
|
||||
|
@ -375,6 +376,18 @@
|
|||
</string-array>
|
||||
<string name="default_story_order_value">NEWEST</string>
|
||||
|
||||
<string name="alphabetical">Alphabetical</string>
|
||||
<string name="most_used_at_top">Most used at top</string>
|
||||
<string-array name="default_feed_list_order_entries">
|
||||
<item>@string/alphabetical</item>
|
||||
<item>@string/most_used_at_top</item>
|
||||
</string-array>
|
||||
<string-array name="default_feed_list_order_values">
|
||||
<item>ALPHABETICAL</item>
|
||||
<item>MOST_USED_AT_TOP</item>
|
||||
</string-array>
|
||||
<string name="default_feed_list_order_value">ALPHABETICAL</string>
|
||||
|
||||
<string name="all_stories">All Stories</string>
|
||||
<string name="unread_only">Unread Only</string>
|
||||
<string name="menu_story_content_preview">Content Preview</string>
|
||||
|
|
|
@ -47,6 +47,13 @@
|
|||
|
||||
<PreferenceCategory
|
||||
android:title="@string/settings_cat_feed_list">
|
||||
<ListPreference
|
||||
android:key="feed_list_order"
|
||||
android:title="@string/setting_feed_list_order"
|
||||
android:dialogTitle="@string/setting_feed_list_order"
|
||||
android:entries="@array/default_feed_list_order_entries"
|
||||
android:entryValues="@array/default_feed_list_order_values"
|
||||
android:defaultValue="@string/default_feed_list_order_value" />
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="enable_row_global_shared"
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.lang.ref.WeakReference;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
|
@ -33,6 +34,7 @@ import com.newsblur.domain.SavedSearch;
|
|||
import com.newsblur.domain.StarredCount;
|
||||
import com.newsblur.domain.SocialFeed;
|
||||
import com.newsblur.util.AppConstants;
|
||||
import com.newsblur.util.FeedListOrder;
|
||||
import com.newsblur.util.FeedSet;
|
||||
import com.newsblur.util.FeedUtils;
|
||||
import com.newsblur.util.PrefsUtils;
|
||||
|
@ -676,6 +678,14 @@ public class FolderListAdapter extends BaseExpandableListAdapter {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sort feeds within each folder
|
||||
FeedListOrder feedListOrder = PrefsUtils.getFeedListOrder(context);
|
||||
Comparator<Feed> feedComparator = Feed.getFeedListOrderComparator(feedListOrder);
|
||||
for (List<Feed> folderChildren : activeFolderChildren) {
|
||||
Collections.sort(folderChildren, feedComparator);
|
||||
}
|
||||
|
||||
// add the always-present (if enabled) special rows/folders that got at the bottom of the list
|
||||
addSpecialRow(READ_STORIES_GROUP_KEY);
|
||||
addSpecialRow(SAVED_SEARCHES_GROUP_KEY);
|
||||
|
|
|
@ -6,10 +6,12 @@ import android.text.TextUtils;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.newsblur.database.DatabaseConstants;
|
||||
import com.newsblur.util.FeedListOrder;
|
||||
|
||||
public class Feed implements Comparable<Feed>, Serializable {
|
||||
|
||||
|
@ -207,4 +209,13 @@ public class Feed implements Comparable<Feed>, Serializable {
|
|||
public static final String NOTIFY_FILTER_UNREAD = "unread";
|
||||
public static final String NOTIFY_FILTER_FOCUS = "focus";
|
||||
|
||||
public static Comparator<Feed> getFeedListOrderComparator(FeedListOrder feedListOrder) {
|
||||
return (o1, o2) -> {
|
||||
if (feedListOrder == FeedListOrder.MOST_USED_AT_TOP) {
|
||||
return Integer.compare(o2.feedOpens, o1.feedOpens);
|
||||
} else {
|
||||
return o1.title.compareToIgnoreCase(o2.title);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package com.newsblur.util
|
||||
|
||||
enum class FeedListOrder {
|
||||
ALPHABETICAL,
|
||||
MOST_USED_AT_TOP
|
||||
}
|
|
@ -70,6 +70,7 @@ public class PrefConstants {
|
|||
public static final String NETWORK_SELECT = "offline_network_select";
|
||||
public static final String KEEP_OLD_STORIES = "keep_old_stories";
|
||||
public static final String CACHE_AGE_SELECT = "cache_age_select";
|
||||
public static final String FEED_LIST_ORDER = "feed_list_order";
|
||||
|
||||
public static final String NETWORK_SELECT_ANY = "ANY";
|
||||
public static final String NETWORK_SELECT_NOMO = "NOMO";
|
||||
|
@ -87,6 +88,9 @@ public class PrefConstants {
|
|||
public static final String ENABLE_ROW_GLOBAL_SHARED = "enable_row_global_shared";
|
||||
public static final String ENABLE_ROW_INFREQUENT_STORIES = "enable_row_infrequent_stories";
|
||||
|
||||
public static final String FEED_LIST_ORDER_ALPHABETICAL = "feed_list_order_alphabetical";
|
||||
public static final String FEED_LIST_ORDER_MOST_USED_AT_TOP = "feed_list_order_most_used_at_top";
|
||||
|
||||
public static final String THEME = "theme";
|
||||
public enum ThemeValue {
|
||||
AUTO,
|
||||
|
|
|
@ -804,6 +804,11 @@ public class PrefsUtils {
|
|||
return PrefConstants.CACHE_AGE_VALUE_30D;
|
||||
}
|
||||
|
||||
public static FeedListOrder getFeedListOrder(Context context) {
|
||||
SharedPreferences prefs = context.getSharedPreferences(PrefConstants.PREFERENCES, 0);
|
||||
return FeedListOrder.valueOf(prefs.getString(PrefConstants.FEED_LIST_ORDER, FeedListOrder.ALPHABETICAL.toString()));
|
||||
}
|
||||
|
||||
public static void applyThemePreference(Activity activity) {
|
||||
ThemeValue value = getSelectedTheme(activity);
|
||||
if (value == ThemeValue.LIGHT) {
|
||||
|
|
Loading…
Add table
Reference in a new issue