Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(613)

Unified Diff: sky/services/keyboard/org/domokit/keyboard/KeyboardServiceImpl.java

Issue 995613002: Implement a basic IME-aware input element (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/services/keyboard/org/domokit/keyboard/InputConnectionAdaptor.java ('k') | sky/shell/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/services/keyboard/org/domokit/keyboard/KeyboardServiceImpl.java
diff --git a/sky/services/keyboard/org/domokit/keyboard/KeyboardServiceImpl.java b/sky/services/keyboard/org/domokit/keyboard/KeyboardServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..645cbf12efbb59f97a2751d2a85a4037bce6d8fe
--- /dev/null
+++ b/sky/services/keyboard/org/domokit/keyboard/KeyboardServiceImpl.java
@@ -0,0 +1,64 @@
+// Copyright 2015 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.domokit.keyboard;
+
+import android.content.Context;
+import android.view.View;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputConnection;
+import android.view.inputmethod.InputMethodManager;
+
+import org.chromium.mojo.system.Core;
+import org.chromium.mojo.system.MessagePipeHandle;
+import org.chromium.mojo.system.MojoException;
+import org.chromium.mojom.keyboard.KeyboardClient;
+import org.chromium.mojom.keyboard.KeyboardService;
+
+/**
+ * Android implementation of Keyboard.
+ */
+public class KeyboardServiceImpl implements KeyboardService {
+ private static View sActiveView;
+ private static KeyboardClient sActiveClient;
+
+ private Context mContext;
+
+ public KeyboardServiceImpl(Context context, Core core, MessagePipeHandle pipe) {
+ mContext = context;
+
+ KeyboardService.MANAGER.bind(this, pipe);
+ }
+
+ public static void setActiveView(View view) {
+ sActiveView = view;
+ }
+
+ public static InputConnection createInputConnection(EditorInfo outAttrs) {
+ if (sActiveClient == null)
+ return null;
+ return new InputConnectionAdaptor(sActiveView, sActiveClient, outAttrs);
+ }
+
+ @Override
+ public void close() {}
+
+ @Override
+ public void onConnectionError(MojoException e) {}
+
+ @Override
+ public void show(KeyboardClient client) {
+ sActiveClient = client;
+ InputMethodManager imm =
+ (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.restartInput(sActiveView);
+ imm.showSoftInput(sActiveView, InputMethodManager.SHOW_IMPLICIT);
+ }
+
+ public void hide() {
+ InputMethodManager imm =
+ (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(sActiveView.getApplicationWindowToken(), 0);
+ }
+}
« no previous file with comments | « sky/services/keyboard/org/domokit/keyboard/InputConnectionAdaptor.java ('k') | sky/shell/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698