I must develop (for my job) an Android client to query and update databases (dbf files, living on our LAN server) via the Internet, of course.
I've achieved similar thing with HMGWEB R.11, but I must to change my development strategy.
The reason for change, is that until now, Android clients worked on remote sites via wi-fi with fast and reliable connections.
Now, this new app requirement is for really mobile clients (working on the streets, from cars, etc). So, I'll depend on Internet provided by cellular network.
Cellular network here is a nightmare (slow, unstable and very expensive).
So, to make my app work, I must minimize the use of the network.
Harbour for Android?: No!
I've took a look at current Harbour for Android development status and the situation is the following:
Harbour 'console' applications con be done easily, the problem is that a console app is unacceptable (and maybe unusable) for an Android user.
AFAIK, the only open source development currently in progress, is qtcontribs by Pritpal, but Android tutorial is not finished and I was not able to succeed creating an application.
The process of creating Harbour+QT Android apps requires install and configure Android SDK, Android NDK, Apache Ant, Java, QT and (of course) Harbour (the process is slightly simplified by qtcontribs distro).
We must be very careful about versions of each thing installed.
If you survive installation process, you must to properly configure all the tools to make it work together and (finally) have your Harbour/QT for Android application working.
Well... as I've said... I was unable to reach that goal.
But there is another thing to consider: according reports that you can find simply googling a little, for some developers, QT for Android apps are big and slow on some devices... SURPRISE!
I live in a underdeveloped country, so, I can't think on terms of 'high-end' devices. I mean that my apps likely will not be used on a Xperia Z3 or a Galaxy S5, but in a more 'modest' hardware, so, performance of the application is a big concern for me.
So, after considering it for weeks, I've decided that my client app, WILL NOT BE Harbour based.
As I've stated many times, the solution for this could be extremely simple. The only thing required, could be adding interfaces for Android Webview to Harbour, then we could use simple HTML to interface with the users. Sadly I have not enough knowledge/time to do this myself, so, I can only ask for it.
The Solution:
An 'HTML + jQuery Mobile' client that send and receive data to an Apache web server, hosting Harbour CGI apps.
The tricks here are:
- ALL user interfaces will be contained in an UNIQUE HTML file, loaded once by the entire life of the user session.
- Then: No page reloads AT ALL!.
- To retrieve information from server and get the status of database update operations I'll use AJAX. So, the data returned from the server will be displayes inside a 'div' WITHOUT PAGE RELOADS.
- The only 'problem' is that you should must have knowledge about HTML, jQuery, JavaScript, CSS and jQuery Mobile. But, we could make slight modifications to HMGWEB to 'compile' a source file with form definitions to create an unique 'multi-page' HTML file for our app.
- Without page reloads, the session handling becomes tremendously easy.
- Eventually you could use anything on the server instead of Harbour CGI (ie: PHP+MySql).
The Example:
This is plain HTML+jQuery Mobile concept. You could make it work from HMGWEB R11 setup
(In such case, you will only use Harbour and Apache from it to run this example)
This will be our index.html file (it must live in c:\hmgweb\apache\htdocs):
Code: Select all
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css">
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
<script language="JavaScript">
$(document).ready(function() {
$('#create').submit(function() { // catch the form's submit event
$.ajax({ // create an AJAX call...
data: $(this).serialize(), // get the form data
type: $(this).attr('method'), // GET or POST
url: $(this).attr('action'), // the file to call
success: function(response) { // on success..
$('#created').html(response); // update the DIV
}
});
return false; // cancel original event to prevent form submitting
});
});
</script>
</head>
<body>
<div data-role="page" id="pageone">
<div data-role="header">
<h1>Welcome To My Homepage</h1>
</div>
<div data-role="main" class="ui-content">
<p>Welcome! If you click on the link below, it will take you to Page Two.</p>
<a href="#pagetwo">Go to Page Two</a>
<br>
<p>Form</p>
<form id=create method=POST action=cgi-bin/test.cgi>
<input type=text name=url>
<input type="submit" value="Create" />
</form>
<p>Before div</p>
<br><br><hr>
<div id=created>Result</div>
<br><br><hr>
<p>After div</p>
<br>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
<div data-role="page" id="pagetwo">
<div data-role="header">
<h1>Welcome To My Homepage</h1>
</div>
<div data-role="main" class="ui-content">
<p>This is Page Two. If you click on the link below, it will take you to Page One.</p>
<a href="#pageone">Go to Page One</a>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
</body>
</html>
You must name it 'test.prg' and its compiled version (test.cgi) will live in c:\hmgweb\apache\cgi-bin
Code: Select all
REQUEST HB_GT_CGI_DEFAULT
function Main()
outstd("Content-type: text/html" + hb_OSNewLine() + hb_OSNewLine())
outstd( 'Hey!!!!')
return nil
An HTML client app, will work not only in Android, but in IOS too.
In fact it will work in any device with a jQuery Mobile compatible web browser, including desktops.
The Future:
I don't know if I'll have enough time to make the appropriate changes to turn HMGWEB into a translator, able to create an html file, from a forms definition file. If not, I'll code HTML+JQM directly, but maybe someone could have it. This is the reason to expose this idea here. Most of current HMGWEB code could be reused.
Good Luck!