mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Support mark-unread for stories.
This commit is contained in:
parent
34dec1f322
commit
8ab30d2951
6 changed files with 56 additions and 0 deletions
|
@ -27,4 +27,9 @@
|
|||
android:showAsAction="never"
|
||||
android:title="@string/menu_save_story"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_reading_markunread"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/menu_mark_unread"/>
|
||||
|
||||
</menu>
|
||||
|
|
|
@ -88,6 +88,7 @@
|
|||
<string name="menu_save_story">Save this story</string>
|
||||
<string name="menu_mark_previous_stories_as_read">Mark previous as read</string>
|
||||
<string name="menu_mark_story_as_read">Mark as read</string>
|
||||
<string name="menu_mark_unread">Mark as unread</string>
|
||||
|
||||
<string name="toast_marked_folder_as_read">Folder marked as read</string>
|
||||
<string name="toast_marked_feed_as_read">Feed marked as read</string>
|
||||
|
@ -97,6 +98,9 @@
|
|||
|
||||
<string name="toast_story_saved">Story saved</string>
|
||||
<string name="toast_story_save_error">Error marking story as saved.</string>
|
||||
|
||||
<string name="toast_story_unread">Story marked as unread</string>
|
||||
<string name="toast_story_unread_error">Error marking story as unread</string>
|
||||
|
||||
<string name="logout_warning">Are you sure you want to log out?</string>
|
||||
|
||||
|
|
|
@ -143,6 +143,9 @@ public abstract class Reading extends NbFragmentActivity implements OnPageChange
|
|||
} else if (item.getItemId() == R.id.menu_reading_save) {
|
||||
FeedUtils.saveStory(story, Reading.this, apiManager);
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.menu_reading_markunread) {
|
||||
this.markStoryUnread(story);
|
||||
return true;
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
@ -216,6 +219,17 @@ public abstract class Reading extends NbFragmentActivity implements OnPageChange
|
|||
}
|
||||
}
|
||||
|
||||
private void markStoryUnread(Story story) {
|
||||
|
||||
// first, ensure the story isn't queued up to be marked as read
|
||||
this.storiesToMarkAsRead.remove(story);
|
||||
|
||||
// next, call the API to un-mark it as read, just in case we missed the batch
|
||||
// operation, or it was read long before now.
|
||||
FeedUtils.markStoryUnread(story, Reading.this, this.apiManager);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
getSharedPreferences(PrefConstants.PREFERENCES, 0).edit().putFloat(PrefConstants.PREFERENCE_TEXT_SIZE, (float) progress / AppConstants.FONT_SIZE_INCREMENT_FACTOR).commit();
|
||||
|
|
|
@ -27,6 +27,7 @@ public class APIConstants {
|
|||
public static final String URL_MARK_SOCIALSTORY_AS_READ = "http://newsblur.com/reader/mark_social_stories_as_read/";
|
||||
public static final String URL_SHARE_STORY = "http://newsblur.com/social/share_story";
|
||||
public static final String URL_MARK_STORY_AS_STARRED = "http://newsblur.com/reader/mark_story_as_starred/";
|
||||
public static final String URL_MARK_STORY_AS_UNREAD = "http://newsblur.com/reader/mark_story_as_unread/";
|
||||
public static final String URL_STARRED_STORIES = "http://newsblur.com/reader/starred_stories";
|
||||
|
||||
public static final String URL_FEED_AUTOCOMPLETE = "http://newsblur.com/rss_feeds/feed_autocomplete";
|
||||
|
|
|
@ -151,6 +151,19 @@ public class APIManager {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean markStoryAsUnread( String feedId, String storyId ) {
|
||||
final APIClient client = new APIClient(context);
|
||||
final ValueMultimap values = new ValueMultimap();
|
||||
values.put(APIConstants.PARAMETER_FEEDID, feedId);
|
||||
values.put(APIConstants.PARAMETER_STORYID, storyId);
|
||||
final APIResponse response = client.post(APIConstants.URL_MARK_STORY_AS_UNREAD, values, false);
|
||||
if (!response.isOffline && response.responseCode == HttpStatus.SC_OK && !response.hasRedirected) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public CategoriesResponse getCategories() {
|
||||
final APIClient client = new APIClient(context);
|
||||
final APIResponse response = client.get(APIConstants.URL_CATEGORIES);
|
||||
|
|
|
@ -54,6 +54,25 @@ public class FeedUtils {
|
|||
}
|
||||
}
|
||||
|
||||
public static void markStoryUnread( final Story story, final Context context, final APIManager apiManager) {
|
||||
|
||||
new AsyncTask<Void, Void, Boolean>() {
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... arg) {
|
||||
return apiManager.markStoryAsUnread(story.feedId, story.id);
|
||||
}
|
||||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
if (result) {
|
||||
Toast.makeText(context, R.string.toast_story_unread, Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(context, R.string.toast_story_unread_error, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This utility method is a fast-returning way to mark as read a batch of stories in both
|
||||
* the local DB and on the server.
|
||||
|
|
Loading…
Add table
Reference in a new issue