android: Updates bindings and adds dialog callbacks

git-svn-id: trunk@32060 -
This commit is contained in:
sekelsenmat 2011-08-26 08:58:20 +00:00
parent 6728ece0c9
commit 956fbe1e44
5 changed files with 64 additions and 37 deletions

View File

@ -52,7 +52,7 @@ type
TDisplayMetrics = class(TJavaObject) TDisplayMetrics = class(TJavaObject)
public public
constructor Create(); constructor Create(); override;
function density(): Single; function density(): Single;
function densityDpi(): Integer; function densityDpi(): Integer;
function heightPixels(): Integer; function heightPixels(): Integer;
@ -100,8 +100,8 @@ type
TAlertDialog_Builder = class(TJavaObject) TAlertDialog_Builder = class(TJavaObject)
public public
constructor Create(); constructor Create(); override;
function create(): TAlertDialog; function create_(): TAlertDialog;
function setMessage(message: string): TAlertDialog_Builder; function setMessage(message: string): TAlertDialog_Builder;
function setTitle(title: string): TAlertDialog_Builder; function setTitle(title: string): TAlertDialog_Builder;
function setView(view: TView): TAlertDialog_Builder; function setView(view: TView): TAlertDialog_Builder;
@ -130,13 +130,13 @@ type
TLinearLayout = class(TViewGroup) TLinearLayout = class(TViewGroup)
public public
constructor Create(); constructor Create(); override;
procedure setOrientation(orientation: Integer); procedure setOrientation(orientation: Integer);
end; end;
TAbsoluteLayout = class(TViewGroup) TAbsoluteLayout = class(TViewGroup)
public public
constructor Create(); constructor Create(); override;
end; end;
TAbsoluteLayout_LayoutParams = class(TViewGroup_LayoutParams) TAbsoluteLayout_LayoutParams = class(TViewGroup_LayoutParams)
@ -146,7 +146,7 @@ type
TTextView = class(TView) TTextView = class(TView)
public public
constructor Create(); constructor Create(); override;
procedure setText(AText: string); procedure setText(AText: string);
public public
OnClickListener: TView_OnClickListener; OnClickListener: TView_OnClickListener;
@ -159,12 +159,12 @@ type
TEditText = class(TTextView) TEditText = class(TTextView)
public public
constructor Create(); constructor Create(); override;
end; end;
TButton = class(TTextView) TButton = class(TTextView)
public public
constructor Create(); constructor Create(); override;
end; end;
TFrameLayout = class(TViewGroup) TFrameLayout = class(TViewGroup)
@ -173,7 +173,7 @@ type
TTimePicker = class(TFrameLayout) TTimePicker = class(TFrameLayout)
public public
constructor Create(); constructor Create(); override;
function getCurrentHour(): Integer; function getCurrentHour(): Integer;
procedure setCurrentHour(currentHour: Integer); procedure setCurrentHour(currentHour: Integer);
function getCurrentMinute(): Integer; function getCurrentMinute(): Integer;
@ -184,7 +184,7 @@ type
TScrollView = class(TFrameLayout) TScrollView = class(TFrameLayout)
public public
constructor Create(); constructor Create(); override;
end; end;
TCompoundButton = class(TButton) TCompoundButton = class(TButton)
@ -197,7 +197,7 @@ type
TCheckBox = class(TCompoundButton) TCheckBox = class(TCompoundButton)
public public
constructor Create(); constructor Create(); override;
end; end;
TAdapterView = class(TViewGroup) TAdapterView = class(TViewGroup)
@ -214,7 +214,7 @@ type
TSpinner = class(TAbsSpinner) TSpinner = class(TAbsSpinner)
public public
constructor Create(); constructor Create(); override;
end; end;
TFilterable = interface(IJavaInterface) TFilterable = interface(IJavaInterface)
@ -250,6 +250,9 @@ const
{ Constants } { Constants }
{ TDisplayMetrics } { TDisplayMetrics }
{ TDialogInterface } { TDialogInterface }
BUTTON_NEGATIVE = $fffffffe;
BUTTON_NEUTRAL = $fffffffd;
BUTTON_POSITIVE = $ffffffff;
{ TActivity } { TActivity }
{ TDisplay } { TDisplay }
{ TWindowManager } { TWindowManager }
@ -525,7 +528,7 @@ begin
vAndroidPipesComm.SendByte(ShortInt(amkUICommand)); vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
vAndroidPipesComm.SendInt(amkUI_TWindowManager_getDefaultDisplay_0); vAndroidPipesComm.SendInt(amkUI_TWindowManager_getDefaultDisplay_0);
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
Result := TDisplay(vAndroidPipesComm.WaitForIntReturn()); Result := TDisplay.Create(vAndroidPipesComm.WaitForIntReturn());
end; end;
procedure TDialog.show(); procedure TDialog.show();
@ -597,12 +600,12 @@ begin
vAndroidPipesComm.SendInt(amkUI_TAlertDialog_Builder_Create_0); vAndroidPipesComm.SendInt(amkUI_TAlertDialog_Builder_Create_0);
Index := vAndroidPipesComm.WaitForIntReturn(); Index := vAndroidPipesComm.WaitForIntReturn();
end; end;
function TAlertDialog_Builder.create(): TAlertDialog; function TAlertDialog_Builder.create_(): TAlertDialog;
begin begin
vAndroidPipesComm.SendByte(ShortInt(amkUICommand)); vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
vAndroidPipesComm.SendInt(amkUI_TAlertDialog_Builder_create_1); vAndroidPipesComm.SendInt(amkUI_TAlertDialog_Builder_create_1);
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
Result := TAlertDialog(vAndroidPipesComm.WaitForIntReturn()); Result := TAlertDialog.Create(vAndroidPipesComm.WaitForIntReturn());
end; end;
function TAlertDialog_Builder.setMessage(message: string): TAlertDialog_Builder; function TAlertDialog_Builder.setMessage(message: string): TAlertDialog_Builder;
@ -614,7 +617,7 @@ begin
vAndroidPipesComm.SendInt(amkUI_TAlertDialog_Builder_setMessage_2); vAndroidPipesComm.SendInt(amkUI_TAlertDialog_Builder_setMessage_2);
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
vAndroidPipesComm.SendInt(lString_1.Index); // text vAndroidPipesComm.SendInt(lString_1.Index); // text
Result := TAlertDialog_Builder(vAndroidPipesComm.WaitForIntReturn()); Result := TAlertDialog_Builder.Create(vAndroidPipesComm.WaitForIntReturn());
lString_1.Free; lString_1.Free;
end; end;
@ -627,7 +630,7 @@ begin
vAndroidPipesComm.SendInt(amkUI_TAlertDialog_Builder_setTitle_3); vAndroidPipesComm.SendInt(amkUI_TAlertDialog_Builder_setTitle_3);
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
vAndroidPipesComm.SendInt(lString_1.Index); // text vAndroidPipesComm.SendInt(lString_1.Index); // text
Result := TAlertDialog_Builder(vAndroidPipesComm.WaitForIntReturn()); Result := TAlertDialog_Builder.Create(vAndroidPipesComm.WaitForIntReturn());
lString_1.Free; lString_1.Free;
end; end;
@ -637,7 +640,7 @@ begin
vAndroidPipesComm.SendInt(amkUI_TAlertDialog_Builder_setView_4); vAndroidPipesComm.SendInt(amkUI_TAlertDialog_Builder_setView_4);
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
vAndroidPipesComm.SendInt(Integer(view.Index)); vAndroidPipesComm.SendInt(Integer(view.Index));
Result := TAlertDialog_Builder(vAndroidPipesComm.WaitForIntReturn()); Result := TAlertDialog_Builder.Create(vAndroidPipesComm.WaitForIntReturn());
end; end;
function TAlertDialog_Builder.show(): TAlertDialog; function TAlertDialog_Builder.show(): TAlertDialog;
@ -645,7 +648,7 @@ begin
vAndroidPipesComm.SendByte(ShortInt(amkUICommand)); vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
vAndroidPipesComm.SendInt(amkUI_TAlertDialog_Builder_show_5); vAndroidPipesComm.SendInt(amkUI_TAlertDialog_Builder_show_5);
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
Result := TAlertDialog(vAndroidPipesComm.WaitForIntReturn()); Result := TAlertDialog.Create(vAndroidPipesComm.WaitForIntReturn());
end; end;
constructor TViewGroup_LayoutParams.Create(width: Integer; height: Integer); constructor TViewGroup_LayoutParams.Create(width: Integer; height: Integer);

View File

@ -159,6 +159,12 @@ type
property DragImageLock: Boolean read FDragImageLock write FDragImageLock; property DragImageLock: Boolean read FDragImageLock write FDragImageLock;
property OverrideCursor: TObject read FOverrideCursor write SetOverrideCursor;} property OverrideCursor: TObject read FOverrideCursor write SetOverrideCursor;}
public
// Android Callbacks
AndroidDialogResult: Integer;
procedure HandleAlertButtonPositive();
procedure HandleAlertButtonNegative();
{$I androidwinapih.inc} {$I androidwinapih.inc}
{$I androidlclintfh.inc} {$I androidlclintfh.inc}
end; end;

View File

@ -863,15 +863,17 @@ end;*)
function TAndroidWidgetSet.RequestInput(const InputCaption, InputPrompt : String; MaskInput : Boolean; var Value : String) : Boolean; function TAndroidWidgetSet.RequestInput(const InputCaption, InputPrompt : String; MaskInput : Boolean; var Value : String) : Boolean;
var var
alert: TAlertDialog_Builder; alert: TAlertDialog_Builder;
alertdlg: TAlertDialog;
input: TEditText; input: TEditText;
begin begin
{ The LCL fills InputDialogFunction, so we cannot uncomment this code or { The LCL fills InputDialogFunction, so we cannot uncomment this code or
else we will end up with non-native dialogs, which is not a great idea in Android else we will end up with non-native dialogs, which is not a great idea in Android }
{$IFDEF LCL_ANDROID_USE_NON_NATIVE_DIALOGS}
if InputDialogFunction<>nil then if InputDialogFunction<>nil then
Result := InputDialogFunction(InputCaption, InputPrompt, MaskInput, Value) Result := InputDialogFunction(InputCaption, InputPrompt, MaskInput, Value)
else else
begin} begin
{$ENDIF}
Result := True; Result := True;
alert := TAlertDialog_Builder.Create; alert := TAlertDialog_Builder.Create;
@ -883,21 +885,27 @@ begin
input := TEditText.Create; input := TEditText.Create;
alert.setView(input); alert.setView(input);
(* alert.setPositiveButton('Ok', new DialogInterface.OnClickListener() { // Now add the buttons
public void onClick(DialogInterface dialog, int whichButton) { alertdlg := alert.create_();
String value = input.getText(); alertdlg.setButton(
// Do something with value! BUTTON_POSITIVE,
} 'Ok',
}); @HandleAlertButtonPositive
);
alertdlg.setButton(
BUTTON_NEGATIVE,
'Cancel',
@HandleAlertButtonNegative
);
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { alertdlg.show();
public void onClick(DialogInterface dialog, int whichButton) {
// Canceled.
}
});*)
alert.show(); // Clean-up
// end; alert.Free;
alertdlg.Free;
{$IFDEF LCL_ANDROID_USE_NON_NATIVE_DIALOGS}
end;
{$ENDIF}
end; end;
(*procedure TQtWidgetSet.SetEventHandlerFlags(AHandler: PEventHandler; (*procedure TQtWidgetSet.SetEventHandlerFlags(AHandler: PEventHandler;

View File

@ -328,5 +328,15 @@ begin
end;} end;}
end; end;
// Android Callbacks
procedure TAndroidWidgetSet.HandleAlertButtonPositive();
begin
AndroidDialogResult := BUTTON_POSITIVE;
end;
procedure TAndroidWidgetSet.HandleAlertButtonNegative();
begin
AndroidDialogResult := BUTTON_NEGATIVE;
end;
//------------------------------------------------------------------------ //------------------------------------------------------------------------

View File

@ -23,8 +23,8 @@ type
TJavaObject = class(IJavaInterface) TJavaObject = class(IJavaInterface)
public public
FIndex: Integer; FIndex: Integer;
constructor Create(AIndex: Integer); virtual; constructor Create(AIndex: Integer); virtual; overload;
constructor Create(); virtual; constructor Create(); virtual; overload;
function GetIndex: Integer; function GetIndex: Integer;
procedure SetIndex(AValue: Integer); procedure SetIndex(AValue: Integer);
property Index: Integer read GetIndex write SetIndex; property Index: Integer read GetIndex write SetIndex;