Loading res/layout/item_contact_editor.xml +2 −2 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ <!-- Left side color bar --> <ImageView android:id="@+id/color_bar" android:layout_width="5dip" android:layout_width="4dip" android:layout_height="fill_parent" /> Loading Loading @@ -133,7 +133,7 @@ <View android:id="@+id/head_secondary_divider" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_height="1px" android:background="?android:attr/listDivider" /> <TextView Loading res/values-es-rUS/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -119,6 +119,7 @@ <string name="send_to_voicemail_view" msgid="9124400414311776864">"Las llamadas se envían directamente a un correo de voz."</string> <string name="default_ringtone" msgid="9099988849649827972">"Predeterminado"</string> <string name="addPicture" msgid="1594679312161537678">"Agregar ícono"</string> <string name="changePicture">Cambiar icono</string> <string name="removePicture" msgid="3041230993155966350">"Eliminar ícono"</string> <string name="noContacts" msgid="8579310973261953559">"No hay contactos."</string> <string name="noMatchingContacts" msgid="4266283206853990471">"No se encontraron contactos coincidentes."</string> Loading res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -321,6 +321,9 @@ <!-- The button/menu item that allows you to add a picture to a contact --> <string name="addPicture">Add icon</string> <!-- The button/menu item that allows you to change an existing contact picture --> <string name="changePicture">Change icon</string> <!-- The menu item that allows you to remove a picture from a contact --> <string name="removePicture">Remove icon</string> Loading src/com/android/contacts/ui/EditContactActivity.java +107 −13 Original line number Diff line number Diff line Loading @@ -26,9 +26,11 @@ import com.android.contacts.model.EntityModifier; import com.android.contacts.model.EntitySet; import com.android.contacts.model.GoogleSource; import com.android.contacts.model.Sources; import com.android.contacts.model.ContactsSource.EditType; import com.android.contacts.model.Editor.EditorListener; import com.android.contacts.model.EntityDelta.ValuesDelta; import com.android.contacts.ui.widget.ContactEditorView; import com.android.contacts.ui.widget.PhotoEditorView; import com.android.contacts.util.EmptyService; import com.android.contacts.util.WeakAsyncTask; import com.google.android.collect.Lists; Loading Loading @@ -81,6 +83,7 @@ import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; /** * Activity for editing or inserting a contact. Loading Loading @@ -344,26 +347,117 @@ public final class EditContactActivity extends Activity ContactEditorView editor = (ContactEditorView) inflater.inflate( R.layout.item_contact_editor, mContent, false); editor.getPhotoEditor().setEditorListener(new EditorListener() { PhotoEditorView photoEditor = editor.getPhotoEditor(); photoEditor.setEditorListener(new PhotoListener(rawContactId, source.readOnly, photoEditor)); mContent.addView(editor); editor.setState(entity, source); } // Show editor now that we've loaded state mContent.setVisibility(View.VISIBLE); } /** * Class that listens to requests coming from photo editors */ private class PhotoListener implements EditorListener, DialogInterface.OnClickListener { private long mRawContactId; private boolean mReadOnly; private PhotoEditorView mEditor; public PhotoListener(long rawContactId, boolean readOnly, PhotoEditorView editor) { mRawContactId = rawContactId; mReadOnly = readOnly; mEditor = editor; } public void onDeleted(Editor editor) { // Do nothing } public void onRequest(int request) { if (!hasValidState()) return; if (request == EditorListener.REQUEST_PICK_PHOTO) { doPickPhotoAction(rawContactId); if (mEditor.hasSetPhoto()) { // There is an existing photo, offer to remove, replace, or promoto to primary createPhotoDialog().show(); } else if (!mReadOnly) { // No photo set and not read-only, try to set the photo doPickPhotoAction(mRawContactId); } } } }); mContent.addView(editor); editor.setState(entity, source); /** * Prepare dialog for picking a new {@link EditType} or entering a * custom label. This dialog is limited to the valid types as determined * by {@link EntityModifier}. */ public Dialog createPhotoDialog() { Context context = EditContactActivity.this; // Wrap our context to inflate list items using correct theme final Context dialogContext = new ContextThemeWrapper(context, android.R.style.Theme_Light); String[] choices; if (mReadOnly) { choices = new String[1]; choices[0] = getString(R.string.use_photo_as_primary); } else { choices = new String[3]; choices[0] = getString(R.string.use_photo_as_primary); choices[1] = getString(R.string.removePicture); choices[2] = getString(R.string.changePicture); } final ListAdapter adapter = new ArrayAdapter<String>(dialogContext, android.R.layout.simple_list_item_1, choices); // Show editor now that we've loaded state mContent.setVisibility(View.VISIBLE); final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext); builder.setTitle(R.string.attachToContact); builder.setSingleChoiceItems(adapter, -1, this); return builder.create(); } /** * Called when something in the dialog is clicked */ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); switch (which) { case 0: // Set the photo as super primary mEditor.setSuperPrimary(true); // And set all other photos as not super primary int count = mContent.getChildCount(); for (int i = 0; i < count; i++) { View childView = mContent.getChildAt(i); if (childView instanceof ContactEditorView) { ContactEditorView editor = (ContactEditorView) childView; PhotoEditorView photoEditor = editor.getPhotoEditor(); if (!photoEditor.equals(mEditor)) { photoEditor.setSuperPrimary(false); } } } break; case 1: // Remove the photo mEditor.setPhotoBitmap(null); break; case 2: // Pick a new photo for the contact doPickPhotoAction(mRawContactId); break; } } } /** {@inheritDoc} */ Loading src/com/android/contacts/ui/widget/ContactEditorView.java +23 −7 Original line number Diff line number Diff line Loading @@ -63,12 +63,14 @@ public class ContactEditorView extends LinearLayout implements OnClickListener { private TextView mReadOnlyName; private PhotoEditorView mPhoto; private View mPhotoStub; private GenericEditorView mName; private boolean mHasPhotoEditor = false; private ViewGroup mGeneral; private ViewGroup mSecondary; private boolean mSecondaryVisible; private TextView mSecondaryHeader; Loading Loading @@ -100,6 +102,7 @@ public class ContactEditorView extends LinearLayout implements OnClickListener { Context.LAYOUT_INFLATER_SERVICE); mPhoto = (PhotoEditorView)findViewById(R.id.edit_photo); mPhotoStub = findViewById(R.id.stub_photo); final int photoSize = getResources().getDimensionPixelSize(R.dimen.edit_photo_size); Loading Loading @@ -171,6 +174,7 @@ public class ContactEditorView extends LinearLayout implements OnClickListener { mSecondary.setVisibility(makeVisible ? View.VISIBLE : View.GONE); mSecondaryHeader.setCompoundDrawablesWithIntrinsicBounds(makeVisible ? mSecondaryOpen : mSecondaryClosed, null, null, null); mSecondaryVisible = makeVisible; } /** Loading Loading @@ -218,16 +222,12 @@ public class ContactEditorView extends LinearLayout implements OnClickListener { // Show and hide the appropriate views if (readOnly) { mGeneral.setVisibility(View.GONE); mSecondary.setVisibility(View.GONE); mSecondaryHeader.setVisibility(View.GONE); mName.setVisibility(View.GONE); mReadOnly.setVisibility(View.VISIBLE); mReadOnly.setText(mContext.getString(R.string.contact_read_only, accountType)); mReadOnlyName.setVisibility(View.VISIBLE); } else { mGeneral.setVisibility(View.VISIBLE); mSecondary.setVisibility(View.VISIBLE); mSecondaryHeader.setVisibility(View.VISIBLE); mName.setVisibility(View.VISIBLE); mReadOnly.setVisibility(View.GONE); mReadOnlyName.setVisibility(View.GONE); Loading @@ -252,6 +252,11 @@ public class ContactEditorView extends LinearLayout implements OnClickListener { // Handle special case editor for photos final ValuesDelta primary = state.getPrimaryEntry(mimeType); mPhoto.setValues(kind, primary, state, source.readOnly); if (readOnly && !mPhoto.hasSetPhoto()) { mPhotoStub.setVisibility(View.GONE); } else { mPhotoStub.setVisibility(View.VISIBLE); } } else if (!readOnly) { // Otherwise use generic section-based editors if (kind.fieldList == null) continue; Loading @@ -263,9 +268,20 @@ public class ContactEditorView extends LinearLayout implements OnClickListener { parent.addView(section); } } final int secondaryVisibility = mSecondary.getChildCount() > 0 ? View.VISIBLE : View.GONE; mSecondary.setVisibility(secondaryVisibility); mSecondaryHeader.setVisibility(secondaryVisibility); if (!readOnly && mSecondary.getChildCount() > 0) { // There exist secondary elements, show the header and honor mSecondaryVisible mSecondaryHeader.setVisibility(View.VISIBLE); if (mSecondaryVisible) { mSecondary.setVisibility(View.VISIBLE); } else { mSecondary.setVisibility(View.GONE); } } else { // There are no secondary elements, hide the whole thing mSecondaryHeader.setVisibility(View.GONE); mSecondary.setVisibility(View.GONE); } } /** Loading Loading
res/layout/item_contact_editor.xml +2 −2 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ <!-- Left side color bar --> <ImageView android:id="@+id/color_bar" android:layout_width="5dip" android:layout_width="4dip" android:layout_height="fill_parent" /> Loading Loading @@ -133,7 +133,7 @@ <View android:id="@+id/head_secondary_divider" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_height="1px" android:background="?android:attr/listDivider" /> <TextView Loading
res/values-es-rUS/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -119,6 +119,7 @@ <string name="send_to_voicemail_view" msgid="9124400414311776864">"Las llamadas se envían directamente a un correo de voz."</string> <string name="default_ringtone" msgid="9099988849649827972">"Predeterminado"</string> <string name="addPicture" msgid="1594679312161537678">"Agregar ícono"</string> <string name="changePicture">Cambiar icono</string> <string name="removePicture" msgid="3041230993155966350">"Eliminar ícono"</string> <string name="noContacts" msgid="8579310973261953559">"No hay contactos."</string> <string name="noMatchingContacts" msgid="4266283206853990471">"No se encontraron contactos coincidentes."</string> Loading
res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -321,6 +321,9 @@ <!-- The button/menu item that allows you to add a picture to a contact --> <string name="addPicture">Add icon</string> <!-- The button/menu item that allows you to change an existing contact picture --> <string name="changePicture">Change icon</string> <!-- The menu item that allows you to remove a picture from a contact --> <string name="removePicture">Remove icon</string> Loading
src/com/android/contacts/ui/EditContactActivity.java +107 −13 Original line number Diff line number Diff line Loading @@ -26,9 +26,11 @@ import com.android.contacts.model.EntityModifier; import com.android.contacts.model.EntitySet; import com.android.contacts.model.GoogleSource; import com.android.contacts.model.Sources; import com.android.contacts.model.ContactsSource.EditType; import com.android.contacts.model.Editor.EditorListener; import com.android.contacts.model.EntityDelta.ValuesDelta; import com.android.contacts.ui.widget.ContactEditorView; import com.android.contacts.ui.widget.PhotoEditorView; import com.android.contacts.util.EmptyService; import com.android.contacts.util.WeakAsyncTask; import com.google.android.collect.Lists; Loading Loading @@ -81,6 +83,7 @@ import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; /** * Activity for editing or inserting a contact. Loading Loading @@ -344,26 +347,117 @@ public final class EditContactActivity extends Activity ContactEditorView editor = (ContactEditorView) inflater.inflate( R.layout.item_contact_editor, mContent, false); editor.getPhotoEditor().setEditorListener(new EditorListener() { PhotoEditorView photoEditor = editor.getPhotoEditor(); photoEditor.setEditorListener(new PhotoListener(rawContactId, source.readOnly, photoEditor)); mContent.addView(editor); editor.setState(entity, source); } // Show editor now that we've loaded state mContent.setVisibility(View.VISIBLE); } /** * Class that listens to requests coming from photo editors */ private class PhotoListener implements EditorListener, DialogInterface.OnClickListener { private long mRawContactId; private boolean mReadOnly; private PhotoEditorView mEditor; public PhotoListener(long rawContactId, boolean readOnly, PhotoEditorView editor) { mRawContactId = rawContactId; mReadOnly = readOnly; mEditor = editor; } public void onDeleted(Editor editor) { // Do nothing } public void onRequest(int request) { if (!hasValidState()) return; if (request == EditorListener.REQUEST_PICK_PHOTO) { doPickPhotoAction(rawContactId); if (mEditor.hasSetPhoto()) { // There is an existing photo, offer to remove, replace, or promoto to primary createPhotoDialog().show(); } else if (!mReadOnly) { // No photo set and not read-only, try to set the photo doPickPhotoAction(mRawContactId); } } } }); mContent.addView(editor); editor.setState(entity, source); /** * Prepare dialog for picking a new {@link EditType} or entering a * custom label. This dialog is limited to the valid types as determined * by {@link EntityModifier}. */ public Dialog createPhotoDialog() { Context context = EditContactActivity.this; // Wrap our context to inflate list items using correct theme final Context dialogContext = new ContextThemeWrapper(context, android.R.style.Theme_Light); String[] choices; if (mReadOnly) { choices = new String[1]; choices[0] = getString(R.string.use_photo_as_primary); } else { choices = new String[3]; choices[0] = getString(R.string.use_photo_as_primary); choices[1] = getString(R.string.removePicture); choices[2] = getString(R.string.changePicture); } final ListAdapter adapter = new ArrayAdapter<String>(dialogContext, android.R.layout.simple_list_item_1, choices); // Show editor now that we've loaded state mContent.setVisibility(View.VISIBLE); final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext); builder.setTitle(R.string.attachToContact); builder.setSingleChoiceItems(adapter, -1, this); return builder.create(); } /** * Called when something in the dialog is clicked */ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); switch (which) { case 0: // Set the photo as super primary mEditor.setSuperPrimary(true); // And set all other photos as not super primary int count = mContent.getChildCount(); for (int i = 0; i < count; i++) { View childView = mContent.getChildAt(i); if (childView instanceof ContactEditorView) { ContactEditorView editor = (ContactEditorView) childView; PhotoEditorView photoEditor = editor.getPhotoEditor(); if (!photoEditor.equals(mEditor)) { photoEditor.setSuperPrimary(false); } } } break; case 1: // Remove the photo mEditor.setPhotoBitmap(null); break; case 2: // Pick a new photo for the contact doPickPhotoAction(mRawContactId); break; } } } /** {@inheritDoc} */ Loading
src/com/android/contacts/ui/widget/ContactEditorView.java +23 −7 Original line number Diff line number Diff line Loading @@ -63,12 +63,14 @@ public class ContactEditorView extends LinearLayout implements OnClickListener { private TextView mReadOnlyName; private PhotoEditorView mPhoto; private View mPhotoStub; private GenericEditorView mName; private boolean mHasPhotoEditor = false; private ViewGroup mGeneral; private ViewGroup mSecondary; private boolean mSecondaryVisible; private TextView mSecondaryHeader; Loading Loading @@ -100,6 +102,7 @@ public class ContactEditorView extends LinearLayout implements OnClickListener { Context.LAYOUT_INFLATER_SERVICE); mPhoto = (PhotoEditorView)findViewById(R.id.edit_photo); mPhotoStub = findViewById(R.id.stub_photo); final int photoSize = getResources().getDimensionPixelSize(R.dimen.edit_photo_size); Loading Loading @@ -171,6 +174,7 @@ public class ContactEditorView extends LinearLayout implements OnClickListener { mSecondary.setVisibility(makeVisible ? View.VISIBLE : View.GONE); mSecondaryHeader.setCompoundDrawablesWithIntrinsicBounds(makeVisible ? mSecondaryOpen : mSecondaryClosed, null, null, null); mSecondaryVisible = makeVisible; } /** Loading Loading @@ -218,16 +222,12 @@ public class ContactEditorView extends LinearLayout implements OnClickListener { // Show and hide the appropriate views if (readOnly) { mGeneral.setVisibility(View.GONE); mSecondary.setVisibility(View.GONE); mSecondaryHeader.setVisibility(View.GONE); mName.setVisibility(View.GONE); mReadOnly.setVisibility(View.VISIBLE); mReadOnly.setText(mContext.getString(R.string.contact_read_only, accountType)); mReadOnlyName.setVisibility(View.VISIBLE); } else { mGeneral.setVisibility(View.VISIBLE); mSecondary.setVisibility(View.VISIBLE); mSecondaryHeader.setVisibility(View.VISIBLE); mName.setVisibility(View.VISIBLE); mReadOnly.setVisibility(View.GONE); mReadOnlyName.setVisibility(View.GONE); Loading @@ -252,6 +252,11 @@ public class ContactEditorView extends LinearLayout implements OnClickListener { // Handle special case editor for photos final ValuesDelta primary = state.getPrimaryEntry(mimeType); mPhoto.setValues(kind, primary, state, source.readOnly); if (readOnly && !mPhoto.hasSetPhoto()) { mPhotoStub.setVisibility(View.GONE); } else { mPhotoStub.setVisibility(View.VISIBLE); } } else if (!readOnly) { // Otherwise use generic section-based editors if (kind.fieldList == null) continue; Loading @@ -263,9 +268,20 @@ public class ContactEditorView extends LinearLayout implements OnClickListener { parent.addView(section); } } final int secondaryVisibility = mSecondary.getChildCount() > 0 ? View.VISIBLE : View.GONE; mSecondary.setVisibility(secondaryVisibility); mSecondaryHeader.setVisibility(secondaryVisibility); if (!readOnly && mSecondary.getChildCount() > 0) { // There exist secondary elements, show the header and honor mSecondaryVisible mSecondaryHeader.setVisibility(View.VISIBLE); if (mSecondaryVisible) { mSecondary.setVisibility(View.VISIBLE); } else { mSecondary.setVisibility(View.GONE); } } else { // There are no secondary elements, hide the whole thing mSecondaryHeader.setVisibility(View.GONE); mSecondary.setVisibility(View.GONE); } } /** Loading