Merge "Avoid the flick based on the change of CallLogProvider."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index a0ca083..94fedf1 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -286,7 +286,9 @@
android:theme="@style/FullyTranslucent.QuickContact"
android:launchMode="singleTop"
android:excludeFromRecents="true"
- android:taskAffinity="android.task.quickcontact">
+ android:taskAffinity="android.task.quickcontact"
+ android:windowSoftInputMode="stateUnchanged"
+ >
<intent-filter>
<action android:name="com.android.contacts.action.QUICK_CONTACT" />
diff --git a/res/layout-finger/quickcontact.xml b/res/layout-finger/quickcontact.xml
index a895a54..340ca3f 100644
--- a/res/layout-finger/quickcontact.xml
+++ b/res/layout-finger/quickcontact.xml
@@ -14,8 +14,10 @@
limitations under the License.
-->
-<RelativeLayout
+<view
xmlns:android="http://schemas.android.com/apk/res/android"
+ class="com.android.contacts.ui.QuickContactWindow$RootLayout"
+ android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/quickcontact_shadow_horiz"
@@ -145,4 +147,4 @@
android:visibility="invisible"
android:src="@drawable/quickcontact_arrow_down" />
-</RelativeLayout>
+</view>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 706b459..041440a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -201,8 +201,8 @@
<!-- Hint text for the organization name when editing -->
<string name="ghostData_company">Company</string>
- <!-- Hint text for the organization position when editing -->
- <string name="ghostData_title">Position</string>
+ <!-- Hint text for the organization title when editing -->
+ <string name="ghostData_title">Title</string>
<!-- Message displayed in a toast when you try to view the details of a contact that
for some reason doesn't exist anymore. -->
diff --git a/src/com/android/contacts/ViewContactActivity.java b/src/com/android/contacts/ViewContactActivity.java
index 1f16715..2e41d80 100644
--- a/src/com/android/contacts/ViewContactActivity.java
+++ b/src/com/android/contacts/ViewContactActivity.java
@@ -320,9 +320,15 @@
return;
}
- // We also have to iterate over the Cursor in the background,
- // as iterating over the Cursor can ANR on large result sets,
- // especially as our ContentProvider is cross-process.
+ // One would think we could just iterate over the Cursor
+ // directly here, as the result set should be small, and we've
+ // already run the query in an AsyncTask, but a lot of ANRs
+ // were being reported in this code nonetheless. See bug
+ // 2539603 for details. The real bug which makes this result
+ // set huge and CPU-heavy may be elsewhere.
+ // TODO: if we keep this async, perhaps the entity iteration
+ // should also be original AsyncTask, rather than ping-ponging
+ // between threads like this.
final ArrayList<Entity> oldEntities = mEntities;
(new AsyncTask<Void, Void, ArrayList<Entity>>() {
@Override
@@ -933,10 +939,16 @@
final boolean duplicatesTitle =
isNameRawContact
&& mDisplayNameSource == DisplayNameSources.ORGANIZATION
- && !hasData;
+ && (!hasData || TextUtils.isEmpty(entry.label));
if (!duplicatesTitle) {
entry.uri = null;
+
+ if (TextUtils.isEmpty(entry.label)) {
+ entry.label = entry.data;
+ entry.data = "";
+ }
+
mOrganizationEntries.add(entry);
}
} else if (Nickname.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) {
diff --git a/src/com/android/contacts/ui/QuickContactWindow.java b/src/com/android/contacts/ui/QuickContactWindow.java
index 4ac787c..6d4ff9b 100644
--- a/src/com/android/contacts/ui/QuickContactWindow.java
+++ b/src/com/android/contacts/ui/QuickContactWindow.java
@@ -34,7 +34,6 @@
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
-import android.content.EntityIterator;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
@@ -59,6 +58,7 @@
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
import android.provider.ContactsContract.CommonDataKinds.Website;
import android.text.TextUtils;
+import android.util.AttributeSet;
import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.Gravity;
@@ -85,6 +85,7 @@
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.ListView;
+import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
@@ -114,6 +115,32 @@
public void onDismiss(QuickContactWindow dialog);
}
+ /**
+ * Custom layout the sole purpose of which is to intercept the BACK key and
+ * close QC even when the soft keyboard is open.
+ */
+ public static class RootLayout extends RelativeLayout {
+
+ QuickContactWindow mQuickContactWindow;
+
+ public RootLayout(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ /**
+ * Intercepts the BACK key event and dismisses QuickContact window.
+ */
+ @Override
+ public boolean dispatchKeyEventPreIme(KeyEvent event) {
+ if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
+ mQuickContactWindow.onBackPressed();
+ return true;
+ } else {
+ return super.dispatchKeyEventPreIme(event);
+ }
+ }
+ }
+
private final Context mContext;
private final LayoutInflater mInflater;
private final WindowManager mWindowManager;
@@ -148,6 +175,7 @@
private ImageView mArrowDown;
private int mMode;
+ private RootLayout mRootView;
private View mHeader;
private HorizontalScrollView mTrackScroll;
private ViewGroup mTrack;
@@ -236,9 +264,16 @@
mWindow = PolicyManager.makeNewWindow(mContext);
mWindow.setCallback(this);
mWindow.setWindowManager(mWindowManager, null, null);
+ mWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED);
mWindow.setContentView(R.layout.quickcontact);
+ mRootView = (RootLayout)mWindow.findViewById(R.id.root);
+ mRootView.mQuickContactWindow = this;
+ mRootView.setFocusable(true);
+ mRootView.setFocusableInTouchMode(true);
+ mRootView.setDescendantFocusability(RootLayout.FOCUS_AFTER_DESCENDANTS);
+
mArrowUp = (ImageView)mWindow.findViewById(R.id.arrow_up);
mArrowDown = (ImageView)mWindow.findViewById(R.id.arrow_down);
@@ -353,6 +388,10 @@
resetTrack();
+ // We need to have a focused view inside the QuickContact window so
+ // that the BACK key event can be intercepted
+ mRootView.requestFocus();
+
mHasValidSocial = false;
mDismissed = false;
mQuerying = true;