Skip to content

Commit

Permalink
App Update
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
hudson1740 committed Nov 4, 2021
1 parent 3753b68 commit 7f8f01b
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 31 deletions.
3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 22 additions & 5 deletions app/src/main/java/com/moradi/quicknotes/AddNotesActivity.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.moradi.quicknotes;

import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
Expand All @@ -21,15 +24,21 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_notes);

// calling the action bar
ActionBar actionBar = getSupportActionBar();

// showing the back button in action bar
actionBar.setDisplayHomeAsUpEnabled(true);

title = findViewById(R.id.title);
description = findViewById(R.id.description);
addNote = findViewById(R.id.addNote);

addNote.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {


@Override
public void onClick(View v) {
if (!TextUtils.isEmpty(title.getText().toString()) && !TextUtils.isEmpty(description.getText().toString())) {
DatabaseClass db = new DatabaseClass(AddNotesActivity.this);
db.addNotes(title.getText().toString(), description.getText().toString());
Expand All @@ -42,10 +51,18 @@ public void onClick(View v) {
} else {
Toast.makeText(AddNotesActivity.this, "Title & Description Required", Toast.LENGTH_SHORT).show();
}


}
});

}
// this event will enable the back
// function to the button on press
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
this.finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}
49 changes: 37 additions & 12 deletions app/src/main/java/com/moradi/quicknotes/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.moradi.quicknotes;

import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.SearchView;
Expand All @@ -13,6 +15,7 @@
import androidx.recyclerview.widget.RecyclerView;

import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Color;
Expand Down Expand Up @@ -50,6 +53,7 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
super.onCreate(savedInstanceState);

setTheme(R.style.LightTheme);
setContentView(R.layout.nav_activity_main);

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

});

}
});
notesList = new ArrayList<>();
databaseClass = new DatabaseClass(this);
fetchAllNotesFromDatabase();
Expand All @@ -76,11 +80,8 @@ public void onClick(View v) {

ItemTouchHelper helper = new ItemTouchHelper(callback);
helper.attachToRecyclerView(recyclerView);


}


void fetchAllNotesFromDatabase() {
Cursor cursor = databaseClass.readAllData();

Expand Down Expand Up @@ -125,24 +126,48 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
deleteAllNotes();
}
else
//ABOUT MENU
if (item.getItemId() == R.id.about) {
Intent intent = new Intent(MainActivity.this, About.class);
startActivity(intent);
Toast.makeText(this, "Temporarily removed for updates.", Toast.LENGTH_LONG).show();
// Intent intent = new Intent(MainActivity.this, About.class);
// startActivity(intent);
return true;
}
else
if (item.getItemId() == R.id.settings) {
Intent intent = new Intent(MainActivity.this, Settings.class);
startActivity(intent);
Toast.makeText(this, "Temporarily removed for updates.", Toast.LENGTH_LONG).show();
// Intent intent = new Intent(MainActivity.this, Settings.class);
// startActivity(intent);
return true;
}
return super.onOptionsItemSelected(item);
}

private void deleteAllNotes() {
DatabaseClass db = new DatabaseClass(MainActivity.this);
db.deleteAllNotes();
recreate();
// DatabaseClass db = new DatabaseClass(MainActivity.this);
// db.deleteAllNotes();
// recreate();

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Confirm");
builder.setMessage("Are you sure you want to delete all notes?");

builder.setPositiveButton("YES", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
DatabaseClass db = new DatabaseClass(MainActivity.this);
db.deleteAllNotes();
recreate();
}
});

builder.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
}


Expand Down
24 changes: 18 additions & 6 deletions app/src/main/java/com/moradi/quicknotes/UpdateNotesActivity.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.moradi.quicknotes;

import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
Expand All @@ -21,6 +24,12 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_update_notes);

// calling the action bar
ActionBar actionBar = getSupportActionBar();

// showing the back button in action bar
actionBar.setDisplayHomeAsUpEnabled(true);

title=findViewById(R.id.title);
description=findViewById(R.id.description);
updateNotes=findViewById(R.id.updateNote);
Expand All @@ -44,18 +53,21 @@ public void onClick(View v) {
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
finish();


}
else
{
Toast.makeText(UpdateNotesActivity.this, "Both Fields Required", Toast.LENGTH_SHORT).show();
}


}
});


}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
this.finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_baseline_arrow_back.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="@color/white">
<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"/>
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_baseline_favorites.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
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"/>
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_baseline_notes_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M3,18h12v-2L3,16v2zM3,6v2h18L21,6L3,6zM3,13h18v-2L3,11v2z"/>
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_baseline_trash.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
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"/>
</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
android:backgroundTint="@color/design_default_color_primary_dark"
android:src="@drawable/ic_baseline_add_24"
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/menu/activity_main_drawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
<menu>
<item
android:id="@+id/nav_home"
android:icon="@drawable/ic_menu_camera"
android:title="@string/menu_home" />
android:icon="@drawable/ic_baseline_notes_24"
android:title="All Notes" />
<item
android:id="@+id/nav_gallery"
android:icon="@drawable/ic_menu_gallery"
android:title="@string/menu_gallery" />
android:icon="@drawable/ic_baseline_favorites"
android:title="Favorites" />
<item
android:id="@+id/nav_slideshow"
android:icon="@drawable/ic_menu_slideshow"
android:title="@string/menu_slideshow" />
android:icon="@drawable/ic_baseline_trash"
android:title="Trash" />
</menu>
</item>
</group>
Expand Down

0 comments on commit 7f8f01b

Please sign in to comment.