mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Update activities to use StoryOrder/ReadFilter values from preferences
This commit is contained in:
parent
e161b3a6a7
commit
c9bd7b7a66
7 changed files with 46 additions and 11 deletions
|
@ -11,6 +11,9 @@ import com.newsblur.database.DatabaseConstants;
|
|||
import com.newsblur.database.FeedProvider;
|
||||
import com.newsblur.database.MixedFeedsReadingAdapter;
|
||||
import com.newsblur.service.SyncService;
|
||||
import com.newsblur.util.PrefConstants;
|
||||
import com.newsblur.util.PrefsUtils;
|
||||
import com.newsblur.util.StoryOrder;
|
||||
|
||||
public class AllSharedStoriesReading extends Reading {
|
||||
|
||||
|
@ -28,6 +31,7 @@ public class AllSharedStoriesReading extends Reading {
|
|||
|
||||
setupCountCursor();
|
||||
|
||||
StoryOrder storyOrder = PrefsUtils.getStoryOrderForFolder(this, PrefConstants.ALL_SHARED_STORIES_FOLDER_NAME);
|
||||
stories = contentResolver.query(FeedProvider.ALL_SHARED_STORIES_URI, null, DatabaseConstants.getStorySelectionFromState(currentState), null, DatabaseConstants.getStorySortOrder(storyOrder));
|
||||
setTitle(getResources().getString(R.string.all_shared_stories));
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getSupportFragmentManager(), getContentResolver(), stories);
|
||||
|
@ -38,6 +42,7 @@ public class AllSharedStoriesReading extends Reading {
|
|||
}
|
||||
|
||||
private void setupCountCursor() {
|
||||
StoryOrder storyOrder = PrefsUtils.getStoryOrderForFolder(this, PrefConstants.ALL_SHARED_STORIES_FOLDER_NAME);
|
||||
Cursor cursor = getContentResolver().query(FeedProvider.FEEDS_URI, null, DatabaseConstants.getStorySelectionFromState(currentState), null, DatabaseConstants.getStorySortOrder(storyOrder));
|
||||
startManagingCursor(cursor);
|
||||
feedIds = new ArrayList<String>();
|
||||
|
|
|
@ -5,13 +5,15 @@ import java.util.ArrayList;
|
|||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.database.DatabaseConstants;
|
||||
import com.newsblur.database.FeedProvider;
|
||||
import com.newsblur.database.MixedFeedsReadingAdapter;
|
||||
import com.newsblur.service.SyncService;
|
||||
import com.newsblur.util.PrefConstants;
|
||||
import com.newsblur.util.PrefsUtils;
|
||||
import com.newsblur.util.StoryOrder;
|
||||
|
||||
public class AllStoriesReading extends Reading {
|
||||
|
||||
|
@ -29,6 +31,7 @@ public class AllStoriesReading extends Reading {
|
|||
|
||||
setupCountCursor();
|
||||
|
||||
StoryOrder storyOrder = PrefsUtils.getStoryOrderForFolder(this, PrefConstants.ALL_STORIES_FOLDER_NAME);
|
||||
stories = contentResolver.query(FeedProvider.ALL_STORIES_URI, null, DatabaseConstants.getStorySelectionFromState(currentState), null, DatabaseConstants.getStorySortOrder(storyOrder));
|
||||
setTitle(getResources().getString(R.string.all_stories));
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getSupportFragmentManager(), getContentResolver(), stories);
|
||||
|
@ -81,8 +84,8 @@ public class AllStoriesReading extends Reading {
|
|||
if (page > 1) {
|
||||
intent.putExtra(SyncService.EXTRA_TASK_PAGE_NUMBER, Integer.toString(page));
|
||||
}
|
||||
intent.putExtra(SyncService.EXTRA_TASK_ORDER, storyOrder);
|
||||
intent.putExtra(SyncService.EXTRA_TASK_READ_FILTER, readFilter);
|
||||
intent.putExtra(SyncService.EXTRA_TASK_ORDER, PrefsUtils.getStoryOrderForFolder(this, PrefConstants.ALL_STORIES_FOLDER_NAME));
|
||||
intent.putExtra(SyncService.EXTRA_TASK_READ_FILTER, PrefsUtils.getReadFilterForFolder(this, PrefConstants.ALL_STORIES_FOLDER_NAME));
|
||||
|
||||
startService(intent);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.newsblur.domain.Classifier;
|
|||
import com.newsblur.domain.Feed;
|
||||
import com.newsblur.fragment.SyncUpdateFragment;
|
||||
import com.newsblur.service.SyncService;
|
||||
import com.newsblur.util.PrefsUtils;
|
||||
|
||||
public class FeedReading extends Reading {
|
||||
|
||||
|
@ -98,8 +99,8 @@ public class FeedReading extends Reading {
|
|||
if (page > 1) {
|
||||
intent.putExtra(SyncService.EXTRA_TASK_PAGE_NUMBER, Integer.toString(page));
|
||||
}
|
||||
intent.putExtra(SyncService.EXTRA_TASK_ORDER, storyOrder);
|
||||
intent.putExtra(SyncService.EXTRA_TASK_READ_FILTER, readFilter);
|
||||
intent.putExtra(SyncService.EXTRA_TASK_ORDER, PrefsUtils.getStoryOrderForFeed(this, feedId));
|
||||
intent.putExtra(SyncService.EXTRA_TASK_READ_FILTER, PrefsUtils.getReadFilterForFeed(this, feedId));
|
||||
startService(intent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.newsblur.database.DatabaseConstants;
|
|||
import com.newsblur.database.FeedProvider;
|
||||
import com.newsblur.database.MixedFeedsReadingAdapter;
|
||||
import com.newsblur.service.SyncService;
|
||||
import com.newsblur.util.PrefsUtils;
|
||||
|
||||
public class FolderReading extends Reading {
|
||||
|
||||
|
@ -59,8 +60,8 @@ public class FolderReading extends Reading {
|
|||
if (page > 1) {
|
||||
intent.putExtra(SyncService.EXTRA_TASK_PAGE_NUMBER, Integer.toString(page));
|
||||
}
|
||||
intent.putExtra(SyncService.EXTRA_TASK_ORDER, storyOrder);
|
||||
intent.putExtra(SyncService.EXTRA_TASK_READ_FILTER, readFilter);
|
||||
intent.putExtra(SyncService.EXTRA_TASK_ORDER, PrefsUtils.getStoryOrderForFolder(this, folderName));
|
||||
intent.putExtra(SyncService.EXTRA_TASK_READ_FILTER, PrefsUtils.getReadFilterForFolder(this, folderName));
|
||||
|
||||
startService(intent);
|
||||
}
|
||||
|
|
|
@ -56,10 +56,6 @@ public abstract class Reading extends NbFragmentActivity implements OnPageChange
|
|||
protected SyncUpdateFragment syncFragment;
|
||||
protected Cursor stories;
|
||||
|
||||
// TODO use property values
|
||||
protected StoryOrder storyOrder = StoryOrder.NEWEST;
|
||||
protected ReadFilter readFilter = ReadFilter.ALL;
|
||||
|
||||
private Set<Story> storiesToMarkAsRead;
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,4 +27,10 @@ public class PrefConstants {
|
|||
|
||||
public static final String PREFERENCE_REGISTRATION_STATE = "registration_stage";
|
||||
|
||||
public static final String FEED_STORY_ORDER_PREFIX = "feed_order_";
|
||||
public static final String FEED_READ_FILTER_PREFIX = "feed_read_filter_";
|
||||
public static final String FOLDER_STORY_ORDER_PREFIX = "folder_order_";
|
||||
public static final String FOLDER_READ_FILTER_PREFIX = "folder_read_filter_";
|
||||
public static final String ALL_STORIES_FOLDER_NAME = "all_stories";
|
||||
public static final String ALL_SHARED_STORIES_FOLDER_NAME = "all_shared_stories";
|
||||
}
|
||||
|
|
|
@ -179,4 +179,27 @@ public class PrefsUtils {
|
|||
prefs.edit().putLong(AppConstants.LAST_SYNC_TIME, (new Date()).getTime()).commit();
|
||||
}
|
||||
|
||||
public static StoryOrder getStoryOrderForFeed(Context context, String feedId)
|
||||
{
|
||||
SharedPreferences prefs = context.getSharedPreferences(PrefConstants.PREFERENCES, 0);
|
||||
return StoryOrder.valueOf(prefs.getString(PrefConstants.FEED_STORY_ORDER_PREFIX + feedId, StoryOrder.NEWEST.getParameterValue()));
|
||||
}
|
||||
|
||||
public static StoryOrder getStoryOrderForFolder(Context context, String folderName)
|
||||
{
|
||||
SharedPreferences prefs = context.getSharedPreferences(PrefConstants.PREFERENCES, 0);
|
||||
return StoryOrder.valueOf(prefs.getString(PrefConstants.FOLDER_STORY_ORDER_PREFIX + folderName, StoryOrder.NEWEST.getParameterValue()));
|
||||
}
|
||||
|
||||
public static ReadFilter getReadFilterForFeed(Context context, String feedId)
|
||||
{
|
||||
SharedPreferences prefs = context.getSharedPreferences(PrefConstants.PREFERENCES, 0);
|
||||
return ReadFilter.valueOf(prefs.getString(PrefConstants.FEED_READ_FILTER_PREFIX + feedId, ReadFilter.ALL.getParameterValue()));
|
||||
}
|
||||
|
||||
public static ReadFilter getReadFilterForFolder(Context context, String folderName)
|
||||
{
|
||||
SharedPreferences prefs = context.getSharedPreferences(PrefConstants.PREFERENCES, 0);
|
||||
return ReadFilter.valueOf(prefs.getString(PrefConstants.FOLDER_READ_FILTER_PREFIX + folderName, ReadFilter.ALL.getParameterValue()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue