paulirotta / tantalum Goto Github PK
View Code? Open in Web Editor NEWTantalum Cross Platform Library
Tantalum Cross Platform Library
Right now LWUIT is treated as a special case of JME in PlatformUtils, but as a result some functionality does not work out of the box. Most notable is creating a StaticWebCache of com.sun.lwuit.Image objects.
If LWUIT-JME and LWUIT-Android were promoted as "platforms" we can make some of the JME support like StringUtils work out of the box for LWUIT developers.
For example StringUtils and LWUITImageTypeHandler are currently copy-paste and modified in TantalumeLWUITBBCReaderExample were moved into the library. Each LWUIT developer creating an Image cache would need to either find or re-invent these changes. There may be a LWUIT replacement for StringUtils- not sure.
LWUIT has own Font and Image classes that hide the JME Font and Image. There may be other touch points, these are the ones I'm aware of.
Can't build the project on Linux, probably due to older SDK version (latest ones not available for Windows). .jar file names are probably different (didn't check).
Error (on "gradle build") is
* What went wrong:
Could not resolve all dependencies for configuration ':Examples:testRuntime'.
> Could not find wtk:midp_2.1:.
Required by:
Tantalum:Examples:unspecified
> Could not find wtk:cldc_1.1:.
Required by:
Tantalum:Examples:unspecified
> Could not find wtk:jsr172_1.0:.
Required by:
Tantalum:Examples:unspecified
> Could not find wtk:jsr177_1.0:.
Required by:
Tantalum:Examples:unspecified
> Could not find wtk:jsr280_1.0:.
Required by:
Tantalum:Examples:unspecified
In WTK lib dir:
ville@ville-tp:~/WTK/lib$ pwd
/home/ville/WTK/lib
ville@ville-tp:~/WTK/lib$ ls
checkbox_off.png date_up.png jsr082.jar jsr239.jar popup_scrolldown.png soundbank.dls
checkbox_on.png defaultFont.svg jsr179.jar jsr75.jar popup_scrollup.png system.config
cldcapi10.jar gauge_leftarrow.png jsr180.jar link_horizontal.png radio_off.png ticker_border.png
cldcapi11.jar gauge_rightarrow.png jsr184.jar link_vertical.png radio_on.png trustedmidlet_icon.png
continuous_strip.png incremental_strip.png jsr211.jar midpapi10.jar satsa-apdu.jar trusted_prompt.png
crlf_bw.png initialFont.svg jsr226.jar midpapi20.jar satsa-crypto.jar untrusted_prompt.png
date_down.png internal.config jsr229.jar midpapi21.jar satsa-jcrmi.jar wma11.jar
date_left.png j2me-ws.jar jsr234.jar mmapi.jar satsa-pki.jar wma20.jar
date_right.png j2me-xmlrpc.jar jsr238.jar popup_arrow.png security_query.png
For development purposes, Java Standard Edition platformadapter would be useful
Currently, JsonGetter misbehaves when http connection fails. It returns jsonmodel, which craps out when called from the superclass (HttpConnection) on retry.
It's not clear what the "third party" role of Workable is. If developers are not expected to implement this interface, hide it somewhere.
A 2 page PDF, front and back, showing common use patterns with //insert blah here
Current "setProgram()" that has switching based on platform is unnecessarily complex.
Let's put the initialization functionality to platform specific classes, which does all the platform specific stuff and then all the necessary cross platform stuff (starting workers etc)
.
It could work like this:
TanlalumJmeRuntime.start(mymidlet, numberofthreads)
or
TantalumAndroidRuntime.start(activity, numberofthreads)
The part of the app where this would be called is never cross platform anyway.
Since you can chain tasks, we should make tasks that are to be executed in UI thread as just Task objects, with a property that tells whether it should be executed in ui thread or background worker:
t = new Task();
t.setUseMainLoop(true);
Add "move" method to JSONModel that retuns JSONObject currently contained in it, and sets JSONObject to null within the model
@vivainio, @paulirotta
One of the promises of using Gradle for building Tantalum was that we would have a repeatable build, and also be able to have a CI for the project. Unfortunately I've found no OSS CI providers that would support JME/WTK-builds out-of-the-box, and now that the new WTK:s are only running on Windows, it's not very likely they will in the future either.
In order to make this happen, I've experimented with building TantalumCore in Standard Edition context, and including it as a library in the JME/Android builds. My branch 'java_se_build' is pushed, and seems to pass all tests, but I have yet to test it on a JME-device. However, since it is SE, I have now been able to enable CI for TantalumCore on this branch over here:
https://travis-ci.org/TantalumMobile/Tantalum
Currently Travis builds all branches, and also all pull requests, but the only builds that will actually succeed are the ones on the java_se-branch, as it's the only one that has the required config (a .travis.yml-file in the root). Also, since all the other builds depend on WTK, they will not work properly even if this config is added. There are some caveats, which I'm not sure we'll be able to fix, but let's see.
Could you please have a look at this, and give me comments on it. We naturally still need to verify that everything works as expected, but I would hope we could merge this to master as soon as we've dealt with any issues we might have.
For HttpGetter, JSONGetter etc
There seems to be some problem related to compiling the preprocessed source files, when using Gradle 1.5.
Change to a factory pattern
We should call init() for Android init sequence as well:
try {
if (Class.forName("android.app.Activity").isAssignableFrom(program.getClass())) {
platform = PLATFORM_ANDROID;
platformAdapter = (PlatformAdapter) Class.forName("org.tantalum.android.AndroidPlatformAdapter").newInstance();
init(logMode); // <=== MISSING
return;
}
} catch (Throwable t) {
System.out.println("Can not init Android in setProgram(" + program.getClass().getName() + ") : " + t);
}
try {
if (Class.forName("javax.microedition.midlet.MIDlet").isAssignableFrom(program.getClass())
|| program.getClass().getName().toLowerCase().indexOf("test") > 0) {
platform = PLATFORM_JME;
platformAdapter = (PlatformAdapter) Class.forName("org.tantalum.jme.JMEPlatformAdapter").newInstance();
init(logMode);
return;
}
} catch (Throwable t) {
System.out.println("Can not init JME in setProgram(" + program.getClass().getName() + ") : " + t);
}
Jari is thinking on this. Ideas needed.
Allow running with standard eclipse.
Approach; add "apply plugin: 'eclipse'" in root build.gradle.
Run "gradle eclipse".
In eclipse, import the directory as "existing project". You should now have something you can build and run.
Currently (RMSUtils.java) we open separate RecordStore for every record we read.
Explore the performance (benchark!) of reusing same RecordStore for all items.
Simpler standard FP nomenclature for a future / promise
Less state transitions good for speed
Associated changes to fork priority state continue to check at point of error so the developer is warned with clear exceptions of attempts to multi-fork-chain
doInBackground is too verbose, and can be confusing when the operation doesn't happen in the background (it can happen on UI task as well)
If someone has IPR-clean implementations they can write or donate to the project to put in StringUtils that would be much appreciated.
It's not really clear what the function of stuff like java.net.* in the project is. We should look for a way to remove them (e.g. build different jar for jme and android)
Hi!
Part of the reason of originally moving the build over to Gradle was to enable us to have a repeatable build, and more importantly, CI for the project. JME has proved to be the tricky part, as none of the open providers seem to support JME/WTK-builds. The situation has not improved with the latest releases, which only run on Windows. We could trick the process to work (I've been able to build using Windows jars on my OS X) but I think we'd break several EULAs and would most probably get no support for setting this up.
In order to tackle the problem, we've talked with Paul to have the core library be built in standard Java, and only the platform specific builds require special frameworks and tools to build. This would also make the test setup a lot less intimidating, as we no longer need to have separate test projects to make it work. I've worked on this in the 'java_se_build'-branch, and finally got it working now. The results can be seen here:
https://travis-ci.org/TantalumMobile/Tantalum/
Travis supports a lot of nice things, so it will e.g. build all new pull requests so that they can automatically be discarded would there be any problem with them. Travis also builds all the pushed branches, so there is no need for any extra config for that part.
The problem at the moment is that the only branch that actually supports CI-builds is the java_se-branch, as the other ones will fail due to missing Java ME-installation. My suggestion would be to verify that this branch works as expected also with the WTK-build, and then merge it in to master as soon as possible. Until we do so, most of the builds in Travis will be failed.
Please have a look, and let me know what you think. If we find it useful, I will write down some more details about this in the Wiki.
There are two examples of a simple JSON service that converts a text string into latitude and longitude.
Some updates are needed:
If time permits, it is nice to demonstract in this app the offline AJAX-style live update from cache as you type. Each key press in the Form input field can trigger a StaticWebCache.getAsync(currentTextFieldText.trim(), StaticWebCache.GET_LOCAL) which updates the field with any cached values which match, before you click a SEARCH button. PicasaViewer has a more complex version of this on a Canvas UI, but Form is more accessible.
"Promises" seem to be quite popular/well known already in JS-land. Explore the opportunity to have promise like API (or see whether it's redundant).
Need wiki page how to set up module testing environment and add module tests
An XSLT shoudl do it:
http://stackoverflow.com/questions/3944129/findbug-ant-xslt-stylesheet-source-code-references
It would also be nice to have all such HTML reports referenced from one page
Many Android developers would be reluctant to give up to use a library that lacks generics.
Is there an elegant way to offer the best of both worlds? I've been thinking about some adaptation layer or GenericObject adaptor, but the solution is not simple and preprocessor games seem ill advised.
j2me is deprecated terminology
This is how I think we should release Tantalum going forward:
https://github.com/TantalumMobile/Tantalum/wiki/Release-strategy
(i.e. no JAR's).
Please approve/criticize in this Issue, and modify the wiki page accordingly
Currently no preprocessing is done for the source files, so the release build is identical to the debug build. We'd need to add a preprocessor into the flow, so that we can create a more compact binary release.
The problem with this is that when we moved over to create JSE-build, we also had to drop the dependency on Antenna. Antenna requires the WTK to be installed, which is not going to be possible on our build infrastructure (I think). We'd either need one of these 4 things to happen:
I'm currently looking into 4), but since this will take a few iterations to complete, I'm going to see whether 1) or 2) would actually be faster.
3) doesn't seem to be too easy to find, based on a fierce googling session I had before
Right?
It would be nice to cache much larger data sets, for example on the phone's memory card.
This involves implementing FlashCache for the file system. Only a few methods, but must also handle memory card removal and recover from bad things like user tampering.
We need a minimal "tantalum app" that does nothing but initializes Tantalum with TantalumRuntime, has minimal LCDUI Form and logs "hello world" with L.i().
Purpose is to convert it to SDK template
This won't work without default ctor:
platformAdapter = (PlatformAdapter) Class.forName("org.tantalum.android.AndroidPlatformAdapter").newInstance();
Kingsley Adio is reporting problems with USB debug not starting reliably on some phones.
I'll refactor that initialization of this setup (where your phone is connected by USB cable and dumps error logs to a terminal window) for speed, easier start and reliability.
JSONGetter should return JSONObject directly. There is no need to protect from multithreaded access since JSON objects coming over the network are typically used in immutable read-only fashion.
You find instances of "Tantalum mobile toolkit", "Tantalum mobile" etc.
We need an agreed "fully qualified name" to use in documentation, presentation etc.
"Tantalum mobile"
"Tantalum mobile toolkit"
"Tantalum Java library"
"Tantalum cross platform toolkit"
"Tantalum cross platform mobile framework"
etc. etc.
Personally no strong preference (yet), but let's pick one and be consistent.
Kingsley is looking to fork and create the BB port. Not for the T5 release but probably T6.
Let him know if you can help.
Instead of dealing with byte[] in ram, we should allow POST/GET to/from stream directly.
interface StreamWriter {
void writeReady(OutputStream out);
}
interface StreamReader {
void readReady(InputStream in);
}
HttpPoster p; ...
p.setStreamWriter(new StreamWriter() {
... write directly to socket instead of going through intermediate byte[] buffer...
});
HttpGetter g;
g.setStreamReader(...)
Simplify, the rejection code flow should be the same
Rename TantalumMidlet to TantalumRuntime, do not sublclass from MIDlet.
Provide start() that is to be executed in MIDlet ctor.
Many things have changed, usually for the simpler. The quick start DOC in git needs to be be refereshed accordingly.
USB debug is supported on phones which give a serial port through USB. But this requires you to be tethered to view a live log.
A new mode to store the log on the USB card as a file is needed
Trying this url, there is no Content-Length header,
http://www.sodexo.fi//ruokalistat/output/daily_json/731/1/1/2013/en?mobileRedirect=false
In HttpGetter::exec, this leads to "length" being 0, and us going to this branch:
L.i(this.getClass().getName() + " exec", "No response. Stream is null, or length is 0");
Instead of:
} else {
bos = new ByteArrayOutputStream(16384);
readBytesVariableLength(inputStream, bos);
out = bos.toByteArray();
}
Network capture below:
GET /ruokalistat/output/daily_json/731/1/1/2013/en?mobileRedirect=false HTTP/1.1
User-Agent: ***
Host: www.sodexo.fi
Connection: Keep-Alive
Accept-Encoding: gzip
HTTP/1.1 200 OK
Server: nginx/1.0.11
Date: Fri, 19 Apr 2013 06:35:54 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/5.3.8
X-Drupal-Cache: MISS
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified: Fri, 19 Apr 2013 06:35:54 +0000
Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0
ETag: "1366353354"
Set-Cookie: SESSee97dcf51c4e7f072056872f1ea10323=TNNdXst9Gv6iTXOWLbGzooI13tCzSLijWwl_ZewOzCc; expires=Sun, 12-May-2013 10:09:14 GMT; path=/; domain=.sodexo.fi; HttpOnly
90
{"meta":{"generated_timestamp":1366353354,"requested_timestamp":false,"ref_url":"http:\/\/www.sodexo.fi\/node\/","ref_title":null},"courses":[]}
0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.