Skip to content

Commit 7f8f01b

Browse files
committed
App Update
- Added back button to each page - Added confirmation to delete "All Notes" - Updated icons for swipe left to right menu - Temporarily disabled "Settings" & "About" for updates for GitHub public launch
1 parent 3753b68 commit 7f8f01b

10 files changed

Lines changed: 126 additions & 31 deletions

File tree

.idea/misc.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/moradi/quicknotes/AddNotesActivity.java

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

3+
import androidx.annotation.NonNull;
4+
import androidx.appcompat.app.ActionBar;
35
import androidx.appcompat.app.AppCompatActivity;
46

57
import android.content.Intent;
68
import android.os.Bundle;
79
import android.text.TextUtils;
10+
import android.view.MenuItem;
811
import android.view.View;
912
import android.widget.Button;
1013
import android.widget.EditText;
@@ -21,15 +24,21 @@ protected void onCreate(Bundle savedInstanceState) {
2124
super.onCreate(savedInstanceState);
2225
setContentView(R.layout.activity_add_notes);
2326

27+
// calling the action bar
28+
ActionBar actionBar = getSupportActionBar();
29+
30+
// showing the back button in action bar
31+
actionBar.setDisplayHomeAsUpEnabled(true);
32+
2433
title = findViewById(R.id.title);
2534
description = findViewById(R.id.description);
2635
addNote = findViewById(R.id.addNote);
2736

2837
addNote.setOnClickListener(new View.OnClickListener() {
29-
@Override
30-
public void onClick(View v) {
3138

3239

40+
@Override
41+
public void onClick(View v) {
3342
if (!TextUtils.isEmpty(title.getText().toString()) && !TextUtils.isEmpty(description.getText().toString())) {
3443
DatabaseClass db = new DatabaseClass(AddNotesActivity.this);
3544
db.addNotes(title.getText().toString(), description.getText().toString());
@@ -42,10 +51,18 @@ public void onClick(View v) {
4251
} else {
4352
Toast.makeText(AddNotesActivity.this, "Title & Description Required", Toast.LENGTH_SHORT).show();
4453
}
45-
46-
4754
}
4855
});
49-
56+
}
57+
// this event will enable the back
58+
// function to the button on press
59+
@Override
60+
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
61+
switch (item.getItemId()) {
62+
case android.R.id.home:
63+
this.finish();
64+
return true;
65+
}
66+
return super.onOptionsItemSelected(item);
5067
}
5168
}

app/src/main/java/com/moradi/quicknotes/MainActivity.java

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.moradi.quicknotes;
22

33
import androidx.annotation.NonNull;
4+
import androidx.appcompat.app.ActionBar;
5+
import androidx.appcompat.app.AlertDialog;
46
import androidx.appcompat.app.AppCompatActivity;
57
import androidx.appcompat.app.AppCompatDelegate;
68
import androidx.appcompat.widget.SearchView;
@@ -13,6 +15,7 @@
1315
import androidx.recyclerview.widget.RecyclerView;
1416

1517
import android.annotation.SuppressLint;
18+
import android.content.DialogInterface;
1619
import android.content.Intent;
1720
import android.database.Cursor;
1821
import android.graphics.Color;
@@ -50,6 +53,7 @@ public class MainActivity extends AppCompatActivity {
5053
protected void onCreate(Bundle savedInstanceState) {
5154
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
5255
super.onCreate(savedInstanceState);
56+
5357
setTheme(R.style.LightTheme);
5458
setContentView(R.layout.nav_activity_main);
5559

@@ -62,10 +66,10 @@ protected void onCreate(Bundle savedInstanceState) {
6266
public void onClick(View v) {
6367
Intent intent = new Intent(MainActivity.this, AddNotesActivity.class);
6468
startActivity(intent);
65-
}
6669

67-
});
6870

71+
}
72+
});
6973
notesList = new ArrayList<>();
7074
databaseClass = new DatabaseClass(this);
7175
fetchAllNotesFromDatabase();
@@ -76,11 +80,8 @@ public void onClick(View v) {
7680

7781
ItemTouchHelper helper = new ItemTouchHelper(callback);
7882
helper.attachToRecyclerView(recyclerView);
79-
80-
8183
}
8284

83-
8485
void fetchAllNotesFromDatabase() {
8586
Cursor cursor = databaseClass.readAllData();
8687

@@ -125,24 +126,48 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
125126
deleteAllNotes();
126127
}
127128
else
129+
//ABOUT MENU
128130
if (item.getItemId() == R.id.about) {
129-
Intent intent = new Intent(MainActivity.this, About.class);
130-
startActivity(intent);
131+
Toast.makeText(this, "Temporarily removed for updates.", Toast.LENGTH_LONG).show();
132+
// Intent intent = new Intent(MainActivity.this, About.class);
133+
// startActivity(intent);
131134
return true;
132135
}
133136
else
134137
if (item.getItemId() == R.id.settings) {
135-
Intent intent = new Intent(MainActivity.this, Settings.class);
136-
startActivity(intent);
138+
Toast.makeText(this, "Temporarily removed for updates.", Toast.LENGTH_LONG).show();
139+
// Intent intent = new Intent(MainActivity.this, Settings.class);
140+
// startActivity(intent);
137141
return true;
138142
}
139143
return super.onOptionsItemSelected(item);
140144
}
141145

142146
private void deleteAllNotes() {
143-
DatabaseClass db = new DatabaseClass(MainActivity.this);
144-
db.deleteAllNotes();
145-
recreate();
147+
// DatabaseClass db = new DatabaseClass(MainActivity.this);
148+
// db.deleteAllNotes();
149+
// recreate();
150+
151+
AlertDialog.Builder builder = new AlertDialog.Builder(this);
152+
builder.setTitle("Confirm");
153+
builder.setMessage("Are you sure you want to delete all notes?");
154+
155+
builder.setPositiveButton("YES", new DialogInterface.OnClickListener() {
156+
public void onClick(DialogInterface dialog, int which) {
157+
DatabaseClass db = new DatabaseClass(MainActivity.this);
158+
db.deleteAllNotes();
159+
recreate();
160+
}
161+
});
162+
163+
builder.setNegativeButton("NO", new DialogInterface.OnClickListener() {
164+
@Override
165+
public void onClick(DialogInterface dialog, int which) {
166+
dialog.dismiss();
167+
}
168+
});
169+
AlertDialog alert = builder.create();
170+
alert.show();
146171
}
147172

148173

app/src/main/java/com/moradi/quicknotes/UpdateNotesActivity.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package com.moradi.quicknotes;
22

3+
import androidx.annotation.NonNull;
4+
import androidx.appcompat.app.ActionBar;
35
import androidx.appcompat.app.AppCompatActivity;
46

57
import android.content.Intent;
68
import android.os.Bundle;
79
import android.text.TextUtils;
10+
import android.view.MenuItem;
811
import android.view.View;
912
import android.widget.Button;
1013
import android.widget.EditText;
@@ -21,6 +24,12 @@ protected void onCreate(Bundle savedInstanceState) {
2124
super.onCreate(savedInstanceState);
2225
setContentView(R.layout.activity_update_notes);
2326

27+
// calling the action bar
28+
ActionBar actionBar = getSupportActionBar();
29+
30+
// showing the back button in action bar
31+
actionBar.setDisplayHomeAsUpEnabled(true);
32+
2433
title=findViewById(R.id.title);
2534
description=findViewById(R.id.description);
2635
updateNotes=findViewById(R.id.updateNote);
@@ -44,18 +53,21 @@ public void onClick(View v) {
4453
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
4554
startActivity(i);
4655
finish();
47-
48-
4956
}
5057
else
5158
{
5259
Toast.makeText(UpdateNotesActivity.this, "Both Fields Required", Toast.LENGTH_SHORT).show();
5360
}
54-
55-
5661
}
5762
});
58-
59-
63+
}
64+
@Override
65+
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
66+
switch (item.getItemId()) {
67+
case android.R.id.home:
68+
this.finish();
69+
return true;
70+
}
71+
return super.onOptionsItemSelected(item);
6072
}
6173
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24"
6+
android:tint="@color/white">
7+
<path
8+
android:fillColor="@android:color/white"
9+
android:pathData="M11.67,3.87L9.9,2.1 0,12l9.9,9.9 1.77,-1.77L3.54,12z"/>
10+
</vector>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24"
6+
android:tint="?attr/colorControlNormal">
7+
<path
8+
android:fillColor="@android:color/white"
9+
android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM16.23,18L12,15.45 7.77,18l1.12,-4.81 -3.73,-3.23 4.92,-0.42L12,5l1.92,4.53 4.92,0.42 -3.73,3.23L16.23,18z"/>
10+
</vector>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24"
6+
android:tint="?attr/colorControlNormal">
7+
<path
8+
android:fillColor="@android:color/white"
9+
android:pathData="M3,18h12v-2L3,16v2zM3,6v2h18L21,6L3,6zM3,13h18v-2L3,11v2z"/>
10+
</vector>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24"
6+
android:tint="?attr/colorControlNormal">
7+
<path
8+
android:fillColor="@android:color/white"
9+
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/>
10+
</vector>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
android:id="@+id/fab"
1414
android:layout_width="wrap_content"
1515
android:layout_height="wrap_content"
16-
android:layout_gravity="bottom|end"
16+
android:layout_gravity="bottom|right"
1717
android:layout_margin="16dp"
1818
android:backgroundTint="@color/design_default_color_primary_dark"
1919
android:src="@drawable/ic_baseline_add_24"

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
<menu>
99
<item
1010
android:id="@+id/nav_home"
11-
android:icon="@drawable/ic_menu_camera"
12-
android:title="@string/menu_home" />
11+
android:icon="@drawable/ic_baseline_notes_24"
12+
android:title="All Notes" />
1313
<item
1414
android:id="@+id/nav_gallery"
15-
android:icon="@drawable/ic_menu_gallery"
16-
android:title="@string/menu_gallery" />
15+
android:icon="@drawable/ic_baseline_favorites"
16+
android:title="Favorites" />
1717
<item
1818
android:id="@+id/nav_slideshow"
19-
android:icon="@drawable/ic_menu_slideshow"
20-
android:title="@string/menu_slideshow" />
19+
android:icon="@drawable/ic_baseline_trash"
20+
android:title="Trash" />
2121
</menu>
2222
</item>
2323
</group>

0 commit comments

Comments
 (0)