mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-23 22:08:29 +02:00
Finishes basic SMS sending in Android and fixes TEdit.GetText in LCL-CustomDrawn, but in the process broke the initial text setting for TEdit
git-svn-id: trunk@34496 -
This commit is contained in:
parent
30e9088462
commit
b92e125ce3
@ -26,7 +26,7 @@ object Form2: TForm2
|
|||||||
OnKeyUp = textDestKeyUp
|
OnKeyUp = textDestKeyUp
|
||||||
OnUTF8KeyPress = textDestUTF8KeyPress
|
OnUTF8KeyPress = textDestUTF8KeyPress
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
Text = 'textDest'
|
Text = '8284'
|
||||||
end
|
end
|
||||||
object Image1: TImage
|
object Image1: TImage
|
||||||
Left = 102
|
Left = 102
|
||||||
|
@ -39,6 +39,8 @@ type
|
|||||||
{ public declarations }
|
{ public declarations }
|
||||||
procedure HandleAccelerometerChanged(Sender: TObject);
|
procedure HandleAccelerometerChanged(Sender: TObject);
|
||||||
procedure HandlePositionRetrieved(Sender: TObject);
|
procedure HandlePositionRetrieved(Sender: TObject);
|
||||||
|
procedure HandleMessagingStatus(AMessage: TLazDeviceMessage;
|
||||||
|
AStatus: TLazMessagingStatus);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -46,6 +48,8 @@ var
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
uses TypInfo;
|
||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
{ TForm2 }
|
{ TForm2 }
|
||||||
@ -59,9 +63,11 @@ procedure TForm2.btnSendSMSClick(Sender: TObject);
|
|||||||
var
|
var
|
||||||
lMessage: TLazDeviceMessage;
|
lMessage: TLazDeviceMessage;
|
||||||
begin
|
begin
|
||||||
|
Messaging.OnMessagingStatus := @HandleMessagingStatus;
|
||||||
lMessage := Messaging.CreateMessage();
|
lMessage := Messaging.CreateMessage();
|
||||||
lMessage.Body := textBody.Text;
|
lMessage.Body := textBody.Text;
|
||||||
lMessage.destinationAddress.Text := textDest.Text;
|
lMessage.destinationAddress.Text := textDest.Text;
|
||||||
|
DebugLn('[TForm2.btnSendSMSClick] dest='+textDest.Text);
|
||||||
Messaging.SendMessage(lMessage);
|
Messaging.SendMessage(lMessage);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -117,5 +123,13 @@ begin
|
|||||||
DebugLn(labelSensorData.Caption);
|
DebugLn(labelSensorData.Caption);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.HandleMessagingStatus(AMessage: TLazDeviceMessage;
|
||||||
|
AStatus: TLazMessagingStatus);
|
||||||
|
begin
|
||||||
|
labelSensorData.Caption := '[HandleMessagingStatus] ' +
|
||||||
|
GetEnumName(TypeInfo(TLazMessagingStatus), integer(AStatus));
|
||||||
|
DebugLn(labelSensorData.Caption);
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -256,6 +256,8 @@ var
|
|||||||
arraydata: PDouble;
|
arraydata: PDouble;
|
||||||
arraylen: jsize;
|
arraylen: jsize;
|
||||||
lIsCopy: jboolean;
|
lIsCopy: jboolean;
|
||||||
|
lSensorDataInt: Integer;
|
||||||
|
lMessagingStatus: TLazMessagingStatus;
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
|
|
||||||
@ -268,6 +270,23 @@ begin
|
|||||||
|
|
||||||
// Send the data to the LCL
|
// Send the data to the LCL
|
||||||
case ASensorKind of
|
case ASensorKind of
|
||||||
|
-11: // Defined by ourselves for Messaging Status
|
||||||
|
begin
|
||||||
|
lSensorDataInt := Round(arraydata[0]);
|
||||||
|
case lSensorDataInt of
|
||||||
|
1: lMessagingStatus := mssSentSuccessfully;
|
||||||
|
2: lMessagingStatus := mssSendingGeneralError;
|
||||||
|
3: lMessagingStatus := mssNoService;
|
||||||
|
5: lMessagingStatus := mssRadioOff;
|
||||||
|
10:lMessagingStatus := mssReceivedSuccessfully;
|
||||||
|
11:lMessagingStatus := mssReceivingGeneralError;
|
||||||
|
else
|
||||||
|
lMessagingStatus := mssSendingGeneralError;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if Assigned(Messaging.OnMessagingStatus) then
|
||||||
|
Messaging.OnMessagingStatus(nil, lMessagingStatus);
|
||||||
|
end;
|
||||||
-10: // Defined by ourselves for PositionInfo
|
-10: // Defined by ourselves for PositionInfo
|
||||||
begin
|
begin
|
||||||
PositionInfo.latitude := arraydata[0];
|
PositionInfo.latitude := arraydata[0];
|
||||||
|
@ -4077,10 +4077,10 @@ var
|
|||||||
lJavaString: jstring;
|
lJavaString: jstring;
|
||||||
lIsCopy: jboolean;
|
lIsCopy: jboolean;
|
||||||
begin
|
begin
|
||||||
{.$ifdef VerboseCDText}
|
{$ifdef VerboseCDText}
|
||||||
DebugLn(Format('[WinAPI GetTextExtentExPoint] DC=%x javaEnvRef=%x Str=%s MaxWidth=%d',
|
DebugLn(Format('[WinAPI GetTextExtentExPoint] DC=%x javaEnvRef=%x Str=%s MaxWidth=%d',
|
||||||
[DC, PtrInt(javaEnvRef), StrPas(Str), MaxWidth]));
|
[DC, PtrInt(javaEnvRef), StrPas(Str), MaxWidth]));
|
||||||
{.$endif}
|
{$endif}
|
||||||
// Result := inherited GetTextExtentExPoint(DC, Str, Count, MaxWidth, MaxCount, PartialWidths, Size);
|
// Result := inherited GetTextExtentExPoint(DC, Str, Count, MaxWidth, MaxCount, PartialWidths, Size);
|
||||||
|
|
||||||
Result := False;
|
Result := False;
|
||||||
@ -4106,9 +4106,9 @@ begin
|
|||||||
|
|
||||||
// Read the output
|
// Read the output
|
||||||
lMaxCount := javaEnvRef^^.GetIntField(javaEnvRef, javaActivityObject, javaField_lclmaxcount);
|
lMaxCount := javaEnvRef^^.GetIntField(javaEnvRef, javaActivityObject, javaField_lclmaxcount);
|
||||||
{.$ifdef VerboseCDText}
|
{$ifdef VerboseCDText}
|
||||||
DebugLn(Format(':[WinAPI GetTextExtentExPoint] MaxCount=%d', [lMaxCount]));
|
DebugLn(Format(':[WinAPI GetTextExtentExPoint] MaxCount=%d', [lMaxCount]));
|
||||||
{.$endif}
|
{$endif}
|
||||||
|
|
||||||
if MaxCount <> nil then MaxCount^ := lMaxCount;
|
if MaxCount <> nil then MaxCount^ := lMaxCount;
|
||||||
|
|
||||||
@ -4123,10 +4123,10 @@ begin
|
|||||||
for i := 0 to lMaxCount-1 do
|
for i := 0 to lMaxCount-1 do
|
||||||
begin
|
begin
|
||||||
PartialWidths[i] := Round(arraydata[i]);
|
PartialWidths[i] := Round(arraydata[i]);
|
||||||
{.$ifdef VerboseCDText}
|
{$ifdef VerboseCDText}
|
||||||
DebugLn(Format(':[WinAPI GetTextExtentExPoint] i=%d PartialWidth=%d',
|
DebugLn(Format(':[WinAPI GetTextExtentExPoint] i=%d PartialWidth=%d',
|
||||||
[i, PartialWidths[i]]));
|
[i, PartialWidths[i]]));
|
||||||
{.$endif}
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Don't forget to release it
|
// Don't forget to release it
|
||||||
|
@ -142,9 +142,44 @@ type
|
|||||||
public
|
public
|
||||||
class procedure CreateCDControl(const AWinControl: TWinControl; var ACDControlField: TCDControl);
|
class procedure CreateCDControl(const AWinControl: TWinControl; var ACDControlField: TCDControl);
|
||||||
published
|
published
|
||||||
|
// TWSWinControl
|
||||||
class function CreateHandle(const AWinControl: TWinControl;
|
class function CreateHandle(const AWinControl: TWinControl;
|
||||||
const AParams: TCreateParams): HWND; override;
|
const AParams: TCreateParams): HWND; override;
|
||||||
class procedure ShowHide(const AWinControl: TWinControl); override;
|
class procedure DestroyHandle(const AWinControl: TWinControl); override;
|
||||||
|
|
||||||
|
{ //class function CanFocus(const AWincontrol: TWinControl): Boolean; override;
|
||||||
|
|
||||||
|
class function GetClientBounds(const AWincontrol: TWinControl; var ARect: TRect): Boolean; override;
|
||||||
|
class function GetClientRect(const AWincontrol: TWinControl; var ARect: TRect): Boolean; override;
|
||||||
|
class procedure GetPreferredSize(const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override;
|
||||||
|
class function GetDefaultClientRect(const AWinControl: TWinControl; const aLeft, aTop, aWidth, aHeight: integer; var aClientRect: TRect): boolean; override;
|
||||||
|
class function GetDesignInteractive(const AWinControl: TWinControl; AClientPos: TPoint): Boolean; override;}
|
||||||
|
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
|
||||||
|
// class function GetTextLen(const AWinControl: TWinControl; var ALength: Integer): Boolean; override;
|
||||||
|
|
||||||
|
{ class procedure SetBiDiMode(const AWinControl: TWinControl; UseRightToLeftAlign, UseRightToLeftReading, UseRightToLeftScrollBar : Boolean); override;
|
||||||
|
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
|
||||||
|
class procedure SetBounds(const AWinControl: TWinControl; const ALeft, ATop, AWidth, AHeight: Integer); override;
|
||||||
|
class procedure SetColor(const AWinControl: TWinControl); override;
|
||||||
|
class procedure SetChildZPosition(const AWinControl, AChild: TWinControl; const AOldPos, ANewPos: Integer; const AChildren: TFPList); override;
|
||||||
|
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
|
||||||
|
class procedure SetPos(const AWinControl: TWinControl; const ALeft, ATop: Integer); override;
|
||||||
|
class procedure SetSize(const AWinControl: TWinControl; const AWidth, AHeight: Integer); override;}
|
||||||
|
class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
|
||||||
|
{ class procedure SetCursor(const AWinControl: TWinControl; const ACursor: HCursor); override;
|
||||||
|
class procedure SetShape(const AWinControl: TWinControl; const AShape: HBITMAP); override;}
|
||||||
|
|
||||||
|
{ class procedure AdaptBounds(const AWinControl: TWinControl;
|
||||||
|
var Left, Top, Width, Height: integer; var SuppressMove: boolean); override;
|
||||||
|
|
||||||
|
class procedure ConstraintsChange(const AWinControl: TWinControl); override;
|
||||||
|
class procedure DefaultWndHandler(const AWinControl: TWinControl; var AMessage); override;
|
||||||
|
class procedure Invalidate(const AWinControl: TWinControl); override;
|
||||||
|
class procedure PaintTo(const AWinControl: TWinControl; ADC: HDC; X, Y: Integer); override;}
|
||||||
|
class procedure ShowHide(const AWinControl: TWinControl); override;
|
||||||
|
|
||||||
|
// TWSCustomEdit
|
||||||
|
|
||||||
{ class procedure SetAlignment(const ACustomEdit: TCustomEdit; const AAlignment: TAlignment); override;
|
{ class procedure SetAlignment(const ACustomEdit: TCustomEdit; const AAlignment: TAlignment); override;
|
||||||
class function GetCaretPos(const ACustomEdit: TCustomEdit): TPoint; override;
|
class function GetCaretPos(const ACustomEdit: TCustomEdit): TPoint; override;
|
||||||
class function GetCanUndo(const ACustomEdit: TCustomEdit): Boolean; override;
|
class function GetCanUndo(const ACustomEdit: TCustomEdit): Boolean; override;
|
||||||
@ -820,6 +855,7 @@ begin
|
|||||||
ACDControlField.Caption := AWinControl.Caption;
|
ACDControlField.Caption := AWinControl.Caption;
|
||||||
ACDControlField.Parent := AWinControl;
|
ACDControlField.Parent := AWinControl;
|
||||||
ACDControlField.Align := alClient;
|
ACDControlField.Align := alClient;
|
||||||
|
TCDIntfEdit(ACDControlField).Text := TCustomEdit(AWinControl).Text;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -836,6 +872,37 @@ begin
|
|||||||
lCDWinControl := TCDWinControl(Result);
|
lCDWinControl := TCDWinControl(Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class procedure TCDWSCustomEdit.DestroyHandle(const AWinControl: TWinControl);
|
||||||
|
var
|
||||||
|
lCDWinControl: TCDWinControl;
|
||||||
|
begin
|
||||||
|
lCDWinControl := TCDWinControl(AWinControl.Handle);
|
||||||
|
lCDWinControl.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TCDWSCustomEdit.GetText(const AWinControl: TWinControl;
|
||||||
|
var AText: String): Boolean;
|
||||||
|
var
|
||||||
|
lCDWinControl: TCDWinControl;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
lCDWinControl := TCDWinControl(AWinControl.Handle);
|
||||||
|
if lCDWinControl.CDControl = nil then Exit;
|
||||||
|
AText := TCDIntfEdit(lCDWinControl.CDControl).Text;
|
||||||
|
DebugLn('[TCDWSCustomEdit.GetText] AText='+AText);
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TCDWSCustomEdit.SetText(const AWinControl: TWinControl;
|
||||||
|
const AText: String);
|
||||||
|
var
|
||||||
|
lCDWinControl: TCDWinControl;
|
||||||
|
begin
|
||||||
|
lCDWinControl := TCDWinControl(AWinControl.Handle);
|
||||||
|
if lCDWinControl.CDControl = nil then Exit;
|
||||||
|
TCDIntfEdit(lCDWinControl.CDControl).Text := AText;
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TCDWSCustomEdit.ShowHide(const AWinControl: TWinControl);
|
class procedure TCDWSCustomEdit.ShowHide(const AWinControl: TWinControl);
|
||||||
var
|
var
|
||||||
lCDWinControl: TCDWinControl;
|
lCDWinControl: TCDWinControl;
|
||||||
|
@ -51,24 +51,30 @@ type
|
|||||||
|
|
||||||
// TLazMessaging
|
// TLazMessaging
|
||||||
|
|
||||||
TLazMessageSendingStatus = (mssSuccess, mssGeneralError);
|
TLazMessagingStatus = (
|
||||||
|
// Message sending status
|
||||||
|
mssSentSuccessfully, mssSendingGeneralError, mssRadioOff, mssNoService,
|
||||||
|
// Message receiving status (by the destination)
|
||||||
|
mssReceivedSuccessfully, mssReceivingGeneralError
|
||||||
|
);
|
||||||
|
|
||||||
TOnMessageSendingFinished = procedure (AMessage: TLazDeviceMessage;
|
TOnMessagingStatus = procedure (AMessage: TLazDeviceMessage;
|
||||||
ASendingStatus: TLazMessageSendingStatus; AErrorMsg: string) of object;
|
AStatus: TLazMessagingStatus) of object;
|
||||||
|
|
||||||
{ TLazMessaging }
|
{ TLazMessaging }
|
||||||
|
|
||||||
TLazMessaging = class
|
TLazMessaging = class
|
||||||
private
|
private
|
||||||
FTOnMessageSendingFinished: TOnMessageSendingFinished;
|
FOnMessagingStatus: TOnMessagingStatus;
|
||||||
|
FMessages: TFPList; // of TLazDeviceMessage
|
||||||
public
|
public
|
||||||
// Attempt to send the specified message.
|
constructor Create; virtual;
|
||||||
procedure SendMessage(AMsg: TLazDeviceMessage);
|
destructor Destroy; override;
|
||||||
//
|
procedure SendMessage(AMsg: TLazDeviceMessage); // Attempt to send the specified message.
|
||||||
function CreateMessage: TLazDeviceMessage;
|
function CreateMessage: TLazDeviceMessage;
|
||||||
// Called asynchronously when the message sending is finished
|
procedure FreeMessage(AMessage: TLazDeviceMessage);
|
||||||
property OnMessageSendingFinished: TOnMessageSendingFinished read FTOnMessageSendingFinished
|
// Called asynchronously when there is a message sending status
|
||||||
write FTOnMessageSendingFinished;
|
property OnMessagingStatus: TOnMessagingStatus read FOnMessagingStatus write FOnMessagingStatus;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// TLazPositionInfo
|
// TLazPositionInfo
|
||||||
@ -123,6 +129,22 @@ end;
|
|||||||
|
|
||||||
{ TLazMessaging }
|
{ TLazMessaging }
|
||||||
|
|
||||||
|
constructor TLazMessaging.Create;
|
||||||
|
begin
|
||||||
|
FMessages := TFPList.Create;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TLazMessaging.Destroy;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
// Free all messages
|
||||||
|
for i := 0 to FMessages.Count-1 do
|
||||||
|
TLazDeviceMessage(FMessages.Items[i]).Free;
|
||||||
|
FMessages.Free;
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TLazMessaging.SendMessage(AMsg: TLazDeviceMessage);
|
procedure TLazMessaging.SendMessage(AMsg: TLazDeviceMessage);
|
||||||
begin
|
begin
|
||||||
LCLIntf.LazDeviceAPIs_SendMessage(AMsg);
|
LCLIntf.LazDeviceAPIs_SendMessage(AMsg);
|
||||||
@ -131,6 +153,13 @@ end;
|
|||||||
function TLazMessaging.CreateMessage: TLazDeviceMessage;
|
function TLazMessaging.CreateMessage: TLazDeviceMessage;
|
||||||
begin
|
begin
|
||||||
Result := TLazDeviceMessage.Create;
|
Result := TLazDeviceMessage.Create;
|
||||||
|
FMessages.Add(Result);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLazMessaging.FreeMessage(AMessage: TLazDeviceMessage);
|
||||||
|
begin
|
||||||
|
FMessages.Remove(AMessage);
|
||||||
|
AMessage.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
Loading…
Reference in New Issue
Block a user