mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Fixed selector to include social feeds in intelligence selection.
This commit is contained in:
parent
3699941cc1
commit
097cc0bf8b
17 changed files with 207 additions and 64 deletions
BIN
media/android/NewsBlur/res/drawable-hdpi/indicator_collapsed.png
Normal file
BIN
media/android/NewsBlur/res/drawable-hdpi/indicator_collapsed.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
media/android/NewsBlur/res/drawable-hdpi/indicator_expanded.png
Normal file
BIN
media/android/NewsBlur/res/drawable-hdpi/indicator_expanded.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
media/android/NewsBlur/res/drawable-mdpi/indicator_collapsed.png
Normal file
BIN
media/android/NewsBlur/res/drawable-mdpi/indicator_collapsed.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
media/android/NewsBlur/res/drawable-mdpi/indicator_expanded.png
Normal file
BIN
media/android/NewsBlur/res/drawable-mdpi/indicator_expanded.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
media/android/NewsBlur/res/drawable-xhdpi/indicator_expanded.png
Normal file
BIN
media/android/NewsBlur/res/drawable-xhdpi/indicator_expanded.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<solid android:color="@color/darkgray" />
|
||||
|
||||
<padding
|
||||
android:bottom="1dp"
|
||||
android:left="1dp"
|
||||
android:top="1dp" />
|
||||
|
||||
<corners
|
||||
android:bottomLeftRadius="13dp"
|
||||
android:bottomRightRadius="0dp"
|
||||
android:topLeftRadius="13dp"
|
||||
android:topRightRadius="0dp" />
|
||||
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/lightgray" />
|
||||
|
||||
<solid android:color="@color/darkgray"/>
|
||||
|
||||
<corners
|
||||
android:bottomLeftRadius="12dp"
|
||||
android:bottomRightRadius="0dp"
|
||||
android:topLeftRadius="12dp"
|
||||
android:topRightRadius="0dp" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<solid android:color="@color/darkgray" />
|
||||
|
||||
<padding
|
||||
android:bottom="1dp"
|
||||
android:top="1dp" />
|
||||
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/lightgray" />
|
||||
|
||||
<solid android:color="@color/darkgray"/>
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<solid android:color="@color/darkgray" />
|
||||
|
||||
<padding
|
||||
android:bottom="1dp"
|
||||
android:right="1dp"
|
||||
android:top="1dp" />
|
||||
|
||||
<corners
|
||||
android:bottomLeftRadius="0dp"
|
||||
android:bottomRightRadius="13dp"
|
||||
android:topLeftRadius="0dp"
|
||||
android:topRightRadius="13dp" />
|
||||
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/lightgray" />
|
||||
|
||||
<solid android:color="@color/darkgray" />
|
||||
|
||||
<corners
|
||||
android:bottomLeftRadius="0dp"
|
||||
android:bottomRightRadius="13dp"
|
||||
android:topLeftRadius="0dp"
|
||||
android:topRightRadius="13dp" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
|
@ -8,11 +8,14 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/row_socialfeed_icon"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:contentDescription="@string/description_row_folder_icon" />
|
||||
|
||||
<TextView
|
||||
|
|
38
media/android/NewsBlur/res/layout/state_toggle.xml
Normal file
38
media/android/NewsBlur/res/layout/state_toggle.xml
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/toggle_all"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/button_intelligence_left"
|
||||
android:minHeight="15dp"
|
||||
android:minWidth="80dp"
|
||||
android:text="All"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/toggle_some"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/button_intelligence_middle"
|
||||
android:minHeight="15dp"
|
||||
android:minWidth="80dp"
|
||||
android:text="Some"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/toggle_focus"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/button_intelligence_right"
|
||||
android:minHeight="15dp"
|
||||
android:minWidth="80dp"
|
||||
android:text="Focus"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
|
@ -110,6 +110,10 @@ public class DatabaseConstants {
|
|||
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 SOCIAL_INTELLIGENCE_ALL = " (" + DatabaseConstants.SOCIAL_FEED_NEGATIVE_COUNT + " + " + DatabaseConstants.SOCIAL_FEED_NEUTRAL_COUNT + " + " + DatabaseConstants.SOCIAL_FEED_POSITIVE_COUNT + ") > 0 ";
|
||||
public static final String SOCIAL_INTELLIGENCE_SOME = " (" + DatabaseConstants.SOCIAL_FEED_NEUTRAL_COUNT + " + " + DatabaseConstants.SOCIAL_FEED_POSITIVE_COUNT + ") > 0 ";
|
||||
public static final String SOCIAL_INTELLIGENCE_BEST = " (" + DatabaseConstants.SOCIAL_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 " +
|
||||
"AND " + DatabaseConstants.STORY_READ + " = '0'";
|
||||
|
|
|
@ -246,7 +246,7 @@ public class FeedProvider extends ContentProvider {
|
|||
case OFFLINE_UPDATES:
|
||||
return db.query(DatabaseConstants.UPDATE_TABLE, null, null, null, null, null, null);
|
||||
case ALL_SOCIAL_FEEDS:
|
||||
return db.query(DatabaseConstants.SOCIAL_FEED_TABLE, null, null, null, null, null, null);
|
||||
return db.query(DatabaseConstants.SOCIAL_FEED_TABLE, null, selection, null, null, null, null);
|
||||
default:
|
||||
throw new UnsupportedOperationException("Unknown URI: " + uri);
|
||||
}
|
||||
|
|
|
@ -48,9 +48,6 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
|
|||
|
||||
public String currentState = DatabaseConstants.FOLDER_INTELLIGENCE_ALL;
|
||||
|
||||
int itemCount = 1;
|
||||
|
||||
|
||||
public MixedExpandableListAdapter(final Context context, final Cursor folderCursor, final Cursor blogCursor, final int collapsedGroupLayout,
|
||||
int expandedGroupLayout, int blogGroupLayout, String[] groupFrom, int[] groupTo, int childLayout, String[] childFrom, int[] childTo, String[] blogFrom, int[] blogTo) {
|
||||
this.context = context;
|
||||
|
@ -170,8 +167,11 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
|
|||
|
||||
@Override
|
||||
public int getChildrenCount(int groupPosition) {
|
||||
groupPosition = groupPosition - blogCursorHelper.getCount() + 1;
|
||||
if (groupPosition < blogCursorHelper.getCount() - 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
groupPosition = groupPosition - blogCursorHelper.getCount() + 1;
|
||||
MyCursorHelper helper = getChildrenCursorHelper(groupPosition, true);
|
||||
return (folderCursorHelper.isValid() && helper != null) ? helper.getCount() : 0;
|
||||
}
|
||||
|
@ -199,6 +199,10 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
|
|||
folderCursorHelper.changeCursor(cursor, false);
|
||||
}
|
||||
|
||||
public void setBlogCursor(Cursor blogCursor) {
|
||||
blogCursorHelper.changeCursor(blogCursor, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
|
||||
Cursor cursor;
|
||||
|
@ -331,6 +335,7 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
|
|||
|
||||
public void requery() {
|
||||
folderCursorHelper.getCursor().requery();
|
||||
blogCursorHelper.getCursor().requery();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -79,6 +79,7 @@ public class FolderFeedListFragment extends Fragment implements OnGroupClickList
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.fragment_folderfeedlist, container);
|
||||
list = (ExpandableListView) v.findViewById(R.id.folderfeed_list);
|
||||
list.setGroupIndicator(getResources().getDrawable(R.drawable.selector_group_indicator));
|
||||
list.setOnCreateContextMenuListener(this);
|
||||
|
||||
Display display = getActivity().getWindowManager().getDefaultDisplay();
|
||||
|
@ -134,27 +135,33 @@ public class FolderFeedListFragment extends Fragment implements OnGroupClickList
|
|||
}
|
||||
|
||||
public void changeState(int state) {
|
||||
String selection = null;
|
||||
String groupSelection = null, blogSelection = null;
|
||||
groupViewBinder.setState(state);
|
||||
blogViewBinder.setState(state);
|
||||
currentState = state;
|
||||
|
||||
switch (state) {
|
||||
case (AppConstants.STATE_ALL):
|
||||
selection = DatabaseConstants.FOLDER_INTELLIGENCE_ALL;
|
||||
groupSelection = DatabaseConstants.FOLDER_INTELLIGENCE_ALL;
|
||||
blogSelection = DatabaseConstants.SOCIAL_INTELLIGENCE_ALL;
|
||||
break;
|
||||
case (AppConstants.STATE_SOME):
|
||||
selection = DatabaseConstants.FOLDER_INTELLIGENCE_SOME;
|
||||
groupSelection = DatabaseConstants.FOLDER_INTELLIGENCE_SOME;
|
||||
blogSelection = DatabaseConstants.SOCIAL_INTELLIGENCE_SOME;
|
||||
break;
|
||||
case (AppConstants.STATE_BEST):
|
||||
selection = DatabaseConstants.FOLDER_INTELLIGENCE_BEST;
|
||||
groupSelection = DatabaseConstants.FOLDER_INTELLIGENCE_BEST;
|
||||
blogSelection = DatabaseConstants.SOCIAL_INTELLIGENCE_BEST;
|
||||
break;
|
||||
}
|
||||
|
||||
folderAdapter.currentState = selection;
|
||||
Cursor cursor = resolver.query(FeedProvider.FOLDERS_URI, null, null, new String[] { selection }, null);
|
||||
folderAdapter.currentState = groupSelection;
|
||||
Cursor cursor = resolver.query(FeedProvider.FOLDERS_URI, null, null, new String[] { groupSelection }, null);
|
||||
Cursor blogCursor = resolver.query(FeedProvider.SOCIAL_FEEDS_URI, null, blogSelection, null, null);
|
||||
|
||||
folderAdapter.setBlogCursor(blogCursor);
|
||||
folderAdapter.setGroupCursor(cursor);
|
||||
folderAdapter.notifyDataSetChanged();
|
||||
folderAdapter.notifyDataSetInvalidated();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,7 +30,7 @@ public class UIUtils {
|
|||
Canvas canvas = new Canvas(clipped);
|
||||
canvas.drawRoundRect(new RectF(0, 0, width, height), radius, radius, paint);
|
||||
paint.setXfermode(new PorterDuffXfermode(DST_IN));
|
||||
|
||||
|
||||
Bitmap rounded = Bitmap.createBitmap(width, height, ARGB_8888);
|
||||
canvas = new Canvas(rounded);
|
||||
canvas.drawBitmap(source, 0, 0, null);
|
||||
|
|
|
@ -2,14 +2,14 @@ package com.newsblur.view;
|
|||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.util.AppConstants;
|
||||
import com.newsblur.util.UIUtils;
|
||||
|
||||
public class StateToggleButton extends LinearLayout implements OnClickListener {
|
||||
|
||||
|
@ -17,9 +17,16 @@ public class StateToggleButton extends LinearLayout implements OnClickListener {
|
|||
|
||||
private Context context;
|
||||
private StateChangedListener stateChangedListener;
|
||||
private ImageView imageStateOne;
|
||||
private ImageView imageStateTwo;
|
||||
private ImageView imageStateThree;
|
||||
|
||||
private LayoutInflater inflater;
|
||||
|
||||
private View view;
|
||||
|
||||
private Button allButton;
|
||||
|
||||
private Button someButton;
|
||||
|
||||
private Button focusButton;
|
||||
|
||||
public StateToggleButton(Context context, AttributeSet art) {
|
||||
super(context, art);
|
||||
|
@ -32,35 +39,15 @@ public class StateToggleButton extends LinearLayout implements OnClickListener {
|
|||
}
|
||||
|
||||
public void setupContents() {
|
||||
final int length = UIUtils.convertDPsToPixels(context, 25);
|
||||
final int marginSide = UIUtils.convertDPsToPixels(context, 35);
|
||||
final int marginTop = UIUtils.convertDPsToPixels(context, 5);
|
||||
|
||||
imageStateOne = new ImageView(context);
|
||||
imageStateOne.setId(AppConstants.STATE_ALL);
|
||||
imageStateOne.setImageResource(R.drawable.negative_count_rect);
|
||||
imageStateOne.setLayoutParams(new LayoutParams(length, length));
|
||||
|
||||
LayoutParams centerParams = new LayoutParams(length, length);
|
||||
centerParams.setMargins(marginSide, marginTop, marginSide, marginTop);
|
||||
imageStateTwo = new ImageView(context);
|
||||
imageStateTwo.setId(AppConstants.STATE_SOME);
|
||||
imageStateTwo.setImageResource(R.drawable.neutral_count_rect);
|
||||
imageStateTwo.setLayoutParams(centerParams);
|
||||
|
||||
imageStateThree = new ImageView(context);
|
||||
imageStateThree.setId(AppConstants.STATE_BEST);
|
||||
imageStateThree.setImageResource(R.drawable.positive_count_rect);
|
||||
imageStateThree.setLayoutParams(new LayoutParams(length, length));
|
||||
|
||||
imageStateOne.setOnClickListener(this);
|
||||
imageStateTwo.setOnClickListener(this);
|
||||
imageStateThree.setOnClickListener(this);
|
||||
|
||||
this.addView(imageStateOne);
|
||||
this.addView(imageStateTwo);
|
||||
this.addView(imageStateThree);
|
||||
|
||||
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = inflater.inflate(R.layout.state_toggle, this);
|
||||
allButton = (Button) view.findViewById(R.id.toggle_all);
|
||||
someButton = (Button) view.findViewById(R.id.toggle_some);
|
||||
focusButton = (Button) view.findViewById(R.id.toggle_focus);
|
||||
allButton.setOnClickListener(this);
|
||||
someButton.setOnClickListener(this);
|
||||
focusButton.setOnClickListener(this);
|
||||
|
||||
setState(CURRENT_STATE);
|
||||
}
|
||||
|
||||
|
@ -78,24 +65,25 @@ public class StateToggleButton extends LinearLayout implements OnClickListener {
|
|||
|
||||
public void setState(final int state) {
|
||||
switch (state) {
|
||||
case AppConstants.STATE_ALL:
|
||||
imageStateOne.setAlpha(255);
|
||||
imageStateTwo.setAlpha(125);
|
||||
imageStateThree.setAlpha(125);
|
||||
case R.id.toggle_all:
|
||||
allButton.setEnabled(false);
|
||||
someButton.setEnabled(true);
|
||||
focusButton.setEnabled(true);
|
||||
CURRENT_STATE = AppConstants.STATE_ALL;
|
||||
break;
|
||||
case AppConstants.STATE_SOME:
|
||||
imageStateOne.setAlpha(125);
|
||||
imageStateTwo.setAlpha(255);
|
||||
imageStateThree.setAlpha(125);
|
||||
case R.id.toggle_some:
|
||||
allButton.setEnabled(true);
|
||||
someButton.setEnabled(false);
|
||||
focusButton.setEnabled(true);
|
||||
CURRENT_STATE = AppConstants.STATE_SOME;
|
||||
break;
|
||||
case AppConstants.STATE_BEST:
|
||||
imageStateOne.setAlpha(125);
|
||||
imageStateTwo.setAlpha(125);
|
||||
imageStateThree.setAlpha(255);
|
||||
case R.id.toggle_focus:
|
||||
allButton.setEnabled(true);
|
||||
someButton.setEnabled(true);
|
||||
focusButton.setEnabled(false);
|
||||
CURRENT_STATE = AppConstants.STATE_BEST;
|
||||
break;
|
||||
}
|
||||
|
||||
CURRENT_STATE = state;
|
||||
}
|
||||
|
||||
public interface StateChangedListener {
|
||||
|
|
Loading…
Add table
Reference in a new issue