protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); Functions.CurrentContext = this; SetContentView(Resource.Layout.ScanCode); _txtViewGrade = FindViewById <TextView> (Resource.Id.txtViewGrade); _editTextSubject = FindViewById <EditText> (Resource.Id.editTextSubject); _seekBarGrade = FindViewById <SeekBar> (Resource.Id.seekBarGrade); _seekBarGrade.ProgressChanged += seekBar_ProgressChanged; _editTextSubject.Text = this.Intent.GetStringExtra("subject"); if (bundle != null) { _qrCode = bundle.GetString("qrCode"); _scannedCode = !string.IsNullOrEmpty(_qrCode); _codeAlreadyUsed = bundle.GetBoolean("codeAlreadyUsed"); } if (_codeAlreadyUsed) { ShowCodeAlreadyScannedDialog(); } if (!IsPackageInstalled("la.droid.qr", this)) { var dialogFragment = new DialogFragment(); dialogFragment.InitializeYesNo("The external application \"QR Droid\" is required but not installed.\r\nWould you like to do that now?", "Error", delegate { GetQRDroid(); }, delegate { Finish(); }); dialogFragment.Show(); return; } if (!_scannedCode) { Intent qrDroid = new Intent("la.droid.qr.scan"); qrDroid.PutExtra("la.droid.qr.complete", true); StartActivityForResult(qrDroid, 1); } if (bundle != null) { _seekBarGrade.Progress = bundle.GetInt("grade") - 2; _editTextSubject.Text = bundle.GetString("subject"); _qrCode = bundle.GetString("qrCode"); } Button btnFinish = FindViewById <Button> (Resource.Id.btnFinish); btnFinish.Click += Finish; Button btnNext = FindViewById <Button> (Resource.Id.btnNext); btnNext.Click += Next; }
public static bool ShowMessage(string title, string message) { Functions.CurrentContext.RunOnUiThread(() => { var dialogFragment = new DialogFragment(); dialogFragment.InitializeOk(message, title, delegate { }, true); dialogFragment.Show(); }); return(true); }
private void DoRegister(object sender, EventArgs e) { if (Functions.IsOffline()) { ResponseManager.ShowMessage("Error", "No internet connection!"); return; } if (_txtPassword.Text != _txtPassword2.Text) { ResponseManager.ShowMessage("Error", "Passwords do not match!"); return; } ResponseManager.ShowLoading("Creating account..."); var data = new NameValueCollection(); data.Add("register", string.Empty); data.Add("email", _txtEmail.Text); data.Add("password", Functions.GetSha256(_txtPassword.Text)); data.Add("firstname", _txtFirstName.Text); data.Add("lastname", _txtLastName.Text); data.Add("class", _txtClass.Text); string reply = WebFunctions.Request(data); ResponseManager.DismissLoading(); if (reply != "Account created!") { ResponseManager.ShowMessage("Error", reply); WebFunctions.ClearCookies(); return; } RunOnUiThread(delegate { var dialogFragment = new DialogFragment(); dialogFragment.InitializeOk(reply, "Success", delegate { Intent resultData = new Intent(); resultData.PutExtra("email", _txtEmail.Text); resultData.PutExtra("password", _txtPassword.Text); SetResult(Result.Ok, resultData); Finish(); }); dialogFragment.Show(); }); }
private void ShowCodeAlreadyScannedDialog() { ScannedCode code = ScannedCodesCollection.GetFullCodeFromCode(_qrCode); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(string.Format("Code has already been graded at {0} with {1}!", code.Subject, code.Grade)); stringBuilder.Append("Do you want to delete the old grade and save a new one?"); var dialogFragment = new DialogFragment(); dialogFragment.InitializeYesNo(stringBuilder.ToString(), "Question", delegate { ScannedCodesCollection.DeleteCode(code); _codeAlreadyUsed = false; }, delegate { Finish(); }); dialogFragment.Show(); }