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 {
...
@@ -85,13 +85,11 @@ public class ArchivedNotesActivity extends AppCompatActivity {
final
Bundle
bundle
=
new
Bundle
();
final
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
"title"
,
item
.
getTitle
());
bundle
.
putString
(
"title"
,
item
.
getTitle
());
bundle
.
putString
(
"bodyTxt"
,
item
.
getDescription
());
bundle
.
putString
(
"bodyTxt"
,
item
.
getDescription
());
final
NoteFragment
newNoteFrag
=
new
NoteFragment
(
false
);
newNoteFrag
.
setArguments
(
bundle
);
//change the fragment
//change the fragment
fragPlace
.
setVisibility
(
View
.
VISIBLE
);
fragPlace
.
setVisibility
(
View
.
VISIBLE
);
allNoteListAndTitle
.
setVisibility
(
View
.
GONE
);
allNoteListAndTitle
.
setVisibility
(
View
.
GONE
);
replaceFragment
(
newNoteFrag
);
//todo
}
}
else
if
(
item
.
getType
().
equals
(
"date"
)){
else
if
(
item
.
getType
().
equals
(
"date"
)){
//todo go to fragment
//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
...
@@ -33,7 +33,7 @@ public class MyArchivedAdaptor extends RecyclerView.Adapter<MyArchivedAdaptor.Vi
private
void
setDates
()
{
private
void
setDates
()
{
for
(
MyDate
myDate
:
dates
)
{
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
());
DateOrNote
date
=
new
DateOrNote
(
myDate
.
getId
(),
"date"
,
myDate
.
getDate
(),
myDate
.
getDescription
());
dateOrNoteList
.
add
(
date
);
dateOrNoteList
.
add
(
date
);
}
}
...
@@ -42,7 +42,7 @@ public class MyArchivedAdaptor extends RecyclerView.Adapter<MyArchivedAdaptor.Vi
...
@@ -42,7 +42,7 @@ public class MyArchivedAdaptor extends RecyclerView.Adapter<MyArchivedAdaptor.Vi
private
void
setNotes
()
{
private
void
setNotes
()
{
for
(
MyNote
myNote
:
notes
)
{
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
());
DateOrNote
note
=
new
DateOrNote
(
myNote
.
getId
(),
"note"
,
myNote
.
getTitle
(),
myNote
.
getDescription
());
dateOrNoteList
.
add
(
note
);
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;
...
@@ -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.MyAllNotesAdaptor
;
import
com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.MyNote
;
import
com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.MyNote
;
import
com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.OnAllNotesItemClickListener
;
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.CustomToolbarOption
;
import
com.example.mynotepad.MenuFeatures.CustomToolbarOptionListener
;
import
com.example.mynotepad.MenuFeatures.CustomToolbarOptionListener
;
import
com.example.mynotepad.R
;
import
com.example.mynotepad.R
;
...
@@ -94,6 +93,7 @@ public class AllNotesListFragment extends Fragment {
...
@@ -94,6 +93,7 @@ public class AllNotesListFragment extends Fragment {
final
Bundle
bundle
=
new
Bundle
();
final
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
"title"
,
myNote
.
getTitle
());
bundle
.
putString
(
"title"
,
myNote
.
getTitle
());
bundle
.
putString
(
"bodyTxt"
,
myNote
.
getDescription
());
bundle
.
putString
(
"bodyTxt"
,
myNote
.
getDescription
());
bundle
.
putString
(
"type"
,
"note"
);
//change the fragment
//change the fragment
navController
.
navigate
(
R
.
id
.
action_allNotesListFragment_to_noteFragment
,
bundle
);
navController
.
navigate
(
R
.
id
.
action_allNotesListFragment_to_noteFragment
,
bundle
);
...
@@ -104,7 +104,7 @@ public class AllNotesListFragment extends Fragment {
...
@@ -104,7 +104,7 @@ public class AllNotesListFragment extends Fragment {
customToolbarOption
.
setVisibility
(
View
.
VISIBLE
);
customToolbarOption
.
setVisibility
(
View
.
VISIBLE
);
allNoteToolBar
.
setVisibility
(
View
.
GONE
);
allNoteToolBar
.
setVisibility
(
View
.
GONE
);
myChosenNote
=
myNote
;
myChosenNote
=
myNote
;
if
(
myChosenNote
.
is
a
rchived
()){
if
(
myChosenNote
.
is
A
rchived
()){
customToolbarOption
.
setYellowStar
();
customToolbarOption
.
setYellowStar
();
}
}
else
{
else
{
...
@@ -166,14 +166,14 @@ public class AllNotesListFragment extends Fragment {
...
@@ -166,14 +166,14 @@ public class AllNotesListFragment extends Fragment {
}
}
protected
void
starClicked
()
{
protected
void
starClicked
()
{
if
(
myChosenNote
.
is
a
rchived
())
{
if
(
myChosenNote
.
is
A
rchived
())
{
customToolbarOption
.
setBlackStar
();
customToolbarOption
.
setBlackStar
();
myChosenNote
.
set
a
rchived
(
false
);
myChosenNote
.
set
A
rchived
(
false
);
updatearchivedNotesInDataBase
();
updatearchivedNotesInDataBase
();
Toast
.
makeText
(
getContext
(),
"unarchived"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
getContext
(),
"unarchived"
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
}
else
{
customToolbarOption
.
setYellowStar
();
customToolbarOption
.
setYellowStar
();
myChosenNote
.
set
a
rchived
(
true
);
myChosenNote
.
set
A
rchived
(
true
);
updatearchivedNotesInDataBase
();
updatearchivedNotesInDataBase
();
Toast
.
makeText
(
getContext
(),
"archived"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
getContext
(),
"archived"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
...
@@ -181,7 +181,7 @@ public class AllNotesListFragment extends Fragment {
...
@@ -181,7 +181,7 @@ public class AllNotesListFragment extends Fragment {
private
void
updatearchivedNotesInDataBase
()
{
private
void
updatearchivedNotesInDataBase
()
{
noteDataBase
.
noteDao
().
updateNote
(
myChosenNote
.
getTitle
(),
myChosenNote
.
getDescription
()
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
...
@@ -31,7 +31,7 @@ public class MyAllNotesAdaptor extends RecyclerView.Adapter<MyAllNotesAdaptor.Vi
public
void
onBindViewHolder
(
ViewHolder
holder
,
int
position
)
{
public
void
onBindViewHolder
(
ViewHolder
holder
,
int
position
)
{
holder
.
titleTV
.
setText
(
notes
.
get
(
position
).
getTitle
());
holder
.
titleTV
.
setText
(
notes
.
get
(
position
).
getTitle
());
holder
.
descriptionTV
.
setText
(
notes
.
get
(
position
).
getDescription
());
holder
.
descriptionTV
.
setText
(
notes
.
get
(
position
).
getDescription
());
holder
.
isarchived
=
notes
.
get
(
position
).
is
a
rchived
();
holder
.
isarchived
=
notes
.
get
(
position
).
is
A
rchived
();
}
}
@Override
@Override
...
...
app/src/main/java/com/example/mynotepad/MenuFeatures/AllNotes/MyNoteRecyclerView/MyNote.java
View file @
59b10593
...
@@ -21,11 +21,11 @@ public class MyNote {
...
@@ -21,11 +21,11 @@ public class MyNote {
return
description
;
return
description
;
}
}
public
boolean
is
a
rchived
()
{
public
boolean
is
A
rchived
()
{
return
isarchived
;
return
isarchived
;
}
}
public
void
set
a
rchived
(
boolean
archived
)
{
public
void
set
A
rchived
(
boolean
archived
)
{
isarchived
=
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;
...
@@ -14,9 +14,10 @@ import android.view.ViewGroup;
import
android.widget.EditText
;
import
android.widget.EditText
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.example.mynotepad.MenuFeatures.AllNotes.AllNotesActivity
;
import
com.example.mynotepad.MenuFeatures.AllNotes.AllNotesListFragment
;
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.AllNotes.DataBase.Note
;
import
com.example.mynotepad.MenuFeatures.Calender.CalenderNotesListFragment
;
import
com.example.mynotepad.R
;
import
com.example.mynotepad.R
;
import
com.google.android.material.floatingactionbutton.FloatingActionButton
;
import
com.google.android.material.floatingactionbutton.FloatingActionButton
;
...
@@ -28,22 +29,22 @@ import static com.example.mynotepad.MainActivity.noteDataBase;
...
@@ -28,22 +29,22 @@ import static com.example.mynotepad.MainActivity.noteDataBase;
*/
*/
public
class
NoteFragment
extends
Fragment
{
public
class
NoteFragment
extends
Fragment
{
private
Note
note
;
private
Note
note
;
DateEntity
dateEntity
;
private
EditText
titleTxt
,
bodyTxt
;
private
EditText
titleTxt
,
bodyTxt
;
private
FloatingActionButton
back
;
private
FloatingActionButton
back
;
private
boolean
isAnewNote
;
private
boolean
isAnewNote
;
private
String
type
;
public
NoteFragment
()
{
public
NoteFragment
()
{
}
}
public
NoteFragment
(
boolean
isAnewNote
)
{
this
.
isAnewNote
=
isAnewNote
;
}
@Override
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
// Inflate the layout for this fragment
// Inflate the layout for this fragment
final
View
v
=
inflater
.
inflate
(
R
.
layout
.
fragment_note
,
container
,
false
);
final
View
v
=
inflater
.
inflate
(
R
.
layout
.
fragment_note
,
container
,
false
);
init
(
v
);
init
(
v
);
isAnewNote
=
true
;
return
v
;
return
v
;
}
}
...
@@ -76,7 +77,10 @@ public class NoteFragment extends Fragment {
...
@@ -76,7 +77,10 @@ public class NoteFragment extends Fragment {
alert
.
setPositiveButton
(
"yes"
,
new
DialogInterface
.
OnClickListener
()
{
alert
.
setPositiveButton
(
"yes"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
saveNote
();
if
(
type
.
equals
(
"note"
))
saveNote
();
else
if
(
type
.
equals
(
"date"
))
saveCalenderNote
();
if
(
getActivity
()
!=
null
)
if
(
getActivity
()
!=
null
)
getActivity
().
onBackPressed
();
getActivity
().
onBackPressed
();
}
}
...
@@ -98,7 +102,19 @@ public class NoteFragment extends Fragment {
...
@@ -98,7 +102,19 @@ public class NoteFragment extends Fragment {
noteDataBase
.
noteDao
().
insertNote
(
note
);
noteDataBase
.
noteDao
().
insertNote
(
note
);
Toast
.
makeText
(
getActivity
(),
"saved"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
getActivity
(),
"saved"
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
}
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
();
Toast
.
makeText
(
getActivity
(),
"updated"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
}
}
...
@@ -106,9 +122,11 @@ public class NoteFragment extends Fragment {
...
@@ -106,9 +122,11 @@ public class NoteFragment extends Fragment {
private
void
setTitleAndBodyTxt
()
{
private
void
setTitleAndBodyTxt
()
{
Bundle
bundle
=
getArguments
();
Bundle
bundle
=
getArguments
();
isAnewNote
=
false
;
if
(
bundle
!=
null
)
{
if
(
bundle
!=
null
)
{
titleTxt
.
setText
(
bundle
.
getString
(
"title"
));
titleTxt
.
setText
(
bundle
.
getString
(
"title"
));
bodyTxt
.
setText
(
bundle
.
getString
(
"bodyTxt"
));
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;
...
@@ -34,176 +34,11 @@ import static com.example.mynotepad.MainActivity.noteDataBase;
public
class
MyCalenderActivity
extends
AppCompatActivity
{
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
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_my_calender
);
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
...
@@ -32,7 +32,7 @@ public class MyCalenderAdaptor extends RecyclerView.Adapter<MyCalenderAdaptor.Ca
public
void
onBindViewHolder
(
@NonNull
CalenderViewHolder
holder
,
int
position
)
{
public
void
onBindViewHolder
(
@NonNull
CalenderViewHolder
holder
,
int
position
)
{
holder
.
dateTV
.
setText
(
dates
.
get
(
position
).
getDate
());
holder
.
dateTV
.
setText
(
dates
.
get
(
position
).
getDate
());
holder
.
descriptionTV
.
setText
(
dates
.
get
(
position
).
getDescription
());
holder
.
descriptionTV
.
setText
(
dates
.
get
(
position
).
getDescription
());
holder
.
isarchived
=
dates
.
get
(
position
).
is
a
rchived
();
holder
.
isarchived
=
dates
.
get
(
position
).
is
A
rchived
();
}
}
@Override
@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
...
@@ -3,13 +3,13 @@ package com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.TimeP
public
class
MyDate
{
public
class
MyDate
{
private
String
date
,
description
;
private
String
date
,
description
;
private
boolean
is
a
rchived
;
private
boolean
is
A
rchived
;
int
id
;
int
id
;
public
MyDate
(
String
date
,
String
description
,
boolean
isarchived
,
int
id
)
{
public
MyDate
(
String
date
,
String
description
,
boolean
isarchived
,
int
id
)
{
this
.
date
=
date
;
this
.
date
=
date
;
this
.
description
=
description
;
this
.
description
=
description
;
this
.
is
a
rchived
=
isarchived
;
this
.
is
A
rchived
=
isarchived
;
this
.
id
=
id
;
this
.
id
=
id
;
}
}
...
@@ -21,12 +21,12 @@ public class MyDate {
...
@@ -21,12 +21,12 @@ public class MyDate {
return
description
;
return
description
;
}
}
public
boolean
is
a
rchived
()
{
public
boolean
is
A
rchived
()
{
return
is
a
rchived
;
return
is
A
rchived
;
}
}
public
void
set
a
rchived
(
boolean
archived
)
{
public
void
set
A
rchived
(
boolean
archived
)
{
is
a
rchived
=
archived
;
is
A
rchived
=
archived
;
}
}
public
int
getId
()
{
public
int
getId
()
{
...
...
app/src/main/res/layout/activity_my_calender.xml
View file @
59b10593
<?xml version="1.0" encoding="utf-8"?>
<?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:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
tools:context=
".MenuFeatures.Calender.MyCalenderActivity"
>
tools:context=
".MenuFeatures.Calender.MyCalenderActivity"
>
<FrameLayout
<fragment
android:id=
"@+id/fragmentPlace_calender"
android:id=
"@+id/fragment_container"
android:layout_width=
"match_parent"
android:name=
"androidx.navigation.fragment.NavHostFragment"
android:layout_height=
"match_parent"
/>
<LinearLayout
android:id=
"@+id/allDateListAndTitle"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"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
app:defaultNavHost=
"true"
android:id=
"@+id/calenderRecyclerView"
app:navGraph=
"@navigation/nav_calender"
/>
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
</LinearLayout>
android:id=
"@+id/addDateButton"
\ No newline at end of file
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
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