Search in sources :

Example 1 with EnrollmentPresenter

use of org.flyve.mdm.agent.core.enrollment.EnrollmentPresenter 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);
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) IOException(java.io.IOException) EnrollmentPresenter(org.flyve.mdm.agent.core.enrollment.EnrollmentPresenter) KeyEvent(android.view.KeyEvent) MultipleEditText(org.flyve.mdm.agent.utils.MultipleEditText) TextView(android.widget.TextView) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout)

Aggregations

KeyEvent (android.view.KeyEvent)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 IOException (java.io.IOException)1 EnrollmentPresenter (org.flyve.mdm.agent.core.enrollment.EnrollmentPresenter)1 MultipleEditText (org.flyve.mdm.agent.utils.MultipleEditText)1