MoreKeysPanel.java revision fa2d543785c52f639ad3157c57420f58a199c550
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 219d5601e9013c5ec9a7ac75db16f4a0a8218b02bfTadashi G. Takaokapublic interface MoreKeysPanel extends PointerTracker.KeyEventHandler { 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 /** 30fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang * Remove the current {@link MoreKeysPanel} to the target view. 31fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang */ 32fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang public boolean onDismissMoreKeysPanel(); 33f44a01b40852dde2363a061cdc7df2ef4cb59aadTadashi G. Takaoka } 34f44a01b40852dde2363a061cdc7df2ef4cb59aadTadashi G. Takaoka 35ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka /** 36fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang * Initializes the layout and event handling of this {@link MoreKeysPanel} and calls the 37fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang * controller's onShowMoreKeysPanel to add the panel's container view. 389d5601e9013c5ec9a7ac75db16f4a0a8218b02bfTadashi G. Takaoka * 39fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang * @param parentView the parent view of this {@link MoreKeysPanel} 40fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang * @param controller the controller that can dismiss this {@link MoreKeysPanel} 41fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang * @param pointX x coordinate of this {@link MoreKeysPanel} 42fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang * @param pointY y coordinate of this {@link MoreKeysPanel} 43fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang * @param listener the listener that will receive keyboard action from this 44fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang * {@link MoreKeysPanel}. 45fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang */ 46fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang // TODO: Currently the MoreKeysPanel is inside a container view that is added to the parent. 47fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang // Consider the simpler approach of placing the MoreKeysPanel itself into the parent view. 48fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang public void showMoreKeysPanel(View parentView, Controller controller, int pointX, 49fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang int pointY, KeyboardActionListener listener); 50fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang 51fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang /** 52fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang * Dismisses the more keys panel and calls the controller's onDismissMoreKeysPanel to remove 53fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang * the panel's container view. 54ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka */ 55fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang public boolean dismissMoreKeysPanel(); 56ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka 57ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka /** 589d5601e9013c5ec9a7ac75db16f4a0a8218b02bfTadashi G. Takaoka * Translate X-coordinate of touch event to the local X-coordinate of this 599d5601e9013c5ec9a7ac75db16f4a0a8218b02bfTadashi G. Takaoka * {@link MoreKeysPanel}. 609d5601e9013c5ec9a7ac75db16f4a0a8218b02bfTadashi G. Takaoka * 6163c233ab9f50d844be6e52e382c6664475606760Tadashi G. Takaoka * @param x the global X-coordinate 629d5601e9013c5ec9a7ac75db16f4a0a8218b02bfTadashi G. Takaoka * @return the local X-coordinate to this {@link MoreKeysPanel} 63ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka */ 6463c233ab9f50d844be6e52e382c6664475606760Tadashi G. Takaoka public int translateX(int x); 65ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka 66ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka /** 679d5601e9013c5ec9a7ac75db16f4a0a8218b02bfTadashi G. Takaoka * Translate Y-coordinate of touch event to the local Y-coordinate of this 689d5601e9013c5ec9a7ac75db16f4a0a8218b02bfTadashi G. Takaoka * {@link MoreKeysPanel}. 699d5601e9013c5ec9a7ac75db16f4a0a8218b02bfTadashi G. Takaoka * 7063c233ab9f50d844be6e52e382c6664475606760Tadashi G. Takaoka * @param y the global Y-coordinate 719d5601e9013c5ec9a7ac75db16f4a0a8218b02bfTadashi G. Takaoka * @return the local Y-coordinate to this {@link MoreKeysPanel} 72ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka */ 7363c233ab9f50d844be6e52e382c6664475606760Tadashi G. Takaoka public int translateY(int y); 74fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang 75fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang /** 76fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang * Return the view containing the more keys panel. 77fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang */ 78fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang public View getContainerView(); 79fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang 80fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang /** 81fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang * Return whether the panel is currently being shown. 82fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang */ 83fa2d543785c52f639ad3157c57420f58a199c550Tom Ouyang public boolean isShowingInParent(); 84ff082d081f3ea18ff0b9b22126ee4a86504cf83cTadashi G. Takaoka} 85