Search in sources :

Example 1 with PhoneNumber

use of com.cmput301w18t05.taskzilla.PhoneNumber in project Taskzilla by CMPUT301W18T05.

the class EditProfileActivity method onCreate.

/**
 * this runs when activity created, setting the default fields for the user
 *
 * @param savedInstanceState
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle("Edit Profile");
    setContentView(R.layout.activity_edit_profile);
    AppColors appColors = AppColors.getInstance();
    ActionBar actionBar = getSupportActionBar();
    actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(appColors.getActionBarColor())));
    actionBar.setTitle(Html.fromHtml("<font color='" + appColors.getActionBarTextColor() + "'>Taskzilla</font>"));
    NameText = findViewById(R.id.NameField);
    EmailText = findViewById(R.id.EmailField);
    PhoneText = findViewById(R.id.Phone);
    profilePicture = findViewById(R.id.ProfilePictureView);
    String userName = getIntent().getStringExtra("Name");
    String userEmail = getIntent().getStringExtra("Email");
    String userPhone = getIntent().getStringExtra("Phone");
    String userPicture = getIntent().getStringExtra("Photo");
    user.setName(userName);
    user.setEmail(new EmailAddress(userEmail));
    user.setPhone(new PhoneNumber(userPhone));
    NameText.setText(user.getName());
    EmailText.setText(user.getEmail().toString());
    PhoneText.setText(user.getPhone().toString());
    try {
        user.setPhoto(new Photo(userPicture));
        profilePicture.setImageBitmap(user.getPhoto().StringToBitmap());
    } catch (Exception e) {
        Photo defaultPhoto = new Photo("");
        profilePicture.setImageBitmap(defaultPhoto.StringToBitmap());
    }
    profilePicture.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            profilePictureClicked();
        }
    });
}
Also used : AppColors(com.cmput301w18t05.taskzilla.AppColors) ColorDrawable(android.graphics.drawable.ColorDrawable) PhoneNumber(com.cmput301w18t05.taskzilla.PhoneNumber) Photo(com.cmput301w18t05.taskzilla.Photo) ImageView(android.widget.ImageView) View(android.view.View) ActionBar(android.support.v7.app.ActionBar) EmailAddress(com.cmput301w18t05.taskzilla.EmailAddress)

Example 2 with PhoneNumber

use of com.cmput301w18t05.taskzilla.PhoneNumber in project Taskzilla by CMPUT301W18T05.

the class SignUpActivity method convertToUserObject.

/**
 * Takes info that was already validated and converts it to the proper type.
 * It is then used as parameters when creating a new user.
 *
 * @see User
 */
public void convertToUserObject() {
    String name = this.name.getText().toString();
    String username = this.username.getText().toString();
    String password = this.password.getText().toString();
    String email = this.email.getText().toString();
    String phone = this.phone.getText().toString();
    newUser = new User();
    newUser.setName(name);
    newUser.setEmail(new EmailAddress(email));
    newUser.setUsername(username);
    newUser.setPassword(password);
    newUser.setPhone(new PhoneNumber(phone));
}
Also used : User(com.cmput301w18t05.taskzilla.User) PhoneNumber(com.cmput301w18t05.taskzilla.PhoneNumber) EmailAddress(com.cmput301w18t05.taskzilla.EmailAddress)

Example 3 with PhoneNumber

use of com.cmput301w18t05.taskzilla.PhoneNumber in project Taskzilla by CMPUT301W18T05.

the class EditProfileActivity method ProfileSaveButton.

public void ProfileSaveButton(View view) {
    if (validateInformation()) {
        user.setName(NameText.getText().toString());
        user.setEmail(new EmailAddress(EmailText.getText().toString()));
        user.setPhone(new PhoneNumber(PhoneText.getText().toString()));
        Intent returnIntent = new Intent();
        returnIntent.putExtra("Name", user.getName());
        returnIntent.putExtra("Email", user.getEmail().toString());
        returnIntent.putExtra("Phone", user.getPhone().toString());
        returnIntent.putExtra("Photo", user.getPhoto().toString());
        setResult(RESULT_OK, returnIntent);
        finish();
    }
}
Also used : PhoneNumber(com.cmput301w18t05.taskzilla.PhoneNumber) Intent(android.content.Intent) EmailAddress(com.cmput301w18t05.taskzilla.EmailAddress)

Example 4 with PhoneNumber

use of com.cmput301w18t05.taskzilla.PhoneNumber in project Taskzilla by CMPUT301W18T05.

the class ProfileFragment method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.i("does this work", String.valueOf(requestCode));
    if (requestCode == 1) {
        // code to add to ESC
        if (resultCode == RESULT_OK) {
            String newName = data.getStringExtra("Name");
            String newEmail = data.getStringExtra("Email");
            String newPhone = data.getStringExtra("Phone");
            String newPhoto = data.getStringExtra("Photo");
            user.setName(newName);
            user.setEmail(new EmailAddress(newEmail));
            user.setPhone(new PhoneNumber(newPhone));
            user.setPhoto(new Photo(newPhoto));
            AddUserRequest request = new AddUserRequest(user);
            RequestManager.getInstance().invokeRequest(getContext(), request);
            nameField.setText(newName);
            emailField.setText(newEmail);
            phoneField.setText(newPhone);
            profilePicture.setImageBitmap(user.getPhoto().StringToBitmap());
        }
    }
}
Also used : PhoneNumber(com.cmput301w18t05.taskzilla.PhoneNumber) Photo(com.cmput301w18t05.taskzilla.Photo) EmailAddress(com.cmput301w18t05.taskzilla.EmailAddress) AddUserRequest(com.cmput301w18t05.taskzilla.request.command.AddUserRequest)

Aggregations

EmailAddress (com.cmput301w18t05.taskzilla.EmailAddress)4 PhoneNumber (com.cmput301w18t05.taskzilla.PhoneNumber)4 Photo (com.cmput301w18t05.taskzilla.Photo)2 Intent (android.content.Intent)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 ActionBar (android.support.v7.app.ActionBar)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 AppColors (com.cmput301w18t05.taskzilla.AppColors)1 User (com.cmput301w18t05.taskzilla.User)1 AddUserRequest (com.cmput301w18t05.taskzilla.request.command.AddUserRequest)1