Loading res/values/strings.xml +1 −1 Original line number Diff line number Diff line Loading @@ -841,7 +841,7 @@ <string name="title_about_name">Mod Name</string> <string name="summary_about_name">Wysie Contacts</string> <string name="title_about_version">Version</string> <string name="summary_about_version">2.51</string> <string name="summary_about_version">2.52 BETA</string> <string name="title_about_credits">Credits</string> <string name="summary_about_credits">ChainsDD and the rest of XDA! :)</string> Loading src/com/android/contacts/CallDetailActivity.java +158 −82 Original line number Diff line number Diff line Loading @@ -63,6 +63,8 @@ import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; import java.util.ArrayList; import java.util.Comparator; import java.util.Collections; import java.util.List; /** Loading Loading @@ -189,10 +191,32 @@ public class CallDetailActivity extends ListActivity implements View.OnCreateCon class ViewEntryData{ public long id; public String number; public String label; public long date; public long duration; public int callType; } //Class used to sort class NumberInfo { public String number; public String label; NumberInfo(String n, String l) { number = n; label = l; } } class LogsSortByTime implements Comparator<ViewEntryData>{ public int compare(ViewEntryData v1, ViewEntryData v2) { Long l1 = v1.date; Long l2 = v2.date; return l2.compareTo(l1); } } /** * Update user interface with details of given call. * Loading @@ -200,17 +224,81 @@ public class CallDetailActivity extends ListActivity implements View.OnCreateCon */ private void updateData() { Bundle bundle = getIntent().getExtras(); String number = bundle.getString("NUMBER"); //Toast.makeText(this, number, Toast.LENGTH_LONG).show(); long personId = bundle.getLong("PERSONID"); ArrayList<NumberInfo> personNumbers = new ArrayList<NumberInfo>(); String displayName = null; Uri personUri = null; Uri callUri = null; Cursor callCursor = null; logs = new ArrayList<ViewEntryData>(); //Wysie_Soh: If the personId is valid if (personId != -1) { personUri = ContentUris.withAppendedId(People.CONTENT_URI, personId); Uri phonesUri = Uri.withAppendedPath(personUri, People.Phones.CONTENT_DIRECTORY); final Cursor phonesCursor = getContentResolver().query(phonesUri, PHONES_PROJECTION, null, null, null); Uri callUri = Uri.withAppendedPath(Calls.CONTENT_FILTER_URI, Uri.encode(number)); Cursor callCursor = getContentResolver().query(callUri, CALL_LOG_PROJECTION, null, null, Calls.DEFAULT_SORT_ORDER); if (phonesCursor != null && phonesCursor.moveToFirst()) { int type = -1; String number = null; String label = null; CharSequence actualLabel = null; do { if (displayName == null) displayName = phonesCursor.getString(COLUMN_INDEX_NAME); type = phonesCursor.getInt(COLUMN_INDEX_TYPE); number = phonesCursor.getString(COLUMN_INDEX_NUMBER); label = phonesCursor.getString(COLUMN_INDEX_LABEL); actualLabel = Phones.getDisplayLabel(this, type, label); personNumbers.add(new NumberInfo(number, actualLabel.toString())); } while (phonesCursor.moveToNext()); phonesCursor.close(); } boolean hasCallLog = false; for (NumberInfo i : personNumbers) { callUri = Uri.withAppendedPath(Calls.CONTENT_FILTER_URI, Uri.encode(i.number)); callCursor = getContentResolver().query(callUri, CALL_LOG_PROJECTION, null, null, null); try { if (callCursor != null && callCursor.moveToFirst()) { hasCallLog = true; do { ViewEntryData data = new ViewEntryData(); data.label = i.label; data.id = callCursor.getLong(LOG_COLUMN_INDEX); data.date = callCursor.getLong(DATE_COLUMN_INDEX); data.duration = callCursor.getLong(DURATION_COLUMN_INDEX); data.callType = callCursor.getInt(CALL_TYPE_COLUMN_INDEX); data.number = callCursor.getString(NUMBER_COLUMN_INDEX); logs.add(data); } while(callCursor.moveToNext()); } } finally { if (callCursor != null) callCursor.close(); } } //Wysie_Soh: No call log found for this personId if (!hasCallLog) { Toast.makeText(this, R.string.toast_call_detail_error_wysie, Toast.LENGTH_SHORT).show(); finish(); } } //Wysie_Soh: If no person found, query by number instead else { String number = bundle.getString("NUMBER"); callUri = Uri.withAppendedPath(Calls.CONTENT_FILTER_URI, Uri.encode(number)); callCursor = getContentResolver().query(callUri, CALL_LOG_PROJECTION, null, null, null); //Wysie_Soh: Loop to find shortest number, and requery. //Wysie_Soh: Loop to find shortest number. //For some reason, eg. if you have 91234567 and +6591234567 and say, 010891234567 //they might not be detected as the same number. This is especially. //Might change to binary search in future. try { if (callCursor != null && callCursor.moveToFirst()) { do { if (number.length() > callCursor.getString(NUMBER_COLUMN_INDEX).length()) { Loading @@ -218,14 +306,48 @@ public class CallDetailActivity extends ListActivity implements View.OnCreateCon } } while(callCursor.moveToNext()); } } finally { if (callCursor != null) callCursor.close(); } //Wysie_Soh:Requery with shortest number found. This will ensure we get all entries. callUri = Uri.withAppendedPath(Calls.CONTENT_FILTER_URI, Uri.encode(number)); callCursor = getContentResolver().query(callUri, CALL_LOG_PROJECTION, null, null, Calls.DEFAULT_SORT_ORDER); mNumber = number; callCursor = getContentResolver().query(callUri, CALL_LOG_PROJECTION, null, null, Calls.DEFAULT_SORT_ORDER); try { if (callCursor != null && callCursor.moveToFirst()) { do { ViewEntryData data = new ViewEntryData(); // Read call log specifics data.id = callCursor.getLong(LOG_COLUMN_INDEX); data.date = callCursor.getLong(DATE_COLUMN_INDEX); data.duration = callCursor.getLong(DURATION_COLUMN_INDEX); data.callType = callCursor.getInt(CALL_TYPE_COLUMN_INDEX); data.number = callCursor.getString(NUMBER_COLUMN_INDEX); ContentResolver resolver = getContentResolver(); logs.add(data); } while(callCursor.moveToNext()); } else { // Something went wrong reading in our primary data, so we're going to // bail out and show error to users. Toast.makeText(this, R.string.toast_call_detail_error_wysie, Toast.LENGTH_SHORT).show(); finish(); } } finally { if (callCursor != null) callCursor.close(); } } //Sort arraylist here Collections.sort(logs ,new LogsSortByTime()); mNumber = logs.get(0).number; ViewEntryData firstPlaceHolder = new ViewEntryData(); firstPlaceHolder.number = mNumber; logs.add(0, firstPlaceHolder); TextView tvName = (TextView) findViewById(R.id.name); TextView tvNumber = (TextView) findViewById(R.id.number); Loading @@ -240,68 +362,22 @@ public class CallDetailActivity extends ListActivity implements View.OnCreateCon } mPhotoView.setImageResource(mNoPhotoResource); } else { // Perform a reverse-phonebook lookup to find the PERSON_ID String callLabel = null; Uri phoneUri = Uri.withAppendedPath(Phones.CONTENT_FILTER_URL, Uri.encode(mNumber)); Cursor phonesCursor = resolver.query(phoneUri, PHONES_PROJECTION, null, null, null); try { if (phonesCursor != null && phonesCursor.moveToFirst()) { long personId = phonesCursor.getLong(COLUMN_INDEX_ID); personUri = ContentUris.withAppendedId( Contacts.People.CONTENT_URI, personId); // Load the photo mPhotoView.setImageBitmap(People.loadContactPhoto(this, personUri, mNoPhotoResource, null /* use the default options */)); tvName.setText(phonesCursor.getString(COLUMN_INDEX_NAME)); if (personId != -1) { mPhotoView.setImageBitmap(People.loadContactPhoto(this, personUri, mNoPhotoResource, null /* use the default options */)); tvName.setText(displayName); tvNumber.setText(mNumber); } else { } else { tvName.setText("("+ getString(R.string.unknown) + ")"); tvNumber.setText(mNumber);// = PhoneNumberUtils.formatNumber(mNumber); //tvNumber.setVisibility(View.GONE); mPhotoView.setImageResource(mNoPhotoResource); } } finally { if (phonesCursor != null) phonesCursor.close(); } } int size = Integer.parseInt(prefs.getString("cl_view_contact_pic_size", "78")); //Wysie_Soh: Set contact picture size mPhotoView.setLayoutParams(new LinearLayout.LayoutParams(size, size)); logs = new ArrayList<ViewEntryData>(); ViewEntryData firstPlaceHolder = new ViewEntryData(); firstPlaceHolder.number = mNumber; logs.add(firstPlaceHolder); try { if (callCursor != null && callCursor.moveToFirst()) { do { ViewEntryData data = new ViewEntryData(); // Read call log specifics data.id = callCursor.getLong(LOG_COLUMN_INDEX); data.date = callCursor.getLong(DATE_COLUMN_INDEX); data.duration = callCursor.getLong(DURATION_COLUMN_INDEX); data.callType = callCursor.getInt(CALL_TYPE_COLUMN_INDEX); data.number = callCursor.getString(NUMBER_COLUMN_INDEX); logs.add(data); }while(callCursor.moveToNext()); } else { // Something went wrong reading in our primary data, so we're going to // bail out and show error to users. Toast.makeText(this, R.string.toast_call_detail_error_wysie, Toast.LENGTH_SHORT).show(); finish(); } } finally { if (callCursor != null) { callCursor.close(); } } adapter = new ViewAdapter(this, logs); setListAdapter(adapter); } Loading src/com/android/contacts/RecentCallsListActivity.java +13 −40 Original line number Diff line number Diff line Loading @@ -197,7 +197,7 @@ public class RecentCallsListActivity extends ListActivity public long date; public int duration; public int count; public int personId; public long personId; RecentCallsInfo() { count = 1; } Loading Loading @@ -721,21 +721,11 @@ public class RecentCallsListActivity extends ListActivity // Set the photo, if requested if (prefs.getBoolean("cl_show_pic", true)) { Cursor phonesCursor = RecentCallsListActivity.this.getContentResolver().query( Uri.withAppendedPath(Phones.CONTENT_FILTER_URL, Uri.encode(number)), PHONES_PROJECTION, null, null, null); int personId = -1; if (phonesCursor != null) { if (phonesCursor.moveToFirst()) { personId = phonesCursor.getInt(PERSON_ID_COLUMN_INDEX); } phonesCursor.close(); } long personId = callsinfo.personId; Bitmap photo = null; SoftReference<Bitmap> ref = mBitmapCache.get(personId); SoftReference<Bitmap> ref = mBitmapCache.get((int)personId); if (ref != null) { photo = ref.get(); } Loading @@ -745,7 +735,7 @@ public class RecentCallsListActivity extends ListActivity //int id = c.getInt(ID_COLUMN_INDEX); Uri uri = ContentUris.withAppendedId(People.CONTENT_URI, personId); photo = People.loadContactPhoto(context, uri, R.drawable.ic_contact_list_picture, null); mBitmapCache.put(personId, new SoftReference<Bitmap>(photo)); mBitmapCache.put((int)personId, new SoftReference<Bitmap>(photo)); } catch (OutOfMemoryError e) { // Not enough memory for the photo, use the default one instead photo = null; Loading @@ -768,17 +758,6 @@ public class RecentCallsListActivity extends ListActivity } } /* @Override public void changeCursor(Cursor cursor) { super.changeCursor(cursor); // Clear the photo bitmap cache, if there is one if (mBitmapCache != null) { mBitmapCache.clear(); } } */ } Loading Loading @@ -840,18 +819,10 @@ public class RecentCallsListActivity extends ListActivity } public void addItemIntoList(RecentCallsInfo item) { /* if(item.number.startsWith(mIpPrefix)) item.number = item.number.substring(mIpPrefix.length()); String chinaNum = "+86"; if(item.number.startsWith(chinaNum)) item.number = item.number.substring(chinaNum.length()); */ for (int i = 0; i < mListCallLogs.size(); i++) { if (PhoneNumberUtils.compare(mListCallLogs.get(i).number, item.number) || (mListCallLogs.get(i).personId == item.personId && item.personId != -1) || if ((mListCallLogs.get(i).personId == item.personId && item.personId != -1) || PhoneNumberUtils.compare(mListCallLogs.get(i).number, item.number) || sloppyPhoneNumComparator(mListCallLogs.get(i).number, item.number)) { if (mListCallLogs.get(i).name == null && item.name != null) { mListCallLogs.get(i).name = item.name; Loading Loading @@ -923,7 +894,7 @@ public class RecentCallsListActivity extends ListActivity if (phonesCursor != null) { if (phonesCursor.moveToFirst()) { item.personId = phonesCursor.getInt(PERSON_ID_COLUMN_INDEX); item.personId = phonesCursor.getLong(PERSON_ID_COLUMN_INDEX); } phonesCursor.close(); } Loading Loading @@ -1160,10 +1131,12 @@ public class RecentCallsListActivity extends ListActivity } // menu.add(0, MENU_ITEM_DELETE, 0, R.string.recentCalls_removeFromRecentList); menu.add(0, MENU_ITEM_DELETE_ALL_NUMBER, 0, getString(R.string.menu_cl_clear_type, number)); if (contactInfoPresent) { menu.add(0, MENU_ITEM_DELETE_ALL_NAME, 0, getString(R.string.menu_cl_clear_type, info.name)); } else { menu.add(0, MENU_ITEM_DELETE_ALL_NUMBER, 0, getString(R.string.menu_cl_clear_type, number)); } } @Override Loading Loading @@ -1443,7 +1416,7 @@ public class RecentCallsListActivity extends ListActivity Intent intent = new Intent(this, CallDetailActivity.class); // intent.setData(ContentUris.withAppendedId(CallLog.Calls.CONTENT_URI, id)); intent.putExtra("PERSONID", mListCallLogs.get(position).personId); intent.putExtra("NUMBER", mListCallLogs.get(position).number); startActivity(intent); } Loading src/com/android/contacts/ViewContactActivity.java +6 −13 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.contacts; import static com.android.contacts.ContactEntryAdapter.CONTACT_CUSTOM_RINGTONE_COLUMN; import static com.android.contacts.ContactEntryAdapter.CONTACT_ID_COLUMN; import static com.android.contacts.ContactEntryAdapter.CONTACT_NAME_COLUMN; import static com.android.contacts.ContactEntryAdapter.CONTACT_NOTES_COLUMN; import static com.android.contacts.ContactEntryAdapter.CONTACT_PHONETIC_NAME_COLUMN; Loading Loading @@ -152,6 +153,7 @@ public class ViewContactActivity extends ListActivity private ContentResolver mResolver; private ViewAdapter mAdapter; private int mNumPhoneNumbers = 0; private long contactId = -1; /* package */ ArrayList<ViewEntry> mPhoneEntries = new ArrayList<ViewEntry>(); /* package */ ArrayList<ViewEntry> mSmsEntries = new ArrayList<ViewEntry>(); Loading Loading @@ -352,6 +354,7 @@ public class ViewContactActivity extends ListActivity if (mCursor.moveToFirst()) { // Set the name String name = mCursor.getString(CONTACT_NAME_COLUMN); contactId = mCursor.getLong(CONTACT_ID_COLUMN); if (TextUtils.isEmpty(name)) { mNameView.setText(getText(android.R.string.unknownName)); } else { Loading Loading @@ -545,19 +548,9 @@ public class ViewContactActivity extends ListActivity } case MENU_ITEM_SHOW_CALL_LOG: { final CharSequence[] items = (CharSequence[])phoneNumbersArray.toArray(new CharSequence[0]); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.view_contact_select_cl_number)); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Intent intent = new Intent(_context, CallDetailActivity.class); intent.putExtra("NUMBER", items[item]); intent.putExtra("PERSONID", contactId); startActivity(intent); } }); builder.show(); return true; } Loading Loading
res/values/strings.xml +1 −1 Original line number Diff line number Diff line Loading @@ -841,7 +841,7 @@ <string name="title_about_name">Mod Name</string> <string name="summary_about_name">Wysie Contacts</string> <string name="title_about_version">Version</string> <string name="summary_about_version">2.51</string> <string name="summary_about_version">2.52 BETA</string> <string name="title_about_credits">Credits</string> <string name="summary_about_credits">ChainsDD and the rest of XDA! :)</string> Loading
src/com/android/contacts/CallDetailActivity.java +158 −82 Original line number Diff line number Diff line Loading @@ -63,6 +63,8 @@ import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; import java.util.ArrayList; import java.util.Comparator; import java.util.Collections; import java.util.List; /** Loading Loading @@ -189,10 +191,32 @@ public class CallDetailActivity extends ListActivity implements View.OnCreateCon class ViewEntryData{ public long id; public String number; public String label; public long date; public long duration; public int callType; } //Class used to sort class NumberInfo { public String number; public String label; NumberInfo(String n, String l) { number = n; label = l; } } class LogsSortByTime implements Comparator<ViewEntryData>{ public int compare(ViewEntryData v1, ViewEntryData v2) { Long l1 = v1.date; Long l2 = v2.date; return l2.compareTo(l1); } } /** * Update user interface with details of given call. * Loading @@ -200,17 +224,81 @@ public class CallDetailActivity extends ListActivity implements View.OnCreateCon */ private void updateData() { Bundle bundle = getIntent().getExtras(); String number = bundle.getString("NUMBER"); //Toast.makeText(this, number, Toast.LENGTH_LONG).show(); long personId = bundle.getLong("PERSONID"); ArrayList<NumberInfo> personNumbers = new ArrayList<NumberInfo>(); String displayName = null; Uri personUri = null; Uri callUri = null; Cursor callCursor = null; logs = new ArrayList<ViewEntryData>(); //Wysie_Soh: If the personId is valid if (personId != -1) { personUri = ContentUris.withAppendedId(People.CONTENT_URI, personId); Uri phonesUri = Uri.withAppendedPath(personUri, People.Phones.CONTENT_DIRECTORY); final Cursor phonesCursor = getContentResolver().query(phonesUri, PHONES_PROJECTION, null, null, null); Uri callUri = Uri.withAppendedPath(Calls.CONTENT_FILTER_URI, Uri.encode(number)); Cursor callCursor = getContentResolver().query(callUri, CALL_LOG_PROJECTION, null, null, Calls.DEFAULT_SORT_ORDER); if (phonesCursor != null && phonesCursor.moveToFirst()) { int type = -1; String number = null; String label = null; CharSequence actualLabel = null; do { if (displayName == null) displayName = phonesCursor.getString(COLUMN_INDEX_NAME); type = phonesCursor.getInt(COLUMN_INDEX_TYPE); number = phonesCursor.getString(COLUMN_INDEX_NUMBER); label = phonesCursor.getString(COLUMN_INDEX_LABEL); actualLabel = Phones.getDisplayLabel(this, type, label); personNumbers.add(new NumberInfo(number, actualLabel.toString())); } while (phonesCursor.moveToNext()); phonesCursor.close(); } boolean hasCallLog = false; for (NumberInfo i : personNumbers) { callUri = Uri.withAppendedPath(Calls.CONTENT_FILTER_URI, Uri.encode(i.number)); callCursor = getContentResolver().query(callUri, CALL_LOG_PROJECTION, null, null, null); try { if (callCursor != null && callCursor.moveToFirst()) { hasCallLog = true; do { ViewEntryData data = new ViewEntryData(); data.label = i.label; data.id = callCursor.getLong(LOG_COLUMN_INDEX); data.date = callCursor.getLong(DATE_COLUMN_INDEX); data.duration = callCursor.getLong(DURATION_COLUMN_INDEX); data.callType = callCursor.getInt(CALL_TYPE_COLUMN_INDEX); data.number = callCursor.getString(NUMBER_COLUMN_INDEX); logs.add(data); } while(callCursor.moveToNext()); } } finally { if (callCursor != null) callCursor.close(); } } //Wysie_Soh: No call log found for this personId if (!hasCallLog) { Toast.makeText(this, R.string.toast_call_detail_error_wysie, Toast.LENGTH_SHORT).show(); finish(); } } //Wysie_Soh: If no person found, query by number instead else { String number = bundle.getString("NUMBER"); callUri = Uri.withAppendedPath(Calls.CONTENT_FILTER_URI, Uri.encode(number)); callCursor = getContentResolver().query(callUri, CALL_LOG_PROJECTION, null, null, null); //Wysie_Soh: Loop to find shortest number, and requery. //Wysie_Soh: Loop to find shortest number. //For some reason, eg. if you have 91234567 and +6591234567 and say, 010891234567 //they might not be detected as the same number. This is especially. //Might change to binary search in future. try { if (callCursor != null && callCursor.moveToFirst()) { do { if (number.length() > callCursor.getString(NUMBER_COLUMN_INDEX).length()) { Loading @@ -218,14 +306,48 @@ public class CallDetailActivity extends ListActivity implements View.OnCreateCon } } while(callCursor.moveToNext()); } } finally { if (callCursor != null) callCursor.close(); } //Wysie_Soh:Requery with shortest number found. This will ensure we get all entries. callUri = Uri.withAppendedPath(Calls.CONTENT_FILTER_URI, Uri.encode(number)); callCursor = getContentResolver().query(callUri, CALL_LOG_PROJECTION, null, null, Calls.DEFAULT_SORT_ORDER); mNumber = number; callCursor = getContentResolver().query(callUri, CALL_LOG_PROJECTION, null, null, Calls.DEFAULT_SORT_ORDER); try { if (callCursor != null && callCursor.moveToFirst()) { do { ViewEntryData data = new ViewEntryData(); // Read call log specifics data.id = callCursor.getLong(LOG_COLUMN_INDEX); data.date = callCursor.getLong(DATE_COLUMN_INDEX); data.duration = callCursor.getLong(DURATION_COLUMN_INDEX); data.callType = callCursor.getInt(CALL_TYPE_COLUMN_INDEX); data.number = callCursor.getString(NUMBER_COLUMN_INDEX); ContentResolver resolver = getContentResolver(); logs.add(data); } while(callCursor.moveToNext()); } else { // Something went wrong reading in our primary data, so we're going to // bail out and show error to users. Toast.makeText(this, R.string.toast_call_detail_error_wysie, Toast.LENGTH_SHORT).show(); finish(); } } finally { if (callCursor != null) callCursor.close(); } } //Sort arraylist here Collections.sort(logs ,new LogsSortByTime()); mNumber = logs.get(0).number; ViewEntryData firstPlaceHolder = new ViewEntryData(); firstPlaceHolder.number = mNumber; logs.add(0, firstPlaceHolder); TextView tvName = (TextView) findViewById(R.id.name); TextView tvNumber = (TextView) findViewById(R.id.number); Loading @@ -240,68 +362,22 @@ public class CallDetailActivity extends ListActivity implements View.OnCreateCon } mPhotoView.setImageResource(mNoPhotoResource); } else { // Perform a reverse-phonebook lookup to find the PERSON_ID String callLabel = null; Uri phoneUri = Uri.withAppendedPath(Phones.CONTENT_FILTER_URL, Uri.encode(mNumber)); Cursor phonesCursor = resolver.query(phoneUri, PHONES_PROJECTION, null, null, null); try { if (phonesCursor != null && phonesCursor.moveToFirst()) { long personId = phonesCursor.getLong(COLUMN_INDEX_ID); personUri = ContentUris.withAppendedId( Contacts.People.CONTENT_URI, personId); // Load the photo mPhotoView.setImageBitmap(People.loadContactPhoto(this, personUri, mNoPhotoResource, null /* use the default options */)); tvName.setText(phonesCursor.getString(COLUMN_INDEX_NAME)); if (personId != -1) { mPhotoView.setImageBitmap(People.loadContactPhoto(this, personUri, mNoPhotoResource, null /* use the default options */)); tvName.setText(displayName); tvNumber.setText(mNumber); } else { } else { tvName.setText("("+ getString(R.string.unknown) + ")"); tvNumber.setText(mNumber);// = PhoneNumberUtils.formatNumber(mNumber); //tvNumber.setVisibility(View.GONE); mPhotoView.setImageResource(mNoPhotoResource); } } finally { if (phonesCursor != null) phonesCursor.close(); } } int size = Integer.parseInt(prefs.getString("cl_view_contact_pic_size", "78")); //Wysie_Soh: Set contact picture size mPhotoView.setLayoutParams(new LinearLayout.LayoutParams(size, size)); logs = new ArrayList<ViewEntryData>(); ViewEntryData firstPlaceHolder = new ViewEntryData(); firstPlaceHolder.number = mNumber; logs.add(firstPlaceHolder); try { if (callCursor != null && callCursor.moveToFirst()) { do { ViewEntryData data = new ViewEntryData(); // Read call log specifics data.id = callCursor.getLong(LOG_COLUMN_INDEX); data.date = callCursor.getLong(DATE_COLUMN_INDEX); data.duration = callCursor.getLong(DURATION_COLUMN_INDEX); data.callType = callCursor.getInt(CALL_TYPE_COLUMN_INDEX); data.number = callCursor.getString(NUMBER_COLUMN_INDEX); logs.add(data); }while(callCursor.moveToNext()); } else { // Something went wrong reading in our primary data, so we're going to // bail out and show error to users. Toast.makeText(this, R.string.toast_call_detail_error_wysie, Toast.LENGTH_SHORT).show(); finish(); } } finally { if (callCursor != null) { callCursor.close(); } } adapter = new ViewAdapter(this, logs); setListAdapter(adapter); } Loading
src/com/android/contacts/RecentCallsListActivity.java +13 −40 Original line number Diff line number Diff line Loading @@ -197,7 +197,7 @@ public class RecentCallsListActivity extends ListActivity public long date; public int duration; public int count; public int personId; public long personId; RecentCallsInfo() { count = 1; } Loading Loading @@ -721,21 +721,11 @@ public class RecentCallsListActivity extends ListActivity // Set the photo, if requested if (prefs.getBoolean("cl_show_pic", true)) { Cursor phonesCursor = RecentCallsListActivity.this.getContentResolver().query( Uri.withAppendedPath(Phones.CONTENT_FILTER_URL, Uri.encode(number)), PHONES_PROJECTION, null, null, null); int personId = -1; if (phonesCursor != null) { if (phonesCursor.moveToFirst()) { personId = phonesCursor.getInt(PERSON_ID_COLUMN_INDEX); } phonesCursor.close(); } long personId = callsinfo.personId; Bitmap photo = null; SoftReference<Bitmap> ref = mBitmapCache.get(personId); SoftReference<Bitmap> ref = mBitmapCache.get((int)personId); if (ref != null) { photo = ref.get(); } Loading @@ -745,7 +735,7 @@ public class RecentCallsListActivity extends ListActivity //int id = c.getInt(ID_COLUMN_INDEX); Uri uri = ContentUris.withAppendedId(People.CONTENT_URI, personId); photo = People.loadContactPhoto(context, uri, R.drawable.ic_contact_list_picture, null); mBitmapCache.put(personId, new SoftReference<Bitmap>(photo)); mBitmapCache.put((int)personId, new SoftReference<Bitmap>(photo)); } catch (OutOfMemoryError e) { // Not enough memory for the photo, use the default one instead photo = null; Loading @@ -768,17 +758,6 @@ public class RecentCallsListActivity extends ListActivity } } /* @Override public void changeCursor(Cursor cursor) { super.changeCursor(cursor); // Clear the photo bitmap cache, if there is one if (mBitmapCache != null) { mBitmapCache.clear(); } } */ } Loading Loading @@ -840,18 +819,10 @@ public class RecentCallsListActivity extends ListActivity } public void addItemIntoList(RecentCallsInfo item) { /* if(item.number.startsWith(mIpPrefix)) item.number = item.number.substring(mIpPrefix.length()); String chinaNum = "+86"; if(item.number.startsWith(chinaNum)) item.number = item.number.substring(chinaNum.length()); */ for (int i = 0; i < mListCallLogs.size(); i++) { if (PhoneNumberUtils.compare(mListCallLogs.get(i).number, item.number) || (mListCallLogs.get(i).personId == item.personId && item.personId != -1) || if ((mListCallLogs.get(i).personId == item.personId && item.personId != -1) || PhoneNumberUtils.compare(mListCallLogs.get(i).number, item.number) || sloppyPhoneNumComparator(mListCallLogs.get(i).number, item.number)) { if (mListCallLogs.get(i).name == null && item.name != null) { mListCallLogs.get(i).name = item.name; Loading Loading @@ -923,7 +894,7 @@ public class RecentCallsListActivity extends ListActivity if (phonesCursor != null) { if (phonesCursor.moveToFirst()) { item.personId = phonesCursor.getInt(PERSON_ID_COLUMN_INDEX); item.personId = phonesCursor.getLong(PERSON_ID_COLUMN_INDEX); } phonesCursor.close(); } Loading Loading @@ -1160,10 +1131,12 @@ public class RecentCallsListActivity extends ListActivity } // menu.add(0, MENU_ITEM_DELETE, 0, R.string.recentCalls_removeFromRecentList); menu.add(0, MENU_ITEM_DELETE_ALL_NUMBER, 0, getString(R.string.menu_cl_clear_type, number)); if (contactInfoPresent) { menu.add(0, MENU_ITEM_DELETE_ALL_NAME, 0, getString(R.string.menu_cl_clear_type, info.name)); } else { menu.add(0, MENU_ITEM_DELETE_ALL_NUMBER, 0, getString(R.string.menu_cl_clear_type, number)); } } @Override Loading Loading @@ -1443,7 +1416,7 @@ public class RecentCallsListActivity extends ListActivity Intent intent = new Intent(this, CallDetailActivity.class); // intent.setData(ContentUris.withAppendedId(CallLog.Calls.CONTENT_URI, id)); intent.putExtra("PERSONID", mListCallLogs.get(position).personId); intent.putExtra("NUMBER", mListCallLogs.get(position).number); startActivity(intent); } Loading
src/com/android/contacts/ViewContactActivity.java +6 −13 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.contacts; import static com.android.contacts.ContactEntryAdapter.CONTACT_CUSTOM_RINGTONE_COLUMN; import static com.android.contacts.ContactEntryAdapter.CONTACT_ID_COLUMN; import static com.android.contacts.ContactEntryAdapter.CONTACT_NAME_COLUMN; import static com.android.contacts.ContactEntryAdapter.CONTACT_NOTES_COLUMN; import static com.android.contacts.ContactEntryAdapter.CONTACT_PHONETIC_NAME_COLUMN; Loading Loading @@ -152,6 +153,7 @@ public class ViewContactActivity extends ListActivity private ContentResolver mResolver; private ViewAdapter mAdapter; private int mNumPhoneNumbers = 0; private long contactId = -1; /* package */ ArrayList<ViewEntry> mPhoneEntries = new ArrayList<ViewEntry>(); /* package */ ArrayList<ViewEntry> mSmsEntries = new ArrayList<ViewEntry>(); Loading Loading @@ -352,6 +354,7 @@ public class ViewContactActivity extends ListActivity if (mCursor.moveToFirst()) { // Set the name String name = mCursor.getString(CONTACT_NAME_COLUMN); contactId = mCursor.getLong(CONTACT_ID_COLUMN); if (TextUtils.isEmpty(name)) { mNameView.setText(getText(android.R.string.unknownName)); } else { Loading Loading @@ -545,19 +548,9 @@ public class ViewContactActivity extends ListActivity } case MENU_ITEM_SHOW_CALL_LOG: { final CharSequence[] items = (CharSequence[])phoneNumbersArray.toArray(new CharSequence[0]); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.view_contact_select_cl_number)); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Intent intent = new Intent(_context, CallDetailActivity.class); intent.putExtra("NUMBER", items[item]); intent.putExtra("PERSONID", contactId); startActivity(intent); } }); builder.show(); return true; } Loading