2020import android .app .AlertDialog ;
2121import android .content .Context ;
2222import android .content .DialogInterface ;
23+ import android .content .res .TypedArray ;
2324import android .database .Cursor ;
2425import android .database .MergeCursor ;
2526import android .os .AsyncTask ;
6162public class PushContactSelectionListFragment extends SherlockListFragment
6263 implements LoaderManager .LoaderCallbacks <Cursor >
6364{
65+ private final int STYLE_ATTRIBUTES [] = new int []{R .attr .contact_selection_push_user ,
66+ R .attr .contact_selection_lay_user ,
67+ R .attr .contact_selection_push_label ,
68+ R .attr .contact_selection_lay_label };
6469
6570 private final HashMap <Long , ContactData > selectedContacts = new HashMap <Long , ContactData >();
6671 private static LayoutInflater li ;
72+ private TypedArray drawables ;
73+
6774
6875 @ Override
6976 public void onActivityCreated (Bundle icicle ) {
@@ -88,8 +95,12 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
8895 public boolean onOptionsItemSelected (MenuItem item ) {
8996
9097 switch (item .getItemId ()) {
91- case R .id .menu_select_all : handleSelectAll (); return true ;
92- case R .id .menu_unselect_all : handleUnselectAll (); return true ;
98+ case R .id .menu_select_all :
99+ handleSelectAll ();
100+ return true ;
101+ case R .id .menu_unselect_all :
102+ handleUnselectAll ();
103+ return true ;
93104 }
94105
95106 super .onOptionsItemSelected (item );
@@ -105,7 +116,7 @@ public List<ContactData> getSelectedContacts() {
105116
106117 private void handleUnselectAll () {
107118 selectedContacts .clear ();
108- ((CursorAdapter )getListView ().getAdapter ()).notifyDataSetChanged ();
119+ ((CursorAdapter ) getListView ().getAdapter ()).notifyDataSetChanged ();
109120 }
110121
111122 private void handleSelectAll () {
@@ -119,16 +130,16 @@ private void handleSelectAll() {
119130 while (cursor != null && cursor .moveToNext ()) {
120131 ContactData contactData = ContactAccessor .getInstance ().getContactData (getActivity (), cursor );
121132
122- if (contactData .numbers .isEmpty ()) continue ;
133+ if (contactData .numbers .isEmpty ()) continue ;
123134 else if (contactData .numbers .size () == 1 ) addSingleNumberContact (contactData );
124- else addMultipleNumberContact (contactData , null , null );
135+ else addMultipleNumberContact (contactData , null , null );
125136 }
126137 } finally {
127138 if (cursor != null )
128139 cursor .close ();
129140 }
130141
131- ((CursorAdapter )getListView ().getAdapter ()).notifyDataSetChanged ();
142+ ((CursorAdapter ) getListView ().getAdapter ()).notifyDataSetChanged ();
132143 }
133144
134145 private void addSingleNumberContact (ContactData contactData ) {
@@ -162,6 +173,7 @@ private void initializeCursor() {
162173
163174 private void initializeResources () {
164175 this .getListView ().setFocusable (true );
176+ this .drawables = getActivity ().obtainStyledAttributes (STYLE_ATTRIBUTES );
165177 }
166178
167179 @ Override
@@ -244,13 +256,13 @@ public void set(PushContactData pushContactData) {
244256 this .pushSupport = pushContactData .pushSupport ;
245257
246258 if (!pushSupport ) {
247- this .name .setTextColor (0xa0000000 );
248- this .number .setTextColor (0xa0000000 );
249- this .pushLabel .setBackgroundColor (0x99000000 );
259+ this .name .setTextColor (drawables . getColor ( 1 , 0xff000000 ) );
260+ this .number .setTextColor (drawables . getColor ( 1 , 0xff000000 ) );
261+ this .pushLabel .setBackgroundColor (drawables . getColor ( 3 , 0x99000000 ) );
250262 } else {
251- this .name .setTextColor (0xff000000 );
252- this .number .setTextColor (0xff000000 );
253- this .pushLabel .setBackgroundColor (0xff64a926 );
263+ this .name .setTextColor (drawables . getColor ( 0 , 0xa0000000 ) );
264+ this .number .setTextColor (drawables . getColor ( 0 , 0xa0000000 ) );
265+ this .pushLabel .setBackgroundColor (drawables . getColor ( 2 , 0xff64a926 ) );
254266 }
255267
256268 if (selectedContacts .containsKey (contactData .id ))
0 commit comments