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.latin.inputlogic;
18 
19 /**
20  * Class for managing space states.
21  *
22  * At any given time, the input logic is in one of five possible space states. Depending on the
23  * current space state, some behavior will change; the prime example of this is the PHANTOM state,
24  * in which any subsequent letter input will input a space before the letter. Read on the
25  * description inside this class for each of the space states.
26  */
27 public class SpaceState {
28     // None: the state where all the keyboard behavior is the most "standard" and no automatic
29     // input is added or removed. In this state, all self-inserting keys only insert themselves,
30     // and backspace removes one character.
31     public static final int NONE = 0;
32     // Double space: the state where the user pressed space twice quickly, which LatinIME
33     // resolved as period-space. In this state, pressing backspace will undo the
34     // double-space-to-period insertion: it will replace ". " with "  ".
35     public static final int DOUBLE = 1;
36     // Swap punctuation: the state where a weak space and a punctuation from the suggestion strip
37     // have just been swapped. In this state, pressing backspace will undo the swap: the
38     // characters will be swapped back back, and the space state will go to WEAK.
39     public static final int SWAP_PUNCTUATION = 2;
40     // Weak space: a space that should be swapped only by suggestion strip punctuation. Weak
41     // spaces happen when the user presses space, accepting the current suggestion (whether
42     // it's an auto-correction or not). In this state, pressing a punctuation from the suggestion
43     // strip inserts it before the space (while it inserts it after the space in the NONE state).
44     public static final int WEAK = 3;
45     // Phantom space: a not-yet-inserted space that should get inserted on the next input,
46     // character provided it's not a separator. If it's a separator, the phantom space is dropped.
47     // Phantom spaces happen when a user chooses a word from the suggestion strip. In this state,
48     // non-separators insert a space before they get inserted.
49     public static final int PHANTOM = 4;
50 
SpaceState()51     private SpaceState() {
52         // This class is not publicly instantiable.
53     }
54 }
55