summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Chan <mchan@android.com>2012-08-17 17:32:58 -0700
committerMichael Chan <mchan@android.com>2012-08-17 17:55:08 -0700
commitbb6d9279d8c0f0fb746160ad428da4738ece175e (patch)
tree41aa5536c96a2ed5622f9debf4da792ebf8a3e8f /src
parenta6ff5f0570e63e46a085bc82dc4256517e248f88 (diff)
downloadandroid_packages_apps_Calendar-bb6d9279d8c0f0fb746160ad428da4738ece175e.tar.gz
android_packages_apps_Calendar-bb6d9279d8c0f0fb746160ad428da4738ece175e.tar.bz2
android_packages_apps_Calendar-bb6d9279d8c0f0fb746160ad428da4738ece175e.zip
Switch from switch to if-else to be compatible with the new ADT
Change-Id: Idd1d803d3edc1eb0294a63480731b5d28a65c4e8
Diffstat (limited to 'src')
-rw-r--r--src/com/android/calendar/AllInOneActivity.java100
-rw-r--r--src/com/android/calendar/CalendarSettingsActivity.java21
-rw-r--r--src/com/android/calendar/EventInfoFragment.java70
-rw-r--r--src/com/android/calendar/SearchActivity.java32
-rw-r--r--src/com/android/calendar/event/EditEventFragment.java35
-rw-r--r--src/com/android/calendar/selectcalendars/SelectSyncedCalendarsMultiAccountActivity.java20
6 files changed, 129 insertions, 149 deletions
diff --git a/src/com/android/calendar/AllInOneActivity.java b/src/com/android/calendar/AllInOneActivity.java
index 549fb4e5..05fc0859 100644
--- a/src/com/android/calendar/AllInOneActivity.java
+++ b/src/com/android/calendar/AllInOneActivity.java
@@ -48,7 +48,6 @@ import android.database.ContentObserver;
import android.database.Cursor;
import android.graphics.drawable.LayerDrawable;
import android.net.Uri;
-import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.provider.CalendarContract;
@@ -782,56 +781,55 @@ public class AllInOneActivity extends Activity implements EventHandler,
Time t = null;
int viewType = ViewType.CURRENT;
long extras = CalendarController.EXTRA_GOTO_TIME;
- switch (item.getItemId()) {
- case R.id.action_refresh:
- mController.refreshCalendars();
- return true;
- case R.id.action_today:
- viewType = ViewType.CURRENT;
- t = new Time(mTimeZone);
- t.setToNow();
- extras |= CalendarController.EXTRA_GOTO_TODAY;
- break;
- case R.id.action_create_event:
- t = new Time();
- t.set(mController.getTime());
- if (t.minute > 30) {
- t.hour++;
- t.minute = 0;
- } else if (t.minute > 0 && t.minute < 30) {
- t.minute = 30;
- }
- mController.sendEventRelatedEvent(
- this, EventType.CREATE_EVENT, -1, t.toMillis(true), 0, 0, 0, -1);
- return true;
- case R.id.action_select_visible_calendars:
- mController.sendEvent(this, EventType.LAUNCH_SELECT_VISIBLE_CALENDARS, null, null,
- 0, 0);
- return true;
- case R.id.action_settings:
- mController.sendEvent(this, EventType.LAUNCH_SETTINGS, null, null, 0, 0);
- return true;
- case R.id.action_hide_controls:
- mHideControls = !mHideControls;
- Utils.setSharedPreference(
- this, GeneralPreferences.KEY_SHOW_CONTROLS, !mHideControls);
- item.setTitle(mHideControls ? mShowString : mHideString);
- if (!mHideControls) {
- mMiniMonth.setVisibility(View.VISIBLE);
- mCalendarsList.setVisibility(View.VISIBLE);
- mMiniMonthContainer.setVisibility(View.VISIBLE);
- }
- final ObjectAnimator slideAnimation = ObjectAnimator.ofInt(this, "controlsOffset",
- mHideControls ? 0 : mControlsAnimateWidth,
- mHideControls ? mControlsAnimateWidth : 0);
- slideAnimation.setDuration(mCalendarControlsAnimationTime);
- ObjectAnimator.setFrameDelay(0);
- slideAnimation.start();
- return true;
- case R.id.action_search:
- return false;
- default:
- return mExtensions.handleItemSelected(item, this);
+ final int itemId = item.getItemId();
+ if (itemId == R.id.action_refresh) {
+ mController.refreshCalendars();
+ return true;
+ } else if (itemId == R.id.action_today) {
+ viewType = ViewType.CURRENT;
+ t = new Time(mTimeZone);
+ t.setToNow();
+ extras |= CalendarController.EXTRA_GOTO_TODAY;
+ } else if (itemId == R.id.action_create_event) {
+ t = new Time();
+ t.set(mController.getTime());
+ if (t.minute > 30) {
+ t.hour++;
+ t.minute = 0;
+ } else if (t.minute > 0 && t.minute < 30) {
+ t.minute = 30;
+ }
+ mController.sendEventRelatedEvent(
+ this, EventType.CREATE_EVENT, -1, t.toMillis(true), 0, 0, 0, -1);
+ return true;
+ } else if (itemId == R.id.action_select_visible_calendars) {
+ mController.sendEvent(this, EventType.LAUNCH_SELECT_VISIBLE_CALENDARS, null, null,
+ 0, 0);
+ return true;
+ } else if (itemId == R.id.action_settings) {
+ mController.sendEvent(this, EventType.LAUNCH_SETTINGS, null, null, 0, 0);
+ return true;
+ } else if (itemId == R.id.action_hide_controls) {
+ mHideControls = !mHideControls;
+ Utils.setSharedPreference(
+ this, GeneralPreferences.KEY_SHOW_CONTROLS, !mHideControls);
+ item.setTitle(mHideControls ? mShowString : mHideString);
+ if (!mHideControls) {
+ mMiniMonth.setVisibility(View.VISIBLE);
+ mCalendarsList.setVisibility(View.VISIBLE);
+ mMiniMonthContainer.setVisibility(View.VISIBLE);
+ }
+ final ObjectAnimator slideAnimation = ObjectAnimator.ofInt(this, "controlsOffset",
+ mHideControls ? 0 : mControlsAnimateWidth,
+ mHideControls ? mControlsAnimateWidth : 0);
+ slideAnimation.setDuration(mCalendarControlsAnimationTime);
+ ObjectAnimator.setFrameDelay(0);
+ slideAnimation.start();
+ return true;
+ } else if (itemId == R.id.action_search) {
+ return false;
+ } else {
+ return mExtensions.handleItemSelected(item, this);
}
mController.sendEvent(this, EventType.GO_TO, t, null, t, -1, viewType, extras, null, null);
return true;
diff --git a/src/com/android/calendar/CalendarSettingsActivity.java b/src/com/android/calendar/CalendarSettingsActivity.java
index 97176485..0a1b90e5 100644
--- a/src/com/android/calendar/CalendarSettingsActivity.java
+++ b/src/com/android/calendar/CalendarSettingsActivity.java
@@ -72,17 +72,16 @@ public class CalendarSettingsActivity extends PreferenceActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- finish();
- return true;
- case R.id.action_add_account:
- Intent nextIntent = new Intent(Settings.ACTION_ADD_ACCOUNT);
- final String[] array = { "com.android.calendar" };
- nextIntent.putExtra(Settings.EXTRA_AUTHORITIES, array);
- nextIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(nextIntent);
- return true;
+ if (item.getItemId() == android.R.id.home) {
+ finish();
+ return true;
+ } else if (item.getItemId() == R.id.action_add_account) {
+ Intent nextIntent = new Intent(Settings.ACTION_ADD_ACCOUNT);
+ final String[] array = { "com.android.calendar" };
+ nextIntent.putExtra(Settings.EXTRA_AUTHORITIES, array);
+ nextIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ startActivity(nextIntent);
+ return true;
}
return super.onOptionsItemSelected(item);
}
diff --git a/src/com/android/calendar/EventInfoFragment.java b/src/com/android/calendar/EventInfoFragment.java
index ce162db5..2ea59af8 100644
--- a/src/com/android/calendar/EventInfoFragment.java
+++ b/src/com/android/calendar/EventInfoFragment.java
@@ -43,7 +43,6 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Rect;
-import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
@@ -65,7 +64,6 @@ import android.text.format.Time;
import android.text.method.LinkMovementMethod;
import android.text.method.MovementMethod;
import android.text.style.ForegroundColorSpan;
-import android.text.style.StyleSpan;
import android.text.style.URLSpan;
import android.text.util.Linkify;
import android.text.util.Rfc822Token;
@@ -958,32 +956,28 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange
// Delete button - start a delete query that calls a runnable that close
// the info activity
- switch (item.getItemId()) {
- case android.R.id.home:
- Utils.returnToCalendarHome(mContext);
- mActivity.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.putExtra(EXTRA_EVENT_ALL_DAY, mAllDay);
- intent.setClass(mActivity, EditEventActivity.class);
- intent.putExtra(EVENT_EDIT_ON_LAUNCH, true);
- startActivity(intent);
- mActivity.finish();
- break;
- case R.id.info_action_delete:
- mDeleteHelper =
- new DeleteEventHelper(mActivity, mActivity, true /* exitWhenDone */);
- mDeleteHelper.setDeleteNotificationListener(EventInfoFragment.this);
- mDeleteHelper.setOnDismissListener(createDeleteOnDismissListener());
- mDeleteDialogVisible = true;
- mDeleteHelper.delete(mStartMillis, mEndMillis, mEventId, -1, onDeleteRunnable);
- break;
- default:
- break;
+ final int itemId = item.getItemId();
+ if (itemId == android.R.id.home) {
+ Utils.returnToCalendarHome(mContext);
+ mActivity.finish();
+ return true;
+ } else if (itemId == 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.putExtra(EXTRA_EVENT_ALL_DAY, mAllDay);
+ intent.setClass(mActivity, EditEventActivity.class);
+ intent.putExtra(EVENT_EDIT_ON_LAUNCH, true);
+ startActivity(intent);
+ mActivity.finish();
+ } else if (itemId == R.id.info_action_delete) {
+ mDeleteHelper =
+ new DeleteEventHelper(mActivity, mActivity, true /* exitWhenDone */);
+ mDeleteHelper.setDeleteNotificationListener(EventInfoFragment.this);
+ mDeleteHelper.setOnDismissListener(createDeleteOnDismissListener());
+ mDeleteDialogVisible = true;
+ mDeleteHelper.delete(mStartMillis, mEndMillis, mEventId, -1, onDeleteRunnable);
}
return super.onOptionsItemSelected(item);
}
@@ -1107,18 +1101,14 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange
public static int getResponseFromButtonId(int buttonId) {
int response;
- switch (buttonId) {
- case R.id.response_yes:
- response = Attendees.ATTENDEE_STATUS_ACCEPTED;
- break;
- case R.id.response_maybe:
- response = Attendees.ATTENDEE_STATUS_TENTATIVE;
- break;
- case R.id.response_no:
- response = Attendees.ATTENDEE_STATUS_DECLINED;
- break;
- default:
- response = Attendees.ATTENDEE_STATUS_NONE;
+ if (buttonId == R.id.response_yes) {
+ response = Attendees.ATTENDEE_STATUS_ACCEPTED;
+ } else if (buttonId == R.id.response_maybe) {
+ response = Attendees.ATTENDEE_STATUS_TENTATIVE;
+ } else if (buttonId == R.id.response_no) {
+ response = Attendees.ATTENDEE_STATUS_DECLINED;
+ } else {
+ response = Attendees.ATTENDEE_STATUS_NONE;
}
return response;
}
diff --git a/src/com/android/calendar/SearchActivity.java b/src/com/android/calendar/SearchActivity.java
index ef175e7b..4775b8d7 100644
--- a/src/com/android/calendar/SearchActivity.java
+++ b/src/com/android/calendar/SearchActivity.java
@@ -273,22 +273,22 @@ public class SearchActivity extends Activity implements CalendarController.Event
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Time t = null;
- switch (item.getItemId()) {
- case R.id.action_today:
- t = new Time();
- t.setToNow();
- mController.sendEvent(this, EventType.GO_TO, t, null, -1, ViewType.CURRENT);
- return true;
- case R.id.action_search:
- return false;
- case R.id.action_settings:
- mController.sendEvent(this, EventType.LAUNCH_SETTINGS, null, null, 0, 0);
- return true;
- case android.R.id.home:
- Utils.returnToCalendarHome(this);
- return true;
- default:
- return false;
+ final int itemId = item.getItemId();
+ if (itemId == R.id.action_today) {
+ t = new Time();
+ t.setToNow();
+ mController.sendEvent(this, EventType.GO_TO, t, null, -1, ViewType.CURRENT);
+ return true;
+ } else if (itemId == R.id.action_search) {
+ return false;
+ } else if (itemId == R.id.action_settings) {
+ mController.sendEvent(this, EventType.LAUNCH_SETTINGS, null, null, 0, 0);
+ return true;
+ } else if (itemId == android.R.id.home) {
+ Utils.returnToCalendarHome(this);
+ return true;
+ } else {
+ return false;
}
}
diff --git a/src/com/android/calendar/event/EditEventFragment.java b/src/com/android/calendar/event/EditEventFragment.java
index 310010eb..50b80528 100644
--- a/src/com/android/calendar/event/EditEventFragment.java
+++ b/src/com/android/calendar/event/EditEventFragment.java
@@ -510,33 +510,30 @@ public class EditEventFragment extends Fragment implements EventHandler {
* @return whether the event was handled here
*/
private boolean onActionBarItemSelected(int itemId) {
- switch (itemId) {
- case R.id.action_done:
- if (EditEventHelper.canModifyEvent(mModel) || EditEventHelper.canRespond(mModel)) {
- if (mView != null && mView.prepareForSave()) {
- if (mModification == Utils.MODIFY_UNINITIALIZED) {
- mModification = Utils.MODIFY_ALL;
- }
- mOnDone.setDoneCode(Utils.DONE_SAVE | Utils.DONE_EXIT);
- mOnDone.run();
- } else {
- mOnDone.setDoneCode(Utils.DONE_REVERT);
- mOnDone.run();
+ if (itemId == R.id.action_done) {
+ if (EditEventHelper.canModifyEvent(mModel) || EditEventHelper.canRespond(mModel)) {
+ if (mView != null && mView.prepareForSave()) {
+ if (mModification == Utils.MODIFY_UNINITIALIZED) {
+ mModification = Utils.MODIFY_ALL;
}
- } else if (EditEventHelper.canAddReminders(mModel) && mModel.mId != -1
- && mOriginalModel != null && mView.prepareForSave()) {
- saveReminders();
- mOnDone.setDoneCode(Utils.DONE_EXIT);
+ mOnDone.setDoneCode(Utils.DONE_SAVE | Utils.DONE_EXIT);
mOnDone.run();
} else {
mOnDone.setDoneCode(Utils.DONE_REVERT);
mOnDone.run();
}
- break;
- case R.id.action_cancel:
+ } else if (EditEventHelper.canAddReminders(mModel) && mModel.mId != -1
+ && mOriginalModel != null && mView.prepareForSave()) {
+ saveReminders();
+ mOnDone.setDoneCode(Utils.DONE_EXIT);
+ mOnDone.run();
+ } else {
mOnDone.setDoneCode(Utils.DONE_REVERT);
mOnDone.run();
- break;
+ }
+ } else if (itemId == R.id.action_cancel) {
+ mOnDone.setDoneCode(Utils.DONE_REVERT);
+ mOnDone.run();
}
return true;
}
diff --git a/src/com/android/calendar/selectcalendars/SelectSyncedCalendarsMultiAccountActivity.java b/src/com/android/calendar/selectcalendars/SelectSyncedCalendarsMultiAccountActivity.java
index 9ec8f9c8..c89387c9 100644
--- a/src/com/android/calendar/selectcalendars/SelectSyncedCalendarsMultiAccountActivity.java
+++ b/src/com/android/calendar/selectcalendars/SelectSyncedCalendarsMultiAccountActivity.java
@@ -16,9 +16,6 @@
package com.android.calendar.selectcalendars;
-import com.android.calendar.R;
-import com.android.calendar.Utils;
-
import android.app.ActionBar;
import android.app.ExpandableListActivity;
import android.content.ContentResolver;
@@ -31,6 +28,9 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.ExpandableListView;
+import com.android.calendar.R;
+import com.android.calendar.Utils;
+
public class SelectSyncedCalendarsMultiAccountActivity extends ExpandableListActivity
implements View.OnClickListener {
@@ -81,15 +81,11 @@ public class SelectSyncedCalendarsMultiAccountActivity extends ExpandableListAct
@Override
public void onClick(View view) {
- switch (view.getId()) {
- case R.id.btn_done:
- mAdapter.doSaveAction();
- finish();
- break;
-
- case R.id.btn_discard:
- finish();
- break;
+ if (view.getId() == R.id.btn_done) {
+ mAdapter.doSaveAction();
+ finish();
+ } else if (view.getId() == R.id.btn_discard) {
+ finish();
}
}