-
-
Notifications
You must be signed in to change notification settings - Fork 126
/
Copy pathDW.NativeButton.Android.pas
93 lines (77 loc) · 2.84 KB
/
DW.NativeButton.Android.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
unit DW.NativeButton.Android;
{*******************************************************}
{ }
{ Kastri }
{ }
{ Delphi Worlds Cross-Platform Library }
{ }
{ Copyright 2020-2024 Dave Nottage under MIT license }
{ which is located in the root folder of this library }
{ }
{*******************************************************}
interface
implementation
uses
// RTL
System.TypInfo, System.Classes, System.SysUtils, System.Types,
// Android
Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.Widget, Androidapi.Helpers, Androidapi.JNI.Net, Androidapi.JNI.JavaTypes,
Androidapi.JNIBridge, Androidapi.JNI, Androidapi.JNI.Support,
// FMX
FMX.Presentation.Messages, FMX.Presentation.Android, FMX.Presentation.Factory, FMX.Controls, FMX.Controls.Presentation, FMX.Controls.Model,
// DW
DW.NativeButton, DW.NativeControl.Android;
type
TAndroidNativeButton = class(TNativeControl)
private
FView: JButton;
function GetModel: TCustomNativeButtonModel;
procedure MMSetText(var AMessage: TDispatchMessageWithValue<string>); message MM_SET_TEXT;
protected
function CreateView: JView; override;
function DefineModelClass: TDataModelClass; override;
procedure DoLongPress; override;
public
constructor Create; override;
destructor Destroy; override;
property Model: TCustomNativeButtonModel read GetModel;
property View: JButton read FView;
end;
{ TAndroidNativeButton }
constructor TAndroidNativeButton.Create;
begin
inherited;
//
end;
function TAndroidNativeButton.DefineModelClass: TDataModelClass;
begin
Result := TCustomNativeButtonModel;
end;
destructor TAndroidNativeButton.Destroy;
begin
//
inherited;
end;
procedure TAndroidNativeButton.DoLongPress;
begin
Model.DoLongPress;
end;
function TAndroidNativeButton.GetModel: TCustomNativeButtonModel;
begin
Result := inherited GetModel<TCustomNativeButtonModel>;
end;
procedure TAndroidNativeButton.MMSetText(var AMessage: TDispatchMessageWithValue<string>);
begin
View.setText(StrToJCharSequence(AMessage.Value));
end;
function TAndroidNativeButton.CreateView: JView;
begin
FView := TJButton.JavaClass.init(TAndroidHelper.Context);
FView.setAllCaps(False);
Result := FView;
end;
initialization
TPresentationProxyFactory.Current.Register(TNativeButton, TControlType.Platform, TAndroidPresentationProxy<TAndroidNativeButton>);
finalization
TPresentationProxyFactory.Current.Unregister(TNativeButton, TControlType.Platform, TAndroidPresentationProxy<TAndroidNativeButton>);
end.