]> iEval git - unical.git/commitdiff
add interface to delete event
authorPetru Trimbitas <l3asketballplayer@yahoo.com>
Thu, 30 May 2013 08:44:02 +0000 (11:44 +0300)
committerPetru Trimbitas <l3asketballplayer@yahoo.com>
Thu, 30 May 2013 08:44:02 +0000 (11:44 +0300)
res/menu/eventmenu.xml [new file with mode: 0644]
res/menu/mainmenu.xml [new file with mode: 0644]
res/menu/options.xml [deleted file]
res/values/strings.xml
src/ro/ieval/unical/deleteEventDialog.java [new file with mode: 0644]
src/ro/ieval/unical/displayEventActivity.java
src/ro/ieval/unical/mainActivity.java

diff --git a/res/menu/eventmenu.xml b/res/menu/eventmenu.xml
new file mode 100644 (file)
index 0000000..9a454e1
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+    <item android:id="@+id/deleteevent" android:icon="@android:drawable/ic_menu_delete" android:title="Delete Event" android:visible="true" android:titleCondensed="DELETE" android:showAsAction="always"></item>
+    <item android:id="@+id/NewEvent" android:title="New event" 
+        android:visible="true" android:showAsAction="ifRoom"
+        android:icon="@android:drawable/ic_menu_add"
+    android:titleCondensed="NEW">
+        
+    </item>
+    
+
+</menu>
diff --git a/res/menu/mainmenu.xml b/res/menu/mainmenu.xml
new file mode 100644 (file)
index 0000000..6cc0074
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+    <item android:id="@+id/NewEvent" android:title="New event" 
+        android:visible="true" android:showAsAction="always"
+        android:icon="@android:drawable/ic_menu_add"
+    android:titleCondensed="NEW">
+        
+    </item>
+    
+
+</menu>
diff --git a/res/menu/options.xml b/res/menu/options.xml
deleted file mode 100644 (file)
index 6060d5a..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
-    <item android:id="@+id/NewEvent" android:title="New event" 
-        android:visible="true" android:showAsAction="always"
-        android:icon="@android:drawable/ic_menu_add"
-    android:titleCondensed="NEW">
-        
-    </item>
-    <item android:id="@+id/deleteevent"
-        android:icon="@android:drawable/ic_menu_delete"
-        android:titleCondensed="DELETE" android:title="Delete event"></item>
-    
-
-</menu>
index 11f2e86aa4c548fa26f5ce6ea739ffb081b919ea..4a9543825ca6774fac85c387a59489ce0be7b313 100644 (file)
     <string name="userlabel">User: </string>
     <string name="passwordlabel">Pass: </string>
     <string name="locationlabel">Location: </string>
-    <string name="repeatlabel">Repeating </string>
+    <string name="repeatlabel">Repeating</string>
+    <string name="yes">Yes</string>
+    <string name="no">No</string>
+    <string name="askdeleteevent">Delete this event ?</string>
     
     <string-array name="Repeat">
         <item>Daily</item>
diff --git a/src/ro/ieval/unical/deleteEventDialog.java b/src/ro/ieval/unical/deleteEventDialog.java
new file mode 100644 (file)
index 0000000..8518615
--- /dev/null
@@ -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();
+    }
+}
index fb76934a7411bc4ed37c79a703ef6148a291cce9..005de087972692b3b202260fed891e386b330bb1 100644 (file)
@@ -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;
+           }
+       }
 }
index 3bfd07fe84e3eb182c9a1ba47d673d9499265063..2c6a95bacbc254bc2d5206724e1280f0762ee021 100644 (file)
@@ -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;
        }
        
This page took 0.031021 seconds and 4 git commands to generate.