Árvore de páginas

A plataforma TMobile / CloudBridge foi descontinuada


TMobile é uma classe utilitária que agrupa métodos focados na plataforma móvel TOTVS | FatClient Embarcado e promove as integrações com aplicativos ou com o hardware do dispositivo móvel.

Hierarquia

  • TMobile

Construtores

Propriedades

Métodos

Observações

  • A plataforma móvel TOTVS | FatClient Embarcado para Android está na versão Beta (para testes e avaliações) e encontra-se disponível na loja Google Play Store.
  • Atualmente a classe TMobile está disponível somente para dispositivos Android.

Exemplos

#include "totvs.ch"

// Definições para integração com leitor de código de barras
#define PRODUCT_MODE      "PRODUCT_MODE"     // Decode only UPC and EAN barcodes. This is the right choice for shopping apps which get prices, reviews, etc. for products.
#define ONE_D_MODE        "ONE_D_MODE"       // Decode only 1D barcodes.
#define QR_CODE_MODE      "QR_CODE_MODE"     // Decode only QR codes.
#define DATA_MATRIX_MODE  "DATA_MATRIX_MODE" // Decode only Data Matrix codes.
#define AZTEC_MODE        "AZTEC_MODE"       // Decode only Aztec.
#define PDF417_MODE       "PDF417_MODE"      // Decode only PDF417.

// Definições dos valores usados para orientação da tela do dispositivo
#define ORIENTATION_UNSPECIFIED        -1 // Usado somente para o SetScreenOrientation. Posição livre definida pelo usuário ou sensor do dispositivo.
#define ORIENTATION_PORTRAIT            1 // Tela na posição retrato.
#define ORIENTATION_LANDSCAPE           2 // Tela na posição paisagem.
#define ORIENTATION_INVERTED_PORTRAIT   4 // Tela na posição retrato invertido.
#define ORIENTATION_INVERTED_LANDSCAPE  8 // Tela na posição paisagem invertida.

// Definições para o formato dos valores de coordenadas globais para Geolocalização (GPS)
#define GEOCOORDINATE_DEGREES                         0 // -23.50607°, -46.64371°           Formato em graus com fração decimal.
#define GEOCOORDINATE_DEGREESHEMISPHERE               1 // 23.50607° S, 46.64376° W         Formato em graus com fração decimal e letra para indicar hemisfério.
#define GEOCOORDINATE_DEGREESMINUTES                  2 // -23° 30.364', -46° 38.625'       Formato em graus com fração em minutos.
#define GEOCOORDINATE_DEGREESMINUTESHEMISPHERE        3 // 23° 30.365' S, 46° 38.626' W     Formato em graus com fração em minutos e letra para indicar hemisfério.
#define GEOCOORDINATE_DEGREESMINUTESSECONDS           4 // -23° 30' 21.9", -46° 38' 37.5"   Formato em graus com fração em minutos e segundos.
#define GEOCOORDINATE_DEGREESMINUTESSECONDSHEMISPHERE 5 // 23° 30' 21.8" S, 46° 38' 37.5" W Formato em graus com fração em minutos e segundos e letra para indicar hemisfério.

// Definições de funcionalidades/componentes para os métodos de OpenSettings() e TestDevice()
#define BLUETOOTH_FEATURE 1
#define NFC_FEATURE       2
#define WIFI_FEATURE      3
#define LOCATION_FEATURE  4
#define CONNECTED_WIFI    5 // Apenas utilizado no TestDevice()
#define CONNECTED_MOBILE  6 // Apenas utilizado no TestDevice()

Function u_tstMobile()
  Local calibri18Black := TFont():New("Calibri",,018,,.T.,,,,,.F.,.F.)

  DEFINE MSDIALOG oDlg TITLE "Testes com TMobile" FROM 000, 000  TO 450, 700 COLORS 0, 16777215 PIXEL

  PRIVATE oMbl := TMobile():New(oDlg)

  oMbl:bNotificationTapped := { |nNotificationId| MsgInfo("ID da notificação: " + cValToChar(nNotificationId),"") }

  oTFont:= TFont():New('calibri',,-18,,.T.)
  oTSay := TSay():New( 005, 045,{||"Integrações disponíveis na classe tMobile para a plataforma TOTVS | FatClient Embarcado"},oDlg;
             ,,oTFont,.T.,.F.,.F.,.T.,0,,270,020,.F.,.T.,.F.,.F.,.F.,.F. )

  SetCss("TButton{color: black;}")

  @ 035, 007 BUTTON oButton01 PROMPT "Ler Código de Barras" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl1() } PIXEL
  @ 035, 180 BUTTON oButton02 PROMPT "Listar Dispositivos Bluetooth Pareados" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl2() } PIXEL

  @ 055, 007 BUTTON oButton03 PROMPT "Capturar Foto" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl3() } PIXEL
  @ 055, 180 BUTTON oButton04 PROMPT "Mostrar Orientação da Tela" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl4() } PIXEL

  @ 075, 007 BUTTON oButton05 PROMPT "Especificar Orientação da Tela" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl5() } PIXEL
  @ 075, 180 BUTTON oButton06 PROMPT "Ativar bScreenOrientationChanged" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl6() } PIXEL

  @ 095, 007 BUTTON oButton07 PROMPT "Mostrar Coordenadas de Geolocalização" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl7() } PIXEL
  @ 095, 180 BUTTON oButton08 PROMPT "Ativar bGeoCoordinateUpdate" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl8() } PIXEL

  @ 115, 007 BUTTON oButton09 PROMPT "Habilitar Atualizações de Coordenadas" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl9() } PIXEL
  @ 115, 180 BUTTON oButton10 PROMPT "Desabilitar Atualizações de Coordenadas" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl10() } PIXEL

  @ 135, 007 BUTTON oButton11 PROMPT "Testar Componente/Funcionalidade" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl11() } PIXEL
  @ 135, 180 BUTTON oButton12 PROMPT "Abrir Menu de Configurações" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl12() } PIXEL

  @ 155, 007 BUTTON oButton13 PROMPT "Disparar Notificação" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl13() } PIXEL
  @ 155, 180 BUTTON oButton14 PROMPT "Caminho do Diretório Temporário" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl14() } PIXEL

  @ 175, 007 BUTTON oButton15 PROMPT "Vibrar" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl15() } PIXEL
  @ 175, 180 BUTTON oButton16 PROMPT "Ler Sensor Acelerômetro" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl16() } PIXEL

  @ 195, 007 BUTTON oButton17 PROMPT "Adicionar Contato" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl17() } PIXEL
  @ 195, 180 BUTTON oButton18 PROMPT "Procurar Contatos" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl18() } PIXEL
  
  @ 215, 007 BUTTON oButton19 PROMPT "Ativar bOnPause" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl19() } PIXEL
  @ 215, 180 BUTTON oButton20 PROMPT "Ativar bOnResume" SIZE 150, 012 OF oDlg ACTION {|| u_tmbl20() } PIXEL

  ACTIVATE DIALOG oDlg CENTERED
Return

Static Function u_tmbl1()
  LOCAL cBarType
  LOCAL aBarResult

  // Especificar aqui um tipo de código de barras para limitar a leitura.
  //cBarType:= PRODUCT_MODE;
  cBarType:= "";

  aBarResult:= oMbl:BarCode()

  If aBarResult[1] = ""
    sMsg := "Nenhum código de barras foi lido."
  Else
    sMsg := "Código de barras lido:" + chr(13) + chr(13) + "Código: " + aBarResult[1] + chr(13) + "Formato: " + aBarResult[2]
  EndIf

  MsgInfo(sMsg)
Return

Static Function u_tmbl2()
  LOCAL aDevicesResult
  Local i

  aDevicesResult:= oMbl:GetPairedBluetoothDevices()

  sMsg := ""
  For i := 1 to len(aDevicesResult)
    sMsg := sMsg + "Nome: " + aDevicesResult[i][1] + chr(13)
    sMsg := sMsg + "Endereço: " + aDevicesResult[i][2] + chr(13) + chr(13)
  Next i

  If sMsg = ""
    sMsg := "Nenhum dispositivo pareado ou interface Bluetooth desligada."
  Else
    sMsg := "Dispositivos Bluetooth Pareados:" + chr(13) + chr(13) + sMsg
  EndIf

  MsgInfo(sMsg)
Return

Static Function u_tmbl3()
  Local cFilePath
  Local cMsg

  DEFINE DIALOG oDlg TITLE "Exemplo TMobile TakePicture" FROM 180,180 TO 610,700 PIXEL

  cFilePath:= oMbl:TakePicture()

  if (cFilePath = "")
    cMsg := "Nenhuma imagem foi gravada."
  else
    cMsg := "Arquivo: " + cFilePath
  endif

  // Por ser o Android um sistema baseado no linux e para indicar que o arquivo encontra-se no
  // lado do client, é adicionada uma letra de unidade de disco fictícia.
  cFilePath:= "C:" + cFilePath

  oTBitmap1 := TBitmap():New(01,01,260,184,,cFilePath,.F.,oDlg,,,.F.,.T.,,,.F.,,.T.,,.F.)
  oTBitmap1:lAutoSize := .F.

  oSay:= TSay():New(187, 02, {||cMsg},oDlg,,,,,,.T.,CLR_RED,CLR_WHITE,200,10)

  oTButton1 := TButton():New( 200, 110, "Fechar", oDlg, {||oDlg:End()},40,10,,,.F.,.T.,.F.,,.F.,,,.F. )

  ACTIVATE DIALOG oDlg CENTERED
Return

Static Function u_tmbl4()
  PrintOrientation( oMbl:GetScreenOrientation() )
Return

Static Function u_tmbl5()
  DEFINE MSDIALOG oDlgInput TITLE "Escolha uma orientação para a tela" FROM 180,180 TO 260,360 PIXEL

  nRadio := 1
  aItems := {'-1=Unspecified','1=Portrait','2=Landscape','4=Inverted Portrait','8=Inverted Landscape'}
  cCombo1:= aItems[1]
  oCombo1 := TComboBox():New(01,01,{|u|if(PCount()>0,cCombo1:=u,cCombo1)},;
        aItems,80,20,oDlgInput,,,,,,.T.,,,,,,,,,'cCombo1')

  oBtn1 := TButton():New( 25, 002, 'Ok', oDlgInput, {|| oMbl:SetScreenOrientation(VAL(cCombo1)), oDlgInput:End() },25,15,,,.F.,.T.,.F.,,.F.,,,.F. )
  oBtn2 := TButton():New( 25, 034, 'Cancela', oDlgInput, {|| oDlgInput:End() },25,15,,,.F.,.T.,.F.,,.F.,,,.F. )

  ACTIVATE MSDIALOG oDlgInput CENTERED
Return

Static Function u_tmbl6()
  oMbl:bScreenOrientationChanged := { |nOrientation| PrintOrientation(nOrientation) }
  MsgInfo("O blobo de código bScreenOrientationChanged foi ativado." + CRLF + ;
          "Mude a orientação da tela do dispositivo móvel para que" + CRLF + ;
          "uma mensagem seja exibida mostrando a nova orientação.")
Return

Static Function u_tmbl7()
  DEFINE MSDIALOG oDlgInput TITLE "Escolha um formato para a coordenada" FROM 180,180 TO 260,460 PIXEL

  oFont := TFont():New('Courier new',,-16,.T.)

  nRadio := 1
  aItems := {'0=Graus com fração decimal',;
             '1=Graus com fração decimal e letra para hemisfério',;
             '2=Graus com fração em minutos',;
             '3=Graus com fração em minutos e letra para hemisfério',;
             '4=Graus com fração em minutos e segundos',;
             '5=Graus com fração em minutos e segundos e letra para hemisfério'}
  cCombo1:= aItems[1]

  oSay1 := TSay():New(01,01,{||'Formato:'},oDlgInput,,oFont,,,,.T.,CLR_BLACK,CLR_WHITE,45,20)
  oCombo1 := TComboBox():New(01,50,{|u|if(PCount()>0,cCombo1:=u,cCombo1)},;
        aItems,80,20,oDlgInput,,,,,,.T.,,,,,,,,,'cCombo1')

  oBtn1 := TButton():New( 25, 002, 'Ok', oDlgInput, {|| msgInfo(oMbl:GetGeoCoordinate(VAL(cCombo1)),"Coordenadas recebidas"), oDlgInput:End() },25,15,,,.F.,.T.,.F.,,.F.,,,.F. )
  oBtn2 := TButton():New( 25, 034, 'Cancela', oDlgInput, {|| oDlgInput:End() },25,15,,,.F.,.T.,.F.,,.F.,,,.F. )

  ACTIVATE MSDIALOG oDlgInput CENTERED
Return

Static Function u_tmbl8()
  oMbl:bGeoCoordinateUpdate := { |cGeoPosition| MsgInfo(cGeoPosition,"") }
  MsgInfo("O blobo de código bGeoCoordinateUpdate foi ativado." + CRLF + ;
          "A cada atualização de coordenada geográfica, uma mensagem" + CRLF + ;
          "será exibida com as coordenadas atualizadas.")
Return

Static Function u_tmbl9()
  DEFINE MSDIALOG oDlgInput TITLE "Habilitar Atualizações de Coordenadas" FROM 180,180 TO 310,460 PIXEL

  oFont := TFont():New('Courier new',,-16,.T.)

  nRadio := 1
  aItems := {'0=Graus com fração decimal',;
             '1=Graus com fração decimal e letra para hemisfério',;
             '2=Graus com fração em minutos',;
             '3=Graus com fração em minutos e letra para hemisfério',;
             '4=Graus com fração em minutos e segundos',;
             '5=Graus com fração em minutos e segundos e letra para hemisfério'}
  cCombo1:= aItems[1]
  oSay1 := TSay():New(01,01,{||'Formato:'},oDlgInput,,oFont,,,,.T.,CLR_BLACK,CLR_WHITE,55,20)
  oCombo1 := TComboBox():New(01,55,{|u|if(PCount()>0,cCombo1:=u,cCombo1)},;
        aItems,80,20,oDlgInput,,,,,,.T.,,,,,,,,,'cCombo1')

  nGet2 := 0
  oSay2 := TSay():New( 20, 01,{||'Intervalo:'},oDlgInput,,oFont,,,,.T.,CLR_BLACK,CLR_WHITE,55,20)
  oGet1 := TGet():New( 20, 55, { | u | If( PCount() == 0, nGet2, nGet2 := u ) },oDlgInput, ;
     030, 010, "@E 99999",, 0, 16777215,,.F.,,.T.,,.F.,,.F.,.F.,,.F.,.F. ,,"nGet2",,,,.F.  )

  oBtn1 := TButton():New( 50, 002, 'Ok', oDlgInput, {|| oMbl:EnableGeoCoordinateUpdate(nGet2,VAL(cCombo1)), oDlgInput:End() },25,15,,,.F.,.T.,.F.,,.F.,,,.F. )
  oBtn2 := TButton():New( 50, 034, 'Cancela', oDlgInput, {|| oDlgInput:End() },25,15,,,.F.,.T.,.F.,,.F.,,,.F. )

  ACTIVATE MSDIALOG oDlgInput CENTERED
Return

Static Function u_tmbl10()
  oMbl:EnableGeoCoordinateUpdate(-1,0)
  msgInfo("Atualizações de Coordenadas Desativadas.","")
Return

Static Function u_tmbl11()
  DEFINE MSDIALOG oDlgInput TITLE "Escolha um componente/funcionalidade para testar" FROM 180,180 TO 260,460 PIXEL

  oFont := TFont():New('Courier new',,-16,.T.)

  nRadio := 1
  aItems := {'1=Bluetooh',;
             '2=NFC',;
             '3=Wi-Fi',;
             '4=Localização',;
             '5=Conectado a rede Wi-Fi',;
             '6=Conectado a rede de dados móveis'}
  cCombo1:= aItems[1]

  oSay1 := TSay():New(01,01,{||'Componente:'},oDlgInput,,oFont,,,,.T.,CLR_BLACK,CLR_WHITE,55,20)
  oCombo1 := TComboBox():New(01,60,{|u|if(PCount()>0,cCombo1:=u,cCombo1)},;
        aItems,80,20,oDlgInput,,,,,,.T.,,,,,,,,,'cCombo1')

  oBtn1 := TButton():New( 25, 002, 'Ok', oDlgInput, {|| ;
    IIf(oMbl:TestDevice(VAL(cCombo1)),MsgInfo("O componente está ativado!",""),MsgStop("O componente está desativado ou ausente no dispositivo.","") );
    ,oDlgInput:End() },25,15,,,.F.,.T.,.F.,,.F.,,,.F. )
  oBtn2 := TButton():New( 25, 034, 'Cancela', oDlgInput, {|| oDlgInput:End() },25,15,,,.F.,.T.,.F.,,.F.,,,.F. )

  ACTIVATE MSDIALOG oDlgInput CENTERED
Return

Static Function u_tmbl12()
  DEFINE MSDIALOG oDlgInput TITLE "Escolha qual tela de configurações deseja abrir" FROM 180,180 TO 260,460 PIXEL

  oFont := TFont():New('Courier new',,-16,.T.)

  nRadio := 1
  aItems := {'1=Bluetooh',;
             '2=NFC',;
             '3=Wi-Fi',;
             '4=Localização'}
  cCombo1:= aItems[1]

  oSay1 := TSay():New(01,01,{||'Configurações:'},oDlgInput,,oFont,,,,.T.,CLR_BLACK,CLR_WHITE,70,20)
  oCombo1 := TComboBox():New(01,75,{|u|if(PCount()>0,cCombo1:=u,cCombo1)},;
        aItems,60,20,oDlgInput,,,,,,.T.,,,,,,,,,'cCombo1')

  oBtn1 := TButton():New( 25, 002, 'Ok', oDlgInput, {|| oMbl:OpenSettings(VAL(cCombo1)), oDlgInput:End() },25,15,,,.F.,.T.,.F.,,.F.,,,.F. )
  oBtn2 := TButton():New( 25, 034, 'Cancela', oDlgInput, {|| oDlgInput:End() },25,15,,,.F.,.T.,.F.,,.F.,,,.F. )

  ACTIVATE MSDIALOG oDlgInput CENTERED
Return

Static Function u_tmbl13()

  DEFINE MSDIALOG oDlgInput TITLE "Criar Notificação" FROM 180,180 TO 340,500 PIXEL

  oFont := TFont():New('Courier new',,-16,.T.)

  oSay1 := TSay():New(01,01,{||'ID:'},oDlgInput,,oFont,,,,.T.,CLR_BLACK,CLR_WHITE,55,20)
  nGet1 := 1
  oGet1 := TGet():New( 01, 20, { | u | If( PCount() == 0, nGet1, nGet1 := u ) },oDlgInput, ;
     030, 010, "@E 9",, 0, 16777215,,.F.,,.T.,,.F.,,.F.,.F.,,.F.,.F. ,,"nGet1",,,,.F.  )

  cGet2 := space(100)
  oSay2 := TSay():New( 20, 01,{||'Título:'},oDlgInput,,oFont,,,,.T.,CLR_BLACK,CLR_WHITE,55,20)
  oGet2 := TGet():New( 20, 55, { | u | If( PCount() == 0, cGet2, cGet2 := u ) },oDlgInput, ;
     100, 010, "@",, 0, 16777215,,.F.,,.T.,,.F.,,.F.,.F.,,.F.,.F. ,,"cGet2",,,,.F.  )

  cGet3 := space(100)
  oSay3 := TSay():New( 40, 01,{||'Mensagem:'},oDlgInput,,oFont,,,,.T.,CLR_BLACK,CLR_WHITE,55,20)
  oGet3 := TGet():New( 40, 55, { | u | If( PCount() == 0, cGet3, cGet3 := u ) },oDlgInput, ;
     100, 010, "@",, 0, 16777215,,.F.,,.T.,,.F.,,.F.,.F.,,.F.,.F. ,,"cGet3",,,,.F.  )

  oBtn1 := TButton():New( 60, 002, 'Ok', oDlgInput, {|| oMbl:CreateNotification(nGet1,ALLTRIM(cGet2),ALLTRIM(cGet3)), oDlgInput:End() },25,15,,,.F.,.T.,.F.,,.F.,,,.F. )
  oBtn2 := TButton():New( 60, 034, 'Cancela', oDlgInput, {|| oDlgInput:End() },25,15,,,.F.,.T.,.F.,,.F.,,,.F. )

  ACTIVATE MSDIALOG oDlgInput CENTERED
Return

Static Function u_tmbl14()

  MsgInfo( "Diretório temporário: " + oMbl:GetTempPath() )

Return

Static Function u_tmbl15()

  oMbl:Vibrate()

Return

Static Function u_tmbl16()
  aRet := oMbl:ReadAccelerometer()

  cMsg := "Valores lidos do sensor acelerômetro (m/s²):" + chr(13) + chr(10)
  cMsg += "Eixo x: " + str(aRet[1]) + chr(13) + chr(10)
  cMsg += "Eixo y: " + str(aRet[2]) + chr(13) + chr(10)
  cMsg += "Eixo z: " + str(aRet[3])

  MsgInfo( cMsg, "" )
Return

Static Function u_tmbl17()

  local aTypes := { "1-Home", "2-Work", "3-Other" }

  DEFINE MSDIALOG oDlgInput TITLE "Adicionar Contato" FROM 180, 180 TO 800, 800 PIXEL

    oFont := TFont():New( 'Courier new',, -16, .T. )

    oPanelBtn := tPanel():New( 0, 0,, oDlgInput, oFont, .T.,,,, 0, 0)
    oPanelBtn:nHeight := 40
    oPanelBtn:Align := CONTROL_ALIGN_BOTTOM

    oTBtnOk := TButton():New( 5, 5, "&Ok", oPanelBtn,;
      { || AddContMob( { cGetCompany, cGetJobTitle, cGetName, cGetNote,;
      cGetEmail1, cCmbEmail1, cGetEmail2, cCmbEmail2, cGetEmail3, cCmbEmail3,;
      cGetPhone1, cCmbPhone1, cGetPhone2, cCmbPhone2, cGetPhone3, cCmbPhone3,;
      cGetPost1, cCmbPost1, cGetPost2, cCmbPost2, cGetPost3, cCmbPost3 } ) },;
      50, 10,,, .F., .T., .F.,, .F.,,, .F. )
    oTBtnCanc := TButton():New( 5, 65, "&Cancel", oPanelBtn,;
      { || oDlgInput:End() }, 50, 10,,, .F., .T., .F.,, .F.,,, .F. )

    oPanelScr := tPanel():New( 0, 0,, oDlgInput, oFont, .T.,,,, 0, 0)
    oPanelScr:Align := CONTROL_ALIGN_ALLCLIENT

    cGetCompany := Space( 256 )
    oGetCompany := TGet():New( 5, 5, { | u | If( PCount() == 0, cGetCompany,;
      cGetCompany := u ) }, oPanelScr, 100, 10,,,,,, .F.,, .T.,, .F.,, .F.,;
      .F.,, .F., .F.,, "cGetCompany",,,, .F.,,, "Company:", 2 )

    cGetJobTitle := Space( 256 )
    oGetJobTitle := TGet():New( 25, 5, { | u | If( PCount() == 0, cGetJobTitle,;
      cGetJobTitle := u ) }, oPanelScr, 100, 10,,,,,, .F.,, .T.,, .F.,, .F.,;
      .F.,, .F., .F.,, "cGetJobTitle",,,, .F.,,, "Job Title:", 2 )

    cGetName := Space( 256 )
    oGetName := TGet():New( 45, 5, { | u | If( PCount() == 0, cGetName,;
      cGetName := u ) }, oPanelScr, 100, 10,,,,,, .F.,, .T.,, .F.,, .F., .F.,,;
      .F., .F.,, "cGetName",,,, .F.,,, "Name:", 2 )

    cGetNote := Space( 256 )
    oGetNote := TGet():New( 65, 5, { | u | If( PCount() == 0, cGetNote,;
      cGetNote := u ) }, oPanelScr, 100, 10,,,,,, .F.,, .T.,, .F.,, .F., .F.,,;
      .F., .F.,, "cGetNote",,,, .F.,,, "Note:", 2 )

    cGetEmail1 := Space( 256 )
    oGetEmail1 := TGet():New( 85, 5, { | u | If( PCount() == 0, cGetEmail1,;
      cGetEmail1 := u ) }, oPanelScr, 100, 10,,,,,, .F.,, .T.,, .F.,, .F.,;
      .F.,, .F., .F.,, "cGetEmail1",,,, .F.,,, "E-mail 1:", 2 )
    cCmbEmail1:= aTypes[1]
    oCmbEmail1 := TComboBox():New( 85, 130, { |u| if( PCount() > 0,;
      cCmbEmail1 := u, cCmbEmail1 ) }, aTypes, 50, 10, oPanelScr,,,,,, .T.,,,,,;
      ,,,, 'cCmbEmail1', "Tipo:", 2 )

    cGetEmail2 := Space( 256 )
    oGetEmail2 := TGet():New( 105, 5, { | u | If( PCount() == 0, cGetEmail2,;
      cGetEmail2 := u ) }, oPanelScr, 100, 10,,,,,, .F.,, .T.,, .F.,, .F., .F.,;
      , .F., .F.,, "cGetEmail2",,,, .F.,,, "E-mail 2:", 2 )
    cCmbEmail2:= aTypes[1]
    oCmbEmail2 := TComboBox():New( 105, 130, { |u| if( PCount() > 0,;
      cCmbEmail2 := u, cCmbEmail2 ) }, aTypes, 50, 10, oPanelScr,,,,,, .T.,,,,,;
      ,,,, 'cCmbEmail2', "Tipo:", 2 )

    cGetEmail3 := Space( 256 )
    oGetEmail3 := TGet():New( 125, 5, { | u | If( PCount() == 0, cGetEmail3,;
      cGetEmail3 := u ) }, oPanelScr, 100, 10,,,,,, .F.,, .T.,, .F.,, .F., .F.,;
      , .F., .F.,, "cGetEmail3",,,, .F.,,, "E-mail 3:", 2 )
    cCmbEmail3:= aTypes[1]
    oCmbEmail3 := TComboBox():New( 125, 130, { |u| if( PCount() > 0,;
      cCmbEmail3 := u, cCmbEmail3 ) }, aTypes, 50, 10, oPanelScr,,,,,, .T.,,,,,;
      ,,,, 'cCmbEmail3', "Tipo:", 2 )

    cGetPhone1 := Space( 256 )
    oGetPhone1 := TGet():New( 145, 5, { | u | If( PCount() == 0, cGetPhone1,;
      cGetPhone1 := u ) }, oPanelScr, 100, 10,,,,,, .F.,, .T.,, .F.,, .F., .F.,;
      , .F., .F.,, "cGetPhone1",,,, .F.,,, "Phone 1:", 2 )
    cCmbPhone1:= aTypes[1]
    oCmbPhone1 := TComboBox():New( 145, 130, { |u| if( PCount() > 0,;
      cCmbPhone1 := u, cCmbPhone1 ) }, aTypes, 50, 10, oPanelScr,,,,,, .T.,,,,,;
      ,,,, 'cCmbPhone1', "Tipo:", 2 )

    cGetPhone2 := Space( 256 )
    oGetPhone2 := TGet():New( 165, 5, { | u | If( PCount() == 0, cGetPhone2,;
      cGetPhone2 := u ) }, oPanelScr, 100, 10,,,,,, .F.,, .T.,, .F.,, .F., .F.,;
      , .F., .F.,, "cGetPhone2",,,, .F.,,, "Phone 2:", 2 )
    cCmbPhone2:= aTypes[1]
    oCmbPhone2 := TComboBox():New( 165, 130, { |u| if( PCount() > 0,;
      cCmbPhone2 := u, cCmbPhone2 ) }, aTypes, 50, 10, oPanelScr,,,,,, .T.,,,,,;
      ,,,, 'cCmbPhone2', "Tipo:", 2 )

    cGetPhone3 := Space( 256 )
    oGetPhone3 := TGet():New( 185, 5, { | u | If( PCount() == 0, cGetPhone3,;
      cGetPhone3 := u ) }, oPanelScr, 100, 10,,,,,, .F.,, .T.,, .F.,, .F., .F.,;
      , .F., .F.,, "cGetPhone3",,,, .F.,,, "Phone 3:", 2 )
    cCmbPhone3:= aTypes[1]
    oCmbPhone3 := TComboBox():New( 185, 130, { |u| if( PCount() > 0,;
      cCmbPhone3 := u, cCmbPhone3 ) }, aTypes, 50, 10, oPanelScr,,,,,, .T.,,,,,;
      ,,,, 'cCmbPhone3', "Tipo:", 2 )

    cGetPost1 := Space( 256 )
    oGetPost1 := TGet():New( 205, 5, { | u | If( PCount() == 0, cGetPost1,;
      cGetPost1 := u ) }, oPanelScr, 100, 10,,,,,, .F.,, .T.,, .F.,, .F., .F.,,;
      .F., .F.,, "cGetPost1",,,, .F.,,, "Postal Address 1:", 2 )
    cCmbPost1:= aTypes[1]
    oCmbPost1 := TComboBox():New( 205, 150, { |u| if( PCount() > 0,;
      cCmbPost1 := u, cCmbPost1 ) }, aTypes, 50, 10, oPanelScr,,,,,, .T.,,,,,,,;
      ,, 'cCmbPost1', "Tipo:", 2 )

    cGetPost2 := Space( 256 )
    oGetPost2 := TGet():New( 225, 5, { | u | If( PCount() == 0, cGetPost2,;
      cGetPost2 := u ) }, oPanelScr, 100, 10,,,,,, .F.,, .T.,, .F.,, .F., .F.,,;
      .F., .F.,, "cGetPost2",,,, .F.,,, "Postal Address 2:", 2 )
    cCmbPost2:= aTypes[1]
    oCmbPost2 := TComboBox():New( 225, 150, { |u| if( PCount() > 0,;
      cCmbPost2 := u, cCmbPost2 ) }, aTypes, 50, 10, oPanelScr,,,,,, .T.,,,,,,,;
      ,, 'cCmbPost2', "Tipo:", 2 )

    cGetPost3 := Space( 256 )
    oGetPost3 := TGet():New( 245, 5, { | u | If( PCount() == 0, cGetPost3,;
      cGetPost3 := u ) }, oPanelScr, 100, 10,,,,,, .F.,, .T.,, .F.,, .F., .F.,,;
      .F., .F.,, "cGetPost3",,,, .F.,,, "Postal Address 3:", 2 )
    cCmbPost3:= aTypes[1]
    oCmbPost3 := TComboBox():New( 245, 150, { |u| if( PCount() > 0,;
      cCmbPost3 := u, cCmbPost3 ) }, aTypes, 50, 10, oPanelScr,,,,,, .T.,,,,,,,;
      ,, 'cCmbPost3', "Tipo:", 2 )

  ACTIVATE MSDIALOG oDlgInput CENTERED

Return

Static Function u_tmbl18()

  local aContacts := {}

  DEFINE MSDIALOG oDlgInput TITLE "Procurar Contato" FROM 180, 180 TO 800, 800 PIXEL

    oFont := TFont():New( 'Courier new',, -16, .T. )

    oPanelBtn := tPanel():New( 0, 0,, oDlgInput, oFont, .T.,,,, 0, 0)
    oPanelBtn:nHeight := 40
    oPanelBtn:Align := CONTROL_ALIGN_BOTTOM

    oTBtnOk := TButton():New( 5, 5, "&Ok", oPanelBtn,;
      { || aContacts := oMbl:FindContact( allTrim( cGetFilter ) ),;
      FindContMob( aContacts, oPanelCards ) }, 50, 10,,, .F., .T., .F.,, .F.,,,;
      .F. )
    oTBtnCanc := TButton():New( 5, 65, "&Cancel", oPanelBtn,;
      { || oDlgInput:End() }, 50, 10,,, .F., .T., .F.,, .F.,,, .F. )

    oPanelScr := tPanel():New( 0, 0,, oDlgInput, oFont, .T.,,,, 0, 50)
    oPanelScr:Align := CONTROL_ALIGN_TOP

    cGetFilter := Space( 256 )
    oGetFilter := TGet():New( 5, 5, { | u | If( PCount() == 0, cGetFilter,;
      cGetFilter := u ) }, oPanelScr, 100, 10,,,,,, .F.,, .T.,, .F.,, .F.,;
      .F.,, .F., .F.,, "cGetFilter",,,, .F.,,, "Filter:", 2 )

    cGetDummy := Space( 256 )
    oGetDummy := TGet():New( 25, 5, { | u | If( PCount() == 0, cGetDummy,;
      cGetDummy := u ) }, oPanelScr, 100, 10,,,,,, .F.,, .T.,, .F.,, .F.,;
      .F.,, .F., .F.,, "cGetDummy",,,, .F.,,, "Dummy:", 2 )

    oPanelCards := tPanel():New( 0, 0,, oDlgInput, oFont, .T.,,,, 0, 0)
    oPanelCards:Align := CONTROL_ALIGN_ALLCLIENT

  ACTIVATE MSDIALOG oDlgInput CENTERED

Return

Static Function u_tmbl19()
  oMbl:bOnPause := { || conout("***** Aplicativo entrou em background (bOnPause) *****") }
  MsgInfo("O bloco de código bOnPause foi ativado." + CRLF + ;
          "Uma mensagem no console será exibida quando a aplicação entrar em segundo plano.","")
Return

Static Function u_tmbl20()
  oMbl:bOnResume := { || conout("***** Aplicativo voltou para o primeiro plano (bOnResume) *****") }
  MsgInfo("O bloco de código bOnResume foi ativado." + CRLF + ;
          "Uma mensagem no console será exibida quando a aplicação voltar para o primeiro plano.","")
Return

Static Function PrintOrientation( nOrientation )
  cMsg:= ""
  Do Case
    Case nOrientation == ORIENTATION_PORTRAIT
      cMsg:= "Portrait Orientation"
    Case nOrientation == ORIENTATION_LANDSCAPE
      cMsg:= "Landscape Orientation"
    Case nOrientation == ORIENTATION_INVERTED_PORTRAIT
      cMsg:= "Inverted Portrait Orientation"
    Case nOrientation == ORIENTATION_INVERTED_LANDSCAPE
      cMsg:= "Inverted Landscape Orientation"
    OtherWise
      cMsg:= "Not supported!"
  EndCase
  MsgInfo(cMsg)
Return

Static Function AddContMob( aInfo )

  local aEmails := {}
  local aPhones := {}
  local aPostals := {}

  oTMobCont := TMobileContact():New()

  oTMobCont:cCompany := aInfo[1]
  oTMobCont:cJobTitle := aInfo[2]
  oTMobCont:cName := aInfo[3]
  oTMobCont:cNote := aInfo[4]

  if len( allTrim( aInfo[5] ) ) > 0
    aAdd( aEmails, TMobileContactEmail():New2( val( subStr( aInfo[6], 1, 1 ) ),;
      aInfo[5] ) )
  endIf
  if len( allTrim( aInfo[7] ) ) > 0
    aAdd( aEmails, TMobileContactEmail():New2( val( subStr( aInfo[8], 1, 1 ) ),;
      aInfo[7] ) )
  endIf
  if len( allTrim( aInfo[9] ) ) > 0
    aAdd( aEmails, TMobileContactEmail():New2( val( subStr( aInfo[10], 1,;
      1 ) ), aInfo[9] ) )
  endIf

  oTMobCont:aEmails := aEmails

  if len( allTrim( aInfo[11] ) ) > 0
    aAdd( aPhones, TMobileContactPhone():New2( val( subStr( aInfo[12], 1,;
      1 ) ), aInfo[11] ) )
  endIf
  if len( allTrim( aInfo[13] ) ) > 0
    aAdd( aPhones, TMobileContactPhone():New2( val( subStr( aInfo[14], 1,;
      1 ) ), aInfo[13] ) )
  endIf
  if len( allTrim( aInfo[15] ) ) > 0
    aAdd( aPhones, TMobileContactPhone():New2( val( subStr( aInfo[16], 1,;
      1 ) ), aInfo[15] ) )
  endIf

  oTMobCont:aPhones := aPhones

  if len( allTrim( aInfo[17] ) ) > 0
    aAdd( aPostals, TMobileContactPostal():New2( val( subStr( aInfo[18], 1,;
      1 ) ), aInfo[17] ) )
  endIf
  if len( allTrim( aInfo[19] ) ) > 0
    aAdd( aPostals, TMobileContactPostal():New2( val( subStr( aInfo[20], 1,;
      1 ) ), aInfo[19] ) )
  endIf
  if len( allTrim( aInfo[21] ) ) > 0
    aAdd( aPostals, TMobileContactPostal():New2( val( subStr( aInfo[22], 1,;
      1 ) ), aInfo[21] ) )
  endIf

  oTMobCont:aPostals := aPostals

  oMbl:AddContact( oTMobCont )

  cId := oTMobile:AddContact( oTMobCont )

  if len( allTrim( cId ) ) > 0
    alert( "Contato adicionado com ID de: " + allTrim( cId ) )
  else
    alert( "Contato não adicionado." )
  endIf

Return

Static Function FindContMob( aContacts, oPanel )
  Local nX

  varInfo( "Contatos", aContacts )

  If len( aContacts ) > 0
    oPanel:FreeChildren()
  EndIf

  nLinha := 1
  nCol := 1

  For nX := 1 to len( aContacts )

    oPanelCont := tPanel():New( 5 + ( ( nLinha - 1 ) * 80 ),;
      5 + ( ( nCol - 1 ) * 100 ),, oPanel,, .T.,,,, 90, 70)

    If len( aContacts[nX]:cName ) > 0
      oSay := TSay():New( 5, 5,, oPanelCont,,,,,, .T., CLR_BLACK, CLR_WHITE, 80, 10)
      oSay:SetText( aContacts[nX]:cName )
    EndIf

    If len( aContacts[nX]:aPhones ) > 0
      oSay := TSay():New( 25, 5,, oPanelCont,,,,,, .T., CLR_BLACK, CLR_WHITE, 80, 10)
      oSay:SetText( aContacts[nX]:aPhones[1]:cNumber )
    EndIf

    If len( aContacts[nX]:aEmails ) > 0
      oSay := TSay():New( 45, 5,, oPanelCont,,,,,, .T., CLR_BLACK, CLR_WHITE, 80, 10)
      oSay:SetText( aContacts[nX]:aEmails[1]:cAddress )
    EndIf

    nCol++
    If( nCol > 3 )
      nCol := 1
      nLinha++
    EndIf

  Next nX

Return


Static Function getDataforCalendar(dDate1,dDate2)
  DEFINE MSDIALOG oDlg TITLE "Pesquisa calendario" FROM 000, 000  TO 100, 280 PIXEL
  SET EPOCH TO 1950
  SET CENTURY ON
  oTSay1    := TSay():New( 5, 5,{||"Data inicial"},oDlg,,,.T.,.F.,.F.,.T.,0,,50,20,.F.,.T.,.F.,.F.,.F.,.F. )
  oTSay2    := TSay():New( 20, 5,{||"Data final"},oDlg,,,.T.,.F.,.F.,.T.,0,,50,20,.F.,.T.,.F.,.F.,.F.,.F. )
  oTGet1    := TGet():New( 05,60,{ | u | If( PCount() == 0, dDate1, dDate1 := u ) },oDlg,060,009,,,0,,,.F.,,.T.,,.F.,,.F.,.F.,,.F.,.F.,,,,,,.T. )
  oTGet2    := TGet():New( 20,60,{ | u | If( PCount() == 0, dDate2, dDate2 := u ) },oDlg,060,009,,,0,,,.F.,,.T.,,.F.,,.F.,.F.,,.F.,.F.,,,,,,.T. )
  oTGet1:lCalendario := .T.
  oTGet2:lCalendario := .T.
  oTButton1 := TButton():New( 40, 40, "OK",oDlg,{|| oDlg:End()},40,10,,,.F.,.T.,.F.,,,{|| .T.},,.F. )
  ACTIVATE DIALOG oDlg CENTERED
Return

Static Function FindCalendar()
  Local i
  dDate1 := Date()
  dDate2 := Date()+30
  getDataforCalendar(<at:var at:name="dDate1," />dDate2)
  aCal := oTMobile:findCalendarEvent(dDate1,dDate2)
  if (Len(aCal)>0)

    for i := 1 to Len(aCal)
      aRet := oTMobile:getCalendarEvent(aCal[i])

      cvartoshow := 'Calendar Id - ' + cvaltochar(aCal[i]) + CRLF
      cvartoshow += 'Title       - ' + aRet:ctitle + CRLF
      cvartoshow += 'Description - ' + aRet:cdescription + CRLF
      cvartoshow += 'Location    - ' + aRet:clocation + CRLF
      cvartoshow += 'DStart      - ' + cvaltochar(aRet:dStartDate) + CRLF
      cvartoshow += 'DEnd        - ' + cvaltochar(aRet:dEndDate) + CRLF
      cvartoshow += 'HStart      - ' + aRet:cStartTime + CRLF
      cvartoshow += 'HEnd        - ' + aRet:cEndTime + CRLF
      cvartoshow += 'allDay      - ' + cvaltochar(aRet:lAllDay) + CRLF
      msginfo(cvartoshow,"")
      oTMobile:viewCalendarEvent(aCal[i])
    next
  else
    msginfo("Error","")
  endif
Return


Static Function newCalendar(aCalend)
  DEFINE MSDIALOG oDlg TITLE "Novo evento" FROM 000, 000  TO 280, 280 PIXEL
  SET EPOCH TO 1950
  SET CENTURY ON

  cPict       := nil
  oTGet01     := TGet():New( 05,05,{ | u | If( PCount() == 0, aCalend:cTitle, aCalend:cTitle:= u ) },oDlg,060,009,cPict,,0,,,.F.,,.T.,,.F.,,.F.,.F.,,.F.,.F.,,,,,,.T.,,,"Titulo" )
  oTGet02     := TGet():New( 20,05,{ | u | If( PCount() == 0, aCalend:cDescription, aCalend:cDescription:= u ) },oDlg,060,009,cPict,,0,,,.F.,,.T.,,.F.,,.F.,.F.,,.F.,.F.,,,,,,.T.,,,"Descrição" )
  oTGet03     := TGet():New( 35,05,{ | u | If( PCount() == 0, aCalend:cLocation, aCalend:cLocation:= u ) },oDlg,060,009,cPict,,0,,,.F.,,.T.,,.F.,,.F.,.F.,,.F.,.F.,,,,,,.T.,,,"Localidade" )

  oTGet04     := TGet():New( 50,05,{ | u | If( PCount() == 0, aCalend:dStartDate, aCalend:dStartDate := u ) },oDlg,060,009,,,0,,,.F.,,.T.,,.F.,,.F.,.F.,,.F.,.F.,,,,,,.T.,,,"Data inicial" )
  oTGet05     := TGet():New( 65,05,{ | u | If( PCount() == 0, aCalend:cStartTime, aCalend:cStartTime := u ) },oDlg,060,009,"@E 99:99:99",,0,,,.F.,,.T.,,.F.,,.F.,.F.,,.F.,.F.,,,,,,.T.,,,"Hora inicial" )

  oTGet06     := TGet():New( 80,05,{ | u | If( PCount() == 0, aCalend:dEndDate, aCalend:dEndDate := u ) },oDlg,060,009,,,0,,,.F.,,.T.,,.F.,,.F.,.F.,,.F.,.F.,,,,,,.T.,,,"Data final" )
  oTGet07     := TGet():New( 95,05,{ | u | If( PCount() == 0, aCalend:cEndTime, aCalend:cEndTime := u ) },oDlg,060,009,"@E 99:99:99",,0,,,.F.,,.T.,,.F.,,.F.,.F.,,.F.,.F.,,,,,,.T.,,,"Hora final" )

  oTCheck     := TCheckBox():New( 110,05, "Dia Inteiro", { | u | If( PCount() == 0, aCalend:lAllDay, aCalend:lAllDay := u ) },oDlg,60,9,,,,,,,,.T.,,, )

  oTButton1 := TButton():New( 125, 40, "OK",oDlg,{|| oDlg:End()},40,10,,,.F.,.T.,.F.,,,{|| .T.},,.F. )

  ACTIVATE DIALOG oDlg CENTERED
Return

Static Function AddCalendar()

  aCalend := TCalendarEvent():New("titulo","descricao","rua teste",Date()+15,"06:00:00",Date()+15,"07:00:00",.T.)

  newCalendar(@aCalend)

  cvartoshow := 'Title       - ' + aCalend:ctitle + CRLF
  cvartoshow += 'Description - ' + aCalend:cdescription + CRLF
  cvartoshow += 'Location    - ' + aCalend:clocation + CRLF
  cvartoshow += 'DStart      - ' + cvaltochar(aCalend:dStartDate) + CRLF
  cvartoshow += 'DEnd        - ' + cvaltochar(aCalend:dEndDate) + CRLF
  cvartoshow += 'HStart      - ' + aCalend:cStartTime + CRLF
  cvartoshow += 'HEnd        - ' + aCalend:cEndTime + CRLF
  cvartoshow += 'allDay      - ' + cvaltochar(aCalend:lAllDay) + CRLF
  msginfo(cvartoshow,"")

  sCalId := oTMobile:addCalendarEvent(aCalend)
  MsgInfo("CalendarId: " + sCalId,"")

Return


Abrangência

TOTVS | FatClient Embarcado versão Beta para Android.

  • Sem rótulos