From 890394d16fed51f28834d1660e9c3536fdb37cea Mon Sep 17 00:00:00 2001 From: srowen Date: Fri, 29 Jun 2012 17:58:06 +0000 Subject: [PATCH] Consolidate one more calendar method. Insert events with ACTION_INSERT not ACTION_EDIT git-svn-id: https://zxing.googlecode.com/svn/trunk@2337 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- .../android/result/CalendarResultHandler.java | 44 +++++++++++++++++++ .../client/android/result/ResultHandler.java | 43 ------------------ 2 files changed, 44 insertions(+), 43 deletions(-) diff --git a/android/src/com/google/zxing/client/android/result/CalendarResultHandler.java b/android/src/com/google/zxing/client/android/result/CalendarResultHandler.java index ae921af62..eb028d7df 100644 --- a/android/src/com/google/zxing/client/android/result/CalendarResultHandler.java +++ b/android/src/com/google/zxing/client/android/result/CalendarResultHandler.java @@ -21,6 +21,7 @@ import com.google.zxing.client.result.CalendarParsedResult; import com.google.zxing.client.result.ParsedResult; import android.app.Activity; +import android.content.Intent; import java.text.DateFormat; import java.util.Date; @@ -64,6 +65,49 @@ public final class CalendarResultHandler extends ResultHandler { } } + /** + * Sends an intent to create a new calendar event by prepopulating the Add Event UI. Older + * versions of the system have a bug where the event title will not be filled out. + * + * @param summary A description of the event + * @param start The start time + * @param allDay if true, event is considered to be all day starting from start time + * @param end The end time (optional) + * @param location a text description of the event location + * @param description a text description of the event itself + */ + private void addCalendarEvent(String summary, + Date start, + boolean allDay, + Date end, + String location, + String description) { + Intent intent = new Intent(Intent.ACTION_INSERT); + intent.setType("vnd.android.cursor.item/event"); + long startMilliseconds = start.getTime(); + intent.putExtra("beginTime", startMilliseconds); + if (allDay) { + intent.putExtra("allDay", true); + } + long endMilliseconds; + if (end == null) { + if (allDay) { + // + 1 day + endMilliseconds = startMilliseconds + 24 * 60 * 60 * 1000; + } else { + endMilliseconds = startMilliseconds; + } + } else { + endMilliseconds = end.getTime(); + } + intent.putExtra("endTime", endMilliseconds); + intent.putExtra("title", summary); + intent.putExtra("eventLocation", location); + intent.putExtra("description", description); + launchIntent(intent); + } + + @Override public CharSequence getDisplayContents() { diff --git a/android/src/com/google/zxing/client/android/result/ResultHandler.java b/android/src/com/google/zxing/client/android/result/ResultHandler.java index 3f9e123e1..f39062243 100644 --- a/android/src/com/google/zxing/client/android/result/ResultHandler.java +++ b/android/src/com/google/zxing/client/android/result/ResultHandler.java @@ -42,7 +42,6 @@ import android.util.Log; import android.view.View; import java.util.Collection; -import java.util.Date; import java.util.Locale; /** @@ -203,48 +202,6 @@ public abstract class ResultHandler { return result.getType(); } - /** - * Sends an intent to create a new calendar event by prepopulating the Add Event UI. Older - * versions of the system have a bug where the event title will not be filled out. - * - * @param summary A description of the event - * @param start The start time - * @param allDay if true, event is considered to be all day starting from start time - * @param end The end time (optional) - * @param location a text description of the event location - * @param description a text description of the event itself - */ - final void addCalendarEvent(String summary, - Date start, - boolean allDay, - Date end, - String location, - String description) { - Intent intent = new Intent(Intent.ACTION_EDIT); - intent.setType("vnd.android.cursor.item/event"); - long startMilliseconds = start.getTime(); - intent.putExtra("beginTime", startMilliseconds); - if (allDay) { - intent.putExtra("allDay", true); - } - long endMilliseconds; - if (end == null) { - if (allDay) { - // + 1 day - endMilliseconds = startMilliseconds + 24 * 60 * 60 * 1000; - } else { - endMilliseconds = startMilliseconds; - } - } else { - endMilliseconds = end.getTime(); - } - intent.putExtra("endTime", endMilliseconds); - intent.putExtra("title", summary); - intent.putExtra("eventLocation", location); - intent.putExtra("description", description); - launchIntent(intent); - } - final void addPhoneOnlyContact(String[] phoneNumbers,String[] phoneTypes) { addContact(null, null, phoneNumbers, phoneTypes, null, null, null, null, null, null, null, null, null, null); }