Skip to content

Commit 50c4d21

Browse files
committed
Bug Fixes
- Modified MainDAO / List Notes to now order by pinned instead of ID so pinned notes will now attach to top - Added updateRecycler(notes) to better assist in notes being update immediately - Added non working checkbox option to Pin | Unpin menu item to be updated at a later date
1 parent ed41633 commit 50c4d21

8 files changed

Lines changed: 41 additions & 11 deletions

File tree

app/src/main/java/com/btn/pronotes/Database/MainDAO.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public interface MainDAO {
1717
void insert(Notes notes);
1818

1919
//List Notes
20-
@Query("SELECT * FROM notes ORDER BY id DESC") //Show Latest added notes on top
20+
@Query("SELECT * FROM notes ORDER BY pinned DESC")//Show pinned notes on top by descending order
2121
List<Notes> getAll();
2222

2323
//Update Items
@@ -28,6 +28,10 @@ public interface MainDAO {
2828
@Delete
2929
void delete(Notes notes);
3030

31+
//Update pinned
3132
@Query("UPDATE notes SET pinned = :pin WHERE ID = :id")
3233
void pin(int id, boolean pin);
34+
35+
36+
// implement code to update re arranged notes
3337
}

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

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

3+
import androidx.annotation.CheckResult;
34
import androidx.annotation.NonNull;
45
import androidx.annotation.Nullable;
56
import androidx.appcompat.app.AppCompatActivity;
@@ -8,6 +9,7 @@
89
import androidx.recyclerview.widget.LinearLayoutManager;
910
import androidx.recyclerview.widget.RecyclerView;
1011
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
12+
import androidx.room.Query;
1113

1214
import android.app.Activity;
1315
import android.content.Intent;
@@ -16,6 +18,8 @@
1618
import android.view.MenuInflater;
1719
import android.view.MenuItem;
1820
import android.view.View;
21+
import android.widget.CheckBox;
22+
import android.widget.Checkable;
1923
import android.widget.PopupMenu;
2024
import android.widget.SearchView;
2125
import android.widget.Toast;
@@ -39,6 +43,12 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI
3943
SearchView searchView_home;
4044
Notes selectedNote;
4145

46+
@Override
47+
protected void onStart() {
48+
super.onStart();
49+
Toast.makeText(this, "Welcome To Pro Notes by BTN", Toast.LENGTH_SHORT).show();
50+
}
51+
4252
@Override
4353
protected void onCreate(Bundle savedInstanceState) {
4454
super.onCreate(savedInstanceState);
@@ -113,6 +123,10 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
113123
Toast.makeText(this, "Email: support@Brett-TechRepair.com", Toast.LENGTH_LONG).show();
114124
return true;
115125
}
126+
switch (item.getItemId()){
127+
case R.id.lock:
128+
Toast.makeText(this, "COMING SOON", Toast.LENGTH_SHORT).show();
129+
}
116130

117131
switch (item.getItemId()){
118132
case R.id.reboot:
@@ -151,6 +165,7 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten
151165
notes.clear();
152166
notes.addAll(database.mainDAO().getAll());
153167
notesListAdapter.notifyDataSetChanged();
168+
updateRecycler(notes);
154169

155170
}
156171
}
@@ -193,7 +208,8 @@ public void onLongClick(Notes notes, CardView cardView) {
193208
}
194209
};
195210

196-
private void showPopup(CardView cardView) {
211+
212+
public void showPopup(CardView cardView) {
197213
PopupMenu popupMenu = new PopupMenu(this, cardView);
198214
popupMenu.setOnMenuItemClickListener(this);
199215
popupMenu.inflate(R.menu.popup_menu);
@@ -207,16 +223,17 @@ public boolean onMenuItemClick(MenuItem item) {
207223
case R.id.pin:
208224
if (selectedNote.isPinned()) {
209225
database.mainDAO().pin(selectedNote.getID(), false);
210-
Toast.makeText(MainActivity.this, "Unpinned!", Toast.LENGTH_SHORT).show();
226+
Toast.makeText(MainActivity.this, "Note Unpinned!", Toast.LENGTH_SHORT).show();
211227
} else {
212228
database.mainDAO().pin(selectedNote.getID(), true);
213-
Toast.makeText(MainActivity.this, "Pinned", Toast.LENGTH_SHORT).show();
214-
}
229+
Toast.makeText(MainActivity.this, "Note Pinned", Toast.LENGTH_SHORT).show();
230+
}
215231
notes.clear();
216232
notes.addAll(database.mainDAO().getAll());
217233
notesListAdapter.notifyDataSetChanged();
218234
overridePendingTransition(0, 0);
219235
String time = System.currentTimeMillis() + "";
236+
return true;
220237

221238
case R.id.delete:
222239
database.mainDAO().delete(selectedNote);
@@ -230,3 +247,4 @@ public boolean onMenuItemClick(MenuItem item) {
230247
}
231248
}
232249

250+

app/src/main/java/com/btn/pronotes/Models/Notes.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class Notes implements Serializable {
2323
@ColumnInfo(name = "pinned")
2424
boolean pinned = false;
2525

26+
2627
//Getter Setter
2728
public int getID() {
2829
return ID;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
android:layout_height="match_parent"
77
android:orientation="vertical"
88
android:background="@color/black"
9+
android:alwaysRetainTaskState="true"
910
tools:context=".MainActivity">
1011

1112
<SearchView

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
android:layout_height="match_parent"
77
android:orientation="vertical"
88
android:background="@color/black"
9+
android:alwaysRetainTaskState="true"
910
tools:context=".NotesTakerActivity">
1011
<Toolbar
1112
android:id="@+id/toolbar_notes"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
android:id="@+id/notes_container"
88
app:cardCornerRadius="8dp"
99
android:elevation="8dp"
10+
android:alwaysRetainTaskState="true"
1011
android:layout_margin="8dp"
1112
>
1213

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<?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">
2+
<menu xmlns:android="http://schemas.android.com/apk/res/android">
43

54
<item android:id="@+id/help"
65
android:icon="@drawable/ic_help"
76
android:title="Help"/>
87

98
<item android:id="@+id/lock"
109
android:icon="@drawable/ic_lock"
11-
android:title="lock"/>
10+
android:title="lock" />
1211

1312
<item android:id="@+id/reboot"
1413
android:icon="@drawable/ic_reboot"
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<menu xmlns:android="http://schemas.android.com/apk/res/android">
3-
<item android:id="@+id/pin"
4-
android:title="Pin/Unpin"/>
3+
4+
<item android:id="@+id/pin"
5+
android:title="Pin | Unpin"
6+
android:checkable="true"
7+
/>
8+
59
<item android:id="@+id/delete"
610
android:title="Delete"/>
7-
</menu>
11+
</menu>
12+

0 commit comments

Comments
 (0)