Commit db2e8c72 authored by 9731301's avatar 9731301

change database to be prepared to add folders

parent 7b22d50a
...@@ -25,7 +25,7 @@ android { ...@@ -25,7 +25,7 @@ android {
dependencies { dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"]) implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2' implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.1' testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.ext:junit:1.1.2'
...@@ -34,9 +34,11 @@ dependencies { ...@@ -34,9 +34,11 @@ dependencies {
implementation 'androidx.navigation:navigation-ui:2.3.1' implementation 'androidx.navigation:navigation-ui:2.3.1'
implementation 'com.alirezaafkar:sundatepicker:2.0.4' implementation 'com.alirezaafkar:sundatepicker:2.0.4'
implementation "androidx.room:room-runtime:2.2.5" implementation "androidx.room:room-runtime:2.2.5"
annotationProcessor "androidx.room:room-compiler:2.2.5" annotationProcessor "androidx.room:room-compiler:2.2.5"
implementation "android.arch.persistence.room:runtime:1.1.1"
annotationProcessor "android.arch.persistence.room:compiler:1.1.1"
implementation 'com.google.code.gson:gson:2.8.5'
//i added these parts just for voice recorder //i added these parts just for voice recorder
def nav_version = "2.3.1" def nav_version = "2.3.1"
......
...@@ -135,6 +135,7 @@ public class ArchivedNoesListFragment extends Fragment { ...@@ -135,6 +135,7 @@ public class ArchivedNoesListFragment extends Fragment {
chosenDateOrNote = item; chosenDateOrNote = item;
customToolbarOption.setVisibility(View.VISIBLE); customToolbarOption.setVisibility(View.VISIBLE);
customToolbarOption.hideRecycleBin(); customToolbarOption.hideRecycleBin();
customToolbarOption.hideFolder();
allNoteToolBar.setVisibility(View.GONE); allNoteToolBar.setVisibility(View.GONE);
} }
}); });
...@@ -159,15 +160,20 @@ public class ArchivedNoesListFragment extends Fragment { ...@@ -159,15 +160,20 @@ public class ArchivedNoesListFragment extends Fragment {
public void onCloseClicked() { public void onCloseClicked() {
closeClicked(customToolbarOption); closeClicked(customToolbarOption);
} }
@Override
public void onFolderClicked() {
}
}); });
} }
private void updateToUnarchiveInDataBase() { private void updateToUnarchiveInDataBase() {
if (chosenDateOrNote.getType().equals("note")) { if (chosenDateOrNote.getType().equals("note")) {
noteDataBase.noteDao().updateNote(chosenDateOrNote.getTitle(), chosenDateOrNote.getDescription(), false, chosenDateOrNote.getId()); noteDataBase.noteDao().updateNote(chosenDateOrNote.getTitle(), chosenDateOrNote.getDescription(), false, chosenDateOrNote.getId() , chosenDateOrNote.getFolders());
} else if (chosenDateOrNote.getType().equals("date")) { } else if (chosenDateOrNote.getType().equals("date")) {
noteDataBase.dateNoreDAO().updateDate(chosenDateOrNote.getTitle(), chosenDateOrNote.getDescription(), false, chosenDateOrNote.getId()); noteDataBase.dateNoreDAO().updateDate(chosenDateOrNote.getTitle(), chosenDateOrNote.getDescription(), false, chosenDateOrNote.getId() , chosenDateOrNote.getFolders());
} }
} }
...@@ -176,7 +182,7 @@ public class ArchivedNoesListFragment extends Fragment { ...@@ -176,7 +182,7 @@ public class ArchivedNoesListFragment extends Fragment {
entityNotes = noteDataBase.noteDao().getAll(); entityNotes = noteDataBase.noteDao().getAll();
myNotes = new ArrayList<>(); myNotes = new ArrayList<>();
for (Note note : entityNotes) { for (Note note : entityNotes) {
MyNote myNote = new MyNote(note.getTitle(), note.getDescription(), note.isarchived(), note.getID()); MyNote myNote = new MyNote(note.getTitle(), note.getDescription(), note.isarchived(), note.getID() , note.getFolders());
myNotes.add(myNote); myNotes.add(myNote);
} }
} }
...@@ -186,7 +192,7 @@ public class ArchivedNoesListFragment extends Fragment { ...@@ -186,7 +192,7 @@ public class ArchivedNoesListFragment extends Fragment {
entityDates = noteDataBase.dateNoreDAO().getAllDateNotes(); entityDates = noteDataBase.dateNoreDAO().getAllDateNotes();
myDates = new ArrayList<>(); myDates = new ArrayList<>();
for (DateEntity dateEntity : entityDates) { for (DateEntity dateEntity : entityDates) {
MyDate myDate = new MyDate(dateEntity.getDate(), dateEntity.getDescription(), dateEntity.isarchived(), dateEntity.getID()); MyDate myDate = new MyDate(dateEntity.getDate(), dateEntity.getDescription(), dateEntity.isarchived(), dateEntity.getID() , dateEntity.getFolders());
myDates.add(myDate); myDates.add(myDate);
} }
} }
......
package com.example.mynotepad.MenuFeatures.AllArchivedNotes.MyArchivedNotesRecyclerView; package com.example.mynotepad.MenuFeatures.AllArchivedNotes.MyArchivedNotesRecyclerView;
import java.util.ArrayList;
public class DateOrNote { public class DateOrNote {
private int id; private int id;
private String type; private String type;
private String title; private String title;
private String description; private String description;
private ArrayList<String> folders;
public DateOrNote(int id, String type, String title, String description) { public DateOrNote(int id, String type, String title, String description , ArrayList<String> folders) {
this.id = id; this.id = id;
this.type = type; this.type = type;
this.title = title; this.title = title;
this.description = description; this.description = description;
this.folders = folders;
} }
public int getId() { public int getId() {
...@@ -28,4 +32,8 @@ public class DateOrNote { ...@@ -28,4 +32,8 @@ public class DateOrNote {
public String getDescription() { public String getDescription() {
return description; return description;
} }
public ArrayList<String> getFolders() {
return folders;
}
} }
...@@ -34,7 +34,7 @@ public class MyArchivedAdaptor extends RecyclerView.Adapter<MyArchivedAdaptor.Vi ...@@ -34,7 +34,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.isArchived()) { if (myDate.isArchived()) {
DateOrNote date = new DateOrNote(myDate.getId(), "date", myDate.getDate(), myDate.getDescription()); DateOrNote date = new DateOrNote(myDate.getId(), "date", myDate.getDate(), myDate.getDescription() , myDate.getFolders());
dateOrNoteList.add(date); dateOrNoteList.add(date);
} }
} }
...@@ -43,7 +43,7 @@ public class MyArchivedAdaptor extends RecyclerView.Adapter<MyArchivedAdaptor.Vi ...@@ -43,7 +43,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.isArchived()) { if (myNote.isArchived()) {
DateOrNote note = new DateOrNote(myNote.getId(), "note", myNote.getTitle(), myNote.getDescription()); DateOrNote note = new DateOrNote(myNote.getId(), "note", myNote.getTitle(), myNote.getDescription() , myNote.getFolders());
dateOrNoteList.add(note); dateOrNoteList.add(note);
} }
} }
......
...@@ -151,6 +151,11 @@ public class AllNotesListFragment extends Fragment { ...@@ -151,6 +151,11 @@ public class AllNotesListFragment extends Fragment {
public void onCloseClicked() { public void onCloseClicked() {
closeClicked(customToolbarOption); closeClicked(customToolbarOption);
} }
@Override
public void onFolderClicked() {
}
}); });
} }
...@@ -195,7 +200,7 @@ public class AllNotesListFragment extends Fragment { ...@@ -195,7 +200,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.isArchived(), myChosenNote.getId()); , myChosenNote.isArchived(), myChosenNote.getId() , myChosenNote.getFolders());
} }
...@@ -229,7 +234,7 @@ public class AllNotesListFragment extends Fragment { ...@@ -229,7 +234,7 @@ public class AllNotesListFragment extends Fragment {
entityNotes = noteDataBase.noteDao().getAll(); entityNotes = noteDataBase.noteDao().getAll();
myNotes = new ArrayList<>(); myNotes = new ArrayList<>();
for (Note note : entityNotes) { for (Note note : entityNotes) {
MyNote myNote = new MyNote(note.getTitle(), note.getDescription(), note.isarchived(), note.getID()); MyNote myNote = new MyNote(note.getTitle(), note.getDescription(), note.isarchived(), note.getID() , note.getFolders());
myNotes.add(myNote); myNotes.add(myNote);
} }
} }
......
package com.example.mynotepad.MenuFeatures.AllNotes.DataBase;
import androidx.room.TypeConverter;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.ArrayList;
public class Converters {
@TypeConverter
public static ArrayList<String> fromString(String value) {
Type listType = new TypeToken<ArrayList<String>>() {}.getType();
return new Gson().fromJson(value, listType);
}
@TypeConverter
public static String fromArrayList(ArrayList<String> list) {
Gson gson = new Gson();
String json = gson.toJson(list);
return json;
}
}
...@@ -3,6 +3,9 @@ package com.example.mynotepad.MenuFeatures.AllNotes.DataBase; ...@@ -3,6 +3,9 @@ package com.example.mynotepad.MenuFeatures.AllNotes.DataBase;
import androidx.room.ColumnInfo; import androidx.room.ColumnInfo;
import androidx.room.Entity; import androidx.room.Entity;
import androidx.room.PrimaryKey; import androidx.room.PrimaryKey;
import java.util.ArrayList;
@Entity @Entity
public class DateEntity { public class DateEntity {
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
...@@ -13,11 +16,14 @@ public class DateEntity { ...@@ -13,11 +16,14 @@ public class DateEntity {
String description; String description;
@ColumnInfo(name = "archived") @ColumnInfo(name = "archived")
boolean isarchived; boolean isarchived;
@ColumnInfo(name = "folders")
ArrayList<String > folders;
public DateEntity(String date , String description , boolean isarchived){ public DateEntity(String date , String description , boolean isarchived ,ArrayList<String> folders ){
this.date = date; this.date = date;
this.description = description; this.description = description;
this.isarchived = isarchived; this.isarchived = isarchived;
this.folders = folders;
} }
...@@ -36,4 +42,8 @@ public class DateEntity { ...@@ -36,4 +42,8 @@ public class DateEntity {
public boolean isarchived(){ public boolean isarchived(){
return isarchived; return isarchived;
} }
public ArrayList<String> getFolders() {
return folders;
}
} }
\ No newline at end of file
...@@ -6,6 +6,7 @@ import androidx.room.Insert; ...@@ -6,6 +6,7 @@ import androidx.room.Insert;
import androidx.room.Query; import androidx.room.Query;
import androidx.room.Update; import androidx.room.Update;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Dao @Dao
...@@ -25,6 +26,6 @@ public interface DateNoreDAO { ...@@ -25,6 +26,6 @@ public interface DateNoreDAO {
//update data //update data
@Query("UPDATE DateEntity SET date = :date , description = :description ,archived = :isarchived Where ID = :id") @Query("UPDATE DateEntity SET date = :date , description = :description ,archived = :isarchived ,folders =:folders Where ID = :id")
void updateDate(String date , String description , boolean isarchived , int id); void updateDate(String date , String description , boolean isarchived , int id , ArrayList<String> folders);
} }
...@@ -4,6 +4,8 @@ import androidx.room.ColumnInfo; ...@@ -4,6 +4,8 @@ import androidx.room.ColumnInfo;
import androidx.room.Entity; import androidx.room.Entity;
import androidx.room.PrimaryKey; import androidx.room.PrimaryKey;
import java.util.ArrayList;
@Entity @Entity
public class Note { public class Note {
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
...@@ -14,11 +16,14 @@ public class Note { ...@@ -14,11 +16,14 @@ public class Note {
String txtBody; String txtBody;
@ColumnInfo(name = "archived") @ColumnInfo(name = "archived")
boolean isarchived; boolean isarchived;
@ColumnInfo(name = "folders")
ArrayList<String> folders;
public Note(String title, String txtBody, boolean isarchived) { public Note(String title, String txtBody, boolean isarchived , ArrayList<String> folders) {
this.title = title; this.title = title;
this.txtBody = txtBody; this.txtBody = txtBody;
this.isarchived = isarchived; this.isarchived = isarchived;
this.folders = folders;
} }
...@@ -37,4 +42,8 @@ public class Note { ...@@ -37,4 +42,8 @@ public class Note {
public boolean isarchived() { public boolean isarchived() {
return isarchived; return isarchived;
} }
public ArrayList<String> getFolders() {
return folders;
}
} }
...@@ -6,6 +6,7 @@ import androidx.room.Insert; ...@@ -6,6 +6,7 @@ import androidx.room.Insert;
import androidx.room.Query; import androidx.room.Query;
import androidx.room.Update; import androidx.room.Update;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Dao @Dao
...@@ -22,6 +23,6 @@ public interface NoteDAO { ...@@ -22,6 +23,6 @@ public interface NoteDAO {
@Delete @Delete
void deleteNote(Note myNote); void deleteNote(Note myNote);
@Query("UPDATE Note SET title = :title , description = :description ,archived = :isarchived Where ID = :id") @Query("UPDATE Note SET title = :title , description = :description ,archived = :isarchived , folders =:folders Where ID = :id")
void updateNote(String title , String description , boolean isarchived , int id); void updateNote(String title , String description , boolean isarchived , int id , ArrayList<String> folders);
} }
\ No newline at end of file
...@@ -2,8 +2,10 @@ package com.example.mynotepad.MenuFeatures.AllNotes.DataBase; ...@@ -2,8 +2,10 @@ package com.example.mynotepad.MenuFeatures.AllNotes.DataBase;
import androidx.room.Database; import androidx.room.Database;
import androidx.room.RoomDatabase; import androidx.room.RoomDatabase;
import androidx.room.TypeConverters;
@Database(entities = {Note.class, DateEntity.class ,PicsEntity.class},version = 1) @Database(entities = {Note.class, DateEntity.class ,PicsEntity.class},version = 1)
@TypeConverters({Converters.class})
public abstract class NoteDataBase extends RoomDatabase { public abstract class NoteDataBase extends RoomDatabase {
public abstract NoteDAO noteDao(); public abstract NoteDAO noteDao();
......
package com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView; package com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView;
import java.util.ArrayList;
public class MyNote { public class MyNote {
private String title, description; private String title, description;
private boolean isarchived; private boolean isarchived;
int id; private int id;
private ArrayList<String> folders;
public MyNote(String title, String description, boolean isarchived, int id) { public MyNote(String title, String description, boolean isarchived, int id , ArrayList<String> folders) {
this.title = title; this.title = title;
this.description = description; this.description = description;
this.isarchived = isarchived; this.isarchived = isarchived;
this.id = id; this.id = id;
this.folders = folders;
} }
public String getTitle() { public String getTitle() {
...@@ -32,4 +36,8 @@ public class MyNote { ...@@ -32,4 +36,8 @@ public class MyNote {
public int getId() { public int getId() {
return id; return id;
} }
public ArrayList<String> getFolders() {
return folders;
}
} }
...@@ -101,9 +101,11 @@ public class NoteFragment extends Fragment { ...@@ -101,9 +101,11 @@ public class NoteFragment extends Fragment {
else if (type.equals("noteDate")) { else if (type.equals("noteDate")) {
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++"); System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++");
if (noteDateType.equals("note")) { if (noteDateType.equals("note")) {
noteDataBase.noteDao().updateNote(titleTxt.getText().toString(), bodyTxt.getText().toString(), true, ArchivedNoesListFragment.chosenDateOrNote.getId()); noteDataBase.noteDao().updateNote(titleTxt.getText().toString(), bodyTxt.getText().toString(),
true, ArchivedNoesListFragment.chosenDateOrNote.getId() , null);//todo ooooooooooooooooooooooo
} else if (noteDateType.equals("date")) { } else if (noteDateType.equals("date")) {
noteDataBase.dateNoreDAO().updateDate(titleTxt.getText().toString(), bodyTxt.getText().toString(), true, ArchivedNoesListFragment.chosenDateOrNote.getId()); noteDataBase.dateNoreDAO().updateDate(titleTxt.getText().toString(), bodyTxt.getText().toString(),
true, ArchivedNoesListFragment.chosenDateOrNote.getId() , ArchivedNoesListFragment.chosenDateOrNote.getFolders());
} }
} }
if (getActivity() != null) if (getActivity() != null)
...@@ -120,11 +122,12 @@ public class NoteFragment extends Fragment { ...@@ -120,11 +122,12 @@ public class NoteFragment extends Fragment {
private void saveNote() { private void saveNote() {
if (isAnewNote) { if (isAnewNote) {
note = new Note(titleTxt.getText().toString(), bodyTxt.getText().toString(), false); note = new Note(titleTxt.getText().toString(), bodyTxt.getText().toString(), false , null);//todo oooooooooooooooooooo add folders
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() ,AllNotesListFragment.myChosenNote.getFolders());
Toast.makeText(getActivity(), "updated", Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(), "updated", Toast.LENGTH_SHORT).show();
} }
} }
...@@ -132,11 +135,12 @@ public class NoteFragment extends Fragment { ...@@ -132,11 +135,12 @@ public class NoteFragment extends Fragment {
private void saveCalenderNote() { private void saveCalenderNote() {
if (isAnewNote) { if (isAnewNote) {
dateEntity = new DateEntity(titleTxt.getText().toString(), bodyTxt.getText().toString(), false); dateEntity = new DateEntity(titleTxt.getText().toString(), bodyTxt.getText().toString(), false , null); // todo ooooooooooooooooooooooooooo add foldesr==rs
noteDataBase.dateNoreDAO().insertDateNote(dateEntity); noteDataBase.dateNoreDAO().insertDateNote(dateEntity);
Toast.makeText(getActivity(), "saved", Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(), "saved", Toast.LENGTH_SHORT).show();
} else { } else {
noteDataBase.dateNoreDAO().updateDate(titleTxt.getText().toString(), bodyTxt.getText().toString(), CalenderNotesListFragment.myChosenDateNote.isArchived(), CalenderNotesListFragment.myChosenDateNote.getId()); noteDataBase.dateNoreDAO().updateDate(titleTxt.getText().toString(), bodyTxt.getText().toString(),
CalenderNotesListFragment.myChosenDateNote.isArchived(), CalenderNotesListFragment.myChosenDateNote.getId() ,CalenderNotesListFragment.myChosenDateNote.getFolders() );
Toast.makeText(getActivity(), "updated", Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(), "updated", Toast.LENGTH_SHORT).show();
} }
} }
......
...@@ -160,6 +160,9 @@ public class CalenderNotesListFragment extends Fragment { ...@@ -160,6 +160,9 @@ public class CalenderNotesListFragment extends Fragment {
public void onCloseClicked() { public void onCloseClicked() {
closeClicked(); closeClicked();
} }
@Override
public void onFolderClicked() { }
}); });
} }
...@@ -206,7 +209,7 @@ public class CalenderNotesListFragment extends Fragment { ...@@ -206,7 +209,7 @@ public class CalenderNotesListFragment extends Fragment {
} }
private void updatearchivedDatesInDataBase() { private void updatearchivedDatesInDataBase() {
noteDataBase.dateNoreDAO().updateDate(myChosenDateNote.getDate(), myChosenDateNote.getDescription(), myChosenDateNote.isArchived(), myChosenDateNote.getId()); noteDataBase.dateNoreDAO().updateDate(myChosenDateNote.getDate(), myChosenDateNote.getDescription(), myChosenDateNote.isArchived(), myChosenDateNote.getId() , myChosenDateNote.getFolders());
} }
...@@ -215,7 +218,7 @@ public class CalenderNotesListFragment extends Fragment { ...@@ -215,7 +218,7 @@ public class CalenderNotesListFragment extends Fragment {
entityDates = noteDataBase.dateNoreDAO().getAllDateNotes(); entityDates = noteDataBase.dateNoreDAO().getAllDateNotes();
myDates = new ArrayList<>(); myDates = new ArrayList<>();
for (DateEntity dateEntity : entityDates) { for (DateEntity dateEntity : entityDates) {
MyDate myDate = new MyDate(dateEntity.getDate(), dateEntity.getDescription(), dateEntity.isarchived(), dateEntity.getID()); MyDate myDate = new MyDate(dateEntity.getDate(), dateEntity.getDescription(), dateEntity.isarchived(), dateEntity.getID() , dateEntity.getFolders());
myDates.add(myDate); myDates.add(myDate);
} }
} }
......
package com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.TimePicker; package com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.TimePicker;
import java.util.ArrayList;
public class MyDate { public class MyDate {
private String date , description ; private String date , description ;
private boolean isArchived; private boolean isArchived;
int id; private int id;
private ArrayList<String> folders;
public MyDate(String date, String description, boolean isarchived , int id) { public MyDate(String date, String description, boolean isarchived , int id , ArrayList<String> folders) {
this.date = date; this.date = date;
this.description = description; this.description = description;
this.isArchived = isarchived; this.isArchived = isarchived;
this.id = id; this.id = id;
this.folders = folders;
} }
public String getDate() { public String getDate() {
...@@ -32,4 +36,8 @@ public class MyDate { ...@@ -32,4 +36,8 @@ public class MyDate {
public int getId() { public int getId() {
return id; return id;
} }
public ArrayList<String> getFolders() {
return folders;
}
} }
...@@ -2,11 +2,13 @@ package com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.TimeP ...@@ -2,11 +2,13 @@ package com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.TimeP
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -20,6 +22,7 @@ import com.alirezaafkar.sundatepicker.DatePicker; ...@@ -20,6 +22,7 @@ import com.alirezaafkar.sundatepicker.DatePicker;
import com.alirezaafkar.sundatepicker.interfaces.DateSetListener; import com.alirezaafkar.sundatepicker.interfaces.DateSetListener;
import com.example.mynotepad.MenuFeatures.AllNotes.DataBase.DateEntity; import com.example.mynotepad.MenuFeatures.AllNotes.DataBase.DateEntity;
import com.example.mynotepad.MenuFeatures.Calender.Date; import com.example.mynotepad.MenuFeatures.Calender.Date;
import com.example.mynotepad.MenuFeatures.Utils;
import com.example.mynotepad.R; import com.example.mynotepad.R;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
...@@ -35,6 +38,7 @@ public class TimePickerFragment extends Fragment { ...@@ -35,6 +38,7 @@ public class TimePickerFragment extends Fragment {
private TextView description; private TextView description;
private Date mDate; private Date mDate;
private FloatingActionButton back; private FloatingActionButton back;
private ConstraintLayout allNotesListLayout;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
...@@ -48,8 +52,19 @@ public class TimePickerFragment extends Fragment { ...@@ -48,8 +52,19 @@ public class TimePickerFragment extends Fragment {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
init(view); init(view);
showTimePicker(); showTimePicker();
setBg(Utils.sTheme);
} }
private void setBg(String sTheme) {
switch (sTheme) {
case "dark":
allNotesListLayout.setBackgroundResource(R.drawable.main_bg_dark);
break;
case "bright":
allNotesListLayout.setBackgroundResource(R.drawable.main_bg_bright);
break;
}
}
private void init(View view) { private void init(View view) {
chosenDate = view.findViewById(R.id.myTitle); chosenDate = view.findViewById(R.id.myTitle);
...@@ -61,6 +76,14 @@ public class TimePickerFragment extends Fragment { ...@@ -61,6 +76,14 @@ public class TimePickerFragment extends Fragment {
showAlert(view); showAlert(view);
} }
}); });
allNotesListLayout = view.findViewById(R.id.noteLayout);
chosenDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showTimePicker();
}
});
} }
...@@ -113,7 +136,7 @@ public class TimePickerFragment extends Fragment { ...@@ -113,7 +136,7 @@ public class TimePickerFragment extends Fragment {
private void saveDateNote() { private void saveDateNote() {
//todo save in data base //todo save in data base
dateEntity = new DateEntity(chosenDate.getText().toString(), description.getText().toString(), false); dateEntity = new DateEntity(chosenDate.getText().toString(), description.getText().toString(), false , null);//todo ooooooooo add folders
noteDataBase.dateNoreDAO().insertDateNote(dateEntity); noteDataBase.dateNoreDAO().insertDateNote(dateEntity);
} }
} }
\ No newline at end of file
...@@ -10,8 +10,7 @@ import android.widget.LinearLayout; ...@@ -10,8 +10,7 @@ import android.widget.LinearLayout;
import com.example.mynotepad.R; import com.example.mynotepad.R;
public class CustomToolbarOption extends LinearLayout implements View.OnClickListener { public class CustomToolbarOption extends LinearLayout implements View.OnClickListener {
private View rootView; private ImageView blackStarImg, yellowStarImg, deleteImg, closeImg, folderImg;
private ImageView blackStarImg , yellowStarImg , deleteImg , closeImg;
private CustomToolbarOptionListener customToolbarOptionListener; private CustomToolbarOptionListener customToolbarOptionListener;
public CustomToolbarOption(Context context) { public CustomToolbarOption(Context context) {
...@@ -24,30 +23,33 @@ public class CustomToolbarOption extends LinearLayout implements View.OnClickLis ...@@ -24,30 +23,33 @@ public class CustomToolbarOption extends LinearLayout implements View.OnClickLis
init(context); init(context);
} }
private void init(Context context){ private void init(Context context) {
rootView = inflate(context, R.layout.custom_toolbar_options, this); View rootView = inflate(context, R.layout.custom_toolbar_options, this);
blackStarImg = findViewById(R.id.black_star); blackStarImg = findViewById(R.id.black_star);
yellowStarImg = findViewById(R.id.yellow_star); yellowStarImg = findViewById(R.id.yellow_star);
deleteImg = findViewById(R.id.deleteImg); deleteImg = findViewById(R.id.deleteImg);
closeImg = findViewById(R.id.closeImg); closeImg = findViewById(R.id.closeImg);
folderImg = findViewById(R.id.folderImg);
yellowStarImg.setOnClickListener(this); yellowStarImg.setOnClickListener(this);
blackStarImg.setOnClickListener(this); blackStarImg.setOnClickListener(this);
deleteImg.setOnClickListener(this); deleteImg.setOnClickListener(this);
closeImg.setOnClickListener(this); closeImg.setOnClickListener(this);
folderImg.setOnClickListener(this);
} }
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (customToolbarOptionListener != null){ if (customToolbarOptionListener != null) {
if (view.getId() == closeImg.getId()) if (view.getId() == closeImg.getId())
customToolbarOptionListener.onCloseClicked(); customToolbarOptionListener.onCloseClicked();
if (view.getId() == deleteImg.getId()) if (view.getId() == deleteImg.getId())
customToolbarOptionListener.onDeleteClicked(); customToolbarOptionListener.onDeleteClicked();
if (view.getId() == yellowStarImg.getId() || view.getId() == blackStarImg.getId()) if (view.getId() == yellowStarImg.getId() || view.getId() == blackStarImg.getId())
customToolbarOptionListener.onStarClicked(); customToolbarOptionListener.onStarClicked();
if (view.getId() == folderImg.getId())
customToolbarOptionListener.onFolderClicked();
} }
} }
...@@ -55,22 +57,27 @@ public class CustomToolbarOption extends LinearLayout implements View.OnClickLis ...@@ -55,22 +57,27 @@ public class CustomToolbarOption extends LinearLayout implements View.OnClickLis
this.customToolbarOptionListener = customToolbarOptionListener; this.customToolbarOptionListener = customToolbarOptionListener;
} }
public void setYellowStar(){ public void setYellowStar() {
yellowStarImg.setVisibility(VISIBLE); yellowStarImg.setVisibility(VISIBLE);
blackStarImg.setVisibility(GONE); blackStarImg.setVisibility(GONE);
} }
public void setBlackStar(){ public void setBlackStar() {
yellowStarImg.setVisibility(GONE); yellowStarImg.setVisibility(GONE);
blackStarImg.setVisibility(VISIBLE); blackStarImg.setVisibility(VISIBLE);
} }
public void hideRecycleBin(){ public void hideRecycleBin() {
deleteImg.setVisibility(GONE); deleteImg.setVisibility(GONE);
} }
public void hideStar(){ public void hideStar() {
yellowStarImg.setVisibility(GONE); yellowStarImg.setVisibility(GONE);
blackStarImg.setVisibility(GONE); blackStarImg.setVisibility(GONE);
} }
public void hideFolder() {
folderImg.setVisibility(GONE);
folderImg.setVisibility(GONE);
}
} }
...@@ -5,4 +5,5 @@ public interface CustomToolbarOptionListener { ...@@ -5,4 +5,5 @@ public interface CustomToolbarOptionListener {
void onStarClicked(); void onStarClicked();
void onDeleteClicked(); void onDeleteClicked();
void onCloseClicked(); void onCloseClicked();
void onFolderClicked();
} }
...@@ -125,6 +125,7 @@ public class AudioListFragment extends Fragment { ...@@ -125,6 +125,7 @@ public class AudioListFragment extends Fragment {
public void onItemLongClicked(MyVoice item) { public void onItemLongClicked(MyVoice item) {
customToolbarOption.setVisibility(View.VISIBLE); customToolbarOption.setVisibility(View.VISIBLE);
customToolbarOption.hideStar(); customToolbarOption.hideStar();
customToolbarOption.hideFolder();
myChosenVoice = item; myChosenVoice = item;
} }
}); });
...@@ -144,6 +145,11 @@ public class AudioListFragment extends Fragment { ...@@ -144,6 +145,11 @@ public class AudioListFragment extends Fragment {
public void onCloseClicked() { public void onCloseClicked() {
customToolbarOption.setVisibility(View.GONE); customToolbarOption.setVisibility(View.GONE);
} }
@Override
public void onFolderClicked() {
}
}); });
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="50dp" android:layout_height="50dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?colorPrimary" android:background="?colorPrimary"
android:orientation="horizontal"> android:orientation="horizontal">
...@@ -12,20 +13,21 @@ ...@@ -12,20 +13,21 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_marginRight="20dp" android:layout_marginRight="20dp"
app:tint="?android:textColorPrimary"
android:src="@drawable/close" /> android:src="@drawable/close" />
<FrameLayout <FrameLayout
android:id="@+id/star" android:id="@+id/star"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignRight="@+id/closeImg" android:layout_alignRight="@+id/folderImg"
android:layout_marginRight="40dp"> android:layout_marginRight="40dp">
<ImageView <ImageView
android:id="@+id/black_star" android:id="@+id/black_star"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
app:tint="?android:textColorPrimary"
android:src="@drawable/ic_black_star" /> android:src="@drawable/ic_black_star" />
<ImageView <ImageView
...@@ -34,14 +36,25 @@ ...@@ -34,14 +36,25 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:src="@drawable/ic_yellow_star" /> android:src="@drawable/ic_yellow_star" />
</FrameLayout> </FrameLayout>
<ImageView
android:id="@+id/folderImg"
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:tint="?android:textColorPrimary"
android:layout_alignRight="@id/deleteImg"
android:layout_marginRight="40dp"
android:src="@drawable/folder" />
<ImageView <ImageView
android:id="@+id/deleteImg" android:id="@+id/deleteImg"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignRight="@id/star" android:layout_alignRight="@id/closeImg"
android:layout_marginRight="40dp" android:layout_marginRight="40dp"
app:tint="?android:textColorPrimary"
android:src="@drawable/ic_bin" /> android:src="@drawable/ic_bin" />
......
...@@ -3,6 +3,10 @@ buildscript { ...@@ -3,6 +3,10 @@ buildscript {
repositories { repositories {
maven {url 'http://maven.google.com'} maven {url 'http://maven.google.com'}
jcenter() jcenter()
maven {
url "https://jitpack.io"
}
} }
dependencies { dependencies {
classpath "com.android.tools.build:gradle:4.0.1" classpath "com.android.tools.build:gradle:4.0.1"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment