2017년 3월 11일 토요일

Calling apps from the web with Android Intent


How to call the Delphi Firemonkey App from a web page via Android Intent.

At this point, the URL parameter values are sent to the App.


1. Create an html page and install it on the web. (callapp.html)
<a href="delphiapp://callType1?title=This is a Type1&data1=1111&data2=2222">call Type1</a><BR><BR>

<a href="delphiapp://callType2?title=This is a Type2&data1=3333&data2=4444&data3=5555">call Type2</a><BR><BR>

<a href="delphiapp://callType2?title=Type2 : 한글로 된 제목&data1=6666&data2=7777&data3=3번째 데이터">call Type2 한글</a><BR><BR>



2. Add the same intent-filter entry to the html page's uri entry in the AndroidManifest.template.xml file.



3. Create a Delphi Project.
procedure TForm1.FormCreate(Sender: TObject);
{$IFDEF ANDROID}
var
  intent: JIntent;
  uri: Jnet_Uri;
  uriStr: String;
  rValue : TStringList;
  i : integer;
{$ENDIF}

begin
  {$IFDEF ANDROID}
  intent := SharedActivity.getIntent;
  if intent <> nil then
  begin
    if TJIntent.JavaClass.ACTION_VIEW.equals(intent.getAction) then
    begin
      uri := intent.getData;
      uriStr := JStringToString(uri.toString);  // read uriStr

      rValue := Get_URL_String( uriStr );  // parsing value

      for i := 0 to rValue.Count-1 do
         Memo1.Lines.Add( rValue[i] );
    end;
  end;
  {$ENDIF}
end;



Demo Video

2016년 12월 6일 화요일

Firemonkey 2D/3D Graph Chart Demo Project

I release the project that draws charts using various Firemonkey's  graphical components and objects.
The Demo Project reads the data from the SQLite Database Table and draws a graph chart.

It has the following features.

  • Demo Project built with Delphi Berlin update2.
  • Multi Platform Support: Windows / Mac OS X / Android / iOS.
  • Demo uses SQLite but uses FireDAC, so all databases can be linked.
  • Database Table Generates graphs that match the aspect ratio automatically, regardless of the number of records.
  • The Demo draws two charts, but you can easily draw multiple charts simultaneously.
  • Graph range is based on maximum value of record value and can be specified at runtime.
  • 2D Graph can draw on all Firemonkey's visible objects (TControl). Demo created above Rectangle object.
  • The total size of the 2D Graph is automatically set to match the size of the dynamically generated TLayout.
  • 3D Graph can be changed by mouse or touch Viewpoint.
  • 3D Graph size is set as camera Z coordinate value.
  • The 3D Graph range is automatically set to match the size of the dynamically generated TLayout3D.
  • The front and back positions of the screen reference of the 3D chart which is generated redundant are designated as the Z coordinate value of TLayout3D.
  • For Demo, 3D Graph Chart can be easily called from other projects using TFrame.

 2D chart creation method


 3D chart creation method

Sample data (SQLite Table)









2016년 11월 2일 수요일

Draw Line any direction with TPath

Draw Line any direction with TPath

TLine object of firemonkey can draw a line to one direction.
If you want to draw line to any direction, you can use TPath.
TPath can be used drawing a curve normally.
But it is simple for line.



Sample Source

unit Unit1;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Objects, FMX.Controls.Presentation, FMX.StdCtrls;

type
  TForm1 = class(TForm)
    Rectangle1: TRectangle;
    Button2: TButton;
    Button1: TButton;
    Button3: TButton;
    Button4: TButton;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    procedure Draw_Line(pBase: TControl; x1, y1, x2, y2,thikness:single; color:Cardinal );
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.Draw_Line(pBase: TControl; x1, y1, x2, y2,thikness:single; color:Cardinal );
var
  LinePath : TPath;
  p1, p2 : TPointF;
begin
  LinePath := TPath.Create(pBase);
  LinePath.Parent := pBase;

  // p1 and p2 number is a only Direction
  // Drawing line of length is set by width and height of TPath.
  if ( x1 < x2 ) and ( y1 < y2 ) then
  begin
    p1.X := 0;     p1.Y := 0;        //  \
    p2.X := 100;   p2.Y := 100;

    LinePath.Position.X := x1;
    LinePath.Position.Y := y1;
    LinePath.Width  := x2 - x1;
    LinePath.Height := y2 - y1;
  end
  else if y1 = y2 then
  begin
    p1.X := 0;    p1.Y := 0;        //  -
    p2.X := 100;  p2.Y := 0;

    LinePath.Position.X := x1;
    LinePath.Position.Y := y1;
    LinePath.Width  := x2 - x1;
    LinePath.Height := 100;  // any value
  end
  else if x1 = x2 then
  begin
    p1.X := 0;   p1.Y := 0;        //  |
    p2.X := 0;   p2.Y := 100;

    LinePath.Position.X := x1;
    LinePath.Position.Y := y1;
    LinePath.Width  := 100;  // any value
    LinePath.Height := y2- y1
  end
  else if ( x1 < x2 ) and ( y1 > y2 ) then
  begin
    p1.X := 100;  p1.Y := 0;        //  /
    p2.X := 0;    p2.Y := 100;

    LinePath.Width  := x2 - x1;
    LinePath.Height := y1 - y2;

    LinePath.Position.X := x1;
    LinePath.Position.Y := y1 - LinePath.Height;
  end;

  LinePath.Stroke.Thickness := thikness;
  LinePath.Stroke.Color := color;
  LinePath.Data.MoveTo( p1 );
  LinePath.Data.LineTo( p2 );
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  Draw_Line( Rectangle1, 0,0, 500,300, 2, $FFFF0000 );
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Draw_Line( Rectangle1, 0,0, 500,0, 4, $FFF0000FF);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  Draw_Line( Rectangle1, 0,0, 0,300, 6, $FFFF00FF);
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  Draw_Line( Rectangle1, 0,300, 500,0, 4, $FF00FF00 );
end;