mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Added all blurblog categories to an All Shared Stories folder.
This commit is contained in:
parent
d5b6f1ea8e
commit
233b51870a
9 changed files with 173 additions and 93 deletions
Binary file not shown.
Before Width: | Height: | Size: 848 B |
Binary file not shown.
Before Width: | Height: | Size: 543 B |
Binary file not shown.
Before Width: | Height: | Size: 698 B |
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB |
66
media/android/NewsBlur/res/layout/row_all_shared_stories.xml
Normal file
66
media/android/NewsBlur/res/layout/row_all_shared_stories.xml
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:background="@color/newsblur_blue"
|
||||||
|
android:paddingBottom="15dp"
|
||||||
|
android:paddingTop="15dp" >
|
||||||
|
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/row_everything_icon"
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginLeft="18dp"
|
||||||
|
android:layout_marginRight="12dp"
|
||||||
|
android:contentDescription="@string/description_row_folder_icon"
|
||||||
|
android:src="@drawable/person" />
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/row_everythingtext"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginLeft="50dp"
|
||||||
|
android:text="@string/all_shared_stories"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="16dp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/row_foldersums"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginRight="5dp" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/row_foldersumneu"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
|
android:background="@drawable/neutral_count_rect"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="5dp"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="12dp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/row_foldersumpos"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
|
android:background="@drawable/positive_count_rect"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="5dp"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="12dp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
|
@ -40,6 +40,7 @@
|
||||||
<string name="reading_sharedby">SHARED BY: </string>
|
<string name="reading_sharedby">SHARED BY: </string>
|
||||||
|
|
||||||
<string name="everything">All stories</string>
|
<string name="everything">All stories</string>
|
||||||
|
<string name="all_shared_stories">All shared stories</string>
|
||||||
|
|
||||||
<string name="replied">Reply posted</string>
|
<string name="replied">Reply posted</string>
|
||||||
<string name="error_replying">There was an error replying</string>
|
<string name="error_replying">There was an error replying</string>
|
||||||
|
|
|
@ -27,9 +27,12 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
private boolean mAutoRequery;
|
private boolean mAutoRequery;
|
||||||
|
|
||||||
private final int GROUP = 0;
|
private final int FOLDER = 0;
|
||||||
private final int BLOG = 1;
|
private final int BLOG = 0;
|
||||||
private final int EVERYTHING = 2;
|
private final int FEED = 1;
|
||||||
|
|
||||||
|
private final int ALL_STORIES = 1;
|
||||||
|
private final int ALL_SHARED_STORIES = 2;
|
||||||
|
|
||||||
private SparseArray<MyCursorHelper> mChildrenCursorHelpers;
|
private SparseArray<MyCursorHelper> mChildrenCursorHelpers;
|
||||||
private MyCursorHelper folderCursorHelper, blogCursorHelper;
|
private MyCursorHelper folderCursorHelper, blogCursorHelper;
|
||||||
|
@ -125,37 +128,67 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getGroupType(int groupPosition) {
|
public int getGroupType(int groupPosition) {
|
||||||
if (groupPosition < blogCursorHelper.getCount()) {
|
if (groupPosition == 0) {
|
||||||
return BLOG;
|
return ALL_SHARED_STORIES;
|
||||||
} else if (groupPosition == blogCursorHelper.getCount()) {
|
} else if (groupPosition == 1) {
|
||||||
return EVERYTHING;
|
return ALL_STORIES;
|
||||||
} else {
|
} else {
|
||||||
return GROUP;
|
return FOLDER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getChildType(int groupPosition, int childPosition) {
|
||||||
|
if (groupPosition == 0) {
|
||||||
|
return BLOG;
|
||||||
|
} else {
|
||||||
|
return FEED;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getGroupTypeCount() {
|
public int getGroupTypeCount() {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getChildTypeCount() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cursor getChild(int groupPosition, int childPosition) {
|
public Cursor getChild(int groupPosition, int childPosition) {
|
||||||
groupPosition = groupPosition - blogCursorHelper.getCount() - 1;
|
if (groupPosition == 0) {
|
||||||
|
blogCursorHelper.moveTo(childPosition);
|
||||||
|
return blogCursorHelper.getCursor();
|
||||||
|
} else {
|
||||||
|
groupPosition = groupPosition - 2;
|
||||||
return getChildrenCursorHelper(groupPosition, true).moveTo(childPosition);
|
return getChildrenCursorHelper(groupPosition, true).moveTo(childPosition);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getChildId(int groupPosition, int childPosition) {
|
public long getChildId(int groupPosition, int childPosition) {
|
||||||
groupPosition = groupPosition - blogCursorHelper.getCount() - 1;
|
if (groupPosition == 0) {
|
||||||
|
return blogCursorHelper.getId(childPosition);
|
||||||
|
} else {
|
||||||
|
groupPosition = groupPosition - 2;
|
||||||
return getChildrenCursorHelper(groupPosition, true).getId(childPosition);
|
return getChildrenCursorHelper(groupPosition, true).getId(childPosition);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
|
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
|
||||||
|
View v;
|
||||||
groupPosition = groupPosition - blogCursorHelper.getCount() - 1;
|
if (groupPosition == 0) {
|
||||||
|
blogCursorHelper.moveTo(childPosition);
|
||||||
|
if (convertView == null) {
|
||||||
|
v = newBlogView(context, blogCursorHelper.getCursor(), parent);
|
||||||
|
} else {
|
||||||
|
v = convertView;
|
||||||
|
}
|
||||||
|
bindBlogView(v, context, blogCursorHelper.getCursor());
|
||||||
|
} else {
|
||||||
|
groupPosition = groupPosition - 2;
|
||||||
|
|
||||||
MyCursorHelper cursorHelper = getChildrenCursorHelper(groupPosition, true);
|
MyCursorHelper cursorHelper = getChildrenCursorHelper(groupPosition, true);
|
||||||
|
|
||||||
|
@ -163,27 +196,28 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
|
||||||
if (cursor == null) {
|
if (cursor == null) {
|
||||||
throw new IllegalStateException("This should only be called when the cursor is valid");
|
throw new IllegalStateException("This should only be called when the cursor is valid");
|
||||||
}
|
}
|
||||||
|
|
||||||
View v;
|
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
v = newChildView(context, cursor, isLastChild, parent);
|
v = newChildView(context, cursor, isLastChild, parent);
|
||||||
} else {
|
} else {
|
||||||
v = convertView;
|
v = convertView;
|
||||||
}
|
}
|
||||||
bindChildView(v, context, cursor, isLastChild);
|
bindChildView(v, context, cursor, isLastChild);
|
||||||
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getChildrenCount(int groupPosition) {
|
public int getChildrenCount(int groupPosition) {
|
||||||
if (groupPosition <= blogCursorHelper.getCount()) {
|
if (groupPosition == 0) {
|
||||||
|
return blogCursorHelper.getCount();
|
||||||
|
} else if (groupPosition == 1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else {
|
||||||
|
groupPosition = groupPosition - 2;
|
||||||
groupPosition = groupPosition - blogCursorHelper.getCount() - 1;
|
|
||||||
MyCursorHelper helper = getChildrenCursorHelper(groupPosition, true);
|
MyCursorHelper helper = getChildrenCursorHelper(groupPosition, true);
|
||||||
return (folderCursorHelper.isValid() && helper != null) ? helper.getCount() : 0;
|
return (folderCursorHelper.isValid() && helper != null) ? helper.getCount() : 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public View newChildView(Context context, Cursor cursor, boolean isLastChild, ViewGroup parent) {
|
public View newChildView(Context context, Cursor cursor, boolean isLastChild, ViewGroup parent) {
|
||||||
return inflater.inflate(childLayout, parent, false);
|
return inflater.inflate(childLayout, parent, false);
|
||||||
|
@ -191,24 +225,20 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cursor getGroup(int groupPosition) {
|
public Cursor getGroup(int groupPosition) {
|
||||||
if (groupPosition >= blogCursorHelper.getCount()) {
|
if (groupPosition >= 2) {
|
||||||
return folderCursorHelper.moveTo(groupPosition - blogCursorHelper.getCount() - 1);
|
return folderCursorHelper.moveTo(groupPosition - 2);
|
||||||
} else {
|
} else {
|
||||||
return blogCursorHelper.moveTo(groupPosition);
|
return blogCursorHelper.moveTo(groupPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGroup(int groupPosition) {
|
public boolean isExpandable(int groupPosition) {
|
||||||
return (groupPosition > blogCursorHelper.getCount());
|
return (groupPosition == 0 || groupPosition > 1);
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isBlog(int groupPosition) {
|
|
||||||
return (groupPosition < blogCursorHelper.getCount());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getGroupCount() {
|
public int getGroupCount() {
|
||||||
return (folderCursorHelper.getCount() + blogCursorHelper.getCount());
|
return (folderCursorHelper.getCount() + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -229,27 +259,24 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
|
||||||
this.countCursor = countCursor;
|
this.countCursor = countCursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
|
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
|
||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
View v;
|
View v;
|
||||||
if (groupPosition < blogCursorHelper.getCount()) {
|
if (groupPosition == 0) {
|
||||||
cursor = blogCursorHelper.moveTo(groupPosition);
|
|
||||||
if (convertView == null) {
|
|
||||||
v = newBlogView(context, cursor, parent);
|
|
||||||
} else {
|
|
||||||
v = convertView;
|
|
||||||
}
|
|
||||||
bindBlogView(v, context, cursor);
|
|
||||||
} else if (groupPosition == blogCursorHelper.getCount()) {
|
|
||||||
cursor = countCursor;
|
cursor = countCursor;
|
||||||
v = inflater.inflate(R.layout.row_everything, null, false);
|
v = inflater.inflate(R.layout.row_all_shared_stories, null, false);
|
||||||
|
countCursor.moveToFirst();
|
||||||
|
((TextView) v.findViewById(R.id.row_foldersumneu)).setText(countCursor.getString(countCursor.getColumnIndex(DatabaseConstants.SUM_NEUT)));
|
||||||
|
((TextView) v.findViewById(R.id.row_foldersumpos)).setText(countCursor.getString(countCursor.getColumnIndex(DatabaseConstants.SUM_POS)));
|
||||||
|
} else if (groupPosition == 1) {
|
||||||
|
cursor = countCursor;
|
||||||
|
v = inflater.inflate(R.layout.row_all_stories, null, false);
|
||||||
countCursor.moveToFirst();
|
countCursor.moveToFirst();
|
||||||
((TextView) v.findViewById(R.id.row_foldersumneu)).setText(countCursor.getString(countCursor.getColumnIndex(DatabaseConstants.SUM_NEUT)));
|
((TextView) v.findViewById(R.id.row_foldersumneu)).setText(countCursor.getString(countCursor.getColumnIndex(DatabaseConstants.SUM_NEUT)));
|
||||||
((TextView) v.findViewById(R.id.row_foldersumpos)).setText(countCursor.getString(countCursor.getColumnIndex(DatabaseConstants.SUM_POS)));
|
((TextView) v.findViewById(R.id.row_foldersumpos)).setText(countCursor.getString(countCursor.getColumnIndex(DatabaseConstants.SUM_POS)));
|
||||||
} else {
|
} else {
|
||||||
cursor = folderCursorHelper.moveTo(groupPosition - blogCursorHelper.getCount() - 1);
|
cursor = folderCursorHelper.moveTo(groupPosition - 2);
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
v = newGroupView(context, cursor, isExpanded, parent);
|
v = newGroupView(context, cursor, isExpanded, parent);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -102,10 +102,10 @@ public class FolderListFragment extends Fragment implements OnGroupClickListener
|
||||||
list.setOnGroupClickListener(this);
|
list.setOnGroupClickListener(this);
|
||||||
list.setOnChildClickListener(this);
|
list.setOnChildClickListener(this);
|
||||||
|
|
||||||
int count = folderAdapter.getGroupCount();
|
// int count = folderAdapter.getGroupCount();
|
||||||
for (int position = 1; position <= count; position++) {
|
// for (int position = 1; position <= count; position++) {
|
||||||
list.expandGroup(position - 1);
|
// list.expandGroup(position - 1);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ public class FolderListFragment extends Fragment implements OnGroupClickListener
|
||||||
|
|
||||||
case R.id.menu_mark_folder_as_read:
|
case R.id.menu_mark_folder_as_read:
|
||||||
int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
|
int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
|
||||||
if (folderAdapter.isGroup(groupPosition)) {
|
if (folderAdapter.isExpandable(groupPosition)) {
|
||||||
final Cursor folderCursor = ((MixedExpandableListAdapter) list.getExpandableListAdapter()).getGroup(groupPosition);
|
final Cursor folderCursor = ((MixedExpandableListAdapter) list.getExpandableListAdapter()).getGroup(groupPosition);
|
||||||
String folderId = folderCursor.getString(folderCursor.getColumnIndex(DatabaseConstants.FOLDER_NAME));
|
String folderId = folderCursor.getString(folderCursor.getColumnIndex(DatabaseConstants.FOLDER_NAME));
|
||||||
new MarkFolderAsReadTask(getActivity(), apiManager, resolver, folderAdapter).execute(folderId);
|
new MarkFolderAsReadTask(getActivity(), apiManager, resolver, folderAdapter).execute(folderId);
|
||||||
|
@ -193,27 +193,13 @@ public class FolderListFragment extends Fragment implements OnGroupClickListener
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onGroupClick(ExpandableListView list, View group, int groupPosition, long id) {
|
public boolean onGroupClick(ExpandableListView list, View group, int groupPosition, long id) {
|
||||||
if (folderAdapter.isGroup(groupPosition)) {
|
if (folderAdapter.isExpandable(groupPosition)) {
|
||||||
if (list.isGroupExpanded(groupPosition)) {
|
if (list.isGroupExpanded(groupPosition)) {
|
||||||
group.findViewById(R.id.row_foldersums).setVisibility(View.VISIBLE);
|
group.findViewById(R.id.row_foldersums).setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
group.findViewById(R.id.row_foldersums).setVisibility(View.INVISIBLE);
|
group.findViewById(R.id.row_foldersums).setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else if (folderAdapter.isBlog(groupPosition)) {
|
|
||||||
Cursor blurblogCursor = folderAdapter.getGroup(groupPosition);
|
|
||||||
String username = blurblogCursor.getString(blurblogCursor.getColumnIndex(DatabaseConstants.SOCIAL_FEED_USERNAME));
|
|
||||||
String userIcon = blurblogCursor.getString(blurblogCursor.getColumnIndex(DatabaseConstants.SOCIAL_FEED_ICON));
|
|
||||||
String userId = blurblogCursor.getString(blurblogCursor.getColumnIndex(DatabaseConstants.SOCIAL_FEED_ID));
|
|
||||||
|
|
||||||
final Intent intent = new Intent(getActivity(), SocialFeedItemsList.class);
|
|
||||||
intent.putExtra(ItemsList.EXTRA_BLURBLOG_USER_ICON, userIcon);
|
|
||||||
intent.putExtra(ItemsList.EXTRA_BLURBLOG_USERNAME, username);
|
|
||||||
intent.putExtra(ItemsList.EXTRA_BLURBLOG_USERID, userId);
|
|
||||||
intent.putExtra(ItemsList.EXTRA_STATE, currentState);
|
|
||||||
getActivity().startActivityForResult(intent, FEEDCHECK );
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
Intent i = new Intent(getActivity(), EverythingItemsList.class);
|
Intent i = new Intent(getActivity(), EverythingItemsList.class);
|
||||||
i.putExtra(EverythingItemsList.EXTRA_STATE, currentState);
|
i.putExtra(EverythingItemsList.EXTRA_STATE, currentState);
|
||||||
|
|
Loading…
Add table
Reference in a new issue