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