mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-02 10:40:41 +02:00
Adds Accelerometer stopping in Android (and to the general structure) and starts implementing SMS sending
git-svn-id: trunk@34486 -
This commit is contained in:
parent
97fac1bc4c
commit
fdc8606135
@ -4,6 +4,7 @@
|
|||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
android:versionName="1.0">
|
android:versionName="1.0">
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
|
<uses-permission android:name="android.permission.SEND_SMS" />
|
||||||
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:anyDensity="true" />
|
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:anyDensity="true" />
|
||||||
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" />
|
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" />
|
||||||
<application android:label="@string/app_name"
|
<application android:label="@string/app_name"
|
||||||
|
@ -13,6 +13,7 @@ import android.hardware.Sensor;
|
|||||||
import android.hardware.SensorEvent;
|
import android.hardware.SensorEvent;
|
||||||
import android.hardware.SensorEventListener;
|
import android.hardware.SensorEventListener;
|
||||||
import android.hardware.SensorManager;
|
import android.hardware.SensorManager;
|
||||||
|
import android.telephony.SmsManager;
|
||||||
|
|
||||||
public class LCLActivity extends Activity implements SensorEventListener
|
public class LCLActivity extends Activity implements SensorEventListener
|
||||||
{
|
{
|
||||||
@ -342,6 +343,22 @@ public class LCLActivity extends Activity implements SensorEventListener
|
|||||||
localSensorManager.unregisterListener(this);
|
localSensorManager.unregisterListener(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// input: String lcldestination, String lcltext (Body)
|
||||||
|
public void LCLDoSendMessage()
|
||||||
|
{
|
||||||
|
if (lclkind == 1)
|
||||||
|
{
|
||||||
|
PendingIntent pi = PendingIntent.getActivity(this, 0,
|
||||||
|
new Intent(this, Object.class), 0);
|
||||||
|
SmsManager sms = SmsManager.getDefault();
|
||||||
|
sms.sendTextMessage(lcldestination, null, lcltext, pi, null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public void LCLDoRequestPositionInfo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------
|
// -------------------------------------------
|
||||||
// Fields exported to the Pascal side for easier data communication
|
// Fields exported to the Pascal side for easier data communication
|
||||||
// -------------------------------------------
|
// -------------------------------------------
|
||||||
@ -377,6 +394,9 @@ public class LCLActivity extends Activity implements SensorEventListener
|
|||||||
public int lclformheight;
|
public int lclformheight;
|
||||||
public int lclscreenwidth;
|
public int lclscreenwidth;
|
||||||
public int lclscreenheight;
|
public int lclscreenheight;
|
||||||
|
// for LazDeviceAPIs
|
||||||
|
public String lcldestination;
|
||||||
|
public int lclkind;
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
|
@ -16,20 +16,20 @@ object Form2: TForm2
|
|||||||
OnClick = Button1Click
|
OnClick = Button1Click
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
object Edit1: TEdit
|
object textDest: TEdit
|
||||||
Left = 12
|
Left = 8
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 32
|
Top = 56
|
||||||
Width = 80
|
Width = 80
|
||||||
OnExit = Edit1Exit
|
OnExit = textDestExit
|
||||||
OnKeyDown = Edit1KeyDown
|
OnKeyDown = textDestKeyDown
|
||||||
OnKeyUp = Edit1KeyUp
|
OnKeyUp = textDestKeyUp
|
||||||
OnUTF8KeyPress = Edit1UTF8KeyPress
|
OnUTF8KeyPress = textDestUTF8KeyPress
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
Text = 'Edit1'
|
Text = 'textDest'
|
||||||
end
|
end
|
||||||
object Image1: TImage
|
object Image1: TImage
|
||||||
Left = 96
|
Left = 102
|
||||||
Height = 138
|
Height = 138
|
||||||
Top = 32
|
Top = 32
|
||||||
Width = 210
|
Width = 210
|
||||||
@ -1783,13 +1783,13 @@ object Form2: TForm2
|
|||||||
2E202E202E202E202E202E20227D3B0A
|
2E202E202E202E202E202E20227D3B0A
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
object Button2: TButton
|
object btnStartAccel: TButton
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 194
|
Top = 194
|
||||||
Width = 304
|
Width = 112
|
||||||
Caption = 'Read Accelerometer'
|
Caption = 'Read Accel.'
|
||||||
OnClick = Button2Click
|
OnClick = btnStartAccelClick
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
end
|
end
|
||||||
object labelSensorData: TLabel
|
object labelSensorData: TLabel
|
||||||
@ -1800,4 +1800,55 @@ object Form2: TForm2
|
|||||||
Caption = 'Sensor Data'
|
Caption = 'Sensor Data'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
|
object btnStopAccel: TButton
|
||||||
|
Left = 128
|
||||||
|
Height = 25
|
||||||
|
Top = 194
|
||||||
|
Width = 91
|
||||||
|
Caption = 'Stop Accel.'
|
||||||
|
OnClick = btnStopAccelClick
|
||||||
|
TabOrder = 3
|
||||||
|
end
|
||||||
|
object btnGetPos: TButton
|
||||||
|
Left = 224
|
||||||
|
Height = 25
|
||||||
|
Top = 194
|
||||||
|
Width = 88
|
||||||
|
Caption = 'Get Position'
|
||||||
|
OnClick = btnGetPosClick
|
||||||
|
TabOrder = 4
|
||||||
|
end
|
||||||
|
object Label1: TLabel
|
||||||
|
Left = 10
|
||||||
|
Height = 18
|
||||||
|
Top = 88
|
||||||
|
Width = 63
|
||||||
|
Caption = 'SMS Text:'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
object textBody: TEdit
|
||||||
|
Left = 8
|
||||||
|
Height = 25
|
||||||
|
Top = 104
|
||||||
|
Width = 80
|
||||||
|
TabOrder = 5
|
||||||
|
Text = 'textBody'
|
||||||
|
end
|
||||||
|
object btnSendSMS: TButton
|
||||||
|
Left = 8
|
||||||
|
Height = 25
|
||||||
|
Top = 136
|
||||||
|
Width = 75
|
||||||
|
Caption = 'Send SMS'
|
||||||
|
OnClick = btnSendSMSClick
|
||||||
|
TabOrder = 6
|
||||||
|
end
|
||||||
|
object Label2: TLabel
|
||||||
|
Left = 8
|
||||||
|
Height = 18
|
||||||
|
Top = 32
|
||||||
|
Width = 53
|
||||||
|
Caption = 'Number'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -14,21 +14,31 @@ type
|
|||||||
|
|
||||||
TForm2 = class(TForm)
|
TForm2 = class(TForm)
|
||||||
Button1: TButton;
|
Button1: TButton;
|
||||||
Button2: TButton;
|
btnStartAccel: TButton;
|
||||||
Edit1: TEdit;
|
btnStopAccel: TButton;
|
||||||
|
btnGetPos: TButton;
|
||||||
|
btnSendSMS: TButton;
|
||||||
|
textDest: TEdit;
|
||||||
|
textBody: TEdit;
|
||||||
Image1: TImage;
|
Image1: TImage;
|
||||||
|
Label1: TLabel;
|
||||||
|
Label2: TLabel;
|
||||||
labelSensorData: TLabel;
|
labelSensorData: TLabel;
|
||||||
|
procedure btnSendSMSClick(Sender: TObject);
|
||||||
procedure Button1Click(Sender: TObject);
|
procedure Button1Click(Sender: TObject);
|
||||||
procedure Button2Click(Sender: TObject);
|
procedure btnStartAccelClick(Sender: TObject);
|
||||||
procedure Edit1Exit(Sender: TObject);
|
procedure btnStopAccelClick(Sender: TObject);
|
||||||
procedure Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
procedure btnGetPosClick(Sender: TObject);
|
||||||
procedure Edit1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
|
procedure textDestExit(Sender: TObject);
|
||||||
procedure Edit1UTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
|
procedure textDestKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
|
procedure textDestKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
|
procedure textDestUTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
|
||||||
private
|
private
|
||||||
{ private declarations }
|
{ private declarations }
|
||||||
public
|
public
|
||||||
{ public declarations }
|
{ public declarations }
|
||||||
procedure HandleAccelerometerChanged(Sender: TObject);
|
procedure HandleAccelerometerChanged(Sender: TObject);
|
||||||
|
procedure HandlePositionRetrieved(Sender: TObject);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -45,29 +55,50 @@ begin
|
|||||||
Hide;
|
Hide;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm2.Button2Click(Sender: TObject);
|
procedure TForm2.btnSendSMSClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
lMessage: TLazDeviceMessage;
|
||||||
|
begin
|
||||||
|
lMessage := Messaging.CreateMessage();
|
||||||
|
lMessage.Body := textBody.Text;
|
||||||
|
lMessage.destinationAddress.Text := textDest.Text;
|
||||||
|
Messaging.SendMessage(lMessage);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.btnStartAccelClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
Accelerometer.OnSensorChanged := @HandleAccelerometerChanged;
|
Accelerometer.OnSensorChanged := @HandleAccelerometerChanged;
|
||||||
Accelerometer.StartReadingAccelerometerData();
|
Accelerometer.StartReadingAccelerometerData();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm2.Edit1Exit(Sender: TObject);
|
procedure TForm2.btnStopAccelClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Accelerometer.StopReadingAccelerometerData();
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.btnGetPosClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
PositionInfo.RequestPositionInfo([]);
|
||||||
|
PositionInfo.OnPositionRetrieved := @HandlePositionRetrieved;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.textDestExit(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
DebugLn('[Edit1Exit]');
|
DebugLn('[Edit1Exit]');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm2.Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState
|
procedure TForm2.textDestKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState
|
||||||
);
|
);
|
||||||
begin
|
begin
|
||||||
DebugLn('[Edit1KeyDown] Key=' + DbgsVKCode(Key));
|
DebugLn('[Edit1KeyDown] Key=' + DbgsVKCode(Key));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm2.Edit1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
|
procedure TForm2.textDestKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
begin
|
begin
|
||||||
DebugLn('[Edit1KeyUp] Key=' + DbgsVKCode(Key));
|
DebugLn('[Edit1KeyUp] Key=' + DbgsVKCode(Key));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm2.Edit1UTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
|
procedure TForm2.textDestUTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
|
||||||
begin
|
begin
|
||||||
DebugLn('[Edit1UTF8KeyPress] Char=' + UTF8Key);
|
DebugLn('[Edit1UTF8KeyPress] Char=' + UTF8Key);
|
||||||
end;
|
end;
|
||||||
@ -79,5 +110,12 @@ begin
|
|||||||
DebugLn(labelSensorData.Caption);
|
DebugLn(labelSensorData.Caption);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.HandlePositionRetrieved(Sender: TObject);
|
||||||
|
begin
|
||||||
|
labelSensorData.Caption := Format('latitude=%f longitude=%f',
|
||||||
|
[PositionInfo.latitude, PositionInfo.longitude]);
|
||||||
|
DebugLn(labelSensorData.Caption);
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -532,6 +532,11 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TWidgetSet.LazDeviceAPIs_StopReadingAccelerometerData();
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
function TWidgetSet.MoveWindowOrgEx(dc: hdc; dX,dY: Integer): boolean;
|
function TWidgetSet.MoveWindowOrgEx(dc: hdc; dX,dY: Integer): boolean;
|
||||||
var
|
var
|
||||||
P: TPoint;
|
P: TPoint;
|
||||||
|
@ -365,6 +365,11 @@ begin
|
|||||||
Widgetset.LazDeviceAPIs_StartReadingAccelerometerData();
|
Widgetset.LazDeviceAPIs_StartReadingAccelerometerData();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure LazDeviceAPIs_StopReadingAccelerometerData();
|
||||||
|
begin
|
||||||
|
Widgetset.LazDeviceAPIs_StopReadingAccelerometerData();
|
||||||
|
end;
|
||||||
|
|
||||||
function MoveWindowOrgEx(dc: hdc; dX,dY: Integer): boolean;
|
function MoveWindowOrgEx(dc: hdc; dX,dY: Integer): boolean;
|
||||||
begin
|
begin
|
||||||
Result := WidgetSet.MoveWindowOrgEx(DC, dX, dY);
|
Result := WidgetSet.MoveWindowOrgEx(DC, dX, dY);
|
||||||
|
@ -96,6 +96,7 @@ function IsDesignerDC(WindowHandle: HWND; DC: HDC): Boolean; {$IFDEF IF_BASE_MEM
|
|||||||
procedure LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
procedure LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
procedure LazDeviceAPIs_SendMessage(AMsg: TLazDeviceMessage); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
procedure LazDeviceAPIs_SendMessage(AMsg: TLazDeviceMessage); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
procedure LazDeviceAPIs_StartReadingAccelerometerData(); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
procedure LazDeviceAPIs_StartReadingAccelerometerData(); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
|
procedure LazDeviceAPIs_StopReadingAccelerometerData(); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
|
|
||||||
function MoveWindowOrgEx(dc : hdc; dX,dY : Integer): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
function MoveWindowOrgEx(dc : hdc; dX,dY : Integer): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
|
|
||||||
|
@ -297,6 +297,9 @@ var
|
|||||||
javaField_lclformheight: JfieldID=nil;
|
javaField_lclformheight: JfieldID=nil;
|
||||||
javaField_lclscreenwidth: JfieldID=nil;
|
javaField_lclscreenwidth: JfieldID=nil;
|
||||||
javaField_lclscreenheight: JfieldID=nil;
|
javaField_lclscreenheight: JfieldID=nil;
|
||||||
|
// For LazDeviceAPIs
|
||||||
|
javaField_lcldestination: JfieldID=nil;
|
||||||
|
javaField_lclkind: JfieldID=nil;
|
||||||
|
|
||||||
// Methods of our Activity
|
// Methods of our Activity
|
||||||
javaMethod_LCLDoGetTextBounds: jmethodid = nil;
|
javaMethod_LCLDoGetTextBounds: jmethodid = nil;
|
||||||
@ -308,6 +311,9 @@ var
|
|||||||
javaMethod_LCLDoHideVirtualKeyboard: jmethodid = nil;
|
javaMethod_LCLDoHideVirtualKeyboard: jmethodid = nil;
|
||||||
javaMethod_LCLDoShowVirtualKeyboard: jmethodid = nil;
|
javaMethod_LCLDoShowVirtualKeyboard: jmethodid = nil;
|
||||||
javaMethod_LCLDoStartReadingAccelerometer: jmethodid = nil;
|
javaMethod_LCLDoStartReadingAccelerometer: jmethodid = nil;
|
||||||
|
javaMethod_LCLDoStopReadingAccelerometer: jmethodid = nil;
|
||||||
|
javaMethod_LCLDoSendMessage: jmethodid = nil;
|
||||||
|
javaMethod_LCLDoRequestPositionInfo: jmethodid = nil;
|
||||||
|
|
||||||
// This is utilized to store the information such as invalidate requests in events
|
// This is utilized to store the information such as invalidate requests in events
|
||||||
eventResult: jint;
|
eventResult: jint;
|
||||||
|
@ -165,12 +165,25 @@ end;
|
|||||||
|
|
||||||
procedure TCDWidgetSet.LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod);
|
procedure TCDWidgetSet.LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod);
|
||||||
begin
|
begin
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCDWidgetSet.LazDeviceAPIs_SendMessage(AMsg: TLazDeviceMessage);
|
procedure TCDWidgetSet.LazDeviceAPIs_SendMessage(AMsg: TLazDeviceMessage);
|
||||||
|
var
|
||||||
|
lJavaString: jstring;
|
||||||
|
lStr: String;
|
||||||
begin
|
begin
|
||||||
|
// Prepare the input
|
||||||
|
// String fields
|
||||||
|
lStr := AMsg.Body;
|
||||||
|
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(lStr));
|
||||||
|
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lcltext, lJavaString);
|
||||||
|
lStr := AMsg.destinationAddress.Text;
|
||||||
|
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(lStr));
|
||||||
|
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lcldestination, lJavaString);
|
||||||
|
// Message type
|
||||||
|
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclkind, 1);
|
||||||
|
// Call the method
|
||||||
|
javaEnvRef^^.CallVoidMethod(javaEnvRef, javaActivityObject, javaMethod_LCLDoSendMessage);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCDWidgetSet.LazDeviceAPIs_StartReadingAccelerometerData();
|
procedure TCDWidgetSet.LazDeviceAPIs_StartReadingAccelerometerData();
|
||||||
@ -179,6 +192,12 @@ begin
|
|||||||
javaEnvRef^^.CallVoidMethod(javaEnvRef, javaActivityObject, javaMethod_LCLDoStartReadingAccelerometer);
|
javaEnvRef^^.CallVoidMethod(javaEnvRef, javaActivityObject, javaMethod_LCLDoStartReadingAccelerometer);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCDWidgetSet.LazDeviceAPIs_StopReadingAccelerometerData();
|
||||||
|
begin
|
||||||
|
// Call the method
|
||||||
|
javaEnvRef^^.CallVoidMethod(javaEnvRef, javaActivityObject, javaMethod_LCLDoStopReadingAccelerometer);
|
||||||
|
end;
|
||||||
|
|
||||||
function TCDWidgetSet.PromptUser(const DialogCaption : string;
|
function TCDWidgetSet.PromptUser(const DialogCaption : string;
|
||||||
const DialogMessage : string;
|
const DialogMessage : string;
|
||||||
DialogType : LongInt;
|
DialogType : LongInt;
|
||||||
|
@ -128,6 +128,11 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCDWidgetSet.LazDeviceAPIs_StopReadingAccelerometerData();
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Function: PromptUser
|
Function: PromptUser
|
||||||
Params:
|
Params:
|
||||||
|
@ -129,6 +129,11 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCDWidgetSet.LazDeviceAPIs_StopReadingAccelerometerData();
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Function: PromptUser
|
Function: PromptUser
|
||||||
Params:
|
Params:
|
||||||
|
@ -129,6 +129,11 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCDWidgetSet.LazDeviceAPIs_StopReadingAccelerometerData();
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Function: PromptUser
|
Function: PromptUser
|
||||||
Params:
|
Params:
|
||||||
|
@ -59,6 +59,7 @@ function IsDesignerDC(WindowHandle: HWND; DC: HDC): Boolean; override;*)
|
|||||||
procedure LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod); override;
|
procedure LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod); override;
|
||||||
procedure LazDeviceAPIs_SendMessage(AMsg: TLazDeviceMessage); override;
|
procedure LazDeviceAPIs_SendMessage(AMsg: TLazDeviceMessage); override;
|
||||||
procedure LazDeviceAPIs_StartReadingAccelerometerData(); override;
|
procedure LazDeviceAPIs_StartReadingAccelerometerData(); override;
|
||||||
|
procedure LazDeviceAPIs_StopReadingAccelerometerData(); override;
|
||||||
|
|
||||||
function PromptUser(const DialogCaption : string;
|
function PromptUser(const DialogCaption : string;
|
||||||
const DialogMessage : string;
|
const DialogMessage : string;
|
||||||
|
@ -375,6 +375,9 @@ begin
|
|||||||
javaField_lclformheight := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lclformheight', 'I');
|
javaField_lclformheight := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lclformheight', 'I');
|
||||||
javaField_lclscreenwidth := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lclscreenwidth', 'I');
|
javaField_lclscreenwidth := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lclscreenwidth', 'I');
|
||||||
javaField_lclscreenheight := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lclscreenheight', 'I');
|
javaField_lclscreenheight := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lclscreenheight', 'I');
|
||||||
|
// For LazDeviceAPIs
|
||||||
|
javaField_lcldestination := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lcldestination', 'Ljava/lang/String;');
|
||||||
|
javaField_lclkind := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lclkind', 'I');
|
||||||
//
|
//
|
||||||
if not assigned(JavaField_lcltext) then
|
if not assigned(JavaField_lcltext) then
|
||||||
begin
|
begin
|
||||||
@ -392,6 +395,9 @@ begin
|
|||||||
javaMethod_LCLDoHideVirtualKeyboard := javaEnvRef^^.GetMethodID(javaEnvRef, javaActivityClass, 'LCLDoHideVirtualKeyboard', '()V');
|
javaMethod_LCLDoHideVirtualKeyboard := javaEnvRef^^.GetMethodID(javaEnvRef, javaActivityClass, 'LCLDoHideVirtualKeyboard', '()V');
|
||||||
javaMethod_LCLDoShowVirtualKeyboard := javaEnvRef^^.GetMethodID(javaEnvRef, javaActivityClass, 'LCLDoShowVirtualKeyboard', '()V');
|
javaMethod_LCLDoShowVirtualKeyboard := javaEnvRef^^.GetMethodID(javaEnvRef, javaActivityClass, 'LCLDoShowVirtualKeyboard', '()V');
|
||||||
javaMethod_LCLDoStartReadingAccelerometer := javaEnvRef^^.GetMethodID(javaEnvRef, javaActivityClass, 'LCLDoStartReadingAccelerometer', '()V');
|
javaMethod_LCLDoStartReadingAccelerometer := javaEnvRef^^.GetMethodID(javaEnvRef, javaActivityClass, 'LCLDoStartReadingAccelerometer', '()V');
|
||||||
|
javaMethod_LCLDoStopReadingAccelerometer := javaEnvRef^^.GetMethodID(javaEnvRef, javaActivityClass, 'LCLDoStopReadingAccelerometer', '()V');
|
||||||
|
javaMethod_LCLDoSendMessage := javaEnvRef^^.GetMethodID(javaEnvRef, javaActivityClass, 'LCLDoSendMessage', '()V');
|
||||||
|
javaMethod_LCLDoRequestPositionInfo := javaEnvRef^^.GetMethodID(javaEnvRef, javaActivityClass, 'LCLDoRequestPositionInfo', '()V');
|
||||||
|
|
||||||
__android_log_write(ANDROID_LOG_INFO, 'lclapp', 'JNI_OnLoad finished');
|
__android_log_write(ANDROID_LOG_INFO, 'lclapp', 'JNI_OnLoad finished');
|
||||||
result:=JNI_VERSION_1_4;// 1_6 is another option
|
result:=JNI_VERSION_1_4;// 1_6 is another option
|
||||||
|
@ -40,6 +40,7 @@ type
|
|||||||
TLazAccelerometer = class
|
TLazAccelerometer = class
|
||||||
private
|
private
|
||||||
FOnSensorChanged: TNotifyEvent;
|
FOnSensorChanged: TNotifyEvent;
|
||||||
|
FReadingStarted: Boolean;
|
||||||
public
|
public
|
||||||
// These fields store the last data read, to get fresh data use UpdateAccelerometerData;
|
// These fields store the last data read, to get fresh data use UpdateAccelerometerData;
|
||||||
xaxis, yaxis, zaxis: Double; // in m/s^2
|
xaxis, yaxis, zaxis: Double; // in m/s^2
|
||||||
@ -63,6 +64,8 @@ type
|
|||||||
public
|
public
|
||||||
// Attempt to send the specified message.
|
// Attempt to send the specified message.
|
||||||
procedure SendMessage(AMsg: TLazDeviceMessage);
|
procedure SendMessage(AMsg: TLazDeviceMessage);
|
||||||
|
//
|
||||||
|
function CreateMessage: TLazDeviceMessage;
|
||||||
// Called asynchronously when the message sending is finished
|
// Called asynchronously when the message sending is finished
|
||||||
property OnMessageSendingFinished: TOnMessageSendingFinished read FTOnMessageSendingFinished
|
property OnMessageSendingFinished: TOnMessageSendingFinished read FTOnMessageSendingFinished
|
||||||
write FTOnMessageSendingFinished;
|
write FTOnMessageSendingFinished;
|
||||||
@ -70,11 +73,9 @@ type
|
|||||||
|
|
||||||
// TLazPositionInfo
|
// TLazPositionInfo
|
||||||
|
|
||||||
TOnPositionRetrieved = procedure of object;
|
|
||||||
|
|
||||||
TLazPositionInfo = class
|
TLazPositionInfo = class
|
||||||
private
|
private
|
||||||
FOnPositionRetrieved: TOnPositionRetrieved;
|
FOnPositionRetrieved: TNotifyEvent;
|
||||||
public
|
public
|
||||||
IsPositionDataAvailable: Boolean; // Indicates if position info was read in the life of this program
|
IsPositionDataAvailable: Boolean; // Indicates if position info was read in the life of this program
|
||||||
// These fields hold the last position information read
|
// These fields hold the last position information read
|
||||||
@ -87,7 +88,7 @@ type
|
|||||||
timeStamp: TDateTime; // The time when the location was established.
|
timeStamp: TDateTime; // The time when the location was established.
|
||||||
procedure RequestPositionInfo(AMethod: TLazPositionMethod);
|
procedure RequestPositionInfo(AMethod: TLazPositionMethod);
|
||||||
// Called asynchronously when the position is read
|
// Called asynchronously when the position is read
|
||||||
property OnPositionRetrieved: TOnPositionRetrieved read FOnPositionRetrieved write FOnPositionRetrieved;
|
property OnPositionRetrieved: TNotifyEvent read FOnPositionRetrieved write FOnPositionRetrieved;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -101,12 +102,16 @@ implementation
|
|||||||
|
|
||||||
procedure TLazAccelerometer.StartReadingAccelerometerData;
|
procedure TLazAccelerometer.StartReadingAccelerometerData;
|
||||||
begin
|
begin
|
||||||
|
if FReadingStarted then Exit;
|
||||||
LCLIntf.LazDeviceAPIs_StartReadingAccelerometerData();
|
LCLIntf.LazDeviceAPIs_StartReadingAccelerometerData();
|
||||||
|
FReadingStarted := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLazAccelerometer.StopReadingAccelerometerData;
|
procedure TLazAccelerometer.StopReadingAccelerometerData;
|
||||||
begin
|
begin
|
||||||
|
if not FReadingStarted then Exit;
|
||||||
|
LCLIntf.LazDeviceAPIs_StopReadingAccelerometerData();
|
||||||
|
FReadingStarted := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TLazPositionInfo }
|
{ TLazPositionInfo }
|
||||||
@ -123,6 +128,11 @@ begin
|
|||||||
LCLIntf.LazDeviceAPIs_SendMessage(AMsg);
|
LCLIntf.LazDeviceAPIs_SendMessage(AMsg);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TLazMessaging.CreateMessage: TLazDeviceMessage;
|
||||||
|
begin
|
||||||
|
Result := TLazDeviceMessage.Create;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
Accelerometer := TLazAccelerometer.Create;
|
Accelerometer := TLazAccelerometer.Create;
|
||||||
Messaging := TLazMessaging.Create;
|
Messaging := TLazMessaging.Create;
|
||||||
|
Loading…
Reference in New Issue
Block a user