16a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard/* 26a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard * Copyright (C) 2013 The Android Open Source Project 36a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard * 46a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard * Licensed under the Apache License, Version 2.0 (the "License"); 56a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard * you may not use this file except in compliance with the License. 66a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard * You may obtain a copy of the License at 76a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard * 86a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard * http://www.apache.org/licenses/LICENSE-2.0 96a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard * 106a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard * Unless required by applicable law or agreed to in writing, software 116a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard * distributed under the License is distributed on an "AS IS" BASIS, 126a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 136a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard * See the License for the specific language governing permissions and 146a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard * limitations under the License. 156a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard */ 166a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard 176a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalardpackage com.android.inputmethod.event; 186a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard 19f2bb15b0ab212e1ef45be2d2ea6610cfa9c9f15cJean Chalardimport java.util.ArrayList; 20f2bb15b0ab212e1ef45be2d2ea6610cfa9c9f15cJean Chalard 217f545a57c987862d55966ac08ef64cfe0b9f51e4Ken Wakasaimport javax.annotation.Nonnull; 227f545a57c987862d55966ac08ef64cfe0b9f51e4Ken Wakasa 236a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard/** 24f2bb15b0ab212e1ef45be2d2ea6610cfa9c9f15cJean Chalard * A generic interface for combiners. Combiners are objects that transform chains of input events 25f2bb15b0ab212e1ef45be2d2ea6610cfa9c9f15cJean Chalard * into committable strings and manage feedback to show to the user on the combining state. 266a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard */ 276a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalardpublic interface Combiner { 286a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard /** 29f2bb15b0ab212e1ef45be2d2ea6610cfa9c9f15cJean Chalard * Process an event, possibly combining it with the existing state and return the new event. 30f2bb15b0ab212e1ef45be2d2ea6610cfa9c9f15cJean Chalard * 31f2bb15b0ab212e1ef45be2d2ea6610cfa9c9f15cJean Chalard * If this event does not result in any new event getting passed down the chain, this method 32f2bb15b0ab212e1ef45be2d2ea6610cfa9c9f15cJean Chalard * returns null. It may also modify the previous event list if appropriate. 33f2bb15b0ab212e1ef45be2d2ea6610cfa9c9f15cJean Chalard * 34f2bb15b0ab212e1ef45be2d2ea6610cfa9c9f15cJean Chalard * @param previousEvents the previous events in this composition. 356a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard * @param event the event to combine with the existing state. 366a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard * @return the resulting event. 376a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard */ 387f545a57c987862d55966ac08ef64cfe0b9f51e4Ken Wakasa @Nonnull 39f2bb15b0ab212e1ef45be2d2ea6610cfa9c9f15cJean Chalard Event processEvent(ArrayList<Event> previousEvents, Event event); 40835965a75e7dad3026911b6615efa502905f3eabJean Chalard 41835965a75e7dad3026911b6615efa502905f3eabJean Chalard /** 42835965a75e7dad3026911b6615efa502905f3eabJean Chalard * Get the feedback that should be shown to the user for the current state of this combiner. 43835965a75e7dad3026911b6615efa502905f3eabJean Chalard * @return A CharSequence representing the feedback to show users. It may include styles. 44835965a75e7dad3026911b6615efa502905f3eabJean Chalard */ 45835965a75e7dad3026911b6615efa502905f3eabJean Chalard CharSequence getCombiningStateFeedback(); 46cbed462d192d0c5af9614f5f997b2768f3d0eb56Jean Chalard 47cbed462d192d0c5af9614f5f997b2768f3d0eb56Jean Chalard /** 48cbed462d192d0c5af9614f5f997b2768f3d0eb56Jean Chalard * Reset the state of this combiner, for example when the cursor was moved. 49cbed462d192d0c5af9614f5f997b2768f3d0eb56Jean Chalard */ 50cbed462d192d0c5af9614f5f997b2768f3d0eb56Jean Chalard void reset(); 516a26de1d7e3bb3b277c0af6d678023b862c22a86Jean Chalard} 52