Home | History | Annotate | Download | only in event
      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 
     17 package com.android.inputmethod.event;
     18 
     19 import java.util.ArrayList;
     20 
     21 import javax.annotation.Nonnull;
     22 
     23 /**
     24  * A generic interface for combiners. Combiners are objects that transform chains of input events
     25  * into committable strings and manage feedback to show to the user on the combining state.
     26  */
     27 public interface Combiner {
     28     /**
     29      * Process an event, possibly combining it with the existing state and return the new event.
     30      *
     31      * If this event does not result in any new event getting passed down the chain, this method
     32      * returns null. It may also modify the previous event list if appropriate.
     33      *
     34      * @param previousEvents the previous events in this composition.
     35      * @param event the event to combine with the existing state.
     36      * @return the resulting event.
     37      */
     38     @Nonnull
     39     Event processEvent(ArrayList<Event> previousEvents, Event event);
     40 
     41     /**
     42      * Get the feedback that should be shown to the user for the current state of this combiner.
     43      * @return A CharSequence representing the feedback to show users. It may include styles.
     44      */
     45     CharSequence getCombiningStateFeedback();
     46 
     47     /**
     48      * Reset the state of this combiner, for example when the cursor was moved.
     49      */
     50     void reset();
     51 }
     52