use of org.flyve.mdm.agent.utils.MultipleEditText in project android-mdm-agent by flyve-mdm.
the class EnrollmentActivity method onCreate.
/**
* Called when the activity is starting
* It displays the UI to enroll the user information
* @param savedInstanceState if the activity is re-initialized, it contains the data it most recently supplied
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_form);
android.support.v7.widget.Toolbar toolbar = findViewById(R.id.toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
try {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} catch (Exception ex) {
FlyveLog.e(this.getClass().getName() + ", onCreate", ex.getMessage());
}
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
}
TextView txtVersion = findViewById(R.id.txtVersion);
txtVersion.setText(MDMAgent.getCompleteVersion());
presenter = new EnrollmentPresenter(EnrollmentActivity.this);
pbx509 = findViewById(R.id.progressBarX509);
imgPhoto = findViewById(R.id.imgPhoto);
ImageView btnCamera = findViewById(R.id.btnCamera);
btnCamera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
presenter.selectPhoto(EnrollmentActivity.this, REQUEST_CAMERA, SELECT_FILE);
}
});
txtMessage = findViewById(R.id.txtMessage);
editName = findViewById(R.id.editName);
editLastName = findViewById(R.id.editLastName);
// Multiples Emails
LinearLayout lnEmails = findViewById(R.id.lnEmails);
editEmail = new MultipleEditText(this, lnEmails, getResources().getString(email));
editEmail.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
editEmail.setSpinnerArray(R.array.email_array);
lnEmails.addView(editEmail.createEditText());
// 3 Phones
LinearLayout lnPhones = findViewById(R.id.lnPhones);
editPhone = new MultipleEditText(this, lnPhones, getResources().getString(R.string.phone));
editPhone.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_CLASS_PHONE);
editPhone.setLimit(3);
editPhone.setSpinnerArray(R.array.phone_array);
lnPhones.addView(editPhone.createEditText());
// Language
spinnerLanguage = findViewById(R.id.spinnerLanguage);
// Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.language_array, android.R.layout.simple_spinner_item);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
spinnerLanguage.setAdapter(adapter);
editAdministrative = findViewById(R.id.editAdministrative);
editAdministrative.setImeOptions(EditorInfo.IME_ACTION_DONE);
editAdministrative.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
validateForm();
return true;
}
return false;
}
});
ImageView btnRegister = findViewById(R.id.btnSave);
btnRegister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
validateForm();
}
});
// start creating a certificated
pbx509.setVisibility(View.VISIBLE);
presenter.createX509certification(EnrollmentActivity.this);
}
use of org.flyve.mdm.agent.utils.MultipleEditText in project android-mdm-agent by flyve-mdm.
the class EditUserActivity method loadSuccess.
@Override
public void loadSuccess(UserSchema userSchema) {
// photo on the header
if (!userSchema.getPicture().equals("")) {
try {
imgPhoto.setImageBitmap(Helpers.stringToBitmap(userSchema.getPicture()));
} catch (Exception ex) {
FlyveLog.e(this.getClass().getName() + ", loadSuccess", ex.getMessage());
}
}
// first name
editName.setText(userSchema.getFirstName());
// last name
editLastName.setText(userSchema.getLastName());
// Multiples Emails
LinearLayout lnEmails = findViewById(R.id.lnEmails);
editEmail = new MultipleEditText(this, lnEmails, getResources().getString(R.string.email));
editEmail.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
editEmail.setSpinnerArray(R.array.email_array);
// load store values
List<String> arrEmails = new ArrayList<>();
List<String> arrEmailTypes = new ArrayList<>();
for (int i = 0; i < userSchema.getEmails().size(); i++) {
arrEmails.add(userSchema.getEmails().get(i).getEmail());
arrEmailTypes.add(userSchema.getEmails().get(i).getType());
}
editEmail.setValue(arrEmails, arrEmailTypes);
lnEmails.addView(editEmail.createEditText());
// load information phones
LinearLayout lnPhones = findViewById(R.id.lnPhones);
editPhone = new MultipleEditText(this, lnPhones, getResources().getString(R.string.phone));
editPhone.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_CLASS_PHONE);
editPhone.setLimit(3);
editPhone.setSpinnerArray(R.array.phone_array);
// load store values
List<String> arrPhones = new ArrayList<>();
List<String> arrPhoneTypes = new ArrayList<>();
if (!userSchema.getMobilePhone().equals("")) {
arrPhones.add(userSchema.getMobilePhone());
arrPhoneTypes.add("");
}
if (!userSchema.getPhone().equals("")) {
arrPhones.add(userSchema.getPhone());
arrPhoneTypes.add("");
}
if (!userSchema.getPhone2().equals("")) {
arrPhones.add(userSchema.getPhone2());
arrPhoneTypes.add("");
}
editPhone.setValue(arrPhones, arrPhoneTypes);
lnPhones.addView(editPhone.createEditText());
// Language
// Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.language_array, android.R.layout.simple_spinner_item);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
spinnerLanguage.setAdapter(adapter);
// select language stored on cache
int spinnerPosition = adapter.getPosition(userSchema.getLanguage());
spinnerLanguage.setSelection(spinnerPosition);
// Administrative Number
editAdministrative.setText(userSchema.getAdministrativeNumber());
}
Aggregations