diff options
author | Andy Doan <andy.doan@linaro.org> | 2011-10-27 11:14:14 -0500 |
---|---|---|
committer | Andy Doan <andy.doan@linaro.org> | 2011-10-27 11:14:14 -0500 |
commit | 3430dea7711f35e2cdf478a57a25bb7f04d1e2a4 (patch) | |
tree | 342bc28be83b084e4ec605e3c37e3ceab04e25f8 | |
parent | 46c60edce5506e0b78a0ccb48d9408ea40c7676f (diff) | |
download | LinaroConnect-3430dea7711f35e2cdf478a57a25bb7f04d1e2a4.tar.gz |
support adding schedule items to calendar
this adds the ability to create a calendar entry for
an item in your schedule
-rw-r--r-- | res/layout/schedule_item_activity.xml | 7 | ||||
-rw-r--r-- | res/values/strings.xml | 1 | ||||
-rw-r--r-- | src/org/linaro/connect/ScheduleItemActivity.java | 35 | ||||
-rw-r--r-- | src/org/linaro/connect/sched/ScheduleItem.java | 8 |
4 files changed, 45 insertions, 6 deletions
diff --git a/res/layout/schedule_item_activity.xml b/res/layout/schedule_item_activity.xml index c222250..29134a1 100644 --- a/res/layout/schedule_item_activity.xml +++ b/res/layout/schedule_item_activity.xml @@ -52,4 +52,11 @@ android:background="@drawable/rounded" android:textColor="@color/dark_text" /> + <Button android:id="@+id/schedule_item_add" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:textSize="10sp" + android:layout_gravity="right" + android:layout_marginTop="15px" + android:text="@string/schedule_item_add"/> </LinearLayout> diff --git a/res/values/strings.xml b/res/values/strings.xml index 78057a8..b526e21 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -3,6 +3,7 @@ <string name="app_name">Linaro Connect</string> <string name="posting_refresh">Refresh</string> <string name="schedule_item">Linaro Connect - Session</string> + <string name="schedule_item_add">Add To Calendar</string> <string name="schedule_mine">Linaro Connect - My Schedule</string> <string name="my_schedule_lp">Launchpad Login</string> diff --git a/src/org/linaro/connect/ScheduleItemActivity.java b/src/org/linaro/connect/ScheduleItemActivity.java index 35fff73..a555061 100644 --- a/src/org/linaro/connect/ScheduleItemActivity.java +++ b/src/org/linaro/connect/ScheduleItemActivity.java @@ -5,10 +5,14 @@ import org.linaro.connect.sched.ScheduleItem; import android.app.Activity; import android.content.Intent; import android.os.Bundle; +import android.view.View; +import android.widget.Button; import android.widget.TextView; public class ScheduleItemActivity extends Activity { + private ScheduleItem mItem; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -16,24 +20,43 @@ public class ScheduleItemActivity extends Activity { setContentView(R.layout.schedule_item_activity); Intent i = getIntent(); - ScheduleItem si = (ScheduleItem)i.getSerializableExtra(ScheduleItem.INTENT_FIELD); + mItem = (ScheduleItem)i.getSerializableExtra(ScheduleItem.INTENT_FIELD); - setTextView(R.id.schedule_item_summary, si.getSummary()); - setTextView(R.id.schedule_item_time, si.getStartTime(null)); - setTextView(R.id.schedule_item_room, si.getLocation()); - setTextView(R.id.schedule_item_desc, si.getDescription()); + setTextView(R.id.schedule_item_summary, mItem.getSummary()); + setTextView(R.id.schedule_item_time, mItem.getStartTime(null)); + setTextView(R.id.schedule_item_room, mItem.getLocation()); + setTextView(R.id.schedule_item_desc, mItem.getDescription()); StringBuffer sb = new StringBuffer(); - for(String s: si.getCategories()) { + for(String s: mItem.getCategories()) { if(sb.length() > 0) sb.append(", "); sb.append(s); } setTextView(R.id.schedule_item_categories, sb.toString()); + + Button b = (Button)findViewById(R.id.schedule_item_add); + b.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + addToCalendar(); + } + }); } private void setTextView(int id, String val) { TextView tv = (TextView)findViewById(id); tv.setText(val); } + + private void addToCalendar() { + Intent intent = new Intent(Intent.ACTION_EDIT); + intent.setType("vnd.android.cursor.item/event"); + intent.putExtra("title", mItem.getSummary()); + intent.putExtra("description", mItem.getDescription()); + intent.putExtra("eventLocation", mItem.getLocation()); + intent.putExtra("beginTime", mItem.getStartInMillis()); + intent.putExtra("endTime", mItem.getEndInMillis()); + startActivity(intent); + } } diff --git a/src/org/linaro/connect/sched/ScheduleItem.java b/src/org/linaro/connect/sched/ScheduleItem.java index e4f8d7c..a6f7366 100644 --- a/src/org/linaro/connect/sched/ScheduleItem.java +++ b/src/org/linaro/connect/sched/ScheduleItem.java @@ -64,6 +64,14 @@ public class ScheduleItem implements Serializable { return Uri.parse(getUrl()); } + public long getStartInMillis() { + return getDate("DTSTART").getTime(); + } + + public long getEndInMillis() { + return getDate("DTEND").getTime(); + } + private Date getDate(String field) { String s = mFields.get(field); Time t = new Time(); |