diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/java/com/harpreet/notes_app/HomeActivity.java b/app/src/main/java/com/harpreet/notes_app/HomeActivity.java index 9ddd477..1fceb63 100644 --- a/app/src/main/java/com/harpreet/notes_app/HomeActivity.java +++ b/app/src/main/java/com/harpreet/notes_app/HomeActivity.java @@ -39,7 +39,10 @@ public class HomeActivity extends AppCompatActivity { private FloatingActionButton fab; private RecyclerView recyclerView; - private FirebaseRecyclerAdapter adapter; + private FirebaseRecyclerAdapter adapter; //These lines declare various variables used within the HomeActivity class, including references to UI + // elements (toolbar, floating action button, and recycler view), an adapter for + // the recycler view, instances of Firebase-related classes (FirebaseAuth and DatabaseReference), + // and other variables to store data. private FirebaseAuth mauth; private DatabaseReference mDatabase; @@ -80,7 +83,7 @@ public void onClick(View v) { } - private void addData() + private void addData() //This method is responsible for displaying an AlertDialog that allows the user to input data (name and description) for a new note. { AlertDialog.Builder mydialog = new AlertDialog.Builder(this); LayoutInflater inflater = LayoutInflater.from(this); @@ -134,7 +137,7 @@ public void onClick(View v) { @Override - protected void onStart() { + protected void onStart() { //It sets up the FirebaseRecyclerAdapter for displaying the notes in the RecyclerView and starts listening for changes in the data. super.onStart(); Query query = FirebaseDatabase.getInstance().getReference().child("All data").child(mauth.getUid()); @@ -181,13 +184,15 @@ public void onClick(View v) { } @Override - protected void onStop() { + protected void onStop() { //This method is called when the activity is stopped. It stops the FirebaseRecyclerAdapter from listening to changes in the data. super.onStop(); adapter.stopListening(); } - public static class Myviewholder extends RecyclerView.ViewHolder{ + public static class Myviewholder extends RecyclerView.ViewHolder{ //This is a static inner class that defines a + // custom RecyclerView.ViewHolder for the notes. It holds references + // to the UI elements within each item of the RecyclerView. View mView; @@ -213,7 +218,9 @@ public void setDate(String date) } - public void updateData() + public void updateData() // + // The updateData() method is responsible for displaying an AlertDialog that allows the user to update the + // selected note's data or delete the note. Here's a breakdown of what the method does: { diff --git a/app/src/main/java/com/harpreet/notes_app/MainActivity.java b/app/src/main/java/com/harpreet/notes_app/MainActivity.java index 2b4c837..8f89c7f 100644 --- a/app/src/main/java/com/harpreet/notes_app/MainActivity.java +++ b/app/src/main/java/com/harpreet/notes_app/MainActivity.java @@ -26,13 +26,17 @@ public class MainActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + // Initialize views email = findViewById(R.id.email); password = findViewById(R.id.password); btnsignin = findViewById(R.id.signin); btnsignup = findViewById(R.id.signup); + // Initialize FirebaseAuth instance mAuth = FirebaseAuth.getInstance(); + // Initialize ProgressDialog progressd = new ProgressDialog(MainActivity.this); + // Check if the user is already signed in, if yes, redirect to HomeActivity if (mAuth.getCurrentUser()!=null) { startActivity(new Intent(getApplicationContext(),HomeActivity.class)); @@ -58,6 +62,7 @@ public void onClick(View v) { progressd.setMessage("Processing"); progressd.show(); + // Sign in with email and password using FirebaseAuth mAuth.signInWithEmailAndPassword(mEmail,mPass).addOnCompleteListener(new OnCompleteListener() { @Override public void onComplete(@NonNull Task task) { @@ -76,7 +81,7 @@ public void onComplete(@NonNull Task task) { } }); - + // Set click listener for sign-up button btnsignup.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/harpreet/notes_app/RegistrationActivity.java b/app/src/main/java/com/harpreet/notes_app/RegistrationActivity.java index 1abccd7..4f19fb8 100644 --- a/app/src/main/java/com/harpreet/notes_app/RegistrationActivity.java +++ b/app/src/main/java/com/harpreet/notes_app/RegistrationActivity.java @@ -45,6 +45,7 @@ public void onClick(View v) { } }); */ + // Set click listener for sign-up button signup.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -61,6 +62,8 @@ public void onClick(View v) { pass.setError("RequiredField.."); return; } + // Show progress dialog while processing sign-up request + pddia.setMessage("Processing"); pddia.show(); mAuth.createUserWithEmailAndPassword(mEmail,mPass).addOnCompleteListener(new OnCompleteListener() {