PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/ime/latinime/src/com/googlecode/eyesfree/inputmethod/voice/VoiceInputLogger.java

http://eyes-free.googlecode.com/
Java | 159 lines | 95 code | 33 blank | 31 comment | 3 complexity | f58dc15f94123773182721eaf5f05077 MD5 | raw file
  1/*
  2 * Copyright (C) 2008 Google Inc.
  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
 17package com.googlecode.eyesfree.inputmethod.voice;
 18
 19import android.content.Context;
 20
 21/**
 22 * Provides the logging facility for voice input events. This fires broadcasts back to
 23 * the voice search app which then logs on our behalf.
 24 *
 25 * Note that debug console logging does not occur in this class. If you want to
 26 * see console output of these logging events, there is a boolean switch to turn
 27 * on on the VoiceSearch side.
 28 */
 29public class VoiceInputLogger {
 30    private static VoiceInputLogger sVoiceInputLogger;
 31
 32    // This flag is used to indicate when there are voice events that
 33    // need to be flushed.
 34    private boolean mHasLoggingInfo = false;
 35
 36    /**
 37     * Returns the singleton of the logger.
 38     *
 39     * @param contextHint a hint context used when creating the logger instance.
 40     * Ignored if the singleton instance already exists.
 41     */
 42    public static synchronized VoiceInputLogger getLogger(Context contextHint) {
 43        if (sVoiceInputLogger == null) {
 44            sVoiceInputLogger = new VoiceInputLogger(contextHint);
 45        }
 46        return sVoiceInputLogger;
 47    }
 48
 49    public VoiceInputLogger(Context context) {
 50    }
 51
 52    public void flush() {
 53        if (hasLoggingInfo()) {
 54            setHasLoggingInfo(false);
 55        }
 56    }
 57    
 58    public void keyboardWarningDialogShown() {
 59        setHasLoggingInfo(true);
 60    }
 61    
 62    public void keyboardWarningDialogDismissed() {
 63        setHasLoggingInfo(true);
 64    }
 65
 66    public void keyboardWarningDialogOk() {
 67        setHasLoggingInfo(true);
 68    }
 69
 70    public void keyboardWarningDialogCancel() {
 71        setHasLoggingInfo(true);
 72    }
 73
 74    public void settingsWarningDialogShown() {
 75        setHasLoggingInfo(true);
 76    }
 77    
 78    public void settingsWarningDialogDismissed() {
 79        setHasLoggingInfo(true);
 80    }
 81
 82    public void settingsWarningDialogOk() {
 83        setHasLoggingInfo(true);
 84    }
 85
 86    public void settingsWarningDialogCancel() {
 87        setHasLoggingInfo(true);
 88    }
 89    
 90    public void swipeHintDisplayed() {
 91        setHasLoggingInfo(true);
 92    }
 93    
 94    public void cancelDuringListening() {
 95        setHasLoggingInfo(true);
 96    }
 97
 98    public void cancelDuringWorking() {
 99        setHasLoggingInfo(true);
100    }
101
102    public void cancelDuringError() {
103        setHasLoggingInfo(true);
104    }
105    
106    public void punctuationHintDisplayed() {
107        setHasLoggingInfo(true);
108    }
109    
110    public void error(int code) {
111        setHasLoggingInfo(true);
112    }
113
114    public void start(String locale, boolean swipe) {
115        setHasLoggingInfo(true);
116    }
117    
118    public void voiceInputDelivered(int length) {
119        setHasLoggingInfo(true);
120    }
121
122    public void textModifiedByTypingInsertion(int length) {
123        setHasLoggingInfo(true);
124    }
125
126    public void textModifiedByTypingInsertionPunctuation(int length) {
127        setHasLoggingInfo(true);
128    }
129
130    public void textModifiedByTypingDeletion(int length) {
131        setHasLoggingInfo(true);
132    }
133
134    public void textModifiedByChooseSuggestion(int suggestionLength, int replacedPhraseLength,
135                                               int index, String before, String after) {
136        setHasLoggingInfo(true);
137    }
138
139    public void inputEnded() {
140        setHasLoggingInfo(true);
141    }
142    
143    public void voiceInputSettingEnabled() {
144        setHasLoggingInfo(true);
145    }
146    
147    public void voiceInputSettingDisabled() {
148        setHasLoggingInfo(true);
149    }
150
151    private void setHasLoggingInfo(boolean hasLoggingInfo) {
152        mHasLoggingInfo = hasLoggingInfo;
153    }
154
155    private boolean hasLoggingInfo(){
156        return mHasLoggingInfo;
157    }
158
159}