From 46e6c000ff1fb47453bd3ad62f4012176e9d9396 Mon Sep 17 00:00:00 2001 From: Petru Trimbitas Date: Thu, 30 May 2013 11:44:02 +0300 Subject: [PATCH] add interface to delete event --- res/menu/eventmenu.xml | 12 ++++++++ res/menu/{options.xml => mainmenu.xml} | 3 -- res/values/strings.xml | 5 +++- src/ro/ieval/unical/deleteEventDialog.java | 28 +++++++++++++++++++ src/ro/ieval/unical/displayEventActivity.java | 21 +++++++++++++- src/ro/ieval/unical/mainActivity.java | 7 ++++- 6 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 res/menu/eventmenu.xml rename res/menu/{options.xml => mainmenu.xml} (67%) create mode 100644 src/ro/ieval/unical/deleteEventDialog.java diff --git a/res/menu/eventmenu.xml b/res/menu/eventmenu.xml new file mode 100644 index 0000000..9a454e1 --- /dev/null +++ b/res/menu/eventmenu.xml @@ -0,0 +1,12 @@ + + + + + + + + + diff --git a/res/menu/options.xml b/res/menu/mainmenu.xml similarity index 67% rename from res/menu/options.xml rename to res/menu/mainmenu.xml index 6060d5a..6cc0074 100644 --- a/res/menu/options.xml +++ b/res/menu/mainmenu.xml @@ -6,9 +6,6 @@ android:titleCondensed="NEW"> - diff --git a/res/values/strings.xml b/res/values/strings.xml index 11f2e86..4a95438 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -10,7 +10,10 @@ User: Pass: Location: - Repeating + Repeating + Yes + No + Delete this event ? Daily diff --git a/src/ro/ieval/unical/deleteEventDialog.java b/src/ro/ieval/unical/deleteEventDialog.java new file mode 100644 index 0000000..8518615 --- /dev/null +++ b/src/ro/ieval/unical/deleteEventDialog.java @@ -0,0 +1,28 @@ +package ro.ieval.unical; + +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.DialogFragment; +import android.content.DialogInterface; +import android.os.Bundle; + +public class deleteEventDialog extends DialogFragment { + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + // Use the Builder class for convenient dialog construction + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + builder.setMessage(R.string.askdeleteevent) + .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + // FIRE ZE MISSILES! + } + }) + .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + // User cancelled the dialog + } + }); + // Create the AlertDialog object and return it + return builder.create(); + } +} diff --git a/src/ro/ieval/unical/displayEventActivity.java b/src/ro/ieval/unical/displayEventActivity.java index fb76934..005de08 100644 --- a/src/ro/ieval/unical/displayEventActivity.java +++ b/src/ro/ieval/unical/displayEventActivity.java @@ -3,9 +3,11 @@ package ro.ieval.unical; import java.util.Date; import android.app.Activity; +import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; +import android.view.MenuItem; import android.widget.TextView; public class displayEventActivity extends Activity { @@ -31,7 +33,24 @@ public class displayEventActivity extends Activity { // TODO Auto-generated method stub // nu stiu cum sa pun delete in loc de new event MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.options, menu); + inflater.inflate(R.menu.eventmenu, menu); return true; } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle item selection + switch (item.getItemId()) { + case R.id.NewEvent: + Intent i=new Intent(this,addEventActivity.class); + startActivity(i); + return true; + case R.id.deleteevent: + deleteEventDialog d=new deleteEventDialog(); + d.show(getFragmentManager(), "Delete"); + return true; + default: + return true; + } + } } diff --git a/src/ro/ieval/unical/mainActivity.java b/src/ro/ieval/unical/mainActivity.java index 3bfd07f..2c6a95b 100644 --- a/src/ro/ieval/unical/mainActivity.java +++ b/src/ro/ieval/unical/mainActivity.java @@ -3,6 +3,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; +import android.provider.CalendarContract.Events; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -23,13 +24,17 @@ public class mainActivity extends android.app.Activity { Intent i=new Intent(this,loginActivity.class); startActivity(i); } + Intent i=new Intent(this,displayEventActivity.class); + Event e[]=Event.getEventsByCalendar(this, Calendar.getAllCalendars(this)[0]._id, Events.DTSTART); + i.putExtra(displayEventActivity.EXTRA_EVENT, e[0]); + startActivity(i); } @Override public boolean onCreateOptionsMenu(Menu menu) { // TODO Auto-generated method stub MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.options, menu); + inflater.inflate(R.menu.mainmenu, menu); return true; } -- 2.39.2