use of com.cmput301w18t05.taskzilla.AppColors in project Taskzilla by CMPUT301W18T05.
the class ZoomImageActivity method onCreate.
/**
* retrieve the photo from the previous activity and set
* the imageview
*
* @param savedInstanceState
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zoom_image);
String stringOfImage = getIntent().getStringExtra("Photo");
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>"));
photo = new Photo(stringOfImage);
ZoomedImageView = findViewById(R.id.ZoomedImage);
ZoomedImageView.setImageBitmap(photo.StringToBitmap());
dector = new ScaleGestureDetector(this, new ScaleListener());
}
use of com.cmput301w18t05.taskzilla.AppColors in project Taskzilla by CMPUT301W18T05.
the class EditTaskActivity method onCreate.
/**
* Activity uses the activity_edit_task.xml layout
* Initialize a task with edited fields
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
task = new Task();
ctx = getApplicationContext();
super.onCreate(savedInstanceState);
setTitle("Edit Task");
setContentView(R.layout.activity_edit_task);
Double taskLat = Double.parseDouble(getIntent().getStringExtra("Lat"));
Double taskLon = Double.parseDouble(getIntent().getStringExtra("Lon"));
taskLocation = new LatLng(taskLat, taskLon);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.dragdropMap2);
mapFragment.getMapAsync(this);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
currentLocationButton = findViewById(R.id.currentLocationButton);
autocompleteFragment = (PlaceAutocompleteFragment) getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
/**
* When the user searchs a location
* set the hint and the taskLocation
* @param place
*/
@Override
public void onPlaceSelected(Place place) {
// TODO: Get info about the selected place.
autocompleteFragment.setHint(place.getName());
taskLocation = place.getLatLng();
}
@Override
public void onError(Status status) {
// TODO: Handle the error.
taskLocation = null;
Log.i("err", "An error occurred: " + status);
}
});
autocompleteFragment.setHint(getIntent().getStringExtra("Lat") + ", " + getIntent().getStringExtra("Lon"));
autocompleteFragment.setText(getIntent().getStringExtra("Lat") + ", " + getIntent().getStringExtra("Lon"));
getLocation();
autocompleteFragment.setBoundsBias(new LatLngBounds(new LatLng(lat - 0.25, lon - 0.25), new LatLng(lat + 0.25, lon + 0.25)));
currentLocationButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
setCurrentLocation();
}
});
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>"));
EditText TaskNameText = findViewById(R.id.TaskName);
EditText DescriptionText = findViewById(R.id.Description);
String taskName = getIntent().getStringExtra("task Name");
String taskDescription = getIntent().getStringExtra("Description");
// Dummy
task.setName(taskName);
// Dummy
task.setDescription(taskDescription);
TaskNameText.setText(task.getName());
DescriptionText.setText(task.getDescription());
photos = new ArrayList<>();
ArrayList<String> photosString = getIntent().getStringArrayListExtra("photos");
for (int i = 0; i < photosString.size(); i++) {
Log.i("test", photosString.get(i));
photos.add(new Photo(photosString.get(i)));
}
recyclerPhotosView = findViewById(R.id.listOfPhotos);
layoutManager = new LinearLayoutManager(ctx, LinearLayoutManager.HORIZONTAL, false);
recyclerPhotosView.setLayoutManager(layoutManager);
recyclerPhotosViewAdapter = new RecyclerViewAdapter(ctx, photos, new CustomOnItemClick() {
@Override
public void onColumnClicked(final int position) {
// taken from https://stackoverflow.com/questions/2115758/how-do-i-display-an-alert-dialog-on-android
// 2018-03-16
AlertDialog.Builder alert = new AlertDialog.Builder(EditTaskActivity.this);
alert.setTitle("Delete Photo");
alert.setMessage("Are you sure you want to delete this photo?");
// DELETE CODE
alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
photos.remove(position);
dialogInterface.dismiss();
recyclerPhotosViewAdapter.notifyDataSetChanged();
}
});
// DELETE CANCEL CODE
alert.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
alert.show();
}
});
recyclerPhotosView.setAdapter(recyclerPhotosViewAdapter);
}
use of com.cmput301w18t05.taskzilla.AppColors 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.AppColors in project Taskzilla by CMPUT301W18T05.
the class NewReviewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_review);
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>"));
findViews();
RatingBar ratingBar = (RatingBar) findViewById(R.id.ratingBar);
LayerDrawable stars = (LayerDrawable) ratingBar.getProgressDrawable();
stars.getDrawable(2).setColorFilter(Color.parseColor(appColors.getActionBarTextColor()), PorterDuff.Mode.SRC_ATOP);
setValues();
}
use of com.cmput301w18t05.taskzilla.AppColors in project Taskzilla by CMPUT301W18T05.
the class WelcomeActivity method loadAppColors.
/**
* load the AppColors singleton from storage
*/
private void loadAppColors() {
try {
FileInputStream fis = openFileInput("COLORS.TXT");
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
PersonalColors c = new Gson().fromJson(br, PersonalColors.class);
AppColors.getInstance().setColors(c);
} catch (FileNotFoundException e) {
System.out.println("File not found!");
}
}
Aggregations