编辑联系人
相关类
packages/apps/Contacts/src/com/android/contacts/activities/ContactEditorActivity.java
packages/apps/Contacts/src/com/android/contacts/editor/ContactEditorFragment.java
packages/apps/Contacts/src/com/android/contacts/ContactSaveService.java
packages/apps/Contacts/src/com/android/contacts/editor/RawContactEditorView.java
packages/apps/Contacts/src/com/android/contacts/model/RawContactDeltaList.java
编辑联系人界面从8.0开始修改为ContactEditorActivity,但同时兼容旧的联系人编辑界面CompactContactEditorActivity
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!-- Edit or create a contact with only the most important fields displayed initially. -->
<activity
android:name=".activities.ContactEditorActivity"
android:theme="@style/EditorActivityTheme">
<intent-filter>
<action android:name="android.intent.action.INSERT"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="vnd.android.cursor.dir/person"/>
<data android:mimeType="vnd.android.cursor.dir/contact"/>
<data android:mimeType="vnd.android.cursor.dir/raw_contact"/>
</intent-filter>
</activity>
<!-- Keep support for apps that expect the Compact editor -->
<activity-alias
android:name="com.android.contacts.activities.CompactContactEditorActivity"
android:exported="true"
android:targetActivity=".activities.ContactEditorActivity">
<intent-filter android:priority="-1">
<action android:name="android.intent.action.INSERT"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="vnd.android.cursor.dir/person"/>
<data android:mimeType="vnd.android.cursor.dir/contact"/>
<data android:mimeType="vnd.android.cursor.dir/raw_contact"/>
</intent-filter>
</activity-alias>
一般情况下编辑联系人界面的启动分两种情况,existing_contact 和 new_contact
1
2
3
4
5
6
7
8
9
10
11
12
13
14
@Override
public void onCreate(Bundle savedState) {
super.onCreate(savedState);
......
if (Intent.ACTION_EDIT.equals(action)) {
mActionBarTitleResId = R.string.contact_editor_title_existing_contact;
} else {
mActionBarTitleResId = R.string.contact_editor_title_new_contact;
}
......
}
ContactEditorActivity的onCreate方法中创建并调用了ContactEditorFragment,由该Fragment负责整个编辑界面的操作和维护,ContactEditorFragment中主要是用自定义ViewRawContactEditorView来展示和编辑联系人数据,从而形成了完整的用户交互
联系人数据编辑完成后的后续保存工作由ContactSaveService类来负责完成,需要注意的是ContactSaveService是一个IntentServer,用在此处恰到好处,当快速处理完Intent任务就会立马释放资源
————————————————