Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
16
gaia/dev_apps/test-keyboard-app/index.html
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
|
||||
<meta charset="utf-8">
|
||||
<title>Keyboard Test App</title>
|
||||
<script type="text/javascript" src="js/main.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="style/keyboard.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="keyboard">
|
||||
<button id="sendKey" class="key">Send Key: \o/ </button>
|
||||
<button id="switchLayout" class="key">Switch layout</button>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
69
gaia/dev_apps/test-keyboard-app/js/main.js
Executable file
|
|
@ -0,0 +1,69 @@
|
|||
var inputContext = null;
|
||||
var keyboardElement;
|
||||
|
||||
function init() {
|
||||
keyboardElement = document.getElementById('keyboard');
|
||||
|
||||
window.navigator.mozInputMethod.oninputcontextchange = function() {
|
||||
inputContext = navigator.mozInputMethod.inputcontext;
|
||||
resizeWindow();
|
||||
};
|
||||
|
||||
window.addEventListener('resize', resizeWindow);
|
||||
|
||||
keyboardElement.addEventListener('mousedown', function onMouseDown(evt) {
|
||||
// Prevent loosing focus to the currently focused app
|
||||
// Otherwise, right after mousedown event, the app will receive a focus event.
|
||||
evt.preventDefault();
|
||||
});
|
||||
|
||||
var sendKeyElement = document.getElementById('sendKey');
|
||||
sendKeyElement.addEventListener('click', function sendKeyHandler() {
|
||||
var testString = '\\o/';
|
||||
for (var i = 0; i < testString.length; i++) {
|
||||
sendKey(testString.charCodeAt(i));
|
||||
}
|
||||
});
|
||||
|
||||
var switchElement = document.getElementById('switchLayout');
|
||||
switchElement.addEventListener('click', function switchHandler() {
|
||||
var mgmt = navigator.mozInputMethod.mgmt;
|
||||
mgmt.next();
|
||||
});
|
||||
|
||||
// long press to trigger IME menu
|
||||
var menuTimeout = 0;
|
||||
switchElement.addEventListener('touchstart', function longHandler() {
|
||||
menuTimeout = window.setTimeout(function menuTimeout() {
|
||||
var mgmt = navigator.mozInputMethod.mgmt;
|
||||
mgmt.showAll();
|
||||
}, 700);
|
||||
});
|
||||
|
||||
switchElement.addEventListener('touchend', function longHandler() {
|
||||
clearTimeout(menuTimeout);
|
||||
});
|
||||
}
|
||||
|
||||
function resizeWindow() {
|
||||
window.resizeTo(window.innerWidth, keyboardElement.clientHeight);
|
||||
}
|
||||
|
||||
function sendKey(keyCode) {
|
||||
switch (keyCode) {
|
||||
case KeyEvent.DOM_VK_BACK_SPACE:
|
||||
case KeyEvent.DOM_VK_RETURN:
|
||||
if (inputContext) {
|
||||
inputContext.sendKey(keyCode, 0, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (inputContext) {
|
||||
inputContext.sendKey(0, keyCode, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('load', init);
|
||||
12
gaia/dev_apps/test-keyboard-app/js/settings.js
Executable file
|
|
@ -0,0 +1,12 @@
|
|||
document.getElementById('back').addEventListener('click', function() {
|
||||
document.addEventListener('visibilitychange', function() {
|
||||
// Close ourself after the activity transition is completed.
|
||||
window.close();
|
||||
});
|
||||
var activity = new MozActivity({
|
||||
name: 'configure',
|
||||
data: {
|
||||
target: 'device'
|
||||
}
|
||||
});
|
||||
});
|
||||
35
gaia/dev_apps/test-keyboard-app/manifest.webapp
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"name": "LOL Keyboard",
|
||||
"description": "An useless virtual keyboard that sends \\o/.",
|
||||
"type": "privileged",
|
||||
"role": "input",
|
||||
"launch_path": "/settings.html",
|
||||
"developer": {
|
||||
"name": "The Gaia Team",
|
||||
"url": "https://github.com/mozilla-b2g/gaia"
|
||||
},
|
||||
"permissions": {
|
||||
"input": {
|
||||
"description": "Send key events and characters to user focused input fields."
|
||||
}
|
||||
},
|
||||
"inputs": {
|
||||
"lol": {
|
||||
"launch_path": "/index.html",
|
||||
"name": "\\o/",
|
||||
"description": "LOL layout",
|
||||
"types": ["text", "url", "number"]
|
||||
}
|
||||
},
|
||||
"icons": {
|
||||
"30": "/style/icons/icon-30.png",
|
||||
"32": "/style/icons/icon-32.png",
|
||||
"45": "/style/icons/icon-45.png",
|
||||
"60": "/style/icons/icon-60.png",
|
||||
"90": "/style/icons/icon-90.png",
|
||||
"120": "/style/icons/icon-120.png",
|
||||
"128": "/style/icons/icon-128.png",
|
||||
"256": "/style/icons/icon-256.png"
|
||||
},
|
||||
"default_locale": "en-US"
|
||||
}
|
||||
19
gaia/dev_apps/test-keyboard-app/settings.html
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
|
||||
<meta charset="utf-8">
|
||||
<title>LOL Keyboard Settings</title>
|
||||
<script defer src="./js/settings.js"></script>
|
||||
<style>
|
||||
button {
|
||||
font-size: 2em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>LOL Keyboard Settings</h1>
|
||||
<p>Nothing to see here.</p>
|
||||
<button id="back">< Back</button>
|
||||
</body>
|
||||
</html>
|
||||
2
gaia/dev_apps/test-keyboard-app/style/icons/ICON.txt
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
Icon attributed to:
|
||||
https://commons.wikimedia.org/wiki/File:High-contrast-input-keyboard.svg
|
||||
BIN
gaia/dev_apps/test-keyboard-app/style/icons/icon-120.png
Executable file
|
After Width: | Height: | Size: 803 B |
BIN
gaia/dev_apps/test-keyboard-app/style/icons/icon-128.png
Executable file
|
After Width: | Height: | Size: 1 KiB |
BIN
gaia/dev_apps/test-keyboard-app/style/icons/icon-256.png
Executable file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
gaia/dev_apps/test-keyboard-app/style/icons/icon-30.png
Executable file
|
After Width: | Height: | Size: 521 B |
BIN
gaia/dev_apps/test-keyboard-app/style/icons/icon-32.png
Executable file
|
After Width: | Height: | Size: 432 B |
BIN
gaia/dev_apps/test-keyboard-app/style/icons/icon-45.png
Executable file
|
After Width: | Height: | Size: 701 B |
BIN
gaia/dev_apps/test-keyboard-app/style/icons/icon-60.png
Executable file
|
After Width: | Height: | Size: 613 B |
BIN
gaia/dev_apps/test-keyboard-app/style/icons/icon-90.png
Executable file
|
After Width: | Height: | Size: 930 B |
25
gaia/dev_apps/test-keyboard-app/style/keyboard.css
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
html {
|
||||
font-size: 10px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#keyboard {
|
||||
width: 100%;
|
||||
height: 20rem;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.key {
|
||||
background-color: #333;
|
||||
font-size: 2.4rem;
|
||||
border: 0.2rem solid gray;
|
||||
color: white;
|
||||
margin: 0.2rem;
|
||||
}
|
||||