Merge "Remove obsolete assets used in horizontal orientation" 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/ContactLoader.java b/src/com/android/contacts/ContactLoader.java
index 13d4122..fcc6510 100644
--- a/src/com/android/contacts/ContactLoader.java
+++ b/src/com/android/contacts/ContactLoader.java
@@ -1345,6 +1345,10 @@
* contact. If the next load is for a different contact, the cached result will be dropped
*/
public void cacheResult() {
- sCachedResult = new Result(mContact);
+ if (mContact == null) {
+ sCachedResult = null;
+ } else {
+ sCachedResult = new Result(mContact);
+ }
}
}
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/list/JoinContactListFragment.java b/src/com/android/contacts/list/JoinContactListFragment.java
index f8fc4cd..1c526a5 100644
--- a/src/com/android/contacts/list/JoinContactListFragment.java
+++ b/src/com/android/contacts/list/JoinContactListFragment.java
@@ -16,6 +16,7 @@
package com.android.contacts.list;
import com.android.contacts.R;
+import com.android.contacts.list.JoinContactLoader.JoinContactLoaderResult;
import android.app.Activity;
import android.app.LoaderManager.LoaderCallbacks;
@@ -78,13 +79,14 @@
break;
}
case JoinContactListAdapter.PARTITION_ALL_CONTACTS: {
- Cursor suggestionsCursor = ((JoinContactLoader) loader).getSuggestionsCursor();
+ Cursor suggestionsCursor = ((JoinContactLoaderResult) data).suggestionCursor;
onContactListLoaded(suggestionsCursor, data);
break;
}
}
}
+ @Override
public void onLoaderReset(Loader<Cursor> loader) {
}
};
diff --git a/src/com/android/contacts/list/JoinContactLoader.java b/src/com/android/contacts/list/JoinContactLoader.java
index c43560e..beb5208 100644
--- a/src/com/android/contacts/list/JoinContactLoader.java
+++ b/src/com/android/contacts/list/JoinContactLoader.java
@@ -18,19 +18,46 @@
import android.content.Context;
import android.content.CursorLoader;
import android.database.Cursor;
-import android.database.MatrixCursor;
+import android.database.CursorWrapper;
import android.net.Uri;
-import android.util.Log;
/**
* A specialized loader for the Join Contacts UI. It executes two queries:
* join suggestions and (optionally) the full contact list.
+ *
+ * This loader also loads the "suggestion" cursor, which can be accessed with:
+ * {@code ((JoinContactLoaderResult) result).suggestionCursor }
*/
public class JoinContactLoader extends CursorLoader {
private String[] mProjection;
private Uri mSuggestionUri;
- private Cursor mSuggestionsCursor;
+
+ /**
+ * Actual returned class. It's guaranteed that this loader always returns an instance of this
+ * class. This class is needed to tie the lifecycle of the second cursor to that of the
+ * primary one.
+ *
+ * Note we can't change the result type of this loader itself, because CursorLoader
+ * extends AsyncTaskLoader<Cursor>, not AsyncTaskLoader<? extends Cursor>
+ */
+ public static class JoinContactLoaderResult extends CursorWrapper {
+ public final Cursor suggestionCursor;
+
+ public JoinContactLoaderResult(Cursor baseCursor, Cursor suggestionCursor) {
+ super(baseCursor);
+ this.suggestionCursor = suggestionCursor;
+ }
+
+ @Override
+ public void close() {
+ try {
+ suggestionCursor.close();
+ } finally {
+ super.close();
+ }
+ }
+ }
public JoinContactLoader(Context context) {
super(context, null, null, null, null, null);
@@ -46,16 +73,12 @@
this.mProjection = projection;
}
- public Cursor getSuggestionsCursor() {
- return mSuggestionsCursor;
- }
-
@Override
public Cursor loadInBackground() {
// First execute the suggestions query, then call super.loadInBackground
// to load the entire list
- mSuggestionsCursor = getContext().getContentResolver()
+ final Cursor suggestionsCursor = getContext().getContentResolver()
.query(mSuggestionUri, mProjection, null, null, null);
- return super.loadInBackground();
+ return new JoinContactLoaderResult(super.loadInBackground(), suggestionsCursor);
}
}
\ No newline at end of file
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);
}
}