Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
My notepad
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9731301
My notepad
Commits
59b10593
Commit
59b10593
authored
Oct 05, 2020
by
9731301
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change calender notes structure to navigation
parent
f0633d15
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
368 additions
and
268 deletions
+368
-268
ArchivedNotesActivity.java
.../MenuFeatures/AllArchivedNotes/ArchivedNotesActivity.java
+1
-3
MyArchivedAdaptor.java
...dNotes/MyArchivedNotesRecyclerView/MyArchivedAdaptor.java
+2
-2
AllNotesListFragment.java
...mynotepad/MenuFeatures/AllNotes/AllNotesListFragment.java
+6
-6
MyAllNotesAdaptor.java
...atures/AllNotes/MyNoteRecyclerView/MyAllNotesAdaptor.java
+1
-1
MyNote.java
...epad/MenuFeatures/AllNotes/MyNoteRecyclerView/MyNote.java
+2
-2
NoteFragment.java
...le/mynotepad/MenuFeatures/AllNotes/Note/NoteFragment.java
+24
-6
CalenderNotesListFragment.java
...epad/MenuFeatures/Calender/CalenderNotesListFragment.java
+212
-0
MyCalenderActivity.java
...e/mynotepad/MenuFeatures/Calender/MyCalenderActivity.java
+1
-166
MyCalenderAdaptor.java
...es/Calender/MyCalenderRecyclerView/MyCalenderAdaptor.java
+1
-1
MyDate.java
...es/Calender/MyCalenderRecyclerView/TimePicker/MyDate.java
+6
-6
activity_my_calender.xml
app/src/main/res/layout/activity_my_calender.xml
+7
-75
fragment_calender_notes_list.xml
app/src/main/res/layout/fragment_calender_notes_list.xml
+80
-0
nav_calender.xml
app/src/main/res/navigation/nav_calender.xml
+25
-0
No files found.
app/src/main/java/com/example/mynotepad/MenuFeatures/AllArchivedNotes/ArchivedNotesActivity.java
View file @
59b10593
...
...
@@ -85,13 +85,11 @@ public class ArchivedNotesActivity extends AppCompatActivity {
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
);
//todo
}
else
if
(
item
.
getType
().
equals
(
"date"
)){
//todo go to fragment
...
...
app/src/main/java/com/example/mynotepad/MenuFeatures/AllArchivedNotes/MyArchivedNotesRecyclerView/MyArchivedAdaptor.java
View file @
59b10593
...
...
@@ -33,7 +33,7 @@ public class MyArchivedAdaptor extends RecyclerView.Adapter<MyArchivedAdaptor.Vi
private
void
setDates
()
{
for
(
MyDate
myDate
:
dates
)
{
if
(
myDate
.
is
a
rchived
())
{
if
(
myDate
.
is
A
rchived
())
{
DateOrNote
date
=
new
DateOrNote
(
myDate
.
getId
(),
"date"
,
myDate
.
getDate
(),
myDate
.
getDescription
());
dateOrNoteList
.
add
(
date
);
}
...
...
@@ -42,7 +42,7 @@ public class MyArchivedAdaptor extends RecyclerView.Adapter<MyArchivedAdaptor.Vi
private
void
setNotes
()
{
for
(
MyNote
myNote
:
notes
)
{
if
(
myNote
.
is
a
rchived
())
{
if
(
myNote
.
is
A
rchived
())
{
DateOrNote
note
=
new
DateOrNote
(
myNote
.
getId
(),
"note"
,
myNote
.
getTitle
(),
myNote
.
getDescription
());
dateOrNoteList
.
add
(
note
);
}
...
...
app/src/main/java/com/example/mynotepad/MenuFeatures/AllNotes/AllNotesListFragment.java
View file @
59b10593
...
...
@@ -19,7 +19,6 @@ import com.example.mynotepad.MenuFeatures.AllNotes.DataBase.Note;
import
com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.MyAllNotesAdaptor
;
import
com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.MyNote
;
import
com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.OnAllNotesItemClickListener
;
import
com.example.mynotepad.MenuFeatures.AllNotes.Note.NoteFragment
;
import
com.example.mynotepad.MenuFeatures.CustomToolbarOption
;
import
com.example.mynotepad.MenuFeatures.CustomToolbarOptionListener
;
import
com.example.mynotepad.R
;
...
...
@@ -94,6 +93,7 @@ public class AllNotesListFragment extends Fragment {
final
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
"title"
,
myNote
.
getTitle
());
bundle
.
putString
(
"bodyTxt"
,
myNote
.
getDescription
());
bundle
.
putString
(
"type"
,
"note"
);
//change the fragment
navController
.
navigate
(
R
.
id
.
action_allNotesListFragment_to_noteFragment
,
bundle
);
...
...
@@ -104,7 +104,7 @@ public class AllNotesListFragment extends Fragment {
customToolbarOption
.
setVisibility
(
View
.
VISIBLE
);
allNoteToolBar
.
setVisibility
(
View
.
GONE
);
myChosenNote
=
myNote
;
if
(
myChosenNote
.
is
a
rchived
()){
if
(
myChosenNote
.
is
A
rchived
()){
customToolbarOption
.
setYellowStar
();
}
else
{
...
...
@@ -166,14 +166,14 @@ public class AllNotesListFragment extends Fragment {
}
protected
void
starClicked
()
{
if
(
myChosenNote
.
is
a
rchived
())
{
if
(
myChosenNote
.
is
A
rchived
())
{
customToolbarOption
.
setBlackStar
();
myChosenNote
.
set
a
rchived
(
false
);
myChosenNote
.
set
A
rchived
(
false
);
updatearchivedNotesInDataBase
();
Toast
.
makeText
(
getContext
(),
"unarchived"
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
customToolbarOption
.
setYellowStar
();
myChosenNote
.
set
a
rchived
(
true
);
myChosenNote
.
set
A
rchived
(
true
);
updatearchivedNotesInDataBase
();
Toast
.
makeText
(
getContext
(),
"archived"
,
Toast
.
LENGTH_SHORT
).
show
();
}
...
...
@@ -181,7 +181,7 @@ public class AllNotesListFragment extends Fragment {
private
void
updatearchivedNotesInDataBase
()
{
noteDataBase
.
noteDao
().
updateNote
(
myChosenNote
.
getTitle
(),
myChosenNote
.
getDescription
()
,
myChosenNote
.
is
a
rchived
(),
myChosenNote
.
getId
());
,
myChosenNote
.
is
A
rchived
(),
myChosenNote
.
getId
());
}
...
...
app/src/main/java/com/example/mynotepad/MenuFeatures/AllNotes/MyNoteRecyclerView/MyAllNotesAdaptor.java
View file @
59b10593
...
...
@@ -31,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
.
isarchived
=
notes
.
get
(
position
).
is
a
rchived
();
holder
.
isarchived
=
notes
.
get
(
position
).
is
A
rchived
();
}
@Override
...
...
app/src/main/java/com/example/mynotepad/MenuFeatures/AllNotes/MyNoteRecyclerView/MyNote.java
View file @
59b10593
...
...
@@ -21,11 +21,11 @@ public class MyNote {
return
description
;
}
public
boolean
is
a
rchived
()
{
public
boolean
is
A
rchived
()
{
return
isarchived
;
}
public
void
set
a
rchived
(
boolean
archived
)
{
public
void
set
A
rchived
(
boolean
archived
)
{
isarchived
=
archived
;
}
...
...
app/src/main/java/com/example/mynotepad/MenuFeatures/AllNotes/Note/NoteFragment.java
View file @
59b10593
...
...
@@ -14,9 +14,10 @@ import android.view.ViewGroup;
import
android.widget.EditText
;
import
android.widget.Toast
;
import
com.example.mynotepad.MenuFeatures.AllNotes.AllNotesActivity
;
import
com.example.mynotepad.MenuFeatures.AllNotes.AllNotesListFragment
;
import
com.example.mynotepad.MenuFeatures.AllNotes.DataBase.DateEntity
;
import
com.example.mynotepad.MenuFeatures.AllNotes.DataBase.Note
;
import
com.example.mynotepad.MenuFeatures.Calender.CalenderNotesListFragment
;
import
com.example.mynotepad.R
;
import
com.google.android.material.floatingactionbutton.FloatingActionButton
;
...
...
@@ -28,22 +29,22 @@ import static com.example.mynotepad.MainActivity.noteDataBase;
*/
public
class
NoteFragment
extends
Fragment
{
private
Note
note
;
DateEntity
dateEntity
;
private
EditText
titleTxt
,
bodyTxt
;
private
FloatingActionButton
back
;
private
boolean
isAnewNote
;
private
String
type
;
public
NoteFragment
()
{
}
public
NoteFragment
(
boolean
isAnewNote
)
{
this
.
isAnewNote
=
isAnewNote
;
}
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
// Inflate the layout for this fragment
final
View
v
=
inflater
.
inflate
(
R
.
layout
.
fragment_note
,
container
,
false
);
init
(
v
);
isAnewNote
=
true
;
return
v
;
}
...
...
@@ -76,7 +77,10 @@ public class NoteFragment extends Fragment {
alert
.
setPositiveButton
(
"yes"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
saveNote
();
if
(
type
.
equals
(
"note"
))
saveNote
();
else
if
(
type
.
equals
(
"date"
))
saveCalenderNote
();
if
(
getActivity
()
!=
null
)
getActivity
().
onBackPressed
();
}
...
...
@@ -98,7 +102,19 @@ 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
(),
AllNotesListFragment
.
myChosenNote
.
isarchived
(),
AllNotesListFragment
.
myChosenNote
.
getId
());
noteDataBase
.
noteDao
().
updateNote
(
titleTxt
.
getText
().
toString
(),
bodyTxt
.
getText
().
toString
(),
AllNotesListFragment
.
myChosenNote
.
isArchived
(),
AllNotesListFragment
.
myChosenNote
.
getId
());
Toast
.
makeText
(
getActivity
(),
"updated"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
private
void
saveCalenderNote
()
{
if
(
isAnewNote
)
{
dateEntity
=
new
DateEntity
(
titleTxt
.
getText
().
toString
(),
bodyTxt
.
getText
().
toString
(),
false
);
noteDataBase
.
dateNoreDAO
().
insertDateNote
(
dateEntity
);
Toast
.
makeText
(
getActivity
(),
"saved"
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
noteDataBase
.
dateNoreDAO
().
updateDate
(
titleTxt
.
getText
().
toString
(),
bodyTxt
.
getText
().
toString
(),
CalenderNotesListFragment
.
myChosenDateNote
.
isArchived
(),
CalenderNotesListFragment
.
myChosenDateNote
.
getId
());
Toast
.
makeText
(
getActivity
(),
"updated"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
...
...
@@ -106,9 +122,11 @@ public class NoteFragment extends Fragment {
private
void
setTitleAndBodyTxt
()
{
Bundle
bundle
=
getArguments
();
isAnewNote
=
false
;
if
(
bundle
!=
null
)
{
titleTxt
.
setText
(
bundle
.
getString
(
"title"
));
bodyTxt
.
setText
(
bundle
.
getString
(
"bodyTxt"
));
type
=
bundle
.
getString
(
"type"
);
}
}
}
\ No newline at end of file
app/src/main/java/com/example/mynotepad/MenuFeatures/Calender/CalenderNotesListFragment.java
0 → 100644
View file @
59b10593
package
com
.
example
.
mynotepad
.
MenuFeatures
.
Calender
;
import
android.app.AlertDialog
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.fragment.app.Fragment
;
import
androidx.navigation.NavController
;
import
androidx.navigation.Navigation
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.FrameLayout
;
import
android.widget.Toast
;
import
com.example.mynotepad.MenuFeatures.AllNotes.DataBase.DateEntity
;
import
com.example.mynotepad.MenuFeatures.AllNotes.Note.NoteFragment
;
import
com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.MyCalenderAdaptor
;
import
com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.OnCalenderItemClickListener
;
import
com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.TimePicker.DatePickerActivity
;
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
com.google.android.material.floatingactionbutton.FloatingActionButton
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
com
.
example
.
mynotepad
.
MainActivity
.
noteDataBase
;
public
class
CalenderNotesListFragment
extends
Fragment
{
private
FloatingActionButton
addDateBtn
;
private
CustomToolbarOption
customToolbarOption
;
private
FrameLayout
calenderToolbar
;
private
RecyclerView
recyclerView
;
private
MyCalenderAdaptor
myAdaptor
;
private
List
<
MyDate
>
myDates
;
private
List
<
DateEntity
>
entityDates
;
public
static
MyDate
myChosenDateNote
;
private
NavController
navController
;
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
// Inflate the layout for this fragment
return
inflater
.
inflate
(
R
.
layout
.
fragment_calender_notes_list
,
container
,
false
);
}
@Override
public
void
onResume
()
{
super
.
onResume
();
LinearLayoutManager
linearLayoutManager
=
new
LinearLayoutManager
(
getContext
(),
LinearLayoutManager
.
VERTICAL
,
false
);
myAdaptor
=
new
MyCalenderAdaptor
(
myDates
);
recyclerView
.
setAdapter
(
myAdaptor
);
recyclerView
.
setLayoutManager
(
linearLayoutManager
);
addListeners
();
}
@Override
public
void
onViewCreated
(
@NonNull
View
view
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onViewCreated
(
view
,
savedInstanceState
);
init
(
view
);
addListeners
();
}
private
void
init
(
View
view
)
{
setAllDateNoteListAndTitles
();
addDateBtn
=
view
.
findViewById
(
R
.
id
.
addDateButton
);
customToolbarOption
=
view
.
findViewById
(
R
.
id
.
calenderCustomToolbarOption
);
customToolbarOption
.
setVisibility
(
View
.
GONE
);
calenderToolbar
=
view
.
findViewById
(
R
.
id
.
calenderToolbar
);
calenderToolbar
.
setEnabled
(
false
);
addDateBtn
=
view
.
findViewById
(
R
.
id
.
addDateButton
);
navController
=
Navigation
.
findNavController
(
view
);
// show list with recycler view
recyclerView
=
view
.
findViewById
(
R
.
id
.
calenderRecyclerView
);
LinearLayoutManager
linearLayoutManager
=
new
LinearLayoutManager
(
getContext
(),
LinearLayoutManager
.
VERTICAL
,
false
);
myAdaptor
=
new
MyCalenderAdaptor
(
myDates
);
recyclerView
.
setAdapter
(
myAdaptor
);
recyclerView
.
setLayoutManager
(
linearLayoutManager
);
}
private
void
addListeners
()
{
addDateBtn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
addNewDateAndDescription
();
}
});
// add listener to recyclerView
myAdaptor
.
setOnCalenderItemClickListener
(
new
OnCalenderItemClickListener
()
{
@Override
public
void
onItemClicked
(
MyDate
myDate
)
{
myChosenDateNote
=
myDate
;
//set noteFragment data
final
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
"title"
,
myChosenDateNote
.
getDate
());
bundle
.
putString
(
"bodyTxt"
,
myChosenDateNote
.
getDescription
());
bundle
.
putString
(
"type"
,
"date"
);
//change the fragment
navController
.
navigate
(
R
.
id
.
action_calenderNotesListFragment_to_noteFragment2
,
bundle
);
}
@Override
public
void
onItemLongClicked
(
MyDate
myDate
)
{
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 archived or not to be saved in database
customToolbarOption
.
setCustomToolbarOptionListener
(
new
CustomToolbarOptionListener
()
{
@Override
public
void
onStarClicked
()
{
starClicked
();
}
@Override
public
void
onDeleteClicked
()
{
deleteClicked
();
}
@Override
public
void
onCloseClicked
()
{
closeClicked
();
}
});
}
private
void
closeClicked
()
{
customToolbarOption
.
setVisibility
(
View
.
GONE
);
calenderToolbar
.
setVisibility
(
View
.
VISIBLE
);
}
private
void
deleteClicked
()
{
AlertDialog
.
Builder
alert
=
new
AlertDialog
.
Builder
(
getContext
());
alert
.
setMessage
(
"are you sure you wanna delete it ??? "
);
alert
.
setPositiveButton
(
"yes"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
noteDataBase
.
dateNoreDAO
().
deleteDateNote
(
entityDates
.
get
(
myDates
.
indexOf
(
myChosenDateNote
)));
LinearLayoutManager
linearLayoutManager
=
new
LinearLayoutManager
(
getContext
(),
LinearLayoutManager
.
VERTICAL
,
false
);
myAdaptor
=
new
MyCalenderAdaptor
(
myDates
);
recyclerView
.
setAdapter
(
myAdaptor
);
recyclerView
.
setLayoutManager
(
linearLayoutManager
);
}
});
alert
.
setNegativeButton
(
"no"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
dialogInterface
.
cancel
();
}
});
alert
.
show
();
calenderToolbar
.
setVisibility
(
View
.
VISIBLE
);
}
private
void
starClicked
()
{
if
(
myChosenDateNote
.
isArchived
())
{
customToolbarOption
.
setBlackStar
();
myChosenDateNote
.
setArchived
(
false
);
updatearchivedDatesInDataBase
();
Toast
.
makeText
(
getContext
(),
"unarchived"
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
customToolbarOption
.
setYellowStar
();
myChosenDateNote
.
setArchived
(
true
);
updatearchivedDatesInDataBase
();
Toast
.
makeText
(
getContext
(),
"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
(
getContext
(),
DatePickerActivity
.
class
);
startActivity
(
intent
);
}
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
app/src/main/java/com/example/mynotepad/MenuFeatures/Calender/MyCalenderActivity.java
View file @
59b10593
...
...
@@ -34,176 +34,11 @@ import static com.example.mynotepad.MainActivity.noteDataBase;
public
class
MyCalenderActivity
extends
AppCompatActivity
{
private
FloatingActionButton
addDateBtn
;
private
CustomToolbarOption
customToolbarOption
;
private
FrameLayout
calenderToolbar
;
private
LinearLayout
allDateListAndTitle
;
private
FrameLayout
fragPlace
;
private
RecyclerView
recyclerView
;
private
MyCalenderAdaptor
myAdaptor
;
private
List
<
MyDate
>
myDates
;
private
List
<
DateEntity
>
entityDates
;
private
MyDate
myChosenDateNote
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_my_calender
);
init
();
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
init
();
}
private
void
init
()
{
setAllDateNoteListAndTitles
();
addDateBtn
=
findViewById
(
R
.
id
.
addDateButton
);
customToolbarOption
=
findViewById
(
R
.
id
.
calenderCustomToolbarOption
);
customToolbarOption
.
setVisibility
(
View
.
GONE
);
calenderToolbar
=
findViewById
(
R
.
id
.
calenderToolbar
);
calenderToolbar
.
setEnabled
(
false
);
addDateBtn
=
findViewById
(
R
.
id
.
addDateButton
);
allDateListAndTitle
=
findViewById
(
R
.
id
.
allDateListAndTitle
);
fragPlace
=
findViewById
(
R
.
id
.
fragmentPlace_calender
);
fragPlace
.
setVisibility
(
View
.
GONE
);
// show list with recycler view
recyclerView
=
findViewById
(
R
.
id
.
calenderRecyclerView
);
LinearLayoutManager
linearLayoutManager
=
new
LinearLayoutManager
(
this
,
LinearLayoutManager
.
VERTICAL
,
false
);
myAdaptor
=
new
MyCalenderAdaptor
(
myDates
);
recyclerView
.
setAdapter
(
myAdaptor
);
recyclerView
.
setLayoutManager
(
linearLayoutManager
);
addListeners
();
}
private
void
addListeners
()
{
addDateBtn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
addNewDateAndDescription
();
}
});
// add listener to recyclerView
myAdaptor
.
setOnCalenderItemClickListener
(
new
OnCalenderItemClickListener
()
{
@Override
public
void
onItemClicked
(
MyDate
myDate
)
{
myChosenDateNote
=
myDate
;
//set noteFragment data
final
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
"title"
,
myChosenDateNote
.
getDate
());
bundle
.
putString
(
"bodyTxt"
,
myChosenDateNote
.
getDescription
());
final
NoteFragment
newNoteFrag
=
new
NoteFragment
(
false
);
newNoteFrag
.
setArguments
(
bundle
);
//change the fragment
/* fragPlace.setVisibility(View.VISIBLE);
allNoteListAndTitle.setVisibility(View.GONE);
addNoteButton.hide();
replaceFragment(newNoteFrag);*/
//toDo go to activity/fragment
}
@Override
public
void
onItemLongClicked
(
MyDate
myDate
)
{
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 archived or not to be saved in database
customToolbarOption
.
setCustomToolbarOptionListener
(
new
CustomToolbarOptionListener
()
{
@Override
public
void
onStarClicked
()
{
starClicked
();
}
@Override
public
void
onDeleteClicked
()
{
deleteClicked
();
}
@Override
public
void
onCloseClicked
()
{
closeClicked
();
}
});
}
private
void
closeClicked
()
{
customToolbarOption
.
setVisibility
(
View
.
GONE
);
calenderToolbar
.
setVisibility
(
View
.
VISIBLE
);
}
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
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
noteDataBase
.
dateNoreDAO
().
deleteDateNote
(
entityDates
.
get
(
myDates
.
indexOf
(
myChosenDateNote
)));
init
();
}
});
alert
.
setNegativeButton
(
"no"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
dialogInterface
.
cancel
();
}
});
alert
.
show
();
calenderToolbar
.
setVisibility
(
View
.
VISIBLE
);
}
private
void
starClicked
()
{
if
(
myChosenDateNote
.
isarchived
())
{
customToolbarOption
.
setBlackStar
();
myChosenDateNote
.
setarchived
(
false
);
updatearchivedDatesInDataBase
();
Toast
.
makeText
(
this
,
"unarchived"
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
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
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
app/src/main/java/com/example/mynotepad/MenuFeatures/Calender/MyCalenderRecyclerView/MyCalenderAdaptor.java
View file @
59b10593
...
...
@@ -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
.
isarchived
=
dates
.
get
(
position
).
is
a
rchived
();
holder
.
isarchived
=
dates
.
get
(
position
).
is
A
rchived
();
}
@Override
...
...
app/src/main/java/com/example/mynotepad/MenuFeatures/Calender/MyCalenderRecyclerView/TimePicker/MyDate.java
View file @
59b10593
...
...
@@ -3,13 +3,13 @@ package com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.TimeP
public
class
MyDate
{
private
String
date
,
description
;
private
boolean
is
a
rchived
;
private
boolean
is
A
rchived
;
int
id
;
public
MyDate
(
String
date
,
String
description
,
boolean
isarchived
,
int
id
)
{
this
.
date
=
date
;
this
.
description
=
description
;
this
.
is
a
rchived
=
isarchived
;
this
.
is
A
rchived
=
isarchived
;
this
.
id
=
id
;
}
...
...
@@ -21,12 +21,12 @@ public class MyDate {
return
description
;
}
public
boolean
is
a
rchived
()
{
return
is
a
rchived
;
public
boolean
is
A
rchived
()
{
return
is
A
rchived
;
}
public
void
set
a
rchived
(
boolean
archived
)
{
is
a
rchived
=
archived
;
public
void
set
A
rchived
(
boolean
archived
)
{
is
A
rchived
=
archived
;
}
public
int
getId
()
{
...
...
app/src/main/res/layout/activity_my_calender.xml
View file @
59b10593
<?xml version="1.0" encoding="utf-8"?>
<
Frame
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<
Linear
Layout
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"
android:orientation=
"vertical"
tools:context=
".MenuFeatures.Calender.MyCalenderActivity"
>
<FrameLayout
android:id=
"@+id/fragmentPlace_calender"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<LinearLayout
android:id=
"@+id/allDateListAndTitle"
<fragment
android:id=
"@+id/fragment_container"
android:name=
"androidx.navigation.fragment.NavHostFragment"
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/calenderToolbar"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<ImageView
android:id=
"@+id/imageView7"
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_gravity=
"center_vertical"
android:layout_marginLeft=
"10dp"
android:enabled=
"false"
android:text=
"@string/calender"
android:textColor=
"#02091E"
android:textSize=
"26dp"
/>
</FrameLayout>
<com.example.mynotepad.MenuFeatures.CustomToolbarOption
android:id=
"@+id/calenderCustomToolbarOption"
android:layout_width=
"match_parent"
android:layout_height=
"50dp"
/>
</FrameLayout>
<FrameLayout
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/calenderRecyclerView"
android:layout_width=
"409dp"
android:layout_height=
"match_parent"
android:background=
"#4883B5DD"
tools:layout_editor_absoluteX=
"1dp"
tools:layout_editor_absoluteY=
"1dp"
/>
app:defaultNavHost=
"true"
app:navGraph=
"@navigation/nav_calender"
/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id=
"@+id/addDateButton"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentBottom=
"true"
android:layout_alignParentRight=
"true"
android:layout_marginRight=
"30dp"
android:layout_marginBottom=
"30dp"
android:clickable=
"true"
android:src=
"@drawable/add"
app:backgroundTint=
"#5266D5"
tools:layout_editor_absoluteX=
"310dp"
tools:layout_editor_absoluteY=
"612dp"
/>
</RelativeLayout>
</FrameLayout>
</LinearLayout>
</FrameLayout>
\ No newline at end of file
</LinearLayout>
\ No newline at end of file
app/src/main/res/layout/fragment_calender_notes_list.xml
0 → 100644
View file @
59b10593
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
android:orientation=
"vertical"
tools:context=
".MenuFeatures.Calender.CalenderNotesListFragment"
>
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<FrameLayout
android:id=
"@+id/calenderToolbar"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<ImageView
android:id=
"@+id/imageView7"
android:layout_width=
"match_parent"
android:layout_height=
"50dp"
android:scaleType=
"fitXY"
app:srcCompat=
"@drawable/index"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginLeft=
"10dp"
android:enabled=
"false"
android:text=
"@string/calender"
android:textColor=
"#02091E"
android:textSize=
"26dp"
android:layout_marginStart=
"10dp"
tools:ignore=
"SpUsage"
/>
</FrameLayout>
<com.example.mynotepad.MenuFeatures.CustomToolbarOption
android:id=
"@+id/calenderCustomToolbarOption"
android:layout_width=
"match_parent"
android:layout_height=
"50dp"
/>
</FrameLayout>
<FrameLayout
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:ignore=
"UselessParent"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/calenderRecyclerView"
android:layout_width=
"409dp"
android:layout_height=
"match_parent"
android:background=
"#4883B5DD"
tools:layout_editor_absoluteX=
"1dp"
tools:layout_editor_absoluteY=
"1dp"
/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id=
"@+id/addDateButton"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentRight=
"true"
android:layout_alignParentBottom=
"true"
android:layout_marginRight=
"30dp"
android:layout_marginBottom=
"30dp"
android:clickable=
"true"
android:src=
"@drawable/add"
app:backgroundTint=
"#5266D5"
tools:layout_editor_absoluteX=
"310dp"
tools:layout_editor_absoluteY=
"612dp"
tools:ignore=
"KeyboardInaccessibleWidget,RtlHardcoded"
/>
</RelativeLayout>
</FrameLayout>
</LinearLayout>
\ No newline at end of file
app/src/main/res/navigation/nav_calender.xml
0 → 100644
View file @
59b10593
<?xml version="1.0" encoding="utf-8"?>
<navigation
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/nav_calender"
app:startDestination=
"@id/calenderNotesListFragment"
>
<fragment
android:id=
"@+id/calenderNotesListFragment"
android:name=
"com.example.mynotepad.MenuFeatures.Calender.CalenderNotesListFragment"
android:label=
"fragment_calender_notes_list"
tools:layout=
"@layout/fragment_calender_notes_list"
>
<action
android:id=
"@+id/action_calenderNotesListFragment_to_noteFragment2"
app:destination=
"@id/noteFragment2"
app:exitAnim=
"@anim/fade_out"
app:enterAnim=
"@anim/slide_in"
app:popEnterAnim=
"@anim/fade_in"
app:popExitAnim=
"@anim/slide_out"
/>
</fragment>
<fragment
android:id=
"@+id/noteFragment2"
android:name=
"com.example.mynotepad.MenuFeatures.AllNotes.Note.NoteFragment"
android:label=
"NoteFragment"
/>
</navigation>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment