Sub Process_Globals
Private secretKey As String = "JBSWY3DPEHPK3PXP"
Private totp As GoogleAuthenticator
Dim timer1Service As Timer
End Sub
Sub Globals
Private EditText_secret As EditText
Private EditText_totp As EditText
Private EditText_countdown As EditText
End Sub
Sub generateTotp(secret As String)
Dim key As String = ""
Try
key = totp.getTotpPassword(secret)
EditText_totp.Text = key
Catch
EditText_totp.Text = "Invalid Secret"
Log(LastException)
End Try
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
EditText_secret.Text = secretKey
timer1Service.Initialize("timer1Service", 1000)
timer1Service.Enabled = True
generateTotp(secretKey)
End Sub
Sub timer1Service_tick
Dim timewindow As Long = DateTime.Now / 1000.0
Dim countDown As Int = 30 - (timewindow Mod 30)
If timewindow Mod 30 = 0 Then
generateTotp(secretKey)
End If
EditText_countdown.Text = countDown
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub EditText_secret_TextChanged (Old As String, New As String)
secretKey = New
generateTotp(secretKey)
End Sub