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

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