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
e17a86a1
Commit
e17a86a1
authored
Nov 26, 2020
by
9731301
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unknown bug for SharedPreferencesClass
parent
cae9b67c
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
493 additions
and
129 deletions
+493
-129
CreateNewFolderDialog.java
...ad/Dialogs/FoldersCustomDialog/CreateNewFolderDialog.java
+30
-6
FolderRecyclerViewAdapter.java
...ialogs/FoldersCustomDialog/FolderRecyclerViewAdapter.java
+58
-0
FoldersDialog.java
.../mynotepad/Dialogs/FoldersCustomDialog/FoldersDialog.java
+18
-8
OnFolderClickListener.java
...ad/Dialogs/FoldersCustomDialog/OnFolderClickListener.java
+5
-0
MainActivity.java
app/src/main/java/com/example/mynotepad/MainActivity.java
+4
-1
AllNotesListFragment.java
...mynotepad/MenuFeatures/AllNotes/AllNotesListFragment.java
+3
-0
FoldersActivity.java
...ample/mynotepad/MenuFeatures/Folders/FoldersActivity.java
+3
-44
FoldersListFragment.java
...e/mynotepad/MenuFeatures/Folders/FoldersListFragment.java
+93
-0
FoldersNotesFragment.java
.../mynotepad/MenuFeatures/Folders/FoldersNotesFragment.java
+66
-0
SharedPreferencesClass.java
...in/java/com/example/mynotepad/SharedPreferencesClass.java
+27
-3
bg_row.xml
app/src/main/res/drawable/bg_row.xml
+1
-1
activity_folders.xml
app/src/main/res/layout/activity_folders.xml
+8
-54
custom_folder_item.xml
app/src/main/res/layout/custom_folder_item.xml
+8
-10
dialog_folders.xml
app/src/main/res/layout/dialog_folders.xml
+5
-2
fragment_folders_notes.xml
app/src/main/res/layout/fragment_folders_notes.xml
+65
-0
fragment_foldersl_list.xml
app/src/main/res/layout/fragment_foldersl_list.xml
+65
-0
nav_folders.xml
app/src/main/res/navigation/nav_folders.xml
+34
-0
No files found.
app/src/main/java/com/example/mynotepad/Dialogs/FoldersCustomDialog/CreateNewFolderDialog.java
View file @
e17a86a1
...
...
@@ -6,15 +6,20 @@ import android.graphics.drawable.ColorDrawable;
import
android.view.View
;
import
android.widget.EditText
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.example.mynotepad.MainActivity
;
import
com.example.mynotepad.R
;
import
java.util.ArrayList
;
public
class
CreateNewFolderDialog
{
private
TextView
cancel
,
done
;
private
EditText
folderName
;
private
OnCreateNewFolderDialogClickListener
onCreateNewFolderDialogClickListener
;
private
Activity
activity
;
public
void
showDialog
(
Activity
activity
){
this
.
activity
=
activity
;
Dialog
dialog
=
new
Dialog
(
activity
);
dialog
.
getWindow
().
setBackgroundDrawable
(
new
ColorDrawable
(
android
.
graphics
.
Color
.
TRANSPARENT
));
dialog
.
setCancelable
(
true
);
...
...
@@ -37,14 +42,33 @@ public class CreateNewFolderDialog {
done
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
if
(!
folderName
.
getText
().
toString
().
equals
(
""
))
onCreateNewFolderDialogClickListener
.
onDoneClicked
(
folderName
.
getText
().
toString
());
dialog
.
dismiss
();
if
(
folderNameIsAcceptable
(
folderName
.
getText
().
toString
()))
{
//save new folder in sharedPreferences
ArrayList
<
String
>
foldersArray
=
MainActivity
.
sharedPreferencesClass
.
getArrayFolders
(
activity
,
"folders"
);
if
(
foldersArray
==
null
)
// if it is the first folder we are creating this array will be null
foldersArray
=
new
ArrayList
<>();
foldersArray
.
add
(
folderName
.
getText
().
toString
());
MainActivity
.
sharedPreferencesClass
.
saveArrayFolders
(
activity
,
foldersArray
,
"folders"
);
dialog
.
dismiss
();
}
}
});
}
public
void
setOnCreateNewFolderDialogClickListener
(
OnCreateNewFolderDialogClickListener
onCreateNewFolderDialogClickListener
)
{
this
.
onCreateNewFolderDialogClickListener
=
onCreateNewFolderDialogClickListener
;
private
boolean
folderNameIsAcceptable
(
String
newFolderName
)
{
if
(!
newFolderName
.
equals
(
""
)){
ArrayList
<
String
>
foldersArray
=
MainActivity
.
sharedPreferencesClass
.
getArrayFolders
(
activity
,
"folders"
);
if
(
foldersArray
==
null
)
return
true
;
//if it is first time we wanna create a folder no need to check being unique
for
(
String
folderName
:
foldersArray
){
if
(
folderName
.
equals
(
newFolderName
))
{
Toast
.
makeText
(
activity
,
"this folder already exists"
,
Toast
.
LENGTH_SHORT
).
show
();
return
false
;
}
}
return
true
;
}
Toast
.
makeText
(
activity
,
"you should enter a name to create new folder"
,
Toast
.
LENGTH_SHORT
).
show
();
return
false
;
}
}
app/src/main/java/com/example/mynotepad/Dialogs/FoldersCustomDialog/FolderRecyclerViewAdapter.java
0 → 100644
View file @
e17a86a1
package
com
.
example
.
mynotepad
.
Dialogs
.
FoldersCustomDialog
;
import
android.content.Context
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.TextView
;
import
androidx.annotation.NonNull
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.example.mynotepad.R
;
import
java.util.ArrayList
;
public
class
FolderRecyclerViewAdapter
extends
RecyclerView
.
Adapter
<
FolderRecyclerViewAdapter
.
ViewHolder
>
{
private
ArrayList
<
String
>
foldersName
;
private
Context
context
;
private
OnFolderClickListener
onFolderClickListener
;
public
FolderRecyclerViewAdapter
(
ArrayList
<
String
>
foldersName
,
Context
context
)
{
this
.
foldersName
=
foldersName
;
this
.
context
=
context
;
}
@NonNull
@Override
public
ViewHolder
onCreateViewHolder
(
@NonNull
ViewGroup
parent
,
int
viewType
)
{
View
view
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
custom_folder_item
,
parent
,
false
);
return
new
ViewHolder
(
view
);
}
@Override
public
void
onBindViewHolder
(
@NonNull
ViewHolder
holder
,
int
position
)
{
holder
.
folderName
.
setText
(
foldersName
.
get
(
position
));
}
@Override
public
int
getItemCount
()
{
return
foldersName
.
size
();
}
public
void
setOnFolderClickListener
(
OnFolderClickListener
onFolderClickListener
)
{
this
.
onFolderClickListener
=
onFolderClickListener
;
}
class
ViewHolder
extends
RecyclerView
.
ViewHolder
implements
View
.
OnClickListener
{
TextView
folderName
;
public
ViewHolder
(
@NonNull
View
itemView
)
{
super
(
itemView
);
folderName
=
itemView
.
findViewById
(
R
.
id
.
folderName
);
}
@Override
public
void
onClick
(
View
v
)
{
if
(
onFolderClickListener
!=
null
)
onFolderClickListener
.
itemClicked
(
folderName
.
getText
().
toString
());
//todo remove this and add this name to data base
}
}
}
app/src/main/java/com/example/mynotepad/Dialogs/FoldersCustomDialog/FoldersDialog.java
View file @
e17a86a1
...
...
@@ -6,21 +6,36 @@ import android.graphics.drawable.ColorDrawable;
import
android.view.View
;
import
android.widget.LinearLayout
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.example.mynotepad.MainActivity
;
import
com.example.mynotepad.R
;
public
class
FoldersDialog
{
private
RecyclerView
recyclerView
;
private
LinearLayout
addNewFolder
;
private
String
selectedFolderName
;
private
FolderRecyclerViewAdapter
folderRecyclerViewAdapter
;
public
void
showDialog
(
final
Activity
activity
){
Dialog
dialog
=
new
Dialog
(
activity
);
final
Dialog
dialog
=
new
Dialog
(
activity
);
dialog
.
getWindow
().
setBackgroundDrawable
(
new
ColorDrawable
(
android
.
graphics
.
Color
.
TRANSPARENT
));
dialog
.
setCancelable
(
true
);
dialog
.
setContentView
(
R
.
layout
.
dialog_folders
);
addNewFolder
=
dialog
.
findViewById
(
R
.
id
.
addFolder
);
recyclerView
=
dialog
.
findViewById
(
R
.
id
.
recyclerView2
);
if
(
MainActivity
.
sharedPreferencesClass
.
getArrayFolders
(
activity
,
"folders"
)!=
null
)
{
folderRecyclerViewAdapter
=
new
FolderRecyclerViewAdapter
(
MainActivity
.
sharedPreferencesClass
.
getArrayFolders
(
activity
,
"folders"
),
activity
);
recyclerView
.
setAdapter
(
folderRecyclerViewAdapter
);
recyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
activity
,
LinearLayoutManager
.
VERTICAL
,
false
));
folderRecyclerViewAdapter
.
setOnFolderClickListener
(
new
OnFolderClickListener
()
{
@Override
public
void
itemClicked
(
String
folderName
)
{
selectedFolderName
=
folderName
;
dialog
.
dismiss
();
}
});
}
dialog
.
show
();
addNewFolder
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
...
...
@@ -28,12 +43,7 @@ public class FoldersDialog {
public
void
onClick
(
View
v
)
{
CreateNewFolderDialog
createNewFolderDialog
=
new
CreateNewFolderDialog
();
createNewFolderDialog
.
showDialog
(
activity
);
createNewFolderDialog
.
setOnCreateNewFolderDialogClickListener
(
new
OnCreateNewFolderDialogClickListener
()
{
@Override
public
void
onDoneClicked
(
String
newFolderName
)
{
//todo save new folder in sharedPrefrences
}
});
folderRecyclerViewAdapter
.
notifyDataSetChanged
();
}
});
}
...
...
app/src/main/java/com/example/mynotepad/Dialogs/FoldersCustomDialog/On
CreateNewFolderDialog
ClickListener.java
→
app/src/main/java/com/example/mynotepad/Dialogs/FoldersCustomDialog/On
Folder
ClickListener.java
View file @
e17a86a1
package
com
.
example
.
mynotepad
.
Dialogs
.
FoldersCustomDialog
;
public
interface
On
CreateNewFolderDialog
ClickListener
{
void
onDoneClicked
(
String
newF
olderName
);
public
interface
On
Folder
ClickListener
{
void
itemClicked
(
String
f
olderName
);
}
app/src/main/java/com/example/mynotepad/MainActivity.java
View file @
e17a86a1
...
...
@@ -18,6 +18,7 @@ import com.example.mynotepad.MenuFeatures.AllArchivedNotes.ArchivedNotesActivity
import
com.example.mynotepad.MenuFeatures.AllNotes.AllNotesActivity
;
import
com.example.mynotepad.MenuFeatures.AllNotes.DataBase.NoteDataBase
;
import
com.example.mynotepad.MenuFeatures.Calender.MyCalenderActivity
;
import
com.example.mynotepad.MenuFeatures.Folders.FoldersActivity
;
import
com.example.mynotepad.MenuFeatures.Pics.PicsActivity
;
import
com.example.mynotepad.MenuFeatures.Setting.SettingActivity
;
import
com.example.mynotepad.MenuFeatures.Utils
;
...
...
@@ -30,7 +31,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private
DrawerLayout
drawerLayout
;
private
ImageView
theme
;
private
NavigationView
navigationView
;
p
rivate
SharedPreferencesClass
sharedPreferencesClass
;
p
ublic
static
SharedPreferencesClass
sharedPreferencesClass
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -125,10 +126,12 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
break
;
}
case
R
.
id
.
folders
:
{
startActivity
(
new
Intent
(
getApplicationContext
(),
FoldersActivity
.
class
));
break
;
}
case
R
.
id
.
settings
:
{
startActivity
(
new
Intent
(
getApplicationContext
(),
SettingActivity
.
class
));
break
;
}
case
R
.
id
.
information
:
{
}
...
...
app/src/main/java/com/example/mynotepad/MenuFeatures/AllNotes/AllNotesListFragment.java
View file @
e17a86a1
package
com
.
example
.
mynotepad
.
MenuFeatures
.
AllNotes
;
import
android.app.Activity
;
import
android.os.Bundle
;
import
androidx.annotation.NonNull
;
...
...
@@ -50,6 +51,7 @@ public class AllNotesListFragment extends Fragment {
private
NavController
navController
;
private
LinearLayout
allNotesListLayout
;
private
CustomDialog
customDialog
;
public
static
Activity
activityyyyyyyyyyyy
;
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
...
...
@@ -64,6 +66,7 @@ public class AllNotesListFragment extends Fragment {
init
(
view
);
setBg
(
Utils
.
sTheme
);
addListeners
();
activityyyyyyyyyyyy
=
getActivity
();
}
...
...
app/src/main/java/com/example/mynotepad/MenuFeatures/Folders/FoldersActivity.java
View file @
e17a86a1
...
...
@@ -19,6 +19,7 @@ import com.example.mynotepad.MenuFeatures.AllNotes.DataBase.Note;
import
com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.MyNote
;
import
com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.TimePicker.MyDate
;
import
com.example.mynotepad.MenuFeatures.CustomToolbarOption
;
import
com.example.mynotepad.MenuFeatures.Utils
;
import
com.example.mynotepad.R
;
import
com.google.android.material.floatingactionbutton.FloatingActionButton
;
...
...
@@ -26,54 +27,12 @@ import java.util.List;
public
class
FoldersActivity
extends
AppCompatActivity
{
private
FloatingActionButton
addNoteButton
;
private
CustomToolbarOption
customToolbarOption
;
private
FrameLayout
allNoteToolBar
;
private
RecyclerView
recyclerView
;
private
MyArchivedAdaptor
myarchivedAdaptor
;
private
List
<
Note
>
entityNotes
;
private
List
<
DateEntity
>
entityDates
;
private
List
<
MyNote
>
myNotes
;
private
List
<
MyDate
>
myDates
;
public
static
DateOrNote
chosenDateOrNote
;
private
NavController
navController
;
private
LinearLayout
allNotesListLayout
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_folders
);
}
private
void
init
(
View
view
)
{
// get data from database
setAllNoteListAndTitles
();
setAllDateNoteListAndTitles
();
customToolbarOption
=
findViewById
(
R
.
id
.
customToolbarOption
);
customToolbarOption
.
setVisibility
(
View
.
GONE
);
allNoteToolBar
=
view
.
findViewById
(
R
.
id
.
toolbar
);
allNoteToolBar
.
setEnabled
(
false
);
navController
=
Navigation
.
findNavController
(
view
);
allNotesListLayout
=
view
.
findViewById
(
R
.
id
.
allNoteListLayout
);
addNoteButton
=
view
.
findViewById
(
R
.
id
.
addButton
);
// show list with recycler view
recyclerView
=
view
.
findViewById
(
R
.
id
.
recyclerView
);
StaggeredGridLayoutManager
staggeredGridLayoutManager
=
new
StaggeredGridLayoutManager
(
2
,
LinearLayoutManager
.
VERTICAL
);
myarchivedAdaptor
=
new
MyArchivedAdaptor
(
myNotes
,
myDates
);
recyclerView
.
setAdapter
(
myarchivedAdaptor
);
recyclerView
.
setLayoutManager
(
staggeredGridLayoutManager
);
addListeners
();
}
private
void
setAllDateNoteListAndTitles
()
{
}
private
void
setAllNoteListAndTitles
()
{
}
private
void
addListeners
()
{
Utils
.
onActivityCreateSetTheme
(
this
,
getSupportActionBar
());
setTitle
(
"folders"
);
}
}
\ No newline at end of file
app/src/main/java/com/example/mynotepad/MenuFeatures/Folders/FoldersListFragment.java
0 → 100644
View file @
e17a86a1
package
com
.
example
.
mynotepad
.
MenuFeatures
.
Folders
;
import
android.app.AlertDialog
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.os.Bundle
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.fragment.app.Fragment
;
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
com.example.mynotepad.Dialogs.FoldersCustomDialog.FolderRecyclerViewAdapter
;
import
com.example.mynotepad.Dialogs.FoldersCustomDialog.OnFolderClickListener
;
import
com.example.mynotepad.MainActivity
;
import
com.example.mynotepad.MenuFeatures.AllNotes.AllNotesListFragment
;
import
com.example.mynotepad.MenuFeatures.CustomToolbarOption
;
import
com.example.mynotepad.MenuFeatures.Utils
;
import
com.example.mynotepad.R
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
java.lang.reflect.Type
;
import
java.util.ArrayList
;
public
class
FoldersListFragment
extends
Fragment
{
private
FolderRecyclerViewAdapter
folderRecyclerViewAdapter
;
private
RecyclerView
recyclerView
;
private
CustomToolbarOption
customToolbarOption
;
private
FrameLayout
allNoteToolBar
;
private
View
listLayout
;
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
// Inflate the layout for this fragment
return
inflater
.
inflate
(
R
.
layout
.
fragment_foldersl_list
,
container
,
false
);
}
@Override
public
void
onViewCreated
(
@NonNull
View
view
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onViewCreated
(
view
,
savedInstanceState
);
init
(
view
);
setBg
(
Utils
.
sTheme
);
}
private
void
init
(
View
view
)
{
listLayout
=
view
.
findViewById
(
R
.
id
.
allNoteListLayout
);
recyclerView
=
view
.
findViewById
(
R
.
id
.
recyclerView
);
customToolbarOption
=
view
.
findViewById
(
R
.
id
.
customToolbarOption
);
customToolbarOption
.
setVisibility
(
View
.
GONE
);
allNoteToolBar
=
view
.
findViewById
(
R
.
id
.
toolbar
);
allNoteToolBar
.
setEnabled
(
false
);
// if (MainActivity.sharedPreferencesClass.getArrayFolders(getActivity(),"folders")!= null) {
SharedPreferences
sharedPreferences
=
getActivity
().
getPreferences
(
Context
.
MODE_PRIVATE
);
Gson
gson
=
new
Gson
();
String
json
=
sharedPreferences
.
getString
(
"folders"
,
null
);
System
.
out
.
println
(
json
+
"+++++++++++++++++++++++++++++++++++++++++++++++"
);
Type
type
=
new
TypeToken
<
ArrayList
<
String
>>()
{}.
getType
();
ArrayList
<
String
>
a
=
gson
.
fromJson
(
json
,
type
);
folderRecyclerViewAdapter
=
new
FolderRecyclerViewAdapter
(
a
,
getActivity
());
recyclerView
.
setAdapter
(
folderRecyclerViewAdapter
);
recyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
getActivity
(),
LinearLayoutManager
.
VERTICAL
,
false
));
folderRecyclerViewAdapter
.
setOnFolderClickListener
(
new
OnFolderClickListener
()
{
@Override
public
void
itemClicked
(
String
folderName
)
{
}
});
// }
}
private
void
setBg
(
String
sTheme
)
{
switch
(
sTheme
)
{
case
"dark"
:
listLayout
.
setBackgroundResource
(
R
.
drawable
.
main_bg_dark
);
break
;
case
"bright"
:
listLayout
.
setBackgroundResource
(
R
.
drawable
.
main_bg_bright
);
break
;
}
}
}
\ No newline at end of file
app/src/main/java/com/example/mynotepad/MenuFeatures/Folders/FoldersNotesFragment.java
0 → 100644
View file @
e17a86a1
package
com
.
example
.
mynotepad
.
MenuFeatures
.
Folders
;
import
android.os.Bundle
;
import
androidx.fragment.app.Fragment
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
com.example.mynotepad.R
;
/**
* A simple {@link Fragment} subclass.
* Use the {@link FoldersNotesFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public
class
FoldersNotesFragment
extends
Fragment
{
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private
static
final
String
ARG_PARAM1
=
"param1"
;
private
static
final
String
ARG_PARAM2
=
"param2"
;
// TODO: Rename and change types of parameters
private
String
mParam1
;
private
String
mParam2
;
public
FoldersNotesFragment
()
{
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment FoldersNotesFragment.
*/
// TODO: Rename and change types and number of parameters
public
static
FoldersNotesFragment
newInstance
(
String
param1
,
String
param2
)
{
FoldersNotesFragment
fragment
=
new
FoldersNotesFragment
();
Bundle
args
=
new
Bundle
();
args
.
putString
(
ARG_PARAM1
,
param1
);
args
.
putString
(
ARG_PARAM2
,
param2
);
fragment
.
setArguments
(
args
);
return
fragment
;
}
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
if
(
getArguments
()
!=
null
)
{
mParam1
=
getArguments
().
getString
(
ARG_PARAM1
);
mParam2
=
getArguments
().
getString
(
ARG_PARAM2
);
}
}
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
// Inflate the layout for this fragment
return
inflater
.
inflate
(
R
.
layout
.
fragment_folders_notes
,
container
,
false
);
}
}
\ No newline at end of file
app/src/main/java/com/example/mynotepad/SharedPreferencesClass.java
View file @
e17a86a1
...
...
@@ -3,23 +3,47 @@ package com.example.mynotepad;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.preference.PreferenceManager
;
import
com.example.mynotepad.MenuFeatures.Utils
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
java.lang.reflect.Type
;
import
java.util.ArrayList
;
public
class
SharedPreferencesClass
{
private
SharedPreferences
sharedPreferences
;
private
SharedPreferences
.
Editor
editor
;
public
void
changeTheTheme
(
Activity
activity
)
{
public
void
changeTheTheme
(
Activity
activity
)
{
sharedPreferences
=
activity
.
getPreferences
(
Context
.
MODE_PRIVATE
);
editor
=
sharedPreferences
.
edit
();
editor
.
putString
(
activity
.
getString
(
R
.
string
.
saved_high_score_key
),
Utils
.
sTheme
).
apply
();
}
public
void
getThemeOnMainActivityCreate
(
Activity
activity
){
public
void
getThemeOnMainActivityCreate
(
Activity
activity
)
{
SharedPreferences
sharedPref
=
activity
.
getPreferences
(
Context
.
MODE_PRIVATE
);
Utils
.
sTheme
=
sharedPref
.
getString
(
activity
.
getString
(
R
.
string
.
saved_high_score_key
)
,
"bright"
);
Utils
.
sTheme
=
sharedPref
.
getString
(
activity
.
getString
(
R
.
string
.
saved_high_score_key
)
,
"bright"
);
}
public
void
saveArrayFolders
(
Activity
activity
,
ArrayList
<
String
>
list
,
String
key
)
{
sharedPreferences
=
activity
.
getSharedPreferences
(
key
,
Context
.
MODE_PRIVATE
);
editor
=
sharedPreferences
.
edit
();
Gson
gson
=
new
Gson
();
String
json
=
gson
.
toJson
(
list
);
editor
.
remove
(
key
);
editor
.
putString
(
key
,
json
);
editor
.
apply
();
}
public
ArrayList
<
String
>
getArrayFolders
(
Activity
activity
,
String
key
)
{
sharedPreferences
=
activity
.
getSharedPreferences
(
key
,
Context
.
MODE_PRIVATE
);
Gson
gson
=
new
Gson
();
String
json
=
sharedPreferences
.
getString
(
key
,
null
);
System
.
out
.
println
(
json
+
"+++++++++++++++++++++++++++++++++++++++++++++++"
);
Type
type
=
new
TypeToken
<
ArrayList
<
String
>>()
{}.
getType
();
return
gson
.
fromJson
(
json
,
type
);
}
}
app/src/main/res/drawable/bg_row.xml
View file @
e17a86a1
...
...
@@ -5,7 +5,7 @@
<solid
android:color=
"?colorOnPrimary"
/>
<stroke
android:width=
"
2
0dp"
android:width=
"
1
0dp"
android:color=
"#16A0B9FC"
/>
<corners
android:radius=
"20dp"
/>
...
...
app/src/main/res/layout/activity_folders.xml
View file @
e17a86a1
...
...
@@ -4,62 +4,16 @@
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@drawable/main_bg_bright"
android:orientation=
"vertical"
tools:context=
".MenuFeatures.AllNotes.AllNotesListFragment"
android:id=
"@+id/allNoteListLayout"
>
tools:context=
".MenuFeatures.AllNotes.AllNotesActivity"
android:id=
"@+id/foldersLayout"
>
<FrameLayout
<fragment
android:id=
"@+id/fragment_container"
android:name=
"androidx.navigation.fragment.NavHostFragment"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
android:layout_height=
"match_parent"
app:defaultNavHost=
"true"
app:navGraph=
"@navigation/nav_folders"
/>
<FrameLayout
android:id=
"@+id/toolbar"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
</FrameLayout>
<com.example.mynotepad.MenuFeatures.CustomToolbarOption
android:id=
"@+id/customToolbarOption"
android:layout_width=
"match_parent"
android:layout_height=
"50dp"
/>
</FrameLayout>
<FrameLayout
android:layout_width=
"match_parent"
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=
"match_parent"
android:layout_height=
"match_parent"
tools:layout_editor_absoluteX=
"1dp"
tools:layout_editor_absoluteY=
"1dp"
/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id=
"@+id/addButton"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentEnd=
"true"
android:layout_alignParentRight=
"true"
android:layout_alignParentBottom=
"true"
android:layout_marginRight=
"16dp"
android:layout_marginBottom=
"16dp"
android:clickable=
"true"
android:focusable=
"true"
android:src=
"@drawable/add"
android:tint=
"?android:textColor"
app:backgroundTint=
"?colorError"
tools:layout_editor_absoluteX=
"310dp"
tools:layout_editor_absoluteY=
"612dp"
/>
</RelativeLayout>
</FrameLayout>
</LinearLayout>
app/src/main/res/layout/custom_folder_item.xml
View file @
e17a86a1
<?xml version="1.0" encoding="utf-8"?>
<
androidx.cardview.widget.CardView
xmlns:android=
"http://schemas.android.com/apk/res/android"
<
LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"80dp"
android:orientation=
"horizontal"
android:background=
"?colorOnPrimary"
android:layout_marginLeft=
"5dp"
android:layout_margin=
"5dp"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"80dp"
android:orientation=
"horizontal"
>
<ImageView
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:padding=
"
2
5dp"
android:padding=
"
1
5dp"
android:src=
"@drawable/folder"
app:tint=
"?android:textColor"
android:layout_marginLeft=
"5dp"
/>
/>
<TextView
android:id=
"@+id/folderName"
android:layout_width=
"0dp"
...
...
@@ -25,5 +25,3 @@
android:textSize=
"20dp"
android:gravity=
"center_vertical"
/>
</LinearLayout>
</androidx.cardview.widget.CardView>
\ No newline at end of file
app/src/main/res/layout/dialog_folders.xml
View file @
e17a86a1
...
...
@@ -11,7 +11,8 @@
android:layout_width=
"match_parent"
android:layout_height=
"80dp"
android:orientation=
"horizontal"
android:id=
"@+id/addFolder"
>
android:id=
"@+id/addFolder"
>
<ImageView
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
...
...
@@ -32,6 +33,8 @@
android:id=
"@+id/recyclerView2"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:padding=
"20dp"
/>
android:layout_marginBottom=
"17dp"
android:padding=
"5dp"
android:layout_marginRight=
"3dp"
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/layout/fragment_folders_notes.xml
0 → 100644
View file @
e17a86a1
<?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:background=
"@drawable/main_bg_bright"
android:orientation=
"vertical"
tools:context=
".MenuFeatures.AllNotes.AllNotesListFragment"
android:id=
"@+id/allNoteListLayout"
>
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<FrameLayout
android:id=
"@+id/toolbar"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
</FrameLayout>
<com.example.mynotepad.MenuFeatures.CustomToolbarOption
android:id=
"@+id/customToolbarOption"
android:layout_width=
"match_parent"
android:layout_height=
"50dp"
/>
</FrameLayout>
<FrameLayout
android:layout_width=
"match_parent"
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=
"match_parent"
android:layout_height=
"match_parent"
tools:layout_editor_absoluteX=
"1dp"
tools:layout_editor_absoluteY=
"1dp"
/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id=
"@+id/addButton"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentEnd=
"true"
android:layout_alignParentRight=
"true"
android:layout_alignParentBottom=
"true"
android:layout_marginRight=
"16dp"
android:layout_marginBottom=
"16dp"
android:clickable=
"true"
android:focusable=
"true"
android:src=
"@drawable/add"
android:tint=
"?android:textColor"
app:backgroundTint=
"?colorError"
tools:layout_editor_absoluteX=
"310dp"
tools:layout_editor_absoluteY=
"612dp"
/>
</RelativeLayout>
</FrameLayout>
</LinearLayout>
app/src/main/res/layout/fragment_foldersl_list.xml
0 → 100644
View file @
e17a86a1
<?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:background=
"@drawable/main_bg_bright"
android:orientation=
"vertical"
tools:context=
".MenuFeatures.AllNotes.AllNotesListFragment"
android:id=
"@+id/allNoteListLayout"
>
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<FrameLayout
android:id=
"@+id/toolbar"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
</FrameLayout>
<com.example.mynotepad.MenuFeatures.CustomToolbarOption
android:id=
"@+id/customToolbarOption"
android:layout_width=
"match_parent"
android:layout_height=
"50dp"
/>
</FrameLayout>
<FrameLayout
android:layout_width=
"match_parent"
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=
"match_parent"
android:layout_height=
"match_parent"
tools:layout_editor_absoluteX=
"1dp"
tools:layout_editor_absoluteY=
"1dp"
/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id=
"@+id/addButton"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentEnd=
"true"
android:layout_alignParentRight=
"true"
android:layout_alignParentBottom=
"true"
android:layout_marginRight=
"16dp"
android:layout_marginBottom=
"16dp"
android:clickable=
"true"
android:focusable=
"true"
android:src=
"@drawable/add"
android:tint=
"?android:textColor"
app:backgroundTint=
"?colorError"
tools:layout_editor_absoluteX=
"310dp"
tools:layout_editor_absoluteY=
"612dp"
/>
</RelativeLayout>
</FrameLayout>
</LinearLayout>
app/src/main/res/navigation/nav_folders.xml
0 → 100644
View file @
e17a86a1
<?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_folders"
app:startDestination=
"@id/foldersListFragment"
>
<fragment
android:id=
"@+id/foldersListFragment"
android:name=
"com.example.mynotepad.MenuFeatures.Folders.FoldersListFragment"
android:label=
"fragment_foldersl_list"
tools:layout=
"@layout/fragment_foldersl_list"
>
<action
android:id=
"@+id/action_foldersListFragment2_to_foldersNotesFragment2"
app:destination=
"@id/foldersNotesFragment"
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/foldersNotesFragment"
android:name=
"com.example.mynotepad.MenuFeatures.Folders.FoldersNotesFragment"
android:label=
"fragment_folders_notes"
tools:layout=
"@layout/fragment_folders_notes"
>
<action
android:id=
"@+id/action_foldersNotesFragment_to_noteFragment4"
app:destination=
"@id/noteFragment4"
/>
</fragment>
<fragment
android:id=
"@+id/noteFragment4"
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