mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Added intelligence selector to item list view.
This commit is contained in:
parent
0bbac42dba
commit
f925f1c054
10 changed files with 73 additions and 25 deletions
|
@ -5,10 +5,19 @@
|
|||
android:background="@drawable/activity_background"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<fragment
|
||||
android:id="@+id/fragment_feedintelligenceselector"
|
||||
android:name="com.newsblur.fragment.FeedIntelligenceSelectorFragment"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:tag="feedIntelligenceSelector" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/activity_itemlist_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@id/fragment_feedintelligenceselector"
|
||||
android:layout_alignParentTop="true" />
|
||||
|
||||
<View
|
||||
|
@ -17,4 +26,10 @@
|
|||
android:layout_alignParentTop="true"
|
||||
android:background="@drawable/orangeline_shadow" />
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="8dip"
|
||||
android:layout_above="@id/fragment_feedintelligenceselector"
|
||||
android:background="@drawable/inverted_orangeline_shadow" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -16,8 +16,9 @@ import com.newsblur.domain.Feed;
|
|||
import com.newsblur.fragment.ItemListFragment;
|
||||
import com.newsblur.fragment.SyncUpdateFragment;
|
||||
import com.newsblur.service.SyncService;
|
||||
import com.newsblur.view.StateToggleButton.StateChangedListener;
|
||||
|
||||
public class ItemsList extends SherlockFragmentActivity implements SyncUpdateFragment.SyncUpdateFragmentInterface {
|
||||
public class ItemsList extends SherlockFragmentActivity implements SyncUpdateFragment.SyncUpdateFragmentInterface, StateChangedListener {
|
||||
|
||||
public static final String EXTRA_FEED = "feedId";
|
||||
private ItemListFragment itemListFragment;
|
||||
|
@ -93,4 +94,10 @@ public class ItemsList extends SherlockFragmentActivity implements SyncUpdateFra
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedState(int state) {
|
||||
Log.d(TAG, "Changed state.");
|
||||
itemListFragment.changeState(state);
|
||||
}
|
||||
|
||||
}
|
|
@ -13,9 +13,7 @@ import com.actionbarsherlock.view.MenuItem;
|
|||
import com.actionbarsherlock.view.Window;
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.fragment.FolderFeedListFragment;
|
||||
import com.newsblur.fragment.ItemListFragment;
|
||||
import com.newsblur.fragment.SyncUpdateFragment;
|
||||
import com.newsblur.network.domain.FeedFolderResponse;
|
||||
import com.newsblur.service.SyncService;
|
||||
import com.newsblur.view.StateToggleButton.StateChangedListener;
|
||||
|
||||
|
|
|
@ -20,20 +20,24 @@ public class FeedProvider extends ContentProvider {
|
|||
public static final Uri FEED_FOLDER_MAP_URI = Uri.parse("content://" + AUTHORITY + "/" + VERSION + "/feedfoldermap/");
|
||||
public static final Uri FOLDERS_URI = Uri.parse("content://" + AUTHORITY + "/" + VERSION + "/folders/");
|
||||
|
||||
public static final String INTELLIGENCE_ALL = " HAVING SUM(" + DatabaseConstants.FEED_NEGATIVE_COUNT + " + " + DatabaseConstants.FEED_NEUTRAL_COUNT + " + " + DatabaseConstants.FEED_POSITIVE_COUNT + ") > 0 ";
|
||||
public static final String INTELLIGENCE_SOME = " HAVING SUM(" + DatabaseConstants.FEED_NEUTRAL_COUNT + " + " + DatabaseConstants.FEED_POSITIVE_COUNT + ") > 0 ";
|
||||
public static final String INTELLIGENCE_BEST = " HAVING SUM(" + DatabaseConstants.FEED_POSITIVE_COUNT + ") > 0 ";
|
||||
public static final String FOLDER_INTELLIGENCE_ALL = " HAVING SUM(" + DatabaseConstants.FEED_NEGATIVE_COUNT + " + " + DatabaseConstants.FEED_NEUTRAL_COUNT + " + " + DatabaseConstants.FEED_POSITIVE_COUNT + ") > 0 ";
|
||||
public static final String FOLDER_INTELLIGENCE_SOME = " HAVING SUM(" + DatabaseConstants.FEED_NEUTRAL_COUNT + " + " + DatabaseConstants.FEED_POSITIVE_COUNT + ") > 0 ";
|
||||
public static final String FOLDER_INTELLIGENCE_BEST = " HAVING SUM(" + DatabaseConstants.FEED_POSITIVE_COUNT + ") > 0 ";
|
||||
|
||||
public static final String STORY_INTELLIGENCE_BEST = " (" + DatabaseConstants.STORY_INTELLIGENCE_AUTHORS + " + " + DatabaseConstants.STORY_INTELLIGENCE_FEED + " + " + DatabaseConstants.STORY_INTELLIGENCE_TAGS + " + " + DatabaseConstants.STORY_INTELLIGENCE_TITLE + ") > 0 ";
|
||||
public static final String STORY_INTELLIGENCE_SOME = " (" + DatabaseConstants.STORY_INTELLIGENCE_AUTHORS + " + " + DatabaseConstants.STORY_INTELLIGENCE_FEED + " + " + DatabaseConstants.STORY_INTELLIGENCE_TAGS + " + " + DatabaseConstants.STORY_INTELLIGENCE_TITLE + ") >= 0 ";
|
||||
|
||||
private static final String TAG = "FeedProvider";
|
||||
|
||||
private static final int ALL_FEEDS = 0;
|
||||
private static final int FEED_STORIES = 1;
|
||||
private static final int STORY_COMMENTS = 7;
|
||||
private static final int ALL_FOLDERS = 2;
|
||||
private static final int SPECIFIC_FOLDER = 3;
|
||||
private static final int INDIVIDUAL_FOLDER = 3;
|
||||
private static final int FEED_FOLDER_MAP = 4;
|
||||
private static final int SPECIFIC_FEED_FOLDER_MAP = 5;
|
||||
private static final int INDIVIDUAL_FEED = 6;
|
||||
private static final int STORY_COMMENTS = 7;
|
||||
private static final int INDIVIDUAL_STORY = 8;
|
||||
|
||||
private BlurDatabase databaseHelper;
|
||||
|
||||
|
@ -43,11 +47,12 @@ public class FeedProvider extends ContentProvider {
|
|||
uriMatcher.addURI(AUTHORITY, VERSION + "/feeds/", ALL_FEEDS);
|
||||
uriMatcher.addURI(AUTHORITY, VERSION + "/feeds/*/", INDIVIDUAL_FEED);
|
||||
uriMatcher.addURI(AUTHORITY, VERSION + "/stories/#/", FEED_STORIES);
|
||||
uriMatcher.addURI(AUTHORITY, VERSION + "/story/#/", INDIVIDUAL_STORY);
|
||||
uriMatcher.addURI(AUTHORITY, VERSION + "/comments/", STORY_COMMENTS);
|
||||
uriMatcher.addURI(AUTHORITY, VERSION + "/feedfoldermap/", FEED_FOLDER_MAP);
|
||||
uriMatcher.addURI(AUTHORITY, VERSION + "/feedfoldermap/*/", SPECIFIC_FEED_FOLDER_MAP);
|
||||
uriMatcher.addURI(AUTHORITY, VERSION + "/folders/", ALL_FOLDERS);
|
||||
uriMatcher.addURI(AUTHORITY, VERSION + "/folders/*/", SPECIFIC_FOLDER);
|
||||
uriMatcher.addURI(AUTHORITY, VERSION + "/folders/*/", INDIVIDUAL_FOLDER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -143,7 +148,11 @@ public class FeedProvider extends ContentProvider {
|
|||
|
||||
// Querying for a stories from a feed
|
||||
case FEED_STORIES:
|
||||
if (!TextUtils.isEmpty(selection)) {
|
||||
selection = selection + " AND " + DatabaseConstants.STORY_FEED_ID + " = ?";
|
||||
} else {
|
||||
selection = DatabaseConstants.STORY_FEED_ID + " = ?";
|
||||
}
|
||||
selectionArgs = new String[] { uri.getLastPathSegment() };
|
||||
return db.query(DatabaseConstants.STORY_TABLE, DatabaseConstants.STORY_COLUMNS, selection, selectionArgs, null, null, DatabaseConstants.STORY_DATE + " DESC");
|
||||
|
||||
|
@ -216,7 +225,8 @@ public class FeedProvider extends ContentProvider {
|
|||
switch (uriMatcher.match(uri)) {
|
||||
case INDIVIDUAL_FEED:
|
||||
return db.update(DatabaseConstants.FEED_TABLE, values, DatabaseConstants.FEED_ID + " = ?", new String[] { uri.getLastPathSegment() });
|
||||
|
||||
case INDIVIDUAL_STORY:
|
||||
return db.update(DatabaseConstants.STORY_TABLE, values, DatabaseConstants.STORY_ID + " = ?", new String[] { uri.getLastPathSegment() });
|
||||
default:
|
||||
throw new UnsupportedOperationException("Unknown URI: " + uri);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import com.newsblur.domain.Folder;
|
|||
public class FolderTreeAdapter extends SimpleCursorTreeAdapter {
|
||||
|
||||
ContentResolver resolver;
|
||||
public String currentState = FeedProvider.INTELLIGENCE_ALL;
|
||||
public String currentState = FeedProvider.FOLDER_INTELLIGENCE_ALL;
|
||||
private String TAG = "FolderTreeAdapter";
|
||||
|
||||
public FolderTreeAdapter(Context context, Cursor cursor, int collapsedGroupLayout, String[] groupFrom, int[] groupTo, int childLayout, String[] childFrom, int[] childTo) {
|
||||
|
|
|
@ -46,7 +46,7 @@ public class FolderFeedListFragment extends Fragment implements OnGroupClickList
|
|||
resolver = getActivity().getContentResolver();
|
||||
apiManager = new APIManager(getActivity());
|
||||
|
||||
Cursor cursor = resolver.query(FeedProvider.FOLDERS_URI, null, null, null, null);
|
||||
Cursor cursor = resolver.query(FeedProvider.FOLDERS_URI, null, null, new String[] { FeedProvider.FOLDER_INTELLIGENCE_ALL }, null);
|
||||
viewBinder = new FolderTreeViewBinder();
|
||||
|
||||
leftBound = UIUtils.convertDPsToPixels(getActivity(), 20);
|
||||
|
@ -129,13 +129,13 @@ public class FolderFeedListFragment extends Fragment implements OnGroupClickList
|
|||
|
||||
switch (state) {
|
||||
case (AppConstants.STATE_ALL):
|
||||
selection = FeedProvider.INTELLIGENCE_ALL;
|
||||
selection = FeedProvider.FOLDER_INTELLIGENCE_ALL;
|
||||
break;
|
||||
case (AppConstants.STATE_SOME):
|
||||
selection = FeedProvider.INTELLIGENCE_SOME;
|
||||
selection = FeedProvider.FOLDER_INTELLIGENCE_SOME;
|
||||
break;
|
||||
case (AppConstants.STATE_BEST):
|
||||
selection = FeedProvider.INTELLIGENCE_BEST;
|
||||
selection = FeedProvider.FOLDER_INTELLIGENCE_BEST;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.newsblur.R;
|
|||
import com.newsblur.activity.Reading;
|
||||
import com.newsblur.database.DatabaseConstants;
|
||||
import com.newsblur.database.FeedProvider;
|
||||
import com.newsblur.util.AppConstants;
|
||||
import com.newsblur.view.ItemViewBinder;
|
||||
|
||||
public class ItemListFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor>, OnItemClickListener {
|
||||
|
@ -32,6 +33,7 @@ public class ItemListFragment extends Fragment implements LoaderManager.LoaderCa
|
|||
private String feedId;
|
||||
public static int ITEMLIST_LOADER = 0x01;
|
||||
private SimpleCursorAdapter adapter;
|
||||
private Uri storiesUri;
|
||||
|
||||
public ItemListFragment(final String feedId) {
|
||||
this.feedId = feedId;
|
||||
|
@ -56,8 +58,8 @@ public class ItemListFragment extends Fragment implements LoaderManager.LoaderCa
|
|||
ListView itemList = (ListView) v.findViewById(R.id.itemlistfragment_list);
|
||||
|
||||
contentResolver = getActivity().getContentResolver();
|
||||
Uri uri = FeedProvider.STORIES_URI.buildUpon().appendPath(feedId).build();
|
||||
Cursor cursor = contentResolver.query(uri, null, null, null, null);
|
||||
storiesUri = FeedProvider.STORIES_URI.buildUpon().appendPath(feedId).build();
|
||||
Cursor cursor = contentResolver.query(storiesUri, null, null, null, null);
|
||||
|
||||
String[] groupFrom = new String[] { DatabaseConstants.STORY_TITLE, DatabaseConstants.STORY_AUTHORS, DatabaseConstants.STORY_READ, DatabaseConstants.STORY_SHORTDATE, DatabaseConstants.STORY_INTELLIGENCE_AUTHORS };
|
||||
int[] groupTo = new int[] { R.id.row_item_title, R.id.row_item_author, R.id.row_item_title, R.id.row_item_date, R.id.row_item_sidebar };
|
||||
|
@ -105,6 +107,23 @@ public class ItemListFragment extends Fragment implements LoaderManager.LoaderCa
|
|||
startActivity(i);
|
||||
}
|
||||
|
||||
public void changeState(int state) {
|
||||
String selection = null;
|
||||
|
||||
switch (state) {
|
||||
case (AppConstants.STATE_ALL):
|
||||
selection = "";
|
||||
break;
|
||||
case (AppConstants.STATE_SOME):
|
||||
selection = FeedProvider.STORY_INTELLIGENCE_SOME;
|
||||
break;
|
||||
case (AppConstants.STATE_BEST):
|
||||
selection = FeedProvider.STORY_INTELLIGENCE_BEST;
|
||||
break;
|
||||
}
|
||||
|
||||
Cursor cursor = contentResolver.query(storiesUri, null, selection, null, null);
|
||||
adapter.swapCursor(cursor);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ public class ReadingItemFragment extends Fragment {
|
|||
public static ReadingItemFragment newInstance(Story story) {
|
||||
ReadingItemFragment readingFragment = new ReadingItemFragment();
|
||||
|
||||
// Supply num input as an argument.
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable("story", story);
|
||||
readingFragment.setArguments(args);
|
||||
|
@ -168,7 +167,7 @@ public class ReadingItemFragment extends Fragment {
|
|||
web.setHorizontalScrollBarEnabled(false);
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
// TODO: Define a better strategy for rescaling the HTML across device screen sizes and storying this HTML as boilderplate somewhere
|
||||
// TODO: Define a better strategy for rescaling the HTML across device screen sizes and storying this HTML as boilerplate somewhere
|
||||
builder.append("<html><head><meta name=\"viewport\" content=\"target-densitydpi=device-dpi\" /><link rel=\"stylesheet\" type=\"text/css\" href=\"reading.css\" /></head><body>");
|
||||
builder.append(story.content);
|
||||
builder.append("</body></html>");
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.newsblur.network;
|
|||
public class APIConstants {
|
||||
|
||||
public static final String URL_LOGIN = "http://dev.newsblur.com/api/login";
|
||||
public static final String URL_FEEDS = "http://dev.newsblur.com/reader/feeds/?include_favicons=true";
|
||||
public static final String URL_FEEDS = "http://dev.newsblur.com/reader/feeds/?include_favicons=true&flat=true";
|
||||
public static final String URL_USER_PROFILE = "http://dev.newsblur.com/social/profile";
|
||||
public static final String URL_MY_PROFILE = "http://dev.newsblur.com/social/load_user_profile";
|
||||
public static final String URL_FOLLOW = "http://dev.newsblur.com/social/follow";
|
||||
|
|
|
@ -61,7 +61,7 @@ public class FolderTreeViewBinder implements ViewBinder {
|
|||
} else if (TextUtils.equals(cursor.getColumnName(columnIndex), DatabaseConstants.FOLDER_NAME)) {
|
||||
String folderName = cursor.getString(columnIndex);
|
||||
if (TextUtils.isEmpty(folderName)) {
|
||||
folderName = "Unsorted";
|
||||
folderName = "Everything";
|
||||
} else {
|
||||
folderName = folderName.toUpperCase();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue