Showing posts with label iOS. Show all posts
Showing posts with label iOS. Show all posts

Friday, March 24, 2017

One codebase to rule them all - RAD Studio 10.2 Tokyo is here!

Finally, it's arrived!! The penguin invasion has started! RAD Studio 10.2 Tokyo is here bringing with it support for Linux!
Delphi for Linux is now available delivering support for Linux 64bit server-side and standalone applications for Ubuntu and RedHat Enterprise. Guys, I'm very enthusiastic about this new support! This is a very greats news for Delphi developers and not, everywhere!


By now Delphi can support and generate native code for several platforms (7 to be exact!!!): Linux (64bit), Windows (x86 and x64), OS X (32-bit ), iOS (32 and 64-bit) and Android.
I think that no citation may be more appropriate of this:
one codebase to rule them all
Below a list of the most interesting features available in this release (IMHO):

Delphi Linux Compiler


  • 64-bit Linux platform support
  • Delphi language support
  • ARC-enabled
  • 1-based strings
  • LLVM engine based

Supported Linux Distributions


  • Ubuntu Server (Ubuntu 16.04 LTS)
  • RedHat Enterprise Linux (version 7)

RTL features supported


  • Linux file system access
  • Threading and Parallel Programming Libraries support
  • Memory management
  • HTTP and REST libraries support for HTTP calls

64-bit Linux for Server Applications


  • FireDAC provides Linux support for all Linux-capable DBMS, with the only exception of Informix. See Database Connectivity.
  • WebBroker, RAD Server (EMS), and DataSnap support for Multi-tier servers (standalone and Apache modules).
  • DUnitX support.
  • PAServer support.
  • Indy-based client and server support.

FireMonkey


  • New System Status Bar Options on iOS
    • Two new properties have been added to TForm for changing the behavior of the system status bar on iOS: SystemStatusBar.BackgroundColor and SystemStatusBar.Visibility.


  • Multi-Threading Support for TBitmap, TCanvas and TContext3D
  • Unification of Delphi and Java threads on Android: CallInUIThread has been deprecated. All code is now running in the Java UI Thread, removing the need for thread synchronization

Improvements for Firebird


  • New Direct property to add support for the Direct I/O backup feature.

Improvements for MySQL

  • Support for MySQL v 5.7.
  • Support for MariaDB v 5.5 or later. Use FireDAC's MySQL node to connect to MariaDB.
  • Compatibilty with the recent MySQL versions 5.6.x and 5.7.x.

Database improvements


  • VCL TDBImage direct support for JPEG and PNG graphic formats.
  • Support for display options for BlobFields.
  • Direct GUID access for TField classes.

RTL


  • HTTP Client
  • HTTP Client Library provides support for 64-bit Linux.
  • Improved async support in HTTP client
  • RTL support for 64-bit Linux
  • RAD Studio 10.2 Tokyo provides Linux file system support using standard system functions, streams, and the IOUtils unit. It also provides Standard RTL Path Functions support for 64-bit Linux.

Improved C++ packages for mobile

RAD Studio 10.2 Tokyo links C++ packages for iOS and Android statically. Previous versions of RAD Studio generated a file with the .so extension for C++ packages, but were not actually dynamic libraries. RAD Studio 10.2 Tokyo generates C++ packages with the correct file extension (.a). If you statically link against a .so package, you may need to change to link against the new filename.

RAD Server Multi-Tenancy Support

With Multi-Tenancy support, a single RAD Server instance with a single RAD Server database connection can support multiple isolated tenants. Each tenant has a unique set of RAD Server resources including Users, Groups, Installations, Edge Modules, and other data. All tenants have custom resources that are installed in the EMS Server. Also, as an administrator you can create new tenants, edit existing ones, add, edit, or delete details of your tenants, specify if the tenant is active, and delete the tenants that you do not need.

iOS 10 Simulator, device, and macOS

Full support for iOS 10, including iOS 10 32-bit and 64-bit debugging on device, Simulator support (Delphi only) and macOS Sierra support.

The news are not only these, for the complete list of all news of this release go here.

Sunday, February 19, 2017

How-To implement 2 finger pan gesture in Delphi Firemonkey

In Firemonkey, as you know, there is a great support for gestures: standard and interactive. The most important interactive gestures as Zoom, Pan, Rotate, DoubleTap (with an amazing description in dockwiki ), etc... are provided by the framework. See here for a full documentation. In a recent project I had the need to implement 2 finger pan gesture, that is not present in the provided gestures. But Firemonkey is a very great framework, and you can implement an event handler to manage custom actions when OnTouch occurs to specify what happens when a user touches the form using a finger or a similar device (not a mouse). So I wrote a little snippet of code that simulate the 2 finger pan gesture, I created a new demo and moved it into my Delphi Demos repository on Github.
I tried it on Android and works fine and very smoothly. It should works fine on all Firemonkey supported platforms: Windows, Android, iOS and OSX.

Thursday, October 9, 2014

Automate Save State Feature in Firemonkey

Hi!
One of the many exciting new features of Delphi XE7 is the Save State in Firemonkey.
The FireMonkey Save State feature allows you to save data describing the state of the application before it closes. The Save State data can be used to recover the state after the application is restarted.
This is a very cool feature but the way in which you save and restore the data is not so refined (for more info see this http://docwiki.embarcadero.com/RADStudio/XE7/en/FireMonkey_Save_State ).
What happen if I need to save 10,15 or more components? I need to specify the save and the restore for each one.
So I decided to write a class helper to automate this process!
Using JSON serialization all the components of type TFMXObject are saved. In particular is stored the Data property.

You can find the demo in my github repository .

This is a snippet of the demo

uses SaveStateHelper;

procedure TForm1.FormCreate(Sender: TObject);
begin
  LoadFormState;
end;

procedure TForm1.FormSaveState(Sender: TObject);
begin
  SaveFormState;
end;

I hope you enjoy it!!

Tuesday, June 3, 2014

Access Marvel Developer API with Delphi XE6



Marvel has recent made available The Marvel Comics API, that allows developers everywhere to access information about Marvel Universe. "The Marvel Comics API is a RESTful service which provides methods for accessing specific resources at canonical URLs and for searching and filtering sets of resources by various criteria. All representations are encoded as JSON objects".



So my idea is to access these API with the Delphi REST Client Library and create an awesome app.
Let's start!
At First we need to register to the developers program, once registered we will be given 2 keys one public and the other private that will be used to call the Marvel API. For more information about the service, resources, authentication and so on I refer you to the official Pages: General Info - Getting Started - Interactive API tester.
You can access six resource types using the API:

  • Comics
  • Comic Series
  • Comic Stories
  • Comic events and crossovers
  • Creators
  • Characters

In this first demo app I get information only about characters of Marvel Universe.




I created an HeaderFooter Mobile Application by the wizard, modified the text of prebuilt label for the Title ("Marvel Character"), added a TLabel for the name of the Character, a TImage that is the representative image for the character and finally I insert the mainly 3 components of the REST Client Library: RESTClient, RESTRequest and RESTResponse.
The Marvel Comics API’s base endpoint is http://gateway.marvel.com/v1/public so I put this URL in the BaseURL property of the RESTClient.



The RESTRequest represent the resource in the REST pattern and in this case represent the character. I defined the Resource property in this way: characters?limit=1&offset={OFFSET}&ts={TS}&apikey={APIKEY}&hash={HASH}.
There are 3 parameters:
  • limit - that represent the number of the result, in this case 1 result for time because we can see 1 character at time on the form
  • offset - that indicate the distance from the first character
  • ts - a timestamp (or other long string which can change on a request-by-request basis)
  •  apikey - your public key
  • hash - a md5 digest of the ts parameter, your private key and your public key (e.g. md5(ts+privateKey+publicKey)
This is the snippet code of request:

procedure THeaderFooterForm.ExecuteRequest;
var
  TS: string;
  imd5: TIdHashMessageDigest;
  HASHStr: string;
begin
  // StartWait show a progress dialog until the request is finished
  StartWait;
  TS := IntToStr(DateTimeToUnix(Now));
  RESTRequest1.Params.ParameterByName('OFFSET').Value := FOffSet.ToString;
  RESTRequest1.Params.ParameterByName('TS').Value := TS;
  RESTRequest1.Params.ParameterByName('APIKEY').Value := PUBLIC_KEY;
  imd5 := TIdHashMessageDigest5.Create;
  try
    HASHStr := TS + PRIVATE_KEY + PUBLIC_KEY;
    RESTRequest1.Params.ParameterByName('HASH').Value :=
      imd5.HashStringAsHex(HASHStr).ToLower;
    RESTRequest1.ExecuteAsync(OnAfterRequest);
  finally
    imd5.Free;
  end;
end;

Once the call give a result will need to parse the JSON response to take the name of the character and its image, obviously respecting the JSON structure described in the official documentation:

procedure THeaderFooterForm.OnAfterRequest;
var
  RetObject: TJSONObject;
  RetData: TJSONObject;
  MResult: TJSONObject;
  Loader: TImageLoaderThread;
  Thumbnail: TJSONObject;
begin
  try
    RetObject := TJSONObject.ParseJSONValue(RESTResponse1.Content)
      as TJSONObject;
    RetData := RetObject.GetValue('data') as TJSONObject;
    MResult := (RetData.GetValue('results') as TJSONArray).Get(0)
      as TJSONObject;
    Thumbnail := MResult.GetValue('thumbnail') as TJSONObject;
    Text1.Text := MResult.GetValue('name').Value;
    // TImageLoaderThread is a custom class to retrieve the image in a background thread
    // and 2 anonymous methods to notify when thread finish download image and when bitmap is ready  
    Loader := TImageLoaderThread.Create(true, nil, OnBitmapLoaded);
    Loader.ImgURL := Thumbnail.GetValue('path').Value + '.' +
      Thumbnail.GetValue('extension').Value;
    Loader.Start;
  finally
    StopWait;
  end;
end;

The image is provided by another URL so I have to make another request for the image.
Both the request (info character + image) are completed by background threads so it doesn't block the GUI.
Here some screeenshot about final app





The app run on Android device but the code work on Android, iOS, Windows and Mac.
In the next post I will improve the app creating a master-detail structure that allowing to search character by other criteria!
The code was loaded on my github repository.

Tuesday, March 11, 2014

Gideros Mobile - A game development tool

Gideros is a set of software packages created and managed by a company named  Gideros Mobile, it provides developers with the ability to create 2D games for multiple platforms by reusing the same code.

At italian DROIDCON in Turin, I held a speech about the Gideros Mobile framework (the slides will be available shortly).

We appreciate this tool so much that in bit Time Software we decided to make a game using Gideros: Math Brain. It's free and available for Android and iOS devices.


To start developing with Gideros I suggest the online tutorials and the book Gideros Mobile Game Development. Here you can find some considerations about the book written by me and my colleague Daniele Teti.

I hope to write soon new post about this tool.