Loading res/values/donottranslate_config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,9 @@ <!-- If true, the default sort order is primary (i.e. by given name) --> <bool name="config_default_display_order_primary">true</bool> <!-- If true, phonetic name fields are not visible when empty --> <bool name="config_default_hide_phonetic_name_if_empty">true</bool> <!-- If true, the order of name fields in the editor is primary (i.e. given name first) --> <bool name="config_editor_field_order_primary">true</bool> Loading res/values/strings.xml +11 −0 Original line number Diff line number Diff line Loading @@ -1318,6 +1318,17 @@ <!-- Label of the "sort by" display option --> <string name="display_options_sort_list_by">Sort by</string> <!-- Label of the "phonetic name fields" display option. [CHAR LIMIT=50] --> <string name="display_options_phonetic_name_fields">Phonetic name</string> <!-- Option to initially show the phonetic name input fields on the contact editor even if the contact does not have a phonetic name. [CHAR LIMIT=25] --> <string name="editor_options_always_show_phonetic_names">Always show</string> <!-- Option to initially hide the phonetic name input fields on the contact editor if the contact being edited doesn't have a phonetic name. [CHAR LIMIT=25] --> <string name="editor_options_hide_phonetic_names_if_empty">Hide if empty</string> <!-- An allowable value for the "sort list by" contact display option --> <string name="display_options_sort_by_given_name">First name</string> Loading res/xml/preference_display_options.xml +6 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,12 @@ android:title="@string/display_options_view_names_as" android:dialogTitle="@string/display_options_view_names_as" /> <com.android.contacts.preference.PhoneticNameDisplayPreference android:icon="@null" android:key="phoneticNameDisplay" android:title="@string/display_options_phonetic_name_fields" android:dialogTitle="@string/display_options_phonetic_name_fields"/> <Preference android:icon="@null" android:key="import" Loading src/com/android/contacts/editor/KindSectionView.java +4 −2 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import com.android.contacts.model.RawContactModifier; import com.android.contacts.model.ValuesDelta; import com.android.contacts.model.account.AccountType; import com.android.contacts.model.dataitem.DataKind; import com.android.contacts.preference.ContactsPreferences; import java.util.ArrayList; import java.util.List; Loading Loading @@ -348,8 +349,7 @@ public class KindSectionView extends LinearLayout { nameValuesDelta, rawContactDelta.getRawContactId(), mListener)); } nameView.setDeletable(false); nameView.setValues( accountType.getKindForMimetype(DataKind.PSEUDO_MIME_TYPE_NAME), nameView.setValues(accountType.getKindForMimetype(DataKind.PSEUDO_MIME_TYPE_NAME), nameValuesDelta, rawContactDelta, /* readOnly =*/ false, mViewIdGenerator); // Correct start margin since there is a second icon in the structured name layout Loading @@ -376,6 +376,8 @@ public class KindSectionView extends LinearLayout { layoutParams.setMargins(0, 0, 0, 0); phoneticNameView.setLayoutParams(layoutParams); mEditors.addView(phoneticNameView); // Display of phonetic name fields is controlled from settings preferences. mHideIfEmpty = new ContactsPreferences(getContext()).shouldHidePhoneticNamesIfEmpty(); } private void addGroupEditorView(RawContactDelta rawContactDelta, DataKind dataKind) { Loading src/com/android/contacts/preference/ContactsPreferences.java +42 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,8 @@ public class ContactsPreferences implements OnSharedPreferenceChangeListener { public static final boolean PREF_DISPLAY_ONLY_PHONES_DEFAULT = false; public static final String PHONETIC_NAME_DISPLAY_KEY = "Phonetic_name_display"; /** * Value to use when a preference is unassigned and needs to be read from the shared preferences */ Loading @@ -77,6 +79,8 @@ public class ContactsPreferences implements OnSharedPreferenceChangeListener { private final Context mContext; private int mSortOrder = PREFERENCE_UNASSIGNED; private int mDisplayOrder = PREFERENCE_UNASSIGNED; private int mPhoneticNameDisplayPreference = PREFERENCE_UNASSIGNED; private AccountWithDataSet mDefaultAccount = null; private ChangeListener mListener = null; private Handler mHandler; Loading Loading @@ -165,6 +169,34 @@ public class ContactsPreferences implements OnSharedPreferenceChangeListener { mBackupManager.dataChanged(); } public int getDefaultPhoneticNameDisplayPreference() { if (mContext.getResources().getBoolean(R.bool.config_default_hide_phonetic_name_if_empty)) { return PhoneticNameDisplayPreference.HIDE_IF_EMPTY; } else { return PhoneticNameDisplayPreference.SHOW_ALWAYS; } } public void setPhoneticNameDisplayPreference(int phoneticNameDisplayPreference) { mPhoneticNameDisplayPreference = phoneticNameDisplayPreference; final Editor editor = mPreferences.edit(); editor.putInt(PHONETIC_NAME_DISPLAY_KEY, phoneticNameDisplayPreference); editor.commit(); mBackupManager.dataChanged(); } public int getPhoneticNameDisplayPreference() { if (mPhoneticNameDisplayPreference == PREFERENCE_UNASSIGNED) { mPhoneticNameDisplayPreference = mPreferences.getInt(PHONETIC_NAME_DISPLAY_KEY, getDefaultPhoneticNameDisplayPreference()); } return mPhoneticNameDisplayPreference; } public boolean shouldHidePhoneticNamesIfEmpty() { return getPhoneticNameDisplayPreference() == PhoneticNameDisplayPreference.HIDE_IF_EMPTY; } public boolean isDefaultAccountUserChangeable() { return mIsDefaultAccountUserChangeable; } Loading Loading @@ -326,6 +358,16 @@ public class ContactsPreferences implements OnSharedPreferenceChangeListener { setDisplayOrder(displayOrder); } if (!mPreferences.contains(PHONETIC_NAME_DISPLAY_KEY)) { int phoneticNameFieldsDisplay = getDefaultPhoneticNameDisplayPreference(); try { phoneticNameFieldsDisplay = Settings.System.getInt(mContext.getContentResolver(), PHONETIC_NAME_DISPLAY_KEY); } catch (SettingNotFoundException e) { } setPhoneticNameDisplayPreference(phoneticNameFieldsDisplay); } if (!mPreferences.contains(mDefaultAccountKey)) { final SharedPreferences previousPrefs = PreferenceManager.getDefaultSharedPreferences(mContext); Loading Loading
res/values/donottranslate_config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,9 @@ <!-- If true, the default sort order is primary (i.e. by given name) --> <bool name="config_default_display_order_primary">true</bool> <!-- If true, phonetic name fields are not visible when empty --> <bool name="config_default_hide_phonetic_name_if_empty">true</bool> <!-- If true, the order of name fields in the editor is primary (i.e. given name first) --> <bool name="config_editor_field_order_primary">true</bool> Loading
res/values/strings.xml +11 −0 Original line number Diff line number Diff line Loading @@ -1318,6 +1318,17 @@ <!-- Label of the "sort by" display option --> <string name="display_options_sort_list_by">Sort by</string> <!-- Label of the "phonetic name fields" display option. [CHAR LIMIT=50] --> <string name="display_options_phonetic_name_fields">Phonetic name</string> <!-- Option to initially show the phonetic name input fields on the contact editor even if the contact does not have a phonetic name. [CHAR LIMIT=25] --> <string name="editor_options_always_show_phonetic_names">Always show</string> <!-- Option to initially hide the phonetic name input fields on the contact editor if the contact being edited doesn't have a phonetic name. [CHAR LIMIT=25] --> <string name="editor_options_hide_phonetic_names_if_empty">Hide if empty</string> <!-- An allowable value for the "sort list by" contact display option --> <string name="display_options_sort_by_given_name">First name</string> Loading
res/xml/preference_display_options.xml +6 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,12 @@ android:title="@string/display_options_view_names_as" android:dialogTitle="@string/display_options_view_names_as" /> <com.android.contacts.preference.PhoneticNameDisplayPreference android:icon="@null" android:key="phoneticNameDisplay" android:title="@string/display_options_phonetic_name_fields" android:dialogTitle="@string/display_options_phonetic_name_fields"/> <Preference android:icon="@null" android:key="import" Loading
src/com/android/contacts/editor/KindSectionView.java +4 −2 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import com.android.contacts.model.RawContactModifier; import com.android.contacts.model.ValuesDelta; import com.android.contacts.model.account.AccountType; import com.android.contacts.model.dataitem.DataKind; import com.android.contacts.preference.ContactsPreferences; import java.util.ArrayList; import java.util.List; Loading Loading @@ -348,8 +349,7 @@ public class KindSectionView extends LinearLayout { nameValuesDelta, rawContactDelta.getRawContactId(), mListener)); } nameView.setDeletable(false); nameView.setValues( accountType.getKindForMimetype(DataKind.PSEUDO_MIME_TYPE_NAME), nameView.setValues(accountType.getKindForMimetype(DataKind.PSEUDO_MIME_TYPE_NAME), nameValuesDelta, rawContactDelta, /* readOnly =*/ false, mViewIdGenerator); // Correct start margin since there is a second icon in the structured name layout Loading @@ -376,6 +376,8 @@ public class KindSectionView extends LinearLayout { layoutParams.setMargins(0, 0, 0, 0); phoneticNameView.setLayoutParams(layoutParams); mEditors.addView(phoneticNameView); // Display of phonetic name fields is controlled from settings preferences. mHideIfEmpty = new ContactsPreferences(getContext()).shouldHidePhoneticNamesIfEmpty(); } private void addGroupEditorView(RawContactDelta rawContactDelta, DataKind dataKind) { Loading
src/com/android/contacts/preference/ContactsPreferences.java +42 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,8 @@ public class ContactsPreferences implements OnSharedPreferenceChangeListener { public static final boolean PREF_DISPLAY_ONLY_PHONES_DEFAULT = false; public static final String PHONETIC_NAME_DISPLAY_KEY = "Phonetic_name_display"; /** * Value to use when a preference is unassigned and needs to be read from the shared preferences */ Loading @@ -77,6 +79,8 @@ public class ContactsPreferences implements OnSharedPreferenceChangeListener { private final Context mContext; private int mSortOrder = PREFERENCE_UNASSIGNED; private int mDisplayOrder = PREFERENCE_UNASSIGNED; private int mPhoneticNameDisplayPreference = PREFERENCE_UNASSIGNED; private AccountWithDataSet mDefaultAccount = null; private ChangeListener mListener = null; private Handler mHandler; Loading Loading @@ -165,6 +169,34 @@ public class ContactsPreferences implements OnSharedPreferenceChangeListener { mBackupManager.dataChanged(); } public int getDefaultPhoneticNameDisplayPreference() { if (mContext.getResources().getBoolean(R.bool.config_default_hide_phonetic_name_if_empty)) { return PhoneticNameDisplayPreference.HIDE_IF_EMPTY; } else { return PhoneticNameDisplayPreference.SHOW_ALWAYS; } } public void setPhoneticNameDisplayPreference(int phoneticNameDisplayPreference) { mPhoneticNameDisplayPreference = phoneticNameDisplayPreference; final Editor editor = mPreferences.edit(); editor.putInt(PHONETIC_NAME_DISPLAY_KEY, phoneticNameDisplayPreference); editor.commit(); mBackupManager.dataChanged(); } public int getPhoneticNameDisplayPreference() { if (mPhoneticNameDisplayPreference == PREFERENCE_UNASSIGNED) { mPhoneticNameDisplayPreference = mPreferences.getInt(PHONETIC_NAME_DISPLAY_KEY, getDefaultPhoneticNameDisplayPreference()); } return mPhoneticNameDisplayPreference; } public boolean shouldHidePhoneticNamesIfEmpty() { return getPhoneticNameDisplayPreference() == PhoneticNameDisplayPreference.HIDE_IF_EMPTY; } public boolean isDefaultAccountUserChangeable() { return mIsDefaultAccountUserChangeable; } Loading Loading @@ -326,6 +358,16 @@ public class ContactsPreferences implements OnSharedPreferenceChangeListener { setDisplayOrder(displayOrder); } if (!mPreferences.contains(PHONETIC_NAME_DISPLAY_KEY)) { int phoneticNameFieldsDisplay = getDefaultPhoneticNameDisplayPreference(); try { phoneticNameFieldsDisplay = Settings.System.getInt(mContext.getContentResolver(), PHONETIC_NAME_DISPLAY_KEY); } catch (SettingNotFoundException e) { } setPhoneticNameDisplayPreference(phoneticNameFieldsDisplay); } if (!mPreferences.contains(mDefaultAccountKey)) { final SharedPreferences previousPrefs = PreferenceManager.getDefaultSharedPreferences(mContext); Loading