Commit cae9b67c authored by 9731301's avatar 9731301

add custom dialogs to add folders

parent db2e8c72
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<option name="modules"> <option name="modules">
<set> <set>
<option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/PersianCalendar" />
<option value="$PROJECT_DIR$/app" /> <option value="$PROJECT_DIR$/app" />
</set> </set>
</option> </option>
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name=".MenuFeatures.Pics.Camera.CameraActivity"></activity> <activity android:name=".MenuFeatures.Folders.FoldersActivity"></activity>
<activity android:name=".MenuFeatures.Pics.Camera.CameraActivity" />
<activity android:name=".MenuFeatures.Pics.PicsActivity" /> <activity android:name=".MenuFeatures.Pics.PicsActivity" />
<activity android:name=".MenuFeatures.Calender.MyCalenderActivity" /> <activity android:name=".MenuFeatures.Calender.MyCalenderActivity" />
<activity android:name=".MenuFeatures.VoiceMassages.VoiceMassagesActivity" /> <activity android:name=".MenuFeatures.VoiceMassages.VoiceMassagesActivity" />
......
package com.example.mynotepad.Dialogs.FoldersCustomDialog;
import android.app.Activity;
import android.app.Dialog;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import com.example.mynotepad.R;
public class CreateNewFolderDialog {
private TextView cancel , done;
private EditText folderName;
private OnCreateNewFolderDialogClickListener onCreateNewFolderDialogClickListener;
public void showDialog(Activity activity){
Dialog dialog = new Dialog(activity);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
dialog.setCancelable(true);
dialog.setContentView(R.layout.dialog_create_new_folder);
cancel = dialog.findViewById(R.id.cancel);
done = dialog.findViewById(R.id.done);
folderName = dialog.findViewById(R.id.folderName);
addListener(dialog);
dialog.show();
}
private void addListener(final Dialog dialog) {
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
done.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!folderName.getText().toString().equals(""))
onCreateNewFolderDialogClickListener.onDoneClicked(folderName.getText().toString());
dialog.dismiss();
}
});
}
public void setOnCreateNewFolderDialogClickListener(OnCreateNewFolderDialogClickListener onCreateNewFolderDialogClickListener) {
this.onCreateNewFolderDialogClickListener = onCreateNewFolderDialogClickListener;
}
}
package com.example.mynotepad.Dialogs.FoldersCustomDialog;
import android.app.Activity;
import android.app.Dialog;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.widget.LinearLayout;
import androidx.recyclerview.widget.RecyclerView;
import com.example.mynotepad.R;
public class FoldersDialog {
private RecyclerView recyclerView;
private LinearLayout addNewFolder;
public void showDialog(final Activity activity){
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);
dialog.show();
addNewFolder.setOnClickListener(new View.OnClickListener() {
@Override
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
}
});
}
});
}
}
package com.example.mynotepad.Dialogs.FoldersCustomDialog;
public interface OnCreateNewFolderDialogClickListener {
void onDoneClicked(String newFolderName);
}
...@@ -17,7 +17,9 @@ import android.view.ViewGroup; ...@@ -17,7 +17,9 @@ import android.view.ViewGroup;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.Toast; import android.widget.Toast;
import com.example.mynotepad.Dialogs.CustomDialog; import com.example.mynotepad.Dialogs.CustomDialog;
import com.example.mynotepad.Dialogs.FoldersCustomDialog.FoldersDialog;
import com.example.mynotepad.Dialogs.onCustomDialogClickListener; import com.example.mynotepad.Dialogs.onCustomDialogClickListener;
import com.example.mynotepad.MenuFeatures.AllNotes.DataBase.Note; import com.example.mynotepad.MenuFeatures.AllNotes.DataBase.Note;
import com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.MyAllNotesAdaptor; import com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.MyAllNotesAdaptor;
...@@ -154,7 +156,8 @@ public class AllNotesListFragment extends Fragment { ...@@ -154,7 +156,8 @@ public class AllNotesListFragment extends Fragment {
@Override @Override
public void onFolderClicked() { public void onFolderClicked() {
FoldersDialog foldersDialog = new FoldersDialog();
foldersDialog.showDialog(getActivity());
} }
}); });
} }
...@@ -200,7 +203,7 @@ public class AllNotesListFragment extends Fragment { ...@@ -200,7 +203,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.getFolders()); , myChosenNote.isArchived(), myChosenNote.getId(), myChosenNote.getFolders());
} }
...@@ -211,6 +214,7 @@ public class AllNotesListFragment extends Fragment { ...@@ -211,6 +214,7 @@ public class AllNotesListFragment extends Fragment {
public void yesClicked() { public void yesClicked() {
showABlankNote(); showABlankNote();
} }
@Override @Override
public void noClicked() { public void noClicked() {
} }
...@@ -234,7 +238,7 @@ public class AllNotesListFragment extends Fragment { ...@@ -234,7 +238,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() , note.getFolders()); 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.Folders;
import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import com.example.mynotepad.MenuFeatures.AllArchivedNotes.MyArchivedNotesRecyclerView.DateOrNote;
import com.example.mynotepad.MenuFeatures.AllArchivedNotes.MyArchivedNotesRecyclerView.MyArchivedAdaptor;
import com.example.mynotepad.MenuFeatures.AllNotes.DataBase.DateEntity;
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.R;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
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() {
}
}
\ No newline at end of file
...@@ -70,6 +70,7 @@ public class AudioListFragment extends Fragment { ...@@ -70,6 +70,7 @@ public class AudioListFragment extends Fragment {
setBottomSheet(); setBottomSheet();
customToolbarOption = v.findViewById(R.id.customToolbarOption); customToolbarOption = v.findViewById(R.id.customToolbarOption);
customToolbarOption.setVisibility(View.GONE); customToolbarOption.setVisibility(View.GONE);
allNoteToolBar = v.findViewById(R.id.toolbar);
myVoiceArrayList = new ArrayList<>(); myVoiceArrayList = new ArrayList<>();
playerPlayBtn = v.findViewById(R.id.player_play_btn); playerPlayBtn = v.findViewById(R.id.player_play_btn);
headerTitleTv = v.findViewById(R.id.player_header_title); headerTitleTv = v.findViewById(R.id.player_header_title);
...@@ -124,6 +125,7 @@ public class AudioListFragment extends Fragment { ...@@ -124,6 +125,7 @@ public class AudioListFragment extends Fragment {
@Override @Override
public void onItemLongClicked(MyVoice item) { public void onItemLongClicked(MyVoice item) {
customToolbarOption.setVisibility(View.VISIBLE); customToolbarOption.setVisibility(View.VISIBLE);
allNoteToolBar.setVisibility(View.GONE);
customToolbarOption.hideStar(); customToolbarOption.hideStar();
customToolbarOption.hideFolder(); customToolbarOption.hideFolder();
myChosenVoice = item; myChosenVoice = item;
...@@ -144,6 +146,7 @@ public class AudioListFragment extends Fragment { ...@@ -144,6 +146,7 @@ public class AudioListFragment extends Fragment {
@Override @Override
public void onCloseClicked() { public void onCloseClicked() {
customToolbarOption.setVisibility(View.GONE); customToolbarOption.setVisibility(View.GONE);
allNoteToolBar.setVisibility(View.VISIBLE);
} }
@Override @Override
...@@ -167,8 +170,8 @@ public class AudioListFragment extends Fragment { ...@@ -167,8 +170,8 @@ public class AudioListFragment extends Fragment {
} }
} }
} }
customToolbarOption.setVisibility(View.GONE); customToolbarOption.setVisibility(View.GONE);
allNoteToolBar.setVisibility(View.VISIBLE);
recyclerViewRecordings.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false)); recyclerViewRecordings.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
recyclerViewRecordings.setHasFixedSize(true); recyclerViewRecordings.setHasFixedSize(true);
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape> <shape>
<solid android:color="?background"/> <solid android:color="?colorPrimary"/>
<corners android:radius="0dp" /> <corners android:radius="0dp" />
</shape> </shape>
</item> </item>
......
<?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>
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
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="25dp"
android:src="@drawable/folder"
app:tint="?android:textColor"
android:layout_marginLeft="5dp"/>
<TextView
android:id="@+id/folderName"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:text="@string/txt"
android:textSize="20dp"
android:gravity="center_vertical"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="350dp"
android:layout_height="250dp"
android:orientation="vertical"
android:background="@drawable/bg_row">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="@string/add_folder"
android:gravity="center_vertical"
android:layout_marginLeft="25dp"
android:textSize="20sp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:hint="folder name"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:textSize="20sp"
android:id="@+id/folderName"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="cancel"
android:textSize="20sp"
android:id="@+id/cancel"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="done"
android:textSize="20sp"
android:id="@+id/done"/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?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"
android:layout_width="350dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/bg_row">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:orientation="horizontal"
android:id="@+id/addFolder">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="15dp"
android:src="@drawable/add"
app:tint="?android:textColor"
android:layout_marginLeft="5dp"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:text="@string/add_folder"
android:textSize="20dp"
android:gravity="center_vertical"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp"/>
</LinearLayout>
\ No newline at end of file
...@@ -7,37 +7,40 @@ ...@@ -7,37 +7,40 @@
android:orientation="vertical" android:orientation="vertical"
tools:context=".MenuFeatures.VoiceMassages.AudioListFragment"> tools:context=".MenuFeatures.VoiceMassages.AudioListFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout <FrameLayout
android:id="@+id/frameLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<FrameLayout <FrameLayout
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp"> android:layout_height="wrap_content">
</FrameLayout> </FrameLayout>
<com.example.mynotepad.MenuFeatures.CustomToolbarOption
android:id="@+id/customToolbarOption"
android:layout_width="match_parent"
android:layout_height="50dp"
app:layout_anchor="@+id/frameLayout"
app:layout_anchorGravity="center" />
</FrameLayout> </FrameLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView" android:id="@+id/recyclerView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginTop="50dp"
android:background="?colorButtonNormal" android:background="?colorButtonNormal"
tools:layout_editor_absoluteX="1dp" tools:layout_editor_absoluteX="1dp"
tools:layout_editor_absoluteY="1dp" /> tools:layout_editor_absoluteY="1dp" />
</LinearLayout>
<include layout="@layout/player_sheet"/> <include layout="@layout/player_sheet"/>
<com.example.mynotepad.MenuFeatures.CustomToolbarOption
android:id="@+id/customToolbarOption"
android:layout_width="match_parent"
android:layout_height="50dp"
app:layout_anchor="@+id/frameLayout"
app:layout_anchorGravity="center" />
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file
...@@ -28,4 +28,6 @@ ...@@ -28,4 +28,6 @@
<string name="back">back</string> <string name="back">back</string>
<string name="save">save</string> <string name="save">save</string>
<string name="saved_high_score_key" /> <string name="saved_high_score_key" />
<string name="txt">txt</string>
<string name="add_folder">Add folder</string>
</resources> </resources>
\ No newline at end of file
include ':PersianCalendar'
include ':app' include ':app'
rootProject.name = "MyNotepad" rootProject.name = "MyNotepad"
\ No newline at end of file
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