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

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/DesktopView.java

Issue 2293693002: [Remoting Android] Enable Rich Input Support
Patch Set: Merge ToT Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chromoting; 5 package org.chromium.chromoting;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.text.InputType; 8 import android.text.InputType;
9 import android.util.AttributeSet; 9 import android.util.AttributeSet;
10 import android.view.KeyEvent;
10 import android.view.MotionEvent; 11 import android.view.MotionEvent;
11 import android.view.SurfaceView; 12 import android.view.SurfaceView;
13 import android.view.inputmethod.BaseInputConnection;
12 import android.view.inputmethod.EditorInfo; 14 import android.view.inputmethod.EditorInfo;
13 import android.view.inputmethod.InputConnection; 15 import android.view.inputmethod.InputConnection;
14 import android.view.inputmethod.InputMethodManager; 16 import android.view.inputmethod.InputMethodManager;
15 17
16 import org.chromium.chromoting.jni.Client; 18 import org.chromium.chromoting.jni.Client;
17 19
18 /** 20 /**
19 * The class for viewing and interacting with a specific remote host. 21 * The class for viewing and interacting with a specific remote host.
20 */ 22 */
21 public final class DesktopView extends SurfaceView { 23 public final class DesktopView extends SurfaceView {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 81 }
80 82
81 /** An {@link Event} which is triggered when user touches the screen. */ 83 /** An {@link Event} which is triggered when user touches the screen. */
82 public final Event<TouchEventParameter> onTouch() { 84 public final Event<TouchEventParameter> onTouch() {
83 return mOnTouch; 85 return mOnTouch;
84 } 86 }
85 87
86 /** Called when a software keyboard is requested, and specifies its options. */ 88 /** Called when a software keyboard is requested, and specifies its options. */
87 @Override 89 @Override
88 public final InputConnection onCreateInputConnection(EditorInfo outAttrs) { 90 public final InputConnection onCreateInputConnection(EditorInfo outAttrs) {
89 // Disables rich input support and instead requests simple key events. 91 // Enable rich input support and disable suggestions.
90 outAttrs.inputType = InputType.TYPE_NULL; 92 outAttrs.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLA G_NO_SUGGESTIONS;
91 93
92 // Prevents most third-party IMEs from ignoring our Activity's adjustRes ize preference. 94 // Prevents most third-party IMEs from ignoring our Activity's adjustRes ize preference.
93 outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_FULLSCREEN; 95 outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_FULLSCREEN;
94 96
95 // Ensures that keyboards will not decide to hide the remote desktop on small displays. 97 // Ensures that keyboards will not decide to hide the remote desktop on small displays.
96 outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_EXTRACT_UI; 98 outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_EXTRACT_UI;
97 99
98 // Stops software keyboards from closing as soon as the enter key is pre ssed. 100 // Stops software keyboards from closing as soon as the enter key is pre ssed.
99 outAttrs.imeOptions |= EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_ NO_ENTER_ACTION; 101 outAttrs.imeOptions |= EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_ NO_ENTER_ACTION;
100 102
101 return null; 103 return new BaseInputConnection(this, false) {
104 public boolean deleteSurroundingText(int beforeLength, int afterLeng th) {
105 // This is to fix the backspace functionality of the soft keyboa rd. The default
106 // connection will try to delete the last character in the conte xt while DesktopView
107 // doesn't have a text context so we need to manually handle the backspace case.
108 if (beforeLength == 1 && afterLength == 0) {
109 return sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEv ent.KEYCODE_DEL))
110 && sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, Key Event.KEYCODE_DEL));
111 }
112 return super.deleteSurroundingText(beforeLength, afterLength);
113 }
114 };
102 } 115 }
103 116
104 /** Called whenever the user attempts to touch the canvas. */ 117 /** Called whenever the user attempts to touch the canvas. */
105 @Override 118 @Override
106 public final boolean onTouchEvent(MotionEvent event) { 119 public final boolean onTouchEvent(MotionEvent event) {
107 TouchEventParameter parameter = new TouchEventParameter(event); 120 TouchEventParameter parameter = new TouchEventParameter(event);
108 mOnTouch.raise(parameter); 121 mOnTouch.raise(parameter);
109 return parameter.handled; 122 return parameter.handled;
110 } 123 }
111 } 124 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698