2012-12-19 21:01:57 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 The Android Open Source Project
|
|
|
|
*
|
2013-01-21 12:52:57 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2012-12-19 21:01:57 +00:00
|
|
|
*
|
2013-01-21 12:52:57 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2012-12-19 21:01:57 +00:00
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
2013-01-21 12:52:57 +00:00
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2012-12-19 21:01:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
package com.android.inputmethod.keyboard.internal;
|
|
|
|
|
|
|
|
import android.graphics.Canvas;
|
2013-01-21 09:36:34 +00:00
|
|
|
import android.view.View;
|
2012-12-19 21:01:57 +00:00
|
|
|
|
|
|
|
import com.android.inputmethod.keyboard.PointerTracker;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Abstract base class for previews that are drawn on PreviewPlacerView, e.g.,
|
|
|
|
* GestureFloatingPrevewText, GestureTrail, and SlidingKeyInputPreview.
|
|
|
|
*/
|
|
|
|
public abstract class AbstractDrawingPreview {
|
2013-01-21 09:36:34 +00:00
|
|
|
private final View mDrawingView;
|
2012-12-19 21:01:57 +00:00
|
|
|
private boolean mPreviewEnabled;
|
|
|
|
|
2013-01-21 09:36:34 +00:00
|
|
|
protected AbstractDrawingPreview(final View drawingView) {
|
|
|
|
mDrawingView = drawingView;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final View getDrawingView() {
|
|
|
|
return mDrawingView;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void setPreviewEnabled(final boolean enabled) {
|
2012-12-19 21:01:57 +00:00
|
|
|
mPreviewEnabled = enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isPreviewEnabled() {
|
|
|
|
return mPreviewEnabled;
|
|
|
|
}
|
|
|
|
|
2013-01-21 09:36:34 +00:00
|
|
|
public void setKeyboardGeometry(final int[] originCoords, final int width, final int height) {
|
|
|
|
// Default implementation is empty.
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onDetachFromWindow() {
|
|
|
|
// Default implementation is empty.
|
|
|
|
}
|
|
|
|
|
2012-12-19 21:01:57 +00:00
|
|
|
/**
|
|
|
|
* Draws the preview
|
|
|
|
* @param canvas The canvas where the preview is drawn.
|
|
|
|
*/
|
2013-01-21 08:00:47 +00:00
|
|
|
public abstract void drawPreview(final Canvas canvas);
|
2012-12-19 21:01:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the position of the preview.
|
2013-01-21 09:36:34 +00:00
|
|
|
* @param tracker The new location of the preview is based on the points in PointerTracker.
|
2012-12-19 21:01:57 +00:00
|
|
|
*/
|
2013-01-21 09:36:34 +00:00
|
|
|
public abstract void setPreviewPosition(final PointerTracker tracker);
|
2012-12-19 21:01:57 +00:00
|
|
|
}
|