mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 11:39:09 +02:00
android: Updates bindings and adds dialog callbacks
git-svn-id: trunk@32060 -
This commit is contained in:
parent
6728ece0c9
commit
956fbe1e44
@ -52,7 +52,7 @@ type
|
||||
|
||||
TDisplayMetrics = class(TJavaObject)
|
||||
public
|
||||
constructor Create();
|
||||
constructor Create(); override;
|
||||
function density(): Single;
|
||||
function densityDpi(): Integer;
|
||||
function heightPixels(): Integer;
|
||||
@ -100,8 +100,8 @@ type
|
||||
|
||||
TAlertDialog_Builder = class(TJavaObject)
|
||||
public
|
||||
constructor Create();
|
||||
function create(): TAlertDialog;
|
||||
constructor Create(); override;
|
||||
function create_(): TAlertDialog;
|
||||
function setMessage(message: string): TAlertDialog_Builder;
|
||||
function setTitle(title: string): TAlertDialog_Builder;
|
||||
function setView(view: TView): TAlertDialog_Builder;
|
||||
@ -130,13 +130,13 @@ type
|
||||
|
||||
TLinearLayout = class(TViewGroup)
|
||||
public
|
||||
constructor Create();
|
||||
constructor Create(); override;
|
||||
procedure setOrientation(orientation: Integer);
|
||||
end;
|
||||
|
||||
TAbsoluteLayout = class(TViewGroup)
|
||||
public
|
||||
constructor Create();
|
||||
constructor Create(); override;
|
||||
end;
|
||||
|
||||
TAbsoluteLayout_LayoutParams = class(TViewGroup_LayoutParams)
|
||||
@ -146,7 +146,7 @@ type
|
||||
|
||||
TTextView = class(TView)
|
||||
public
|
||||
constructor Create();
|
||||
constructor Create(); override;
|
||||
procedure setText(AText: string);
|
||||
public
|
||||
OnClickListener: TView_OnClickListener;
|
||||
@ -159,12 +159,12 @@ type
|
||||
|
||||
TEditText = class(TTextView)
|
||||
public
|
||||
constructor Create();
|
||||
constructor Create(); override;
|
||||
end;
|
||||
|
||||
TButton = class(TTextView)
|
||||
public
|
||||
constructor Create();
|
||||
constructor Create(); override;
|
||||
end;
|
||||
|
||||
TFrameLayout = class(TViewGroup)
|
||||
@ -173,7 +173,7 @@ type
|
||||
|
||||
TTimePicker = class(TFrameLayout)
|
||||
public
|
||||
constructor Create();
|
||||
constructor Create(); override;
|
||||
function getCurrentHour(): Integer;
|
||||
procedure setCurrentHour(currentHour: Integer);
|
||||
function getCurrentMinute(): Integer;
|
||||
@ -184,7 +184,7 @@ type
|
||||
|
||||
TScrollView = class(TFrameLayout)
|
||||
public
|
||||
constructor Create();
|
||||
constructor Create(); override;
|
||||
end;
|
||||
|
||||
TCompoundButton = class(TButton)
|
||||
@ -197,7 +197,7 @@ type
|
||||
|
||||
TCheckBox = class(TCompoundButton)
|
||||
public
|
||||
constructor Create();
|
||||
constructor Create(); override;
|
||||
end;
|
||||
|
||||
TAdapterView = class(TViewGroup)
|
||||
@ -214,7 +214,7 @@ type
|
||||
|
||||
TSpinner = class(TAbsSpinner)
|
||||
public
|
||||
constructor Create();
|
||||
constructor Create(); override;
|
||||
end;
|
||||
|
||||
TFilterable = interface(IJavaInterface)
|
||||
@ -250,6 +250,9 @@ const
|
||||
{ Constants }
|
||||
{ TDisplayMetrics }
|
||||
{ TDialogInterface }
|
||||
BUTTON_NEGATIVE = $fffffffe;
|
||||
BUTTON_NEUTRAL = $fffffffd;
|
||||
BUTTON_POSITIVE = $ffffffff;
|
||||
{ TActivity }
|
||||
{ TDisplay }
|
||||
{ TWindowManager }
|
||||
@ -525,7 +528,7 @@ begin
|
||||
vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
|
||||
vAndroidPipesComm.SendInt(amkUI_TWindowManager_getDefaultDisplay_0);
|
||||
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
|
||||
Result := TDisplay(vAndroidPipesComm.WaitForIntReturn());
|
||||
Result := TDisplay.Create(vAndroidPipesComm.WaitForIntReturn());
|
||||
end;
|
||||
|
||||
procedure TDialog.show();
|
||||
@ -597,12 +600,12 @@ begin
|
||||
vAndroidPipesComm.SendInt(amkUI_TAlertDialog_Builder_Create_0);
|
||||
Index := vAndroidPipesComm.WaitForIntReturn();
|
||||
end;
|
||||
function TAlertDialog_Builder.create(): TAlertDialog;
|
||||
function TAlertDialog_Builder.create_(): TAlertDialog;
|
||||
begin
|
||||
vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
|
||||
vAndroidPipesComm.SendInt(amkUI_TAlertDialog_Builder_create_1);
|
||||
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
|
||||
Result := TAlertDialog(vAndroidPipesComm.WaitForIntReturn());
|
||||
Result := TAlertDialog.Create(vAndroidPipesComm.WaitForIntReturn());
|
||||
end;
|
||||
|
||||
function TAlertDialog_Builder.setMessage(message: string): TAlertDialog_Builder;
|
||||
@ -614,7 +617,7 @@ begin
|
||||
vAndroidPipesComm.SendInt(amkUI_TAlertDialog_Builder_setMessage_2);
|
||||
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
|
||||
vAndroidPipesComm.SendInt(lString_1.Index); // text
|
||||
Result := TAlertDialog_Builder(vAndroidPipesComm.WaitForIntReturn());
|
||||
Result := TAlertDialog_Builder.Create(vAndroidPipesComm.WaitForIntReturn());
|
||||
lString_1.Free;
|
||||
end;
|
||||
|
||||
@ -627,7 +630,7 @@ begin
|
||||
vAndroidPipesComm.SendInt(amkUI_TAlertDialog_Builder_setTitle_3);
|
||||
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
|
||||
vAndroidPipesComm.SendInt(lString_1.Index); // text
|
||||
Result := TAlertDialog_Builder(vAndroidPipesComm.WaitForIntReturn());
|
||||
Result := TAlertDialog_Builder.Create(vAndroidPipesComm.WaitForIntReturn());
|
||||
lString_1.Free;
|
||||
end;
|
||||
|
||||
@ -637,7 +640,7 @@ begin
|
||||
vAndroidPipesComm.SendInt(amkUI_TAlertDialog_Builder_setView_4);
|
||||
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
|
||||
vAndroidPipesComm.SendInt(Integer(view.Index));
|
||||
Result := TAlertDialog_Builder(vAndroidPipesComm.WaitForIntReturn());
|
||||
Result := TAlertDialog_Builder.Create(vAndroidPipesComm.WaitForIntReturn());
|
||||
end;
|
||||
|
||||
function TAlertDialog_Builder.show(): TAlertDialog;
|
||||
@ -645,7 +648,7 @@ begin
|
||||
vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
|
||||
vAndroidPipesComm.SendInt(amkUI_TAlertDialog_Builder_show_5);
|
||||
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
|
||||
Result := TAlertDialog(vAndroidPipesComm.WaitForIntReturn());
|
||||
Result := TAlertDialog.Create(vAndroidPipesComm.WaitForIntReturn());
|
||||
end;
|
||||
|
||||
constructor TViewGroup_LayoutParams.Create(width: Integer; height: Integer);
|
||||
|
@ -159,6 +159,12 @@ type
|
||||
property DragImageLock: Boolean read FDragImageLock write FDragImageLock;
|
||||
property OverrideCursor: TObject read FOverrideCursor write SetOverrideCursor;}
|
||||
|
||||
public
|
||||
// Android Callbacks
|
||||
AndroidDialogResult: Integer;
|
||||
procedure HandleAlertButtonPositive();
|
||||
procedure HandleAlertButtonNegative();
|
||||
|
||||
{$I androidwinapih.inc}
|
||||
{$I androidlclintfh.inc}
|
||||
end;
|
||||
|
@ -863,15 +863,17 @@ end;*)
|
||||
function TAndroidWidgetSet.RequestInput(const InputCaption, InputPrompt : String; MaskInput : Boolean; var Value : String) : Boolean;
|
||||
var
|
||||
alert: TAlertDialog_Builder;
|
||||
alertdlg: TAlertDialog;
|
||||
input: TEditText;
|
||||
begin
|
||||
{ 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
|
||||
Result := InputDialogFunction(InputCaption, InputPrompt, MaskInput, Value)
|
||||
else
|
||||
begin}
|
||||
begin
|
||||
{$ENDIF}
|
||||
Result := True;
|
||||
|
||||
alert := TAlertDialog_Builder.Create;
|
||||
@ -883,21 +885,27 @@ begin
|
||||
input := TEditText.Create;
|
||||
alert.setView(input);
|
||||
|
||||
(* alert.setPositiveButton('Ok', new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
String value = input.getText();
|
||||
// Do something with value!
|
||||
}
|
||||
});
|
||||
// Now add the buttons
|
||||
alertdlg := alert.create_();
|
||||
alertdlg.setButton(
|
||||
BUTTON_POSITIVE,
|
||||
'Ok',
|
||||
@HandleAlertButtonPositive
|
||||
);
|
||||
alertdlg.setButton(
|
||||
BUTTON_NEGATIVE,
|
||||
'Cancel',
|
||||
@HandleAlertButtonNegative
|
||||
);
|
||||
|
||||
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
// Canceled.
|
||||
}
|
||||
});*)
|
||||
alertdlg.show();
|
||||
|
||||
alert.show();
|
||||
// end;
|
||||
// Clean-up
|
||||
alert.Free;
|
||||
alertdlg.Free;
|
||||
{$IFDEF LCL_ANDROID_USE_NON_NATIVE_DIALOGS}
|
||||
end;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
(*procedure TQtWidgetSet.SetEventHandlerFlags(AHandler: PEventHandler;
|
||||
|
@ -328,5 +328,15 @@ begin
|
||||
end;}
|
||||
end;
|
||||
|
||||
// Android Callbacks
|
||||
procedure TAndroidWidgetSet.HandleAlertButtonPositive();
|
||||
begin
|
||||
AndroidDialogResult := BUTTON_POSITIVE;
|
||||
end;
|
||||
|
||||
procedure TAndroidWidgetSet.HandleAlertButtonNegative();
|
||||
begin
|
||||
AndroidDialogResult := BUTTON_NEGATIVE;
|
||||
end;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
@ -23,8 +23,8 @@ type
|
||||
TJavaObject = class(IJavaInterface)
|
||||
public
|
||||
FIndex: Integer;
|
||||
constructor Create(AIndex: Integer); virtual;
|
||||
constructor Create(); virtual;
|
||||
constructor Create(AIndex: Integer); virtual; overload;
|
||||
constructor Create(); virtual; overload;
|
||||
function GetIndex: Integer;
|
||||
procedure SetIndex(AValue: Integer);
|
||||
property Index: Integer read GetIndex write SetIndex;
|
||||
|
Loading…
Reference in New Issue
Block a user