Merge "Add press-states to ContactDetailFragment." into jb-dev
diff --git a/res/layout/carousel_about_tab.xml b/res/layout/carousel_about_tab.xml
index e033a6f..dc261d2 100644
--- a/res/layout/carousel_about_tab.xml
+++ b/res/layout/carousel_about_tab.xml
@@ -32,6 +32,13 @@
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"/>
+ <View android:id="@+id/photo_overlay"
+ android:background="?android:attr/selectableItemBackground"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentLeft="true"/>
+
<!-- Transparent view to overlay on the contact's photo
(to allow white text to appear over a white photo). -->
<View android:id="@+id/label_background"
diff --git a/src/com/android/contacts/detail/ContactDetailTabCarousel.java b/src/com/android/contacts/detail/ContactDetailTabCarousel.java
index b0b3dc4..1e20689 100644
--- a/src/com/android/contacts/detail/ContactDetailTabCarousel.java
+++ b/src/com/android/contacts/detail/ContactDetailTabCarousel.java
@@ -61,6 +61,7 @@
private int mTabShadowHeight;
private ImageView mPhotoView;
+ private View mPhotoViewOverlay;
private TextView mStatusView;
private ImageView mStatusPhotoView;
private final ContactDetailPhotoSetter mPhotoSetter = new ContactDetailPhotoSetter();
@@ -136,6 +137,7 @@
// Retrieve the photo view for the "about" tab
// TODO: This should be moved down to mAboutTab, so that it hosts its own controls
mPhotoView = (ImageView) mAboutTab.findViewById(R.id.photo);
+ mPhotoViewOverlay = mAboutTab.findViewById(R.id.photo_overlay);
// Retrieve the social update views for the "updates" tab
// TODO: This should be moved down to mUpdatesTab, so that it hosts its own controls
@@ -466,11 +468,11 @@
mContext, contactData, mPhotoView, expandOnClick);
if (expandOnClick || contactData.isWritableContact(mContext)) {
- mPhotoView.setOnClickListener(listener);
+ mPhotoViewOverlay.setOnClickListener(listener);
} else {
// Work around framework issue... if we instead use
// setClickable(false), then we can't swipe horizontally.
- mPhotoView.setOnClickListener(null);
+ mPhotoViewOverlay.setOnClickListener(null);
}
ContactDetailDisplayUtils.setSocialSnippet(
diff --git a/src/com/android/contacts/widget/AlphaTouchInterceptorOverlay.java b/src/com/android/contacts/widget/AlphaTouchInterceptorOverlay.java
index 5418435..a7d219c 100644
--- a/src/com/android/contacts/widget/AlphaTouchInterceptorOverlay.java
+++ b/src/com/android/contacts/widget/AlphaTouchInterceptorOverlay.java
@@ -17,9 +17,11 @@
package com.android.contacts.widget;
import com.android.contacts.detail.ContactDetailDisplayUtils;
+import com.android.contacts.util.ThemeUtils;
import android.content.Context;
import android.view.View;
+import android.widget.FrameLayout;
/**
* A View that other Views can use to create a touch-interceptor layer above
@@ -37,16 +39,21 @@
* Typically, you would not use this class directly, but rather use another class
* that uses it, for example {@link FrameLayoutWithOverlay}.
*/
-public class AlphaTouchInterceptorOverlay extends View {
+public class AlphaTouchInterceptorOverlay extends FrameLayout {
- private View mAlphaLayer = this;
- private float mAlpha = 1.0f;
+ private View mInterceptorLayer;
+ private View mAlphaLayer;
+ private float mAlpha = 0.0f;
public AlphaTouchInterceptorOverlay(Context context) {
super(context);
- setAlphaLayer(this);
- setVisibility(VISIBLE);
- ContactDetailDisplayUtils.setAlphaOnViewBackground(this, 1.0f);
+
+ mInterceptorLayer = new View(context);
+ final int resId = ThemeUtils.getSelectableItemBackground(context.getTheme());
+ mInterceptorLayer.setBackgroundResource(resId);
+ addView(mInterceptorLayer);
+
+ mAlphaLayer = this;
}
/**
@@ -60,6 +67,7 @@
// We're no longer the alpha-layer, so make ourself invisible.
if (mAlphaLayer == this) ContactDetailDisplayUtils.setAlphaOnViewBackground(this, 0.0f);
+
mAlphaLayer = (alphaLayer == null) ? this : alphaLayer;
setAlphaLayerValue(mAlpha);
}
@@ -67,6 +75,18 @@
/** Sets the alpha value on the alpha layer. */
public void setAlphaLayerValue(float alpha) {
mAlpha = alpha;
- ContactDetailDisplayUtils.setAlphaOnViewBackground(mAlphaLayer, mAlpha);
+ if (mAlphaLayer != null) {
+ ContactDetailDisplayUtils.setAlphaOnViewBackground(mAlphaLayer, mAlpha);
+ }
+ }
+
+ /** Delegate to interceptor-layer. */
+ public void setOverlayOnClickListener(OnClickListener listener) {
+ mInterceptorLayer.setOnClickListener(listener);
+ }
+
+ /** Delegate to interceptor-layer. */
+ public void setOverlayClickable(boolean clickable) {
+ mInterceptorLayer.setClickable(clickable);
}
}
diff --git a/src/com/android/contacts/widget/FrameLayoutWithOverlay.java b/src/com/android/contacts/widget/FrameLayoutWithOverlay.java
index b4cd810..6d7106b 100644
--- a/src/com/android/contacts/widget/FrameLayoutWithOverlay.java
+++ b/src/com/android/contacts/widget/FrameLayoutWithOverlay.java
@@ -22,7 +22,6 @@
import android.view.ViewGroup;
import android.widget.FrameLayout;
-
/**
* A FrameLayout whose contents are kept beneath an {@link AlphaTouchInterceptorOverlay}.
* If necessary, you can specify your own alpha-layer and manually manage its z-order.
@@ -47,8 +46,8 @@
}
/**
- * Delegate to overlay: set the View that it will use as it's alpha-layer.
- * If none is set, the overlay will use itself as the alpha layer. Only
+ * Delegate to overlay: set the View that it will use as its alpha-layer.
+ * If none is set, the overlay will use its own alpha layer. Only
* necessary to set this if some child views need to appear above the
* alpha-layer.
*/
@@ -63,11 +62,11 @@
/** Delegate to overlay. */
public void setOverlayOnClickListener(OnClickListener listener) {
- mOverlay.setOnClickListener(listener);
+ mOverlay.setOverlayOnClickListener(listener);
}
/** Delegate to overlay. */
public void setOverlayClickable(boolean clickable) {
- mOverlay.setClickable(clickable);
+ mOverlay.setOverlayClickable(clickable);
}
}