DBILITY

FMX 기기정보 본문

delphi

FMX 기기정보

DBILITY 2019. 7. 5. 18:59
반응형

그냥 해본다..하드웨어 백버튼 클릭시 종료도 있다.


unit UMain;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes,
  System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.ListBox,
  FMX.Layouts, FMX.StdCtrls, FMX.Controls.Presentation, FMX.Platform,
  FMX.VirtualKeyboard;

type
  TForm1 = class(TForm)
    ToolBar1: TToolBar;
    기기정보: TLabel;
    Button1: TButton;
    ListBox1: TListBox;
    ListBoxItem1: TListBoxItem;
    ListBoxItem2: TListBoxItem;
    ListBoxItem3: TListBoxItem;
    procedure Button1Click(Sender: TObject);
    procedure FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$IFDEF ANDROID}

uses
  AndroidApi.Jni.Os, AndroidApi.Helpers;
{$ENDIF}
{$IFDEF IOS}

uses
  iOsApi.UIKit, MacApi.Helpers;
{$ENDIF}
{$R *.fmx}
{$IFDEF ANDROID}

function GetAndroidCodeName(VerString: String): String;
var
  iVer: Single;
begin
  if TryStrToFloat(VerString, iVer) then
  begin
    if iVer >= 9.0 then
      Result := '파이'
    else if iVer >= 8.0 then
      Result := '오레오'
    else if iVer >= 7.0 then
      Result := '누가'
    else if iVer >= 6.0 then
      Result := '마시멜로'
    else if iVer >= 5.0 then
      Result := '롤리팝'
    else if iVer >= 4.4 then
      Result := '킷캣'
    else if iVer >= 4.1 then
      Result := '젤리빈'
    else if iVer >= 4.0 then
      Result := '아이스크림샌드위치'
    else if iVer >= 3.0 then
      Result := '허니콤'
    else if iVer >= 2.3 then
      Result := '진저브레드'
    else if iVer >= 2.2 then
      Result := '프로요'
    else
      Result := '알수없음';
  end;
end;
{$ENDIF}

procedure TForm1.Button1Click(Sender: TObject);
begin
{$IFDEF ANDROID}
  ListBoxItem1.ItemData.Detail := JStringToString(TJBuild.JavaClass.MODEL);
  ListBoxItem2.ItemData.Detail :=
    GetAndroidCodeName(JStringToString(TJBuild_VERSION.JavaClass.RELEASE));
  ListBoxItem3.ItemData.Detail :=
    JStringToString(TJBuild_VERSION.JavaClass.RELEASE);
  // ShowMessage(JStringToString(TJBuild_VERSION.JavaClass.BASE_OS));
  // ShowMessage(JStringToString(TJBuild_VERSION.JavaClass.CODENAME));
{$ENDIF}
{$IFDEF IOS}
  ListBoxItem1.ItemData.Detail := NSStrToStr(Device.System.Name);
  ListBoxItem2.ItemData.Detail := NSStrToStr(Device.SystemVersion);
  ListBoxItem3.ItemData.Detail := NSStrToStr(Device.MODEL);
{$ENDIF}
end;

procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
  Shift: TShiftState);
var
  FVirtualKeyService: IFMXVirtualKeyboardService;
begin

  if Key = vkHardwareBack then
  begin

    TPlatformServices.Current.SupportsPlatformService
      (IFMXVirtualKeyboardService, IInterface(FVirtualKeyService));

    if (FVirtualKeyService <> nil) and
      (TVirtualKeyboardState.Visible in FVirtualKeyService.VirtualKeyboardState)
    then
    else
    begin
      Key := 0;
      TDialogService.PreferredMode := TDialogService.TPreferredMode.Platform;
      TDialogService.MessageDialog('Exit?', TMsgDlgType.mtInformation,
        [TMsgDlgBtn.mbOK, TMsgDlgBtn.mbCancel], TMsgDlgBtn.mbCancel, 0,
        procedure(const AResult: TModalResult)
        begin
          if AResult = mrOk then
            Close;
        end);

      // MessageDlg('Exit?', TMsgDlgType.mtInformation,
      // [TMsgDlgBtn.mbOK, TMsgDlgBtn.mbCancel], -1,
      // procedure(const AResult: TModalResult)
      // begin
      // if AResult = mrOK then
      // Close;
      // end);

    end;
  end;
end;

end.


반응형

'delphi' 카테고리의 다른 글

FMX 로또번호 생성기  (0) 2019.07.23
FMX InputQueryAsync  (0) 2019.07.05
ToYcon  (0) 2019.06.29
SILK ICONS  (0) 2019.06.29
Comments