FileDocCategorySizeDatePackage
Tutorial.javaAPI DocAndroid 1.5 API9352Wed May 06 22:42:48 BST 2009com.android.inputmethod.latin

Tutorial

public class Tutorial extends Object implements android.view.View.OnTouchListener

Fields Summary
private List
mBubbles
private long
mStartTime
private static final long
MINIMUM_TIME
private static final long
MAXIMUM_TIME
private android.view.View
mInputView
private LatinIME
mIme
private int[]
mLocation
private int
mBubblePointerOffset
private static final int
MSG_SHOW_BUBBLE
private int
mBubbleIndex
android.os.Handler
mHandler
Constructors Summary
public Tutorial(LatinIME ime, LatinKeyboardView inputView)

        Context context = inputView.getContext();
        mIme = ime;
        int inputWidth = inputView.getWidth();
        final int x = inputWidth / 20; // Half of 1/10th
        mBubblePointerOffset = inputView.getContext().getResources()
            .getDimensionPixelOffset(R.dimen.bubble_pointer_offset);
        Bubble bWelcome = new Bubble(context, inputView, 
                R.drawable.dialog_bubble_step02, x, 0, 
                R.string.tip_to_open_keyboard, R.string.touch_to_continue);
        mBubbles.add(bWelcome);
        Bubble bAccents = new Bubble(context, inputView, 
                R.drawable.dialog_bubble_step02, x, 0, 
                R.string.tip_to_view_accents, R.string.touch_to_continue);
        mBubbles.add(bAccents);
        Bubble b123 = new Bubble(context, inputView, 
                R.drawable.dialog_bubble_step07, x, 0, 
                R.string.tip_to_open_symbols, R.string.touch_to_continue);
        mBubbles.add(b123);
        Bubble bABC = new Bubble(context, inputView, 
                R.drawable.dialog_bubble_step07, x, 0, 
                R.string.tip_to_close_symbols, R.string.touch_to_continue);
        mBubbles.add(bABC);
        Bubble bSettings = new Bubble(context, inputView, 
                R.drawable.dialog_bubble_step07, x, 0, 
                R.string.tip_to_launch_settings, R.string.touch_to_continue);
        mBubbles.add(bSettings);
        Bubble bDone = new Bubble(context, inputView, 
                R.drawable.dialog_bubble_step02, x, 0, 
                R.string.tip_to_start_typing, R.string.touch_to_finish);
        mBubbles.add(bDone);
        mInputView = inputView;
    
Methods Summary
booleanclose()

        mHandler.removeMessages(MSG_SHOW_BUBBLE);
        hide();
        return true;
    
voidhide()

        for (int i = 0; i < mBubbles.size(); i++) {
            mBubbles.get(i).hide();
        }
        mInputView.setOnTouchListener(null);
    
booleannext()

        if (mBubbleIndex >= 0) {
            // If the bubble is not yet showing, don't move to the next.
            if (!mBubbles.get(mBubbleIndex).isShowing()) {
                return true;
            }
            // Hide all previous bubbles as well, as they may have had a delayed show
            for (int i = 0; i <= mBubbleIndex; i++) {
                mBubbles.get(i).hide();
            }
        }
        mBubbleIndex++;
        if (mBubbleIndex >= mBubbles.size()) {
            mInputView.setOnTouchListener(null);
            mIme.sendDownUpKeyEvents(-1); // Inform the setupwizard that tutorial is in last bubble
            mIme.tutorialDone();
            return false;
        }
        if (mBubbleIndex == 3 || mBubbleIndex == 4) {
            mIme.mKeyboardSwitcher.toggleSymbols();
        }
        mHandler.sendMessageDelayed(
                mHandler.obtainMessage(MSG_SHOW_BUBBLE, mBubbles.get(mBubbleIndex)), 500);
        return true;
    
public booleanonTouch(android.view.View v, android.view.MotionEvent event)

        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            next();
        }
        return true;
    
voidstart()

        mInputView.getLocationInWindow(mLocation);
        mBubbleIndex = -1;
        mInputView.setOnTouchListener(this);
        next();