Merge "Update explanation in comments."
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/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;