/ime/latinime/src/com/googlecode/eyesfree/inputmethod/latin/tutorial/LatinTutorialModule1.java

http://eyes-free.googlecode.com/ · Java · 75 lines · 46 code · 11 blank · 18 comment · 16 complexity · 0782c8bea5974924f1f7358263390489 MD5 · raw file

  1. /*
  2. * Copyright (C) 2011 Google Inc.
  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. package com.googlecode.eyesfree.inputmethod.latin.tutorial;
  17. import android.content.Context;
  18. import android.view.View;
  19. import com.googlecode.eyesfree.inputmethod.latin.AccessibilityUtils;
  20. import com.googlecode.eyesfree.inputmethod.latin.LatinIME;
  21. import com.googlecode.eyesfree.inputmethod.latin.R;
  22. /**
  23. * @author alanv@google.com (Alan Viverette)
  24. */
  25. public class LatinTutorialModule1 extends TutorialModule implements View.OnClickListener {
  26. private static final int FLAG_STARTED = 0;
  27. public LatinTutorialModule1(Context context, TutorialController controller) {
  28. super(context, controller, R.layout.tutorial_1_introduction);
  29. findViewById(R.id.tutorial_1_content).setOnClickListener(this);
  30. findViewById(R.id.tutorial_continue).setOnClickListener(this);
  31. }
  32. @Override
  33. public void onShown() {
  34. super.onShown();
  35. if (!hasFlag(FLAG_STARTED)) {
  36. setFlag(FLAG_STARTED, true);
  37. findViewById(R.id.tutorial_continue).setEnabled(false);
  38. if (!AccessibilityUtils.isAccessibilityEnabled(getContext())) {
  39. addInstruction(R.string.need_accessibility_message);
  40. } else if (!AccessibilityUtils.isInputMethodEnabled(getContext(), LatinIME.class)) {
  41. addInstruction(R.string.need_enable_message);
  42. } else if (!AccessibilityUtils.isInputMethodDefault(getContext(), LatinIME.class)) {
  43. addInstruction(R.string.need_default_message);
  44. } else {
  45. addInstruction(R.string.tutorial_1_message_1);
  46. findViewById(R.id.tutorial_continue).setEnabled(true);
  47. }
  48. }
  49. }
  50. @Override
  51. public void onInstructionRead(int resId) {
  52. if (resId == R.string.tutorial_1_message_1) {
  53. addInstruction(R.string.tutorial_1_message_2);
  54. } else if (resId == R.string.tutorial_1_message_2) {
  55. addInstruction(R.string.tutorial_1_message_3);
  56. }
  57. }
  58. @Override
  59. public void onClick(View v) {
  60. if (v.getId() == R.id.tutorial_1_content || v.getId() == R.id.tutorial_continue) {
  61. getController().next();
  62. }
  63. }
  64. }