1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
/*
* Copyright (C) 2011 The Android Open Source Project
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* 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.
*/
package com.android.inputmethod.keyboard;
import android.view.View;
import android.view.ViewGroup;
public interface MoreKeysPanel {
public interface Controller {
/**
* Add the {@link MoreKeysPanel} to the target view.
* @param panel the panel to be shown.
*/
public void onShowMoreKeysPanel(final MoreKeysPanel panel);
/**
* Remove the current {@link MoreKeysPanel} from the target view.
*/
public void onDismissMoreKeysPanel();
/**
* Instructs the parent to cancel the panel (e.g., when entering a different input mode).
*/
public void onCancelMoreKeysPanel();
}
public static final Controller EMPTY_CONTROLLER = new Controller() {
@Override
public void onShowMoreKeysPanel(final MoreKeysPanel panel) {}
@Override
public void onDismissMoreKeysPanel() {}
@Override
public void onCancelMoreKeysPanel() {}
};
/**
* Initializes the layout and event handling of this {@link MoreKeysPanel} and calls the
* controller's onShowMoreKeysPanel to add the panel's container view.
*
* @param parentView the parent view of this {@link MoreKeysPanel}
* @param controller the controller that can dismiss this {@link MoreKeysPanel}
* @param pointX x coordinate of this {@link MoreKeysPanel}
* @param pointY y coordinate of this {@link MoreKeysPanel}
* @param listener the listener that will receive keyboard action from this
* {@link MoreKeysPanel}.
*/
// TODO: Currently the MoreKeysPanel is inside a container view that is added to the parent.
// Consider the simpler approach of placing the MoreKeysPanel itself into the parent view.
public void showMoreKeysPanel(View parentView, Controller controller, int pointX,
int pointY, KeyboardActionListener listener);
/**
* Dismisses the more keys panel and calls the controller's onDismissMoreKeysPanel to remove
* the panel's container view.
*/
public void dismissMoreKeysPanel();
/**
* Process a move event on the more keys panel.
*
* @param x translated x coordinate of the touch point
* @param y translated y coordinate of the touch point
* @param pointerId pointer id touch point
* @param eventTime timestamp of touch point
*/
public void onMoveEvent(final int x, final int y, final int pointerId, final long eventTime);
/**
* Process a down event on the more keys panel.
*
* @param x translated x coordinate of the touch point
* @param y translated y coordinate of the touch point
* @param pointerId pointer id touch point
* @param eventTime timestamp of touch point
*/
public void onDownEvent(final int x, final int y, final int pointerId, final long eventTime);
/**
* Process an up event on the more keys panel.
*
* @param x translated x coordinate of the touch point
* @param y translated y coordinate of the touch point
* @param pointerId pointer id touch point
* @param eventTime timestamp of touch point
*/
public void onUpEvent(final int x, final int y, final int pointerId, final long eventTime);
/**
* Translate X-coordinate of touch event to the local X-coordinate of this
* {@link MoreKeysPanel}.
*
* @param x the global X-coordinate
* @return the local X-coordinate to this {@link MoreKeysPanel}
*/
public int translateX(int x);
/**
* Translate Y-coordinate of touch event to the local Y-coordinate of this
* {@link MoreKeysPanel}.
*
* @param y the global Y-coordinate
* @return the local Y-coordinate to this {@link MoreKeysPanel}
*/
public int translateY(int y);
/**
* Show this {@link MoreKeysPanel} in the parent view.
*
* @param parentView the {@link ViewGroup} that hosts this {@link MoreKeysPanel}.
*/
public void showInParent(ViewGroup parentView);
/**
* Remove this {@link MoreKeysPanel} from the parent view.
*/
public void removeFromParent();
/**
* Return whether the panel is currently being shown.
*/
public boolean isShowingInParent();
}
|