| Index: blimp/client/app/android/java/src/org/chromium/blimp/input/ImeEditText.java
|
| diff --git a/blimp/client/app/android/java/src/org/chromium/blimp/input/ImeEditText.java b/blimp/client/app/android/java/src/org/chromium/blimp/input/ImeEditText.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..3aeb14d120ac08550458059cc86c97ea20947b94
|
| --- /dev/null
|
| +++ b/blimp/client/app/android/java/src/org/chromium/blimp/input/ImeEditText.java
|
| @@ -0,0 +1,43 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package org.chromium.blimp.input;
|
| +
|
| +import android.content.Context;
|
| +import android.support.v7.app.AlertDialog;
|
| +import android.util.AttributeSet;
|
| +import android.view.KeyEvent;
|
| +import android.widget.EditText;
|
| +
|
| +/**
|
| + * A {@link EditText} contained in a dialog which allows users to enter text.
|
| + * The dialog is dismissed on pressing back button.
|
| + */
|
| +public class ImeEditText extends EditText {
|
| + // The alert dialog that contains this text box.
|
| + private AlertDialog mParentDialog;
|
| +
|
| + public ImeEditText(Context context, AttributeSet attrs) {
|
| + super(context, attrs);
|
| + }
|
| +
|
| + /**
|
| + * Sets the parent view for this view.
|
| + * @param dialog The dialog containing this view.
|
| + */
|
| + public void initialize(AlertDialog dialog) {
|
| + mParentDialog = dialog;
|
| + }
|
| +
|
| + /**
|
| + * Dismiss the text input dialog as soon as back button is pressed.
|
| + */
|
| + @Override
|
| + public boolean dispatchKeyEventPreIme(KeyEvent event) {
|
| + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
| + mParentDialog.dismiss();
|
| + }
|
| + return super.dispatchKeyEventPreIme(event);
|
| + }
|
| +}
|
|
|