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
f0633d15
Commit
f0633d15
authored
Oct 05, 2020
by
9731301
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change all notes structure to navigation
parent
e27b1a0d
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
394 additions
and
333 deletions
+394
-333
MainActivity.java
app/src/main/java/com/example/mynotepad/MainActivity.java
+8
-5
ArchivedNotesActivity.java
.../MenuFeatures/AllArchivedNotes/ArchivedNotesActivity.java
+16
-2
AllNotesActivity.java
...ple/mynotepad/MenuFeatures/AllNotes/AllNotesActivity.java
+0
-217
AllNotesListFragment.java
...mynotepad/MenuFeatures/AllNotes/AllNotesListFragment.java
+223
-0
NoteFragment.java
...le/mynotepad/MenuFeatures/AllNotes/Note/NoteFragment.java
+11
-8
AudioListFragment.java
...notepad/MenuFeatures/VoiceMassages/AudioListFragment.java
+0
-1
VoiceMassagesActivity.java
...pad/MenuFeatures/VoiceMassages/VoiceMassagesActivity.java
+0
-22
VoiceAdaptor.java
...VoiceMassages/VoiceMassagesRecyclerView/VoiceAdaptor.java
+3
-3
menu_anim_close.xml
app/src/main/res/anim/menu_anim_close.xml
+10
-0
menu_anim_open.xml
app/src/main/res/anim/menu_anim_open.xml
+12
-0
activity_all_notes.xml
app/src/main/res/layout/activity_all_notes.xml
+7
-75
fragment_all_notes_list.xml
app/src/main/res/layout/fragment_all_notes_list.xml
+78
-0
nav_notes.xml
app/src/main/res/navigation/nav_notes.xml
+26
-0
No files found.
app/src/main/java/com/example/mynotepad/MainActivity.java
View file @
f0633d15
...
...
@@ -3,10 +3,11 @@ package com.example.mynotepad;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.room.Room
;
import
android.animation.ObjectAnimator
;
import
android.os.Bundle
;
import
android.view.Gravity
;
import
android.view.View
;
import
android.view.animation.Animation
;
import
android.view.animation.AnimationUtils
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
...
...
@@ -22,7 +23,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
private
TextView
wlcTxt
;
private
Information
informationView
;
public
static
NoteDataBase
noteDataBase
;
private
ObjectAnimator
objectAnimator
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -54,7 +54,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
findViewById
(
R
.
id
.
main
).
setOnClickListener
(
this
);
customMenu
.
setOnClickListener
(
this
);
objectAnimator
=
ObjectAnimator
.
ofFloat
(
customMenu
,
"x"
,
400
);
customMenu
.
setInfoClickListener
(
new
InfoClickListener
()
{
@Override
public
void
onInfoTvClicked
(
TextView
infoTv
)
{
...
...
@@ -68,11 +67,15 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
@Override
public
void
onClick
(
View
view
)
{
if
(
view
.
getId
()
==
toolbarListImg
.
getId
()
||
customMenu
.
getId
()
==
view
.
getId
())
{
objectAnimator
.
setDuration
(
2000
);
objectAnimator
.
start
();
if
(
view
.
getId
()
==
toolbarListImg
.
getId
()){
//start animation
Animation
animOpen
=
AnimationUtils
.
loadAnimation
(
this
,
R
.
anim
.
menu_anim_open
);
customMenu
.
startAnimation
(
animOpen
);
}
customMenu
.
setVisibility
(
customMenu
.
VISIBLE
);
informationView
.
setVisibility
(
View
.
GONE
);
}
else
if
(
R
.
id
.
main
==
view
.
getId
())
{
if
(
customMenu
.
getVisibility
()
==
View
.
VISIBLE
)
customMenu
.
startAnimation
(
AnimationUtils
.
loadAnimation
(
this
,
R
.
anim
.
menu_anim_close
));
customMenu
.
setVisibility
(
customMenu
.
GONE
);
informationView
.
setVisibility
(
View
.
GONE
);
}
...
...
app/src/main/java/com/example/mynotepad/MenuFeatures/AllArchivedNotes/ArchivedNotesActivity.java
View file @
f0633d15
package
com
.
example
.
mynotepad
.
MenuFeatures
.
AllArchivedNotes
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.fragment.app.Fragment
;
import
androidx.fragment.app.FragmentTransaction
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
android.os.Bundle
;
...
...
@@ -24,7 +27,7 @@ import java.util.List;
import
static
com
.
example
.
mynotepad
.
MainActivity
.
noteDataBase
;
public
class
ArchivedNotesActivity
extends
A
llNotes
Activity
{
public
class
ArchivedNotesActivity
extends
A
ppCompat
Activity
{
private
FrameLayout
fragPlace
;
private
LinearLayout
allNoteListAndTitle
;
...
...
@@ -37,7 +40,7 @@ public class ArchivedNotesActivity extends AllNotesActivity {
private
List
<
MyNote
>
myNotes
;
private
List
<
MyDate
>
myDates
;
private
DateOrNote
chosenDateOrNote
;
private
FragmentTransaction
fragmentTransaction
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
@@ -157,4 +160,15 @@ public class ArchivedNotesActivity extends AllNotesActivity {
myDates
.
add
(
myDate
);
}
}
public
void
replaceFragment
(
Fragment
fragment
)
{
fragmentTransaction
=
getSupportFragmentManager
().
beginTransaction
();
fragmentTransaction
.
replace
(
fragPlace
.
getId
(),
fragment
);
fragmentTransaction
.
commit
();
}
protected
void
closeClicked
(
CustomToolbarOption
customToolbarOption
)
{
customToolbarOption
.
setVisibility
(
View
.
GONE
);
allNoteToolBar
.
setVisibility
(
View
.
VISIBLE
);
}
}
\ No newline at end of file
app/src/main/java/com/example/mynotepad/MenuFeatures/AllNotes/AllNotesActivity.java
View file @
f0633d15
package
com
.
example
.
mynotepad
.
MenuFeatures
.
AllNotes
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.fragment.app.Fragment
;
import
androidx.fragment.app.FragmentTransaction
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
android.app.AlertDialog
;
import
android.content.DialogInterface
;
import
android.os.Bundle
;
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
;
import
com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.OnAllNotesItemClickListener
;
import
com.example.mynotepad.MenuFeatures.AllNotes.Note.NoteFragment
;
import
com.example.mynotepad.MenuFeatures.AllNotes.DataBase.Note
;
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.HashMap
;
import
java.util.List
;
import
static
com
.
example
.
mynotepad
.
MainActivity
.
noteDataBase
;
public
class
AllNotesActivity
extends
AppCompatActivity
{
private
FrameLayout
fragPlace
;
private
LinearLayout
allNoteListAndTitle
;
private
FloatingActionButton
addNoteButton
;
private
FragmentTransaction
fragmentTransaction
;
private
CustomToolbarOption
customToolbarOption
;
private
FrameLayout
allNoteToolBar
;
private
RecyclerView
recyclerView
;
private
MyAllNotesAdaptor
myAdaptor
;
private
List
<
Note
>
entityNotes
;
private
List
<
MyNote
>
myNotes
;
private
static
MyNote
myChosenNote
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_all_notes
);
init
();
}
private
void
init
()
{
// get data from database
setAllNoteListAndTitles
();
customToolbarOption
=
findViewById
(
R
.
id
.
customToolbarOption
);
customToolbarOption
.
setVisibility
(
View
.
GONE
);
allNoteToolBar
=
findViewById
(
R
.
id
.
allNotesToolbar
);
allNoteToolBar
.
setEnabled
(
false
);
addNoteButton
=
findViewById
(
R
.
id
.
addNoteButton
);
allNoteListAndTitle
=
findViewById
(
R
.
id
.
allNoteListAndTitle
);
fragPlace
=
findViewById
(
R
.
id
.
fragmentPlace
);
fragPlace
.
setVisibility
(
View
.
GONE
);
// show list with recycler view
recyclerView
=
findViewById
(
R
.
id
.
recyclerView
);
LinearLayoutManager
linearLayoutManager
=
new
LinearLayoutManager
(
this
,
LinearLayoutManager
.
VERTICAL
,
false
);
myAdaptor
=
new
MyAllNotesAdaptor
(
myNotes
);
recyclerView
.
setLayoutManager
(
linearLayoutManager
);
recyclerView
.
setAdapter
(
myAdaptor
);
addListeners
();
}
private
void
addListeners
()
{
addNoteButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
showAddAlert
();
}
});
// add listener to recyclerView
myAdaptor
.
setOnItemClickListener
(
new
OnAllNotesItemClickListener
()
{
@Override
public
void
onItemClicked
(
MyNote
myNote
)
{
myChosenNote
=
myNote
;
//set noteFragment data
final
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
"title"
,
myNote
.
getTitle
());
bundle
.
putString
(
"bodyTxt"
,
myNote
.
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
);
}
@Override
public
void
onItemLongClicked
(
MyNote
myNote
)
{
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 archived or not to be saved in database
customToolbarOption
.
setCustomToolbarOptionListener
(
new
CustomToolbarOptionListener
()
{
@Override
public
void
onStarClicked
()
{
starClicked
();
}
@Override
public
void
onDeleteClicked
()
{
Note
note
=
entityNotes
.
get
(
myNotes
.
indexOf
(
myChosenNote
));
deleteClicked
(
note
);
}
@Override
public
void
onCloseClicked
()
{
closeClicked
(
customToolbarOption
);
}
});
}
protected
void
closeClicked
(
CustomToolbarOption
customToolbarOption
)
{
customToolbarOption
.
setVisibility
(
View
.
GONE
);
allNoteToolBar
.
setVisibility
(
View
.
VISIBLE
);
}
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
(
note
);
init
();
}
});
alert
.
setNegativeButton
(
"no"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
dialogInterface
.
cancel
();
}
});
alert
.
show
();
allNoteToolBar
.
setVisibility
(
View
.
VISIBLE
);
}
protected
void
starClicked
()
{
if
(
myChosenNote
.
isarchived
())
{
customToolbarOption
.
setBlackStar
();
myChosenNote
.
setarchived
(
false
);
updatearchivedNotesInDataBase
();
Toast
.
makeText
(
this
,
"unarchived"
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
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
);
alert
.
setTitle
(
"new note :"
);
alert
.
setMessage
(
"Do you want to create a new note ?"
);
alert
.
setCancelable
(
true
);
alert
.
setPositiveButton
(
"yes"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
showABlankNote
();
}
});
alert
.
setNegativeButton
(
"no"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
dialogInterface
.
cancel
();
}
});
alert
.
show
();
}
private
void
showABlankNote
()
{
fragPlace
.
setVisibility
(
View
.
VISIBLE
);
allNoteListAndTitle
.
setVisibility
(
View
.
GONE
);
addNoteButton
.
hide
();
NoteFragment
newNoteFrag
=
new
NoteFragment
(
true
);
replaceFragment
(
newNoteFrag
);
}
public
void
replaceFragment
(
Fragment
fragment
)
{
fragmentTransaction
=
getSupportFragmentManager
().
beginTransaction
();
fragmentTransaction
.
replace
(
fragPlace
.
getId
(),
fragment
);
fragmentTransaction
.
commit
();
}
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
);
}
}
}
\ No newline at end of file
app/src/main/java/com/example/mynotepad/MenuFeatures/AllNotes/AllNotesListFragment.java
0 → 100644
View file @
f0633d15
package
com
.
example
.
mynotepad
.
MenuFeatures
.
AllNotes
;
import
android.app.AlertDialog
;
import
android.content.DialogInterface
;
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.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
;
import
com.google.android.material.floatingactionbutton.FloatingActionButton
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
com
.
example
.
mynotepad
.
MainActivity
.
noteDataBase
;
public
class
AllNotesListFragment
extends
Fragment
{
private
FloatingActionButton
addNoteButton
;
private
CustomToolbarOption
customToolbarOption
;
private
FrameLayout
allNoteToolBar
;
private
RecyclerView
recyclerView
;
private
MyAllNotesAdaptor
myAdaptor
;
private
List
<
Note
>
entityNotes
;
private
List
<
MyNote
>
myNotes
;
public
static
MyNote
myChosenNote
;
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_all_notes_list
,
container
,
false
);
}
@Override
public
void
onViewCreated
(
@NonNull
View
view
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onViewCreated
(
view
,
savedInstanceState
);
init
(
view
);
addListeners
();
}
private
void
init
(
View
view
)
{
// get data from database
setAllNoteListAndTitles
();
customToolbarOption
=
view
.
findViewById
(
R
.
id
.
customToolbarOption
);
customToolbarOption
.
setVisibility
(
View
.
GONE
);
allNoteToolBar
=
view
.
findViewById
(
R
.
id
.
allNotesToolbar
);
allNoteToolBar
.
setEnabled
(
false
);
addNoteButton
=
view
.
findViewById
(
R
.
id
.
addNoteButton
);
navController
=
Navigation
.
findNavController
(
view
);
// show list with recycler view
recyclerView
=
view
.
findViewById
(
R
.
id
.
recyclerView
);
LinearLayoutManager
linearLayoutManager
=
new
LinearLayoutManager
(
getContext
(),
LinearLayoutManager
.
VERTICAL
,
false
);
myAdaptor
=
new
MyAllNotesAdaptor
(
myNotes
);
recyclerView
.
setLayoutManager
(
linearLayoutManager
);
recyclerView
.
setAdapter
(
myAdaptor
);
}
private
void
addListeners
()
{
addNoteButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
showAddAlert
();
}
});
// add listener to recyclerView
myAdaptor
.
setOnItemClickListener
(
new
OnAllNotesItemClickListener
()
{
@Override
public
void
onItemClicked
(
MyNote
myNote
)
{
myChosenNote
=
myNote
;
//set noteFragment data
final
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
"title"
,
myNote
.
getTitle
());
bundle
.
putString
(
"bodyTxt"
,
myNote
.
getDescription
());
//change the fragment
navController
.
navigate
(
R
.
id
.
action_allNotesListFragment_to_noteFragment
,
bundle
);
}
@Override
public
void
onItemLongClicked
(
MyNote
myNote
)
{
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 archived or not to be saved in database
customToolbarOption
.
setCustomToolbarOptionListener
(
new
CustomToolbarOptionListener
()
{
@Override
public
void
onStarClicked
()
{
starClicked
();
}
@Override
public
void
onDeleteClicked
()
{
Note
note
=
entityNotes
.
get
(
myNotes
.
indexOf
(
myChosenNote
));
deleteClicked
(
note
);
}
@Override
public
void
onCloseClicked
()
{
closeClicked
(
customToolbarOption
);
}
});
}
protected
void
closeClicked
(
CustomToolbarOption
customToolbarOption
)
{
customToolbarOption
.
setVisibility
(
View
.
GONE
);
allNoteToolBar
.
setVisibility
(
View
.
VISIBLE
);
}
protected
void
deleteClicked
(
final
Note
note
)
{
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
.
noteDao
().
deleteNote
(
note
);
LinearLayoutManager
linearLayoutManager
=
new
LinearLayoutManager
(
getContext
(),
LinearLayoutManager
.
VERTICAL
,
false
);
myAdaptor
=
new
MyAllNotesAdaptor
(
myNotes
);
recyclerView
.
setLayoutManager
(
linearLayoutManager
);
recyclerView
.
setAdapter
(
myAdaptor
);
}
});
alert
.
setNegativeButton
(
"no"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
dialogInterface
.
cancel
();
}
});
alert
.
show
();
allNoteToolBar
.
setVisibility
(
View
.
VISIBLE
);
}
protected
void
starClicked
()
{
if
(
myChosenNote
.
isarchived
())
{
customToolbarOption
.
setBlackStar
();
myChosenNote
.
setarchived
(
false
);
updatearchivedNotesInDataBase
();
Toast
.
makeText
(
getContext
(),
"unarchived"
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
customToolbarOption
.
setYellowStar
();
myChosenNote
.
setarchived
(
true
);
updatearchivedNotesInDataBase
();
Toast
.
makeText
(
getContext
(),
"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
(
getContext
());
alert
.
setTitle
(
"new note :"
);
alert
.
setMessage
(
"Do you want to create a new note ?"
);
alert
.
setCancelable
(
true
);
alert
.
setPositiveButton
(
"yes"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
showABlankNote
();
}
});
alert
.
setNegativeButton
(
"no"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
dialogInterface
.
cancel
();
}
});
alert
.
show
();
}
private
void
showABlankNote
()
{
navController
.
navigate
(
R
.
id
.
action_allNotesListFragment_to_noteFragment
);
}
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
);
}
}
}
\ No newline at end of file
app/src/main/java/com/example/mynotepad/MenuFeatures/AllNotes/Note/NoteFragment.java
View file @
f0633d15
...
...
@@ -15,6 +15,7 @@ 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.Note
;
import
com.example.mynotepad.R
;
import
com.google.android.material.floatingactionbutton.FloatingActionButton
;
...
...
@@ -31,7 +32,10 @@ public class NoteFragment extends Fragment {
private
FloatingActionButton
back
;
private
boolean
isAnewNote
;
public
NoteFragment
(
boolean
isAnewNote
){
public
NoteFragment
()
{
}
public
NoteFragment
(
boolean
isAnewNote
)
{
this
.
isAnewNote
=
isAnewNote
;
}
...
...
@@ -63,6 +67,7 @@ public class NoteFragment extends Fragment {
}
private
void
showAlert
()
{
final
AlertDialog
.
Builder
alert
=
new
AlertDialog
.
Builder
(
getContext
());
alert
.
setTitle
(
"new note :"
);
...
...
@@ -72,17 +77,15 @@ public class NoteFragment extends Fragment {
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
saveNote
();
getActivity
().
finish
();
if
(
getActivity
()
!=
null
)
getActivity
().
onBackPressed
();
}
});
alert
.
setNegativeButton
(
"no"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
dialogInterface
.
cancel
();
if
(
getActivity
()
!=
null
)
getActivity
().
finish
();
getActivity
().
onBackPressed
();
}
});
alert
.
show
();
...
...
@@ -94,8 +97,8 @@ public class NoteFragment extends Fragment {
note
=
new
Note
(
titleTxt
.
getText
().
toString
(),
bodyTxt
.
getText
().
toString
(),
false
);
noteDataBase
.
noteDao
().
insertNote
(
note
);
Toast
.
makeText
(
getActivity
(),
"saved"
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
noteDataBase
.
noteDao
().
updateNote
(
titleTxt
.
getText
().
toString
()
,
bodyTxt
.
getText
().
toString
()
,
note
.
isarchived
()
,
note
.
getID
());
}
else
{
noteDataBase
.
noteDao
().
updateNote
(
titleTxt
.
getText
().
toString
()
,
bodyTxt
.
getText
().
toString
(),
AllNotesListFragment
.
myChosenNote
.
isarchived
(),
AllNotesListFragment
.
myChosenNote
.
getId
());
Toast
.
makeText
(
getActivity
(),
"updated"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
...
...
app/src/main/java/com/example/mynotepad/MenuFeatures/VoiceMassages/AudioListFragment.java
View file @
f0633d15
...
...
@@ -16,7 +16,6 @@ import android.view.LayoutInflater;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ImageButton
;
import
android.widget.LinearLayout
;
import
android.widget.SeekBar
;
import
android.widget.TextView
;
...
...
app/src/main/java/com/example/mynotepad/MenuFeatures/VoiceMassages/VoiceMassagesActivity.java
View file @
f0633d15
package
com
.
example
.
mynotepad
.
MenuFeatures
.
VoiceMassages
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
android.app.AlertDialog
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.ImageView
;
import
com.example.mynotepad.MenuFeatures.AllNotes.AllNotesActivity
;
import
com.example.mynotepad.MenuFeatures.CustomToolbarOption
;
import
com.example.mynotepad.MenuFeatures.CustomToolbarOptionListener
;
import
com.example.mynotepad.MenuFeatures.VoiceMassages.VoiceMassagesRecyclerView.MyVoice
;
import
com.example.mynotepad.MenuFeatures.VoiceMassages.VoiceMassagesRecyclerView.OnVoiceMassageClickListener
;
import
com.example.mynotepad.MenuFeatures.VoiceMassages.VoiceMassagesRecyclerView.VoiceAdaptor
;
import
com.example.mynotepad.R
;
import
com.google.android.material.floatingactionbutton.FloatingActionButton
;
import
java.io.File
;
import
java.util.ArrayList
;
import
static
com
.
example
.
mynotepad
.
MainActivity
.
noteDataBase
;
public
class
VoiceMassagesActivity
extends
AppCompatActivity
{
...
...
app/src/main/java/com/example/mynotepad/MenuFeatures/VoiceMassages/VoiceMassagesRecyclerView/VoiceAdaptor.java
View file @
f0633d15
...
...
@@ -104,7 +104,7 @@ public class VoiceAdaptor extends RecyclerView.Adapter<VoiceAdaptor.VoiceViewHol
private
ImageView
imageViewPlay
,
imageViewStop
;
private
TextView
textViewName
,
textLongAgo
;
private
String
recordingUri
;
private
Handler
m
Handler
=
new
Handler
();
private
Handler
seekBar
Handler
=
new
Handler
();
private
VoiceViewHolder
holder
;
private
int
playingPosition
;
...
...
@@ -237,7 +237,7 @@ public class VoiceAdaptor extends RecyclerView.Adapter<VoiceAdaptor.VoiceViewHol
if
(
mPlayer
!=
null
&&
fromUser
)
{
mPlayer
.
seekTo
(
progress
);
}
mHandler
.
postDelayed
(
runnable
,
10
0
);
seekBar
.
postDelayed
(
runnable
,
0
);
}
@Override
...
...
@@ -264,7 +264,7 @@ public class VoiceAdaptor extends RecyclerView.Adapter<VoiceAdaptor.VoiceViewHol
seekBar
.
setMax
(
mPlayer
.
getDuration
());
seekBar
.
setProgress
(
mCurrentPosition
);
}
mHandler
.
postDelayed
(
runnable
,
10
0
);
seekBarHandler
.
postDelayed
(
runnable
,
0
);
}
/*
...
...
app/src/main/res/anim/menu_anim_close.xml
0 → 100644
View file @
f0633d15
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:fillAfter=
"false"
android:interpolator=
"@android:anim/accelerate_interpolator"
>
<translate
android:duration=
"300"
android:toXDelta=
"-70%"
/>
</set>
\ No newline at end of file
app/src/main/res/anim/menu_anim_open.xml
0 → 100644
View file @
f0633d15
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:fillAfter=
"false"
android:interpolator=
"@android:anim/accelerate_interpolator"
>
<translate
android:duration=
"300"
android:fromXDelta=
"-70%"
android:toXDelta=
"0"
/>
</set>
\ No newline at end of file
app/src/main/res/layout/activity_all_notes.xml
View file @
f0633d15
<?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"
tools:context=
".MenuFeatures.AllNotes.AllNotesActivity"
>
<FrameLayout
android:id=
"@+id/fragmentPlace"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<LinearLayout
android:id=
"@+id/allNoteListAndTitle"
<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/allNotesToolbar"
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_marginLeft=
"10dp"
android:enabled=
"false"
android:text=
"@string/all_notes"
android:textColor=
"#02091E"
android:textSize=
"26dp"
/>
</FrameLayout>
<com.example.mynotepad.MenuFeatures.CustomToolbarOption
android:id=
"@+id/customToolbarOption"
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/recyclerView"
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_notes"
/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id=
"@+id/addNoteButton"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentRight=
"true"
android:layout_alignParentBottom=
"true"
android:layout_marginBottom=
"30dp"
android:layout_marginRight=
"30dp"
android:clickable=
"true"
android:src=
"@drawable/add"
app:backgroundTint=
"#5266D5"
tools:layout_editor_absoluteX=
"310dp"
tools:layout_editor_absoluteY=
"612dp"
android:layout_alignParentEnd=
"true"
android:focusable=
"true"
/>
</RelativeLayout>
</FrameLayout>
</LinearLayout>
</FrameLayout>
\ No newline at end of file
</LinearLayout>
app/src/main/res/layout/fragment_all_notes_list.xml
0 → 100644
View file @
f0633d15
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:orientation=
"vertical"
tools:context=
".MenuFeatures.AllNotes.AllNotesListFragment"
>
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<FrameLayout
android:id=
"@+id/allNotesToolbar"
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_marginLeft=
"10dp"
android:enabled=
"false"
android:text=
"@string/all_notes"
android:textColor=
"#02091E"
android:textSize=
"26dp"
/>
</FrameLayout>
<com.example.mynotepad.MenuFeatures.CustomToolbarOption
android:id=
"@+id/customToolbarOption"
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/recyclerView"
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/addNoteButton"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentRight=
"true"
android:layout_alignParentBottom=
"true"
android:layout_marginBottom=
"30dp"
android:layout_marginRight=
"30dp"
android:clickable=
"true"
android:src=
"@drawable/add"
app:backgroundTint=
"#5266D5"
tools:layout_editor_absoluteX=
"310dp"
tools:layout_editor_absoluteY=
"612dp"
android:layout_alignParentEnd=
"true"
android:focusable=
"true"
/>
</RelativeLayout>
</FrameLayout>
</LinearLayout>
app/src/main/res/navigation/nav_notes.xml
0 → 100644
View file @
f0633d15
<?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_notes"
app:startDestination=
"@id/allNotesListFragment"
tools:ignore=
"UnusedNavigation"
>
<fragment
android:id=
"@+id/allNotesListFragment"
android:name=
"com.example.mynotepad.MenuFeatures.AllNotes.AllNotesListFragment"
android:label=
"fragment_all_notes_list"
tools:layout=
"@layout/fragment_all_notes_list"
>
<action
android:id=
"@+id/action_allNotesListFragment_to_noteFragment"
app:destination=
"@id/noteFragment"
app:enterAnim=
"@anim/slide_in"
app:exitAnim=
"@anim/fade_out"
app:popEnterAnim=
"@anim/fade_in"
app:popExitAnim=
"@anim/slide_out"
/>
</fragment>
<fragment
android:id=
"@+id/noteFragment"
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