Don't show triangle and on-press state if there is no action
Bug:5265514
Change-Id: Ifc1d3b765f909f0ec7cc7565b9d89de50c4a5549
diff --git a/res/layout/item_photo_editor.xml b/res/layout/item_photo_editor.xml
index a22a535..b1af745 100644
--- a/res/layout/item_photo_editor.xml
+++ b/res/layout/item_photo_editor.xml
@@ -17,25 +17,38 @@
<view
class="com.android.contacts.editor.PhotoEditorView"
xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="48dip"
- android:layout_height="48dip"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
>
+ <FrameLayout
+ android:layout_width="48dip"
+ android:layout_height="48dip"
+ >
+ <ImageView
+ android:id="@+id/photo"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:src="@drawable/ic_contact_picture_holo_light"
+ android:cropToPadding="true"
+ android:scaleType="centerCrop"
+ android:gravity="left"
+ />
+ <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>
<ImageView
- android:id="@+id/photo"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:src="@drawable/ic_contact_picture_holo_light"
- android:cropToPadding="true"
- android:scaleType="centerCrop"
- android:gravity="left"
- />
- <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"
+ android:id="@+id/photo_triangle_affordance"
+ android:src="@drawable/account_spinner_icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom"
/>
</view>
diff --git a/res/layout/raw_contact_editor_view.xml b/res/layout/raw_contact_editor_view.xml
index 1ea781e..c8aa9da 100644
--- a/res/layout/raw_contact_editor_view.xml
+++ b/res/layout/raw_contact_editor_view.xml
@@ -52,24 +52,10 @@
</LinearLayout>
- <LinearLayout
- android:id="@+id/stub_photo"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ <include
+ android:id="@+id/edit_photo"
android:layout_marginRight="8dip"
- android:orientation="horizontal">
-
- <include
- android:id="@+id/edit_photo"
- layout="@layout/item_photo_editor" />
-
- <ImageView
- android:src="@drawable/account_spinner_icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom" />
-
- </LinearLayout>
+ layout="@layout/item_photo_editor" />
</LinearLayout>
diff --git a/res/layout/raw_contact_readonly_editor_view.xml b/res/layout/raw_contact_readonly_editor_view.xml
index aa7d705..998d392 100644
--- a/res/layout/raw_contact_readonly_editor_view.xml
+++ b/res/layout/raw_contact_readonly_editor_view.xml
@@ -42,24 +42,10 @@
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?android:attr/textColorSecondary" />
- <LinearLayout
- android:id="@+id/stub_photo"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ <include
+ android:id="@+id/edit_photo"
android:layout_marginRight="8dip"
- android:orientation="horizontal">
-
- <include
- android:id="@+id/edit_photo"
- layout="@layout/item_photo_editor" />
-
- <ImageView
- android:src="@drawable/account_spinner_icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom" />
-
- </LinearLayout>
+ layout="@layout/item_photo_editor" />
</LinearLayout>
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index a18a93f..b3fb5e9 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -799,6 +799,7 @@
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;
}
}
@@ -882,7 +883,7 @@
// Remove the pressed state from the account header because the user cannot switch accounts
// on an existing contact
final View accountView = editor.findViewById(R.id.account);
- accountView.setBackgroundDrawable(null);
+ accountView.setBackground(null);
accountView.setEnabled(false);
}
diff --git a/src/com/android/contacts/editor/PhotoEditorView.java b/src/com/android/contacts/editor/PhotoEditorView.java
index 0cbe97e..955554c 100644
--- a/src/com/android/contacts/editor/PhotoEditorView.java
+++ b/src/com/android/contacts/editor/PhotoEditorView.java
@@ -16,12 +16,12 @@
package com.android.contacts.editor;
+import com.android.contacts.ContactsUtils;
import com.android.contacts.R;
import com.android.contacts.model.DataKind;
import com.android.contacts.model.EntityDelta;
import com.android.contacts.model.EntityDelta.ValuesDelta;
import com.android.contacts.util.ContactPhotoUtils;
-import com.android.contacts.ContactsUtils;
import android.content.Context;
import android.graphics.Bitmap;
@@ -29,19 +29,20 @@
import android.provider.ContactsContract.CommonDataKinds.Photo;
import android.util.AttributeSet;
import android.view.View;
-import android.widget.FrameLayout;
import android.widget.ImageView;
+import android.widget.LinearLayout;
/**
* Simple editor for {@link Photo}.
*/
-public class PhotoEditorView extends FrameLayout implements Editor {
+public class PhotoEditorView extends LinearLayout implements Editor {
private ImageView mPhotoImageView;
private View mFrameView;
private ValuesDelta mEntry;
private EditorListener mListener;
+ private View mTriangleAffordance;
private boolean mHasSetPhoto = false;
private boolean mReadOnly;
@@ -70,6 +71,7 @@
@Override
protected void onFinishInflate() {
super.onFinishInflate();
+ mTriangleAffordance = findViewById(R.id.photo_triangle_affordance);
mPhotoImageView = (ImageView) findViewById(R.id.photo);
mFrameView = findViewById(R.id.frame);
mFrameView.setOnClickListener(new OnClickListener() {
@@ -123,8 +125,6 @@
return mHasSetPhoto;
}
-
-
/**
* Assign the given {@link Bitmap} as the new value, updating UI and
* readying for persisting through {@link ValuesDelta}.
@@ -176,6 +176,10 @@
@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
diff --git a/src/com/android/contacts/editor/RawContactReadOnlyEditorView.java b/src/com/android/contacts/editor/RawContactReadOnlyEditorView.java
index 2cc5d98..58474ef 100644
--- a/src/com/android/contacts/editor/RawContactReadOnlyEditorView.java
+++ b/src/com/android/contacts/editor/RawContactReadOnlyEditorView.java
@@ -55,7 +55,6 @@
implements OnClickListener {
private LayoutInflater mInflater;
- private View mPhotoStub;
private TextView mName;
private Button mEditExternallyButton;
private ViewGroup mGeneral;
@@ -96,8 +95,6 @@
mInflater = (LayoutInflater)getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
- mPhotoStub = findViewById(R.id.stub_photo);
-
mName = (TextView) findViewById(R.id.read_only_name);
mEditExternallyButton = (Button) findViewById(R.id.button_edit_externally);
mEditExternallyButton.setOnClickListener(this);
@@ -177,13 +174,6 @@
setHasPhotoEditor(hasPhotoEditor);
primary = state.getPrimaryEntry(Photo.CONTENT_ITEM_TYPE);
getPhotoEditor().setValues(kind, primary, state, !type.areContactsWritable(), vig);
- if (!hasPhotoEditor || !getPhotoEditor().hasSetPhoto()) {
- mPhotoStub.setVisibility(View.GONE);
- } else {
- mPhotoStub.setVisibility(View.VISIBLE);
- }
- } else {
- mPhotoStub.setVisibility(View.VISIBLE);
}
// Name