MoreKeysPanel.java revision fa2d543785c52f639ad3157c57420f58a199c550
1/*
2 * Copyright (C) 2011 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;
18
19import android.view.View;
20
21public interface MoreKeysPanel extends PointerTracker.KeyEventHandler {
22    public interface Controller {
23        /**
24         * Add the {@link MoreKeysPanel} to the target view.
25         * @param panel
26         */
27        public void onShowMoreKeysPanel(final MoreKeysPanel panel);
28
29        /**
30         * Remove the current {@link MoreKeysPanel} to the target view.
31         */
32        public boolean onDismissMoreKeysPanel();
33    }
34
35    /**
36     * Initializes the layout and event handling of this {@link MoreKeysPanel} and calls the
37     * controller's onShowMoreKeysPanel to add the panel's container view.
38     *
39     * @param parentView the parent view of this {@link MoreKeysPanel}
40     * @param controller the controller that can dismiss this {@link MoreKeysPanel}
41     * @param pointX x coordinate of this {@link MoreKeysPanel}
42     * @param pointY y coordinate of this {@link MoreKeysPanel}
43     * @param listener the listener that will receive keyboard action from this
44     * {@link MoreKeysPanel}.
45     */
46    // TODO: Currently the MoreKeysPanel is inside a container view that is added to the parent.
47    // Consider the simpler approach of placing the MoreKeysPanel itself into the parent view.
48    public void showMoreKeysPanel(View parentView, Controller controller, int pointX,
49            int pointY, KeyboardActionListener listener);
50
51    /**
52     * Dismisses the more keys panel and calls the controller's onDismissMoreKeysPanel to remove
53     * the panel's container view.
54     */
55    public boolean dismissMoreKeysPanel();
56
57    /**
58     * Translate X-coordinate of touch event to the local X-coordinate of this
59     * {@link MoreKeysPanel}.
60     *
61     * @param x the global X-coordinate
62     * @return the local X-coordinate to this {@link MoreKeysPanel}
63     */
64    public int translateX(int x);
65
66    /**
67     * Translate Y-coordinate of touch event to the local Y-coordinate of this
68     * {@link MoreKeysPanel}.
69     *
70     * @param y the global Y-coordinate
71     * @return the local Y-coordinate to this {@link MoreKeysPanel}
72     */
73    public int translateY(int y);
74
75    /**
76     * Return the view containing the more keys panel.
77     */
78    public View getContainerView();
79
80    /**
81     * Return whether the panel is currently being shown.
82     */
83    public boolean isShowingInParent();
84}
85