OSDN Git Service

Remove text selector and hide ime on print options close.
authorSvetoslav <svetoslavganov@google.com>
Tue, 15 Jul 2014 19:53:13 +0000 (12:53 -0700)
committerSvetoslav <svetoslavganov@google.com>
Tue, 15 Jul 2014 19:56:02 +0000 (12:56 -0700)
bug:16301754

Change-Id: I69bf09df9976b12c611821737eb4abb794c1df80

packages/PrintSpooler/src/com/android/printspooler/widget/PrintContentView.java

index 555aa97..efb030e 100644 (file)
@@ -22,6 +22,7 @@ import android.util.AttributeSet;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.inputmethod.InputMethodManager;
 import com.android.printspooler.R;
 
 /**
@@ -301,6 +302,7 @@ public final class PrintContentView extends ViewGroup implements View.OnClickLis
             mSummaryContent.setLayerType(View.LAYER_TYPE_HARDWARE, null);
             mDraggableContent.setLayerType(View.LAYER_TYPE_HARDWARE, null);
             mMoreOptionsContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+            ensureImeClosedAndInputFocusCleared();
         }
         if ((mDragProgress > 0 && progress == 0)
                 || (mDragProgress < 1.0f && progress == 1.0f)) {
@@ -351,6 +353,18 @@ public final class PrintContentView extends ViewGroup implements View.OnClickLis
         }
     }
 
+    private void ensureImeClosedAndInputFocusCleared() {
+        View focus = findFocus();
+        if (focus != null) {
+            InputMethodManager imm = (InputMethodManager) mContext.getSystemService(
+                    Context.INPUT_METHOD_SERVICE);
+            if (imm.isActive(focus)) {
+                imm.hideSoftInputFromWindow(getWindowToken(), 0);
+            }
+            focus.clearFocus();
+        }
+    }
+
     private final class DragCallbacks extends ViewDragHelper.Callback {
         @Override
         public boolean tryCaptureView(View child, int pointerId) {