Polished background color of list view, highlight currently selected list

pull/14/head
Sam Bosley 13 years ago
parent 6b9e23436a
commit 790373c3cb

@ -13,6 +13,7 @@
android:layout_height="200dip" android:layout_height="200dip"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:scrollbars="vertical" android:scrollbars="vertical"
android:divider="@android:color/transparent"
android:cacheColorHint="#00000000"/> android:cacheColorHint="#00000000"/>
<!-- Footer --> <!-- Footer -->

@ -37,6 +37,7 @@
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_above="@id/lists_footer" android:layout_above="@id/lists_footer"
android:scrollbars="vertical" android:scrollbars="vertical"
android:divider="@android:color/transparent"
android:cacheColorHint="#00000000"/> android:cacheColorHint="#00000000"/>
</RelativeLayout> </RelativeLayout>

@ -3,7 +3,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:background="@drawable/list_popover_bg"> android:background="@color/tablet_list_bg">
<!-- Footer --> <!-- Footer -->
<LinearLayout <LinearLayout
@ -37,6 +37,7 @@
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_above="@id/lists_footer" android:layout_above="@id/lists_footer"
android:scrollbars="vertical" android:scrollbars="vertical"
android:divider="@android:color/transparent"
android:cacheColorHint="#00000000"/> android:cacheColorHint="#00000000"/>
</RelativeLayout> </RelativeLayout>

@ -8,6 +8,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="67" android:layout_weight="67"
android:background="@android:color/white"
android:id="@+id/filterlist_fragment_container"> android:id="@+id/filterlist_fragment_container">
</FrameLayout> </FrameLayout>
<View <View

@ -13,6 +13,7 @@
android:layout_height="300dip" android:layout_height="300dip"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:scrollbars="vertical" android:scrollbars="vertical"
android:divider="@android:color/transparent"
android:cacheColorHint="#00000000"/> android:cacheColorHint="#00000000"/>
<!-- Footer --> <!-- Footer -->

@ -27,5 +27,9 @@
<color name="task_edit_details">#0b78a5</color> <color name="task_edit_details">#0b78a5</color>
<color name="task_edit_deadline_gray">#888888</color> <color name="task_edit_deadline_gray">#888888</color>
<color name="red_text_color">#d00000</color>
<color name="tablet_list_bg">#292929</color>
<color name="tablet_list_selected">#101010</color>
</resources> </resources>

@ -63,7 +63,7 @@
<item name="abBackground">@android:color/white</item> <item name="abBackground">@android:color/white</item>
<item name="abDisplayOptions">useLogo|showHome|showTitle</item> <item name="abDisplayOptions">useLogo|showHome|showTitle</item>
<item name="abLogo">@drawable/icon_48</item> <item name="abLogo">@drawable/icon_48</item>
<item name="asAbTextColor">#d00000</item> <item name="asAbTextColor">@color/red_text_color</item>
</style> </style>
<style name="Theme.TransparentWhite" parent="@style/Theme.White"> <style name="Theme.TransparentWhite" parent="@style/Theme.White">
@ -75,7 +75,7 @@
<item name="abBackground">@android:color/white</item> <item name="abBackground">@android:color/white</item>
<item name="abDisplayOptions">useLogo|showHome|showTitle</item> <item name="abDisplayOptions">useLogo|showHome|showTitle</item>
<item name="abLogo">@drawable/icon_48</item> <item name="abLogo">@drawable/icon_48</item>
<item name="asAbTextColor">#d00000</item> <item name="asAbTextColor">@color/red_text_color</item>
</style> </style>
<style name="Theme_Dialog" parent="@android:style/Theme.Dialog"> <style name="Theme_Dialog" parent="@android:style/Theme.Dialog">

@ -99,7 +99,9 @@ public class AstridWrapperActivity extends FragmentActivity
if(item instanceof Filter) { if(item instanceof Filter) {
Filter filter = (Filter)item; Filter filter = (Filter)item;
if(filter instanceof FilterWithCustomIntent) { if(filter instanceof FilterWithCustomIntent) {
int lastSelectedList = intent.getIntExtra(FilterListActivity.TOKEN_LAST_SELECTED, 0);
intent = ((FilterWithCustomIntent)filter).getCustomIntent(); intent = ((FilterWithCustomIntent)filter).getCustomIntent();
intent.putExtra(FilterListActivity.TOKEN_LAST_SELECTED, lastSelectedList);
} else { } else {
intent.putExtra(TaskListActivity.TOKEN_FILTER, filter); intent.putExtra(TaskListActivity.TOKEN_FILTER, filter);
} }

@ -69,6 +69,8 @@ public class FilterListActivity extends ListFragment {
public static final String TAG_FILTERLIST_FRAGMENT = "filterlist_fragment"; public static final String TAG_FILTERLIST_FRAGMENT = "filterlist_fragment";
public static final String TOKEN_LAST_SELECTED = "lastSelected";
// -- extra codes // -- extra codes
//public static final String SHOW_BACK_BUTTON = "show_back"; //$NON-NLS-1$ //public static final String SHOW_BACK_BUTTON = "show_back"; //$NON-NLS-1$
@ -92,12 +94,15 @@ public class FilterListActivity extends ListFragment {
@Autowired ExceptionService exceptionService; @Autowired ExceptionService exceptionService;
protected FilterAdapter adapter = null; protected FilterAdapter adapter = null;
private boolean mDualFragments;
private final RefreshReceiver refreshReceiver = new RefreshReceiver(); private final RefreshReceiver refreshReceiver = new RefreshReceiver();
private OnFilterItemClickedListener mListener; private OnFilterItemClickedListener mListener;
private boolean mDualFragments;
private int mSelectedIndex;
/* ====================================================================== /* ======================================================================
* ======================================================= initialization * ======================================================= initialization
* ====================================================================== */ * ====================================================================== */
@ -175,10 +180,11 @@ public class FilterListActivity extends ListFragment {
} }
}); });
onNewIntent(getActivity().getIntent()); AstridWrapperActivity activity = (AstridWrapperActivity) getActivity();
mDualFragments = activity.isMultipleFragments();
Fragment tasklistFrame = getFragmentManager().findFragmentByTag(TaskListActivity.TAG_TASKLIST_FRAGMENT); if (mDualFragments)
mDualFragments = (tasklistFrame != null) && tasklistFrame.isInLayout(); mSelectedIndex = activity.getIntent().getIntExtra(TOKEN_LAST_SELECTED, 0);
onNewIntent(activity.getIntent());
if (mDualFragments) { if (mDualFragments) {
// In dual-pane mode, the list view highlights the selected item. // In dual-pane mode, the list view highlights the selected item.
@ -299,6 +305,8 @@ public class FilterListActivity extends ListFragment {
R.layout.filter_adapter_row, false); R.layout.filter_adapter_row, false);
setListAdapter(adapter); setListAdapter(adapter);
adapter.setLastSelected(mSelectedIndex);
registerForContextMenu(getListView()); registerForContextMenu(getListView());
} }
@ -310,12 +318,12 @@ public class FilterListActivity extends ListFragment {
@Override @Override
public void onListItemClick(ListView parent, View v, int position, long id) { public void onListItemClick(ListView parent, View v, int position, long id) {
// if (mDualFragments) if (mDualFragments)
// { getListView().setItemChecked(position, true);
// setSelectedChild(groupPosition, childPosition, false);
// setItemChecked((int) getSelectedPosition(), true);
// }
Filter item = adapter.getItem(position); Filter item = adapter.getItem(position);
mSelectedIndex = position;
adapter.setLastSelected(mSelectedIndex);
getActivity().getIntent().putExtra(TOKEN_LAST_SELECTED, mSelectedIndex);
mListener.onFilterItemClicked(item); mListener.onFilterItemClicked(item);
} }

@ -4,15 +4,12 @@ import android.os.Bundle;
import android.support.v4.app.ActionBar; import android.support.v4.app.ActionBar;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.PopupWindow.OnDismissListener; import android.widget.PopupWindow.OnDismissListener;
import android.widget.TextView; import android.widget.TextView;
import com.timsu.astrid.R; import com.timsu.astrid.R;
import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.astrid.adapter.FilterAdapter;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.FilterListItem; import com.todoroo.astrid.api.FilterListItem;
import com.todoroo.astrid.service.ThemeService; import com.todoroo.astrid.service.ThemeService;
@ -24,19 +21,8 @@ public class TaskListWrapperActivity extends AstridWrapperActivity {
private View listsNav; private View listsNav;
private TextView lists; private TextView lists;
private FilterAdapter listDropdownAdapter;
private ListDropdownPopover popover; private ListDropdownPopover popover;
private final OnItemClickListener listClickListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Filter item = listDropdownAdapter.getItem(position);
onFilterItemClicked(item);
popover.dismiss();
lists.setText(item.title);
}
};
private final OnClickListener popupMenuClickListener = new OnClickListener() { private final OnClickListener popupMenuClickListener = new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

@ -88,6 +88,8 @@ public class FilterAdapter extends ArrayAdapter<Filter> {
/** whether rows are selectable */ /** whether rows are selectable */
private final boolean selectable; private final boolean selectable;
private int mSelectedIndex;
// Previous solution involved a queue of filters and a filterSizeLoadingThread. The filterSizeLoadingThread had // Previous solution involved a queue of filters and a filterSizeLoadingThread. The filterSizeLoadingThread had
// a few problems: how to make sure that the thread is resumed when the controlling activity is resumed, and // a few problems: how to make sure that the thread is resumed when the controlling activity is resumed, and
// how to make sure that the the filterQueue does not accumulate filters without being processed. I am replacing // how to make sure that the the filterQueue does not accumulate filters without being processed. I am replacing
@ -157,6 +159,10 @@ public class FilterAdapter extends ArrayAdapter<Filter> {
offerFilter(item); offerFilter(item);
} }
public void setLastSelected(int lastSelected) {
mSelectedIndex = lastSelected;
}
/** /**
* Create or reuse a view * Create or reuse a view
@ -200,6 +206,12 @@ public class FilterAdapter extends ArrayAdapter<Filter> {
viewHolder.item = (FilterListItem) getItem(position); viewHolder.item = (FilterListItem) getItem(position);
populateView(viewHolder, false); populateView(viewHolder, false);
if (listView.isItemChecked(position)) {
convertView.setBackgroundColor(activity.getResources().getColor(R.color.tablet_list_selected));
} else {
convertView.setBackgroundColor(activity.getResources().getColor(android.R.color.transparent));
}
return convertView; return convertView;
} }
@ -286,6 +298,10 @@ public class FilterAdapter extends ArrayAdapter<Filter> {
add((Filter) filter); add((Filter) filter);
} }
} }
if (mSelectedIndex < getCount()) {
listView.setItemChecked(mSelectedIndex, true);
}
notifyDataSetChanged(); notifyDataSetChanged();
} }
} }

Loading…
Cancel
Save