mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
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
This commit is contained in:
parent
07c8b8282e
commit
890394d16f
|
@ -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() {
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue