OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.mojo.shell; |
| 6 |
| 7 import android.app.Activity; |
| 8 import android.content.Context; |
| 9 import android.view.View; |
| 10 import android.view.inputmethod.InputMethodManager; |
| 11 |
| 12 import org.chromium.base.CalledByNative; |
| 13 import org.chromium.base.JNINamespace; |
| 14 |
| 15 /** |
| 16 * Interaction with the keyboard. |
| 17 */ |
| 18 @JNINamespace("mojo::shell") |
| 19 public class Keyboard { |
| 20 @CalledByNative |
| 21 private static void showSoftKeyboard(Activity activity) { |
| 22 View v = activity.getCurrentFocus(); |
| 23 InputMethodManager imm = |
| 24 (InputMethodManager) activity.getSystemService(Context.INPUT_MET
HOD_SERVICE); |
| 25 imm.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT); |
| 26 } |
| 27 |
| 28 @CalledByNative |
| 29 private static void hideSoftKeyboard(Activity activity) { |
| 30 View v = activity.getCurrentFocus(); |
| 31 InputMethodManager imm = |
| 32 (InputMethodManager) activity.getSystemService(Context.INPUT_MET
HOD_SERVICE); |
| 33 imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0); |
| 34 } |
| 35 } |
OLD | NEW |