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
715f057d
Commit
715f057d
authored
Sep 24, 2020
by
9731301
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add listeners for delete notes and some other components
parent
bdfadfbc
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
157 additions
and
53 deletions
+157
-53
AllNotesActivity.java
...ple/mynotepad/MenuFeatures/AllNotes/AllNotesActivity.java
+56
-4
CustomToolbarOption.java
.../mynotepad/MenuFeatures/AllNotes/CustomToolbarOption.java
+31
-11
CustomToolbarOptionListener.java
...ad/MenuFeatures/AllNotes/CustomToolbarOptionListener.java
+11
-0
MyAdaptor.java
...d/MenuFeatures/AllNotes/MyNoteRecyclerView/MyAdaptor.java
+5
-3
MyNote.java
...epad/MenuFeatures/AllNotes/MyNoteRecyclerView/MyNote.java
+4
-0
OnItemClickListener.java
...ures/AllNotes/MyNoteRecyclerView/OnItemClickListener.java
+1
-1
close.xml
app/src/main/res/drawable/close.xml
+10
-0
activity_main.xml
app/src/main/res/layout/activity_main.xml
+13
-10
custom_toolbar_options.xml
app/src/main/res/layout/custom_toolbar_options.xml
+16
-6
fragment_note.xml
app/src/main/res/layout/fragment_note.xml
+9
-18
strings.xml
app/src/main/res/values/strings.xml
+1
-0
No files found.
app/src/main/java/com/example/mynotepad/MenuFeatures/AllNotes/AllNotesActivity.java
View file @
715f057d
...
...
@@ -10,9 +10,9 @@ import androidx.room.Room;
import
android.app.AlertDialog
;
import
android.content.DialogInterface
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.FrameLayout
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
...
...
@@ -24,6 +24,7 @@ import com.example.mynotepad.MenuFeatures.AllNotes.NotesDataBase.Note;
import
com.example.mynotepad.MenuFeatures.AllNotes.NotesDataBase.NoteDataBase
;
import
com.example.mynotepad.R
;
import
com.google.android.material.floatingactionbutton.FloatingActionButton
;
import
com.google.android.material.snackbar.Snackbar
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -40,6 +41,7 @@ public class AllNotesActivity extends AppCompatActivity {
private
MyAdaptor
myAdaptor
;
private
List
<
Note
>
notes
;
private
List
<
MyNote
>
myNotes
;
public
static
MyNote
myChosenNote
;
public
static
NoteDataBase
noteDataBase
;
...
...
@@ -77,6 +79,7 @@ public class AllNotesActivity extends AppCompatActivity {
}
public
void
addListeners
()
{
addNoteButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
...
...
@@ -84,11 +87,12 @@ public class AllNotesActivity extends AppCompatActivity {
showAddAlert
();
}
});
//todo add listener for long click //update the data base
//todo
add listener to recyclerView
//
add listener to recyclerView
myAdaptor
.
setOnItemClickListener
(
new
OnItemClickListener
()
{
@Override
public
void
onItemClicked
(
MyNote
myNote
)
{
myChosenNote
=
myNote
;
//set noteFragment data
final
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
"title"
,
myNote
.
getTitle
());
...
...
@@ -104,8 +108,53 @@ public class AllNotesActivity extends AppCompatActivity {
}
@Override
public
void
onItemLongClick
(
MyNote
item
)
{
public
void
onItemLongClicked
(
MyNote
myNote
)
{
customToolbarOption
.
setVisibility
(
View
.
VISIBLE
);
allNoteToolBar
.
setVisibility
(
View
.
GONE
);
myChosenNote
=
myNote
;
}
});
//add listener to custom toolbar option and set being achieved or not to be saved in database
customToolbarOption
.
setCustomToolbarOptionListener
(
new
CustomToolbarOptionListener
()
{
@Override
public
void
onStarClicked
(
ImageView
yellowS
,
ImageView
blackS
)
{
if
(
yellowS
.
getVisibility
()
==
View
.
VISIBLE
){
yellowS
.
setVisibility
(
View
.
GONE
);
blackS
.
setVisibility
(
View
.
VISIBLE
);
myChosenNote
.
setAchieved
(
false
);
}
else
{
yellowS
.
setVisibility
(
View
.
VISIBLE
);
blackS
.
setVisibility
(
View
.
GONE
);
myChosenNote
.
setAchieved
(
true
);
}
}
@Override
public
void
onDeleteClicked
(
final
ImageView
imageView
)
{
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
(
notes
.
get
(
myNotes
.
indexOf
(
myChosenNote
)));
init
();
}
});
alert
.
setNegativeButton
(
"no"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
dialogInterface
.
cancel
();
}
});
alert
.
show
();
}
@Override
public
void
onCloseClicked
(
ImageView
imageView
)
{
customToolbarOption
.
setVisibility
(
View
.
GONE
);
allNoteToolBar
.
setVisibility
(
View
.
VISIBLE
);
}
});
}
...
...
@@ -156,4 +205,7 @@ public class AllNotesActivity extends AppCompatActivity {
}
}
public
MyNote
getMyChosenNote
()
{
return
myChosenNote
;
}
}
\ No newline at end of file
app/src/main/java/com/example/mynotepad/MenuFeatures/AllNotes/CustomToolbarOption.java
View file @
715f057d
...
...
@@ -12,8 +12,8 @@ import com.example.mynotepad.R;
public
class
CustomToolbarOption
extends
LinearLayout
implements
View
.
OnClickListener
{
private
View
rootView
;
private
ImageView
blackStarImg
,
yellowStarImg
,
deleteImg
;
private
FrameLayout
sta
r
;
private
ImageView
blackStarImg
,
yellowStarImg
,
deleteImg
,
closeImg
;
private
CustomToolbarOptionListener
customToolbarOptionListene
r
;
public
CustomToolbarOption
(
Context
context
)
{
super
(
context
);
...
...
@@ -30,20 +30,40 @@ public class CustomToolbarOption extends LinearLayout implements View.OnClickLis
blackStarImg
=
findViewById
(
R
.
id
.
black_star
);
yellowStarImg
=
findViewById
(
R
.
id
.
yellow_star
);
deleteImg
=
findViewById
(
R
.
id
.
deleteImg
);
star
=
findViewById
(
R
.
id
.
star
);
setStarColor
();
closeImg
=
findViewById
(
R
.
id
.
closeImg
);
//todo setStarColor();
yellowStarImg
.
setOnClickListener
(
this
);
blackStarImg
.
setOnClickListener
(
this
);
deleteImg
.
setOnClickListener
(
this
);
closeImg
.
setOnClickListener
(
this
);
}
private
void
setStarColor
()
{
/* private void setStarColor() {
if (AllNotesActivity.myChosenNote.isAchieved()){
blackStarImg.setVisibility(GONE);
yellowStarImg.setVisibility(VISIBLE);
}
else {
blackStarImg.setVisibility(VISIBLE);
yellowStarImg.setVisibility(GONE);
}
}*/
@Override
public
void
onClick
(
View
view
)
{
if
(
view
.
getId
()
==
star
.
getId
()){
//Todo if note is achived yellow
if
(
customToolbarOptionListener
!=
null
){
if
(
view
.
getId
()
==
closeImg
.
getId
())
customToolbarOptionListener
.
onCloseClicked
(
closeImg
);
if
(
view
.
getId
()
==
deleteImg
.
getId
())
customToolbarOptionListener
.
onDeleteClicked
(
deleteImg
);
if
(
view
.
getId
()
==
yellowStarImg
.
getId
()
||
view
.
getId
()
==
blackStarImg
.
getId
())
customToolbarOptionListener
.
onStarClicked
(
yellowStarImg
,
blackStarImg
);
}
else
if
(
view
.
getId
()
==
deleteImg
.
getId
()){
//Todo
}
public
void
setCustomToolbarOptionListener
(
CustomToolbarOptionListener
customToolbarOptionListener
)
{
this
.
customToolbarOptionListener
=
customToolbarOptionListener
;
}
}
app/src/main/java/com/example/mynotepad/MenuFeatures/AllNotes/CustomToolbarOptionListener.java
0 → 100644
View file @
715f057d
package
com
.
example
.
mynotepad
.
MenuFeatures
.
AllNotes
;
import
android.widget.ImageView
;
import
com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.MyNote
;
public
interface
CustomToolbarOptionListener
{
void
onStarClicked
(
ImageView
yellowS
,
ImageView
blackS
);
void
onDeleteClicked
(
ImageView
imageView
);
void
onCloseClicked
(
ImageView
imageView
);
}
app/src/main/java/com/example/mynotepad/MenuFeatures/AllNotes/MyNoteRecyclerView/MyAdaptor.java
View file @
715f057d
...
...
@@ -56,19 +56,21 @@ public class MyAdaptor extends RecyclerView.Adapter<MyAdaptor.ViewHolder> {
descriptionTV
=
itemView
.
findViewById
(
R
.
id
.
descriptionTv
);
isAchieved
=
false
;
itemView
.
setOnClickListener
(
this
);
itemView
.
setOnLongClickListener
(
this
);
}
@Override
public
void
onClick
(
View
view
)
{
if
(
onItemClickListener
!=
null
)
if
(
onItemClickListener
!=
null
)
{
onItemClickListener
.
onItemClicked
(
notes
.
get
(
getAdapterPosition
()));
}
}
@Override
public
boolean
onLongClick
(
View
view
)
{
if
(
onItemClickListener
!=
null
)
onItemClickListener
.
onItemLongClick
(
notes
.
get
(
getAdapterPosition
()));
return
fals
e
;
onItemClickListener
.
onItemLongClick
ed
(
notes
.
get
(
getAdapterPosition
()));
return
tru
e
;
}
}
...
...
app/src/main/java/com/example/mynotepad/MenuFeatures/AllNotes/MyNoteRecyclerView/MyNote.java
View file @
715f057d
...
...
@@ -22,4 +22,8 @@ public class MyNote {
public
boolean
isAchieved
()
{
return
isAchieved
;
}
public
void
setAchieved
(
boolean
achieved
)
{
isAchieved
=
achieved
;
}
}
app/src/main/java/com/example/mynotepad/MenuFeatures/AllNotes/MyNoteRecyclerView/OnItemClickListener.java
View file @
715f057d
...
...
@@ -2,5 +2,5 @@ package com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView;
public
interface
OnItemClickListener
{
void
onItemClicked
(
MyNote
item
);
void
onItemLongClick
(
MyNote
item
);
void
onItemLongClick
ed
(
MyNote
item
);
}
app/src/main/res/drawable/close.xml
0 → 100644
View file @
715f057d
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"24dp"
android:height=
"24dp"
android:viewportWidth=
"24"
android:viewportHeight=
"24"
android:tint=
"?attr/colorControlNormal"
>
<path
android:fillColor=
"@android:color/white"
android:pathData=
"M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"
/>
</vector>
app/src/main/res/layout/activity_main.xml
View file @
715f057d
...
...
@@ -4,7 +4,6 @@
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"#9983B5DD"
android:orientation=
"vertical"
>
<RelativeLayout
...
...
@@ -28,27 +27,31 @@
<RelativeLayout
android:id=
"@+id/main"
android:layout_below=
"@+id/toolBarId"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"#77347C74"
>
android:layout_below=
"@+id/toolBarId"
android:layout_alignParentEnd=
"true"
android:layout_alignParentRight=
"true"
android:layout_marginTop=
"-4dp"
android:layout_marginEnd=
"-2dp"
android:layout_marginRight=
"-2dp"
android:background=
"#77A9D1CD"
>
<ImageView
android:id=
"@+id/imageView"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerHorizontal=
"true"
android:layout_centerVertical=
"true"
android:layout_width=
"356dp"
android:layout_height=
"271dp"
android:layout_centerInParent=
"true"
android:src=
"@drawable/stones"
/>
<TextView
android:id=
"@+id/wlcTxt"
android:layout_width=
"
194
dp"
android:layout_height=
"
65
dp"
android:layout_width=
"
211
dp"
android:layout_height=
"
73
dp"
android:layout_above=
"@+id/imageView"
android:layout_centerHorizontal=
"true"
android:layout_marginTop=
"173dp"
android:layout_marginBottom=
"
45
dp"
/>
android:layout_marginBottom=
"
37
dp"
/>
</RelativeLayout>
</RelativeLayout>
...
...
app/src/main/res/layout/custom_toolbar_options.xml
View file @
715f057d
...
...
@@ -2,15 +2,25 @@
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"40dp"
android:background=
"#
9983B5DD
"
android:background=
"#
32648C
"
android:orientation=
"horizontal"
>
<ImageView
android:id=
"@+id/closeImg"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:layout_alignParentRight=
"true"
android:layout_marginRight=
"20dp"
android:src=
"@drawable/close"
/>
<FrameLayout
android:id=
"@+id/star"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:layout_align
ParentRight=
"true
"
android:layout_marginRight=
"
2
0dp"
>
android:layout_align
Right=
"@+id/closeImg
"
android:layout_marginRight=
"
4
0dp"
>
<ImageView
android:id=
"@+id/black_star"
...
...
@@ -21,18 +31,18 @@
<ImageView
android:id=
"@+id/yellow_star"
android:layout_width=
"wrap_content"
android:layout_height=
"
match_parent
"
android:layout_height=
"
35dp
"
android:src=
"@drawable/yellow_star"
/>
</FrameLayout>
<ImageView
android:id=
"@+id/deleteImg"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:layout_alignRight=
"@id/star"
android:layout_marginRight=
"40dp"
android:src=
"@drawable/bin"
android:id=
"@+id/deleteImg"
/>
android:src=
"@drawable/bin"
/>
</RelativeLayout>
\ No newline at end of file
app/src/main/res/layout/fragment_note.xml
View file @
715f057d
...
...
@@ -7,29 +7,20 @@
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"65dp"
android:layout_marginTop=
"10dp"
>
<EditText
android:id=
"@+id/myTitle"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:layout_marginStart=
"10dp"
android:layout_marginLeft=
"30dp"
android:layout_marginTop=
"20dp"
android:layout_marginRight=
"20dp"
android:layout_weight=
"3"
android:ems=
"10"
android:hint=
"title "
android:textSize=
"24dp"
/>
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:hint=
"title"
android:textSize=
"24dp"
android:layout_marginRight=
"50dp"
android:layout_marginLeft=
"10dp"
/>
</LinearLayout>
<FrameLayout
android:layout_width=
"
440dp
"
android:layout_width=
"
match_parent
"
android:layout_height=
"match_parent"
>
<EditText
...
...
app/src/main/res/values/strings.xml
View file @
715f057d
...
...
@@ -5,4 +5,5 @@
<string
name=
"all_notes"
>
all notes
</string>
<!-- TODO: Remove or change this placeholder text -->
<string
name=
"hello_blank_fragment"
>
Hello blank fragment
</string>
<string
name=
"title"
>
title
</string>
</resources>
\ 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