Skip to content

Commit ed41633

Browse files
committed
Feature Updates
- Back button re enabled in all notes to go to main activity -Added restart app button -Changed add note button color Working on -Save arrangement of moved notes by long click drag -Move pinned notes to position 1+++
1 parent 7f42190 commit ed41633

10 files changed

Lines changed: 106 additions & 40 deletions

File tree

app/src/main/java/com/btn/pronotes/MainActivity.java

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
import java.util.Locale;
3232

3333
public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuItemClickListener {
34-
RecyclerView recyclerView;
35-
NotesListAdapter notesListAdapter;
36-
List<Notes> notes = new ArrayList<>();
37-
RoomDB database;
38-
FloatingActionButton fab_add;
39-
SearchView searchView_home;
40-
Notes selectedNote;
34+
RecyclerView recyclerView;
35+
NotesListAdapter notesListAdapter;
36+
List<Notes> notes = new ArrayList<>();
37+
RoomDB database;
38+
FloatingActionButton fab_add;
39+
SearchView searchView_home;
40+
Notes selectedNote;
4141

4242
@Override
4343
protected void onCreate(Bundle savedInstanceState) {
@@ -56,12 +56,12 @@ protected void onCreate(Bundle savedInstanceState) {
5656
fab_add.setOnClickListener(new View.OnClickListener() {
5757
@Override
5858
public void onClick(View v) {
59-
Intent intent = new Intent(MainActivity.this, NotesTakerActivity.class);
60-
startActivityForResult(intent, 101); // adding note 101
59+
Intent intent = new Intent(MainActivity.this, NotesTakerActivity.class);
60+
startActivityForResult(intent, 101); // adding note 101
6161
}
6262
});
6363

64-
// Impliments the drag and drop movement of the notes
64+
// Implements the drag and drop movement of the notes
6565
ItemTouchHelper.SimpleCallback simpleCallback = new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT | ItemTouchHelper.START | ItemTouchHelper.END, 0) {
6666
@Override
6767
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
@@ -70,18 +70,19 @@ public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.
7070
int toPosition = target.getAdapterPosition();
7171
Collections.swap(notes, fromPosition, toPosition);
7272
recyclerView.getAdapter().notifyItemMoved(fromPosition, toPosition);
73-
return false;
73+
return true;
7474
}
75+
7576
@Override
7677
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
7778

7879
}
7980
};
8081
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleCallback);
81-
itemTouchHelper.attachToRecyclerView(recyclerView);
82+
itemTouchHelper.attachToRecyclerView(recyclerView);
8283

8384

84-
// End of drag and drop movement
85+
// End of drag and drop movement
8586

8687
//search box home code
8788
searchView_home.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@@ -97,6 +98,7 @@ public boolean onQueryTextChange(String newText) {
9798
}
9899
});
99100
}
101+
100102
@Override
101103
public boolean onCreateOptionsMenu(Menu menu) {
102104
MenuInflater inflater = getMenuInflater();
@@ -106,20 +108,31 @@ public boolean onCreateOptionsMenu(Menu menu) {
106108

107109
@Override
108110
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
109-
switch (item.getItemId()){
111+
switch (item.getItemId()) {
110112
case R.id.help:
111113
Toast.makeText(this, "Email: support@Brett-TechRepair.com", Toast.LENGTH_LONG).show();
112114
return true;
113115
}
116+
117+
switch (item.getItemId()){
118+
case R.id.reboot:
119+
120+
finish();
121+
startActivity(getIntent());
122+
// this provides animation
123+
overridePendingTransition(0, 0);
124+
125+
}
114126
return super.onOptionsItemSelected(item);
115127
}
116128

129+
117130
//note search filter code
118131
private void filter(String newText) {
119132
List<Notes> filteredList = new ArrayList<>();
120-
for (Notes singleNote : notes){
133+
for (Notes singleNote : notes) {
121134
if (singleNote.getTitle().toLowerCase().contains(newText.toLowerCase())
122-
|| singleNote.getNotes().toLowerCase().contains(newText.toLowerCase())){
135+
|| singleNote.getNotes().toLowerCase().contains(newText.toLowerCase())) {
123136
filteredList.add(singleNote);
124137
}
125138
}
@@ -142,18 +155,18 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten
142155
}
143156
}
144157
//Saving Note
145-
else if (requestCode==102 | resultCode==Activity.RESULT_OK){
158+
else if (requestCode == 102 | resultCode == Activity.RESULT_OK) {
146159
assert data != null;
147160
Notes new_notes = (Notes) data.getSerializableExtra("note");
148-
database.mainDAO().update(new_notes.getID(), new_notes.getTitle(), new_notes.getNotes());
149-
notes.clear();
150-
notes.addAll(database.mainDAO().getAll());
151-
notesListAdapter.notifyDataSetChanged();
161+
database.mainDAO().update(new_notes.getID(), new_notes.getTitle(), new_notes.getNotes());
162+
notes.clear();
163+
notes.addAll(database.mainDAO().getAll());
164+
notesListAdapter.notifyDataSetChanged();
152165
updateRecycler(notes);
153166
Toast.makeText(MainActivity.this, "Note Saved!", Toast.LENGTH_SHORT).show();
154167

155-
}
156168
}
169+
}
157170

158171
private void updateRecycler(List<Notes> notes) {
159172
recyclerView.setHasFixedSize(true);
@@ -190,20 +203,20 @@ private void showPopup(CardView cardView) {
190203
//Pinning notes //!!make a way to move pinned to top!!
191204
@Override
192205
public boolean onMenuItemClick(MenuItem item) {
193-
switch (item.getItemId()){
206+
switch (item.getItemId()) {
194207
case R.id.pin:
195-
if(selectedNote.isPinned()){
208+
if (selectedNote.isPinned()) {
196209
database.mainDAO().pin(selectedNote.getID(), false);
197210
Toast.makeText(MainActivity.this, "Unpinned!", Toast.LENGTH_SHORT).show();
198-
}
199-
else {
211+
} else {
200212
database.mainDAO().pin(selectedNote.getID(), true);
201213
Toast.makeText(MainActivity.this, "Pinned", Toast.LENGTH_SHORT).show();
202214
}
203215
notes.clear();
204216
notes.addAll(database.mainDAO().getAll());
205217
notesListAdapter.notifyDataSetChanged();
206-
return true;
218+
overridePendingTransition(0, 0);
219+
String time = System.currentTimeMillis() + "";
207220

208221
case R.id.delete:
209222
database.mainDAO().delete(selectedNote);
@@ -215,4 +228,5 @@ public boolean onMenuItemClick(MenuItem item) {
215228
return false;
216229
}
217230
}
218-
}
231+
}
232+

app/src/main/java/com/btn/pronotes/NotesTakerActivity.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package com.btn.pronotes;
22

3+
import androidx.activity.OnBackPressedCallback;
34
import androidx.appcompat.app.AppCompatActivity;
45

56
import android.app.Activity;
67
import android.content.Intent;
8+
import android.media.Image;
79
import android.os.Bundle;
10+
import android.provider.ContactsContract;
811
import android.view.View;
912
import android.widget.EditText;
1013
import android.widget.ImageView;
@@ -18,6 +21,7 @@
1821
public class NotesTakerActivity extends AppCompatActivity {
1922
EditText editText_title, editText_notes;
2023
ImageView imageView_save;
24+
ImageView imageView_back;
2125
Notes notes;
2226

2327
boolean isOldNote = false;
@@ -27,6 +31,7 @@ protected void onCreate(Bundle savedInstanceState) {
2731
setContentView(R.layout.activity_notes_taker);
2832

2933
imageView_save = findViewById(R.id.imageView_save);
34+
imageView_back = findViewById(R.id.imageView_back);
3035
editText_title = findViewById(R.id.editText_title);
3136
editText_notes = findViewById(R.id.editText_notes);
3237

@@ -67,5 +72,13 @@ public void onClick(View v) {
6772
finish();
6873
}
6974
});
75+
//back button inside of note
76+
imageView_back.setOnClickListener(new View.OnClickListener() {
77+
@Override
78+
public void onClick (View view){
79+
Intent back = new Intent(view.getContext(), MainActivity.class);
80+
startActivity(back);
81+
}
82+
});
7083
}
7184
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<vector android:autoMirrored="true" android:height="24dp"
22
android:tint="#FFFFFF" android:viewportHeight="24"
33
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4-
<path android:fillColor="@android:color/white" android:pathData="M11.67,3.87L9.9,2.1 0,12l9.9,9.9 1.77,-1.77L3.54,12z"/>
4+
<path android:fillColor="@android:color/black" android:pathData="M11.67,3.87L9.9,2.1 0,12l9.9,9.9 1.77,-1.77L3.54,12z"/>
55
</vector>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#FFFFFF"
2+
android:viewportHeight="24" android:viewportWidth="24"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="@android:color/white" android:pathData="M13,3h-2v10h2L13,3zM17.83,5.17l-1.42,1.42C17.99,7.86 19,9.81 19,12c0,3.87 -3.13,7 -7,7s-7,-3.13 -7,-7c0,-2.19 1.01,-4.14 2.58,-5.42L6.17,5.17C4.23,6.82 3,9.26 3,12c0,4.97 4.03,9 9,9s9,-4.03 9,-9c0,-2.74 -1.23,-5.18 -3.17,-6.83z"/>
5+
</vector>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3+
<solid android:color="@color/search"/>
4+
<corners android:radius="8dp"/>
5+
<padding android:left="8dp"
6+
android:bottom="8dp"
7+
android:right="8dp"
8+
android:top="8dp"/>
9+
</shape>

app/src/main/res/layout/activity_main.xml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
android:layout_marginTop="16dp"
1818
android:layout_marginEnd="16dp"
1919
android:layout_marginBottom="16dp"
20-
android:background="@color/grey"
20+
android:background="@drawable/roundedsearch"
2121
android:iconifiedByDefault="false"
2222
android:queryHint="Search Notes...">
2323

@@ -35,11 +35,14 @@
3535

3636
<com.google.android.material.floatingactionbutton.FloatingActionButton
3737
android:id="@+id/fab_add"
38-
android:layout_alignParentBottom="true"
39-
android:layout_alignParentEnd="true"
40-
android:src="@drawable/ic_add"
41-
android:layout_margin="24dp"
4238
android:layout_width="wrap_content"
43-
android:layout_height="wrap_content"/>
39+
android:layout_height="wrap_content"
40+
android:layout_alignParentEnd="true"
41+
android:layout_alignParentBottom="true"
42+
android:layout_marginStart="24dp"
43+
android:layout_marginTop="24dp"
44+
android:layout_marginEnd="24dp"
45+
android:layout_marginBottom="24dp"
46+
android:src="@drawable/ic_add" />
4447

4548
</RelativeLayout>

app/src/main/res/layout/activity_notes_taker.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@
3030
android:layout_width="?attr/actionBarSize"
3131
android:layout_height="?attr/actionBarSize"
3232
android:layout_alignParentStart="true"
33-
android:background="@android:color/transparent"
3433
android:padding="4dp"
3534
android:src="@drawable/ic_back"
36-
android:visibility="gone" />
35+
android:visibility="visible" />
3736
</RelativeLayout>
3837

3938

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<menu xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto">
4+
5+
<item android:id="@+id/help"
6+
android:icon="@drawable/ic_help"
7+
android:title="Help"/>
8+
9+
<item android:id="@+id/lock"
10+
android:icon="@drawable/ic_lock"
11+
android:title="lock"/>
12+
13+
<item android:id="@+id/reboot"
14+
android:icon="@drawable/ic_reboot"
15+
android:title="Restart App"/>
16+
17+
</menu>

app/src/main/res/menu/info_menu.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@
1010
android:icon="@drawable/ic_lock"
1111
android:title="lock"/>
1212

13+
<item android:id="@+id/reboot"
14+
android:icon="@drawable/ic_reboot"
15+
android:tooltipText="Reboot Application in case of errors"
16+
android:title="Hard Restart"/>
17+
1318
</menu>

app/src/main/res/values/colors.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<color name="purple_200">#FFBB86FC</color>
4-
<color name="purple_500">#FF6200EE</color>
4+
<color name="purple_500">#000000</color> '
5+
<!--<color name="purple_500">#FF6200EE</color> -->
56
<color name="purple_700">#FF3700B3</color>
6-
<color name="teal_200">#FF03DAC5</color>
7+
<color name="teal_200">#38FF00</color>
78
<color name="teal_700">#FF018786</color>
89
<color name="black">#FF000000</color>
910
<color name="white">#FFFFFFFF</color>
@@ -16,7 +17,7 @@
1617
<color name="color4">#4EDA2E</color>
1718
<color name="color5">#FF5722</color>
1819

19-
<color name="search">#A8A8A8</color>
20+
<color name="search">?android:attr/windowBackground</color>
2021

2122

2223
</resources>

0 commit comments

Comments
 (0)