2010-12-02 09:46:21 +00:00
|
|
|
/*
|
2011-05-20 03:09:57 +00:00
|
|
|
* Copyright (C) 2010 The Android Open Source Project
|
2010-12-02 09:46:21 +00:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
|
|
* use this file except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations under
|
|
|
|
* the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.android.inputmethod.keyboard;
|
|
|
|
|
2012-08-21 05:05:57 +00:00
|
|
|
import com.android.inputmethod.latin.Constants;
|
2012-06-12 10:40:37 +00:00
|
|
|
import com.android.inputmethod.latin.InputPointers;
|
|
|
|
|
2010-12-02 09:46:21 +00:00
|
|
|
public interface KeyboardActionListener {
|
|
|
|
|
|
|
|
/**
|
2010-12-30 16:35:24 +00:00
|
|
|
* Called when the user presses a key. This is sent before the {@link #onCodeInput} is called.
|
|
|
|
* For keys that repeat, this is only called once.
|
2010-12-02 09:46:21 +00:00
|
|
|
*
|
2010-12-30 16:35:24 +00:00
|
|
|
* @param primaryCode the unicode of the key being pressed. If the touch is not on a valid key,
|
|
|
|
* the value will be zero.
|
2010-12-02 09:46:21 +00:00
|
|
|
*/
|
2012-01-17 08:08:26 +00:00
|
|
|
public void onPressKey(int primaryCode);
|
2010-12-02 09:46:21 +00:00
|
|
|
|
|
|
|
/**
|
2010-12-30 16:35:24 +00:00
|
|
|
* Called when the user releases a key. This is sent after the {@link #onCodeInput} is called.
|
|
|
|
* For keys that repeat, this is only called once.
|
2010-12-02 09:46:21 +00:00
|
|
|
*
|
2010-12-30 16:35:24 +00:00
|
|
|
* @param primaryCode the code of the key that was released
|
2011-03-02 19:43:13 +00:00
|
|
|
* @param withSliding true if releasing has occurred because the user slid finger from the key
|
|
|
|
* to other key without releasing the finger.
|
2010-12-02 09:46:21 +00:00
|
|
|
*/
|
2012-01-17 08:08:26 +00:00
|
|
|
public void onReleaseKey(int primaryCode, boolean withSliding);
|
2010-12-02 09:46:21 +00:00
|
|
|
|
|
|
|
/**
|
2010-12-20 07:13:57 +00:00
|
|
|
* Send a key code to the listener.
|
2010-12-02 09:46:21 +00:00
|
|
|
*
|
2010-12-30 16:35:24 +00:00
|
|
|
* @param primaryCode this is the code of the key that was pressed
|
|
|
|
* @param x x-coordinate pixel of touched event. If {@link #onCodeInput} is not called by
|
2012-08-21 05:05:57 +00:00
|
|
|
* {@link PointerTracker} or so, the value should be
|
|
|
|
* {@link Constants#NOT_A_COORDINATE}. If it's called on insertion from the
|
|
|
|
* suggestion strip, it should be {@link Constants#SUGGESTION_STRIP_COORDINATE}.
|
2010-12-30 16:35:24 +00:00
|
|
|
* @param y y-coordinate pixel of touched event. If {@link #onCodeInput} is not called by
|
2012-08-21 05:05:57 +00:00
|
|
|
* {@link PointerTracker} or so, the value should be
|
|
|
|
* {@link Constants#NOT_A_COORDINATE}.If it's called on insertion from the
|
|
|
|
* suggestion strip, it should be {@link Constants#SUGGESTION_STRIP_COORDINATE}.
|
2010-12-02 09:46:21 +00:00
|
|
|
*/
|
2012-03-06 05:56:46 +00:00
|
|
|
public void onCodeInput(int primaryCode, int x, int y);
|
2010-12-30 16:35:24 +00:00
|
|
|
|
2010-12-02 09:46:21 +00:00
|
|
|
/**
|
|
|
|
* Sends a sequence of characters to the listener.
|
|
|
|
*
|
2010-12-30 16:35:24 +00:00
|
|
|
* @param text the sequence of characters to be displayed.
|
2010-12-02 09:46:21 +00:00
|
|
|
*/
|
2010-12-30 16:35:24 +00:00
|
|
|
public void onTextInput(CharSequence text);
|
2010-12-02 09:46:21 +00:00
|
|
|
|
2012-07-04 06:24:59 +00:00
|
|
|
/**
|
|
|
|
* Called when user started batch input.
|
|
|
|
*/
|
|
|
|
public void onStartBatchInput();
|
|
|
|
|
2012-06-12 10:40:37 +00:00
|
|
|
/**
|
2012-07-18 09:14:51 +00:00
|
|
|
* Sends the ongoing batch input points data.
|
2012-06-12 10:40:37 +00:00
|
|
|
* @param batchPointers the batch input points representing the user input
|
|
|
|
*/
|
2012-07-18 09:14:51 +00:00
|
|
|
public void onUpdateBatchInput(InputPointers batchPointers);
|
2012-06-12 10:40:37 +00:00
|
|
|
|
2012-07-04 06:24:59 +00:00
|
|
|
/**
|
2012-07-18 09:14:51 +00:00
|
|
|
* Sends the final batch input points data.
|
2012-07-04 06:24:59 +00:00
|
|
|
*
|
2012-07-18 09:14:51 +00:00
|
|
|
* @param batchPointers the batch input points representing the user input
|
2012-07-04 06:24:59 +00:00
|
|
|
*/
|
2012-07-18 09:14:51 +00:00
|
|
|
public void onEndBatchInput(InputPointers batchPointers);
|
2012-07-04 06:24:59 +00:00
|
|
|
|
2010-12-02 09:46:21 +00:00
|
|
|
/**
|
|
|
|
* Called when user released a finger outside any key.
|
|
|
|
*/
|
2010-12-30 16:35:24 +00:00
|
|
|
public void onCancelInput();
|
2011-08-06 01:45:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Send a non-"code input" custom request to the listener.
|
|
|
|
* @return true if the request has been consumed, false otherwise.
|
|
|
|
*/
|
|
|
|
public boolean onCustomRequest(int requestCode);
|
2011-08-29 10:09:56 +00:00
|
|
|
|
|
|
|
public static class Adapter implements KeyboardActionListener {
|
|
|
|
@Override
|
2012-01-17 08:08:26 +00:00
|
|
|
public void onPressKey(int primaryCode) {}
|
2011-08-29 10:09:56 +00:00
|
|
|
@Override
|
2012-01-17 08:08:26 +00:00
|
|
|
public void onReleaseKey(int primaryCode, boolean withSliding) {}
|
2011-08-29 10:09:56 +00:00
|
|
|
@Override
|
2012-03-06 05:56:46 +00:00
|
|
|
public void onCodeInput(int primaryCode, int x, int y) {}
|
2011-08-29 10:09:56 +00:00
|
|
|
@Override
|
|
|
|
public void onTextInput(CharSequence text) {}
|
|
|
|
@Override
|
2012-07-04 06:24:59 +00:00
|
|
|
public void onStartBatchInput() {}
|
|
|
|
@Override
|
2012-07-18 09:14:51 +00:00
|
|
|
public void onUpdateBatchInput(InputPointers batchPointers) {}
|
2012-06-12 10:40:37 +00:00
|
|
|
@Override
|
2012-07-18 09:14:51 +00:00
|
|
|
public void onEndBatchInput(InputPointers batchPointers) {}
|
2012-07-04 06:24:59 +00:00
|
|
|
@Override
|
2011-08-29 10:09:56 +00:00
|
|
|
public void onCancelInput() {}
|
|
|
|
@Override
|
|
|
|
public boolean onCustomRequest(int requestCode) {
|
|
|
|
return false;
|
|
|
|
}
|
2012-07-04 07:55:51 +00:00
|
|
|
|
|
|
|
// TODO: Remove this method when the vertical correction is removed.
|
|
|
|
public static boolean isInvalidCoordinate(int coordinate) {
|
2012-08-21 05:05:57 +00:00
|
|
|
// Detect {@link Constants#NOT_A_COORDINATE},
|
|
|
|
// {@link Constants#SUGGESTION_STRIP_COORDINATE}, and
|
|
|
|
// {@link Constants#SPELL_CHECKER_COORDINATE}.
|
2012-07-04 07:55:51 +00:00
|
|
|
return coordinate < 0;
|
|
|
|
}
|
2011-08-29 10:09:56 +00:00
|
|
|
}
|
2010-12-02 09:46:21 +00:00
|
|
|
}
|