diff --git a/Listify/app/build.gradle b/Listify/app/build.gradle
index a14ee50..7038265 100644
--- a/Listify/app/build.gradle
+++ b/Listify/app/build.gradle
@@ -53,4 +53,6 @@ dependencies {
implementation 'com.squareup.okhttp3:okhttp:4.8.1'
implementation 'com.crystal:crystalrangeseekbar:1.1.3'
implementation 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.1'
+ implementation "androidx.cardview:cardview:1.0.0"
+
}
\ No newline at end of file
diff --git a/Listify/app/src/main/AndroidManifest.xml b/Listify/app/src/main/AndroidManifest.xml
index 7389dd5..cf117a8 100644
--- a/Listify/app/src/main/AndroidManifest.xml
+++ b/Listify/app/src/main/AndroidManifest.xml
@@ -3,6 +3,9 @@
package="com.example.listify">
+
+
+
+
+
+
+
+
+
{
+ Intent takePicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
+ File imageFileLocation = getOutputImageFile();
+ Log.i("Profile Picture", "New image file at " + imageFileLocation.getAbsolutePath());
+ newImageFileLocation = imageFileLocation;
+ Uri imageUri = FileProvider.getUriForFile(
+ MainActivity.this,
+ BuildConfig.APPLICATION_ID + ".provider",
+ imageFileLocation);
+ takePicture.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
+ startActivityForResult(takePicture, CAMERA_CAPTURE);
+ });
+ builder.setNeutralButton("Select picture", (dialog, which) -> {
+ Intent pickPhoto = new Intent(Intent.ACTION_PICK,
+ MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
+ startActivityForResult(pickPhoto, IMAGE_SELECT);
+ });
+ builder.setNegativeButton("Cancel", (dialog, which) -> {
+ });
+ AlertDialog dialog = builder.create();
+ dialog.show();
+ }
+ });
+
mAppBarConfiguration = new AppBarConfiguration.Builder(
R.id.nav_home, R.id.nav_profile, R.id.nav_logout)
.setDrawerLayout(drawer)
@@ -176,6 +223,55 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
});
}
+ protected void onActivityResult (int requestCode,
+ int resultCode,
+ Intent data) {
+ Uri selectedImage = null;
+ switch (requestCode){
+ case CAMERA_CAPTURE:
+ Log.i("Profile Picture", "Pulling image file at " + this.newImageFileLocation.getAbsolutePath());
+ selectedImage = Uri.fromFile(this.newImageFileLocation);
+ break;
+ case IMAGE_SELECT:
+ if ((data == null) || (data.getData() == null)) {
+ return;
+ }
+ selectedImage = data.getData();
+ break;
+ }
+
+ MainActivity.super.onActivityResult(requestCode, resultCode, data);
+ NavigationView navigationView = findViewById(R.id.nav_view);
+ ImageView profilePicture = navigationView.getHeaderView(0).findViewById(R.id.imageViewProfilePicture);
+ profilePicture.setImageURI(selectedImage);
+ }
+
+ //getOutputImageFile from https://developer.android.com/guide/topics/media/camera
+ private static File getOutputImageFile(){
+ // To be safe, you should check that the SDCard is mounted
+ // using Environment.getExternalStorageState() before doing this.
+
+ File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
+ Environment.DIRECTORY_PICTURES), "MyCameraApp");
+ // This location works best if you want the created images to be shared
+ // between applications and persist after your app has been uninstalled.
+
+ // Create the storage directory if it does not exist
+ if (! mediaStorageDir.exists()){
+ if (! mediaStorageDir.mkdirs()){
+ Log.d("File creation", "failed to create directory");
+ return null;
+ }
+ }
+
+ // Create a media file name
+ String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
+ File mediaFile = new File(mediaStorageDir.getPath() + File.separator +
+ "IMG_"+ timeStamp + ".jpg");
+ Log.i("File creation", mediaFile.toString());
+ return mediaFile;
+ }
+
@Override
public boolean onSupportNavigateUp() {
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
@@ -214,5 +310,8 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
Toast.makeText(this, "An error occurred", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
+
}
+
+
}
\ No newline at end of file
diff --git a/Listify/app/src/main/res/layout/nav_header_main.xml b/Listify/app/src/main/res/layout/nav_header_main.xml
index 3f4a0fa..4014ebb 100644
--- a/Listify/app/src/main/res/layout/nav_header_main.xml
+++ b/Listify/app/src/main/res/layout/nav_header_main.xml
@@ -1,8 +1,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/Listify/app/src/main/res/raw/ic_launcher_round.png b/Listify/app/src/main/res/raw/ic_launcher_round.png
new file mode 100644
index 0000000..e96783c
Binary files /dev/null and b/Listify/app/src/main/res/raw/ic_launcher_round.png differ
diff --git a/Listify/app/src/main/res/xml/file_paths.xml b/Listify/app/src/main/res/xml/file_paths.xml
new file mode 100644
index 0000000..3197349
--- /dev/null
+++ b/Listify/app/src/main/res/xml/file_paths.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file