Combiner.java revision 60fbf9e9627063ad697809d62853f6b3ee5f6ad3
1/* 2 * Copyright (C) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.inputmethod.event; 18 19import java.util.ArrayList; 20 21/** 22 * A generic interface for combiners. Combiners are objects that transform chains of input events 23 * into committable strings and manage feedback to show to the user on the combining state. 24 */ 25public interface Combiner { 26 /** 27 * Process an event, possibly combining it with the existing state and return the new event. 28 * 29 * If this event does not result in any new event getting passed down the chain, this method 30 * returns null. It may also modify the previous event list if appropriate. 31 * 32 * @param previousEvents the previous events in this composition. 33 * @param event the event to combine with the existing state. 34 * @return the resulting event. 35 */ 36 Event processEvent(ArrayList<Event> previousEvents, Event event); 37 38 /** 39 * Get the feedback that should be shown to the user for the current state of this combiner. 40 * @return A CharSequence representing the feedback to show users. It may include styles. 41 */ 42 CharSequence getCombiningStateFeedback(); 43 44 /** 45 * Reset the state of this combiner, for example when the cursor was moved. 46 */ 47 void reset(); 48} 49