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();
}
});
}
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));
}
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();
}
}
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());
}
}
}
Aggregations