Loading src/com/android/contacts/editor/CompactContactEditorFragment.java +10 −1 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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; } Loading src/com/android/contacts/editor/CompactRawContactsEditorView.java +15 −32 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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); Loading Loading @@ -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)) { Loading Loading @@ -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)) { Loading @@ -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; } Loading Loading @@ -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); } } } src/com/android/contacts/editor/ContactEditorBaseFragment.java +8 −3 Original line number Diff line number Diff line Loading @@ -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; } Loading Loading @@ -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 // Loading Loading @@ -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( Loading @@ -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 { Loading src/com/android/contacts/editor/ContactEditorFragment.java +25 −12 Original line number Diff line number Diff line Loading @@ -382,16 +382,13 @@ 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(); final String displayName = nameEditorView.getDisplayName(); if (!TextUtils.isEmpty(displayName)) { return displayName; } } } } } // Return the first non-empty name for (int i = 0; i < mContent.getChildCount(); i++) { final View view = mContent.getChildAt(i); Loading @@ -400,15 +397,31 @@ 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(); 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; } } } } return null; } Loading src/com/android/contacts/editor/EditorIntents.java +11 −8 Original line number Diff line number Diff line Loading @@ -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); } /** Loading @@ -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; Loading Loading @@ -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; } Loading @@ -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(); Loading @@ -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); } } } Loading
src/com/android/contacts/editor/CompactContactEditorFragment.java +10 −1 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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; } Loading
src/com/android/contacts/editor/CompactRawContactsEditorView.java +15 −32 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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); Loading Loading @@ -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)) { Loading Loading @@ -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)) { Loading @@ -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; } Loading Loading @@ -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); } } }
src/com/android/contacts/editor/ContactEditorBaseFragment.java +8 −3 Original line number Diff line number Diff line Loading @@ -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; } Loading Loading @@ -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 // Loading Loading @@ -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( Loading @@ -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 { Loading
src/com/android/contacts/editor/ContactEditorFragment.java +25 −12 Original line number Diff line number Diff line Loading @@ -382,16 +382,13 @@ 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(); final String displayName = nameEditorView.getDisplayName(); if (!TextUtils.isEmpty(displayName)) { return displayName; } } } } } // Return the first non-empty name for (int i = 0; i < mContent.getChildCount(); i++) { final View view = mContent.getChildAt(i); Loading @@ -400,15 +397,31 @@ 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(); 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; } } } } return null; } Loading
src/com/android/contacts/editor/EditorIntents.java +11 −8 Original line number Diff line number Diff line Loading @@ -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); } /** Loading @@ -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; Loading Loading @@ -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; } Loading @@ -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(); Loading @@ -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); } } }