From 4afba187f8990ae2b3afaf8fcdb6039f231f4914 Mon Sep 17 00:00:00 2001 From: James Kung Date: Tue, 18 Dec 2012 23:12:08 -0800 Subject: Color picker for events Bug: 3439638 Change-Id: I46ac6816ab887290f67bacf2faa1a9ed73ff7d6b --- src/com/android/calendar/EventInfoActivity.java | 70 ++++++++----------------- 1 file changed, 23 insertions(+), 47 deletions(-) (limited to 'src/com/android/calendar/EventInfoActivity.java') diff --git a/src/com/android/calendar/EventInfoActivity.java b/src/com/android/calendar/EventInfoActivity.java index 2b4c8a13..a0a126f6 100644 --- a/src/com/android/calendar/EventInfoActivity.java +++ b/src/com/android/calendar/EventInfoActivity.java @@ -25,8 +25,11 @@ import android.app.FragmentManager; import android.app.FragmentTransaction; import android.content.Intent; import android.content.res.Resources; +import android.database.ContentObserver; import android.net.Uri; import android.os.Bundle; +import android.os.Handler; +import android.provider.CalendarContract; import android.provider.CalendarContract.Attendees; import android.util.Log; import android.widget.Toast; @@ -42,6 +45,23 @@ public class EventInfoActivity extends Activity { private long mStartMillis, mEndMillis; private long mEventId; + // Create an observer so that we can update the views whenever a + // Calendar event changes. + private final ContentObserver mObserver = new ContentObserver(new Handler()) { + @Override + public boolean deliverSelfNotifications() { + return false; + } + + @Override + public void onChange(boolean selfChange) { + if (selfChange) return; + if (mInfoFragment != null) { + mInfoFragment.reloadEvents(); + } + } + }; + @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); @@ -135,53 +155,6 @@ public class EventInfoActivity extends Activity { } } -// @Override -// public boolean onOptionsItemSelected(MenuItem item) { -// -// // Handles option menu selections: -// // Home button - close event info activity and start the main calendar one -// // Edit button - start the event edit activity and close the info activity -// // Delete button - start a delete query that calls a runnable that close the info activity -// -// switch (item.getItemId()) { -// case android.R.id.home: -// Intent launchIntent = new Intent(); -// launchIntent.setAction(Intent.ACTION_VIEW); -// launchIntent.setData(Uri.parse(CalendarContract.CONTENT_URI + "/time")); -// launchIntent.setFlags( -// Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP); -// startActivity(launchIntent); -// finish(); -// return true; -// case R.id.info_action_edit: -// Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, mEventId); -// Intent intent = new Intent(Intent.ACTION_EDIT, uri); -// intent.putExtra(EXTRA_EVENT_BEGIN_TIME, mStartMillis); -// intent.putExtra(EXTRA_EVENT_END_TIME, mEndMillis); -// intent.setClass(this, EditEventActivity.class); -// intent.putExtra(EVENT_EDIT_ON_LAUNCH, true); -// startActivity(intent); -// finish (); -// break; -// case R.id.info_action_delete: -// DeleteEventHelper deleteHelper = new DeleteEventHelper( -// this, this, true /* exitWhenDone */); -// deleteHelper.delete(mStartMillis, mEndMillis, mEventId, -1, onDeleteRunnable); -// break; -// default: -// break; -// } -// return super.onOptionsItemSelected(item); -// } - - // runs at the end of a delete action and closes the activity -// private Runnable onDeleteRunnable = new Runnable() { -// @Override -// public void run() { -// finish (); -// } -// }; - @Override protected void onNewIntent(Intent intent) { // From the Android Dev Guide: "It's important to note that when @@ -202,11 +175,14 @@ public class EventInfoActivity extends Activity { @Override protected void onResume() { super.onResume(); + getContentResolver().registerContentObserver(CalendarContract.Events.CONTENT_URI, + true, mObserver); } @Override protected void onPause() { super.onPause(); + getContentResolver().unregisterContentObserver(mObserver); } @Override -- cgit v1.2.3