use of org.flyve.mdm.agent.data.localstorage.UserData in project android-mdm-agent by flyve-mdm.
the class EnrollmentActivity method validateForm.
/**
* Send information to validateForm
*/
private void validateForm() {
// waiting for cert x509
if (pbx509.getVisibility() == View.VISIBLE) {
sendEnrollment = true;
pd = ProgressDialog.show(EnrollmentActivity.this, "", getResources().getString(R.string.creating_certified_x509));
return;
}
pd = ProgressDialog.show(EnrollmentActivity.this, "", getResources().getString(R.string.enrollment_in_process));
// Get all emails
ArrayList<UserData.EmailsData> arrEmails = new ArrayList<>();
List<EditText> emailEdit = editEmail.getEditList();
List<Spinner> emailTypeEdit = editEmail.getSpinnList();
for (int i = 0; i < emailEdit.size(); i++) {
EditText editText = emailEdit.get(i);
Spinner spinner = emailTypeEdit.get(i);
if (!editText.getText().toString().equals("")) {
UserData.EmailsData emails = new UserData(EnrollmentActivity.this).new EmailsData();
emails.setEmail(editText.getText().toString());
emails.setType(spinner.getSelectedItem().toString());
arrEmails.add(emails);
}
}
String mobilePhone = "";
String phone = "";
String phone2 = "";
// Mobile Phone
if (!editPhone.getEditList().isEmpty()) {
String mMobilePhone = editPhone.getEditList().get(0).getText().toString();
if (!mMobilePhone.equals("")) {
mobilePhone = mMobilePhone;
}
}
// Phone
if (editPhone.getEditList().size() > 1) {
String mPhone = editPhone.getEditList().get(1).getText().toString();
if (!phone.equals("")) {
phone = mPhone;
}
}
// Phone 2
if (editPhone.getEditList().size() > 2) {
String mPhone2 = editPhone.getEditList().get(2).getText().toString();
if (!mPhone2.equals("")) {
phone2 = mPhone2;
}
}
// Enroll the user
presenter.enroll(EnrollmentActivity.this, arrEmails, editName.getText().toString(), editLastName.getText().toString(), phone, phone2, mobilePhone, inventory, strPicture, spinnerLanguage.getSelectedItem().toString(), editAdministrative.getText().toString());
}
use of org.flyve.mdm.agent.data.localstorage.UserData in project android-mdm-agent by flyve-mdm.
the class PreviewUserActivity method loadData.
/**
* Loads the information of the User
*/
private void loadData() {
try {
UserData user = new UserData(PreviewUserActivity.this);
if (user == null) {
return;
}
ImageView imgPhoto = findViewById(R.id.imgPhoto);
if (user.getPicture() != null && !user.getPicture().equals("")) {
imgPhoto.setImageBitmap(Helpers.stringToBitmap(user.getPicture()));
}
LinearLayout lnEmail = findViewById(R.id.lnEmails);
lnEmail.removeAllViews();
for (int i = 0; i < user.getEmails().size(); i++) {
TextView txtEmail = new TextView(PreviewUserActivity.this);
txtEmail.setText(user.getEmails().get(i).getEmail());
lnEmail.addView(txtEmail);
}
TextView txtFirstName = findViewById(R.id.txtFirstName);
txtFirstName.setText(user.getFirstName() + " " + user.getLastName());
TextView txtPhone = findViewById(R.id.txtPhone);
if (user.getPhone() != null && !user.getPhone().equals("")) {
txtPhone.setText(user.getPhone());
txtPhone.setVisibility(View.VISIBLE);
} else {
txtPhone.setVisibility(View.GONE);
}
TextView txtPhoneMobile = findViewById(R.id.txtPhoneMobile);
if (user.getMobilePhone() != null && !user.getMobilePhone().equals("")) {
txtPhoneMobile.setText(user.getMobilePhone());
txtPhoneMobile.setVisibility(View.VISIBLE);
} else {
txtPhoneMobile.setVisibility(View.GONE);
}
TextView txtPhone2 = findViewById(R.id.txtPhone2);
if (user.getPhone2() != null && !user.getPhone2().equals("")) {
txtPhone2.setText(user.getPhone2());
txtPhone2.setVisibility(View.VISIBLE);
} else {
txtPhone2.setVisibility(View.GONE);
}
TextView txtLanguage = findViewById(R.id.txtLanguage);
txtLanguage.setText(user.getLanguage());
TextView txtAdministrativeNumber = findViewById(R.id.txtAdministrativeNumber);
txtAdministrativeNumber.setText(user.getAdministrativeNumber());
} catch (Exception ex) {
FlyveLog.e(this.getClass().getName() + ", loadData", ex.getMessage());
}
}
Aggregations