49
|
1 |
/*
|
|
2 |
* Copyright (c) 2009,2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
package javax.microedition.lcdui;
|
|
19 |
|
|
20 |
import org.eclipse.swt.internal.extension.OS;
|
|
21 |
|
|
22 |
final class SystemPropertyUtil {
|
|
23 |
|
|
24 |
/**
|
|
25 |
* Constant for Soft Key Label Height
|
|
26 |
*/
|
|
27 |
public static final int LABEL_HEIGHT = 30;
|
|
28 |
|
|
29 |
private static final int HbKeyboardNone = 0x00000000;
|
|
30 |
private static final int HbKeyboard12Key = 0x00000001;
|
|
31 |
private static final int HbKeyboardQwerty = 0x00000001|0x00010000;
|
|
32 |
|
|
33 |
/*
|
|
34 |
* This method checks if the current Displayable exists
|
|
35 |
* If yes, then the current Displayable is asked for the property
|
|
36 |
* If no, the null is returned
|
|
37 |
*/
|
|
38 |
final static String getSoftKeyLabelLocationImpl(String softKeyId)
|
|
39 |
{
|
|
40 |
String SoftKeyLabelLocation = null;
|
|
41 |
|
|
42 |
Displayable disp = javax.microedition.lcdui.Display.getDisplay().getCurrent();
|
|
43 |
|
|
44 |
if((disp != null) && (disp instanceof Canvas))
|
|
45 |
{
|
|
46 |
if(((Canvas) disp).IsFullScreenMode())
|
|
47 |
{
|
|
48 |
|
|
49 |
if("com.nokia.softkey1.label.location".equals(softKeyId))
|
|
50 |
{
|
|
51 |
SoftKeyLabelLocation = "0," + String.valueOf(((Canvas) disp).getHeight()) + ","
|
|
52 |
+ String.valueOf((((Canvas) disp).getWidth())/2) + ","
|
|
53 |
+ String.valueOf(LABEL_HEIGHT);
|
|
54 |
}
|
|
55 |
else if("com.nokia.softkey2.label.location".equals(softKeyId))
|
|
56 |
{
|
|
57 |
SoftKeyLabelLocation = String.valueOf((((Canvas) disp).getWidth())/2) + ","
|
|
58 |
+ String.valueOf(((Canvas) disp).getHeight()) + ","
|
|
59 |
+ String.valueOf((((Canvas) disp).getWidth())/2) + ","
|
|
60 |
+ String.valueOf(LABEL_HEIGHT);
|
|
61 |
}
|
|
62 |
}
|
|
63 |
}
|
|
64 |
return SoftKeyLabelLocation;
|
|
65 |
}
|
|
66 |
|
|
67 |
/*
|
|
68 |
* This method checks if the current Displayable exists
|
|
69 |
* If yes, then the current Displayable is asked for the property
|
|
70 |
* If no, the null is returned
|
|
71 |
*/
|
|
72 |
final static String getSoftKeyLabelAnchorImpl(String softKeyId)
|
|
73 |
{
|
|
74 |
String SoftKeyLabelAnchor = null;
|
|
75 |
|
|
76 |
Displayable disp = javax.microedition.lcdui.Display.getDisplay().getCurrent();
|
|
77 |
|
|
78 |
if((disp != null) && (disp instanceof Canvas))
|
|
79 |
{
|
|
80 |
if(null == ((Canvas) disp).getCanvasKeypad())
|
|
81 |
{
|
|
82 |
SoftKeyLabelAnchor = String.valueOf(Graphics.TOP | Graphics.HCENTER);
|
|
83 |
}
|
|
84 |
else
|
|
85 |
{
|
|
86 |
if("com.nokia.softkey1.label.anchor".equals(softKeyId))
|
|
87 |
{
|
|
88 |
SoftKeyLabelAnchor = String.valueOf(Graphics.TOP | Graphics.LEFT);
|
|
89 |
}
|
|
90 |
else if("com.nokia.softkey2.label.anchor".equals(softKeyId))
|
|
91 |
{
|
|
92 |
SoftKeyLabelAnchor = String.valueOf(Graphics.TOP | Graphics.RIGHT);
|
|
93 |
}
|
|
94 |
}
|
|
95 |
}
|
|
96 |
|
|
97 |
return SoftKeyLabelAnchor;
|
|
98 |
}
|
|
99 |
|
|
100 |
final static String doGetDynamicProperty(String key)
|
|
101 |
{
|
|
102 |
if("com.nokia.key.scancode".equals(key))
|
|
103 |
{
|
|
104 |
return String.valueOf(ESWTUIThreadRunner.getLastKeyScancode());
|
|
105 |
}
|
|
106 |
else if("com.nokia.key.modifier".equals(key))
|
|
107 |
{
|
|
108 |
return String.valueOf(ESWTUIThreadRunner.getLastKeyModifier());
|
|
109 |
}
|
|
110 |
else if("com.nokia.keyboard.type".equals(key))
|
|
111 |
{
|
|
112 |
// TODO: eSWT support required
|
|
113 |
/*
|
|
114 |
No keypad (for example a touch device without keypad) - None
|
|
115 |
Standard ITU-T keypad (Phone keypad with 12 keys) - PhoneKeypad
|
|
116 |
QWERTY (4x12 layout) - FullKeyboard
|
|
117 |
QWERTY (limited, 4x10 layout) - LimitedKeyboard4x10
|
|
118 |
QWERTY (limited, 3x11 layout) - LimitedKeyboard3x11
|
|
119 |
Half QWERTY layout (aka Compact QWERTY keyboard). - HalfKeyboard
|
|
120 |
Custom QWERTY layout - Custom
|
|
121 |
Unknown layout - Unknown
|
|
122 |
*/
|
|
123 |
String keyBoard="None";
|
|
124 |
int type = OS.HbInputSettingProxy_availableHwKeyboard();
|
|
125 |
|
|
126 |
switch(type){
|
|
127 |
case HbKeyboardNone:
|
|
128 |
keyBoard="None";
|
|
129 |
break;
|
|
130 |
case HbKeyboard12Key:
|
|
131 |
keyBoard="PhoneKeypad";
|
|
132 |
break;
|
|
133 |
case HbKeyboardQwerty:
|
|
134 |
keyBoard="FullKeyboard";
|
|
135 |
break;
|
|
136 |
default:
|
|
137 |
keyBoard = "None";
|
|
138 |
}
|
|
139 |
return keyBoard;
|
|
140 |
}
|
|
141 |
else if("com.nokia.softkey1.label.location".equals(key))
|
|
142 |
{
|
|
143 |
return getSoftKeyLabelLocationImpl(key);
|
|
144 |
}
|
|
145 |
else if("com.nokia.softkey1.label.anchor".equals(key))
|
|
146 |
{
|
|
147 |
return getSoftKeyLabelAnchorImpl(key);
|
|
148 |
}
|
|
149 |
else if("com.nokia.softkey2.label.location".equals(key))
|
|
150 |
{
|
|
151 |
return getSoftKeyLabelLocationImpl(key);
|
|
152 |
}
|
|
153 |
else if("com.nokia.softkey2.label.anchor".equals(key))
|
|
154 |
{
|
|
155 |
return getSoftKeyLabelAnchorImpl(key);
|
|
156 |
}
|
|
157 |
return "key not supported";
|
|
158 |
}
|
|
159 |
}
|