Commit f0633d15 authored by 9731301's avatar 9731301

change all notes structure to navigation

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