Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #236 from malcolmgroves/delphi-xe5-android
Browse files Browse the repository at this point in the history
Updated for Delphi XE5 iOS and Android
  • Loading branch information
ColinEberhardt committed Jan 31, 2014
2 parents cee8047 + 139eb46 commit eb2a140
Show file tree
Hide file tree
Showing 27 changed files with 6,244 additions and 5,725 deletions.
36 changes: 15 additions & 21 deletions delphi/README.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,54 @@
#Delphi Implementation

Visit the *Delphi page* (this will be live shortly) on the PropertyCross website for screenshots and code sharing metrics.
Visit the [Delphi page](http://propertycross.com/delphi/) on the PropertyCross website for screenshots and code sharing metrics.

##Introduction

Embarcadero Delphi is an integrated development environment for developing applications across a range of platforms. Applications are written using [Object Pascal](http://en.wikipedia.org/wiki/Object_Pascal) and the [FireMonkey](http://en.wikipedia.org/wiki/FireMonkey) UI framework. The latest release of Delphi XE4 is the first release of FireMonkey that supports mobile application development for the iOS platfom. Android support is currently in development.
Embarcadero Delphi is an integrated development environment for developing applications across a range of platforms. Applications are written using [Object Pascal](http://en.wikipedia.org/wiki/Object_Pascal) and the [FireMonkey](http://en.wikipedia.org/wiki/FireMonkey) UI framework. The latest release of Delphi XE5 supports mobile development on both iOS and Android, as well as desktop platforms.

Delphi applications are written using the Delphi XE IDE which has a graphical UI editor for iOS applications. Compilation requires a Mac computer with Xcode, with the Delphi IDE communication to the Mac via 'PAServer'. Applications written using Delphi present a fully native user interface.
Delphi applications are written using the Delphi XE5 IDE which has a graphical UI editor for mobile applications. Deployment to iOS requires tcp access to a Mac with the Xcode command-line tools, with the Delphi IDE communicating to the Mac via a 'PAServer' agent. Deployment to Android can all be done from Windows. Applications written using Delphi present a fully native user interface.

##Building the Application

### Requirements

The property cross example code is designed to work with the following editions of Embarcadero's RAD Tools.

- RAD Studio XE4 (Pro or above)
- Delphi XE4 Enterprise, Architect or Ultimate edition.
- RAD Studio XE5 (Pro or above)
- Delphi XE5 Enterprise, Architect or Ultimate edition.

A trial version is available from the [Embarcadero website](http://www.embarcadero.com/products/delphi/downloads).

#### Additional iOS Requirements

In addition to your development PC, you need the following to develop mobile applications for iOS:

- A Mac running OS X
- An iOS device, connected to your Mac by USB cable

See the [FireMonkey Prerequisites](http://docwiki.embarcadero.com/RADStudio/XE4/en/FireMonkey_Platform_Prerequisites) documentation.
See the [FireMonkey Prerequisites](http://docwiki.embarcadero.com/RADStudio/en/FireMonkey_Platform_Prerequisites) documentation.

You will need to ensure you have installed on the Mac

- Xcode with Command line tools
- PAServer (part of the install Delphi / RAD Studio install)

### Set-up

Configuration of the IDE ready for Mac and iOS development
You will also need to make sure that (if you want to deploy to the device) you have you device provisioned and accessible. You will require your Apple developer account for this. If you have a device already provisioned for use with XCode then you should be good to go.

See the following guides
- PAServer (part of the Delphi / RAD Studio install)

As mentioned above, for Android development no Mac is required.

- [Set up your development environment for Mac](http://docwiki.embarcadero.com/RADStudio/XE4/en/IOS_Tutorial:_Set_Up_Your_Development)
- [Set up your development environment on Windows](http://docwiki.embarcadero.com/RADStudio/XE4/en/IOS_Tutorial:_Set_Up_Your_Development_Environment_on_Windows_PC)


More on the set-up available here (including code signing help):
### Set-up

http://docwiki.embarcadero.com/RADStudio/XE4/en/IOS_Mobile_Application_Development
There are step-by-step guides to setting up your development environment for iOS and Android development as part of the [Mobile Application Development Tutorials](http://docwiki.embarcadero.com/RADStudio/XE5/en/Mobile_Tutorials:_Mobile_Application_Development_(iOS_and_Android)

### Running the project

Once your environment is configured open **PropertyCrossDelphi.proj** via **File >
Once your environment is configured open **PropertyCrossDelphi.dproj** via **File >
Open Project** in the IDE.

On your screen you should see the main form along with the Project Manager (top right)


Choose the build configuration and also target platform you desire from the Project Manager. Ensure that the PA Server is running on the Mac and your device is unlocked (if deploying to the device) and choose run without debugging (or Ctrl+Shift+F9) from the top of the screen. The application will now run onto your device.
Choose the build configuration and also target platform you desire from the Project Manager. If building for iOS, ensure that the PA Server is running on the Mac and your device is unlocked (if deploying to the device) and choose run without debugging (or Ctrl+Shift+F9) from the top of the screen. The application will now run onto your device.

##Application Structure

Expand Down
35 changes: 35 additions & 0 deletions delphi/source/AndroidManifest.template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="%package%"
android:versionCode="%versionCode%"
android:versionName="%versionName%">

<!-- This is the platform API where NativeActivity was introduced. -->
<uses-sdk android:minSdkVersion="%minSdkVersion%" />
<%uses-permission%>
<application android:persistent="%persistent%"
android:restoreAnyVersion="%restoreAnyVersion%"
android:label="%label%"
android:installLocation="%installLocation%"
android:debuggable="%debuggable%"
android:largeHeap="%largeHeap%"
android:icon="%icon%"
android:theme="%theme%">
<!-- Our activity is a subclass of the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. -->
<activity android:name="com.embarcadero.firemonkey.FMXNativeActivity"
android:label="%activityLabel%"
android:configChanges="orientation|keyboardHidden">
<!-- Tell NativeActivity the name of our .so -->
<meta-data android:name="android.app.lib_name"
android:value="%libNameValue%" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.embarcadero.firemonkey.notifications.FMXNotificationAlarm" />
</application>
</manifest>
<!-- END_INCLUDE(manifest) -->
116 changes: 116 additions & 0 deletions delphi/source/BackButtonManager.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
unit BackButtonManager;

interface

uses FMX.TabControl, FMX.Types, System.Classes, FMX.Forms, System.Actions;

type
TActionHelper = class helper for TFMXObject
function GetFMXAction: TBasicAction;
end;

TBackActionManager = class
private
public
class procedure HideBackActionControls(Root : TFMXObject; UpdateActionState: Boolean);
class function FindBackAction(TabControl : TTabControl; IncInvisibleLinks : Boolean): TChangeTabAction; overload;
class function FindBackAction(CurrFMXObj : TFMXObject; IncInvisibleLinks : Boolean): TChangeTabAction; overload;
end;

implementation

uses FMX.Controls, System.SysUtils, System.Generics.Collections;

{ TActionFinder }

class function TBackActionManager.FindBackAction(TabControl: TTabControl;
IncInvisibleLinks: Boolean): TChangeTabAction;
begin
Result := nil;

if (TabControl = nil) or (TabControl.ActiveTab = nil) then
Exit;

// Find the active Page... If it has a control with ChangeTabAction, and BackStyle :-)
// If not, Has it got a PageControl... if so recursively call.
Result := FindBackAction(TabControl.ActiveTab,IncInvisibleLinks);
end;

class procedure TBackActionManager.HideBackActionControls(Root: TFMXObject; UpdateActionState: Boolean);
var
I : Integer;
Comp : TFMXObject;
Control : TStyledControl;
Action: TBasicAction;
begin
if Root = nil then
Exit;

for I := 0 to Pred(Root.ChildrenCount) do begin
Comp := Root.Children.Items[I];
if Comp is TStyledControl then begin
Control := TStyledControl(Comp);

if Control.Visible then begin
if LowerCase(Control.StyleLookup) = 'backtoolbutton' then begin
Action := Control.GetFMXAction;
if UpdateActionState and Assigned(Action) and (Action is TContainedAction) then
TContainedAction(Action).Visible := False
else
Control.Visible := False;
end;
end;
end;
TBackActionManager.HideBackActionControls(Comp, UpdateActionState);
end;
end;


class function TBackActionManager.FindBackAction(CurrFMXObj: TFMXObject;
IncInvisibleLinks: Boolean): TChangeTabAction;
var
I : Integer;
Comp : TFMXObject;
Control : TStyledControl;
Action: TBasicAction;
begin
Result := nil;

if CurrFMXObj = nil then
Exit(nil);

for I := 0 to Pred(CurrFMXObj.ChildrenCount) do begin
Comp := CurrFMXObj.Children.Items[I];
if Comp is TStyledControl then begin
Control := TStyledControl(Comp);

if Control.Visible or IncInvisibleLinks then begin
if LowerCase(Control.StyleLookup) = 'backtoolbutton' then begin
// Check for Action
Action := Control.GetFMXAction;
if Assigned(Action) then begin
if Action is TChangeTabAction then
Exit(TChangeTabAction(Action));
end;
end;
end;
end;

if Comp is TTabControl then
Result := FindBackAction(TTabControl(Comp),IncInvisibleLinks)
else
Result := FindBackAction(Comp,IncInvisibleLinks);

if Assigned(Result) then
Exit;
end;
end;

{ TActionHelper }

function TActionHelper.GetFMXAction: TBasicAction;
begin
Result := Self.GetAction;
end;

end.
Loading

0 comments on commit eb2a140

Please sign in to comment.