MoreKeysPanel.java revision ac69ab400d1ea4f90b4ca24486d62212decf1069
1ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka/*
2ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka * Copyright (C) 2011 The Android Open Source Project
3ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka *
4ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka * Licensed under the Apache License, Version 2.0 (the "License");
5ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka * you may not use this file except in compliance with the License.
6ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka * You may obtain a copy of the License at
7ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka *
8ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka *      http://www.apache.org/licenses/LICENSE-2.0
9ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka *
10ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka * Unless required by applicable law or agreed to in writing, software
11ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka * distributed under the License is distributed on an "AS IS" BASIS,
12ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka * See the License for the specific language governing permissions and
14ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka * limitations under the License.
15ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka */
16ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka
17ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaokapackage com.android.inputmethod.keyboard;
18ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka
19f44a01b40852dde2363a061cdc7df2ef4cb59aadTadashi G. Takaokaimport android.view.View;
20ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka
2135580bad6f3da3b204653825bbb6871563e70728Tom Ouyangpublic interface MoreKeysPanel {
22f44a01b40852dde2363a061cdc7df2ef4cb59aadTadashi G. Takaoka    public interface Controller {
23fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang        /**
24fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang         * Add the {@link MoreKeysPanel} to the target view.
25fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang         * @param panel
26fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang         */
27fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang        public void onShowMoreKeysPanel(final MoreKeysPanel panel);
28fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang
29fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang        /**
3035580bad6f3da3b204653825bbb6871563e70728Tom Ouyang         * Remove the current {@link MoreKeysPanel} from the target view.
31fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang         */
32fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang        public boolean onDismissMoreKeysPanel();
33ac69ab400d1ea4f90b4ca24486d62212decf1069Tom Ouyang
34ac69ab400d1ea4f90b4ca24486d62212decf1069Tom Ouyang        /**
35ac69ab400d1ea4f90b4ca24486d62212decf1069Tom Ouyang         * Instructs the parent to cancel the panel (e.g., when entering a different input mode).
36ac69ab400d1ea4f90b4ca24486d62212decf1069Tom Ouyang         */
37ac69ab400d1ea4f90b4ca24486d62212decf1069Tom Ouyang        public void onCancelMoreKeysPanel();
38f44a01b40852dde2363a061cdc7df2ef4cb59aadTadashi G. Takaoka    }
39f44a01b40852dde2363a061cdc7df2ef4cb59aadTadashi G. Takaoka
40ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka    /**
41fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang     * Initializes the layout and event handling of this {@link MoreKeysPanel} and calls the
42fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang     * controller's onShowMoreKeysPanel to add the panel's container view.
439d5601e9013c5ec9a7ac75db16f4a0a8218b02bfTadashi G. Takaoka     *
44fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang     * @param parentView the parent view of this {@link MoreKeysPanel}
45fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang     * @param controller the controller that can dismiss this {@link MoreKeysPanel}
46fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang     * @param pointX x coordinate of this {@link MoreKeysPanel}
47fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang     * @param pointY y coordinate of this {@link MoreKeysPanel}
48fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang     * @param listener the listener that will receive keyboard action from this
49fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang     * {@link MoreKeysPanel}.
50fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang     */
51fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang    // TODO: Currently the MoreKeysPanel is inside a container view that is added to the parent.
52fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang    // Consider the simpler approach of placing the MoreKeysPanel itself into the parent view.
53fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang    public void showMoreKeysPanel(View parentView, Controller controller, int pointX,
54fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang            int pointY, KeyboardActionListener listener);
55fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang
56fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang    /**
57fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang     * Dismisses the more keys panel and calls the controller's onDismissMoreKeysPanel to remove
58fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang     * the panel's container view.
59ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka     */
60fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang    public boolean dismissMoreKeysPanel();
61ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka
62ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka    /**
6335580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     * Process a move event on the more keys panel.
6435580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     *
6535580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     * @param x translated x coordinate of the touch point
6635580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     * @param y translated y coordinate of the touch point
6735580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     * @param pointerId pointer id touch point
6835580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     * @param eventTime timestamp of touch point
6935580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     */
7035580bad6f3da3b204653825bbb6871563e70728Tom Ouyang    public void onMoveEvent(final int x, final int y, final int pointerId, final long eventTime);
7135580bad6f3da3b204653825bbb6871563e70728Tom Ouyang
7235580bad6f3da3b204653825bbb6871563e70728Tom Ouyang    /**
7335580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     * Process a down event on the more keys panel.
7435580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     *
7535580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     * @param x translated x coordinate of the touch point
7635580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     * @param y translated y coordinate of the touch point
7735580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     * @param pointerId pointer id touch point
7835580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     * @param eventTime timestamp of touch point
7935580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     */
8035580bad6f3da3b204653825bbb6871563e70728Tom Ouyang    public void onDownEvent(final int x, final int y, final int pointerId, final long eventTime);
8135580bad6f3da3b204653825bbb6871563e70728Tom Ouyang
8235580bad6f3da3b204653825bbb6871563e70728Tom Ouyang    /**
8335580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     * Process an up event on the more keys panel.
8435580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     *
8535580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     * @param x translated x coordinate of the touch point
8635580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     * @param y translated y coordinate of the touch point
8735580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     * @param pointerId pointer id touch point
8835580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     * @param eventTime timestamp of touch point
8935580bad6f3da3b204653825bbb6871563e70728Tom Ouyang     */
9035580bad6f3da3b204653825bbb6871563e70728Tom Ouyang    public void onUpEvent(final int x, final int y, final int pointerId, final long eventTime);
9135580bad6f3da3b204653825bbb6871563e70728Tom Ouyang
9235580bad6f3da3b204653825bbb6871563e70728Tom Ouyang    /**
939d5601e9013c5ec9a7ac75db16f4a0a8218b02bfTadashi G. Takaoka     * Translate X-coordinate of touch event to the local X-coordinate of this
949d5601e9013c5ec9a7ac75db16f4a0a8218b02bfTadashi G. Takaoka     * {@link MoreKeysPanel}.
959d5601e9013c5ec9a7ac75db16f4a0a8218b02bfTadashi G. Takaoka     *
9663c233ab9f50d844be6e52e382c6664475606760Tadashi G. Takaoka     * @param x the global X-coordinate
979d5601e9013c5ec9a7ac75db16f4a0a8218b02bfTadashi G. Takaoka     * @return the local X-coordinate to this {@link MoreKeysPanel}
98ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka     */
9963c233ab9f50d844be6e52e382c6664475606760Tadashi G. Takaoka    public int translateX(int x);
100ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka
101ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka    /**
1029d5601e9013c5ec9a7ac75db16f4a0a8218b02bfTadashi G. Takaoka     * Translate Y-coordinate of touch event to the local Y-coordinate of this
1039d5601e9013c5ec9a7ac75db16f4a0a8218b02bfTadashi G. Takaoka     * {@link MoreKeysPanel}.
1049d5601e9013c5ec9a7ac75db16f4a0a8218b02bfTadashi G. Takaoka     *
10563c233ab9f50d844be6e52e382c6664475606760Tadashi G. Takaoka     * @param y the global Y-coordinate
1069d5601e9013c5ec9a7ac75db16f4a0a8218b02bfTadashi G. Takaoka     * @return the local Y-coordinate to this {@link MoreKeysPanel}
107ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka     */
10863c233ab9f50d844be6e52e382c6664475606760Tadashi G. Takaoka    public int translateY(int y);
109fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang
110fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang    /**
111fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang     * Return the view containing the more keys panel.
112fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang     */
113fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang    public View getContainerView();
114fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang
115fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang    /**
116fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang     * Return whether the panel is currently being shown.
117fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang     */
118fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang    public boolean isShowingInParent();
119ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka}
120