• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * 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, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */
16 
17 package com.android.inputmethod.latin;
18 
19 import android.util.Log;
20 
21 public class ComposingStateManager {
22     private static final String TAG = ComposingStateManager.class.getSimpleName();
23     private static final ComposingStateManager sInstance = new ComposingStateManager();
24     private boolean mAutoCorrectionIndicatorOn;
25     private boolean mIsComposing;
26 
getInstance()27     public static ComposingStateManager getInstance() {
28         return sInstance;
29     }
30 
ComposingStateManager()31     private ComposingStateManager() {
32         mAutoCorrectionIndicatorOn = false;
33         mIsComposing = false;
34     }
35 
onStartComposingText()36     public synchronized void onStartComposingText() {
37         if (!mIsComposing) {
38             if (LatinImeLogger.sDBG) {
39                 Log.i(TAG, "Start composing text.");
40             }
41             mAutoCorrectionIndicatorOn = false;
42             mIsComposing = true;
43         }
44     }
45 
onFinishComposingText()46     public synchronized void onFinishComposingText() {
47         if (mIsComposing) {
48             if (LatinImeLogger.sDBG) {
49                 Log.i(TAG, "Finish composing text.");
50             }
51             mAutoCorrectionIndicatorOn = false;
52             mIsComposing = false;
53         }
54     }
55 
isAutoCorrectionIndicatorOn()56     public synchronized boolean isAutoCorrectionIndicatorOn() {
57         return mAutoCorrectionIndicatorOn;
58     }
59 
setAutoCorrectionIndicatorOn(boolean on)60     public synchronized void setAutoCorrectionIndicatorOn(boolean on) {
61         // Auto-correction indicator should be specified only when the current state is "composing".
62         if (!mIsComposing) return;
63         if (LatinImeLogger.sDBG) {
64             Log.i(TAG, "Set auto correction Indicator: " + on);
65         }
66         mAutoCorrectionIndicatorOn = on;
67     }
68 }
69