Skip to content

Commit

Permalink
更新可以在kaios运行的版本
Browse files Browse the repository at this point in the history
更新可以在kaios运行的版本
  • Loading branch information
zixing131 committed Nov 16, 2021
1 parent c263ce5 commit 2e84af0
Show file tree
Hide file tree
Showing 12 changed files with 463 additions and 15 deletions.
4 changes: 3 additions & 1 deletion bld/main-all.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions config/runtests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
config.jars = "tests/tests.jar";
config.jad = "tests/runtests.jad";
config.midletClassName = "RunTestsMIDlet";
config.jars = "tests/Anyview4.0.jar";
config.jad = "tests/Anyview4.0.jad";
config.midletClassName = "com.ismyway.anyview.Anyview";

MIDlet.shouldStartBackgroundService = function() {
return fs.exists("/startBackgroundService");
Expand Down
Binary file added img/icon-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<script type="text/javascript" src="config/build.js" defer></script>
<script type="text/javascript" src="config/urlparams.js" defer></script>
<script type="text/javascript" src="timer.js" defer></script>
<script type="text/javascript" src="index.js" defer></script>
<script type="text/javascript" src="index.js" defer></script>
</head>

<body><iframe id="mozbrowser" mozbrowser></iframe></body>
Expand Down
11 changes: 8 additions & 3 deletions keymap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

//----------------------keymap

function handleKeydown(e) {
console.log(e.key);
function handleKeydown(e) {
if (e.key != "EndCall" && e.key!="Backspace") {
e.preventDefault();//清除默认行为(滚动屏幕等)
}
switch(e.key) {
case 'ArrowUp':
MIDP.sendKeyPress(-1);
Expand Down Expand Up @@ -57,14 +59,17 @@ function handleKeydown(e) {
MIDP.sendKeyPress(42);
break;
case '#':
start();
MIDP.sendKeyPress(35);
break;
}
}


function handleKeyup(e) {
console.log(e.key);
if (e.key != "EndCall" && e.key!="Backspace") {
e.preventDefault();//清除默认行为(滚动屏幕等)
}
switch(e.key) {
case 'ArrowUp':
MIDP.sendKeyRelease(-1);
Expand Down
2 changes: 1 addition & 1 deletion main.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<!-- Load the rest of the scripts from the combined script main-all.js
- to improve startup and runtime performance. See Makefile for the list
- of files that get combined into this one. -->
<script type="text/javascript" src="bld/main-all.js" defer></script>
<script type="text/javascript" src="bld/main-all.js" defer></script>
<script type="text/javascript" src="keymap.js" defer></script>
</head>

Expand Down
14 changes: 8 additions & 6 deletions manifest.webapp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "PluotSorbet",
"name": "AnyView",
"description": "a J2ME-compatible virtual machine written in JavaScript",
"launch_path": "/index.html?jars=tests/Anyview4.0.jar&jad=tests/Anyview4.0.jad&midletClassName=com.ismyway.anyview.Anyview",
"origin": "app://pluotsorbet.mozilla.org",
"launch_path": "/main.html",
"origin": "app://pluotsorbet.AnyView.org",
"version": "1624444801",
"icons": {
"128": "/img/icon-128.png",
Expand Down Expand Up @@ -51,16 +51,18 @@
}
},
"messages": [
{ "alarm": "/index.html" }
{ "alarm": "/main.html" }
],
"activities": {
"share": {
"href": "/index.html",
"href": "/main.html",
"disposition": "window",
"filters": {
"type": ["image/*", "video/*", "audio/*"]
}
}
},
"type": "privileged"
"type": "web",
"cursor": false,
"fullscreen": true
}
38 changes: 38 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
DumbPipe.registerOpener("echo", function(message, sender) {
sender(message);
});

// Generate faked location data for tests
LocationProvider.AVAILABLE = 1;
DumbPipe.registerOpener("locationprovider", function(message, sender) {
return function(message) {
switch (message.type) {
case "requestData":
sender({
type: "data",
position: {
timestamp: Date.now(),
latitude: 45,
longitude: -122,
altitude: 500,
horizontalAccuracy: 200,
verticalAccuracy: 10,
speed: 90,
course: 2
},
state: LocationProvider.AVAILABLE
});
break;
}
};
});

var backgroundChecks = 0;

DumbPipe.registerOpener("backgroundCheck", function() {
backgroundChecks++;
});

DumbPipe.registerOpener("getBackgroundChecks", function(message, sender) {
sender(backgroundChecks);
});
65 changes: 65 additions & 0 deletions tests/mozactivitymock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */

var lastSMSNumber = null;
var lastSMSBody = null;
var lastAddContactParams = null;

DumbPipe.registerOpener("lastSMSNumber", function(message, sender) {
sender(lastSMSNumber);
});

DumbPipe.registerOpener("lastSMSBody", function(message, sender) {
sender(lastSMSBody);
});

DumbPipe.registerOpener("lastAddContactParams", function(message, sender) {
sender(lastAddContactParams);
});

function MozActivity(obj) {
if (obj.name === "new") {
switch (obj.data.type) {
case "websms/sms":
lastSMSNumber = obj.data.number;
lastSMSBody = obj.data.body;
break;

case "webcontacts/contact":
lastAddContactParams = obj.data.params;

break;

default:
throw new Error("MozActivity with type " + obj.data.type + " not supported");
}

nextTickBeforeEvents((function() {
this.onsuccess();
}).bind(this));

} else {
throw new Error("MozActivity " + obj.name + " not supported");
}
}

var messageHandlers = {};
navigator.mozSetMessageHandler = function(name, func) {
messageHandlers[name] = func;
}

DumbPipe.registerOpener("callShareActivityMessageHandler", function(message, sender) {
var activity = {
source: {
name: "share",
data: {
"type": "image/*",
"number": 1,
"blobs": [ new Blob([]) ],
"filenames": ["j2mesharetestimage" + message.num + ".jpg"],
"filepaths": ["/sdcard/DCIM/100MZLLA/j2mesharetestimage" + message.num + ".jpg"]
},
},
};
messageHandlers["activity"](activity);
});
38 changes: 38 additions & 0 deletions tests/mozactivitymock.unprivileged.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */

Native["javax/wireless/messaging/SendSMSTest.getNumber.()Ljava/lang/String;"] = function(addr) {
asyncImpl("Ljava/lang/String;", new Promise(function(resolve, reject) {
var sender = DumbPipe.open("lastSMSNumber", {}, function(lastSMSNumber) {
DumbPipe.close(sender);
resolve(J2ME.newString(lastSMSNumber));
});
}));
};

Native["javax/wireless/messaging/SendSMSTest.getBody.()Ljava/lang/String;"] = function(addr) {
asyncImpl("Ljava/lang/String;", new Promise(function(resolve, reject) {
var sender = DumbPipe.open("lastSMSBody", {}, function(lastSMSBody) {
DumbPipe.close(sender);
resolve(J2ME.newString(lastSMSBody));
});
}));
};

Native["com/sun/midp/midlet/AddContactTest.getNumber.()Ljava/lang/String;"] = function(addr) {
asyncImpl("Ljava/lang/String;", new Promise(function(resolve, reject) {
var sender = DumbPipe.open("lastAddContactParams", {}, function(lastAddContactParams) {
DumbPipe.close(sender);
resolve(J2ME.newString(lastAddContactParams.tel));
});
}));
};

Native["com/sun/midp/midlet/AddContactTest.hasNumber.()Z"] = function(addr) {
asyncImpl("Z", new Promise(function(resolve, reject) {
var sender = DumbPipe.open("lastAddContactParams", {}, function(lastAddContactParams) {
DumbPipe.close(sender);
resolve(lastAddContactParams.tel ? 1 : 0);
});
}));
};
Loading

0 comments on commit 2e84af0

Please sign in to comment.