Checkpoint of new edit contact UI, work in progress.
This change introduces several new concepts which are
summarized below. One major change is a MMVC approach that
has two models: the structured Contacts data, and the
data-source constraints model. Another is augmenting an
Entity using a specific set of actions.
First, each data source is defined through a ContactsSource
that describe how it handles data, both for rendering and
editing cases, such as the Data.MIMETYPE it handles, what
types are allowed, and the fields required for editing. In
this change, ContactsSource objects for Google and Exchange
are hard-coded, but an initial XML version will need to be
finalized for supporting third-party apps that show custom
icons and strings.
Second, AugmentedEntity allows us to keep the edit changes
separate from the initial data and build a "diff" between
the current Entity state and the desired changes, which is
represented as a set of ContentProviderOperations. If the
data changed while the user was editing, we can easily swap
in the new Entity and apply the edits on top. In the worst
case, this may end up creating duplicated data, but won't
lose the users changes.
Finally, this change starts splitting the UI and modeling
code into different sub-packages. The UI is split into
multiple ViewHolders to mirror the structure on screen.
There are dozens of TODOs littered throughout the code,
which I'm following up on shortly. This is a checkpoint to
start a code review on the core structure.
diff --git a/res/layout/act_edit.xml b/res/layout/act_edit.xml
new file mode 100644
index 0000000..fe79160
--- /dev/null
+++ b/res/layout/act_edit.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical"
+ android:fillViewport="true">
+
+ <!-- TODO: insert aggregate summary widget -->
+ <!-- TODO: insert contact tab widget -->
+
+ <ScrollView
+ android:id="@android:id/tabcontent"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_weight="1"
+ android:fillViewport="true" />
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ style="@android:style/ButtonBar">
+
+ <Button android:id="@+id/btn_done"
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/menu_done" />
+
+ <Button android:id="@+id/btn_discard"
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/menu_doNotSave" />
+
+ </LinearLayout>
+
+</LinearLayout>
diff --git a/res/layout/act_edit_contact.xml b/res/layout/act_edit_contact.xml
new file mode 100644
index 0000000..b052671
--- /dev/null
+++ b/res/layout/act_edit_contact.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- placed inside act_edit as tabcontent -->
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:fillViewport="true">
+
+ <TextView
+ android:id="@+id/text_summary"
+android:background="#f0f0"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+
+ <FrameLayout
+ android:id="@+id/hook_photo"
+android:background="#f00f"
+ android:layout_width="76dip"
+ android:layout_height="76dip"
+ android:layout_below="@+id/text_summary" />
+
+ <FrameLayout
+ android:id="@+id/hook_displayname"
+android:background="#fff0"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignTop="@+id/hook_photo"
+ android:layout_alignBottom="@+id/hook_photo"
+ android:layout_toRightOf="@+id/hook_photo" />
+
+ <LinearLayout
+ android:id="@+id/sect_general"
+android:background="#f0ff"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/hook_photo"
+ android:orientation="vertical" />
+
+ <!-- TODO: make secondary section collapsable -->
+ <TextView
+android:background="#ff00"
+ android:id="@+id/head_secondary"
+ android:layout_width="fill_parent"
+ android:layout_height="10dip"
+ android:layout_below="@+id/sect_general" />
+
+ <LinearLayout
+android:background="#ff0f"
+ android:id="@+id/sect_secondary"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/head_secondary"
+ android:orientation="vertical" />
+
+</RelativeLayout>
diff --git a/res/layout/item_edit_kind.xml b/res/layout/item_edit_kind.xml
new file mode 100644
index 0000000..e01f160
--- /dev/null
+++ b/res/layout/item_edit_kind.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- the body surrounding all editors for a specific kind -->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <LinearLayout
+ android:id="@+id/kind_header"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="14dip"
+ android:layout_marginTop="3dip"
+ android:layout_marginBottom="1dip"
+ android:layout_marginRight="?android:attr/scrollbarSize"
+ android:orientation="horizontal"
+ android:gravity="bottom"
+ android:focusable="true"
+ android:clickable="true">
+
+ <TextView
+ android:id="@+id/kind_title"
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layout_marginBottom="8dip"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:singleLine="true"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal" />
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:duplicateParentState="true"
+ style="@style/PlusButton" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/kind_editors"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical" />
+
+</LinearLayout>
diff --git a/res/layout/item_editor.xml b/res/layout/item_editor.xml
new file mode 100644
index 0000000..8d46bcc
--- /dev/null
+++ b/res/layout/item_editor.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:baselineAligned="false"
+ android:gravity="top"
+ android:paddingRight="?android:attr/scrollbarSize">
+
+ <Button
+ android:id="@+id/edit_label"
+ android:layout_width="100dip"
+ android:layout_height="wrap_content"
+ android:gravity="left|center_vertical" />
+
+ <LinearLayout
+ android:id="@+id/edit_fields"
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layout_marginLeft="4dip"
+ android:orientation="vertical"
+ android:baselineAligned="false"
+ android:gravity="center_vertical" />
+
+ <ImageButton
+ android:id="@+id/edit_delete"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@style/MinusButton" />
+
+</LinearLayout>
diff --git a/res/layout/item_editor_displayname.xml b/res/layout/item_editor_displayname.xml
new file mode 100644
index 0000000..ae6d815
--- /dev/null
+++ b/res/layout/item_editor_displayname.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <EditText
+ android:id="@+id/name"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginRight="?android:attr/scrollbarSize"
+ android:gravity="center_vertical"
+ android:inputType="textPersonName|textCapWords"
+ android:hint="@string/ghostData_name" />
+
+ <!-- "Phonetic name" entry widget, visible only in certain locales -->
+ <include layout="@layout/edit_phonetic_name"/>
+
+</LinearLayout>
diff --git a/res/layout/item_editor_field.xml b/res/layout/item_editor_field.xml
new file mode 100644
index 0000000..1e77068
--- /dev/null
+++ b/res/layout/item_editor_field.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<EditText
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
diff --git a/res/layout/item_editor_photo.xml b/res/layout/item_editor_photo.xml
new file mode 100644
index 0000000..d4fcf13
--- /dev/null
+++ b/res/layout/item_editor_photo.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<ImageView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:clickable="true"
+ android:focusable="true"
+ android:src="@drawable/ic_menu_add_picture"
+ android:scaleType="center"
+ android:background="@drawable/btn_contact_picture" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c6d1401..93724fb 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -658,4 +658,44 @@
-->
<string name="description_image_button_pound">pound</string>
+<!-- TODO: add comments to each of these strings to prepare for translation -->
+<!-- TODO: split out separate strings for "Home" versus "Call home", see http://b/2029022 -->
+<string name="nameLabelsGroup">Name</string>
+<string name="nicknameLabelsGroup">Nickname</string>
+<string name="organizationLabelsGroup">Organization</string>
+<string name="websiteLabelsGroup">Website</string>
+
+<string name="type_home">Home</string>
+<string name="type_mobile">Mobile</string>
+<string name="type_work">Work</string>
+<string name="type_fax_work">Work Fax</string>
+<string name="type_fax_home">Home Fax</string>
+<string name="type_pager">Pager</string>
+<string name="type_other">Other</string>
+<string name="type_custom">Custom</string>
+
+<!-- exchange specific -->
+<string name="type_home_2">Home 2</string>
+<string name="type_work_2">Work 2</string>
+<string name="type_car">Car</string>
+<string name="type_company_main">Company Main</string>
+<string name="type_mms">MMS</string>
+<string name="type_radio">Radio</string>
+<string name="type_assistant">Assistant</string>
+
+<string name="type_email_1">Email 1</string>
+<string name="type_email_2">Email 2</string>
+<string name="type_email_3">Email 3</string>
+
+
+<string name="type_im_aim">AIM</string>
+<string name="type_im_live">Windows Live</string>
+<string name="type_im_yahoo">Yahoo</string>
+<string name="type_im_skype">Skype</string>
+<string name="type_im_qq">QQ</string>
+<string name="type_im_talk">Google Talk</string>
+<string name="type_im_icq">ICQ</string>
+<string name="type_im_jabber">Jabber</string>
+
+
</resources>