Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
e691f6d
Small changes for Android
lmbelo May 31, 2021
1a79b32
Small changes for android
lmbelo May 31, 2021
d5ad2e6
Python distribution finder app - used on pre-build event of sample apps
lmbelo Jun 1, 2021
b5bdddd
Python distributions
lmbelo Jun 1, 2021
87b6729
Base Android sample project
lmbelo Jun 1, 2021
c9ef931
Android conditionals
lmbelo Jun 3, 2021
317cce4
Android test cases project
lmbelo Jun 3, 2021
66ed9d9
Helper class for loading Python lib
lmbelo Jun 3, 2021
da03d4c
Test case - Check up Python environment on Android
lmbelo Jun 3, 2021
8078105
Test case - Check up functionality for Python types on a custom varia…
lmbelo Jun 3, 2021
73a388c
Test case - Check up numeric operations
lmbelo Jun 3, 2021
87352ac
Renamed PyEnv test case unit to the desired patter name
lmbelo Jun 3, 2021
9ec1662
Test case - Check up method callback
lmbelo Jun 3, 2021
34fea3d
MethodCallBack for ARM processor
lmbelo Jun 22, 2021
a40b688
Patching bugs on Android
lmbelo Jul 20, 2021
f520794
Wrap Delphi unit test
lmbelo Jul 20, 2021
aafb166
MethodCallback unit test adjustments
lmbelo Jul 20, 2021
69dcde0
NumberServices unit test adjustments
lmbelo Jul 20, 2021
92d87d2
PyEnv unit test adjustments
lmbelo Jul 20, 2021
ec0411b
PythonLoad unit adjustments
lmbelo Jul 20, 2021
aceeb95
VarPyth unit test adjustments
lmbelo Jul 20, 2021
2c4bed6
Including WrapDelphiTest unit to project
lmbelo Jul 20, 2021
04e9151
x64 method callback version
lmbelo Aug 1, 2021
5dd8a38
Small adjustments
lmbelo Aug 1, 2021
f40f3f0
Fixing 'GetDispatchInvokeArgs' for x64
lmbelo Aug 1, 2021
0caf39e
Adjustments for x64
lmbelo Aug 1, 2021
794f020
Removing the Android conditional. CPUX64 is not present under DCCAARM…
lmbelo Aug 4, 2021
2c6dbb6
Wrappers for FMX Media
lmbelo Aug 10, 2021
09bf7ef
Removing unused Windows unit reference from uses clause.
lmbelo Aug 10, 2021
d7f7079
Windows wrapper conditional compilation out for Android.
lmbelo Aug 10, 2021
daa63ed
Wrapper for TCameraComponent
lmbelo Aug 10, 2021
a5ec152
Fixing erroneous wraper forTListBoxItem class.
lmbelo Aug 11, 2021
d40dab7
Adding WrapFmxMedia to FMX wrappers.
lmbelo Aug 11, 2021
eb7f879
Camera preview demo initial project
lmbelo Aug 11, 2021
57d58d7
Adding wrapper for TTabItem
lmbelo Aug 11, 2021
8c52000
Adding the WrapFmxMedia unit to the FMX project
lmbelo Aug 11, 2021
73782cd
Extending method calling by rtti to support class ref parameters
lmbelo Aug 12, 2021
6ab3703
Wrapper for TTabItem component
lmbelo Aug 12, 2021
994ba9f
CameraPreviewDemo project updates to add a TTabContron and a TTabItem
lmbelo Aug 12, 2021
876df22
Build script and cleaned up some project references
Aug 14, 2021
180334e
Sample updates
lmbelo Aug 16, 2021
0020b1f
Merge branch 'selfiesample' of https://github.com/Embarcadero/python4…
lmbelo Aug 16, 2021
e85739e
Adapting to compile layouts for Linux
lmbelo Aug 24, 2021
21a3495
Support to Build for All version of Python
Aug 24, 2021
b38cceb
CameraPreviewDemo updates
lmbelo Sep 9, 2021
422766e
Adding TPyDelphiCameraComponent event handler
lmbelo Sep 9, 2021
e5ed4d6
Extending ActionsList and Action wrappers
lmbelo Sep 9, 2021
43cc0b6
New references to ActionList and Action wrappers
lmbelo Sep 9, 2021
4f62cb9
Merge pull request #1 from Embarcadero/selfiesample
lmbelo Sep 23, 2021
909b306
Adding TTrackBar wrapper
lmbelo Sep 29, 2021
5494e22
Adding TTrackBar wrapper
lmbelo Sep 29, 2021
fcfc0b5
Small adjustment
lmbelo Sep 29, 2021
5d1716e
Adding TActivityIndicator wrapper
lmbelo Sep 29, 2021
c560889
Adding WrapVclWinXCtrls to VCL wrappers
lmbelo Sep 29, 2021
8053e99
Adding partial support for VCL themes
lmbelo Oct 1, 2021
0796cbd
Adding WrapVclWinXCtrls and WrapVclThemes units to project
lmbelo Oct 1, 2021
e1cd461
Including WrapVclWinXCtrls and WrapVclThemes in VCL wrappers
lmbelo Oct 1, 2021
2b718a2
Merge pull request #2 from Embarcadero/lastmile
lmbelo Oct 1, 2021
7fa7565
Merging upstream
lmbelo Oct 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@
*.Patch
*.#00
*.pch
/Modules/DelphiFMX/pyd
/Modules/DelphiVCL/pyd
/Modules/DelphiFMX/dcu
/Modules/DelphiVCL/dcu
/Tests/TestInsightSettings.ini
165 changes: 165 additions & 0 deletions Demos/FMX/Android/CameraPreviewDemo/AppEnvironment.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
(**************************************************************************)
(* *)
(* Module: Unit 'AppEnvironment' Copyright (c) 2021 *)
(* *)
(* Lucas Moura Belo - lmbelo *)
(* lucas.belo@live.com *)
(* Brazil *)
(* *)
(* PyScripter *)
(* e-mail: pyscripter@gmail.com *)
(* *)
(* Project pages: https://github.com/Embarcadero/python4delphi *)
(* https://github.com/pyscripter/python4delphi *)
(**************************************************************************)
(* Functionality: App environment set up *)
(* *)
(* *)
(**************************************************************************)
(* This source code is distributed with no WARRANTY, for no reason or use.*)
(* Everyone is allowed to use and change this code free for his own tasks *)
(* and projects, as long as this header and its copyright text is intact. *)
(* For changed versions of this code, which are public distributed the *)
(* following additional conditions have to be fullfilled: *)
(* 1) The header has to contain a comment on the change and the author of *)
(* it. *)
(* 2) A copy of the changed source has to be sent to the above E-Mail *)
(* address or my then valid address, if this is possible to the *)
(* author. *)
(* The second condition has the target to maintain an up to date central *)
(* version of the component. If this condition is not acceptable for *)
(* confidential or legal reasons, everyone is free to derive a component *)
(* or to generate a diff file to my or other original sources. *)
(**************************************************************************)
unit AppEnvironment;

interface

uses
System.Classes, System.SysUtils, System.Threading, System.Zip, PythonEngine;

type
IProgressNotifier = interface
['{7A2D1743-D4D8-4093-B372-04D814536708}']
procedure Start(const ADescription, AFirstAction: string; const ATotal: Int64);
procedure Update(const ACurrentAction: string; const AProgress: Int64);
procedure Stop();
end;

TAppEnvInit = reference to procedure(const AInitialized: boolean; const ALastErrorMsg: string);

TAppEnvironment = class
private
FInitialized: boolean;
FProgressNotifier: IProgressNotifier;
procedure OnZipProgressEvent(Sender: TObject; FileName: string; Header: TZipHeader; Position: Int64);
procedure DoInitializeEnvironmentAsync(const APythonEngine: TPythonEngine;
const ACheckPyLib: boolean = true);
public
constructor Create(const AProgressNotifier: IProgressNotifier);

procedure InitializeEnvironmentAsync(const APythonEngine: TPythonEngine;
const ACheckPyLib: boolean; const AAppEnvInit: TAppEnvInit);

property Initialized: boolean read FInitialized;
end;

implementation

uses
System.IOUtils, FMX.Dialogs, PythonLoad;

{ TAppEnvironment }

constructor TAppEnvironment.Create(const AProgressNotifier: IProgressNotifier);
begin
Assert(Assigned(AProgressNotifier), '"AProgressNotifier" undefined');
FInitialized := false;
FProgressNotifier := AProgressNotifier;
end;

procedure TAppEnvironment.DoInitializeEnvironmentAsync(const APythonEngine: TPythonEngine;
const ACheckPyLib: boolean = true);
begin
try
//Lock user iteractions
TThread.Synchronize(nil, procedure() begin
FProgressNotifier.Start('Searching for Python installation', String.Empty, 0);
end);

Sleep(200);

//Python distibution unzip
TPythonLoad.Extract(
procedure(const AFolderExists: boolean; var AReplaceFiles: boolean) begin
if not AFolderExists then begin
TThread.Synchronize(nil, procedure() begin
FProgressNotifier.Start('Installing Python', String.Empty, 0);
end);
end;
AReplaceFiles := false;
end, OnZipProgressEvent);

//Configure Python for Android
TThread.Synchronize(nil, procedure() begin
FProgressNotifier.Start('Configuring Python for Android', String.Empty, 3);
FProgressNotifier.Update('Check for files', 1)
end);

TPythonLoad.Configure(APythonEngine);
Sleep(1000);

//Load python library
TThread.Synchronize(nil, procedure() begin
FProgressNotifier.Start('Loading Python', String.Empty, 3);
FProgressNotifier.Update('Loading and mapping library', 2)
end);

TThread.Synchronize(nil, procedure() begin
APythonEngine.LoadDll();
end);
Sleep(1000);

//All done notification
TThread.Synchronize(nil, procedure() begin
FProgressNotifier.Start('Loading environment', String.Empty, 3);
FProgressNotifier.Update('All ready', 3)
end);
Sleep(1000);
finally
TThread.Synchronize(nil, procedure() begin
FProgressNotifier.Stop();
end);
end;
end;

procedure TAppEnvironment.InitializeEnvironmentAsync(
const APythonEngine: TPythonEngine; const ACheckPyLib: boolean;
const AAppEnvInit: TAppEnvInit);
begin
TTask.Run(
procedure() begin
try
DoInitializeEnvironmentAsync(APythonEngine, ACheckPyLib);
FInitialized := true;
if Assigned(AAppEnvInit) then
AAppEnvInit(true, String.Empty);
except
on E: Exception do begin
if Assigned(AAppEnvInit) then
AAppEnvInit(false, E.Message);
end;
end;
end);
end;

procedure TAppEnvironment.OnZipProgressEvent(Sender: TObject; FileName: string;
Header: TZipHeader; Position: Int64);
begin
TThread.Queue(nil, procedure() begin
FProgressNotifier.Start('Extracting files', String.Empty, Header.UncompressedSize);
FProgressNotifier.Update(TPath.GetFileName(FileName), Position);
end);
end;

end.
17 changes: 17 additions & 0 deletions Demos/FMX/Android/CameraPreviewDemo/CameraPreviewDemo.dpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
program CameraPreviewDemo;

uses
System.StartUpCopy,
FMX.Forms,
MainForm in 'MainForm.pas' {PyMainForm},
PythonLoad in 'PythonLoad.pas',
ProgressFrame in 'ProgressFrame.pas' {ProgressViewFrame: TFrame},
AppEnvironment in 'AppEnvironment.pas';

{$R *.res}

begin
Application.Initialize;
Application.CreateForm(TPyMainForm, PyMainForm);
Application.Run;
end.
Loading