summaryrefslogtreecommitdiffstats
path: root/src/com/android/contacts
diff options
context:
space:
mode:
authorWalter Jang <wjang@google.com>2015-05-05 09:14:35 -0700
committerWalter Jang <wjang@google.com>2015-05-14 14:44:45 -0700
commitbf63a6d6a888b3e1b5fb91accf2dadaab4384539 (patch)
tree1909473ecf1012bfdd43826bf1b7a87337ce41e1 /src/com/android/contacts
parent3126951b118920c412149a54fbc65dc39d63aa5c (diff)
downloadpackages_apps_Contacts-bf63a6d6a888b3e1b5fb91accf2dadaab4384539.tar.gz
packages_apps_Contacts-bf63a6d6a888b3e1b5fb91accf2dadaab4384539.tar.bz2
packages_apps_Contacts-bf63a6d6a888b3e1b5fb91accf2dadaab4384539.zip
Fix contact name passing from compact to full editor on inserts
Bug 19624360 Change-Id: I50c415b59c4bad1d08f18f8c2bc7d57ddb73c418
Diffstat (limited to 'src/com/android/contacts')
-rw-r--r--src/com/android/contacts/editor/CompactContactEditorFragment.java11
-rw-r--r--src/com/android/contacts/editor/CompactRawContactsEditorView.java47
-rw-r--r--src/com/android/contacts/editor/ContactEditorBaseFragment.java11
-rw-r--r--src/com/android/contacts/editor/ContactEditorFragment.java37
-rw-r--r--src/com/android/contacts/editor/EditorIntents.java19
-rw-r--r--src/com/android/contacts/editor/PhoneticNameEditorView.java4
6 files changed, 73 insertions, 56 deletions
diff --git a/src/com/android/contacts/editor/CompactContactEditorFragment.java b/src/com/android/contacts/editor/CompactContactEditorFragment.java
index 2bffc6a22..3c0e6ddd6 100644
--- a/src/com/android/contacts/editor/CompactContactEditorFragment.java
+++ b/src/com/android/contacts/editor/CompactContactEditorFragment.java
@@ -355,7 +355,8 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl
// Prepare an Intent to start the expanded editor
final Intent intent = isInsert
- ? EditorIntents.createInsertContactIntent(mState, getDisplayName(), mUpdatedPhotos)
+ ? EditorIntents.createInsertContactIntent(
+ mState, getDisplayName(), getPhoneticName(), mUpdatedPhotos)
: EditorIntents.createEditContactIntent(mLookupUri, getMaterialPalette());
ImplicitIntentsUtil.startActivityInApp(getActivity(), intent);
@@ -381,6 +382,14 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl
? null : structuredNameEditorView.getDisplayName();
}
+ @Override
+ public String getPhoneticName() {
+ final PhoneticNameEditorView phoneticNameEditorView =
+ getContent().getFirstPhoneticNameEditorView();
+ return phoneticNameEditorView == null
+ ? null : phoneticNameEditorView.getPhoneticName();
+ }
+
private CompactRawContactsEditorView getContent() {
return (CompactRawContactsEditorView) mContent;
}
diff --git a/src/com/android/contacts/editor/CompactRawContactsEditorView.java b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
index 704fe9d79..36502e2a2 100644
--- a/src/com/android/contacts/editor/CompactRawContactsEditorView.java
+++ b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
@@ -246,6 +246,12 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
? null : (StructuredNameEditorView) mNames.getChildAt(0);
}
+ public PhoneticNameEditorView getFirstPhoneticNameEditorView() {
+ // There should only ever be one phonetic name
+ return mPhoneticNames.getChildCount() == 0
+ ? null : (PhoneticNameEditorView) mPhoneticNames.getChildAt(0);
+ }
+
public View getAggregationAnchorView() {
// Since there is only one structured name we can just return it as the anchor for
// the aggregation suggestions popup
@@ -274,6 +280,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
/* valuesDelta =*/ null, ViewIdGenerator.NO_VIEW_INDEX));
mMaterialPalette = materialPalette;
+ vlog("Setting compact editor state from " + rawContactDeltas);
addPhotoView(rawContactDeltas, viewIdGenerator);
addStructuredNameView(rawContactDeltas);
addEditorViews(rawContactDeltas);
@@ -424,7 +431,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
continue;
}
final String mimeType = dataKind.mimeType;
- log(Log.VERBOSE, mimeType + " " + dataKind.fieldList.size() + " field(s)");
+ vlog(mimeType + " " + dataKind.fieldList.size() + " field(s)");
if (Photo.CONTENT_ITEM_TYPE.equals(mimeType)
|| StructuredName.CONTENT_ITEM_TYPE.equals(mimeType)
|| GroupMembership.CONTENT_ITEM_TYPE.equals(mimeType)) {
@@ -521,11 +528,11 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
String mimeType, DataKind dataKind) {
final List<ValuesDelta> result = new ArrayList<>();
if (rawContactDelta == null) {
- log(Log.VERBOSE, "Null RawContactDelta");
+ vlog("Null RawContactDelta");
return result;
}
if (!rawContactDelta.hasMimeEntries(mimeType)) {
- log(Log.VERBOSE, "No ValueDeltas");
+ vlog("No ValueDeltas");
return result;
}
for (ValuesDelta valuesDelta : rawContactDelta.getMimeEntries(mimeType)) {
@@ -538,14 +545,13 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
private static boolean hasNonEmptyValue(DataKind dataKind, ValuesDelta valuesDelta) {
if (valuesDelta == null) {
- log(Log.VERBOSE, "Null valuesDelta");
+ vlog("Null valuesDelta");
return false;
}
for (EditField editField : dataKind.fieldList) {
final String column = editField.column;
final String value = valuesDelta == null ? null : valuesDelta.getAsString(column);
- log(Log.VERBOSE, "Field " + column + " empty=" + TextUtils.isEmpty(value) +
- " value=" + value);
+ vlog("Field " + column + " empty=" + TextUtils.isEmpty(value) + " value=" + value);
if (!TextUtils.isEmpty(value)) {
return true;
}
@@ -598,32 +604,9 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
return result;
}
- private static void log(int level, String message) {
- log(TAG, level, message);
- }
-
- private static void log(String tag, int level, String message) {
- if (Log.isLoggable(tag, level)) {
- switch (level) {
- case Log.VERBOSE:
- Log.v(tag, message);
- break;
- case Log.DEBUG:
- Log.d(tag, message);
- break;
- case Log.INFO:
- Log.i(tag, message);
- break;
- case Log.WARN:
- Log.w(tag, message);
- break;
- case Log.ERROR:
- Log.e(tag, message);
- break;
- default:
- Log.v(tag, message);
- break;
- }
+ private static void vlog(String message) {
+ if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ Log.v(TAG, message);
}
}
}
diff --git a/src/com/android/contacts/editor/ContactEditorBaseFragment.java b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
index a7686ae3d..529bc4ee0 100644
--- a/src/com/android/contacts/editor/ContactEditorBaseFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
@@ -922,7 +922,7 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
// If we're coming back from the fully expanded editor and this is an insert, just
// pass any values entered by the user back to the compact editor without doing a save
final Intent resultIntent = EditorIntents.createCompactInsertContactIntent(
- mState, getDisplayName(), mUpdatedPhotos);
+ mState, getDisplayName(), getPhoneticName(), mUpdatedPhotos);
mListener.onSaveFinished(resultIntent);
return true;
}
@@ -979,6 +979,11 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
*/
abstract protected String getDisplayName();
+ /**
+ * Returns the currently displayed phonetic name;
+ */
+ abstract protected String getPhoneticName();
+
//
// Account creation
//
@@ -1343,7 +1348,7 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
if (!saveSucceeded || contactLookupUri == null) {
resultIntent = saveMode == SaveMode.COMPACT
? EditorIntents.createCompactInsertContactIntent(
- mState, getDisplayName(), updatedPhotos)
+ mState, getDisplayName(), getPhoneticName(), updatedPhotos)
: null;
} else {
final Uri lookupUri = maybeConvertToLegacyLookupUri(
@@ -1354,7 +1359,7 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
} else if (saveMode == SaveMode.COMPACT) {
resultIntent = isInsert(getActivity().getIntent())
? EditorIntents.createCompactInsertContactIntent(
- mState, getDisplayName(), updatedPhotos)
+ mState, getDisplayName(), getPhoneticName(), updatedPhotos)
: EditorIntents.createCompactEditContactIntent(
lookupUri, getMaterialPalette(), updatedPhotos);
} else {
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index 494972921..4cda73d93 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -382,12 +382,9 @@ public class ContactEditorFragment extends ContactEditorBaseFragment implements
final StructuredNameEditorView nameEditorView =
rawContactEditorView.getNameEditor();
if (nameEditorView != null) {
- final ValuesDelta valuesDelta = nameEditorView.getValues();
- if (valuesDelta != null && valuesDelta.isSuperPrimary()) {
- final String displayName = valuesDelta.getDisplayName();
- if (!TextUtils.isEmpty(displayName)) {
- return displayName;
- }
+ final String displayName = nameEditorView.getDisplayName();
+ if (!TextUtils.isEmpty(displayName)) {
+ return displayName;
}
}
}
@@ -400,12 +397,28 @@ public class ContactEditorFragment extends ContactEditorBaseFragment implements
final StructuredNameEditorView nameEditorView =
rawContactEditorView.getNameEditor();
if (nameEditorView != null) {
- final ValuesDelta valuesDelta = nameEditorView.getValues();
- if (valuesDelta != null) {
- final String displayName = valuesDelta.getDisplayName();
- if (!TextUtils.isEmpty(displayName)) {
- return displayName;
- }
+ final String displayName = nameEditorView.getDisplayName();
+ if (!TextUtils.isEmpty(displayName)) {
+ return displayName;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String getPhoneticName() {
+ for (int i = 0; i < mContent.getChildCount(); i++) {
+ final View view = mContent.getChildAt(i);
+ if (view instanceof RawContactEditorView) {
+ final RawContactEditorView rawContactEditorView = (RawContactEditorView) view;
+ final PhoneticNameEditorView phoneticNameEditorView =
+ (PhoneticNameEditorView) rawContactEditorView.getPhoneticNameEditor();
+ if (phoneticNameEditorView != null) {
+ final String phoneticName = phoneticNameEditorView.getPhoneticName();
+ if (!TextUtils.isEmpty(phoneticName)) {
+ return phoneticName;
}
}
}
diff --git a/src/com/android/contacts/editor/EditorIntents.java b/src/com/android/contacts/editor/EditorIntents.java
index 3fb2145e0..5d7edd325 100644
--- a/src/com/android/contacts/editor/EditorIntents.java
+++ b/src/com/android/contacts/editor/EditorIntents.java
@@ -56,7 +56,7 @@ public class EditorIntents {
*/
public static Intent createCompactInsertContactIntent() {
return createCompactInsertContactIntent(/* rawContactDeltaList =*/ null,
- /* displayName =*/ null, /* updatedPhotos =*/ null);
+ /* displayName =*/ null, /* phoneticName =*/ null, /* updatedPhotos =*/ null);
}
/**
@@ -64,10 +64,10 @@ public class EditorIntents {
* the field values specified by rawContactDeltaList pre-populate in the form.
*/
public static Intent createCompactInsertContactIntent(RawContactDeltaList rawContactDeltaList,
- String displayName, Bundle updatedPhotos) {
+ String displayName, String phoneticName, Bundle updatedPhotos) {
final Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
- if (rawContactDeltaList != null || displayName != null) {
- putRawContactDeltaValues(intent, rawContactDeltaList, displayName);
+ if (rawContactDeltaList != null || displayName != null || phoneticName != null) {
+ putRawContactDeltaValues(intent, rawContactDeltaList, displayName, phoneticName);
}
putUpdatedPhotos(intent, updatedPhotos);
return intent;
@@ -108,11 +108,11 @@ public class EditorIntents {
* existing contact.
*/
public static Intent createInsertContactIntent(RawContactDeltaList rawContactDeltaList,
- String displayName, Bundle updatedPhotos) {
+ String displayName, String phoneticName, Bundle updatedPhotos) {
final Intent intent = new Intent(ContactEditorBaseActivity.ACTION_INSERT,
Contacts.CONTENT_URI);
addContactIntentFlags(intent);
- putRawContactDeltaValues(intent, rawContactDeltaList, displayName);
+ putRawContactDeltaValues(intent, rawContactDeltaList, displayName, phoneticName);
putUpdatedPhotos(intent, updatedPhotos);
return intent;
}
@@ -137,7 +137,7 @@ public class EditorIntents {
}
private static void putRawContactDeltaValues(Intent intent,
- RawContactDeltaList rawContactDeltaList, String displayName) {
+ RawContactDeltaList rawContactDeltaList, String displayName, String phoneticName) {
// Pass on all the data that has been entered so far
if (rawContactDeltaList != null && !rawContactDeltaList.isEmpty()) {
ArrayList<ContentValues> contentValues = rawContactDeltaList.get(0).getContentValues();
@@ -146,9 +146,12 @@ public class EditorIntents {
ContactsContract.Intents.Insert.DATA, contentValues);
}
}
- // Name must be passed separately since it is skipped in RawContactModifier.parseValues
+ // Names must be passed separately since they are skipped in RawContactModifier.parseValues
if (!TextUtils.isEmpty(displayName)) {
intent.putExtra(ContactsContract.Intents.Insert.NAME, displayName);
}
+ if (!TextUtils.isEmpty(phoneticName)) {
+ intent.putExtra(ContactsContract.Intents.Insert.PHONETIC_NAME, phoneticName);
+ }
}
}
diff --git a/src/com/android/contacts/editor/PhoneticNameEditorView.java b/src/com/android/contacts/editor/PhoneticNameEditorView.java
index 420575cbd..f094d55b8 100644
--- a/src/com/android/contacts/editor/PhoneticNameEditorView.java
+++ b/src/com/android/contacts/editor/PhoneticNameEditorView.java
@@ -151,4 +151,8 @@ public class PhoneticNameEditorView extends TextFieldsEditorView {
return !TextUtils.isEmpty(family) || !TextUtils.isEmpty(middle)
|| !TextUtils.isEmpty(given);
}
+
+ public String getPhoneticName() {
+ return getEntry().getAsString(DataKind.PSEUDO_COLUMN_PHONETIC_NAME);
+ }
}