summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Attwell <brianattwell@google.com>2014-11-07 16:36:30 -0800
committerBrian Attwell <brianattwell@google.com>2014-11-10 17:50:40 -0800
commit7e67082d3f7c4ab56945040c0e4617b71c7e5f0b (patch)
tree26ea97c16e24c3a3f09854f1226ad900ee9deebe
parentfc2ad4fa3ea7a947b693b635ae3aa51e64568095 (diff)
downloadpackages_apps_Contacts-7e67082d3f7c4ab56945040c0e4617b71c7e5f0b.tar.gz
packages_apps_Contacts-7e67082d3f7c4ab56945040c0e4617b71c7e5f0b.tar.bz2
packages_apps_Contacts-7e67082d3f7c4ab56945040c0e4617b71c7e5f0b.zip
New design for photo editor
The photo editor field now looks like the mocks. It includes a RadioButton that allows users to choose which photo is primary. This RadioButton only appears if more than one raw contact has a photo inside the contact. Additional changes: -fixed non-regression that made it impossible to set some photos as primary -fixed non-regression that made it possible for multiple photos to appear as primary -I fudged with a bunch of padding values in order to compensate for View insets and paddings. This can't always be done perfectly, since some insets/paddings vary based on screen-configuration. I needed to start taking fudging with these paddings in order to make the photo editor look consistent with the other editor fields. This CL doesn't bother ensuring the readonly photo edit field looks good. This will be done in a later CL. Bug: 18004959 Change-Id: I683f3ffa8e7f8683c2c083a2b4592b2b95c58c63
-rw-r--r--res/drawable-hdpi/account_spinner_icon.pngbin324 -> 0 bytes
-rw-r--r--res/drawable-ldrtl-hdpi/account_spinner_icon.pngbin4076 -> 0 bytes
-rw-r--r--res/drawable-ldrtl-mdpi/account_spinner_icon.pngbin4051 -> 0 bytes
-rw-r--r--res/drawable-ldrtl-xhdpi/account_spinner_icon.pngbin4133 -> 0 bytes
-rw-r--r--res/drawable-mdpi/account_spinner_icon.pngbin303 -> 0 bytes
-rw-r--r--res/drawable-xhdpi/account_spinner_icon.pngbin364 -> 0 bytes
-rw-r--r--res/drawable-xxhdpi/account_spinner_icon.pngbin1146 -> 0 bytes
-rw-r--r--res/layout/item_photo_editor.xml95
-rw-r--r--res/values/dimens.xml12
-rw-r--r--res/values/strings.xml12
-rw-r--r--res/values/styles.xml5
-rw-r--r--src/com/android/contacts/activities/PhotoSelectionActivity.java2
-rw-r--r--src/com/android/contacts/detail/PhotoSelectionHandler.java13
-rw-r--r--src/com/android/contacts/editor/ContactEditorFragment.java43
-rw-r--r--src/com/android/contacts/editor/Editor.java1
-rw-r--r--src/com/android/contacts/editor/PhotoActionPopup.java22
-rw-r--r--src/com/android/contacts/editor/PhotoEditorView.java47
17 files changed, 155 insertions, 97 deletions
diff --git a/res/drawable-hdpi/account_spinner_icon.png b/res/drawable-hdpi/account_spinner_icon.png
deleted file mode 100644
index 956638633..000000000
--- a/res/drawable-hdpi/account_spinner_icon.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldrtl-hdpi/account_spinner_icon.png b/res/drawable-ldrtl-hdpi/account_spinner_icon.png
deleted file mode 100644
index ec1f26718..000000000
--- a/res/drawable-ldrtl-hdpi/account_spinner_icon.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldrtl-mdpi/account_spinner_icon.png b/res/drawable-ldrtl-mdpi/account_spinner_icon.png
deleted file mode 100644
index 11b1a3e4d..000000000
--- a/res/drawable-ldrtl-mdpi/account_spinner_icon.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldrtl-xhdpi/account_spinner_icon.png b/res/drawable-ldrtl-xhdpi/account_spinner_icon.png
deleted file mode 100644
index 2c1c59f11..000000000
--- a/res/drawable-ldrtl-xhdpi/account_spinner_icon.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/account_spinner_icon.png b/res/drawable-mdpi/account_spinner_icon.png
deleted file mode 100644
index e159d59d4..000000000
--- a/res/drawable-mdpi/account_spinner_icon.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/account_spinner_icon.png b/res/drawable-xhdpi/account_spinner_icon.png
deleted file mode 100644
index d3d3cacc9..000000000
--- a/res/drawable-xhdpi/account_spinner_icon.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/account_spinner_icon.png b/res/drawable-xxhdpi/account_spinner_icon.png
deleted file mode 100644
index 5f90fbc3b..000000000
--- a/res/drawable-xxhdpi/account_spinner_icon.png
+++ /dev/null
Binary files differ
diff --git a/res/layout/item_photo_editor.xml b/res/layout/item_photo_editor.xml
index e73f4e387..ebf122d1a 100644
--- a/res/layout/item_photo_editor.xml
+++ b/res/layout/item_photo_editor.xml
@@ -4,9 +4,9 @@
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.
@@ -14,40 +14,71 @@
limitations under the License.
-->
-<view
- class="com.android.contacts.editor.PhotoEditorView"
+<view class="com.android.contacts.editor.PhotoEditorView"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:orientation="horizontal"
- >
- <FrameLayout
- android:layout_width="72dp"
- android:layout_height="72dp"
- >
- <ImageView
- android:id="@+id/photo"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:cropToPadding="true"
- android:scaleType="centerCrop"
- android:gravity="start"
- />
- <View
- android:id="@+id/frame"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:clickable="true"
- android:focusable="true"
- android:contentDescription="@string/description_contact_photo"
- android:background="?android:attr/selectableItemBackground"
- />
- </FrameLayout>
+ android:orientation="horizontal" >
+
+ <ImageView
+ android:id="@+id/kind_icon"
+ android:src="@drawable/ic_camera_alt_black_24dp"
+ android:layout_marginTop="8dp"
+ android:contentDescription="@string/photo_section"
+ style="@style/EditKindIconStyle" />
+
+ <!-- Needs 10dp of top padding, in order get a total of 32dp of padding between this view
+ and the previous DataKindSection. Note that EditTexts in other editor.xml files have this
+ padding built in. Similarly, we need to add 4dp of start margin to make up for the padding
+ that an EditText would have in this image's place. -->
<ImageView
- android:id="@+id/photo_triangle_affordance"
- android:src="@drawable/account_spinner_icon"
+ android:id="@+id/photo"
+ android:layout_width="72dip"
+ android:layout_height="72dip"
+ android:cropToPadding="true"
+ android:scaleType="centerCrop"
+ android:layout_marginTop="10dp"
+ android:layout_marginStart="4dp"
+ android:contentDescription="@string/description_contact_photo"
+ android:layout_marginBottom="@dimen/editor_padding_below_photo"
+ android:gravity="start" />
+
+ <!-- We want 16dp for the effective marginStart. So we set 12dp, since the private
+ @android:dimen/control_inset_material already includes 4dp of padding. -->
+ <LinearLayout
+ android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- />
+ android:layout_marginStart="12dp" >
+
+ <!-- The values applied to this button are complicated:
+ 1) We want 16dp internal padding in the button. The background drawable is inset
+ by private @android:dimen/button_inset_horizontal_material=4dp. Therefore,
+ we need paddingStart/End of 20dp.
+ 2) In order to leave enough room for the 32dp RadioButton, this can only be 46dp.
+ This is 2dp less than the default touch target size.
+ 3) This button will appear to be offset by the private
+ @android:dimen/button_inset_vertical_material amount. Therefore, in order to achieve
+ 10dp of apparent top margin, we only need to apply 4dp. -->
+ <Button
+ android:id="@+id/change_button"
+ android:layout_width="wrap_content"
+ android:layout_height="46dp"
+ android:textSize="@dimen/editor_form_text_size"
+ android:textColor="@color/primary_text_color"
+ android:layout_marginTop="4dp"
+ android:paddingStart="20dp"
+ android:paddingEnd="20dp"
+ android:text="@string/change_photo" />
+
+ <!-- Don't explicitly set the layout_height in case we need to rely on text wrapping.
+ For one line, we can expect the height to be 32dp with 16dp text size. -->
+ <RadioButton
+ android:id="@+id/primary_checkbox"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="48dp"
+ android:textSize="@dimen/editor_form_text_size"
+ android:text="@string/primary_photo" />
+ </LinearLayout>
</view>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 53855ba05..df01b1a0a 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -58,10 +58,16 @@
<dimen name="editor_kind_icon_size">24dp</dimen>
<!-- Total width of data-kind icon, including its start and end padding -->
- <dimen name="editor_kind_icon_total_width">72dp</dimen>
+ <dimen name="editor_kind_icon_total_width">68dp</dimen>
- <!-- Padding below every editor view, such as LabeledEditorView -->
- <dimen name="editor_padding_between_editor_views">24dp</dimen>
+ <!-- Padding below every editor view, such as LabeledEditorView. This value is chosen
+ to give 32dp of apparent padding between EditText's in the Raw Contact Editor. -->
+ <dimen name="editor_padding_between_editor_views">20dp</dimen>
+
+ <!-- Padding below the photo editor. This value is larger than
+ editor_padding_between_editor_views, since ImageView's don't have space between the bottom
+ of their visual bottom, like an EditText does. -->
+ <dimen name="editor_padding_below_photo">22dp</dimen>
<!-- Width of the Type-Label in the Editor -->
<dimen name="editor_type_label_width">150dip</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index bd0391746..0ce47866b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -373,9 +373,6 @@
<!-- String describing which account a contact came from when editing it -->
<string name="from_account_format"><xliff:g id="source" example="user@gmail.com">%1$s</xliff:g></string>
- <!-- Checkbox asking the user if they want to display a particular photo for a contact -->
- <string name="use_photo_as_primary">Use this photo</string>
-
<!-- Text used to explain that a contact cannot be edited from the People application since the data is read only [CHAR LIMIT=40] -->
<string name="contact_read_only">Not editable from this app.</string>
@@ -438,6 +435,15 @@
<!-- The button to add an organization field to a contact in the Raw Contact Editor [CHAR LIMIT=15] -->
<string name="group_edit_field_hint_text">Group name</string>
+ <!-- Button used for changing a photo in the Raw Contact Editor [CHAR LIMIT=15] -->
+ <string name="change_photo">Change</string>
+
+ <!-- Content description for the camera icon beside the photo section in the Raw Contact Editor [CHAR LIMIT=NONE] -->
+ <string name="photo_section">Photo section</string>
+
+ <!-- RadioButton that determines whether a raw contact's photo should be used for the entire contact [CHAR LIMIT=15] -->
+ <string name="primary_photo">Primary photo</string>
+
<!-- String describing the Star/Favorite checkbox
Used by AccessibilityService to announce the purpose of the view.
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 1261a7a25..06f1afe76 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -29,6 +29,7 @@
<style name="EditorActivityTheme" parent="@style/PeopleTheme">
<item name="android:listViewStyle">@style/ListViewStyle</item>
<item name="android:actionBarStyle">@style/EditorActionBarStyle</item>
+ <item name="android:colorButtonNormal">@color/background_primary</item>
</style>
<style name="Theme">
@@ -317,7 +318,9 @@
<item name="android:layout_height">24dp</item>
<item name="android:tint">@color/editor_icon_color</item>
<item name="android:layout_marginStart">16dp</item>
- <item name="android:layout_marginEnd">32dp</item>
+ <!-- We want 32dp of padding between these icon's and EditText's. Since EditText's have
+ 4dp of starting padding built in, we set this as 28dp. -->
+ <item name="android:layout_marginEnd">28dp</item>
<item name="android:layout_marginTop">@dimen/editor_kind_icon_top_margin</item>
</style>
</resources>
diff --git a/src/com/android/contacts/activities/PhotoSelectionActivity.java b/src/com/android/contacts/activities/PhotoSelectionActivity.java
index da0d2e4a5..c81c44890 100644
--- a/src/com/android/contacts/activities/PhotoSelectionActivity.java
+++ b/src/com/android/contacts/activities/PhotoSelectionActivity.java
@@ -486,7 +486,7 @@ public class PhotoSelectionActivity extends Activity {
// from the gallery), but with slightly different wording.
// Note: don't worry about this being a read-only contact; this code will not be invoked.
int mode = (mPhotoUri == null) ? PhotoActionPopup.Modes.NO_PHOTO
- : PhotoActionPopup.Modes.PHOTO_DISALLOW_PRIMARY;
+ : PhotoActionPopup.Modes.WRITE_ABLE_PHOTO;
// We don't want to provide a choice to remove the photo for two reasons:
// 1) the UX designs don't call for it
// 2) even if we wanted to, the implementation would be moderately hairy
diff --git a/src/com/android/contacts/detail/PhotoSelectionHandler.java b/src/com/android/contacts/detail/PhotoSelectionHandler.java
index d2363de08..9919773bc 100644
--- a/src/com/android/contacts/detail/PhotoSelectionHandler.java
+++ b/src/com/android/contacts/detail/PhotoSelectionHandler.java
@@ -65,7 +65,7 @@ public abstract class PhotoSelectionHandler implements OnClickListener {
private static final int mDefaultPhotoDim = 720;
protected final Context mContext;
- private final View mPhotoView;
+ private final View mChangeAnchorView;
private final int mPhotoMode;
private final int mPhotoPickSize;
private final Uri mCroppedPhotoUri;
@@ -74,10 +74,10 @@ public abstract class PhotoSelectionHandler implements OnClickListener {
private final boolean mIsDirectoryContact;
private ListPopupWindow mPopup;
- public PhotoSelectionHandler(Context context, View photoView, int photoMode,
+ public PhotoSelectionHandler(Context context, View changeAnchorView, int photoMode,
boolean isDirectoryContact, RawContactDeltaList state) {
mContext = context;
- mPhotoView = photoView;
+ mChangeAnchorView = changeAnchorView;
mPhotoMode = photoMode;
mTempPhotoUri = ContactPhotoUtils.generateTempImageUri(context);
mCroppedPhotoUri = ContactPhotoUtils.generateTempCroppedImageUri(mContext);
@@ -98,7 +98,7 @@ public abstract class PhotoSelectionHandler implements OnClickListener {
if (listener != null) {
if (getWritableEntityIndex() != -1) {
mPopup = PhotoActionPopup.createPopupMenu(
- mContext, mPhotoView, listener, mPhotoMode);
+ mContext, mChangeAnchorView, listener, mPhotoMode);
mPopup.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss() {
@@ -319,11 +319,6 @@ public abstract class PhotoSelectionHandler implements OnClickListener {
public abstract class PhotoActionListener implements PhotoActionPopup.Listener {
@Override
- public void onUseAsPrimaryChosen() {
- // No default implementation.
- }
-
- @Override
public void onRemovePictureChosen() {
// No default implementation.
}
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index ca7151a15..ac8a6418d 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -932,28 +932,28 @@ public class ContactEditorFragment extends Fragment implements
private void bindPhotoHandler(BaseRawContactEditorView editor, AccountType type,
RawContactDeltaList state) {
final int mode;
+ final boolean showIsPrimaryOption;
if (type.areContactsWritable()) {
if (editor.hasSetPhoto()) {
- if (hasMoreThanOnePhoto()) {
- mode = PhotoActionPopup.Modes.PHOTO_ALLOW_PRIMARY;
- } else {
- mode = PhotoActionPopup.Modes.PHOTO_DISALLOW_PRIMARY;
- }
+ mode = PhotoActionPopup.Modes.WRITE_ABLE_PHOTO;
+ showIsPrimaryOption = hasMoreThanOnePhoto();
} else {
mode = PhotoActionPopup.Modes.NO_PHOTO;
+ showIsPrimaryOption = false;
}
+ } else if (editor.hasSetPhoto() && hasMoreThanOnePhoto()) {
+ mode = PhotoActionPopup.Modes.READ_ONLY_PHOTO;
+ showIsPrimaryOption = true;
} else {
- if (editor.hasSetPhoto() && hasMoreThanOnePhoto()) {
- mode = PhotoActionPopup.Modes.READ_ONLY_ALLOW_PRIMARY;
- } else {
- // Read-only and either no photo or the only photo ==> no options
- editor.getPhotoEditor().setEditorListener(null);
- return;
- }
+ // Read-only and either no photo or the only photo ==> no options
+ editor.getPhotoEditor().setEditorListener(null);
+ editor.getPhotoEditor().setShowPrimary(false);
+ return;
}
final PhotoHandler photoHandler = new PhotoHandler(mContext, editor, mode, state);
editor.getPhotoEditor().setEditorListener(
(PhotoHandler.PhotoEditorListener) photoHandler.getListener());
+ editor.getPhotoEditor().setShowPrimary(showIsPrimaryOption);
// Note a newly created raw contact gets some random negative ID, so any value is valid
// here. (i.e. don't check against -1 or anything.)
@@ -1859,6 +1859,17 @@ public class ContactEditorFragment extends Fragment implements
if (requestingEditor != null) {
requestingEditor.setPhotoEntry(photo);
+ // Immediately set all other photos as non-primary. Otherwise the UI can display
+ // multiple photos as "Primary photo".
+ for (int i = 0; i < mContent.getChildCount(); i++) {
+ final View childView = mContent.getChildAt(i);
+ if (childView instanceof BaseRawContactEditorView
+ && childView != requestingEditor) {
+ final BaseRawContactEditorView rawContactEditor
+ = (BaseRawContactEditorView) childView;
+ rawContactEditor.getPhotoEditor().setSuperPrimary(false);
+ }
+ }
} else {
Log.w(TAG, "The contact that requested the photo is no longer present.");
}
@@ -2000,7 +2011,7 @@ public class ContactEditorFragment extends Fragment implements
public PhotoHandler(Context context, BaseRawContactEditorView editor, int photoMode,
RawContactDeltaList state) {
- super(context, editor.getPhotoEditor(), photoMode, false, state);
+ super(context, editor.getPhotoEditor().getChangeAnchorView(), photoMode, false, state);
mEditor = editor;
mRawContactId = editor.getRawContactId();
mPhotoEditorListener = new PhotoEditorListener();
@@ -2030,6 +2041,9 @@ public class ContactEditorFragment extends Fragment implements
if (request == EditorListener.REQUEST_PICK_PHOTO) {
onClick(mEditor.getPhotoEditor());
}
+ if (request == EditorListener.REQUEST_PICK_PRIMARY_PHOTO) {
+ useAsPrimaryChosen();
+ }
}
@Override
@@ -2041,8 +2055,7 @@ public class ContactEditorFragment extends Fragment implements
/**
* User has chosen to set the selected photo as the (super) primary photo
*/
- @Override
- public void onUseAsPrimaryChosen() {
+ public void useAsPrimaryChosen() {
// Set the IsSuperPrimary for each editor
int count = mContent.getChildCount();
for (int i = 0; i < count; i++) {
diff --git a/src/com/android/contacts/editor/Editor.java b/src/com/android/contacts/editor/Editor.java
index 799030936..bda5c6e03 100644
--- a/src/com/android/contacts/editor/Editor.java
+++ b/src/com/android/contacts/editor/Editor.java
@@ -40,6 +40,7 @@ public interface Editor {
*/
public void onRequest(int request);
+ public static final int REQUEST_PICK_PRIMARY_PHOTO = 0;
public static final int REQUEST_PICK_PHOTO = 1;
public static final int FIELD_CHANGED = 2;
public static final int FIELD_TURNED_EMPTY = 3;
diff --git a/src/com/android/contacts/editor/PhotoActionPopup.java b/src/com/android/contacts/editor/PhotoActionPopup.java
index 990388080..14b195b72 100644
--- a/src/com/android/contacts/editor/PhotoActionPopup.java
+++ b/src/com/android/contacts/editor/PhotoActionPopup.java
@@ -40,8 +40,6 @@ public class PhotoActionPopup {
* Bitmask flags to specify which actions should be presented to the user.
*/
public static final class Flags {
- /** If set, show choice to use as primary photo. */
- public static final int ALLOW_PRIMARY = 1;
/** If set, show choice to remove photo. */
public static final int REMOVE_PHOTO = 2;
/** If set, show choices to take a picture with the camera, or pick one from the gallery. */
@@ -59,14 +57,8 @@ public class PhotoActionPopup {
public static final class Modes {
public static final int NO_PHOTO =
Flags.TAKE_OR_PICK_PHOTO;
- public static final int READ_ONLY_ALLOW_PRIMARY =
- Flags.ALLOW_PRIMARY;
- public static final int PHOTO_DISALLOW_PRIMARY =
- Flags.REMOVE_PHOTO |
- Flags.TAKE_OR_PICK_PHOTO |
- Flags.TAKE_OR_PICK_PHOTO_REPLACE_WORDING;
- public static final int PHOTO_ALLOW_PRIMARY =
- Flags.ALLOW_PRIMARY |
+ public static final int READ_ONLY_PHOTO = 0;
+ public static final int WRITE_ABLE_PHOTO =
Flags.REMOVE_PHOTO |
Flags.TAKE_OR_PICK_PHOTO |
Flags.TAKE_OR_PICK_PHOTO_REPLACE_WORDING;
@@ -77,11 +69,6 @@ public class PhotoActionPopup {
// Build choices, depending on the current mode. We assume this Dialog is never called
// if there are NO choices (e.g. a read-only picture is already super-primary)
final ArrayList<ChoiceListItem> choices = new ArrayList<ChoiceListItem>(4);
- // Use as Primary
- if ((mode & Flags.ALLOW_PRIMARY) > 0) {
- choices.add(new ChoiceListItem(ChoiceListItem.ID_USE_AS_PRIMARY,
- context.getString(R.string.use_photo_as_primary)));
- }
// Remove
if ((mode & Flags.REMOVE_PHOTO) > 0) {
choices.add(new ChoiceListItem(ChoiceListItem.ID_REMOVE,
@@ -109,9 +96,6 @@ public class PhotoActionPopup {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final ChoiceListItem choice = choices.get(position);
switch (choice.getId()) {
- case ChoiceListItem.ID_USE_AS_PRIMARY:
- listener.onUseAsPrimaryChosen();
- break;
case ChoiceListItem.ID_REMOVE:
listener.onRemovePictureChosen();
break;
@@ -144,7 +128,6 @@ public class PhotoActionPopup {
private final int mId;
private final String mCaption;
- public static final int ID_USE_AS_PRIMARY = 0;
public static final int ID_TAKE_PHOTO = 1;
public static final int ID_PICK_PHOTO = 2;
public static final int ID_REMOVE = 3;
@@ -165,7 +148,6 @@ public class PhotoActionPopup {
}
public interface Listener {
- void onUseAsPrimaryChosen();
void onRemovePictureChosen();
void onTakePhotoChosen();
void onPickFromGalleryChosen();
diff --git a/src/com/android/contacts/editor/PhotoEditorView.java b/src/com/android/contacts/editor/PhotoEditorView.java
index 2f8b2a5a6..b967b26c1 100644
--- a/src/com/android/contacts/editor/PhotoEditorView.java
+++ b/src/com/android/contacts/editor/PhotoEditorView.java
@@ -24,8 +24,10 @@ import android.provider.ContactsContract.CommonDataKinds.Photo;
import android.provider.ContactsContract.DisplayPhoto;
import android.util.AttributeSet;
import android.view.View;
+import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.RadioButton;
import com.android.contacts.R;
import com.android.contacts.common.ContactPhotoManager.DefaultImageProvider;
@@ -43,11 +45,11 @@ import com.android.contacts.util.ContactPhotoUtils;
public class PhotoEditorView extends LinearLayout implements Editor {
private ImageView mPhotoImageView;
- private View mFrameView;
+ private Button mChangeButton;
+ private RadioButton mPrimaryCheckBox;
private ValuesDelta mEntry;
private EditorListener mListener;
- private View mTriangleAffordance;
private ContactPhotoManager mContactPhotoManager;
private boolean mHasSetPhoto = false;
@@ -64,7 +66,6 @@ public class PhotoEditorView extends LinearLayout implements Editor {
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
- mFrameView.setEnabled(enabled);
}
@Override
@@ -78,10 +79,10 @@ public class PhotoEditorView extends LinearLayout implements Editor {
protected void onFinishInflate() {
super.onFinishInflate();
mContactPhotoManager = ContactPhotoManager.getInstance(mContext);
- mTriangleAffordance = findViewById(R.id.photo_triangle_affordance);
mPhotoImageView = (ImageView) findViewById(R.id.photo);
- mFrameView = findViewById(R.id.frame);
- mFrameView.setOnClickListener(new OnClickListener() {
+ mPrimaryCheckBox = (RadioButton) findViewById(R.id.primary_checkbox);
+ mChangeButton = (Button) findViewById(R.id.change_button);
+ mChangeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mListener != null) {
@@ -89,6 +90,16 @@ public class PhotoEditorView extends LinearLayout implements Editor {
}
}
});
+ // Turn off own state management. We do this ourselves on rotation.
+ mPrimaryCheckBox.setSaveEnabled(false);
+ mPrimaryCheckBox.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (mListener != null) {
+ mListener.onRequest(EditorListener.REQUEST_PICK_PRIMARY_PHOTO);
+ }
+ }
+ });
}
/** {@inheritDoc} */
@@ -106,6 +117,8 @@ public class PhotoEditorView extends LinearLayout implements Editor {
setId(vig.getId(state, kind, values, 0));
+ mPrimaryCheckBox.setChecked(values != null && values.isSuperPrimary());
+
if (values != null) {
// Try decoding photo if actual entry
final byte[] photoBytes = values.getAsByteArray(Photo.PHOTO);
@@ -114,7 +127,6 @@ public class PhotoEditorView extends LinearLayout implements Editor {
photoBytes.length);
mPhotoImageView.setImageBitmap(photo);
- mFrameView.setEnabled(isEnabled());
mHasSetPhoto = true;
mEntry.setFromTemplate(false);
@@ -140,6 +152,14 @@ public class PhotoEditorView extends LinearLayout implements Editor {
}
/**
+ * Whether to display a "Primary photo" RadioButton. This is only needed if there are multiple
+ * candidate photos.
+ */
+ public void setShowPrimary(boolean showPrimaryCheckBox) {
+ mPrimaryCheckBox.setVisibility(showPrimaryCheckBox ? View.VISIBLE : View.GONE);
+ }
+
+ /**
* Return true if a valid {@link Photo} has been set.
*/
public boolean hasSetPhoto() {
@@ -162,7 +182,6 @@ public class PhotoEditorView extends LinearLayout implements Editor {
final Bitmap scaled = Bitmap.createScaledBitmap(photo, size, size, false);
mPhotoImageView.setImageBitmap(scaled);
- mFrameView.setEnabled(isEnabled());
mHasSetPhoto = true;
mEntry.setFromTemplate(false);
@@ -211,7 +230,6 @@ public class PhotoEditorView extends LinearLayout implements Editor {
// Invalid photo, show default "add photo" place-holder
mPhotoImageView.setImageDrawable(
ContactPhotoManager.getDefaultAvatarDrawableForContact(getResources(), false, null));
- mFrameView.setEnabled(!mReadOnly && isEnabled());
mHasSetPhoto = false;
mEntry.setFromTemplate(true);
}
@@ -220,10 +238,6 @@ public class PhotoEditorView extends LinearLayout implements Editor {
@Override
public void setEditorListener(EditorListener listener) {
mListener = listener;
-
- final boolean isPushable = listener != null;
- mTriangleAffordance.setVisibility(isPushable ? View.VISIBLE : View.INVISIBLE);
- mFrameView.setVisibility(isPushable ? View.VISIBLE : View.INVISIBLE);
}
@Override
@@ -245,4 +259,11 @@ public class PhotoEditorView extends LinearLayout implements Editor {
public void clearAllFields() {
resetDefault();
}
+
+ /**
+ * The change drop down menu should be anchored to this view.
+ */
+ public View getChangeAnchorView() {
+ return mChangeButton;
+ }
}