11package com .moradi .quicknotes ;
22
33import androidx .annotation .NonNull ;
4+ import androidx .appcompat .app .ActionBar ;
5+ import androidx .appcompat .app .AlertDialog ;
46import androidx .appcompat .app .AppCompatActivity ;
57import androidx .appcompat .app .AppCompatDelegate ;
68import androidx .appcompat .widget .SearchView ;
1315import androidx .recyclerview .widget .RecyclerView ;
1416
1517import android .annotation .SuppressLint ;
18+ import android .content .DialogInterface ;
1619import android .content .Intent ;
1720import android .database .Cursor ;
1821import 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
0 commit comments