添加移除常用联系功能,需要修改的另外一个应用程序是com.android.contacts。
在MTK6575平台上,需要修改的文件有:
modified: packages/apps/Contacts/src/com/android/contacts/activities/DialtactsActivity.javamodified: packages/apps/Contacts/src/com/android/contacts/activities/PeopleActivity.javamodified: packages/apps/Contacts/src/com/android/contacts/group/GroupDetailFragment.javamodified: packages/apps/Contacts/src/com/android/contacts/list/ContactTileAdapter.javamodified: packages/apps/Contacts/src/com/android/contacts/list/ContactTileListFragment.javamodified: packages/apps/Contacts/src/com/android/contacts/list/ContactTileView.javamodified: packages/apps/Contacts/src/com/android/contacts/list/PhoneFavoriteFragment.javamodified: packages/apps/Contacts/res/values-zh-rCN/strings.xmlmodified: packages/apps/Contacts/res/values-zh-rTW/strings.xmlmodified: packages/apps/Contacts/res/values/strings.xml
文件packages/apps/Contacts/src/com/android/contacts/activities/DialtactsActivity.java的主要修改如下:
@@ -935,17 +939,95 @@ public class DialtactsActivity extends TransactionSafeActivity implements ProvidenterSearchUi();}};-+ /*robin_20120509*/private PhoneFavoriteFragment.Listener mPhoneFavoriteListener =new PhoneFavoriteFragment.Listener() {@Override- public void onContactSelected(Uri contactUri) {+ public void onContactClick(Uri contactUri) {PhoneNumberInteraction.startInteractionForPhoneCall(DialtactsActivity.this, contactUri,CALL_ORIGIN_DIALTACTS);}+ @Override+ public boolean onContactLongClick(Uri contactUri,int type) {+ if (type==ViewTypes.FREQUENT)+ {+ final Uri contactLookUpUri=contactUri;+ Runnable r=new Runnable(){++ @Override+ public void run() {+ removeFrequentContact(contactLookUpUri);+ }};+ showRemoveFrequentContactAlertDialog(r);+ return true;+ }+ return false;+ }};+ Handler handler=new Handler();+ IContentProvider mContentProvider;+ final static String ContactsProvider_CALL_METHOD_UPDATE_FAKE_TIMES_USED="CALL_METHOD_update_FAKE_TIMES_USED_Stat";+ void removeFrequentContact(Uri contactUri)+ {+ IContentProvider cp = null;+ synchronized (this) {+ cp = mContentProvider;+ if (cp == null) {+ cp = mContentProvider =getContentResolver().acquireProvider(ContactsContract.AUTHORITY);+ }+ }+ try {+ Bundle bundle=new Bundle();+ bundle.putString("Uri", contactUri.toString());+ Bundle b = cp.call(ContactsProvider_CALL_METHOD_UPDATE_FAKE_TIMES_USED, "", bundle);+ if (b != null) {+ int v = b.getInt("count",0);+ if(v>0)+ {+ Toast.makeText(this, R.string.remove_frequent_contact_succes, Toast.LENGTH_SHORT).show();+ return;+ }+ }+ Toast.makeText(this, R.string.remove_frequent_contact_fail, Toast.LENGTH_SHORT).show();+ // If the response Bundle is null, we fall through+ // to the query interface below.+ } catch (RemoteException e) {+ Log.w(TAG, "", e);+ // Not supported by the remote side? Fall through+ // to query().+ }+ }++AlertDialog removeFrequentContactAlertDialog;+void showRemoveFrequentContactAlertDialog(final Runnable runnable)+{+ AlertDialog.Builder dialogBuilder=new AlertDialog.Builder(this);+ dialogBuilder.setMessage(R.string.remove_frequent_contact_alert);+ dialogBuilder.setCancelable(true);+ DialogInterface.OnClickListener negativeListener=new DialogInterface.OnClickListener(){++ @Override+ public void onClick(DialogInterface arg0, int arg1) {++ }};+ DialogInterface.OnClickListener positiveListener=new DialogInterface.OnClickListener(){+ @Override+ public void onClick(DialogInterface arg0, int arg1) {+ handler.post(runnable);++ }+ };+ dialogBuilder.setNegativeButton(android.R.string.cancel, negativeListener);+ dialogBuilder.setPositiveButton(android.R.string.ok, positiveListener);+ removeFrequentContactAlertDialog=dialogBuilder.create();+ removeFrequentContactAlertDialog.show();+}+/*robin_20120509*/
文件packages/apps/Contacts/src/com/android/contacts/activities/PeopleActivity.java的主要修改如下:
@@ -1340,19 +1345,97 @@ public class PeopleActivity extends ContactsActivitystartActivity(new Intent(Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS));}}-+ /*[robin_20120509*/private final class StrequentContactListFragmentListenerimplements ContactTileListFragment.Listener {@Override- public void onContactSelected(Uri contactUri, Rect targetRect) {+ public void onContactClick(Uri contactUri, Rect targetRect) {if (PhoneCapabilityTester.isUsingTwoPanes(PeopleActivity.this)) {QuickContact.showQuickContact(PeopleActivity.this, targetRect, contactUri, 0, null);} else {startActivity(new Intent(Intent.ACTION_VIEW, contactUri));}}+ @Override+ public boolean onContactLongClick(Uri contactUri, Rect targetRect,int type) {+ if (type==ViewTypes.FREQUENT)+ {+ final Uri contactLookUpUri=contactUri;+ Runnable r=new Runnable(){++ @Override+ public void run() {+ // TODO Auto-generated method stub+ removeFrequentContact(contactLookUpUri);+ }};+ showRemoveFrequentContactAlertDialog(r);+ return true;+ }+ return false;+ }+ }+ Handler handler=new Handler();+ IContentProvider mContentProvider;+ final static String ContactsProvider_CALL_METHOD_UPDATE_FAKE_TIMES_USED="CALL_METHOD_update_FAKE_TIMES_USED_Stat";+ void removeFrequentContact(Uri contactUri)+ {+ IContentProvider cp = null;+ synchronized (this) {+ cp = mContentProvider;+ if (cp == null) {+ cp = mContentProvider =getContentResolver().acquireProvider(ContactsContract.AUTHORITY);+ }+ }+ try {+ Bundle bundle=new Bundle();+ bundle.putString("Uri", contactUri.toString());+ Bundle b = cp.call(ContactsProvider_CALL_METHOD_UPDATE_FAKE_TIMES_USED, "ID_TYPE_CONTACT", bundle);+ if (b != null) {+ int v = b.getInt("count",0);+ if(v>0)+ {+ Toast.makeText(this, R.string.remove_frequent_contact_succes, Toast.LENGTH_SHORT).show();+ return;+ }+ }+ Toast.makeText(this, R.string.remove_frequent_contact_fail, Toast.LENGTH_SHORT).show();+ /* If the response Bundle is null, we fall through+ to the query interface below.*/+ } catch (RemoteException e) {+ Log.w(TAG, "", e);+ /** Not supported by the remote side? Fall through+ to query().*/+ }}+AlertDialog removeFrequentContactAlertDialog;+void showRemoveFrequentContactAlertDialog(final Runnable runnable)+{+ AlertDialog.Builder dialogBuilder=new AlertDialog.Builder(this);+ dialogBuilder.setMessage(R.string.remove_frequent_contact_alert);+ dialogBuilder.setCancelable(true);+ DialogInterface.OnClickListener negativeListener=new DialogInterface.OnClickListener(){++ @Override+ public void onClick(DialogInterface arg0, int arg1) {+ /* TODO Auto-generated method stub*/++ }};+ DialogInterface.OnClickListener positiveListener=new DialogInterface.OnClickListener(){++ @Override+ public void onClick(DialogInterface arg0, int arg1) {+ /* TODO Auto-generated method stub*/+ handler.post(runnable);++ }+ };+ dialogBuilder.setNegativeButton(android.R.string.cancel, negativeListener);+ dialogBuilder.setPositiveButton(android.R.string.ok, positiveListener);+ removeFrequentContactAlertDialog=dialogBuilder.create();+ removeFrequentContactAlertDialog.show();+}+/*robin_20120509]*/private final class GroupBrowserActionListener implements OnGroupBrowserActionListener {
packages/apps/Contacts/src/com/android/contacts/calllog/CallLogAdapter.java文件修改如下
@@ -398,7 +398,18 @@ implements CallLogGroupBuilder.GroupCreator, OnScrollListener{if (OperatorUtils.getOptrProperties().equals("OP02")) {contactInfo.photoId = (slotId == 0) ? -3 : -4;} else {- contactInfo.photoId = SimCardUtils.isSimUsimType(slotId) ? -2 : -1;+ // contactInfo.photoId = SimCardUtils.isSimUsimType(slotId) ? -2 : -1;+ if(SimCardUtils.isSimUsimType(slotId)){+ if(slotId == 0)+ contactInfo.photoId = -5;+ else+ contactInfo.photoId = -6;+ }else{+ if(slotId == 0)+ contactInfo.photoId = -7;+ else+ contactInfo.photoId = -8;+ }}}
文件packages/apps/Contacts/src/com/android/contacts/list/ContactTileAdapter.java的主要修改如下:
@@ -276,12 +277,20 @@ public class ContactTileAdapter extends BaseAdapter {} else {boolean isUsim = SimCardUtils.isSimUsimType(slotId);if (isUsim) {- Log.i(TAG, "-----------usim");- contact.photoUri = Uri.parse("content://usim");+ <