1/*
2 * Copyright (C) 2012 The Android Open Source Project
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.android.inputmethod.keyboard.internal;
18
19import android.graphics.Canvas;
20import android.view.View;
21
22import com.android.inputmethod.keyboard.PointerTracker;
23
24/**
25 * Abstract base class for previews that are drawn on PreviewPlacerView, e.g.,
26 * GestureFloatingPrevewText, GestureTrail, and SlidingKeyInputPreview.
27 */
28public abstract class AbstractDrawingPreview {
29    private final View mDrawingView;
30    private boolean mPreviewEnabled;
31
32    protected AbstractDrawingPreview(final View drawingView) {
33        mDrawingView = drawingView;
34    }
35
36    public final View getDrawingView() {
37        return mDrawingView;
38    }
39
40    public final void setPreviewEnabled(final boolean enabled) {
41        mPreviewEnabled = enabled;
42    }
43
44    public boolean isPreviewEnabled() {
45        return mPreviewEnabled;
46    }
47
48    public void setKeyboardGeometry(final int[] originCoords, final int width, final int height) {
49        // Default implementation is empty.
50    }
51
52    public void onDetachFromWindow() {
53        // Default implementation is empty.
54    }
55
56    /**
57     * Draws the preview
58     * @param canvas The canvas where the preview is drawn.
59     */
60    public abstract void drawPreview(final Canvas canvas);
61
62    /**
63     * Set the position of the preview.
64     * @param tracker The new location of the preview is based on the points in PointerTracker.
65     */
66    public abstract void setPreviewPosition(final PointerTracker tracker);
67}
68