Skip to content

Commit

Permalink
Merge pull request #12 from faiyaz103/bishal
Browse files Browse the repository at this point in the history
Note Delete and Edit Functionality Added
  • Loading branch information
IronDigger098 authored May 25, 2024
2 parents 44e568f + 63d1f55 commit 547b015
Show file tree
Hide file tree
Showing 8 changed files with 262 additions and 6 deletions.
14 changes: 10 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@
android:theme="@style/Theme.NoteMania"
tools:targetApi="31">
<activity
android:name=".createnote"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
android:name=".notedetails"
android:exported="false" />
<activity
android:name=".notesActivity"
android:theme="@style/Theme.AppCompat.DayNight.DarkActionBar"
android:name=".editnoteactivity"
android:exported="false" />
<activity
android:name=".createnote"
android:exported="false"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar" />
<activity
android:name=".notesActivity"
android:exported="false"
android:theme="@style/Theme.AppCompat.DayNight.DarkActionBar" />
<activity
android:name=".forgotpassword"
android:exported="false" />
Expand Down
24 changes: 24 additions & 0 deletions app/src/main/java/com/example/notemania/editnoteactivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.notemania;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class editnoteactivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_editnoteactivity);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
}
}
24 changes: 24 additions & 0 deletions app/src/main/java/com/example/notemania/notedetails.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.notemania;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class notedetails extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_notedetails);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
}
}
68 changes: 68 additions & 0 deletions app/src/main/java/com/example/notemania/notesActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
Expand All @@ -23,7 +27,10 @@
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.Query;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Random;

public class notesActivity extends AppCompatActivity {

Expand Down Expand Up @@ -64,9 +71,51 @@ public void onClick(View v) {
noteAdapter=new FirestoreRecyclerAdapter<firebasemodel,NoteViewHolder>(allusernotes){
@Override
protected void onBindViewHolder(@NonNull NoteViewHolder noteViewHolder,int i,@NonNull firebasemodel firebasemodel){

ImageView popupbutton=noteViewHolder.itemView.findViewById(R.id.menupopbutton);

int colourcode=getRandomcolor();
noteViewHolder.mnote.setBackgroundColor(noteViewHolder.itemView.getResources().getColor(colourcode,null));
noteViewHolder.notetitle.setText(firebasemodel.getTitle());
noteViewHolder.notecontent.setText(firebasemodel.getContent());

noteViewHolder.itemView.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v){
//we have to open note detail activity
Intent intent=new Intent(v.getContext(),notedetails.class);
v.getContext().startActivity(intent);
//Toast.makeText(getApplicationContext(),"This is Clicked",Toast.LENGTH_SHORT).show();
}
});

popupbutton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
PopupMenu popupMenu=new PopupMenu(v.getContext(),v);
popupMenu.setGravity(Gravity.END);
popupMenu.getMenu().add("Edit").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(@NonNull MenuItem item) {
Intent intent=new Intent(v.getContext(),editnoteactivity.class);
v.getContext().startActivity(intent);
return false;
}
});
popupMenu.getMenu().add("Delete").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener(){
@Override
public boolean onMenuItemClick(MenuItem item){
Toast.makeText(v.getContext(),"This Note is Deleted",Toast.LENGTH_SHORT).show();
return false;
}
});
popupMenu.show();
}
});




}
@NonNull
Expand Down Expand Up @@ -130,4 +179,23 @@ protected void onStop() {
noteAdapter.startListening();
}
}
private int getRandomcolor()
{
List<Integer>colorcode=new ArrayList<>();
colorcode.add(R.color.gray);
colorcode.add(R.color.green);
colorcode.add(R.color.pink);
colorcode.add(R.color.lightgreen);
colorcode.add(R.color.skyblue);
colorcode.add(R.color.color1);
colorcode.add(R.color.color2);
colorcode.add(R.color.color3);
colorcode.add(R.color.color4);
colorcode.add(R.color.color5);

Random random=new Random();
int number=random.nextInt(colorcode.size());
return colorcode.get(number);

}
}
56 changes: 56 additions & 0 deletions app/src/main/res/layout/activity_editnoteactivity.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".editnoteactivity">

<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:id="@+id/toolbarforeditnote"
android:background="@color/white">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="12dp"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="@color/black"
android:id="@+id/edittitleofnote" />

</RelativeLayout>

</androidx.appcompat.widget.Toolbar>

<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="15sp"
android:background="#faf7f7"
android:gravity="top|left"
android:textColor="@color/black"
android:layout_below="@id/toolbarforeditnote"
android:padding="15dp"
android:id="@+id/editcontentofnote" />

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="30dp"
android:layout_marginEnd="30dp"
android:id="@+id/saveeditnote"
android:src="@drawable/update"
app:backgroundTint="#A1F4FB"
app:maxImageSize="56dp" />

</RelativeLayout>
58 changes: 58 additions & 0 deletions app/src/main/res/layout/activity_notedetails.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".notedetails">

<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:id="@+id/toolbarfornotedetail"
android:background="@color/white">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="12dp"
android:textSize="25sp"
android:textStyle="bold"
android:text="Title Displayed Here"
android:textColor="@color/black"
android:id="@+id/titleofnotedetail" />

</RelativeLayout>

</androidx.appcompat.widget.Toolbar>

<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="17sp"
android:background="#faf7f7"
android:gravity="top|left"
android:textColor="@color/black"
android:hint="Enter your note content here"
android:layout_below="@id/toolbarfornotedetail"
android:padding="15dp"
android:id="@+id/contentofnotedetail" />

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="30dp"
android:layout_marginEnd="30dp"
android:id="@+id/gotoeditnote"
android:src="@drawable/edit"
app:backgroundTint="#A1F4FB"
app:maxImageSize="56dp" />

</RelativeLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/layout/notes_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:background="#00BCD4"

android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/notetitle"
Expand All @@ -49,7 +49,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/notecontent"
android:background="#CE03F4C4"

android:paddingBottom="20dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>


<color name="gray" >#cdc9c3</color>
<color name="green" >#c6ebc9</color>
<color name="lightgreen" >#cfffa5</color>
<color name="skyblue" >#a7c5eb</color>
<color name="pink" >#f3e6e3</color>
<color name="color1" >#efbbcf</color>
<color name="color2" >#d6b0b1</color>
<color name="color3" >#ccf6c8</color>
<color name="color4" >#ffe0ac</color>
<color name="color5" >#e5cfe5</color>



</resources>

0 comments on commit 547b015

Please sign in to comment.