Commit 9fedf74e authored by 9731301's avatar 9731301

add ArchivedNotesActivity to ger selected notes and dateNotes

parent 91785dd1
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="org.jetbrains.annotations.Nullable" />
<option name="myDefaultNotNull" value="androidx.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="12">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
<item index="6" class="java.lang.String" itemvalue="android.annotation.Nullable" />
<item index="7" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
<item index="10" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
<item index="11" class="java.lang.String" itemvalue="com.android.annotations.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="11">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
<item index="5" class="java.lang.String" itemvalue="android.annotation.NonNull" />
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
<item index="10" class="java.lang.String" itemvalue="com.android.annotations.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
......
......@@ -17,7 +17,7 @@
<activity android:name=".MenuFeatures.Calender.MyCalenderActivity" />
<activity android:name=".MenuFeatures.VoiceMassages.VoiceMassagesActivity" />
<activity android:name=".MenuFeatures.AllNotes.AllNotesActivity" />
<activity android:name=".MenuFeatures.AllAchievedNotes.AchivedNotesActivity" />
<activity android:name=".MenuFeatures.AllArchivedNotes.ArchivedNotesActivity" />
<activity android:name=".MenuFeatures.Setting.SettingActivity" />
<activity android:name=".MainActivity">
<intent-filter>
......
......@@ -8,7 +8,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.example.mynotepad.MenuFeatures.AllAchievedNotes.AchivedNotesActivity;
import com.example.mynotepad.MenuFeatures.AllArchivedNotes.ArchivedNotesActivity;
import com.example.mynotepad.MenuFeatures.AllNotes.AllNotesActivity;
import com.example.mynotepad.MenuFeatures.Calender.MyCalenderActivity;
import com.example.mynotepad.MenuFeatures.Information.InfoClickListener;
......@@ -19,7 +19,7 @@ import com.google.android.material.snackbar.Snackbar;
public class CustomMenu extends LinearLayout implements View.OnClickListener {
private View rootView;
private TextView settingTv, allNotesTv, achievedTv, calenderTv, informationTv, voiceMassagesTv;
private TextView settingTv, allNotesTv, archivedTv, calenderTv, informationTv, voiceMassagesTv;
private ImageView img;
private InfoClickListener infoClickListener;
......@@ -38,7 +38,7 @@ public class CustomMenu extends LinearLayout implements View.OnClickListener {
rootView = inflate(context, R.layout.custom_menu, this);
settingTv = findViewById(R.id.settingTxt);
allNotesTv = findViewById(R.id.allNotesTxt);
achievedTv = findViewById(R.id.achievedTxt);
archivedTv = findViewById(R.id.archivedTxt);
calenderTv = findViewById(R.id.calenderTxt);
informationTv = findViewById(R.id.infoTxt);
voiceMassagesTv = findViewById(R.id.voiceTxt);
......@@ -46,7 +46,7 @@ public class CustomMenu extends LinearLayout implements View.OnClickListener {
settingTv.setOnClickListener(this);
allNotesTv.setOnClickListener(this);
achievedTv.setOnClickListener(this);
archivedTv.setOnClickListener(this);
calenderTv.setOnClickListener(this);
informationTv.setOnClickListener(this);
voiceMassagesTv.setOnClickListener(this);
......@@ -59,8 +59,8 @@ public class CustomMenu extends LinearLayout implements View.OnClickListener {
showSetting();
} else if (view.getId() == allNotesTv.getId()) {
showAllNotes();
} else if (view.getId() == achievedTv.getId()) {
showAchieved();
} else if (view.getId() == archivedTv.getId()) {
showArchived();
} else if (view.getId() == calenderTv.getId()) {
showCalender();
} else if (view.getId() == informationTv.getId()) {
......@@ -82,8 +82,8 @@ public class CustomMenu extends LinearLayout implements View.OnClickListener {
getContext().startActivity(intent);
}
private void showAchieved() {
Intent newIntent = new Intent(getContext(), AchivedNotesActivity.class);
private void showArchived() {
Intent newIntent = new Intent(getContext(), ArchivedNotesActivity.class);
getContext().startActivity(newIntent);
}
......
package com.example.mynotepad.MenuFeatures.AllAchievedNotes;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.example.mynotepad.R;
public class AchivedNotesActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_achived_notes);
}
}
\ No newline at end of file
package com.example.mynotepad.MenuFeatures.AllArchivedNotes;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.example.mynotepad.MenuFeatures.AllArchivedNotes.MyArchivedNotesRecyclerView.*;
import com.example.mynotepad.MenuFeatures.AllNotes.DataBase.DateEntity;
import com.example.mynotepad.MenuFeatures.AllNotes.AllNotesActivity;
import com.example.mynotepad.MenuFeatures.AllNotes.DataBase.Note;
import com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.MyNote;
import com.example.mynotepad.MenuFeatures.AllNotes.Note.NoteFragment;
import com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.TimePicker.MyDate;
import com.example.mynotepad.MenuFeatures.CustomToolbarOption;
import com.example.mynotepad.MenuFeatures.CustomToolbarOptionListener;
import com.example.mynotepad.R;
import java.util.ArrayList;
import java.util.List;
import static com.example.mynotepad.MainActivity.noteDataBase;
public class ArchivedNotesActivity extends AllNotesActivity {
private FrameLayout fragPlace;
private LinearLayout allNoteListAndTitle;
private CustomToolbarOption customToolbarOption;
private FrameLayout allNoteToolBar;
private RecyclerView recyclerView;
private MyArchivedAdaptor myarchivedAdaptor;
private List<Note> entityNotes;
private List<DateEntity> entityDates;
private List<MyNote> myNotes;
private List<MyDate> myDates;
private DateOrNote chosenDateOrNote;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_achived_notes);
init();
}
private void init() {
// get data from database
setAllNoteListAndTitles();
setAllDateNoteListAndTitles();
customToolbarOption = findViewById(R.id.customToolbarOption2);
customToolbarOption.setVisibility(View.GONE);
allNoteToolBar = findViewById(R.id.allNotesToolbar2);
allNoteToolBar.setEnabled(false);
allNoteListAndTitle = findViewById(R.id.allNoteListAndTitle2);
fragPlace = findViewById(R.id.fragmentPlace2);
fragPlace.setVisibility(View.GONE);
// show list with recycler view
recyclerView = findViewById(R.id.recyclerView2);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
myarchivedAdaptor = new MyArchivedAdaptor(myNotes, myDates);
recyclerView.setAdapter(myarchivedAdaptor);
recyclerView.setLayoutManager(linearLayoutManager);
addListeners();
}
private void addListeners() {
// add listener to recyclerView
myarchivedAdaptor.setOnArchivedItemClickListener(new OnArchivedItemClickListener() {
@Override
public void onItemClicked(DateOrNote item) {
chosenDateOrNote = item;
if (item.getType().equals("note")){
//set noteFragment data
final Bundle bundle = new Bundle();
bundle.putString("title", item.getTitle());
bundle.putString("bodyTxt", item.getDescription());
final NoteFragment newNoteFrag = new NoteFragment(false);
newNoteFrag.setArguments(bundle);
//change the fragment
fragPlace.setVisibility(View.VISIBLE);
allNoteListAndTitle.setVisibility(View.GONE);
replaceFragment(newNoteFrag);
}
else if (item.getType().equals("date")){
//todo go to fragment
}
}
@Override
public void onItemLongClicked(DateOrNote item) {
chosenDateOrNote = item;
customToolbarOption.setVisibility(View.VISIBLE);
customToolbarOption.hideRecycleBin();
allNoteToolBar.setVisibility(View.GONE);
}
});
//add listener to custom toolbar option and set being archived or not to be saved in database
customToolbarOption.setCustomToolbarOptionListener(new CustomToolbarOptionListener() {
@Override
public void onStarClicked() {
customToolbarOption.setBlackStar();
myarchivedAdaptor.getDateOrNoteList().remove(chosenDateOrNote);
updateToUnarchiveInDataBase();
Toast.makeText(ArchivedNotesActivity.this, "unarchived", Toast.LENGTH_SHORT).show();
}
@Override
public void onDeleteClicked() {
}
@Override
public void onCloseClicked() {
closeClicked(customToolbarOption);
}
});
}
private void updateToUnarchiveInDataBase() {
if (chosenDateOrNote.getType().equals("note")){
noteDataBase.noteDao().updateNote(chosenDateOrNote.getTitle() , chosenDateOrNote.getDescription() , false , chosenDateOrNote.getId());
}
else if(chosenDateOrNote.getType().equals("date")){
noteDataBase.dateNoreDAO().updateDate(chosenDateOrNote.getTitle() , chosenDateOrNote.getDescription() , false , chosenDateOrNote.getId());
}
}
private void setAllNoteListAndTitles() {
entityNotes = noteDataBase.noteDao().getAll();
myNotes = new ArrayList<>();
for (Note note : entityNotes) {
MyNote myNote = new MyNote(note.getTitle(), note.getDescription(), note.isarchived() , note.getID());
myNotes.add(myNote);
}
}
private void setAllDateNoteListAndTitles() {
//get data from database to set in recyclerView
entityDates = noteDataBase.dateNoreDAO().getAllDateNotes();
myDates = new ArrayList<>();
for (DateEntity dateEntity : entityDates) {
MyDate myDate = new MyDate(dateEntity.getDate(), dateEntity.getDescription(), dateEntity.isarchived() , dateEntity.getID());
myDates.add(myDate);
}
}
}
\ No newline at end of file
package com.example.mynotepad.MenuFeatures.AllArchivedNotes.MyArchivedNotesRecyclerView;
public class DateOrNote {
private int id;
private String type;
private String title;
private String description;
public DateOrNote(int id, String type, String title, String description) {
this.id = id;
this.type = type;
this.title = title;
this.description = description;
}
public int getId() {
return id;
}
public String getType() {
return type;
}
public String getTitle() {
return title;
}
public String getDescription() {
return description;
}
}
package com.example.mynotepad.MenuFeatures.AllArchivedNotes.MyArchivedNotesRecyclerView;
public interface OnArchivedItemClickListener {
void onItemClicked(DateOrNote item);
void onItemLongClicked(DateOrNote item);
}
......@@ -13,6 +13,7 @@ import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.MyAllNotesAdaptor;
import com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.MyNote;
......@@ -45,7 +46,6 @@ public class AllNotesActivity extends AppCompatActivity {
private static MyNote myChosenNote;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -71,15 +71,15 @@ public class AllNotesActivity extends AppCompatActivity {
recyclerView = findViewById(R.id.recyclerView);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
myAdaptor = new MyAllNotesAdaptor(myNotes);
recyclerView.setAdapter(myAdaptor);
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setAdapter(myAdaptor);
addListeners();
}
public void addListeners() {
private void addListeners() {
addNoteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
......@@ -96,7 +96,7 @@ public class AllNotesActivity extends AppCompatActivity {
final Bundle bundle = new Bundle();
bundle.putString("title", myNote.getTitle());
bundle.putString("bodyTxt", myNote.getDescription());
final NoteFragment newNoteFrag = new NoteFragment(false );
final NoteFragment newNoteFrag = new NoteFragment(false);
newNoteFrag.setArguments(bundle);
//change the fragment
......@@ -111,41 +111,47 @@ public class AllNotesActivity extends AppCompatActivity {
customToolbarOption.setVisibility(View.VISIBLE);
allNoteToolBar.setVisibility(View.GONE);
myChosenNote = myNote;
if (myChosenNote.isarchived()){
customToolbarOption.setYellowStar();
}
else {
customToolbarOption.setBlackStar();
}
}
});
//add listener to custom toolbar option and set being achieved or not to be saved in database
//add listener to custom toolbar option and set being archived or not to be saved in database
customToolbarOption.setCustomToolbarOptionListener(new CustomToolbarOptionListener() {
@Override
public void onStarClicked(ImageView yellowS, ImageView blackS) {
starClicked(yellowS, blackS);
public void onStarClicked() {
starClicked();
}
@Override
public void onDeleteClicked(final ImageView imageView) {
deleteClicked(imageView);
public void onDeleteClicked() {
Note note = entityNotes.get(myNotes.indexOf(myChosenNote));
deleteClicked(note);
}
@Override
public void onCloseClicked() {
closeClicked();
closeClicked(customToolbarOption);
}
});
}
private void closeClicked() {
protected void closeClicked(CustomToolbarOption customToolbarOption) {
customToolbarOption.setVisibility(View.GONE);
allNoteToolBar.setVisibility(View.VISIBLE);
}
private void deleteClicked(ImageView imageView) {
protected void deleteClicked(final Note note) {
AlertDialog.Builder alert = new AlertDialog.Builder(AllNotesActivity.this);
alert.setMessage("are you sure you wanna delete it ??? ");
alert.setPositiveButton("yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
noteDataBase.noteDao().deleteNote(entityNotes.get(myNotes.indexOf(myChosenNote)));
noteDataBase.noteDao().deleteNote(note);
init();
}
});
......@@ -159,18 +165,25 @@ public class AllNotesActivity extends AppCompatActivity {
allNoteToolBar.setVisibility(View.VISIBLE);
}
private void starClicked(ImageView yellowS, ImageView blackS) {
if (yellowS.getVisibility() == View.VISIBLE) {
yellowS.setVisibility(View.GONE);
blackS.setVisibility(View.VISIBLE);
myChosenNote.setAchieved(false);
protected void starClicked() {
if (myChosenNote.isarchived()) {
customToolbarOption.setBlackStar();
myChosenNote.setarchived(false);
updatearchivedNotesInDataBase();
Toast.makeText(this, "unarchived", Toast.LENGTH_SHORT).show();
} else {
yellowS.setVisibility(View.VISIBLE);
blackS.setVisibility(View.GONE);
myChosenNote.setAchieved(true);
customToolbarOption.setYellowStar();
myChosenNote.setarchived(true);
updatearchivedNotesInDataBase();
Toast.makeText(this, "archived", Toast.LENGTH_SHORT).show();
}
}
private void updatearchivedNotesInDataBase() {
noteDataBase.noteDao().updateNote(myChosenNote.getTitle(), myChosenNote.getDescription()
, myChosenNote.isarchived(), myChosenNote.getId());
}
private void showAddAlert() {
final AlertDialog.Builder alert = new AlertDialog.Builder(this);
......@@ -212,7 +225,7 @@ public class AllNotesActivity extends AppCompatActivity {
entityNotes = noteDataBase.noteDao().getAll();
myNotes = new ArrayList<>();
for (Note note : entityNotes) {
MyNote myNote = new MyNote(note.getTitle(), note.getDescription(), note.isAchieved());
MyNote myNote = new MyNote(note.getTitle(), note.getDescription(), note.isarchived(), note.getID());
myNotes.add(myNote);
}
}
......
......@@ -11,13 +11,13 @@ public class DateEntity {
String date ;
@ColumnInfo(name = "description")
String description;
@ColumnInfo(name = "achieved")
boolean isAchieved;
@ColumnInfo(name = "archived")
boolean isarchived;
public DateEntity(String date , String description , boolean isAchieved){
public DateEntity(String date , String description , boolean isarchived){
this.date = date;
this.description = description;
this.isAchieved = isAchieved;
this.isarchived = isarchived;
}
......@@ -33,7 +33,7 @@ public class DateEntity {
return description;
}
public boolean isAchieved(){
return isAchieved;
public boolean isarchived(){
return isarchived;
}
}
\ No newline at end of file
......@@ -25,5 +25,6 @@ public interface DateNoreDAO {
@Update
void updateDateNote(DateEntity dateEntity);
@Query("UPDATE DateEntity SET date = :date , description = :description ,archived = :isarchived Where ID = :id")
void updateDate(String date , String description , boolean isarchived , int id);
}
......@@ -11,13 +11,13 @@ import androidx.room.PrimaryKey;
String title ;
@ColumnInfo(name = "description")
String txtBody;
@ColumnInfo(name = "achieved")
boolean isAchieved;
@ColumnInfo(name = "archived")
boolean isarchived;
public Note(String title , String txtBody , boolean isAchieved){
public Note(String title , String txtBody , boolean isarchived){
this.title = title;
this.txtBody = txtBody;
this.isAchieved = isAchieved;
this.isarchived = isarchived;
}
......@@ -33,7 +33,7 @@ import androidx.room.PrimaryKey;
return txtBody;
}
public boolean isAchieved(){
return isAchieved;
public boolean isarchived(){
return isarchived;
}
}
......@@ -23,8 +23,9 @@ public interface NoteDAO {
void deleteNote(Note myNote);
@Query("UPDATE Note SET title = :title , description = :description ,achieved = :isAchieved Where ID = :id")
void updateNote(String title , String description , boolean isAchieved , int id);
@Query("UPDATE Note SET title = :title , description = :description ,archived = :isarchived Where ID = :id")
void updateNote(String title , String description , boolean isarchived , int id);
}
\ No newline at end of file
......@@ -21,7 +21,6 @@ public class MyAllNotesAdaptor extends RecyclerView.Adapter<MyAllNotesAdaptor.Vi
this.notes = notes;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.custom_allnotes_item, parent, false);
......@@ -32,7 +31,7 @@ public class MyAllNotesAdaptor extends RecyclerView.Adapter<MyAllNotesAdaptor.Vi
public void onBindViewHolder(ViewHolder holder, int position) {
holder.titleTV.setText(notes.get(position).getTitle());
holder.descriptionTV.setText(notes.get(position).getDescription());
holder.isAchieved = notes.get(position).isAchieved();
holder.isarchived = notes.get(position).isarchived();
}
@Override
......@@ -46,13 +45,13 @@ public class MyAllNotesAdaptor extends RecyclerView.Adapter<MyAllNotesAdaptor.Vi
class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
protected TextView titleTV, descriptionTV;
protected boolean isAchieved;
protected boolean isarchived;
public ViewHolder(View itemView) {
super(itemView);
titleTV = itemView.findViewById(R.id.titleTv);
descriptionTV = itemView.findViewById(R.id.descriptionTv);
isAchieved = false;
isarchived = false;
itemView.setOnClickListener(this);
itemView.setOnLongClickListener(this);
}
......
......@@ -2,13 +2,15 @@ package com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView;
public class MyNote {
private String title , description ;
private boolean isAchieved;
private String title, description;
private boolean isarchived;
int id;
public MyNote(String title, String description, boolean isAchieved) {
public MyNote(String title, String description, boolean isarchived, int id) {
this.title = title;
this.description = description;
this.isAchieved = isAchieved;
this.isarchived = isarchived;
this.id = id;
}
public String getTitle() {
......@@ -19,11 +21,15 @@ public class MyNote {
return description;
}
public boolean isAchieved() {
return isAchieved;
public boolean isarchived() {
return isarchived;
}
public void setAchieved(boolean achieved) {
isAchieved = achieved;
public void setarchived(boolean archived) {
isarchived = archived;
}
public int getId() {
return id;
}
}
......@@ -95,7 +95,7 @@ public class NoteFragment extends Fragment {
noteDataBase.noteDao().insertNote(note);
Toast.makeText(getActivity(), "saved", Toast.LENGTH_SHORT).show();
}else {
noteDataBase.noteDao().updateNote(titleTxt.getText().toString() , bodyTxt.getText().toString() , note.isAchieved() , note.getID());
noteDataBase.noteDao().updateNote(titleTxt.getText().toString() , bodyTxt.getText().toString() , note.isarchived() , note.getID());
Toast.makeText(getActivity(), "updated", Toast.LENGTH_SHORT).show();
}
}
......
......@@ -12,8 +12,10 @@ import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.example.mynotepad.MenuFeatures.AllNotes.DataBase.DateEntity;
import com.example.mynotepad.MenuFeatures.AllNotes.DataBase.Note;
import com.example.mynotepad.MenuFeatures.AllNotes.Note.NoteFragment;
import com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.MyCalenderAdaptor;
import com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.OnCalenderItemClickListener;
......@@ -58,7 +60,7 @@ public class MyCalenderActivity extends AppCompatActivity {
private void init() {
setAllNoteListAndTitles();
setAllDateNoteListAndTitles();
addDateBtn = findViewById(R.id.addDateButton);
customToolbarOption = findViewById(R.id.calenderCustomToolbarOption);
......@@ -114,20 +116,26 @@ public class MyCalenderActivity extends AppCompatActivity {
customToolbarOption.setVisibility(View.VISIBLE);
calenderToolbar.setVisibility(View.GONE);
myChosenDateNote = myDate;
if (myChosenDateNote.isarchived()){
customToolbarOption.setYellowStar();
}
else {
customToolbarOption.setBlackStar();
}
}
});
//add listener to custom toolbar option and set being achieved or not to be saved in database
//add listener to custom toolbar option and set being archived or not to be saved in database
customToolbarOption.setCustomToolbarOptionListener(new CustomToolbarOptionListener() {
@Override
public void onStarClicked(ImageView yellowS, ImageView blackS) {
starClicked(yellowS, blackS);
public void onStarClicked() {
starClicked();
}
@Override
public void onDeleteClicked(final ImageView imageView) {
deleteClicked(imageView);
public void onDeleteClicked() {
deleteClicked();
}
......@@ -144,7 +152,7 @@ public class MyCalenderActivity extends AppCompatActivity {
calenderToolbar.setVisibility(View.VISIBLE);
}
private void deleteClicked(ImageView imageView) {
private void deleteClicked() {
AlertDialog.Builder alert = new AlertDialog.Builder(MyCalenderActivity.this);
alert.setMessage("are you sure you wanna delete it ??? ");
alert.setPositiveButton("yes", new DialogInterface.OnClickListener() {
......@@ -164,31 +172,36 @@ public class MyCalenderActivity extends AppCompatActivity {
calenderToolbar.setVisibility(View.VISIBLE);
}
private void starClicked(ImageView yellowS, ImageView blackS) {
if (yellowS.getVisibility() == View.VISIBLE) {
yellowS.setVisibility(View.GONE);
blackS.setVisibility(View.VISIBLE);
myChosenDateNote.setAchieved(false);
private void starClicked() {
if (myChosenDateNote.isarchived()) {
customToolbarOption.setBlackStar();
myChosenDateNote.setarchived(false);
updatearchivedDatesInDataBase();
Toast.makeText(this, "unarchived", Toast.LENGTH_SHORT).show();
} else {
yellowS.setVisibility(View.VISIBLE);
blackS.setVisibility(View.GONE);
myChosenDateNote.setAchieved(true);
customToolbarOption.setYellowStar();
myChosenDateNote.setarchived(true);
updatearchivedDatesInDataBase();
Toast.makeText(this, "archived", Toast.LENGTH_SHORT).show();
}
}
private void updatearchivedDatesInDataBase() {
noteDataBase.dateNoreDAO().updateDate(myChosenDateNote.getDate(), myChosenDateNote.getDescription(), myChosenDateNote.isarchived(), myChosenDateNote.getId());
}
private void addNewDateAndDescription() {
Intent intent = new Intent(MyCalenderActivity.this, DatePickerActivity.class);
startActivity(intent);
}
private void setAllNoteListAndTitles() {
myDates = new ArrayList<>();
private void setAllDateNoteListAndTitles() {
//get data from database to set in recyclerView
entityDates = noteDataBase.dateNoreDAO().getAllDateNotes();
myDates = new ArrayList<>();
for (DateEntity dateEntity : entityDates) {
MyDate myDate = new MyDate(dateEntity.getDate(), dateEntity.getDescription(), dateEntity.isAchieved());
MyDate myDate = new MyDate(dateEntity.getDate(), dateEntity.getDescription(), dateEntity.isarchived(), dateEntity.getID());
myDates.add(myDate);
}
}
......
......@@ -32,7 +32,7 @@ public class MyCalenderAdaptor extends RecyclerView.Adapter<MyCalenderAdaptor.Ca
public void onBindViewHolder(@NonNull CalenderViewHolder holder, int position) {
holder.dateTV.setText(dates.get(position).getDate());
holder.descriptionTV.setText(dates.get(position).getDescription());
holder.isAchieved = dates.get(position).isAchieved();
holder.isarchived = dates.get(position).isarchived();
}
@Override
......@@ -46,13 +46,13 @@ public class MyCalenderAdaptor extends RecyclerView.Adapter<MyCalenderAdaptor.Ca
class CalenderViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
protected TextView dateTV, descriptionTV;
protected boolean isAchieved;
protected boolean isarchived;
public CalenderViewHolder(@NonNull View itemView) {
super(itemView);
dateTV = itemView.findViewById(R.id.titleTv);
descriptionTV = itemView.findViewById(R.id.descriptionTv);
isAchieved = false;
isarchived = false;
itemView.setOnClickListener(this);
itemView.setOnLongClickListener(this);
}
......
......@@ -3,12 +3,14 @@ package com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.TimeP
public class MyDate {
private String date , description ;
private boolean isAchieved;
private boolean isarchived;
int id;
public MyDate(String date, String description, boolean isAchieved) {
public MyDate(String date, String description, boolean isarchived , int id) {
this.date = date;
this.description = description;
this.isAchieved = isAchieved;
this.isarchived = isarchived;
this.id = id;
}
public String getDate() {
......@@ -19,11 +21,15 @@ public class MyDate {
return description;
}
public boolean isAchieved() {
return isAchieved;
public boolean isarchived() {
return isarchived;
}
public void setAchieved(boolean achieved) {
isAchieved = achieved;
public void setarchived(boolean archived) {
isarchived = archived;
}
public int getId() {
return id;
}
}
......@@ -30,7 +30,6 @@ public class CustomToolbarOption extends LinearLayout implements View.OnClickLis
yellowStarImg = findViewById(R.id.yellow_star);
deleteImg = findViewById(R.id.deleteImg);
closeImg = findViewById(R.id.closeImg);
//todo setStarColor();
yellowStarImg.setOnClickListener(this);
blackStarImg.setOnClickListener(this);
......@@ -39,16 +38,6 @@ public class CustomToolbarOption extends LinearLayout implements View.OnClickLis
}
/* private void setStarColor() {
if (AllNotesActivity.myChosenNote.isAchieved()){
blackStarImg.setVisibility(GONE);
yellowStarImg.setVisibility(VISIBLE);
}
else {
blackStarImg.setVisibility(VISIBLE);
yellowStarImg.setVisibility(GONE);
}
}*/
@Override
public void onClick(View view) {
......@@ -56,13 +45,32 @@ public class CustomToolbarOption extends LinearLayout implements View.OnClickLis
if (view.getId() == closeImg.getId())
customToolbarOptionListener.onCloseClicked();
if (view.getId() == deleteImg.getId())
customToolbarOptionListener.onDeleteClicked(deleteImg);
customToolbarOptionListener.onDeleteClicked();
if (view.getId() == yellowStarImg.getId() || view.getId() == blackStarImg.getId())
customToolbarOptionListener.onStarClicked(yellowStarImg , blackStarImg);
customToolbarOptionListener.onStarClicked();
}
}
public void setCustomToolbarOptionListener(CustomToolbarOptionListener customToolbarOptionListener) {
this.customToolbarOptionListener = customToolbarOptionListener;
}
public void setYellowStar(){
yellowStarImg.setVisibility(VISIBLE);
blackStarImg.setVisibility(GONE);
}
public void setBlackStar(){
yellowStarImg.setVisibility(GONE);
blackStarImg.setVisibility(VISIBLE);
}
public void hideRecycleBin(){
deleteImg.setVisibility(GONE);
}
public void hideStar(){
yellowStarImg.setVisibility(GONE);
blackStarImg.setVisibility(GONE);
}
}
package com.example.mynotepad.MenuFeatures;
import android.widget.ImageView;
public interface CustomToolbarOptionListener {
void onStarClicked(ImageView yellowS , ImageView blackS);
void onDeleteClicked(ImageView imageView);
void onStarClicked();
void onDeleteClicked();
void onCloseClicked();
}
......@@ -105,19 +105,20 @@ public class VoiceMassagesActivity extends AppCompatActivity {
@Override
public void onItemLongClicked(MyVoice item) {
customToolbarOption.setVisibility(View.VISIBLE);
customToolbarOption.hideStar();
myChosenVoice = item;
}
});
//add listener to custom toolbar option and set being achieved or not to be saved in database
//add listener to custom toolbar option and set being archived or not to be saved in database
customToolbarOption.setCustomToolbarOptionListener(new CustomToolbarOptionListener() {
@Override
public void onStarClicked(ImageView yellowS, ImageView blackS) {
public void onStarClicked() {
}
@Override
public void onDeleteClicked(final ImageView imageView) {
deleteClicked(imageView);
public void onDeleteClicked() {
deleteClicked();
}
@Override
......@@ -127,7 +128,7 @@ public class VoiceMassagesActivity extends AppCompatActivity {
});
}
private void deleteClicked(ImageView imageView) {
private void deleteClicked() {
AlertDialog.Builder alert = new AlertDialog.Builder(VoiceMassagesActivity.this);
alert.setMessage("are you sure you wanna delete it ??? ");
alert.setPositiveButton("yes", new DialogInterface.OnClickListener() {
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MenuFeatures.AllAchievedNotes.AchivedNotesActivity">
tools:context=".MenuFeatures.AllarchivedNotes.archivedNotesActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<FrameLayout
android:id="@+id/fragmentPlace2"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:id="@+id/allNoteListAndTitle2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/allNotesToolbar2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imageView72"
android:layout_width="match_parent"
android:layout_height="50dp"
android:scaleType="fitXY"
app:srcCompat="@drawable/index" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:enabled="false"
android:text="@string/archived"
android:textColor="#02091E"
android:textSize="26dp" />
</FrameLayout>
<com.example.mynotepad.MenuFeatures.CustomToolbarOption
android:id="@+id/customToolbarOption2"
android:layout_width="match_parent"
android:layout_height="50dp" />
</FrameLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView2"
android:layout_width="409dp"
android:layout_height="match_parent"
android:background="#4883B5DD"
tools:layout_editor_absoluteX="1dp"
tools:layout_editor_absoluteY="1dp" />
</LinearLayout>
</FrameLayout>
\ No newline at end of file
......@@ -99,14 +99,14 @@
<TextView
android:id="@+id/achievedTxt"
android:id="@+id/archivedTxt"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_weight="6"
android:gravity="center_vertical"
android:text="@string/achieved"
android:text="@string/archived"
android:textSize="20dp" />
<TextView
......
<resources>
<string name="app_name">MyNotepad</string>
<string name="setting">setting</string>
<string name="achieved">achieved</string>
<string name="all_notes">all notes</string>
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="title">title</string>
......@@ -12,4 +11,5 @@
<string name="date">date</string>
<string name="chosendate">chosenDate</string>
<string name="dots">...</string>
<string name="archived">archived</string>
</resources>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment